From: EoF-1141 <61620805+EoF-1141@users.noreply.github.com> Date: Sat, 17 Apr 2021 12:08:25 +0000 (+0200) Subject: Improved FreePlay Modification X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=190ba915fc93307b738e965c393a4036ff463856;p=rhonda%2Ftheotherroles.git Improved FreePlay Modification Custom End Game Criteria will now be skipped in Tutorial Mode --- diff --git a/Source Code/EndGamePatch.cs b/Source Code/EndGamePatch.cs index 72cfff8..1579b04 100644 --- a/Source Code/EndGamePatch.cs +++ b/Source Code/EndGamePatch.cs @@ -202,8 +202,8 @@ namespace TheOtherRoles { class CheckEndCriteriaPatch { public static bool Prefix(ShipStatus __instance) { if (!GameData.Instance) return false; - if (FreePlayFix.isInFreePlay) // if (__instance.DummyLocations != null && __instance.DummyLocations.Count > 0) - return true; // I don't know how to get from ShipStatus GameModes.FreePlay + if (DestroyableSingleton.BMHJGNNOGDM) // InstanceExists | Don't check Custom Criteria when in Tutorial + return true; var statistics = new PlayerStatistics(__instance); if (CheckAndEndGameForChildLose(__instance)) return false; if (CheckAndEndGameForJesterWin(__instance)) return false; @@ -218,14 +218,8 @@ namespace TheOtherRoles { private static bool CheckAndEndGameForChildLose(ShipStatus __instance) { if (Child.triggerChildLose) { - if (!DestroyableSingleton.BMHJGNNOGDM) - { - __instance.enabled = false; - ShipStatus.EABBNOODFGL((GameOverReason)CustomGameOverReason.ChildLose, false); - return true; - } - DestroyableSingleton.CHNDKKBEIDG.ShowPopUp(DestroyableSingleton.CHNDKKBEIDG.GetString(StringNames.GameOverImpostorDead, new Il2CppReferenceArray(0))); - ReviveEveryone(); + __instance.enabled = false; + ShipStatus.EABBNOODFGL((GameOverReason)CustomGameOverReason.ChildLose, false); return true; } return false; @@ -233,14 +227,8 @@ namespace TheOtherRoles { private static bool CheckAndEndGameForJesterWin(ShipStatus __instance) { if (Jester.triggerJesterWin) { - if (!DestroyableSingleton.BMHJGNNOGDM) - { - __instance.enabled = false; - ShipStatus.EABBNOODFGL((GameOverReason)CustomGameOverReason.JesterWin, false); - return true; - } - DestroyableSingleton.CHNDKKBEIDG.ShowPopUp(DestroyableSingleton.CHNDKKBEIDG.GetString(StringNames.GameOverImpostorDead, new Il2CppReferenceArray(0))); - ReviveEveryone(); + __instance.enabled = false; + ShipStatus.EABBNOODFGL((GameOverReason)CustomGameOverReason.JesterWin, false); return true; } return false; @@ -273,24 +261,9 @@ namespace TheOtherRoles { } private static bool CheckAndEndGameForTaskWin(ShipStatus __instance) { - bool localCompletedAllTasks = true; - foreach (PlayerTask t in PlayerControl.LocalPlayer.myTasks) { - localCompletedAllTasks = localCompletedAllTasks && t.FDIIBNGHCAK; - } - - if (!DestroyableSingleton.BMHJGNNOGDM) - { - if (GameData.Instance.TotalTasks <= GameData.Instance.CompletedTasks) - { - __instance.enabled = false; - ShipStatus.EABBNOODFGL(GameOverReason.HumansByTask, false); - return true; - } - } - else if (localCompletedAllTasks) - { - DestroyableSingleton.CHNDKKBEIDG.ShowPopUp(DestroyableSingleton.CHNDKKBEIDG.GetString(StringNames.GameOverTaskWin, new Il2CppReferenceArray(0))); - __instance.Begin(); + if (GameData.Instance.TotalTasks <= GameData.Instance.CompletedTasks) { + __instance.enabled = false; + ShipStatus.EABBNOODFGL(GameOverReason.HumansByTask, false); return true; } return false; @@ -298,14 +271,8 @@ namespace TheOtherRoles { private static bool CheckAndEndGameForLoverWin(ShipStatus __instance, PlayerStatistics statistics) { if (statistics.TeamLoversAlive == 2 && statistics.TotalAlive <= 3) { - if (!DestroyableSingleton.BMHJGNNOGDM) - { - __instance.enabled = false; - ShipStatus.EABBNOODFGL((GameOverReason)CustomGameOverReason.LoversWin, false); - return true; - } - DestroyableSingleton.CHNDKKBEIDG.ShowPopUp(DestroyableSingleton.CHNDKKBEIDG.GetString(StringNames.GameOverImpostorDead, new Il2CppReferenceArray(0))); - ReviveEveryone(); + __instance.enabled = false; + ShipStatus.EABBNOODFGL((GameOverReason)CustomGameOverReason.LoversWin, false); return true; } return false; @@ -313,14 +280,8 @@ namespace TheOtherRoles { private static bool CheckAndEndGameForJackalWin(ShipStatus __instance, PlayerStatistics statistics) { if (statistics.TeamJackalAlive >= statistics.TotalAlive - statistics.TeamJackalAlive && statistics.TeamImpostorsAlive == 0 && !(statistics.TeamJackalHasAliveLover && statistics.TeamLoversAlive == 2)) { - if (!DestroyableSingleton.BMHJGNNOGDM) - { - __instance.enabled = false; - ShipStatus.EABBNOODFGL((GameOverReason)CustomGameOverReason.TeamJackalWin, false); - return true; - } - DestroyableSingleton.CHNDKKBEIDG.ShowPopUp(DestroyableSingleton.CHNDKKBEIDG.GetString(StringNames.GameOverImpostorKills, new Il2CppReferenceArray(0))); - ReviveEveryone(); + __instance.enabled = false; + ShipStatus.EABBNOODFGL((GameOverReason)CustomGameOverReason.TeamJackalWin, false); return true; } return false; @@ -328,25 +289,20 @@ namespace TheOtherRoles { private static bool CheckAndEndGameForImpostorWin(ShipStatus __instance, PlayerStatistics statistics) { if (statistics.TeamImpostorsAlive >= statistics.TotalAlive - statistics.TeamImpostorsAlive && statistics.TeamJackalAlive == 0 && !(statistics.TeamImpostorHasAliveLover && statistics.TeamLoversAlive == 2)) { - if (!DestroyableSingleton.BMHJGNNOGDM) { - __instance.enabled = false; - GameOverReason endReason; - switch (TempData.PJPCCFAPCKJ) { - case DeathReason.Exile: - endReason = GameOverReason.ImpostorByVote; - break; - case DeathReason.Kill: - endReason = GameOverReason.ImpostorByKill; - break; - default: - endReason = GameOverReason.ImpostorByVote; - break; - } - ShipStatus.EABBNOODFGL(endReason, false); - return true; + __instance.enabled = false; + GameOverReason endReason; + switch (TempData.PJPCCFAPCKJ) { + case DeathReason.Exile: + endReason = GameOverReason.ImpostorByVote; + break; + case DeathReason.Kill: + endReason = GameOverReason.ImpostorByKill; + break; + default: + endReason = GameOverReason.ImpostorByVote; + break; } - DestroyableSingleton.CHNDKKBEIDG.ShowPopUp(DestroyableSingleton.CHNDKKBEIDG.GetString(StringNames.GameOverImpostorKills, new Il2CppReferenceArray(0))); - ReviveEveryone(); + ShipStatus.EABBNOODFGL(endReason, false); return true; } return false; @@ -354,35 +310,17 @@ namespace TheOtherRoles { private static bool CheckAndEndGameForCrewmateWin(ShipStatus __instance, PlayerStatistics statistics) { if (statistics.TeamImpostorsAlive == 0 && statistics.TeamJackalAlive == 0) { - if (!DestroyableSingleton.BMHJGNNOGDM) { - __instance.enabled = false; - ShipStatus.EABBNOODFGL(GameOverReason.HumansByVote, false); - return true; - } - DestroyableSingleton.CHNDKKBEIDG.ShowPopUp(DestroyableSingleton.CHNDKKBEIDG.GetString(StringNames.GameOverImpostorDead, new Il2CppReferenceArray(0))); - ReviveEveryone(); + __instance.enabled = false; + ShipStatus.EABBNOODFGL(GameOverReason.HumansByVote, false); return true; } return false; } - private static void ReviveEveryone() { - for (int i = 0; i < GameData.Instance.MFDAIFHGKMG; i++) - GameData.Instance.AllPlayers[i].GJPBCGFPMOD.Revive(); - DeadBody[] array = UnityEngine.Object.FindObjectsOfType(); - for (int i = 0; i < array.Length; i++) UnityEngine.Object.Destroy(array[i].gameObject); - } - - private static void EndGameForSabotage(ShipStatus __instance) - { - if (!DestroyableSingleton.BMHJGNNOGDM) - { - __instance.enabled = false; - ShipStatus.EABBNOODFGL(GameOverReason.ImpostorBySabotage, false); - return; - } - DestroyableSingleton.CHNDKKBEIDG.ShowPopUp(DestroyableSingleton.CHNDKKBEIDG.GetString(StringNames.GameOverSabotage, new Il2CppReferenceArray(0))); - ReviveEveryone(); + private static void EndGameForSabotage(ShipStatus __instance) { + __instance.enabled = false; + ShipStatus.EABBNOODFGL(GameOverReason.ImpostorBySabotage, false); + return; } }