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 NicheFixes v1.0.0
NicheFixes.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Steamworks; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("NicheFixes")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was fully created with Generative AI assistance (code written by an AI agent).")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic (Claude Opus 5.5)")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 NicheFixes { [BepInPlugin("nicheteam.nichefixes", "NicheFixes", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "nicheteam.nichefixes"; public const string Name = "NicheFixes"; public const string Version = "1.0.0"; internal const string MapClickCodesGuid = "com.benhough.lethal.MapClickCodes"; internal const string ShipSystemsGuid = "com.y4ngz.company.shipsystems"; internal const string MonitorLabelsGuid = "LethalCompany.Lego.MonitorLabelContinued"; internal const string LethalCctvGuid = "com.y4ngz.company.lethalcctv"; internal static ManualLogSource Log; internal static ConfigEntry<bool> TextGuardOn; internal static ConfigEntry<bool> MapClickGuardOn; internal static ConfigEntry<bool> ChuteWatchdogOn; internal static ConfigEntry<bool> RadarNamesOn; internal static ConfigEntry<bool> CctvPanelFitOn; internal static ConfigEntry<int> ChuteStuckSeconds; internal static ConfigEntry<int> CctvPanelWidth; internal static ConfigEntry<int> CctvPanelHeight; private void Awake() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; TextGuardOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "Text Font Guard", true, "Repairs text that has lost its font or font material instead of letting it throw an error every frame. Logs which object it fixed, once."); MapClickGuardOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "MapClickCodes Menu Guard", true, "Stops MapClickCodes from throwing an error every frame on the main menu, before a lobby exists."); ChuteWatchdogOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "Fuel Chute Watchdog", true, "Host only. Restarts Ship Systems' fuel chute setup if it gets stuck, which can happen after going back to the menu and hosting again."); RadarNamesOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "Radar Player Names", true, "Shows each player's real name on the radar (and on Monitor Label tags) instead of \"Player\". Only changes what you see."); ChuteStuckSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("Fixes", "Fuel Chute Stuck Seconds", 20, new ConfigDescription("How long the chute setup may stay unfinished before the watchdog restarts it.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 120), Array.Empty<object>())); CctvPanelFitOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "CCTV Panel Fit", true, "Fits LethalCCTV's mainframe and hacking panels inside the CCTV monitor instead of letting them hang off the left and right edges."); CctvPanelWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Fixes", "CCTV Panel Width Percent", 92, new ConfigDescription("How much of the monitor's width the panel may use. Lower it if the sides still touch the edge.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(50, 100), Array.Empty<object>())); CctvPanelHeight = ((BaseUnityPlugin)this).Config.Bind<int>("Fixes", "CCTV Panel Height Percent", 92, new ConfigDescription("How much of the monitor's height the panel may use. Lower it if the top or bottom touches the edge.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(50, 100), Array.Empty<object>())); Harmony harmony = new Harmony("nicheteam.nichefixes"); int num = 0; if (TextGuardOn.Value && TextFontGuard.Apply(harmony)) { num++; } if (MapClickGuardOn.Value && MapClickCodesGuard.Apply(harmony)) { num++; } if (ChuteWatchdogOn.Value && FuelChuteWatchdog.Prepare()) { num++; } if (RadarNamesOn.Value) { num++; } if (CctvPanelFitOn.Value && CctvPanelFit.Apply(harmony)) { num++; } GameObject val = new GameObject("NicheFixes.Runner"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<Runner>(); Log.LogInfo((object)string.Format("{0} {1} loaded with {2} fix(es) active.", "NicheFixes", "1.0.0", num)); } internal static Assembly PluginAssembly(string guid) { if (!Chainloader.PluginInfos.TryGetValue(guid, out var value) || !((Object)(object)((value != null) ? value.Instance : null) != (Object)null)) { return null; } return ((object)value.Instance).GetType().Assembly; } } internal sealed class Runner : MonoBehaviour { private float _next; private void Update() { if (Time.realtimeSinceStartup < _next) { return; } _next = Time.realtimeSinceStartup + 2f; try { FuelChuteWatchdog.Tick(); } catch (Exception ex) { FuelChuteWatchdog.Disable("unexpected error: " + ex.Message); } try { RadarNameSync.Tick(); } catch (Exception ex2) { RadarNameSync.Disable("unexpected error: " + ex2.Message); } } } internal static class RadarNameSync { private static bool _off; private static MethodInfo _refreshLabels; private static bool _labelsLooked; private static ManualCameraRenderer[] _renderers = (ManualCameraRenderer[])(object)new ManualCameraRenderer[0]; private static float _nextRendererScan; private static int _lobby; internal static void Disable(string why) { if (!_off) { _off = true; Plugin.Log.LogWarning((object)("Radar name sync turned off: " + why)); } } internal static void Tick() { if (_off || !Plugin.RadarNamesOn.Value) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return; } int instanceID = ((Object)instance).GetInstanceID(); if (instanceID != _lobby || Time.realtimeSinceStartup > _nextRendererScan) { _lobby = instanceID; _nextRendererScan = Time.realtimeSinceStartup + 15f; _renderers = Object.FindObjectsOfType<ManualCameraRenderer>(); } bool flag = false; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val == (Object)null || (!val.isPlayerControlled && !val.isPlayerDead)) { continue; } string text = val.playerUsername; if (IsPlaceholder(text) && TrySteamName(val.playerSteamId, out var name)) { text = (val.playerUsername = name); if ((Object)(object)val.usernameBillboardText != (Object)null) { ((TMP_Text)val.usernameBillboardText).text = name; } flag = true; } if (IsPlaceholder(text)) { continue; } ManualCameraRenderer[] renderers = _renderers; foreach (ManualCameraRenderer val2 in renderers) { if ((Object)(object)val2 == (Object)null || val2.radarTargets == null) { continue; } foreach (TransformAndName radarTarget in val2.radarTargets) { if (radarTarget != null && !radarTarget.isNonPlayer && !((Object)(object)radarTarget.transform != (Object)(object)((Component)val).transform) && !(radarTarget.name == text)) { radarTarget.name = text; flag = true; } } } } if (flag) { if ((Object)(object)instance.mapScreen != (Object)null) { instance.mapScreen.UpdateRadarTargetName(); } RefreshMonitorLabels(); } } private static bool IsPlaceholder(string name) { if (string.IsNullOrWhiteSpace(name)) { return true; } string text = name.Trim(); if (!text.Equals("Player", StringComparison.OrdinalIgnoreCase)) { return text.StartsWith("Player #", StringComparison.OrdinalIgnoreCase); } return true; } private static bool TrySteamName(ulong steamId, out string name) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) name = null; if (steamId == 0L) { return false; } try { if (!SteamClient.IsValid) { return false; } Friend val = new Friend(SteamId.op_Implicit(steamId)); name = ((Friend)(ref val)).Name; return !string.IsNullOrWhiteSpace(name) && !IsPlaceholder(name); } catch { return false; } } private static void RefreshMonitorLabels() { if (!_labelsLooked) { _labelsLooked = true; _refreshLabels = Plugin.PluginAssembly("LethalCompany.Lego.MonitorLabelContinued")?.GetType("MonitorLabelsContinued.BulkImport.RadarTargetLabelManager")?.GetMethod("UpdateLabels", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(int) }, null); } if (_refreshLabels == null) { return; } try { _refreshLabels.Invoke(null, new object[1] { -1 }); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not refresh Monitor Label names: " + ex.Message)); _refreshLabels = null; } } } internal static class TextFontGuard { private static TMP_FontAsset _fallback; private static readonly HashSet<int> Reported = new HashSet<int>(); private static int _reports; private static int _skipped; internal static bool Apply(Harmony harmony) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown try { HarmonyMethod val = new HarmonyMethod(typeof(TextFontGuard).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic)); List<MethodBase> list = new List<MethodBase>(); list.Add(AccessTools.Method(typeof(TextMeshPro), "Rebuild", new Type[1] { typeof(CanvasUpdate) }, (Type[])null)); list.Add(AccessTools.Method(typeof(TextMeshProUGUI), "Rebuild", new Type[1] { typeof(CanvasUpdate) }, (Type[])null)); list.Add(AccessTools.Method(typeof(TextMeshPro), "ForceMeshUpdate", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null)); list.Add(AccessTools.Method(typeof(TextMeshProUGUI), "ForceMeshUpdate", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null)); int num = 0; foreach (MethodBase item in list) { if (!(item == null)) { harmony.Patch(item, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } } if (num == 0) { Plugin.Log.LogWarning((object)"Text font guard: no text methods found; off."); return false; } return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Text font guard could not start: " + ex.Message)); return false; } } private static bool Prefix(TMP_Text __instance) { if ((Object)(object)__instance == (Object)null) { return true; } TMP_FontAsset font = __instance.font; if ((Object)(object)font != (Object)null && (Object)(object)((TMP_Asset)font).material != (Object)null && (Object)(object)__instance.fontSharedMaterial != (Object)null) { return true; } return Repair(__instance); } private static bool Repair(TMP_Text text) { try { TMP_FontAsset font = text.font; string text2; if ((Object)(object)font == (Object)null || (Object)(object)((TMP_Asset)font).material == (Object)null) { text2 = (((Object)(object)font == (Object)null) ? "font" : "font material"); TMP_FontAsset val = Fallback(); if ((Object)(object)val == (Object)null) { return Skip(text, text2 + " (no fallback font loaded yet)"); } text.font = val; } else { text2 = "material"; } if ((Object)(object)text.fontSharedMaterial == (Object)null) { text.fontSharedMaterial = ((TMP_Asset)text.font).material; } bool flag = (Object)(object)text.font != (Object)null && (Object)(object)((TMP_Asset)text.font).material != (Object)null && (Object)(object)text.fontSharedMaterial != (Object)null; Report(text, text2, flag ? ("fixed with font '" + ((Object)text.font).name + "'") : "could not fix, skipped"); return flag; } catch (Exception ex) { return Skip(text, "repair failed: " + ex.Message); } } private static bool Skip(TMP_Text text, string why) { _skipped++; Report(text, why, "skipped its redraw to avoid an error"); return false; } private static void Report(TMP_Text text, string missing, string outcome) { if (_reports < 25 && Reported.Add(((Object)text).GetInstanceID())) { _reports++; Plugin.Log.LogWarning((object)("Text '" + PathOf(text.transform) + "' was missing its " + missing + "; " + outcome + ".")); } } private static TMP_FontAsset Fallback() { if ((Object)(object)_fallback != (Object)null && (Object)(object)((TMP_Asset)_fallback).material != (Object)null) { return _fallback; } _fallback = null; try { TMP_FontAsset defaultFontAsset = TMP_Settings.defaultFontAsset; if ((Object)(object)defaultFontAsset != (Object)null && (Object)(object)((TMP_Asset)defaultFontAsset).material != (Object)null) { return _fallback = defaultFontAsset; } } catch { } try { HUDManager instance = HUDManager.Instance; if ((Object)(object)instance != (Object)null && instance.controlTipLines != null) { TextMeshProUGUI[] controlTipLines = instance.controlTipLines; foreach (TextMeshProUGUI val in controlTipLines) { if ((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)val).font != (Object)null && (Object)(object)((TMP_Asset)((TMP_Text)val).font).material != (Object)null) { return _fallback = ((TMP_Text)val).font; } } } } catch { } TMP_FontAsset val2 = null; TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); foreach (TMP_FontAsset val3 in array) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((TMP_Asset)val3).material == (Object)null)) { if (((Object)val3).name.IndexOf("3270", StringComparison.OrdinalIgnoreCase) >= 0) { return _fallback = val3; } if ((Object)(object)val2 == (Object)null) { val2 = val3; } } } return _fallback = val2; } private static string PathOf(Transform t) { List<string> list = new List<string>(); int num = 0; while ((Object)(object)t != (Object)null && num < 6) { list.Add(((Object)t).name); num++; t = t.parent; } list.Reverse(); return string.Join("/", list); } } internal static class MapClickCodesGuard { internal static bool Apply(Harmony harmony) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown try { Assembly assembly = Plugin.PluginAssembly("com.benhough.lethal.MapClickCodes"); if (assembly == null) { Plugin.Log.LogInfo((object)"MapClickCodes not installed; its guard is off."); return false; } MethodInfo methodInfo = assembly.GetType("MapClickCodes.HostModGate")?.GetMethod("EnsureRegistered", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (methodInfo == null) { Plugin.Log.LogWarning((object)"MapClickCodes changed (no HostModGate.EnsureRegistered); its guard is off."); return false; } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(MapClickCodesGuard).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("MapClickCodes guard could not start: " + ex.Message)); return false; } } private static bool Prefix() { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null)) { return singleton.CustomMessagingManager != null; } return true; } } internal static class CctvPanelFit { private const string DisplayType = "Y4NGZCompany.ShipSystems.Surveillance.CCTVVanillaMonitorDisplay"; private const string FocusType = "Y4NGZCompany.ShipSystems.Surveillance.MonitorFocus"; private static readonly Vector2 FallbackCanvas = new Vector2(768f, 576f); private static FieldInfo _overlayRoot; private static float _widthFraction = 0.92f; private static float _heightFraction = 0.92f; private static bool _failed; private static bool _logged; internal static bool Apply(Harmony harmony) { //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown try { Assembly assembly = Plugin.PluginAssembly("com.y4ngz.company.lethalcctv"); if (assembly == null) { Plugin.Log.LogInfo((object)"LethalCCTV not installed; CCTV panel fit is off."); return false; } Type type = assembly.GetType("Y4NGZCompany.ShipSystems.Surveillance.CCTVVanillaMonitorDisplay"); Type type2 = typeof(Vector2).MakeByRefType(); MethodInfo methodInfo = assembly.GetType("Y4NGZCompany.ShipSystems.Surveillance.MonitorFocus")?.GetMethod("ResolveInteractiveOverlayDock", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[3] { typeof(bool), type2, type2 }, null); ParameterInfo[] array = methodInfo?.GetParameters(); if (type == null || array == null || array[0].Name != "lowerLeftMonitor" || array[2].Name != "dockSize") { Plugin.Log.LogWarning((object)"LethalCCTV changed (no MonitorFocus.ResolveInteractiveOverlayDock); CCTV panel fit is off."); return false; } _overlayRoot = type.GetField("_leftTerminalOverlayRoot", BindingFlags.Static | BindingFlags.NonPublic); if (_overlayRoot != null && _overlayRoot.FieldType != typeof(RectTransform)) { _overlayRoot = null; } _widthFraction = (float)Mathf.Clamp(Plugin.CctvPanelWidth.Value, 50, 100) / 100f; _heightFraction = (float)Mathf.Clamp(Plugin.CctvPanelHeight.Value, 50, 100) / 100f; harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(CctvPanelFit).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("CCTV panel fit could not start: " + ex.Message)); return false; } } private static void Postfix(bool lowerLeftMonitor, ref Vector2 dockSize) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (_failed || !lowerLeftMonitor) { return; } try { Vector2 val = FallbackCanvas; object? obj = _overlayRoot?.GetValue(null); RectTransform val2 = (RectTransform)((obj is RectTransform) ? obj : null); if ((Object)(object)val2 != (Object)null) { Rect rect = val2.rect; if (((Rect)(ref rect)).width > 1f && ((Rect)(ref rect)).height > 1f) { val = ((Rect)(ref rect)).size; } } Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(val.x * _widthFraction, val.y * _heightFraction); if (!_logged) { _logged = true; Plugin.Log.LogInfo((object)$"CCTV panel fit: monitor {val.x:0}x{val.y:0}, panel box {dockSize.x:0}x{dockSize.y:0} -> {val3.x:0}x{val3.y:0}."); } dockSize = val3; } catch (Exception ex) { _failed = true; Plugin.Log.LogWarning((object)("CCTV panel fit stopped after an error, panels use LethalCCTV's own size: " + ex.Message)); } } } internal static class FuelChuteWatchdog { private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static bool _ready; private static PropertyInfo _instance; private static FieldInfo _stageActive; private static FieldInfo _chute; private static MethodInfo _abort; private static MethodInfo _fuelEnabled; private static MethodInfo _isServer; private static float _activeSince = -1f; private static int _restarts; private static int _clearedForLobby; internal static bool Prepare() { try { Assembly assembly = Plugin.PluginAssembly("com.y4ngz.company.shipsystems"); if (assembly == null) { Plugin.Log.LogInfo((object)"Ship Systems not installed; fuel chute watchdog is off."); return false; } Type type = assembly.GetType("Y4NGZCompany.ShipSystems.Layout.ShipSystemsController"); _instance = type?.GetProperty("Instance", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _stageActive = type?.GetField("_fuelStageActive", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _chute = type?.GetField("_fuelChute", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _abort = type?.GetMethod("AbortFuelChuteStaging", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null); _fuelEnabled = type?.GetMethod("get_FuelSystemEnabled", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); _isServer = type?.GetMethod("IsServer", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); _ready = _instance != null && _stageActive != null && _chute != null && _abort != null && _fuelEnabled != null && _isServer != null; if (!_ready) { Plugin.Log.LogWarning((object)"Ship Systems changed; fuel chute watchdog is off."); } return _ready; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Fuel chute watchdog could not start: " + ex.Message)); return false; } } internal static void Disable(string why) { if (_ready) { _ready = false; Plugin.Log.LogWarning((object)("Fuel chute watchdog turned off: " + why)); } } internal static void Tick() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (!_ready || (Object)(object)StartOfRound.Instance == (Object)null) { _activeSince = -1f; return; } object value = _instance.GetValue(null, null); MonoBehaviour val = (MonoBehaviour)((value is MonoBehaviour) ? value : null); if (val == null || (Object)(object)val == (Object)null) { _activeSince = -1f; return; } if (!(bool)_isServer.Invoke(null, null) || !(bool)_fuelEnabled.Invoke(value, null)) { _activeSince = -1f; return; } int instanceID = ((Object)StartOfRound.Instance).GetInstanceID(); if (instanceID != _clearedForLobby) { object? value2 = _chute.GetValue(value); Component val2 = (Component)((value2 is Component) ? value2 : null); if (val2 != null && (Object)(object)val2 != (Object)null) { Scene scene = val2.gameObject.scene; if (!((Scene)(ref scene)).isLoaded || ((Scene)(ref scene)).name == "DontDestroyOnLoad") { _clearedForLobby = instanceID; _chute.SetValue(value, null); Plugin.Log.LogWarning((object)"Fuel chute from an earlier lobby was still referenced; cleared so Ship Systems builds a new one."); } } } if ((bool)_stageActive.GetValue(value)) { if (_activeSince < 0f) { _activeSince = Time.realtimeSinceStartup; } else if (Time.realtimeSinceStartup - _activeSince > (float)Plugin.ChuteStuckSeconds.Value) { _activeSince = -1f; if (++_restarts > 5) { Disable("restarted 5 times without success"); return; } _abort.Invoke(value, new object[1] { "NicheFixes: setup stuck, restarting" }); Plugin.Log.LogWarning((object)"Fuel chute setup was stuck; restarted it."); } } else { _activeSince = -1f; } } } }