diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 2b690dec..9bc84bc6 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -1620,10 +1620,19 @@ private void HealthController_DiedEvent(EDamageType obj) if (FikaPlugin.Instance.ForceSaveOnDeath) { - SavePlayer((CoopPlayer)gparam_0.Player, MyExitStatus, null, true); + StartCoroutine(SaveOnDeathRoutine()); } } + private IEnumerator SaveOnDeathRoutine() + { + Task saveTask = SavePlayer((CoopPlayer)gparam_0.Player, MyExitStatus, null, true); + while (!saveTask.IsCompleted) + { + yield return null; + } + } + public override void Stop(string profileId, ExitStatus exitStatus, string exitName, float delay = 0f) { Logger.LogInfo("CoopGame::Stop"); @@ -1739,11 +1748,11 @@ public override void Stop(string profileId, ExitStatus exitStatus, string exitNa GClass548.Config.UseSpiritPlayer = false; } - private void SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitName, bool fromDeath) + private Task SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitName, bool fromDeath) { if (hasSaved) { - return; + return Task.CompletedTask; } if (fromDeath) @@ -1771,6 +1780,7 @@ private void SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitNam RequestHandler.PutJson("/raid/profile/save", SaveRequest.ToJson(Converters.AddItem(new NotesJsonConverter()).ToArray())); hasSaved = true; + return Task.CompletedTask; } private void StopFromError(string profileId, ExitStatus exitStatus) @@ -1984,12 +1994,8 @@ public void HandleExit() MonoBehaviourSingleton.Instance.FadeOutVolumeAfterRaid(); StaticManager staticManager = StaticManager.Instance; float num = delay; - Action action; - if ((action = EndAction) == null) - { - action = (EndAction = new Action(FireCallback)); - } - staticManager.WaitSeconds(num, action); + EndAction = new Action(FireCallback); + staticManager.WaitSeconds(num, EndAction); } private void FireCallback() @@ -2023,12 +2029,8 @@ public void ExitOverride() } MonoBehaviour instance2 = StaticManager.Instance; float num = delay; - Action action; - if ((action = action_0) == null) - { - action = action_0 = new Action(method_1); - } - instance2.WaitSeconds(num, action); + action_0 = new Action(method_1); + instance2.WaitSeconds(num, action_0); } }