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.2.0
MoonPhaseUtils.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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.Localization; 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("2.2.0.0")] [assembly: AssemblyInformationalVersion("2.2.0+2957a501d53235fe30f472c06fea032885a3927a")] [assembly: AssemblyProduct("MoonUtils")] [assembly: AssemblyTitle("MoonPhaseUtils")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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", "2.2.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 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); } public void SetupLabel() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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); screenImage.transform.SetParent(val.transform, false); screenImageTexture = screenImage.AddComponent<RawImage>(); ((Graphic)screenImageTexture).color = new Color(1f, 1f, 1f, 0f); 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; float num = 30f + y + 10f; screenImage.GetComponent<RectTransform>().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 = "2.2.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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Invalid comparison between Unknown and I4 //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: 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); TextMeshProUGUI saveFileHeader = __instance.saveFileHeader; LocalizedAsset localizedCorruptedHeader = __instance.localizedCorruptedHeader; ((TMP_Text)saveFileHeader).text = ((localizedCorruptedHeader != null) ? localizedCorruptedHeader.GetLocalizedString((Locale)null) : null) ?? "Corrupted Save File"; ((Graphic)__instance.saveFileHeader).color = new Color(1f, 0f, 0f); __instance.saveFileRenameButton.GetComponent<MenuButton>().ResizeToText(); ((TMP_Text)__instance.saveFileHeaderDate).text = ":("; TextMeshProUGUI saveFileInfoRow = __instance.saveFileInfoRow1; LocalizedAsset localizedCorruptedInfoRow = __instance.localizedCorruptedInfoRow1; ((TMP_Text)saveFileInfoRow).text = ((localizedCorruptedInfoRow != null) ? localizedCorruptedInfoRow.GetLocalizedString((Locale)null) : null) ?? "Sorry!"; ((TMP_Text)__instance.saveFileInfoRow2).text = ""; ((Component)__instance.saveFileInfoMoonRect).gameObject.SetActive(false); TextMeshProUGUI saveFileInfoRow2 = __instance.saveFileInfoRow3; LocalizedAsset localizedCorruptedInfoRow2 = __instance.localizedCorruptedInfoRow3; ((TMP_Text)saveFileInfoRow2).text = ((localizedCorruptedInfoRow2 != null) ? localizedCorruptedInfoRow2.GetLocalizedString((Locale)null) : null) ?? "Press \"Delete Save\" to delete \nentire saves folder."; 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); } GameObject val2 = (__instance.saveFileInfoLoadButton.activeSelf ? __instance.saveFileInfoLoadButton : (__instance.saveFileInfoRestoreButton.activeSelf ? __instance.saveFileInfoRestoreButton : null)); MenuSelectableElement val3 = (MenuSelectableElement)(Object.op_Implicit((Object)(object)val2) ? /*isinst with value type is only supported in some contexts*/: null); if (Object.op_Implicit((Object)(object)val3)) { if ((int)SemiFunc.InputMode() != 1) { object field = GetField("isKeyboardNavigating", MenuManager.instance, typeof(MenuManager)); if (!(field is bool) || !(bool)field) { goto IL_03cd; } } SetField("lastHoverMenuID", GetField("menuID", val3, typeof(MenuSelectableElement)), MenuManager.instance, typeof(MenuManager)); } goto IL_03cd; IL_03cd: object field2 = GetField("menuSelectableElement", __instance.saveFileRenameButton.GetComponent<MenuButton>(), typeof(MenuButton)); MenuSelectableElement val4 = (MenuSelectableElement)((field2 is MenuSelectableElement) ? field2 : null); if (Object.op_Implicit((Object)(object)val4)) { Navigation navigation = ((Selectable)val4).navigation; ((Navigation)(ref navigation)).selectOnDown = (Selectable)(object)val3; Navigation navigation2 = navigation; ((Selectable)val4).navigation = navigation2; } MenuElementSaveFile? obj = ((IEnumerable<MenuElementSaveFile>)(List<MenuElementSaveFile>)GetField("saveFiles", __instance)).FirstOrDefault((Func<MenuElementSaveFile, bool>)((MenuElementSaveFile s) => (string)GetField("saveFileName", s, typeof(MenuElementSaveFile)) == saveFolderName)); MenuSelectableElement val5 = ((obj != null) ? ((Component)obj).GetComponent<MenuSelectableElement>() : null); ExecuteMethod("SetRightNavigation", __instance, new object[3] { val4, val3, val5 }); if (StatsManager.instance.SaveFileGetRenamed(saveFolderName, text)) { ((TMP_Text)__instance.saveFileHeader).text = StatsManager.instance.SaveFileGetTeamName(saveFolderName, text); } else { TextMeshProUGUI saveFileHeader2 = __instance.saveFileHeader; LocalizedAsset localizedClickToRename = __instance.localizedClickToRename; ((TMP_Text)saveFileHeader2).text = ((localizedClickToRename != null) ? localizedClickToRename.GetLocalizedString((Locale)null) : null) ?? "(Click to Rename)"; } ((Graphic)__instance.saveFileHeader).color = new Color(1f, 0.54f, 0f); __instance.saveFileRenameButton.GetComponent<MenuButton>().ResizeToText(); ((TMP_Text)__instance.saveFileHeaderDate).text = StatsManager.instance.SaveFileGetDateAndTime(saveFolderName, text); ((TMP_Text)__instance.saveFileInfoRow1).text = "<sprite name=truck> <color=#" + ColorUtility.ToHtmlStringRGB(SemiFunc.ColorDifficultyGet(1f, 20f, (float)result + 1f)) + "><b>" + (result + 1) + "</b></color>"; TextMeshProUGUI saveFileInfoRow3 = __instance.saveFileInfoRow1; ((TMP_Text)saveFileInfoRow3).text = ((TMP_Text)saveFileInfoRow3).text + " "; float num = StatsManager.instance.SaveFileGetTimePlayed(saveFolderName, text); TextMeshProUGUI saveFileInfoRow4 = __instance.saveFileInfoRow1; ((TMP_Text)saveFileInfoRow4).text = ((TMP_Text)saveFileInfoRow4).text + "<sprite name=clock> " + SemiFunc.TimeToString(num, __instance.localizedDurationShort, true, new Color(0.1f, 0.4f, 0.8f), new Color(0.05f, 0.3f, 0.6f)); TextMeshProUGUI saveFileInfoRow5 = __instance.saveFileInfoRow1; ((TMP_Text)saveFileInfoRow5).text = ((TMP_Text)saveFileInfoRow5).text + " "; TextMeshProUGUI saveFileInfoRow6 = __instance.saveFileInfoRow1; ((TMP_Text)saveFileInfoRow6).text = ((TMP_Text)saveFileInfoRow6).text + "<sprite name=$$> <b>" + result2 + "</b><color=#" + __instance.hexColorDollarGreen + ">k</color>"; string text2 = SemiFunc.DollarGetString(result3); TextMeshProUGUI saveFileInfoRow7 = __instance.saveFileInfoRow2; string[] obj2 = new string[7] { "<color=#", __instance.hexColorDollarGreen, "><sprite name=$$$> ", null, null, null, null }; LocalizedAsset localizedTotalHaul = __instance.localizedTotalHaul; obj2[3] = ((localizedTotalHaul != null) ? localizedTotalHaul.GetLocalizedString((Locale)null) : null) ?? "Total Haul:"; obj2[4] = " $ <color=white><b>"; obj2[5] = text2; obj2[6] = "</b></color>k</color>"; ((TMP_Text)saveFileInfoRow7).text = string.Concat(obj2); 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, Type type = null) { if ((object)type == null) { type = typeof(MenuPageSaves); } FieldInfo fieldInfo = AccessTools.Field(type, fieldName); if (fieldInfo != null) { return fieldInfo.GetValue(instance); } if (instance != null) { return AccessTools.Property(type, fieldName)?.GetValue(instance); } return null; } 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 methodInfo.Invoke(instance, parameters); } return null; } private static void SetField(string fieldName, object value, object instance = null, Type type = null) { FieldInfo fieldInfo = AccessTools.Field(type ?? 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Invalid comparison between Unknown and I4 //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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 && !SemiFunc.IsLevelShop(RunManager.instance.levelCurrent) && (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)) { return; } int num = (int)fieldInfo.GetValue(RunManager.instance); if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.SetupLabel(); Plugin.Instance.SetupImage(); List<MoonAttribute> source = RunManager.instance.MoonGetAttributes(num); string text = string.Concat("<color=#", ColorUtility.ToHtmlStringRGB(Color.white), "><b>", RunManager.instance.MoonGetName(num).Trim(), "</b>\n" + string.Join("\n", source.Select((MoonAttribute a) => a.text)), "</color>"); bool flag2 = num != 0; ((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(flag2); Plugin.Instance.UpdateImagePosition(); Plugin.Instance.screenImageTexture.texture = RunManager.instance.MoonGetIcon(num); ((Graphic)Plugin.Instance.screenImageTexture).color = (flag2 ? new Color(1f, 1f, 1f, 1f) : new Color(1f, 1f, 1f, 0f)); 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 methodInfo.Invoke(instance, parameters); } return null; } 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); } } } }