public MapState Apply(ApplicableOperator op) { this.applicableConnections.Remove(op); RoomDoor roomDoor = op.sourceRoomDoor; RoomDoor otherRoom = op.connectionRoomDoor; openDoors.Remove(roomDoor); lastDoor = roomDoor; otherRoom.room.roomId = rooms.Count; MapState newState = new MapState(); foreach (Room room in rooms) { if (room.roomId == roomDoor.room.roomId) { Room clonedRoom = roomDoor.room.clone(); Door clonedDoor = clonedRoom.GetDoor(roomDoor.door.doorId); Room.ConnectDoors(clonedRoom, clonedDoor, otherRoom.room, otherRoom.door); newState.AddRoom(clonedRoom); } else { newState.AddRoom(room.clone()); } } newState.AddRoom(otherRoom.room); return(newState); }
public MapState clone() { MapState state = new MapState(); foreach (Room room in rooms) { state.AddRoom(room.clone()); } return(state); }