示例#1
0
        private static bool CheckAndEndGameForSabotageWin(ShipStatus __instance)
        {
            ISystemType systemType = __instance.Systems.ContainsKey(SystemTypes.LifeSupp) ? __instance.Systems[SystemTypes.LifeSupp] : null;

            if (systemType != null)
            {
                LifeSuppSystemType lifeSuppSystemType = systemType.TryCast <LifeSuppSystemType>();
                if (lifeSuppSystemType.Countdown < 0f)
                {
                    EndGameForSabotage(__instance);
                    lifeSuppSystemType.Countdown = 10000f;
                    return(true);
                }
            }
            ISystemType systemType2 = __instance.Systems.ContainsKey(SystemTypes.Reactor) ? __instance.Systems[SystemTypes.Reactor] : null;

            if (systemType2 == null)
            {
                systemType2 = __instance.Systems.ContainsKey(SystemTypes.Laboratory) ? __instance.Systems[SystemTypes.Laboratory] : null;
            }
            if (systemType2 != null)
            {
                ReactorSystemType reactorSystemType = systemType2.TryCast <ReactorSystemType>();
                if (reactorSystemType.Countdown < 0f)
                {
                    EndGameForSabotage(__instance);
                    reactorSystemType.Countdown = 10000f;
                    return(true);
                }
            }
            return(false);
        }
示例#2
0
        public static bool Prefix(ShipStatus __instance)
        {
            if (!GameData.Instance)
            {
                return(false);
            }
            ISystemType systemType = __instance.Systems.ContainsKey(SystemTypes.LifeSupp) ? __instance.Systems[SystemTypes.LifeSupp] : null;

            if (systemType != null)
            {
                LifeSuppSystemType lifeSuppSystemType = systemType.TryCast <LifeSuppSystemType>();
                if (lifeSuppSystemType.Countdown < 0f)
                {
                    EndGameForSabotage(__instance);
                    lifeSuppSystemType.Countdown = 10000f;
                }
            }
            ISystemType systemType2 = __instance.Systems.ContainsKey(SystemTypes.Reactor) ? __instance.Systems[SystemTypes.Reactor] : null;

            if (systemType2 == null)
            {
                systemType2 = __instance.Systems.ContainsKey(SystemTypes.Laboratory) ? __instance.Systems[SystemTypes.Laboratory] : null;
            }
            if (systemType2 != null)
            {
                ReactorSystemType reactorSystemType = systemType2.TryCast <ReactorSystemType>();
                if (reactorSystemType.Countdown < 0f)
                {
                    EndGameForSabotage(__instance);
                    reactorSystemType.Countdown = 10000f;
                }
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            for (int i = 0; i < GameData.Instance.PlayerCount; i++)
            {
                GameData.PlayerInfo playerInfo = GameData.Instance.AllPlayers[i];
                if (!playerInfo.Disconnected)
                {
                    if (playerInfo.IsImpostor)
                    {
                        num3++;
                    }
                    if (!playerInfo.IsDead)
                    {
                        if (playerInfo.IsImpostor)
                        {
                            num2++;
                        }
                        else
                        {
                            num++;
                        }
                    }
                }
            }
            if (num2 <= 0 && (!DestroyableSingleton <TutorialManager> .InstanceExists || num3 > 0))
            {
                if (!DestroyableSingleton <TutorialManager> .InstanceExists)
                {
                    __instance.enabled = false;
                    ShipStatus.RpcEndGame(GameOverReason.HumansByVote, false);
                    return(false);
                }
                DestroyableSingleton <HudManager> .Instance.ShowPopUp(DestroyableSingleton <TranslationController> .Instance.GetString(StringNames.GameOverImpostorDead, new Il2CppReferenceArray <Il2CppSystem.Object>(0)));

                ReviveEveryone();
                return(false);
            }
            else
            {
                if (num > num2)
                {
                    bool localCompletedAllTasks = true;
                    foreach (PlayerTask t in PlayerControl.LocalPlayer.myTasks)
                    {
                        localCompletedAllTasks = localCompletedAllTasks && t.IsComplete;
                    }

                    if (!DestroyableSingleton <TutorialManager> .InstanceExists)
                    {
                        if (GameData.Instance.TotalTasks <= GameData.Instance.CompletedTasks)
                        {
                            __instance.enabled = false;
                            ShipStatus.RpcEndGame(GameOverReason.HumansByTask, false);
                            return(false);
                        }
                    }
                    else if (localCompletedAllTasks)
                    {
                        DestroyableSingleton <HudManager> .Instance.ShowPopUp(DestroyableSingleton <TranslationController> .Instance.GetString(StringNames.GameOverTaskWin, new Il2CppReferenceArray <Il2CppSystem.Object>(0)));

                        __instance.Begin();
                    }
                    if (num + num2 == 3 && Lovers.existingAndAlive())   // 3 players with 2 lovers is always a lover win (either shared with crewmates or solo for lovers, marked as impostor win)
                    {
                        __instance.enabled = false;
                        ShipStatus.RpcEndGame(Lovers.existingWithImpLover() ? GameOverReason.ImpostorByKill : GameOverReason.HumansByVote, false); // should be implemented using a proper GameOverReason in the future
                        return(false);
                    }
                    return(false);
                }
                if (num == num2 && Lovers.existingAndAlive() && Lovers.existingWithImpLover())   // 3 vs 3 or 2 vs 2 is not win if both lovers are alive and one is an impostor
                {
                    return(false);
                }
                if (!DestroyableSingleton <TutorialManager> .InstanceExists)
                {
                    __instance.enabled = false;
                    GameOverReason endReason;
                    switch (TempData.LastDeathReason)
                    {
                    case DeathReason.Exile:
                        endReason = GameOverReason.ImpostorByVote;
                        break;

                    case DeathReason.Kill:
                        endReason = GameOverReason.ImpostorByKill;
                        break;

                    default:
                        endReason = GameOverReason.ImpostorByVote;
                        break;
                    }
                    ShipStatus.RpcEndGame(endReason, false);
                    return(false);
                }
                DestroyableSingleton <HudManager> .Instance.ShowPopUp(DestroyableSingleton <TranslationController> .Instance.GetString(StringNames.GameOverImpostorKills, new Il2CppReferenceArray <Il2CppSystem.Object>(0)));

                ReviveEveryone();
                return(false);
            }
        }