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 MoonPhaseUtils v2.0.0
MoonPhaseUtils.dll
Decompiled 6 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using MoonPhaseUtils.patches; using Photon.Pun; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MoonPhaseUtils")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+36882cbb7ac1db4c9b85442d846cffedc9c145af")] [assembly: AssemblyProduct("MoonUtils")] [assembly: AssemblyTitle("MoonPhaseUtils")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MoonPhaseUtils { [BepInPlugin("MoonPhaseUtils", "MoonUtils", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private static Harmony harmony; private static readonly object _updateLock = new object(); public GameObject? screenLabel; public GameObject? screenImage; public TextMeshProUGUI? screenLabelText; public RawImage? screenImageTexture; public static Plugin Instance { get; private set; } private void Awake() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Logger.LogInfo((object)"Plugin MoonPhaseUtils is loaded!"); harmony = new Harmony("MoonPhaseUtils"); MethodInfo methodInfo = AccessTools.Method(typeof(LevelGenerator), "GenerateDone", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(MoonPhaseClass), "GenerateDonePatched", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); PatchMoonUpdate(); } private void PatchMoonUpdate() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(RunManager), "CalculateMoonLevel", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(RunManagerPatchClass), "CalculateMoonLevelPatched", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo3 = AccessTools.Method(typeof(MenuPageSaves), "SaveFileSelected", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(MenuPageSavesPatchClass), "SaveFileSelectedPatched", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public void SetupLabel() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) lock (_updateLock) { if ((Object)(object)screenLabel == (Object)null) { Logger.LogInfo((object)"MoonPhaseUtils: Creating label..."); GameObject val = GameObject.Find("Game Hud"); GameObject val2 = GameObject.Find("Tax Haul"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Logger.LogInfo((object)"MoonPhaseUtils: Error getting HUD or Haul - not setting up label :("); return; } TMP_FontAsset font = val2.GetComponent<TMP_Text>().font; screenLabel = new GameObject(); screenLabel.SetActive(false); ((Object)screenLabel).name = "ListDeadPlayers"; screenLabel.AddComponent<TextMeshProUGUI>(); screenLabelText = screenLabel.GetComponent<TextMeshProUGUI>(); ((TMP_Text)screenLabelText).font = font; ((TMP_Text)screenLabelText).fontSize = 24f; ((TMP_Text)screenLabelText).enableWordWrapping = true; ((TMP_Text)screenLabelText).overflowMode = (TextOverflowModes)0; ((TMP_Text)screenLabelText).alignment = (TextAlignmentOptions)1028; ((TMP_Text)screenLabelText).horizontalAlignment = (HorizontalAlignmentOptions)4; ((TMP_Text)screenLabelText).verticalAlignment = (VerticalAlignmentOptions)1024; ((TMP_Text)screenLabelText).SetText("", true); screenLabel.transform.SetParent(val.transform, false); RectTransform component = screenLabel.GetComponent<RectTransform>(); component.anchorMax = new Vector2(1f, 0f); component.anchorMin = new Vector2(1f, 0f); component.pivot = new Vector2(1f, 0f); component.anchoredPosition = new Vector2(-30f, 30f); component.sizeDelta = new Vector2(300f, 400f); } } } public void SetupImage() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) lock (_updateLock) { if ((Object)(object)screenImage == (Object)null) { Logger.LogInfo((object)"MoonPhaseUtils: Creating image..."); GameObject val = GameObject.Find("Game Hud"); GameObject val2 = GameObject.Find("Tax Haul"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Logger.LogInfo((object)"MoonPhaseUtils: Error getting HUD or Haul - not setting up image :("); return; } screenImage = new GameObject("MoonImage"); screenImage.SetActive(false); screenImageTexture = screenImage.AddComponent<RawImage>(); ((Graphic)screenImageTexture).color = Color.white; screenImage.transform.SetParent(val.transform, false); RectTransform component = screenImage.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 0f); component.pivot = new Vector2(1f, 0f); component.anchoredPosition = new Vector2(-30f, 60f); component.sizeDelta = new Vector2(30f, 30f); } } } public void UpdateImagePosition() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)screenLabel == (Object)null) && !((Object)(object)screenImage == (Object)null) && !((Object)(object)screenLabelText == (Object)null)) { ((TMP_Text)screenLabelText).ForceMeshUpdate(false, false); float y = ((TMP_Text)screenLabelText).GetRenderedValues(false).y; RectTransform component = screenImage.GetComponent<RectTransform>(); float num = 30f + y + 10f; component.anchoredPosition = new Vector2(-30f, num); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "MoonPhaseUtils"; public const string PLUGIN_NAME = "MoonUtils"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace MoonPhaseUtils.UI { public class TopUIBanner : MonoBehaviour { public static void Show(string moonName, Texture moonIcon) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ModUIBanner"); Canvas val2 = val.AddComponent<Canvas>(); val2.renderMode = (RenderMode)0; val.AddComponent<CanvasScaler>(); val.AddComponent<GraphicRaycaster>(); GameObject val3 = new GameObject("TopPanel"); val3.transform.SetParent(((Component)val2).transform); RectTransform obj = val3.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0f, 1f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(0.5f, 1f); obj.anchoredPosition = new Vector2(0f, 0f); obj.sizeDelta = new Vector2(0f, 100f); ((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.6f); GameObject val4 = new GameObject("TopText"); val4.transform.SetParent(val3.transform); Text obj2 = val4.AddComponent<Text>(); obj2.text = "Current moon: " + moonName; obj2.alignment = (TextAnchor)3; obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); ((Graphic)obj2).color = Color.white; RectTransform component = ((Component)obj2).GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(0.7f, 1f); component.offsetMin = new Vector2(10f, 0f); component.offsetMax = new Vector2(0f, 0f); GameObject val5 = new GameObject("TopImage"); val5.transform.SetParent(val3.transform); Image obj3 = val5.AddComponent<Image>(); Texture2D val6 = (Texture2D)(object)((moonIcon is Texture2D) ? moonIcon : null); obj3.sprite = Sprite.Create(val6, new Rect(0f, 0f, (float)((Texture)val6).width, (float)((Texture)val6).height), new Vector2(0.5f, 0.5f)); RectTransform component2 = ((Component)obj3).GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.7f, 0f); component2.anchorMax = new Vector2(1f, 1f); component2.offsetMin = new Vector2(0f, 10f); component2.offsetMax = new Vector2(-10f, -10f); } } } namespace MoonPhaseUtils.patches { public class MenuPageSavesPatchClass { internal static ManualLogSource Logger = Plugin.Logger; [HarmonyPrefix] private static bool SaveFileSelectedPatched(MenuPageSaves __instance, string saveFolderName, List<string> saveFileBackups) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) MenuElementAnimations component = ((Component)__instance.saveFileInfo).GetComponent<MenuElementAnimations>(); component.UIAniNudgeX(10f, 0.2f, 1f); component.UIAniRotate(2f, 0.2f, 1f); __instance.saveInfoDefault.SetActive(false); __instance.saveInfoSelected.SetActive(true); Image val = (Image)GetField("saveFileInfoPanel", __instance); ((Graphic)val).color = new Color(0f, 0.1f, 0.25f, 1f); SetField("saveFileInfoPanel", val, __instance); SetField("currentSaveFileName", saveFolderName, __instance); SetField("currentSaveFileBackups", saveFileBackups, __instance); string text = saveFolderName; if (!int.TryParse(StatsManager.instance.SaveFileGetRunLevel(saveFolderName, (string)null), out var result) || !int.TryParse(StatsManager.instance.SaveFileGetRunCurrency(saveFolderName, (string)null), out var result2) || !int.TryParse(StatsManager.instance.SaveFileGetTotalHaul(saveFolderName, (string)null), out var result3)) { SetField("currentSaveFileValid", false, __instance); if (saveFileBackups.Count > 0) { text = saveFileBackups[0]; } if (saveFolderName == text || !int.TryParse(StatsManager.instance.SaveFileGetRunLevel(saveFolderName, text), out result) || !int.TryParse(StatsManager.instance.SaveFileGetRunCurrency(saveFolderName, text), out result2) || !int.TryParse(StatsManager.instance.SaveFileGetTotalHaul(saveFolderName, text), out result3)) { ((GameObject)GetField("saveFileInfoLoadButton", __instance)).SetActive(false); ((GameObject)GetField("saveFileInfoRestoreButton", __instance)).SetActive(false); ((TMP_Text)__instance.saveFileHeader).text = "CORRUPTED SAVE FILE"; ((Graphic)__instance.saveFileHeader).color = new Color(1f, 0f, 0f); ((TMP_Text)__instance.saveFileHeaderDate).text = ":("; ((TMP_Text)__instance.saveFileInfoRow1).text = "Sorry!"; ((TMP_Text)__instance.saveFileInfoRow2).text = ""; ((Component)__instance.saveFileInfoMoonRect).gameObject.SetActive(false); ((TMP_Text)__instance.saveFileInfoRow3).text = "Press \"Delete Save\" to delete \nthis save file."; return false; } ((GameObject)GetField("saveFileInfoLoadButton", __instance)).SetActive(false); ((GameObject)GetField("saveFileInfoRestoreButton", __instance)).SetActive(true); } else { SetField("currentSaveFileValid", true, __instance); ((GameObject)GetField("saveFileInfoLoadButton", __instance)).SetActive(true); ((GameObject)GetField("saveFileInfoRestoreButton", __instance)).SetActive(false); } ((TMP_Text)__instance.saveFileHeader).text = StatsManager.instance.SaveFileGetTeamName(saveFolderName, text); ((Graphic)__instance.saveFileHeader).color = new Color(1f, 0.54f, 0f); ((TMP_Text)__instance.saveFileHeaderDate).text = StatsManager.instance.SaveFileGetDateAndTime(saveFolderName, (string)null); string text2 = " "; ((TMP_Text)__instance.saveFileInfoRow1).text = "<sprite name=truck> <color=#" + ColorUtility.ToHtmlStringRGB(SemiFunc.ColorDifficultyGet(1f, 10f, (float)result + 1f)) + "><b>" + (result + 1) + "</b></color>"; TextMeshProUGUI saveFileInfoRow = __instance.saveFileInfoRow1; ((TMP_Text)saveFileInfoRow).text = ((TMP_Text)saveFileInfoRow).text + text2; float num = StatsManager.instance.SaveFileGetTimePlayed(saveFolderName, text); TextMeshProUGUI saveFileInfoRow2 = __instance.saveFileInfoRow1; ((TMP_Text)saveFileInfoRow2).text = ((TMP_Text)saveFileInfoRow2).text + ((TMP_Text)saveFileInfoRow2).text + "<sprite name=clock> " + SemiFunc.TimeToString(num, true, new Color(0.1f, 0.4f, 0.8f), new Color(0.05f, 0.3f, 0.6f)); TextMeshProUGUI saveFileInfoRow3 = __instance.saveFileInfoRow1; ((TMP_Text)saveFileInfoRow3).text = ((TMP_Text)saveFileInfoRow3).text + text2; string text3 = ColorUtility.ToHtmlStringRGB(new Color(0.2f, 0.5f, 0.3f)); TextMeshProUGUI saveFileInfoRow4 = __instance.saveFileInfoRow1; ((TMP_Text)saveFileInfoRow4).text = ((TMP_Text)saveFileInfoRow4).text + "<sprite name=$$> <b>" + result2 + "</b><color=#" + text3 + ">k</color>"; string text4 = SemiFunc.DollarGetString(result3); ((TMP_Text)__instance.saveFileInfoRow2).text = "<color=#" + text3 + "><sprite name=$$$> TOTAL HAUL: <b></b>$ </color><b>" + text4 + "</b><color=#" + text3 + ">k</color>"; int num2 = Mathf.Clamp(RunManager.instance.CalculateMoonLevel(result), 0, RunManager.instance.moons.Count); if (num2 > 0) { ((Component)__instance.saveFileInfoMoonRect).gameObject.SetActive(true); __instance.saveFileInfoMoonImage.texture = RunManager.instance.MoonGetIcon(num2); } else { ((Component)__instance.saveFileInfoMoonRect).gameObject.SetActive(false); } ExecuteMethod("InfoPlayerNames", __instance, new object[3] { __instance.saveFileInfoRow3, saveFolderName, text }); return false; } private static object GetField(string fieldName, object instance = null) { FieldInfo fieldInfo = AccessTools.Field(typeof(MenuPageSaves), fieldName); if (!(fieldInfo != null)) { return null; } return fieldInfo.GetValue(instance); } private static object ExecuteMethod(string methodName, object instance = null, object[] parameters = null) { MethodInfo methodInfo = AccessTools.Method(typeof(MenuPageSaves), methodName, (Type[])null, (Type[])null); if (methodInfo == null) { return null; } return methodInfo.Invoke(instance, parameters); } private static void SetField(string fieldName, object value, object instance = null) { FieldInfo fieldInfo = AccessTools.Field(typeof(MenuPageSaves), fieldName); if (fieldInfo != null) { fieldInfo.SetValue(instance, value); } } } [HarmonyPatch(typeof(GameManager), "SetGameMode")] public class MoonPhaseClass { internal static ManualLogSource Logger = Plugin.Logger; [HarmonyPostfix] public static void GenerateDonePatched(LevelGenerator __instance, PhotonMessageInfo _info) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_012e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RunManager.instance != (Object)null) { bool flag = (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelLobby && (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelMainMenu && (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelLobbyMenu && (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelRecording && (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelShop && (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelTutorial; if (!((int)__instance.State == 15 && flag)) { return; } FieldInfo fieldInfo = AccessTools.Field(typeof(RunManager), "moonLevel"); if (fieldInfo != null) { int num = (int)fieldInfo.GetValue(RunManager.instance); if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.SetupLabel(); Plugin.Instance.SetupImage(); string text = string.Concat("<color=#", ColorUtility.ToHtmlStringRGB(Color.white), "><b>", RunManager.instance.MoonGetName(num).Trim(), "</b>\n" + string.Join("\n", RunManager.instance.MoonGetAttributes(num)), "</color>"); ((TMP_Text)Plugin.Instance.screenLabelText).SetText(text, true); ((TMP_Text)Plugin.Instance.screenLabelText).fontSizeMax = 10f; ((TMP_Text)Plugin.Instance.screenLabelText).fontSize = 12f; Plugin.Instance.screenLabel.SetActive(num != 0); Plugin.Instance.UpdateImagePosition(); Plugin.Instance.screenImageTexture.texture = RunManager.instance.MoonGetIcon(num); Plugin.Instance.screenImage.SetActive(true); } } } else { Logger.LogWarning((object)"RunManager.instance is null."); } } } public class RunManagerPatchClass { internal static ManualLogSource Logger = Plugin.Logger; [HarmonyPrefix] private static bool CalculateMoonLevelPatched(RunManager __instance, int _levelsCompleted, ref int __result) { __result = (_levelsCompleted - 1) % 4 + 1; return false; } [HarmonyPrefix] private static bool UpdateMoonLevelPatched(RunManager __instance) { int num = (int)GetField("moonLevel", __instance); int num2 = __instance.CalculateMoonLevel((int)GetField("levelsCompleted", __instance)); SetField("moonLevelPrev", num, __instance); SetField("moonLevel", num2, __instance); if (num == num2) { return false; } SetField("moonLevelChanged", true, __instance); return false; } private static object GetField(string fieldName, object instance = null) { FieldInfo fieldInfo = AccessTools.Field(typeof(RunManager), fieldName); if (!(fieldInfo != null)) { return null; } return fieldInfo.GetValue(instance); } private static object ExecuteMethod(string methodName, object instance = null, object[] parameters = null) { MethodInfo methodInfo = AccessTools.Method(typeof(RunManager), methodName, (Type[])null, (Type[])null); if (methodInfo == null) { return null; } return methodInfo.Invoke(instance, parameters); } private static void SetField(string fieldName, object value, object instance = null) { FieldInfo fieldInfo = AccessTools.Field(typeof(RunManager), fieldName); if (fieldInfo != null) { fieldInfo.SetValue(instance, value); } } } }