online fix
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user