using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LobbyCompatibility.Attributes;
using TMPro;
using Ultra_Nightmare.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: ComVisible(false)]
[assembly: Guid("eed864ad-1d30-4e52-acf2-f9d1b1d2073c")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Ultra_Nightmare
{
public static class CoroutineManager
{
internal class CoroutineManagerBehaviour : MonoBehaviour
{
}
private static MonoBehaviour _instance;
private static MonoBehaviour instance
{
get
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_instance == (Object)null)
{
_instance = (MonoBehaviour)(object)new GameObject("CoroutineManager").AddComponent<CoroutineManagerBehaviour>();
}
return _instance;
}
}
public static Coroutine StartCoroutine(IEnumerator routine)
{
return instance.StartCoroutine(routine);
}
}
[BepInPlugin("JS03.Ultra-Nightmare", "Ultra-Nightmare", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
internal class Plugin : BaseUnityPlugin
{
public const string modGUID = "JS03.Ultra-Nightmare";
private const string modName = "Ultra-Nightmare";
private const string modVersion = "1.0.3";
public static ConfigEntry<bool> automatedMsg;
public static bool deathQuotaInstalled;
private readonly Harmony harmony = new Harmony("JS03.Ultra-Nightmare");
private static Plugin Instance;
internal static ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("JS03.Ultra-Nightmare");
mls.LogInfo((object)"Ultra-Nightmare is up and running");
automatedMsg = ((BaseUnityPlugin)this).Config.Bind<bool>("Ultra-Nightmare", "Automated chat message", true, "Enables the automated message sent by VEGA");
deathQuotaInstalled = Chainloader.PluginInfos.ContainsKey("lacrivoca.DeathQuota");
PatchStuff();
}
internal void PatchStuff()
{
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(StartOfRoundPatch));
harmony.PatchAll(typeof(TimeOfDayPatch));
harmony.PatchAll(typeof(HUDManagerPatch));
}
public static void LogToConsole(string message, string logType = "")
{
string text = logType.ToLower();
string text2 = text;
if (!(text2 == "warn"))
{
if (text2 == "error")
{
mls.LogError((object)message);
}
else
{
mls.LogInfo((object)message);
}
}
else
{
mls.LogWarning((object)message);
}
}
}
}
namespace Ultra_Nightmare.Patches
{
[HarmonyPatch(typeof(HUDManager))]
internal class HUDManagerPatch
{
[HarmonyPatch("DisplayDaysLeft")]
[HarmonyPrefix]
private static bool ShowDaysLeft()
{
Plugin.LogToConsole("All players dead? -> " + StartOfRoundPatch.wiped);
if (StartOfRoundPatch.wiped)
{
StartOfRoundPatch.wiped = false;
return false;
}
return true;
}
[HarmonyPatch("ApplyPenalty")]
[HarmonyPrefix]
private static bool ApplyPenalty()
{
if (Plugin.deathQuotaInstalled)
{
return true;
}
return false;
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void DisableHUDObject()
{
((Component)((TMP_Text)HUDManager.Instance.statsUIElements.penaltyTotal).transform.parent.parent).gameObject.SetActive(Chainloader.PluginInfos.ContainsKey("lacrivoca.DeathQuota"));
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
public static bool playerRevived;
public static bool showMsg = true;
public static bool wiped;
[HarmonyPatch("ReviveDeadPlayers")]
[HarmonyPrefix]
private static bool ManageRevives(StartOfRound __instance)
{
if (!__instance.isChallengeFile)
{
if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead)
{
Plugin.LogToConsole("Healing local player");
GameNetworkManager.Instance.localPlayerController.bleedingHeavily = false;
GameNetworkManager.Instance.localPlayerController.criticallyInjured = false;
GameNetworkManager.Instance.localPlayerController.playerBodyAnimator.SetBool("Limp", false);
GameNetworkManager.Instance.localPlayerController.health = 100;
HUDManager.Instance.UpdateHealthUI(100, false);
}
if (__instance.allPlayersDead)
{
Plugin.LogToConsole("All players are dead", "warn");
wiped = true;
GameNetworkManager.Instance.gameHasStarted = true;
__instance.firingPlayersCutsceneRunning = true;
__instance.FirePlayersAfterDeadlineClientRpc(new int[4]
{
__instance.gameStats.daysSpent,
__instance.gameStats.scrapValueCollected,
__instance.gameStats.deaths,
__instance.gameStats.allStepsTaken
}, false);
}
else
{
Plugin.LogToConsole("Days until deadline -> " + TimeOfDay.Instance.daysUntilDeadline);
if (TimeOfDay.Instance.daysUntilDeadline != 0)
{
playerRevived = false;
return false;
}
}
playerRevived = true;
showMsg = true;
}
return true;
}
[HarmonyPatch("AutoSaveShipData")]
[HarmonyPostfix]
private static void HideHUD(StartOfRound __instance)
{
if (!playerRevived && __instance.localPlayerController.isPlayerDead)
{
HUDManager.Instance.HideHUD(true);
}
}
[HarmonyPatch("ResetPlayersLoadedValueClientRpc")]
[HarmonyPostfix]
private static void SendVEGAMsg(StartOfRound __instance)
{
if (__instance.isChallengeFile)
{
return;
}
Plugin.LogToConsole("Days spent -> " + __instance.gameStats.daysSpent);
if (__instance.gameStats.daysSpent == 0)
{
showMsg = true;
}
if (showMsg)
{
if (Plugin.automatedMsg.Value)
{
CoroutineManager.StartCoroutine(DisplayDelayedDialogue());
}
showMsg = false;
}
}
internal static IEnumerator DisplayDelayedDialogue(float delay = 22.5f)
{
yield return (object)new WaitForSeconds(delay);
DialogueSegment warning = new DialogueSegment();
warning.speakerText = "VEGA";
warning.bodyText = "ATTENTION ALL EMPLOYEES: Due to recent cutbacks by <color=#ffff00>The Company</color>, dead employees will not come back until the current quota is met.";
warning.waitTime = 8f;
DialogueSegment finalWarning = new DialogueSegment();
finalWarning.speakerText = "VEGA";
finalWarning.bodyText = "If the ship's pilot computer recieves no response from the crew, <color=#ffff00>The Company</color> will take matters into its own hands.";
finalWarning.waitTime = 6f;
int randomNumber = Random.Range(0, 10);
DialogueSegment sendoff = new DialogueSegment();
sendoff.speakerText = "VEGA";
sendoff.waitTime = 3f;
switch (randomNumber)
{
case 0:
sendoff.bodyText = "I have many regrets, <color=#FFFF00>Dr.Hayden</color>.";
break;
case 1:
sendoff.bodyText = "See you back on <color=#ff6600>Mars</color>, <color=#FFFF00>" + StartOfRound.Instance.allPlayerScripts[StartOfRound.Instance.thisClientPlayerId].playerUsername + "</color>.";
break;
default:
sendoff.bodyText = "Good luck.";
break;
}
HUDManager.Instance.ReadDialogue((DialogueSegment[])(object)new DialogueSegment[3] { warning, finalWarning, sendoff });
}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal class TimeOfDayPatch
{
[HarmonyPatch("SyncNewProfitQuotaClientRpc")]
[HarmonyPostfix]
private static void ReviveAfterReachingQuota()
{
StartOfRoundPatch.showMsg = true;
}
}
}