public virtual void ToggleDoors(bool secure, bool open) { Doors.ForEachReverse( d => { if (d == null || d.Deleted || d.Map != Map) { Doors.Remove(d); return; } if ((!d.Open || !CanCloseDoor(d)) && (d.Open || !CanOpenDoor(d))) { return; } d.Open = open; d.Locked = secure; if (_DoorTimerField == null) { return; } var t = _DoorTimerField.GetValue(d) as Timer; if (t != null) { t.Stop(); } }); }
private bool ConnectsTo(char facing, int direction, Room room, Door door) { if (facing != 'N' && facing != 'E' && facing != 'S' && facing != 'W') { return(false); } if (!Doors.TryAdd(facing.ToString(), door)) { return(false); } if (!Rooms.TryAdd(facing.ToString(), room)) { Doors.Remove(facing.ToString()); return(false); } return(true); }
public bool AddDoorTo(int direction, Room connection, bool oneWay = false) { // Checks if the door direction exists and outputs the string for that direction if (!Door.Directions.TryGetValue(direction, out string facing)) { return(false); } facing = facing[0].ToString(); // Trys to set the door in this room if (!Doors.TryAdd(facing, new Door(direction, connection, this))) { return(false); } if (!Rooms.TryAdd(facing, connection)) { Doors.Remove(facing); return(false); } if (oneWay) { return(true); } // New opposite direction int oppDir = ((direction < 2) ? 2 : -2); // Checks if the new opposite direction exists and outputs the string for the new direction if (!Door.Directions.TryGetValue(oppDir, out string oppFace)) { return(false); } // Adds the door to the connecting room if (!connection.ConnectsTo(oppFace[0], oppDir, this, new Door(oppDir, this, connection))) { // If the add fails, remove the door from this room as well (we don't want one way doors) Doors.Remove(facing); return(false); } return(true); }
public DoorListViewModel(IDoorService doorService, HubConnection connection) { _doorService = doorService; AddDoorCommand = new DelegateCommand <DoorModel>(OnAddDoor); RemoveDoorCommand = new DelegateCommand <DoorModel>(OnDeleteDoor); EditDoorCommand = new DelegateCommand <DoorModel>(OnEditDoor); _connection = connection; connection.On <DoorModel>("DeleteMessageReceived", obj => { var doorItem = Doors.FirstOrDefault(x => x.Id == obj.Id); Doors.Remove(doorItem); }); connection.On <DoorModel>("AddMessageReceived", obj => { var doorItem = Doors.FirstOrDefault(x => x.Id == obj.Id); if (doorItem == null) { Doors.Add(obj); } }); connection.On <DoorModel>("EditMessageReceived", obj => { var doorItem = Doors.FirstOrDefault(x => x.Id == obj.Id); if (doorItem != null) { doorItem.IsLocked = obj.IsLocked; doorItem.IsOpen = obj.IsOpen; doorItem.Label = obj.Label; } }); }
private void DeleteDoor() { Doors.Remove(SelectedDoor); }
//======================================================================================== // Object management - tools. private void DeleteData(Data data) { if (data is IReferenceable refdata) { refdata.DetachAllReferences(); } switch (data) { case Room d: Rooms.Remove(d); break; case DoorSet d: DoorSets.Remove(d); break; case Door d: Doors.Remove(d); break; case ScrollSet d: ScrollSets.Remove(d); break; case PlmSet d: PlmSets.Remove(d); break; case ScrollPlmData d: ScrollPlmDatas.Remove(d); break; case Background d: Backgrounds.Remove(d); break; case Fx d: Fxs.Remove(d); break; case SaveStation d: SaveStations.Remove(d); break; case LevelData d: LevelDatas.Remove(d); break; case EnemySet d: EnemySets.Remove(d); break; case EnemyGfx d: EnemyGfxs.Remove(d); break; case ScrollAsm d: ScrollAsms.Remove(d); break; case Asm d: DoorAsms.Remove(d); SetupAsms.Remove(d); MainAsms.Remove(d); break; case TileSet d: TileSets.Remove(d); break; case TileTable d: TileTables.Remove(d); break; case TileSheet d: TileSheets.Remove(d); break; case Palette d: Palettes.Remove(d); break; case AreaMap d: AreaMaps.Remove(d); break; default: break; } ChangesMade = true; }