public void DestroySpawner(RegisteredSpawner spawner) { var peer = spawner.Peer; if (peer != null) { var peerRooms = peer.GetProperty((int)MsfPeerPropertyCodes.RegisteredSpawners) as Dictionary <int, RegisteredSpawner>; // Remove the spawner from peer if (peerRooms != null) { peerRooms.Remove(spawner.SpawnerId); } } // Remove the spawner from all spawners spawnersList.Remove(spawner.SpawnerId); // Invoke the event if (OnSpawnerDestroyedEvent != null) { OnSpawnerDestroyedEvent.Invoke(spawner); } }
/// <summary> /// Destroys spawner /// </summary> /// <param name="spawner"></param> public void DestroySpawner(RegisteredSpawner spawner) { // Get spawner owner peer var peer = spawner.Peer; // If peer exists if (peer != null) { // Get spawners from peer property var peerSpawners = peer.GetProperty((int)MstPeerPropertyCodes.RegisteredSpawners) as Dictionary <int, RegisteredSpawner>; // Remove the spawner from peer if (peerSpawners != null) { peerSpawners.Remove(spawner.SpawnerId); } } // Remove the spawner from all spawners spawnersList.Remove(spawner.SpawnerId); // Invoke the event OnSpawnerDestroyedEvent?.Invoke(spawner); }