New method for events + TP work
This commit is contained in:
@ -57,42 +57,42 @@ class ZoneManager {
|
||||
private isPositionWalkable(zoneId: number, x: number, y: number): boolean {
|
||||
const loadedZone = this.loadedZones.find((lz) => lz.zone.id === zoneId)
|
||||
if (!loadedZone) {
|
||||
console.log(`Zone ${zoneId} not found in loadedZones`);
|
||||
return false;
|
||||
console.log(`Zone ${zoneId} not found in loadedZones`)
|
||||
return false
|
||||
}
|
||||
if (!loadedZone.grid) {
|
||||
console.log(`Grid for zone ${zoneId} is undefined`);
|
||||
return false;
|
||||
console.log(`Grid for zone ${zoneId} is undefined`)
|
||||
return false
|
||||
}
|
||||
if (!loadedZone.grid[y]) {
|
||||
console.log(`Row ${y} in grid for zone ${zoneId} is undefined`);
|
||||
return false;
|
||||
console.log(`Row ${y} in grid for zone ${zoneId} is undefined`)
|
||||
return false
|
||||
}
|
||||
return loadedZone.grid[y][x] === 0;
|
||||
return loadedZone.grid[y][x] === 0
|
||||
}
|
||||
|
||||
public addCharacterToZone(zoneId: number, character: Character) {
|
||||
console.log(`Adding character ${character.id} to zone ${zoneId}`);
|
||||
console.log(`Character position: x=${character.positionX}, y=${character.positionY}`);
|
||||
console.log(`Adding character ${character.id} to zone ${zoneId}`)
|
||||
console.log(`Character position: x=${character.positionX}, y=${character.positionY}`)
|
||||
|
||||
const loadedZone = this.loadedZones.find((loadedZone) => {
|
||||
return loadedZone.zone.id === zoneId
|
||||
})
|
||||
|
||||
if (!loadedZone) {
|
||||
console.log(`Zone ${zoneId} not found in loadedZones`);
|
||||
return;
|
||||
console.log(`Zone ${zoneId} not found in loadedZones`)
|
||||
return
|
||||
}
|
||||
|
||||
if (this.isPositionWalkable(zoneId, character.positionX, character.positionY)) {
|
||||
loadedZone.characters.push(character)
|
||||
console.log(`Character ${character.id} added to zone ${zoneId}`);
|
||||
console.log(`Character ${character.id} added to zone ${zoneId}`)
|
||||
} else {
|
||||
// set position to 0,0 if not walkable
|
||||
console.log(`Position (${character.positionX}, ${character.positionY}) is not walkable in zone ${zoneId}`);
|
||||
character.positionX = 0;
|
||||
character.positionY = 0;
|
||||
loadedZone.characters.push(character);
|
||||
console.log(`Position (${character.positionX}, ${character.positionY}) is not walkable in zone ${zoneId}`)
|
||||
character.positionX = 0
|
||||
character.positionY = 0
|
||||
loadedZone.characters.push(character)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user