Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Area.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Area extends GameEntity {
* @fires Area#roomRemoved
*/
removeRoom(room) {
this.removeRoomFromMap(room);
this.rooms.delete(room.id);

/**
Expand Down Expand Up @@ -115,6 +116,21 @@ class Area extends GameEntity {
floor.addRoom(x, y, room);
}

removeRoomFromMap(room) {
if (!room.coordinates) {
throw new Error('Room does not have coordinates');
}

const {x, y, z} = room.coordinates;

if (!this.map.has(z)) {
throw new Error(`That floor doesn't exist`);
}

const floor = this.map.get(z);
floor.removeRoom(x, y);
}

/**
* find a room at the given coordinates for this area
* @param {number} x
Expand Down