remove event listeners in server/client state managers

This commit is contained in:
JohnCorby 2021-12-26 04:51:26 -08:00
parent 9089b5f2a3
commit d27113a4f3
2 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,7 @@ using QSB.Messaging;
using QSB.Player;
using QSB.Player.TransformSync;
using QSB.Utility;
using System;
using UnityEngine;
namespace QSB.ClientServerStateSync
@ -24,6 +25,9 @@ namespace QSB.ClientServerStateSync
() => new ClientStateMessage(ForceGetCurrentState()).Send());
}
private void OnDestroy() =>
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
public void SendChangeClientStateMessage(ClientState newState)
{
ChangeClientState(newState);

View File

@ -4,6 +4,7 @@ using QSB.Messaging;
using QSB.Player;
using QSB.Player.TransformSync;
using QSB.Utility;
using System;
using System.Linq;
using UnityEngine;
@ -36,6 +37,12 @@ namespace QSB.ClientServerStateSync
() => new ServerStateMessage(ForceGetCurrentState()).Send());
}
private void OnDestroy()
{
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
GlobalMessenger.RemoveListener("TriggerSupernova", OnTriggerSupernova);
}
public void SendChangeServerStateMessage(ServerState newState)
{
ChangeServerState(newState);