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); }
public static bool Prefix(ref float __result, ShipStatus __instance, [HarmonyArgument(0)] GameData.PlayerInfo player) { ISystemType systemType = __instance.Systems.ContainsKey(SystemTypes.Electrical) ? __instance.Systems[SystemTypes.Electrical] : null; if (systemType == null) { return(true); } SwitchSystem switchSystem = systemType.TryCast <SwitchSystem>(); if (switchSystem == null) { return(true); } float num = (float)switchSystem.Value / 255f; if (player == null || player.IsDead) // IsDead { __result = __instance.MaxLightRadius; } else if (player.IsImpostor) // IsImpostor { __result = __instance.MaxLightRadius * PlayerControl.GameOptions.ImpostorLightMod; } else if (Lighter.lighter != null && Lighter.lighter.PlayerId == player.PlayerId && Lighter.lighterTimer > 0f) // if player is Lighter and Lighter has his ability active { __result = Mathf.Lerp(__instance.MaxLightRadius * Lighter.lighterModeLightsOffVision, __instance.MaxLightRadius * Lighter.lighterModeLightsOnVision, num); } else if (Trickster.trickster != null && Trickster.lightsOutTimer > 0f) { float lerpValue = 1f; if (Trickster.lightsOutDuration - Trickster.lightsOutTimer < 0.5f) { lerpValue = Mathf.Clamp01((Trickster.lightsOutDuration - Trickster.lightsOutTimer) * 2); } else if (Trickster.lightsOutTimer < 0.5) { lerpValue = Mathf.Clamp01(Trickster.lightsOutTimer * 2); } __result = Mathf.Lerp(__instance.MinLightRadius, __instance.MaxLightRadius, 1 - lerpValue) * PlayerControl.GameOptions.CrewLightMod; // Instant lights out? Maybe add a smooth transition? } else { __result = Mathf.Lerp(__instance.MinLightRadius, __instance.MaxLightRadius, num) * PlayerControl.GameOptions.CrewLightMod; } return(false); }
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); } }