Added code comment for #246
This commit is contained in:
parent
fda8cc532e
commit
f7072acdd2
@ -39,10 +39,10 @@ export default class ZoneUpdateEvent {
|
||||
) {}
|
||||
|
||||
public listen(): void {
|
||||
this.socket.on('gm:zone_editor:zone:update', this.handleZoneUpdate.bind(this))
|
||||
this.socket.on('gm:zone_editor:zone:update', this.handleEvent.bind(this))
|
||||
}
|
||||
|
||||
private async handleZoneUpdate(data: IPayload, callback: (response: Zone | null) => void): Promise<void> {
|
||||
private async handleEvent(data: IPayload, callback: (response: Zone | null) => void): Promise<void> {
|
||||
try {
|
||||
const character = await CharacterRepository.getById(this.socket.characterId as number)
|
||||
if (!character) {
|
||||
@ -146,6 +146,9 @@ export default class ZoneUpdateEvent {
|
||||
|
||||
callback(zone)
|
||||
|
||||
/**
|
||||
* @TODO #246: Reload zone for players who are currently in the zone
|
||||
*/
|
||||
zoneManager.unloadZone(data.zoneId)
|
||||
await zoneManager.loadZone(zone)
|
||||
} catch (error: any) {
|
||||
|
@ -2,33 +2,31 @@ import config from '../config'
|
||||
|
||||
class Rotation {
|
||||
static calculate(X1: number, Y1: number, X2: number, Y2: number): number {
|
||||
let rotation = 0
|
||||
|
||||
if (config.ALLOW_DIAGONAL_MOVEMENT) {
|
||||
// Check diagonal movements
|
||||
if (X1 > X2 && Y1 > Y2) {
|
||||
rotation = 7
|
||||
return 7
|
||||
} else if (X1 < X2 && Y1 < Y2) {
|
||||
rotation = 3
|
||||
return 3
|
||||
} else if (X1 > X2 && Y1 < Y2) {
|
||||
rotation = 5
|
||||
return 5
|
||||
} else if (X1 < X2 && Y1 > Y2) {
|
||||
rotation = 1
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
if (rotation === 0) {
|
||||
if (X1 > X2) {
|
||||
rotation = 6
|
||||
} else if (X1 < X2) {
|
||||
rotation = 2
|
||||
} else if (Y1 < Y2) {
|
||||
rotation = 4
|
||||
} else if (Y1 > Y2) {
|
||||
rotation = 0
|
||||
}
|
||||
// Non-diagonal movements
|
||||
if (X1 > X2) {
|
||||
return 6
|
||||
} else if (X1 < X2) {
|
||||
return 2
|
||||
} else if (Y1 < Y2) {
|
||||
return 4
|
||||
} else if (Y1 > Y2) {
|
||||
return 0
|
||||
}
|
||||
|
||||
return rotation
|
||||
return 0 // Default case
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user