internal Locker(MapGeneration.Distributors.Locker vanillalocker) { locker = vanillalocker; for (ushort i = 0; i < locker.Chambers.Count(); i++) { Chambers.Add(new LockerChamber(locker.Chambers[i], this, i)); } }
private Room GetRandomChamber() { var availableChambers = Chambers.Where(c => GetOccupiedSideCount(c) < 4).ToList(); if (availableChambers.Count == 0) { return(null); } return(availableChambers[Random.Next(0, availableChambers.Count)]); }
/// <summary> /// Creates a copy of this instance /// </summary> /// <returns>A copy of this instance</returns> public object Clone() { return(new Heat { Beds = Beds.Select(bed => (BedOrChamber)bed?.Clone()).ToList(), Chambers = Chambers.Select(chamber => (BedOrChamber)chamber?.Clone()).ToList(), ColdExtrudeTemperature = ColdExtrudeTemperature, ColdRetractTemperature = ColdRetractTemperature, Extra = Extra.Select(extra => (ExtraHeater)extra.Clone()).ToList(), Heaters = Heaters.Select(heater => (Heater)heater.Clone()).ToList() }); }
private void CreateChamberTree(Rectangle startingChamber) { int chamberNumber = Utilities.RandomNumber(MinChambers, MaxChambers); Chambers.Add(startingChamber); int attempts = 0; while (Chambers.Count < chamberNumber && attempts < 100) { int n = 0; while (n < Chambers.Count) { AddRandomNeighborChamber(Chambers[n]); n++; } attempts++; } }
private void AddRandomNeighborChamber(Rectangle chamber) { Point passage = new Point(0, 0); int nborWidth = Utilities.RandomNumber(MinChamberWidth, MaxChamberWidth); int nborHeight = Utilities.RandomNumber(MinChamberHeight, MaxChamberHeight); Point nborPos = new Point(0, 0); switch (Utilities.RandomNumber(1, 4)) { case 1: passage = PassageNorth(chamber); nborPos = ChamberNorth(passage, nborWidth, nborHeight); break; case 2: passage = PassageSouth(chamber); nborPos = ChamberSouth(passage, nborWidth); break; case 3: passage = PassageWest(chamber); nborPos = ChamberWest(passage, nborWidth, nborHeight); break; case 4: passage = PassageEast(chamber); nborPos = ChamberEast(passage, nborHeight); break; default: break; } Rectangle neighbor = new Rectangle(nborPos, new Point(nborWidth, nborHeight)); if (CanFitChamber(GetChamberWithWalls(neighbor)) && (ForceRegularChambers && !ChamberIntersects(GetChamberWithWalls(neighbor)) || !ForceRegularChambers && !ChamberIntersects(neighbor))) { Chambers.Add(neighbor); Passages.Add(passage); } }
private bool ChamberIntersects(Rectangle chamber) { return(Chambers.Where(i => GetChamberWithWalls(i).Intersects(chamber)).Any()); }