Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of OpenMonitors v1.1.1
OpenMonitors.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DunGen; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using OpenMonitors.Monitors; using TMPro; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("OpenMonitors")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OpenMonitors")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1203C15A-FDA7-419A-9D8B-0312A7C308AC")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace OpenMonitors { public static class ModInfo { public const string Name = "OpenMonitors"; public const string Guid = "xxxstoner420bongmasterxxx.open_monitors"; public const string Version = "1.1.1"; } [BepInPlugin("xxxstoner420bongmasterxxx.open_monitors", "OpenMonitors", "1.1.1")] public class Plugin : BaseUnityPlugin { public static ConfigFile ModConfig; private static Plugin? _instance; public static ManualLogSource ModLogger; private readonly Harmony _harmony = new Harmony("xxxstoner420bongmasterxxx.open_monitors"); private void Awake() { ModLogger = ((BaseUnityPlugin)this).Logger; if (!Object.op_Implicit((Object)(object)_instance)) { ModLogger.LogInfo((object)"OpenMonitors -> loading"); _instance = this; ModConfig = ((BaseUnityPlugin)this).Config; Config.Initialize(); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ModLogger.LogInfo((object)"OpenMonitors -> complete"); } } } public static class PluginInfo { public const string PLUGIN_GUID = "OpenMonitors"; public const string PLUGIN_NAME = "OpenMonitors"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace OpenMonitors.Patch { [HarmonyPatch(typeof(DepositItemsDesk))] public class DepositItemsDesk { [HarmonyPostfix] [HarmonyPatch("SellAndDisplayItemProfits")] private static void UpdateCreditsAfterSellingLoot() { Plugin.ModLogger.LogDebug((object)"DepositItemsDesk.UpdateCreditsAfterSellingLoot"); CreditsMonitor.Instance.UpdateMonitor(); } } [HarmonyPatch(typeof(HUDManager))] public class HUDManager { [HarmonyPostfix] [HarmonyPatch("ApplyPenalty")] private static void UpdateCreditsAfterDeadPlayersPenalty() { Plugin.ModLogger.LogDebug((object)"HUDManager.UpdateCreditsAfterDeadPlayersPenalty"); CreditsMonitor.Instance.UpdateMonitor(); } } [HarmonyPatch(typeof(PlayerControllerB))] public class PlayerControllerB { [HarmonyPostfix] [HarmonyPatch("ConnectClientToPlayerObject")] private static void OnPlayerConnect() { ((MonoBehaviour)CoroutineHelper.Instance).StartCoroutine(WaitOnPlayerConnectForMonitorsToBeCreated()); } private static IEnumerator WaitOnPlayerConnectForMonitorsToBeCreated() { Plugin.ModLogger.LogDebug((object)"WaitOnPlayerConnectForMonitorsToBeCreated"); yield return (object)new WaitUntil((Func<bool>)(() => Object.op_Implicit((Object)(object)CreditsMonitor.Instance) && Object.op_Implicit((Object)(object)LifeSupportMonitor.Instance))); CreditsMonitor.Instance.UpdateMonitor(); LifeSupportMonitor.Instance.UpdateMonitor(); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("GrabObjectClientRpc")] private static void RefreshLootOnPickupClient(bool grabValidated, ref NetworkObjectReference grabbedObject) { NetworkObject val = default(NetworkObject); if (((NetworkObjectReference)(ref grabbedObject)).TryGet(ref val, (NetworkManager)null)) { GrabbableObject componentInChildren = ((Component)val).gameObject.GetComponentInChildren<GrabbableObject>(); if (componentInChildren.isInShipRoom || componentInChildren.isInElevator) { Plugin.ModLogger.LogDebug((object)"PlayerControllerB.RefreshLootOnPickupClient"); LootMonitor.Instance.UpdateMonitor(); } } } [HarmonyPostfix] [HarmonyPatch("ThrowObjectClientRpc")] private static void RefreshLootOnThrowClient(bool droppedInElevator, bool droppedInShipRoom, Vector3 targetFloorPosition, NetworkObjectReference grabbedObject) { if (droppedInShipRoom || droppedInElevator) { Plugin.ModLogger.LogDebug((object)"PlayerControllerB.RefreshLootOnThrowClient"); LootMonitor.Instance.UpdateMonitor(); } } [HarmonyPostfix] [HarmonyPatch("KillPlayer")] private static void UpdateLifeSupportMonitorOnPlayerDeath(Vector3 bodyVelocity, bool spawnBody, CauseOfDeath causeOfDeath, int deathAnimation) { Plugin.ModLogger.LogDebug((object)"PlayerControllerB.UpdateLifeSupportMonitorOnPlayerDeath"); LifeSupportMonitor.Instance.UpdateMonitor(); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("KillPlayerClientRpc")] private static void UpdateLifeSupportMonitorOnPlayerDeathClientRpc(int playerId, bool spawnBody, Vector3 bodyVelocity, int causeOfDeath, int deathAnimation) { Plugin.ModLogger.LogDebug((object)"PlayerControllerB.UpdateLifeSupportMonitorOnPlayerDeathClientRpc"); LifeSupportMonitor.Instance.UpdateMonitor(); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("DamagePlayer")] private static void UpdateLifeSupportMonitorOnPlayerDamage(int damageNumber, bool hasDamageSFX, bool callRPC, CauseOfDeath causeOfDeath, int deathAnimation, bool fallDamage, Vector3 force) { Plugin.ModLogger.LogDebug((object)"PlayerControllerB.UpdateLifeSupportMonitorOnPlayerDamage"); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("DamageOnOtherClients")] private static void UpdateLifeSupportMonitorForPlayerDamageOnOtherClients(int damageNumber, int newHealthAmount) { Plugin.ModLogger.LogDebug((object)"PlayerControllerB.UpdateLifeSupportMonitorForPlayerDamageOnOtherClients"); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("DamagePlayerClientRpc")] private static void UpdateLifeSupportMonitorOnPlayerDamageClientRpc(int damageNumber, int newHealthAmount) { Plugin.ModLogger.LogDebug((object)"PlayerControllerB.UpdateLifeSupportMonitorOnPlayerDamageClientRpc"); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("DamagePlayerFromOtherClientClientRpc")] private static void UpdateLifeSupportMonitorOnOtherClientPlayerDamageClientRpc(int damageAmount, Vector3 hitDirection, int playerWhoHit, int newHealthAmount) { Plugin.ModLogger.LogDebug((object)"PlayerControllerB.UpdateLifeSupportMonitorOnOtherClientPlayerDamageClientRpc"); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } } [HarmonyPatch(typeof(StartOfRound))] public class StartOfRound { [HarmonyPostfix] [HarmonyPatch("Start")] private static void Initialize() { Plugin.ModLogger.LogDebug((object)"StartOfRound.Initialize"); Setup.Initialize(); } [HarmonyPostfix] [HarmonyPatch("ReviveDeadPlayers")] private static void RefreshMonitorsWhenPlayerRevives() { Plugin.ModLogger.LogDebug((object)"StartOfRound.RefreshMonitorsWhenPlayerRevives"); CreditsMonitor.Instance.UpdateMonitor(); DayMonitor.Instance.UpdateMonitor(); LifeSupportMonitor.Instance.UpdateMonitor(); LootMonitor.Instance.UpdateMonitor(); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("SyncShipUnlockablesClientRpc")] private static void RefreshLootForClientOnStart() { Plugin.ModLogger.LogDebug((object)"StartOfRound.RefreshLootForClientOnStart"); LootMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("ChangeLevelClientRpc")] private static void UpdateCreditsWhenSwitchingMoons() { Plugin.ModLogger.LogDebug((object)"StartOfRound.UpdateCreditsWhenSwitchingMoons"); CreditsMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("EndOfGameClientRpc")] private static void RefreshDayWhenShipHasLeft() { Plugin.ModLogger.LogDebug((object)"StartOfRound.RefreshDayWhenShipHasLeft"); DayMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("StartGame")] private static void UpdateDayAtStartOfGame() { Plugin.ModLogger.LogDebug((object)"StartOfRound.UpdateDayAtStartOfGame"); DayMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("OnClientConnect")] private static void UpdateMonitorsWhenPlayerConnectsClient(ulong clientId) { Plugin.ModLogger.LogDebug((object)"StartOfRound.UpdateMonitorsWhenPlayerConnectsClient"); CreditsMonitor.Instance.UpdateMonitor(); LifeSupportMonitor.Instance.UpdateMonitor(); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); LootMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("OnPlayerConnectedClientRpc")] private static void UpdateMonitorsWhenPlayerConnectsClientRpc(ulong clientId, int connectedPlayers, ulong[] connectedPlayerIdsOrdered, int assignedPlayerObjectId, int serverMoneyAmount, int levelID, int profitQuota, int timeUntilDeadline, int quotaFulfilled, int randomSeed) { Plugin.ModLogger.LogDebug((object)"StartOfRound.UpdateMonitorsWhenPlayerConnectsClientRpc"); CreditsMonitor.Instance.UpdateMonitor(); LifeSupportMonitor.Instance.UpdateMonitor(); LootMonitor.Instance.UpdateMonitor(); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("OnPlayerDC")] private static void UpdateMonitorsWhenPlayerDisconnects(int playerObjectNumber, ulong clientId) { Plugin.ModLogger.LogDebug((object)"StartOfRound.UpdateMonitorsWhenPlayerDisconnects"); CreditsMonitor.Instance.UpdateMonitor(); LifeSupportMonitor.Instance.UpdateMonitor(); LootMonitor.Instance.UpdateMonitor(); PlayersLifeSupportMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("SetMapScreenInfoToCurrentLevel")] private static void ColorWeather(ref TextMeshProUGUI ___screenLevelDescription, ref SelectableLevel ___currentLevel) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder("Orbiting: ").AppendLine(___currentLevel.PlanetName); if (!Config.HideWeather.Value) { stringBuilder.Append("Weather: ").AppendLine(FormatWeather(___currentLevel.currentWeather)); } stringBuilder.Append(___currentLevel.LevelDescription ?? string.Empty); ((TMP_Text)___screenLevelDescription).text = stringBuilder.ToString(); } private static string FormatWeather(LevelWeatherType currentWeather) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected I4, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Plugin.ModLogger.LogDebug((object)$"Weather: {currentWeather}"); if (1 == 0) { } string text = (currentWeather - -1) switch { 1 => ParseColorInput(Config.DustCloudsWeatherColor), 6 => ParseColorInput(Config.EclipsedWeatherColor), 5 => ParseColorInput(Config.FloodedWeatherColor), 4 => ParseColorInput(Config.FoggyWeatherColor), 0 => ParseColorInput(Config.NoneWeatherColor), 2 => ParseColorInput(Config.RainyWeatherColor), 3 => ParseColorInput(Config.StormyWeatherColor), _ => ((ConfigEntryBase)Config.NoneWeatherColor).DefaultValue.ToString(), }; if (1 == 0) { } string arg = text; return $"<color=#{arg}>{currentWeather}</color>"; } private static string ParseColorInput(ConfigEntry<string> entry) { string text = entry.Value.Replace("#", ""); Regex regex = new Regex("(?i)[0-9a-f]{6}"); return regex.IsMatch(text) ? text : ((ConfigEntryBase)entry).DefaultValue.ToString(); } } [HarmonyPatch(typeof(Terminal))] public class Terminal { [HarmonyPostfix] [HarmonyPatch("SyncGroupCreditsClientRpc")] private static void RefreshMoney() { Plugin.ModLogger.LogDebug((object)"Terminal.RefreshMoney"); CreditsMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("TextPostProcess")] private static string WeatherConditions(string __result) { if (Config.HideWeather.Value) { __result = Enum.GetValues(typeof(LevelWeatherType)).Cast<LevelWeatherType>().Aggregate(__result, (string current, LevelWeatherType value) => current.Replace($"({value})", string.Empty)); } return __result; } } [HarmonyPatch(typeof(TimeOfDay))] public class TimeOfDay { [HarmonyPostfix] [HarmonyPatch("SyncNewProfitQuotaClientRpc")] private static void UpdateCreditsAfterReachingQuota() { Plugin.ModLogger.LogDebug((object)"TimeOfDay.UpdateCreditsAfterReachingQuota"); CreditsMonitor.Instance.UpdateMonitor(); } [HarmonyPostfix] [HarmonyPatch("MoveTimeOfDay")] private static void UpdateClockTime() { TimeMonitor.Instance.UpdateMonitor(); } } } namespace OpenMonitors.Monitors { public static class Config { private const string MonitorSection = "Monitors"; private const string MonitorWeatherColors = "MonitorWeatherColors"; private const string AllowableSlotValues = "Possible Slots: 1, 2, 4, 5, 6, 7, 8"; public static ConfigEntry<bool> HideWeather { get; private set; } public static ConfigEntry<int> ProfitQuotaMonitorSlot { get; private set; } public static ConfigEntry<int> DeadlineMonitorSlot { get; private set; } public static ConfigEntry<bool> HideLifeSupport { get; private set; } public static ConfigEntry<int> LifeSupportMonitorSlot { get; private set; } public static ConfigEntry<bool> HidePlayersLifeSupport { get; private set; } public static ConfigEntry<bool> HideLoot { get; private set; } public static ConfigEntry<int> LootMonitorSlot { get; private set; } public static ConfigEntry<bool> HideCredits { get; private set; } public static ConfigEntry<int> CreditsMonitorSlot { get; private set; } public static ConfigEntry<bool> HideDay { get; private set; } public static ConfigEntry<int> DayMonitorSlot { get; private set; } public static ConfigEntry<bool> HideTime { get; private set; } public static ConfigEntry<int> TimeMonitorSlot { get; private set; } public static ConfigEntry<bool> KeepBlueBackground1 { get; private set; } public static ConfigEntry<bool> KeepBlueBackground2 { get; private set; } public static ConfigEntry<string> NoneWeatherColor { get; private set; } public static ConfigEntry<string> RainyWeatherColor { get; private set; } public static ConfigEntry<string> FoggyWeatherColor { get; private set; } public static ConfigEntry<string> StormyWeatherColor { get; private set; } public static ConfigEntry<string> FloodedWeatherColor { get; private set; } public static ConfigEntry<string> EclipsedWeatherColor { get; private set; } public static ConfigEntry<string> DustCloudsWeatherColor { get; private set; } public static void Initialize() { HideWeather = Plugin.ModConfig.Bind<bool>("General", "HideWeather", false, "Disables Weather from the navigation screen, and Terminal"); ProfitQuotaMonitorSlot = Plugin.ModConfig.Bind<int>("Monitors", "ProfitQuotaMonitorSlot", 1, "Slot for the Profit Quota Monitor. Possible Slots: 1, 2, 4, 5, 6, 7, 8"); DeadlineMonitorSlot = Plugin.ModConfig.Bind<int>("Monitors", "DeadlineMonitorSlot", 2, "Slot for the Deadline Monitor. Possible Slots: 1, 2, 4, 5, 6, 7, 8"); HideLifeSupport = Plugin.ModConfig.Bind<bool>("Monitors", "HideLifeSupport", false, "Disables the Life Support Monitor."); LifeSupportMonitorSlot = Plugin.ModConfig.Bind<int>("Monitors", "LifeSupportMonitorSlot", 4, "Slot for the Life Support Monitor. Possible Slots: 1, 2, 4, 5, 6, 7, 8"); HidePlayersLifeSupport = Plugin.ModConfig.Bind<bool>("Monitors", "HidePlayersLifeSupport", true, "Disables the Players Life Support Monitor."); HideLoot = Plugin.ModConfig.Bind<bool>("Monitors", "HideLoot", false, "Disables the Loot Monitor"); LootMonitorSlot = Plugin.ModConfig.Bind<int>("Monitors", "LootMonitorSlot", 5, "Slot for the Loot Monitor. Possible Slots: 1, 2, 4, 5, 6, 7, 8"); HideCredits = Plugin.ModConfig.Bind<bool>("Monitors", "HideCredits", false, "Disables the Credits Monitor"); TimeMonitorSlot = Plugin.ModConfig.Bind<int>("Monitors", "TimeMonitorSlot", 6, "Slot for the Time Monitor. Possible Slots: 1, 2, 4, 5, 6, 7, 8"); HideDay = Plugin.ModConfig.Bind<bool>("Monitors", "HideDay", false, "Disables the Day Monitor"); DayMonitorSlot = Plugin.ModConfig.Bind<int>("Monitors", "DayMonitorSlot", 7, "Slot for the Day Monitor. Possible Slots: 1, 2, 4, 5, 6, 7, 8"); HideTime = Plugin.ModConfig.Bind<bool>("Monitors", "HideTime", false, "Disables the Time Monitor"); CreditsMonitorSlot = Plugin.ModConfig.Bind<int>("Monitors", "CreditsMonitorSlot", 8, "Slot for the Credits Monitor. Possible Slots: 1, 2, 4, 5, 6, 7, 8"); KeepBlueBackground1 = Plugin.ModConfig.Bind<bool>("Monitors", "KeepBlueBackground - Monitor 1", false, "Keeps the blue background on Monitor 1 (Quota)"); KeepBlueBackground2 = Plugin.ModConfig.Bind<bool>("Monitors", "KeepBlueBackground - Monitor 2", false, "Keeps the blue background on Monitor 2 (Deadline)"); NoneWeatherColor = Plugin.ModConfig.Bind<string>("MonitorWeatherColors", "No weather:", "69FF69", "Input 6 character hex code for weather coloring"); RainyWeatherColor = Plugin.ModConfig.Bind<string>("MonitorWeatherColors", "Rainy:", "FFF01C", "Input 6 character hex code for weather coloring"); FoggyWeatherColor = Plugin.ModConfig.Bind<string>("MonitorWeatherColors", "Foggy:", "FFF01C", "Input 6 character hex code for weather coloring"); StormyWeatherColor = Plugin.ModConfig.Bind<string>("MonitorWeatherColors", "Stormy:", "FF9B00", "Input 6 character hex code for weather coloring"); FloodedWeatherColor = Plugin.ModConfig.Bind<string>("MonitorWeatherColors", "Flooded:", "FF9B00", "Input 6 character hex code for weather coloring"); EclipsedWeatherColor = Plugin.ModConfig.Bind<string>("MonitorWeatherColors", "Eclipsed:", "FF0000", "Input 6 character hex code for weather coloring"); DustCloudsWeatherColor = Plugin.ModConfig.Bind<string>("MonitorWeatherColors", "Dust Clouds:", "69FF69", "Input 6 character color hex code for weather coloring"); if (ProfitQuotaMonitorSlot.Value == 3) { ProfitQuotaMonitorSlot.Value = (int)((ConfigEntryBase)ProfitQuotaMonitorSlot).DefaultValue; } if (DeadlineMonitorSlot.Value == 3) { DeadlineMonitorSlot.Value = (int)((ConfigEntryBase)DeadlineMonitorSlot).DefaultValue; } if (LifeSupportMonitorSlot.Value == 3) { LifeSupportMonitorSlot.Value = (int)((ConfigEntryBase)LifeSupportMonitorSlot).DefaultValue; } if (LootMonitorSlot.Value == 3) { LootMonitorSlot.Value = (int)((ConfigEntryBase)LootMonitorSlot).DefaultValue; } if (TimeMonitorSlot.Value == 3) { TimeMonitorSlot.Value = (int)((ConfigEntryBase)TimeMonitorSlot).DefaultValue; } if (DayMonitorSlot.Value == 3) { DayMonitorSlot.Value = (int)((ConfigEntryBase)DayMonitorSlot).DefaultValue; } } } public class CreditsMonitor : MonoBehaviour { public static CreditsMonitor Instance; private Terminal _terminal = null; private TextMeshProUGUI _textMesh = null; public void Start() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start()")); if (!Object.op_Implicit((Object)(object)Instance)) { Instance = this; } _textMesh = ((Component)this).GetComponent<TextMeshProUGUI>(); _terminal = Object.FindObjectOfType<Terminal>(); Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start() -> UpdateMonitor()")); UpdateMonitor(); } public void UpdateMonitor() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> UpdateMonitor()")); ((TMP_Text)_textMesh).text = (Config.HideCredits.Value ? string.Empty : $"CREDITS:\n${_terminal.groupCredits}"); } } public class DayMonitor : MonoBehaviour { public static DayMonitor Instance; public TextMeshProUGUI textMesh = null; public void Start() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start()")); if (!Object.op_Implicit((Object)(object)Instance)) { Instance = this; } textMesh = ((Component)this).GetComponent<TextMeshProUGUI>(); ((TMP_Text)textMesh).text = (Config.HideDay.Value ? string.Empty : "DAY:\n?"); if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start() -> IsHost")); UpdateMonitor(); } else { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start() -> NOT IsHost")); } } public void UpdateMonitor() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> UpdateMonitor()")); ((TMP_Text)textMesh).text = (Config.HideDay.Value ? string.Empty : $"DAY:\n{StartOfRound.Instance.gameStats.daysSpent}"); } } public class LifeSupportMonitor : MonoBehaviour { public static LifeSupportMonitor Instance; private TextMeshProUGUI _textMesh = null; public void Start() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start()")); if (!Object.op_Implicit((Object)(object)Instance)) { Instance = this; } _textMesh = ((Component)this).GetComponent<TextMeshProUGUI>(); Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start() -> UpdateMonitor()")); UpdateMonitor(); } public void UpdateMonitor() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> UpdateMonitor()")); ((TMP_Text)_textMesh).text = (Config.HideLifeSupport.Value ? string.Empty : $"ALIVE:\n{StartOfRound.Instance.livingPlayers} / {StartOfRound.Instance.connectedPlayersAmount + 1}"); } } public class LootMonitor : MonoBehaviour { public static LootMonitor Instance; public TextMeshProUGUI textMesh = null; private GameObject _ship = null; public void Start() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start()")); if (!Object.op_Implicit((Object)(object)Instance)) { Instance = this; } textMesh = ((Component)this).GetComponent<TextMeshProUGUI>(); ((TMP_Text)textMesh).text = "LOOT:\n$NaN"; _ship = GameObject.Find("/Environment/HangarShip"); Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start() -> UpdateMonitor()")); UpdateMonitor(); } public void UpdateMonitor() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> UpdateMonitor()")); ((TMP_Text)textMesh).text = (Config.HideLoot.Value ? string.Empty : $"LOOT:\n${Calculate()}"); } private float Calculate() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Calculate()")); return (from grabbable in _ship.GetComponentsInChildren<GrabbableObject>() where CheckIfItemIsScrapAndOnShipFloor(grabbable) select grabbable).Sum((GrabbableObject x) => x.scrapValue); static bool CheckIfItemIsScrapAndOnShipFloor(GrabbableObject item) { return item.itemProperties.isScrap && item != null && !item.isPocketed && !item.isHeld; } } } public class PlayersLifeSupportMonitor : MonoBehaviour { public static PlayersLifeSupportMonitor Instance; public TextMeshProUGUI textMesh = null; public void Start() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start()")); if (!Object.op_Implicit((Object)(object)Instance)) { Instance = this; } textMesh = ((Component)this).GetComponent<TextMeshProUGUI>(); ((TMP_Text)textMesh).fontSize = 42f; ((TMP_Text)textMesh).enableWordWrapping = false; ((TMP_Text)textMesh).text = (Config.HidePlayersLifeSupport.Value ? string.Empty : "LIFE SUPPORT:\n?"); Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start() end")); } public void UpdateMonitor() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> UpdateMonitor()")); if (!Config.HidePlayersLifeSupport.Value) { ((MonoBehaviour)CoroutineHelper.Instance).StartCoroutine(UpdateMonitorCoroutine()); } } private IEnumerator UpdateMonitorCoroutine() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> UpdateCoroutine(), waiting 2 seconds before updating due to slow player loading")); yield return (object)new WaitForSeconds(2f); StringBuilder builder = new StringBuilder().AppendLine("LIFE SUPPORT:").AppendLine(); foreach (PlayerControllerB player in StartOfRound.Instance.ClientPlayerList.Keys.Select((ulong playerId) => StartOfRound.Instance.allPlayerScripts[playerId])) { builder.Append((player.playerUsername.Length > 15) ? ("- " + player.playerUsername.Substring(0, 15) + "... ") : ("- " + player.playerUsername + " ")); if (player.isPlayerDead) { Plugin.ModLogger.LogDebug((object)("-> " + player.playerUsername + " is dead")); builder.AppendLine("<color=#FF0000>(DEAD)</color>"); } else if (player.health <= 50) { Plugin.ModLogger.LogDebug((object)$"-> {player.playerUsername} is injured! {player.health}"); builder.AppendLine("<color=#FFF01C>(HURT)</color>"); } else { Plugin.ModLogger.LogDebug((object)("-> " + player.playerUsername + " is still alive!")); builder.AppendLine(); } } ((TMP_Text)textMesh).text = builder.ToString(); } } internal static class Setup { private const string MonitorContainerPath = "Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer"; private static GameObject _mainContainer = null; private static GameObject _quotaMonitorText = null; private static GameObject _deadlineMonitorText = null; private static readonly Vector3 TopRowLocalRotation = new Vector3(351.5f, 0f); private static readonly Vector3 LeftMonitorGroupBottomRowLocalRotation = new Vector3(9.5577f, 0f); private static readonly Vector3 RightMonitorGroupLocalRotation = new Vector3(0f, 24.9f, 5.4f); private static readonly Dictionary<int, Tuple<Vector3, Vector3>> MonitorPositionsBySlots = new Dictionary<int, Tuple<Vector3, Vector3>> { { 1, new Tuple<Vector3, Vector3>(new Vector3(-233f, 24f, 21f), LeftMonitorGroupBottomRowLocalRotation) }, { 2, new Tuple<Vector3, Vector3>(new Vector3(240f, 24f, 21f), LeftMonitorGroupBottomRowLocalRotation) }, { 3, new Tuple<Vector3, Vector3>(new Vector3(797f, 29f, -101f), new Vector3(8.4566f, 26.5f, RightMonitorGroupLocalRotation.z)) }, { 4, new Tuple<Vector3, Vector3>(new Vector3(1220f, 80f, -304f), new Vector3(8.4566f, RightMonitorGroupLocalRotation.y, RightMonitorGroupLocalRotation.z)) }, { 5, new Tuple<Vector3, Vector3>(new Vector3(-233f, 480f), TopRowLocalRotation) }, { 6, new Tuple<Vector3, Vector3>(new Vector3(240f, 480f), TopRowLocalRotation) }, { 7, new Tuple<Vector3, Vector3>(new Vector3(748f, 500f, -110f), TopRowLocalRotation + RightMonitorGroupLocalRotation) }, { 8, new Tuple<Vector3, Vector3>(new Vector3(1170f, 540f, -310.3f), TopRowLocalRotation + RightMonitorGroupLocalRotation) }, { 9, new Tuple<Vector3, Vector3>(new Vector3(905f, -545f, -235f), new Vector3(10.5f, 26.2f, 5.2f)) } }; public static void Initialize() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) _mainContainer = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer"); _quotaMonitorText = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer/HeaderText"); MonitorPositionsBySlots[Config.ProfitQuotaMonitorSlot.Value].Deconstruct(out var item, out var item2); Vector3 localPosition = item; Vector3 val = item2; _quotaMonitorText.transform.localPosition = localPosition; _quotaMonitorText.transform.localRotation = Quaternion.Euler(val); if (!Config.KeepBlueBackground1.Value) { Plugin.ModLogger.LogDebug((object)"Destroying Quota BG"); Object.Destroy((Object)(object)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer/BG")); } if (!Config.KeepBlueBackground2.Value) { Plugin.ModLogger.LogDebug((object)"Destroying Deadline BG"); Object.Destroy((Object)(object)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer/BG (1)")); } _deadlineMonitorText = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube/Canvas (1)/MainContainer/HeaderText (1)"); MonitorPositionsBySlots[Config.DeadlineMonitorSlot.Value].Deconstruct(out item2, out item); Vector3 localPosition2 = item2; Vector3 val2 = item; _deadlineMonitorText.transform.localPosition = localPosition2; _deadlineMonitorText.transform.localRotation = Quaternion.Euler(val2); LifeSupportMonitor.Instance = CreateMonitor<LifeSupportMonitor>(Config.LifeSupportMonitorSlot.Value); LootMonitor.Instance = CreateMonitor<LootMonitor>(Config.LootMonitorSlot.Value); TimeMonitor.Instance = CreateMonitor<TimeMonitor>(Config.TimeMonitorSlot.Value); CreditsMonitor.Instance = CreateMonitor<CreditsMonitor>(Config.CreditsMonitorSlot.Value); DayMonitor.Instance = CreateMonitor<DayMonitor>(Config.DayMonitorSlot.Value); PlayersLifeSupportMonitor.Instance = CreateMonitor<PlayersLifeSupportMonitor>(9); } private static T CreateMonitor<T>(int targetSlot) where T : MonoBehaviour { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) string text = typeof(T).Name.Replace("Monitor", ""); Plugin.ModLogger.LogDebug((object)("Creating Monitor " + text)); GameObject val = Object.Instantiate<GameObject>(_quotaMonitorText, _mainContainer.transform); ((Object)val).name = text; TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>(); var (localPosition, val4) = MonitorPositionsBySlots[targetSlot]; ((TMP_Text)component).transform.localPosition = localPosition; ((TMP_Text)component).transform.localRotation = Quaternion.Euler(val4); Plugin.ModLogger.LogDebug((object)("Monitor " + text + " created")); return val.AddComponent<T>(); } } public class TimeMonitor : MonoBehaviour { public static TimeMonitor Instance; public TextMeshProUGUI textMesh = null; public void Start() { Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start()")); if (!Object.op_Implicit((Object)(object)Instance)) { Instance = this; } textMesh = ((Component)this).GetComponent<TextMeshProUGUI>(); ((TMP_Text)textMesh).text = (Config.HideTime.Value ? string.Empty : "TIME:\n7:30\nAM"); Plugin.ModLogger.LogDebug((object)(((Object)this).name + " -> Start() end")); } public void UpdateMonitor() { ((TMP_Text)textMesh).text = (Config.HideTime.Value ? string.Empty : ("TIME:\n" + ((TMP_Text)HUDManager.Instance.clockNumber).text)); } } }