private static void PopulateZone(EncounterZone zone, int dungeonLevel, Random seededRand, EncounterState state, bool safe = false) { // Add satellites int numSatellites = LevelData.GetNumberOfSatellites(dungeonLevel); for (int i = 0; i < numSatellites; i++) { var unblockedPosition = zone.RandomEmptyPosition(seededRand, state); var satellite = EntityBuilder.CreateSatelliteEntity(); state.PlaceEntity(satellite, unblockedPosition); } EncounterDef encounterDef; if (safe) { encounterDef = LevelData.GetEncounterDefById(EncounterDefId.EMPTY_ENCOUNTER); } else { encounterDef = LevelData.ChooseEncounter(dungeonLevel, seededRand); } zone.ReadoutEncounterName = encounterDef.Name; if (encounterDef.EntityDefIds.Count > 0) { string activationGroupId = Guid.NewGuid().ToString(); foreach (string entityDefId in encounterDef.EntityDefIds) { var unblockedPosition = zone.RandomEmptyPosition(seededRand, state); var newEntity = EntityBuilder.CreateEnemyByEntityDefId(entityDefId, activationGroupId, state.CurrentTick); state.PlaceEntity(newEntity, unblockedPosition); } } var chosenItemDefs = LevelData.ChooseItemDefs(dungeonLevel, seededRand); foreach (string chosenItemDefId in chosenItemDefs) { var unblockedPosition = zone.RandomEmptyPosition(seededRand, state); var newEntity = EntityBuilder.CreateItemByEntityDefId(chosenItemDefId); state.PlaceEntity(newEntity, unblockedPosition); zone.AddItemToReadout(newEntity); } }