Please disclose if any significant portion of your mod was created 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 ImprovedClock v1.3.0
ImprovedClock.dll
Decompiled a year ago#define DEBUG using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using ImprovedClock.Dependencies; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; using MonoMod.Utils; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TestAccount666.ImprovedClock")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Your clock, but on steroids!")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+c9492439a46aa794840b8e4313afa0221c7d0a0f")] [assembly: AssemblyProduct("ImprovedClock")] [assembly: AssemblyTitle("TestAccount666.ImprovedClock")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.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 ImprovedClock { public static class ConfigManager { public static ConfigEntry<bool> enableNormalHumanBeingClock; public static ConfigEntry<bool> enableRealtimeClock; public static ConfigEntry<bool> showClockInShip; public static ConfigEntry<int> clockVisibilityInShip; public static ConfigEntry<bool> showClockInFacility; public static ConfigEntry<int> clockVisibilityInFacility; public static ConfigEntry<bool> showClockInSpectator; public static ConfigEntry<int> clockVisibilityInSpectator; public static ConfigEntry<int> clockNumberColorRed; public static ConfigEntry<int> clockNumberColorGreen; public static ConfigEntry<int> clockNumberColorBlue; public static ConfigEntry<int> clockBoxColorRed; public static ConfigEntry<int> clockBoxColorGreen; public static ConfigEntry<int> clockBoxColorBlue; public static ConfigEntry<int> clockIconColorRed; public static ConfigEntry<int> clockIconColorGreen; public static ConfigEntry<int> clockIconColorBlue; public static ConfigEntry<int> clockShipLeaveIconColorRed; public static ConfigEntry<int> clockShipLeaveIconColorGreen; public static ConfigEntry<int> clockShipLeaveIconColorBlue; public static ConfigEntry<int> clockSizeMultiplier; public static ConfigEntry<bool> useAlternativeDangerIcon; public static ConfigEntry<string> disabledClockMoons; public static void Initialize(ConfigFile configFile) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Expected O, but got Unknown //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Expected O, but got Unknown //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Expected O, but got Unknown //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected O, but got Unknown //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Expected O, but got Unknown enableNormalHumanBeingClock = configFile.Bind<bool>("General", "Enable 24 hour clock", true, "If true, will make the clock display 24 hour time instead of 12 hour time."); enableRealtimeClock = configFile.Bind<bool>("General", "Enable realtime clock", true, "If true, will make the clock update instantly."); showClockInShip = configFile.Bind<bool>("Visibility", "Show clock in ship", true, "If true, will show the click in the ship too."); clockVisibilityInShip = configFile.Bind<int>("Visibility", "Clock visibility in ship", 100, new ConfigDescription("The visibility percentage to use for clock visibility in ship.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); showClockInFacility = configFile.Bind<bool>("Visibility", "Show clock in facility", false, "If true, will show the click in the facility too."); clockVisibilityInFacility = configFile.Bind<int>("Visibility", "Clock visibility in facility", 100, new ConfigDescription("The visibility percentage to use for clock visibility in facility.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); showClockInSpectator = configFile.Bind<bool>("Visibility", "Show clock in spectator", true, "If true, will show the click in the spectator too."); clockVisibilityInSpectator = configFile.Bind<int>("Visibility", "Clock visibility in spectator", 100, new ConfigDescription("The visibility percentage to use for clock visibility in spectator.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); clockSizeMultiplier = configFile.Bind<int>("Clock Customization", "Clock Size Percentage", 100, new ConfigDescription("A multiplier applied to the clock's size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(50, 200), Array.Empty<object>())); useAlternativeDangerIcon = configFile.Bind<bool>("Clock Customization", "Use Alternative Danger Icon", false, "If true, will use an alternative danger icon."); clockNumberColorRed = configFile.Bind<int>("Number Customization", "Color Red", 255, new ConfigDescription("Defines how much red is in the clock numbers' color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockNumberColorGreen = configFile.Bind<int>("Number Customization", "Color Green", 76, new ConfigDescription("Defines how much green is in the clock numbers' color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockNumberColorBlue = configFile.Bind<int>("Number Customization", "Color Blue", 0, new ConfigDescription("Defines how much blue is in the clock numbers' color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockBoxColorRed = configFile.Bind<int>("Box Customization", "Color Red", 255, new ConfigDescription("Defines how much red is in the clock box's color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockBoxColorGreen = configFile.Bind<int>("Box Customization", "Color Green", 76, new ConfigDescription("Defines how much green is in the clock box's color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockBoxColorBlue = configFile.Bind<int>("Box Customization", "Color Blue", 0, new ConfigDescription("Defines how much blue is in the clock box's color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockIconColorRed = configFile.Bind<int>("Icon Customization", "Color Red", 255, new ConfigDescription("Defines how much red is in the clock icon's color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockIconColorGreen = configFile.Bind<int>("Icon Customization", "Color Green", 76, new ConfigDescription("Defines how much green is in the clock icon's color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockIconColorBlue = configFile.Bind<int>("Icon Customization", "Color Blue", 0, new ConfigDescription("Defines how much blue is in the clock icon's color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockShipLeaveIconColorRed = configFile.Bind<int>("Ship Leave Icon Customization", "Color Red", 255, new ConfigDescription("Defines how much red is in the clock ship leave icon's color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockShipLeaveIconColorGreen = configFile.Bind<int>("Ship Leave Icon Customization", "Color Green", 76, new ConfigDescription("Defines how much green is in the clock ship leave icon's color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); clockShipLeaveIconColorBlue = configFile.Bind<int>("Ship Leave Icon Customization", "Color Blue", 0, new ConfigDescription("Defines how much blue is in the clock ship leave icon's color", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); disabledClockMoons = configFile.Bind<string>("Special Cases", "Disabled Clock Moons", "Example1, Example2", "A comma-separated list of moons where the clock is disabled (Does *NOT* affect spectator clock.) Uses `contains`, so only names are required. For example, `Roid` will disable clock on Asteroid-13 and Asteroid-14."); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("TestAccount666.ImprovedClock", "ImprovedClock", "1.3.0")] public class ImprovedClock : BaseUnityPlugin { public static SpectatorClock? spectatorClock; public static GameObject spectatorClockPrefab = null; public static Sprite skullAlternativeSprite = null; public static Sprite skullSprite = null; public static readonly HashSet<SelectableLevel> ClockDisabledLevels = new HashSet<SelectableLevel>(); public static ImprovedClock Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("TestAccount666.ImprovedClock"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; if (DependencyChecker.IsLobbyCompatibilityInstalled()) { Logger.LogInfo((object)"Found LobbyCompatibility Mod, initializing support :)"); LobbyCompatibilitySupport.Initialize(); } ConfigManager.Initialize(((BaseUnityPlugin)this).Config); LoadAssetBundle(); Patch(); ConfigManager.clockNumberColorRed.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockNumberColorGreen.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockNumberColorBlue.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockBoxColorRed.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockBoxColorGreen.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockBoxColorBlue.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockIconColorRed.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockIconColorGreen.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockIconColorBlue.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockShipLeaveIconColorRed.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockShipLeaveIconColorGreen.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockShipLeaveIconColorBlue.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.clockSizeMultiplier.SettingChanged += delegate { SetClockColorAndSize(); }; ConfigManager.showClockInSpectator.SettingChanged += delegate { bool clockVisible = ConfigManager.showClockInSpectator.Value && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null && StartOfRound.Instance.localPlayerController.isPlayerDead; spectatorClock?.SetClockVisible(clockVisible); }; ConfigManager.clockVisibilityInSpectator.SettingChanged += delegate { spectatorClock?.SetClockVisibility(); }; ConfigManager.useAlternativeDangerIcon.SettingChanged += delegate { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)HUDManager.Instance == (Object)null)) { Sprite[] clockIcons = HUDManager.Instance.clockIcons; bool value = ConfigManager.useAlternativeDangerIcon.Value; clockIcons[^1] = (value ? skullAlternativeSprite : skullSprite); HUDManager.Instance.clockIcons = clockIcons; HUDManager.Instance.SetClockIcon(TimeOfDay.Instance.dayMode); } }; Coroutine fetchDisabledMoonsRoutine = null; fetchDisabledMoonsRoutine = ((MonoBehaviour)this).StartCoroutine(WaitAndFetchDisabledMoons()); ConfigManager.disabledClockMoons.SettingChanged += delegate { if (fetchDisabledMoonsRoutine != null) { ((MonoBehaviour)this).StopCoroutine(fetchDisabledMoonsRoutine); fetchDisabledMoonsRoutine = null; } fetchDisabledMoonsRoutine = ((MonoBehaviour)this).StartCoroutine(WaitAndFetchDisabledMoons()); }; Logger.LogInfo((object)"TestAccount666.ImprovedClock v1.3.0 has loaded!"); } private static IEnumerator WaitAndFetchDisabledMoons() { ClockDisabledLevels.Clear(); string disabledMoonsString = ConfigManager.disabledClockMoons.Value; if (string.IsNullOrWhiteSpace(disabledMoonsString)) { yield break; } List<string> disabledMoons = disabledMoonsString.Replace(", ", ",").Split(',').ToList(); if (disabledMoons.Count <= 0) { yield break; } yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)StartOfRound.Instance != (Object)null && Object.op_Implicit((Object)(object)StartOfRound.Instance))); yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null)); SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel selectableLevel in levels) { string levelName = selectableLevel.PlanetName; foreach (string item in disabledMoons.Where((string disabledMoon) => levelName.ToLower().Contains(disabledMoon.ToLower()))) { _ = item; ClockDisabledLevels.Add(selectableLevel); } } } private static void LoadAssetBundle() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string directoryName = Path.GetDirectoryName(executingAssembly.Location); Debug.Assert(directoryName != null, "assemblyDirectory != null"); AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "improvedclock")); spectatorClockPrefab = val.LoadAsset<GameObject>("Assets/LethalCompany/Mods/ImprovedClock/SpectatorClock.prefab"); Object.DontDestroyOnLoad((Object)(object)spectatorClockPrefab); skullAlternativeSprite = val.LoadAsset<Sprite>("Assets/LethalCompany/Mods/ImprovedClock/SkullAlternative.png"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } public static void SetClockColorAndSize() { //IL_002d: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)HUDManager.Instance == (Object)null)) { Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(-0.5893304f, 0.5893304f, 0.5893303f); val *= (float)ConfigManager.clockSizeMultiplier.Value / 100f; Color color = default(Color); ((Color)(ref color))..ctor(0.003921569f * (float)ConfigManager.clockNumberColorRed.Value, 0.003921569f * (float)ConfigManager.clockNumberColorGreen.Value, 0.003921569f * (float)ConfigManager.clockNumberColorBlue.Value, 1f); Color color2 = default(Color); ((Color)(ref color2))..ctor(0.003921569f * (float)ConfigManager.clockBoxColorRed.Value, 0.003921569f * (float)ConfigManager.clockBoxColorGreen.Value, 0.003921569f * (float)ConfigManager.clockBoxColorBlue.Value, 1f); Color color3 = default(Color); ((Color)(ref color3))..ctor(0.003921569f * (float)ConfigManager.clockIconColorRed.Value, 0.003921569f * (float)ConfigManager.clockIconColorGreen.Value, 0.003921569f * (float)ConfigManager.clockIconColorBlue.Value, 1f); Color color4 = default(Color); ((Color)(ref color4))..ctor(0.003921569f * (float)ConfigManager.clockShipLeaveIconColorRed.Value, 0.003921569f * (float)ConfigManager.clockShipLeaveIconColorGreen.Value, 0.003921569f * (float)ConfigManager.clockShipLeaveIconColorBlue.Value, 1f); TextMeshProUGUI clockNumber = HUDManager.Instance.clockNumber; ((Graphic)clockNumber).color = color; Transform parent = ((TMP_Text)clockNumber).transform.parent; Image component = ((Component)parent).GetComponent<Image>(); ((Graphic)component).color = color2; ((Component)parent).transform.localScale = val; Image clockIcon = HUDManager.Instance.clockIcon; ((Graphic)clockIcon).color = color3; Image shipLeavingEarlyIcon = HUDManager.Instance.shipLeavingEarlyIcon; ((Graphic)shipLeavingEarlyIcon).color = color4; if (!((Object)(object)spectatorClock == (Object)null) && Object.op_Implicit((Object)(object)spectatorClock)) { ((Graphic)spectatorClock.clockNumber).color = color; ((Graphic)spectatorClock.clockIcon).color = color3; ((Graphic)spectatorClock.clockBox).color = color2; ((Component)spectatorClock.clockBox).transform.localScale = val; ((Graphic)spectatorClock.shipLeaveIcon).color = color4; } } } } public class SpectatorClock : MonoBehaviour { public CanvasGroup canvasGroup; public TextMeshProUGUI clockNumber; public Image clockIcon; public Image clockBox; public Image shipLeaveIcon; private void Start() { SetClock(); ImprovedClock.SetClockColorAndSize(); SetClockVisibility(); } public void SetClockVisibility() { canvasGroup.alpha = ConfigManager.clockVisibilityInSpectator.Value; } public void SetShipLeaveIconVisible(bool visible) { ((Behaviour)shipLeaveIcon).enabled = visible && ((Behaviour)canvasGroup).enabled; } public void SetClock() { ((TMP_Text)clockNumber).text = ((TMP_Text)HUDManager.Instance.clockNumber).text; clockIcon.sprite = HUDManager.Instance.clockIcon.sprite; } public void SetClockVisible(bool visible) { ImprovedClock.Logger.LogDebug((object)$"Toggling SpectatorClock visibility! Visible? {visible}"); canvasGroup.alpha = (visible ? ((float)ConfigManager.clockVisibilityInSpectator.Value) : 0f); ((Behaviour)canvasGroup).enabled = visible; ((Behaviour)clockNumber).enabled = visible; ((Behaviour)clockIcon).enabled = visible; ((Behaviour)clockBox).enabled = visible; SetShipLeaveIconVisible(visible && TimeOfDay.Instance.shipLeavingAlertCalled); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TestAccount666.ImprovedClock"; public const string PLUGIN_NAME = "ImprovedClock"; public const string PLUGIN_VERSION = "1.3.0"; } } namespace ImprovedClock.Patches { [HarmonyPatch(typeof(HUDManager))] public static class HUDManagerPatch { public static bool skipAlphaCheck; [HarmonyPatch("OnEnable")] [HarmonyPostfix] private static void SetClockColor() { ImprovedClock.SetClockColorAndSize(); Sprite[] clockIcons = HUDManager.Instance.clockIcons; ImprovedClock.skullSprite = clockIcons[^1]; if (ConfigManager.useAlternativeDangerIcon.Value) { clockIcons[^1] = ImprovedClock.skullAlternativeSprite; HUDManager.Instance.clockIcons = clockIcons; } } [HarmonyPatch("SetClock")] [HarmonyPrefix] private static bool SetNormalHumanBeingClock(float timeNormalized, float numberOfHours, bool createNewLine, ref string __result) { if (!ConfigManager.enableNormalHumanBeingClock.Value) { ImprovedClock.spectatorClock?.SetClock(); return true; } HUDManager instance = HUDManager.Instance; int num = (int)((double)timeNormalized * (60.0 * (double)numberOfHours)) + 360; int num2 = (int)Mathf.Floor((float)num / 60f); instance.newLine = (createNewLine ? "\n" : " "); instance.amPM = "12:00" + instance.newLine + "AM"; if (num2 >= 24) { ((TMP_Text)instance.clockNumber).text = "24:00 " + instance.newLine; __result = "24:00\n"; ImprovedClock.spectatorClock?.SetClock(); return false; } instance.amPM = ((num2 >= 12) ? (instance.newLine + "PM") : (instance.newLine + "AM")); int num3 = num % 60; string text = $"{num2:00}:{num3:00}"; ((TMP_Text)instance.clockNumber).text = text; __result = text; ImprovedClock.spectatorClock?.SetClock(); return false; } [HarmonyPatch("SetClockVisible")] [HarmonyPrefix] private static void SetClockVisible(ref bool visible) { SelectableLevel currentLevel = StartOfRound.Instance.currentLevel; if (ImprovedClock.ClockDisabledLevels.Contains(currentLevel)) { visible = false; return; } PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if (localPlayerController.inTerminalMenu) { visible = false; } else if (visible) { skipAlphaCheck = true; } else if ((ConfigManager.showClockInShip.Value || !localPlayerController.isInHangarShipRoom) && (ConfigManager.showClockInFacility.Value || !localPlayerController.isInsideFactory)) { visible = true; } } [HarmonyPatch("SetClockVisible")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ModifyTargetAlpha(IEnumerable<CodeInstruction> instructions) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); try { List<CodeInstruction> list2 = list; List<CodeInstruction> list3 = new List<CodeInstruction>(list2.Count); list3.AddRange(list2); List<CodeInstruction> list4 = list3; for (int i = 0; i < list4.Count; i++) { CodeInstruction val = list4[i]; if (!(val.opcode != OpCodes.Ldc_R4)) { ImprovedClock.Logger.LogInfo((object)"Successfully found correct instruction!"); list4[i] = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HUDManagerPatch), "GetTargetAlpha", (Type[])null, (Type[])null)); list4.Insert(i + 1, new CodeInstruction(OpCodes.Stloc_0, (object)null)); list4.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_0, (object)null)); break; } } return list4; } catch (Exception ex) { Extensions.LogDetailed(ex, (string)null); return list; } } public static float GetTargetAlpha() { if (skipAlphaCheck) { skipAlphaCheck = false; return 1f; } PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if (localPlayerController.isInsideFactory) { return (float)ConfigManager.clockVisibilityInFacility.Value / 100f; } return localPlayerController.isInHangarShipRoom ? ((float)ConfigManager.clockVisibilityInShip.Value / 100f) : 1f; } [HarmonyPatch("RemoveSpectateUI")] [HarmonyPostfix] private static void DisableSpectatorClock() { if ((Object)(object)ImprovedClock.spectatorClock == (Object)null) { ImprovedClock.Logger.LogError((object)"Couldn't find SpectatorClock!"); return; } ImprovedClock.spectatorClock.SetClockVisible(visible: false); ImprovedClock.spectatorClock?.SetShipLeaveIconVisible(visible: false); } } [HarmonyPatch(typeof(PlayerControllerB))] public static class PlayerControllerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void CreateSpectatorClock(PlayerControllerB __instance) { ((MonoBehaviour)__instance).StartCoroutine(WaitAndCreateSpectatorClock(__instance)); } [HarmonyPatch("KillPlayer")] [HarmonyPrefix] private static void EnableSpectatorClock(PlayerControllerB __instance) { if (!ConfigManager.showClockInSpectator.Value || !StartOfRound.Instance.currentLevel.planetHasTime) { return; } PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if (!((Object)(object)localPlayerController != (Object)(object)__instance)) { if ((Object)(object)ImprovedClock.spectatorClock == (Object)null) { ImprovedClock.Logger.LogError((object)"Couldn't find SpectatorClock!"); } else { ImprovedClock.spectatorClock.SetClockVisible(visible: true); } } } public static IEnumerator WaitAndCreateSpectatorClock(PlayerControllerB playerControllerB) { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)StartOfRound.Instance != (Object)null && Object.op_Implicit((Object)(object)StartOfRound.Instance))); yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null && Object.op_Implicit((Object)(object)StartOfRound.Instance.localPlayerController))); if ((Object)(object)StartOfRound.Instance.localPlayerController != (Object)(object)playerControllerB) { ImprovedClock.Logger.LogDebug((object)"Not local player!"); yield break; } yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)HUDManager.Instance != (Object)null && Object.op_Implicit((Object)(object)HUDManager.Instance))); yield return (object)new WaitUntil((Func<bool>)(() => HUDManager.Instance.Clock != null)); Transform canvasPanel = ((Component)HUDManager.Instance.Clock.canvasGroup).transform.parent.parent; GameObject spectatorClockObject = Object.Instantiate<GameObject>(ImprovedClock.spectatorClockPrefab, canvasPanel); spectatorClockObject.transform.SetSiblingIndex(1); ImprovedClock.spectatorClock = spectatorClockObject.GetComponent<SpectatorClock>(); Object.DontDestroyOnLoad((Object)(object)ImprovedClock.spectatorClock); ImprovedClock.Logger.LogDebug((object)"Clock created!"); ImprovedClock.spectatorClock.SetClockVisible(visible: false); ImprovedClock.spectatorClock?.SetShipLeaveIconVisible(visible: false); } } [HarmonyPatch(typeof(StartOfRound))] public static class StartOfRoundPatch { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] private static void DisableSpectatorClock() { if ((Object)(object)ImprovedClock.spectatorClock == (Object)null) { ImprovedClock.Logger.LogError((object)"Couldn't find SpectatorClock!"); return; } ImprovedClock.spectatorClock.SetClockVisible(visible: false); ImprovedClock.spectatorClock?.SetShipLeaveIconVisible(visible: false); } } [HarmonyPatch(typeof(TimeOfDay))] public static class TimeOfDayPatch { [HarmonyPatch("MoveTimeOfDay")] [HarmonyPrefix] private static void SetHudTimeRefresh() { if (ConfigManager.enableRealtimeClock.Value) { TimeOfDay.Instance.changeHUDTimeInterval = 4f; } } [HarmonyPatch("SetShipLeaveEarlyClientRpc")] [HarmonyPrefix] private static void SetShipLeaveIconVisibility() { ShipLeaving(); } [HarmonyPatch("TimeOfDayEvents")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ListenForShipLeave(IEnumerable<CodeInstruction> instructions) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); try { List<CodeInstruction> list2 = list; List<CodeInstruction> list3 = new List<CodeInstruction>(list2.Count); list3.AddRange(list2); List<CodeInstruction> list4 = list3; for (int i = 0; i < list4.Count; i++) { CodeInstruction val = list4[i]; if (!(val.opcode != OpCodes.Stfld) && val.operand is FieldInfo fieldInfo && !(fieldInfo.FieldType != typeof(bool)) && fieldInfo.Name.Contains("shipLeavingAlertCalled")) { list4.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(TimeOfDayPatch), "ShipLeaving", (Type[])null, (Type[])null))); ImprovedClock.Logger.LogInfo((object)"Found ship leaving alert instruction!"); break; } } return list4; } catch (Exception ex) { Extensions.LogDetailed(ex, (string)null); return list; } } public static void ShipLeaving() { ImprovedClock.spectatorClock?.SetShipLeaveIconVisible(visible: true); } } } namespace ImprovedClock.Dependencies { internal static class DependencyChecker { internal static bool IsLobbyCompatibilityInstalled() { return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Contains("LobbyCompatibility")); } } internal static class LobbyCompatibilitySupport { internal static void Initialize() { PluginHelper.RegisterPlugin("TestAccount666.ImprovedClock", new Version("1.3.0"), (CompatibilityLevel)0, (VersionStrictness)2); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }