mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
revert un-inline
This commit is contained in:
1 parent
0f1962394a
commit
af75cc3606
1 file changed
+1
-92
@@ -1,6 +1,4 @@
|
|||||||
using System.Linq;
|
using HarmonyLib;
|
||||||
using AmongUs.Data;
|
|
||||||
using HarmonyLib;
|
|
||||||
using MiraAPI.Events;
|
using MiraAPI.Events;
|
||||||
using MiraAPI.Events.Vanilla.Gameplay;
|
using MiraAPI.Events.Vanilla.Gameplay;
|
||||||
using MiraAPI.GameEnd;
|
using MiraAPI.GameEnd;
|
||||||
@@ -9,95 +7,6 @@ namespace MiraAPI.Patches.Events;
|
|||||||
|
|
||||||
internal static class EndGamePatches
|
internal static class EndGamePatches
|
||||||
{
|
{
|
||||||
// To un-inline RpcEndGame
|
|
||||||
[HarmonyPatch(typeof(LogicGameFlowNormal), nameof(LogicGameFlowNormal.CheckEndCriteria))]
|
|
||||||
public static class LogicGameFlowNormalPatches
|
|
||||||
{
|
|
||||||
public static void Prefix(LogicGameFlowNormal __instance, ref bool __runOriginal)
|
|
||||||
{
|
|
||||||
__runOriginal = false;
|
|
||||||
if (!GameData.Instance)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ShipStatus.Instance.Systems.TryGetValue(SystemTypes.LifeSupp, out var systemType))
|
|
||||||
{
|
|
||||||
var lifeSuppSystemType = systemType.Cast<LifeSuppSystemType>();
|
|
||||||
if (lifeSuppSystemType.Countdown < 0f)
|
|
||||||
{
|
|
||||||
__instance.EndGameForSabotage();
|
|
||||||
lifeSuppSystemType.Countdown = 10000f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var systemType2 in ShipStatus.Instance.Systems.Values)
|
|
||||||
{
|
|
||||||
var criticalSabotage = systemType2.TryCast<ICriticalSabotage>();
|
|
||||||
if (criticalSabotage is { Countdown: < 0f })
|
|
||||||
{
|
|
||||||
__instance.EndGameForSabotage();
|
|
||||||
criticalSabotage.ClearSabotage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var playerCounts = __instance.GetPlayerCounts();
|
|
||||||
var item = playerCounts.Item1;
|
|
||||||
var item2 = playerCounts.Item2;
|
|
||||||
var item3 = playerCounts.Item3;
|
|
||||||
if (item2 <= 0 && (!TutorialManager.InstanceExists || item3 > 0))
|
|
||||||
{
|
|
||||||
if (!TutorialManager.InstanceExists)
|
|
||||||
{
|
|
||||||
var gameOverReason = GameOverReason.CrewmatesByVote;
|
|
||||||
__instance.Manager.RpcEndGame(gameOverReason, !DataManager.Player.Ads.HasPurchasedAdRemoval);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Minigame.Instance)
|
|
||||||
{
|
|
||||||
HudManager.Instance.ShowPopUp(
|
|
||||||
TranslationController.Instance.GetString(StringNames.GameOverImpostorDead));
|
|
||||||
__instance.Manager.ReviveEveryoneFreeplay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (item <= item2)
|
|
||||||
{
|
|
||||||
if (!TutorialManager.InstanceExists)
|
|
||||||
{
|
|
||||||
var gameOverReason2 = GameData.LastDeathReason switch
|
|
||||||
{
|
|
||||||
DeathReason.Exile => GameOverReason.ImpostorsByVote,
|
|
||||||
DeathReason.Kill => GameOverReason.ImpostorsByKill,
|
|
||||||
_ => GameOverReason.CrewmateDisconnect,
|
|
||||||
};
|
|
||||||
|
|
||||||
__instance.Manager.RpcEndGame(gameOverReason2, !DataManager.Player.Ads.HasPurchasedAdRemoval);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HudManager.Instance.ShowPopUp(TranslationController.Instance.GetString(StringNames.GameOverImpostorKills));
|
|
||||||
__instance.Manager.ReviveEveryoneFreeplay();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!TutorialManager.InstanceExists)
|
|
||||||
{
|
|
||||||
__instance.Manager.CheckEndGameViaTasks();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PlayerControl.LocalPlayer.myTasks.ToArray().All(t => t.IsComplete))
|
|
||||||
{
|
|
||||||
HudManager.Instance.ShowPopUp(
|
|
||||||
TranslationController.Instance.GetString(
|
|
||||||
StringNames.GameOverTaskWin));
|
|
||||||
ShipStatus.Instance.Begin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(GameManager), nameof(GameManager.RpcEndGame))]
|
[HarmonyPatch(typeof(GameManager), nameof(GameManager.RpcEndGame))]
|
||||||
public static class GameManagerPatches
|
public static class GameManagerPatches
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user