online fix

This commit is contained in:
2025-10-27 12:37:18 +01:00
parent 96d50bfad5
commit e6759d6610
281 changed files with 7337 additions and 136 deletions

View File

@@ -31,6 +31,7 @@ namespace MegaKoop.Game.Networking
}
private static SteamCharacterStateCache instance;
private static bool isApplicationQuitting;
private readonly Dictionary<int, CharacterState> states = new();
private SteamCoopNetworkManager networkManager;
@@ -40,9 +41,10 @@ namespace MegaKoop.Game.Networking
{
get
{
if (instance == null)
if (instance == null && !isApplicationQuitting)
{
var go = new GameObject("SteamCharacterStateCache");
go.hideFlags = HideFlags.HideAndDontSave;
instance = go.AddComponent<SteamCharacterStateCache>();
DontDestroyOnLoad(go);
}
@@ -68,6 +70,21 @@ namespace MegaKoop.Game.Networking
EnsureSubscription();
}
private void OnDestroy()
{
if (instance == this)
{
Unsubscribe();
states.Clear();
instance = null;
}
}
private void OnApplicationQuit()
{
isApplicationQuitting = true;
}
private void Update()
{
EnsureSubscription();