private void RequestActiveZombie(ZombieAgent zombie, PlayerZone zone) { ZombieSpawnRequest spawn = new ZombieSpawnRequest(); spawn.zombie = zombie; spawn.zone = zone; lock (_spawnQueue) { _spawnQueue.Enqueue(spawn); } }
void RequestActiveZombie(ZombieAgent zombie, PlayerZone zone) { zombie.state = ZombieAgent.State.Active; ZombieSpawnRequest spawn = new ZombieSpawnRequest(); spawn.zombie = zombie; spawn.zone = zone; lock (_spawnQueue) { _spawnQueue.Enqueue(spawn); } }
void ProcessSpawnQueue() { for (int i = 0; i < MaxZombieSpawnsPerTick; i++) { ZombieSpawnRequest zombieSpawn = null; lock (_spawnQueue) { if (_spawnQueue.Count == 0) { break; } zombieSpawn = _spawnQueue.Dequeue(); } if (!CreateZombie(zombieSpawn.zombie, zombieSpawn.zone)) { // Failed to spawn zombie, keep population size. RespawnInactiveZombie(zombieSpawn.zombie); } } }