public void DequeuAndSpawnZombies() { var result = Tools.generator.TryGetNextGeneratedZombie(map); if (result == null) { return; } if (ZombieCount() >= GetMaxZombieCount()) { return; } if (Tools.IsValidSpawnLocation(result.cell, result.map) == false) { return; } var existingZombies = result.map.thingGrid.ThingsListAtFast(result.cell).OfType <Zombie>(); if (existingZombies.Any(zombie => zombie.state == ZombieState.Emerging)) { Tools.generator.RequeueZombie(result); return; } ZombieGenerator.FinalizeZombieGeneration(result.zombie); GenPlace.TryPlaceThing(result.zombie, result.cell, result.map, ThingPlaceMode.Direct); result.map.GetGrid().ChangeZombieCount(result.cell, 1); }
public void DequeuAndSpawnZombies() { if (dequeedSpawnCounter-- < 0) { dequeedSpawnCounter = Rand.Range(10, 51); var result = Tools.generator.TryGetNextGeneratedZombie(map); if (result == null) { return; } if (result.isEvent == false && ZombieCount() >= GetMaxZombieCount()) { Tools.generator.RequeueZombie(result); return; } // TODO: if zombie cannot spawn at location, we are wasting it here. // to solve this, we need to find a better location and only if we find // none, we can discard it // if (Tools.IsValidSpawnLocation(result.cell, result.map) == false) { return; } var existingZombies = result.map.thingGrid.ThingsListAtFast(result.cell).OfType <Zombie>(); if (existingZombies.Any(zombie => zombie.state == ZombieState.Emerging)) { Tools.generator.RequeueZombie(result); return; } ZombieGenerator.FinalizeZombieGeneration(result.zombie); GenPlace.TryPlaceThing(result.zombie, result.cell, result.map, ThingPlaceMode.Direct); } }