/// <summary> /// Creates Rooms by orthogonally dividing the interior of the Story perimeter by a quantity of x-axis and y-axis intervals. /// Adds the new Rooms to the Rooms list. /// New Rooms conform to Corridor and Service perimeters. /// </summary> /// <param name="xRooms">Quantity Rooms along the orthogonal x-axis.</param> /// <param name="yRooms">Quantity Rooms along the orthogonal y-axis.</param> /// <param name="height">Height of the new Rooms.</param> /// <param name="setback">Offset from the Story perimeter.</param> /// <param name="name">String identifier applied to every new Room.</param> /// <param name="color">Rendering color of the Room as a Space.</param> /// <returns> /// None. /// </returns> public void RoomsByDivision(int xRooms = 1, int yRooms = 1, double height = 3.0, double setback = 0.0, string name = "", Color color = null) { if (Perimeter == null) { throw new ArgumentNullException(Messages.PERIMETER_NULL_EXCEPTION); } if (setback < 0.0) { throw new ArgumentNullException(Messages.NONPOSITIVE_VALUE_EXCEPTION); } Rooms.Clear(); var polygon = Perimeter.Offset(setback * -1.0).First(); var roomGroup = new RoomGroup(polygon, xRooms, yRooms, name); roomGroup.SetElevation(Elevation); roomGroup.SetHeight(height); Rooms.AddRange(roomGroup.Rooms); RoomsColor = color; FitRoomsToServices(); FitRoomsToCorridors(); }
/// <summary> /// Adds a Room to the Rooms list. /// </summary> /// <param name="room">Room to add.</param> /// <param name="fit">Indicates whether the new Room should mutually fit to other Story features. Default is true.</param> /// <returns> /// True if one or more Rooms were added to the Story. /// </returns> public bool AddRoom(Room room, bool fit = true) { if (Perimeter == null || room.Perimeter == null || !Perimeter.Covers(perimeter)) { return(false); } var newRoom = new Room() { Color = room.Color, Elevation = Elevation, Height = room.Height, Name = room.Name, Perimeter = room.Perimeter }; var fitRooms = new List <Room> { newRoom }; if (fit) { var toRooms = new List <Room>(Exclusions); toRooms.AddRange(Services); toRooms.AddRange(Corridors); fitRooms = FitRooms(fitRooms, toRooms); } if (fitRooms.Count == 0) { return(false); } Rooms.AddRange(fitRooms); return(true); }
public void ResetWithHome(HMHome home) { Accessories.Clear(); Accessories.AddRange(home.Accessories); Accessories.SortByLocalizedName(a => a.Name); Rooms.Clear(); Rooms.AddRange(home.GetAllRooms()); Rooms.SortByLocalizedName(r => r.Name); Zones.Clear(); Zones.AddRange(home.Zones); Zones.SortByLocalizedName(z => z.Name); ActionSets.Clear(); ActionSets.AddRange(home.ActionSets); ActionSets.SortByTypeAndLocalizedName(); Triggers.Clear(); Triggers.AddRange(home.Triggers); Triggers.SortByLocalizedName(t => t.Name); ServiceGroups.Clear(); ServiceGroups.AddRange(home.ServiceGroups); ServiceGroups.SortByLocalizedName(sg => sg.Name); }
public void CreateRooms() { Rooms.AddRange(new List <Room> { new Room("livingroom", "you find yourself in a large dusty livingroom.\nthe wooden floor is uneaven and there are barely any furniture in the room.\n" + "there are two doors, one to the north and one to the east. the northern door seems slightly open.", false), new Room("kitchen", "you find yourself in a small kitchen.\nthe refrigerator is wide open and you can see it containing smelly leftovers from god-knows-when.\n" + "there is but one door in the kitchen, the southern one you just came from.", false), new Room("cellar", "you find yourself in a pitch black cellar...", true) }); }
public Zone(string id, string name, ZoneTypeEnum type, Room[] rooms = null) : this() { Id = id; Name = name; Type = type; if (rooms != null) { Rooms.AddRange(rooms); } }
/// <summary> /// Private function configuring all Room perimeters to conform to all Service perimeters. /// </summary> /// <returns> /// None. /// </returns> private void FitRoomsToServices() { foreach (Room service in Services) { if (service.Perimeter == null) { continue; } int index = 0; List <int> indices = new List <int>(); var addRooms = new List <Room>(); foreach (Room room in Rooms) { var perimeters = room.Perimeter.Difference(service.Perimeter); if (perimeters != null && perimeters.Count > 0) { room.Perimeter = perimeters.First(); for (int i = 1; i < perimeters.Count; i++) { var addRoom = new Room() { Color = room.Color, Elevation = room.Elevation, Height = room.Height, Name = room.Name, Perimeter = perimeters[i] }; addRooms.Add(addRoom); } } else { indices.Add(index); } index++; } foreach (int remove in indices) { Rooms.RemoveAt(remove); } if (addRooms.Count > 0) { Rooms.AddRange(addRooms); } } }
/// <summary> /// Creates Rooms by orthogonally dividing the interior of the Story perimeter by a quantity of x-axis and y-axis intervals. /// Adds the new Rooms to the Rooms list. /// New Rooms conform to Corridor and Service perimeters. /// </summary> /// <param name="xRooms">Quantity Rooms along the orthogonal x-axis.</param> /// <param name="yRooms">Quantity Rooms along the orthogonal y-axis.</param> /// <param name="height">Height of the new Rooms.</param> /// <param name="setback">Offset from the Story perimeter.</param> /// <param name="name">String identifier applied to every new Room.</param> /// <param name="color">Rendering color of the Room as a Space.</param> /// <returns> /// None. /// </returns> public bool RoomsByDivision(int xRooms = 1, int yRooms = 1, double height = 3.0, double setback = 0.0, string name = "", Color color = null, bool fit = true) { if (Perimeter == null || height < 0.0 || setback < 0.0 || xRooms < 1 || yRooms < 1) { return(false); } var polygon = Perimeter.Offset(setback * -1.0).First(); var roomGroup = new RoomGroup() { Name = name, Perimeter = polygon }; roomGroup.RoomsByDivision(xRooms, yRooms, height, name); roomGroup.Elevation = Elevation; roomGroup.SetHeight(height); roomGroup.SetColor(color); var fitRooms = new List <Room>(roomGroup.Rooms); if (fit) { var toRooms = new List <Room>(Exclusions); toRooms.AddRange(Services); toRooms.AddRange(Corridors); fitRooms = FitRooms(fitRooms, toRooms); } if (fitRooms.Count == 0) { return(false); } Rooms.Clear(); Rooms.AddRange(fitRooms); return(true); }
public async Task RefreshRooms(bool silent = false) { if (IsLoadingRooms) { return; } IsLoadingRooms = silent ? false : true;; await Task.Run(async() => { try { List <Rooms> tempRo = (await _roomsController.GetAllEntries())?.ToList(); IEnumerable <Reservations> tempRes = (await _reservationsController.GetAllEntries()); IEnumerable <Rooms> tempAVRO = from Rooms room in tempRo where tempRes.FirstOrDefault(re => (re.Room_Id == room.ID && re.IsAvailable)) == null select room; if (tempAVRO.Count() <= 0) { if (!silent) { ErrorDialog("Please try later", "No room available"); } } Rooms.AddRange(tempAVRO, true); } catch (Exception e) { if (!silent) { Toast = $"Bad network {e.Message}"; } } finally { IsLoadingRooms = false; } }); }
/// <summary> /// Adds a Room to the Rooms list. /// </summary> /// <param name="room">Room to add.</param> /// <param name="fit">Indicates whether the new room should mutually fit to other Story features. Default is true.</param> /// <returns> /// True if one or more rooms were added to the Story. /// </returns> public bool AddRoom(Room room, bool fit = true) { if (Perimeter == null || room.Perimeter == null) { throw new ArgumentNullException(Messages.PERIMETER_NULL_EXCEPTION); } if (!Perimeter.Covers(perimeter)) { throw new ArgumentNullException(Messages.PERIMETER_PLACEMENT_EXCEPTION); } var newRoom = new Room() { Color = room.Color, Elevation = Elevation, Height = room.Height, Name = room.Name, Perimeter = room.Perimeter }; var fitRooms = new List <Room> { newRoom }; if (fit) { var toRooms = new List <Room>(Exclusions); toRooms.AddRange(Services); toRooms.AddRange(Corridors); fitRooms = FitRooms(fitRooms, toRooms); } if (fitRooms.Count == 0) { return(false); } Rooms.AddRange(fitRooms); return(true); }
/// <summary> /// Clears the current Rooms list and creates new Rooms defined by orthogonal x- and y-axis divisions of the RoomGroup Perimeter. /// </summary> /// <param name="xRooms">The quantity of Rooms along orthogonal x-axis. Must be positive.</param> /// <param name="yRooms">The quantity of Rooms along orthogonal y-axis. Must be positive.</param> /// <returns> /// True if the Rooms are created. /// </returns> public bool RoomsByDivision(int xRooms = 1, int yRooms = 1, double height = 3.0, string name = "") { if (Perimeter == null || xRooms < 1 || yRooms < 1 || height <= 0.0) { return(false); } var sizeX = SizeX / xRooms; var sizeY = SizeY / yRooms; var count = xRooms * yRooms; var box = new TopoBox(Perimeter); var newRooms = new List <Room>(); for (int xIdx = 0; xIdx < xRooms; xIdx++) { var xCoord = box.SW.X + (xIdx * sizeX); for (int yIdx = 0; yIdx < yRooms; yIdx++) { var yCoord = box.SW.Y + (yIdx * sizeY); var polygon = Shaper.Rectangle(sizeX, sizeY); polygon = polygon.MoveFromTo(Vector3.Origin, new Vector3(xCoord, yCoord)).Intersection(Perimeter).First(); var room = new Room() { Height = height, Name = name, Perimeter = polygon }; newRooms.Add(room); } } if (newRooms.Count == 0) { return(false); } Rooms.Clear(); Rooms.AddRange(newRooms); return(true); }
private void SeedRoomTemplates001() { Rooms.AddRange(new[] { new RoomTemplate() { Name = "Elevator", Width = 4, Height = 4, Icon = "vertical_align_center", IsSystemOnly = true }, new RoomTemplate() { Name = "Floor", Width = 1, Height = 1, Icon = "open_with", Price = 0.02 }, new RoomTemplate() { Name = "Developer room, small", Width = 4, Height = 4, WorkplaceMaxCount = 5, Icon = "computer", Price = 2 }, new RoomTemplate() { Name = "Developer room, medium", Width = 8, Height = 4, WorkplaceMaxCount = 11, Icon = "computer", Price = 5 }, new RoomTemplate() { Name = "Developer room, large", Width = 16, Height = 6, WorkplaceMaxCount = 30, Icon = "computer", Price = 15 }, new RoomTemplate() { Name = "Bathroom, small", Width = 1, Height = 2, BathroomMaxCount = 8, Icon = "wc", Price = 1.5 }, new RoomTemplate() { Name = "Bathroom, medium", Width = 2, Height = 2, BathroomMaxCount = 16, Icon = "wc", Price = 2 }, new RoomTemplate() { Name = "Kitchen, small", Width = 1, Height = 2, KitchenMaxCount = 16, Icon = "kitchen", Price = 1.5 }, new RoomTemplate() { Name = "Kitchen, medium", Width = 2, Height = 3, KitchenMaxCount = 32, Icon = "kitchen", Price = 2 }, new RoomTemplate() { Name = "Kitchen, large", Width = 16, Height = 6, KitchenMaxCount = 100, Icon = "kitchen", Price = 10 }, new RoomTemplate() { Name = "Smoking room, small", Width = 2, Height = 2, SmokeMaxCount = 3, Icon = "smoking_rooms", Price = 0.5 }, new RoomTemplate() { Name = "Smoking room, medium", Width = 2, Height = 4, SmokeMaxCount = 7, Icon = "smoking_rooms", Price = 1 }, }); }