public virtual void SpawnRandInCandRooms(TGenContext map, SpawnList <RoomHallIndex> spawningRooms, List <TSpawnable> spawns, int successPercent) { while (spawningRooms.Count > 0 && spawns.Count > 0) { int randIndex = spawningRooms.PickIndex(map.Rand); RoomHallIndex roomIndex = spawningRooms.GetSpawn(randIndex); // try to spawn the item if (this.SpawnInRoom(map, roomIndex, spawns[spawns.Count - 1])) { GenContextDebug.DebugProgress("Placed Object"); // remove the item spawn spawns.RemoveAt(spawns.Count - 1); if (successPercent <= 0) { spawningRooms.RemoveAt(randIndex); } else { int newRate = Math.Max(1, spawningRooms.GetSpawnRate(randIndex) * successPercent / 100); spawningRooms.SetSpawnRate(randIndex, newRate); } } else { spawningRooms.RemoveAt(randIndex); } } }
public CategorySpawnChooser(CategorySpawnChooser <T> other) { Spawns = new SpawnDict <string, SpawnList <T> >(); foreach (string key in other.Spawns.GetKeys()) { SpawnList <T> list = new SpawnList <T>(); SpawnList <T> otherList = other.Spawns.GetSpawn(key); for (int ii = 0; ii < otherList.Count; ii++) { list.Add(otherList.GetSpawn(ii), otherList.GetSpawnRate(ii)); } Spawns.Add(key, list, other.Spawns.GetSpawnRate(key)); } }