protected override void OnUnload() { // Stop sending world data to players processNewConnections = false; // Dipose of the world World.OnPlayerKilled -= World_OnPlayerKilled; World.Dispose(); // Unhook from user connection events server.OnUserConnected -= Server_OnUserConnected; server.OnUserDisconnected -= Server_OnUserDisconnected; // Unhook from the custom packet handler server.RemovePacketHook(OnCustomPacket); // Remove remotes channel.RemoveRemoteEvent("Server_ChatItem"); // Unhook component events snapshotComponent.OnWorldSnapshotOutbound -= SnapshotComponent_OnWorldSnapshotOutbound; netPlayerComponent.OnClientInfoReceived -= NetPlayerComponent_OnClientInfoReceived; netPlayerComponent.OnClientLeave -= NetPlayerComponent_OnClientLeave; // Stop the current gamemode if (currentGamemode != null) { currentGamemode.Stop(); currentGamemode = null; } base.OnUnload(); }
void SwitchGamemode(GamemodeType to) { if (currentGamemode != null) { currentGamemode.Stop(); } currentGamemode = null; NetworkedGamemode gamemode; if (gamemodes.TryGetValue(to, out gamemode)) { currentGamemode = gamemode; currentGamemode.Start(); channel.FireEventForAllConnections("Client_SwitchGamemode", (byte)to); } else { DashCMD.WriteError("[MatchScreen] Gamemode type '{0}' is not defined!", to); } }