Decompiled source of InGame Achievements and Unlocks v0.0.3

InGameAchievements.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Assets.Scripts.Saves___Serialization.Progression.Achievements;
using Assets.Scripts.Utility;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("InGameAchievements")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InGameAchievements")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a052f8b9-b678-40b0-a576-d1c5418579fb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SaveLoadWeapons
{
	[BepInPlugin("mike9k1.megabonk.ingameachievements", "In-Game Achievements and Unlocks", "0.0.3")]
	public class InGameAchievements : MelonMod
	{
		public new const string PLUGIN_GUID = "mike9k1.megabonk.ingameachievements";

		public new const string PLUGIN_NAME = "In-Game Achievements and Unlocks";

		public new const string PLUGIN_VERSION = "0.0.3";

		public static string savesDirectory = "BepInEx\\plugins\\InGameAchievements\\";

		private string PauseTypeName = "PauseUi";

		private string PauseMethodName = "Pause";

		private string PauseStartMethodName = "IsPaused";

		private string MainMenuTypeName = "QuickQuestsWindow";

		private string MainMenuMethodName = "Start";

		private string QuestsTypeName = "QuestsWindowNew";

		private string QuestsMethodName = "Awake";

		private string QuestsStartMethodName = "Start";

		private string UnlocksTypeName = "UnlocksUi";

		private string UnlocksMethodName = "Awake";

		private string UnlocksStartMethodName = "OnTabSelected";

		private static MainMenu mmenu;

		private static PauseUi pauseMenu;

		private static QuickQuestsWindow achievementsProgressWindow;

		private static QuickQuestsWindow newAchievementsWindow;

		private static UnlocksUi unlocksWindow;

		private static UnlocksUi newUnlocksWindow;

		private static QuestsWindowNew questsWindow;

		private static QuestsWindowNew newQuestsWindow;

		private static MyButtonNormal questsButton;

		private static MyButtonNormal newQuestsButton;

		private static MyButtonNormal unlocksButton;

		private static MyButtonNormal newUnlocksButton;

		private static RectTransform buttonsListTransform;

		private static bool unlocksBackEvtListenerSet = false;

		private static Type FindType(string fullName)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					Type type = assembly.GetType(fullName, throwOnError: false);
					if (type != null)
					{
						return type;
					}
				}
				catch
				{
				}
			}
			return null;
		}

		private static void PausePostfix(PauseUi __instance)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			Window component = __instance.main.GetComponent<Window>();
			pauseMenu = __instance;
			if ((Object)(object)newAchievementsWindow == (Object)null)
			{
				MelonLogger.Msg("Achievements Window is null. Cannot add to pause screen.");
			}
			else if ((Object)(object)((Component)newAchievementsWindow).transform == (Object)null)
			{
				MelonLogger.Msg("Achievements Window transform property is null.");
			}
			if ((Object)(object)component == (Object)null)
			{
				MelonLogger.Msg("Main Pause Window is null.");
			}
			else if ((Object)(object)((Component)component).transform == (Object)null)
			{
				MelonLogger.Msg("Main Pause Window transform property is null.");
			}
			if (!((Object)(object)newAchievementsWindow == (Object)null))
			{
				((Component)newAchievementsWindow).transform.SetParent(((Component)component).transform);
				RectTransform component2 = ((Component)newAchievementsWindow).GetComponent<RectTransform>();
				Vector2 anchorMax = component2.anchorMax;
				anchorMax.y = 0.21f;
				component2.anchorMax = anchorMax;
				((Component)newQuestsWindow).transform.SetParent(((Component)pauseMenu).transform, false);
				((Component)newUnlocksWindow).transform.SetParent(((Component)pauseMenu).transform, false);
			}
		}

		private static void PauseStartPostfix(PauseUi __instance)
		{
			if ((Object)(object)newUnlocksButton == (Object)null || (Object)(object)newQuestsButton == (Object)null || (Object)(object)pauseMenu == (Object)null || (Object)(object)((Component)newUnlocksButton).transform == (Object)null || (Object)(object)((Component)newQuestsButton).transform == (Object)null)
			{
				return;
			}
			if ((Object)(object)((Component)newUnlocksButton).transform.parent != (Object)null || (Object)(object)((Component)newQuestsButton).transform.parent != (Object)null)
			{
				UnlocksStartPostfix(newUnlocksWindow);
				return;
			}
			GameObject val = GameObject.Find("Pause and Buttons");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			VerticalLayoutGroup component = val.GetComponent<VerticalLayoutGroup>();
			VerticalLayoutGroup val2 = null;
			if ((Object)(object)component == (Object)null)
			{
				MelonLogger.Msg("Buttons list is not set. Returning");
				return;
			}
			Enumerator<RectTransform> enumerator = ((LayoutGroup)component).m_RectChildren.GetEnumerator();
			while (enumerator.MoveNext())
			{
				RectTransform current = enumerator.Current;
				if (((Object)current).name == "Buttons")
				{
					val2 = ((Component)current).GetComponent<VerticalLayoutGroup>();
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				MelonLogger.Msg("Buttons list is not set. Returning");
				return;
			}
			((HorizontalOrVerticalLayoutGroup)component).spacing = -20f;
			((Component)newUnlocksButton).transform.SetParent(((Component)val2).transform, false);
			((MyButton)newUnlocksButton).SetInteractable(true);
			((Component)newQuestsButton).transform.SetParent(((Component)val2).transform, false);
			((MyButton)newQuestsButton).SetInteractable(true);
			((UnityEvent)((Component)newUnlocksButton).GetComponent<Button>().onClick).AddListener(UnityAction.op_Implicit((Action)OnUnlocksClick));
			((UnityEvent)((Component)newQuestsButton).GetComponent<Button>().onClick).AddListener(UnityAction.op_Implicit((Action)OnQuestsClick));
		}

		private static void OnUnlocksClick()
		{
			if ((Object)(object)newUnlocksWindow == (Object)null)
			{
				MelonLogger.Msg("Unlocks window is null. Returning.");
			}
			else
			{
				pauseMenu.GoToWindow(((Component)newUnlocksWindow).gameObject);
			}
		}

		private static void OnUnlocksExit()
		{
			pauseMenu.GoToMain();
		}

		private static void OnQuestsClick()
		{
			if ((Object)(object)newQuestsWindow == (Object)null)
			{
				MelonLogger.Msg("Quests window is null. Returning.");
			}
			else
			{
				pauseMenu.GoToWindow(((Component)newQuestsWindow).gameObject);
			}
		}

		private static string ToSafeString(object obj)
		{
			if (obj != null)
			{
				return obj.ToString();
			}
			return "null";
		}

		private static void MainMenuPostfix(QuickQuestsWindow __instance)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)achievementsProgressWindow != (Object)null)
			{
				return;
			}
			achievementsProgressWindow = __instance;
			Transform parent = ((Component)achievementsProgressWindow).transform.parent;
			((Component)achievementsProgressWindow).transform.parent = null;
			((Component)achievementsProgressWindow).transform.parentInternal = null;
			Object.DontDestroyOnLoad((Object)(object)achievementsProgressWindow);
			newAchievementsWindow = Object.Instantiate<GameObject>(((Component)achievementsProgressWindow).gameObject, parent).GetComponent<QuickQuestsWindow>();
			((Component)newAchievementsWindow).transform.SetParent(parent);
			RectTransform component = ((Component)newAchievementsWindow).GetComponent<RectTransform>();
			Vector2 anchorMax = component.anchorMax;
			anchorMax.y = 0f;
			anchorMax.x = 0f;
			component.anchorMax = anchorMax;
			anchorMax = component.anchorMin;
			anchorMax.x = 0f;
			anchorMax.y = 0.15f;
			component.anchorMin = anchorMax;
			float num = 0f;
			List<MyAchievement> list = new List<MyAchievement>();
			for (int i = 0; i < 21; i++)
			{
				num = -0.1f;
				MyAchievement item = null;
				MyAchievement val = null;
				Enumerator<string, MyAchievement> enumerator = DataManager.Instance.achievementsData.GetEnumerator();
				while (enumerator.MoveNext())
				{
					KeyValuePair<string, MyAchievement> current = enumerator.Current;
					if (current.Value.GetProgress() > num && !current.Value.IsCompleted() && !list.Contains(current.Value))
					{
						num = current.Value.GetProgress();
						val = current.Value;
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					list.Add(val);
					item = val;
				}
				else
				{
					list.Add(item);
				}
			}
			Random random = new Random();
			List<int> list2 = new List<int>();
			for (int j = 4; j < 7; j++)
			{
				int num2 = random.Next(j, 20);
				while (list2.Contains(num2))
				{
					num2 = random.Next(j, 20);
				}
				list2.Add(num2);
				MyAchievement val2 = list[num2];
				QuickQuestContainer component2 = GameObject.Find("QuestEntry(Clone)").GetComponent<QuickQuestContainer>();
				if ((Object)(object)component2.currentAchievement != (Object)null)
				{
					((Object)component2).name = "QuestEntry(New)";
					j--;
					continue;
				}
				if ((Object)(object)val2 != (Object)null)
				{
					component2.SetQuest(val2);
				}
				((Object)component2).name = "QuestEntry(New)";
			}
			newAchievementsWindow = achievementsProgressWindow;
			mmenu = Object.FindObjectOfType<MainMenu>();
			mmenu.tabUnlocks.GetComponent<UnlocksUi>().Awake();
			mmenu.quests.GetComponent<QuestsWindowNew>().Awake();
			questsButton = GameObject.Find("B_Quests").GetComponent<MyButtonNormal>();
			unlocksButton = GameObject.Find("B_Unlocks").GetComponent<MyButtonNormal>();
			if ((Object)(object)questsButton == (Object)null)
			{
				MelonLogger.Msg("Quests button is not yet instantiated. Returning.");
				return;
			}
			if ((Object)(object)unlocksButton == (Object)null)
			{
				MelonLogger.Msg("Unlocks button is not yet instantiated. Returning.");
				return;
			}
			parent = ((Component)questsButton).transform.parent;
			((Component)questsButton).transform.SetParent((Transform)null, false);
			Object.DontDestroyOnLoad((Object)(object)questsButton);
			newQuestsButton = Object.Instantiate<GameObject>(((Component)questsButton).gameObject, parent).GetComponent<MyButtonNormal>();
			parent = ((Component)unlocksButton).transform.parent;
			((Component)unlocksButton).transform.SetParent((Transform)null, false);
			Object.DontDestroyOnLoad((Object)(object)unlocksButton);
			newUnlocksButton = Object.Instantiate<GameObject>(((Component)unlocksButton).gameObject, parent).GetComponent<MyButtonNormal>();
			MyButtonNormal component3 = GameObject.Find("B_Shop").GetComponent<MyButtonNormal>();
			((Component)component3).transform.SetParent((Transform)null, false);
			((Component)newUnlocksButton).transform.SetParent(parent);
			newUnlocksButton = unlocksButton;
			((Component)newQuestsButton).transform.SetParent(parent);
			newQuestsButton = questsButton;
			((Component)component3).transform.SetParent(parent, false);
		}

		private static void QuestsPostfix(QuestsWindowNew __instance)
		{
			if (!(((Object)__instance).name != "W_Quests2NEW") && !((Object)(object)questsWindow != (Object)null))
			{
				questsWindow = __instance;
				Transform parent = ((Component)questsWindow).transform.parent;
				((Component)questsWindow).transform.SetParent((Transform)null, false);
				Object.DontDestroyOnLoad((Object)(object)questsWindow);
				GameObject val = Object.Instantiate<GameObject>(((Component)questsWindow).gameObject, parent);
				newQuestsWindow = val.GetComponent<QuestsWindowNew>();
				((Component)newQuestsWindow).transform.SetParent(parent);
				mmenu.quests = val;
				newQuestsWindow = questsWindow;
			}
		}

		private static void UnlocksPostfix(UnlocksUi __instance)
		{
			if (!((Object)(object)unlocksWindow != (Object)null))
			{
				unlocksBackEvtListenerSet = false;
				unlocksWindow = __instance;
				Transform parent = ((Component)unlocksWindow).transform.parent;
				((Component)unlocksWindow).transform.SetParent((Transform)null, false);
				Object.DontDestroyOnLoad((Object)(object)unlocksWindow);
				GameObject val = Object.Instantiate<GameObject>(((Component)unlocksWindow).gameObject, parent);
				newUnlocksWindow = val.GetComponent<UnlocksUi>();
				((Component)newUnlocksWindow).transform.SetParent(parent);
				mmenu.tabUnlocks = val;
				newUnlocksWindow = unlocksWindow;
			}
		}

		private static void UnlocksStartPostfix(UnlocksUi __instance)
		{
			if (unlocksBackEvtListenerSet || !((Object)(object)newUnlocksWindow != (Object)null) || !((Object)(object)pauseMenu != (Object)null) || !((Object)(object)((Component)__instance).transform.parent == (Object)(object)((Component)pauseMenu).transform))
			{
				return;
			}
			MyButton val = null;
			Enumerator<MyButton> enumerator = ((Component)newUnlocksWindow).GetComponent<Window>().allButtons.GetEnumerator();
			while (enumerator.MoveNext())
			{
				MyButton current = enumerator.Current;
				if (((Object)current).name == "B_Back")
				{
					val = current;
					break;
				}
			}
			if (!((Object)(object)val == (Object)null))
			{
				((UnityEvent)((Component)val).GetComponent<Button>().onClick).AddListener(UnityAction.op_Implicit((Action)OnUnlocksExit));
				unlocksBackEvtListenerSet = true;
			}
		}

		private static void QuestsStartPostfix(QuestsWindowNew __instance)
		{
			if ((Object)(object)newQuestsWindow != (Object)null && (Object)(object)pauseMenu != (Object)null && (Object)(object)((Component)__instance).transform.parent == (Object)(object)((Component)pauseMenu).transform)
			{
				MyButton val = null;
				Enumerator<MyButton> enumerator = ((Component)newQuestsWindow).GetComponent<Window>().allButtons.GetEnumerator();
				while (enumerator.MoveNext())
				{
					MyButton current = enumerator.Current;
					if (((Object)current).name == "B_Back")
					{
						val = current;
						break;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					MelonLogger.Msg("Back button is null. Returning.");
					return;
				}
				((UnityEvent)((Component)val).GetComponent<Button>().onClick).AddListener(UnityAction.op_Implicit((Action)OnUnlocksExit));
			}
			int num = 0;
			foreach (MyButtonTabs item in (Il2CppArrayBase<MyButtonTabs>)(object)__instance.tabNavigation.buttons)
			{
				if (num > 6)
				{
					((Component)item).transform.SetParent((Transform)null, false);
				}
				num++;
			}
		}

		private void TryPatch()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Expected O, but got Unknown
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Expected O, but got Unknown
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Expected O, but got Unknown
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Expected O, but got Unknown
			Type type = FindType(PauseTypeName);
			if (type == null)
			{
				MelonLogger.Error("Type not found: " + PauseTypeName);
				return;
			}
			MethodInfo method = type.GetMethod(PauseMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method == null)
			{
				MelonLogger.Error("Method not found: " + type.FullName + "." + PauseMethodName + "()");
				return;
			}
			HarmonyMethod val = new HarmonyMethod(typeof(InGameAchievements).GetMethod("PausePostfix", BindingFlags.Static | BindingFlags.NonPublic));
			HarmonyInstance.Patch((MethodBase)method, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo method2 = type.GetMethod(PauseStartMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method2 == null)
			{
				MelonLogger.Error("Method not found: " + type.FullName + "." + PauseStartMethodName + "()");
				return;
			}
			HarmonyMethod val2 = new HarmonyMethod(typeof(InGameAchievements).GetMethod("PauseStartPostfix", BindingFlags.Static | BindingFlags.NonPublic));
			HarmonyInstance.Patch((MethodBase)method2, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Type type2 = FindType(MainMenuTypeName);
			if (type2 == null)
			{
				MelonLogger.Error("Type not found: " + MainMenuTypeName);
				return;
			}
			MethodInfo method3 = type2.GetMethod(MainMenuMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method3 == null)
			{
				MelonLogger.Error("Method not found: " + type2.FullName + "." + MainMenuMethodName + "()");
				return;
			}
			HarmonyMethod val3 = new HarmonyMethod(typeof(InGameAchievements).GetMethod("MainMenuPostfix", BindingFlags.Static | BindingFlags.NonPublic));
			HarmonyInstance.Patch((MethodBase)method3, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Type type3 = FindType(QuestsTypeName);
			if (type3 == null)
			{
				MelonLogger.Error("Type not found: " + QuestsTypeName);
				return;
			}
			MethodInfo method4 = type3.GetMethod(QuestsMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method4 == null)
			{
				MelonLogger.Error("Method not found: " + type3.FullName + "." + QuestsMethodName + "()");
				return;
			}
			HarmonyMethod val4 = new HarmonyMethod(typeof(InGameAchievements).GetMethod("QuestsPostfix", BindingFlags.Static | BindingFlags.NonPublic));
			HarmonyInstance.Patch((MethodBase)method4, (HarmonyMethod)null, val4, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo method5 = type3.GetMethod(QuestsStartMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method5 == null)
			{
				MelonLogger.Error("Method not found: " + type3.FullName + "." + QuestsStartMethodName + "()");
				return;
			}
			HarmonyMethod val5 = new HarmonyMethod(typeof(InGameAchievements).GetMethod("QuestsStartPostfix", BindingFlags.Static | BindingFlags.NonPublic));
			HarmonyInstance.Patch((MethodBase)method5, (HarmonyMethod)null, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Type type4 = FindType(UnlocksTypeName);
			if (type4 == null)
			{
				MelonLogger.Error("Type not found: " + UnlocksTypeName);
				return;
			}
			MethodInfo method6 = type4.GetMethod(UnlocksMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method6 == null)
			{
				MelonLogger.Error("Method not found: " + type4.FullName + "." + UnlocksMethodName + "()");
				return;
			}
			HarmonyMethod val6 = new HarmonyMethod(typeof(InGameAchievements).GetMethod("UnlocksPostfix", BindingFlags.Static | BindingFlags.NonPublic));
			HarmonyInstance.Patch((MethodBase)method6, (HarmonyMethod)null, val6, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo method7 = type4.GetMethod(UnlocksStartMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method7 == null)
			{
				MelonLogger.Error("Method not found: " + type4.FullName + "." + UnlocksStartMethodName + "()");
			}
			else
			{
				HarmonyMethod val7 = new HarmonyMethod(typeof(InGameAchievements).GetMethod("UnlocksStartPostfix", BindingFlags.Static | BindingFlags.NonPublic));
				HarmonyInstance.Patch((MethodBase)method7, (HarmonyMethod)null, val7, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		public override void OnInitializeMelon()
		{
			TryPatch();
		}
	}
}
namespace MelonLoader
{
	public class MelonMod : BasePlugin
	{
		public Harmony HarmonyInstance;

		public static MelonMod melonModRef;

		public virtual string PLUGIN_GUID => "author.game.modname";

		public virtual string PLUGIN_NAME => "Mod Name Here";

		public virtual string PLUGIN_VERSION => "0.0.1";

		public MelonMod()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			HarmonyInstance = new Harmony(PLUGIN_GUID);
			melonModRef = this;
		}

		public virtual void OnInitializeMelon()
		{
		}

		public virtual void OnLateInitializeMelon()
		{
		}

		public virtual void OnFixedUpdate()
		{
		}

		public virtual void OnUpdate()
		{
		}

		public override void Load()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			OnInitializeMelon();
			HarmonyMethod val = new HarmonyMethod(typeof(MelonMod).GetMethod("FixedUpdate"));
			HarmonyInstance.Patch((MethodBase)typeof(MyTime).GetMethod("FixedUpdate"), (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			HarmonyMethod val2 = new HarmonyMethod(typeof(MelonMod).GetMethod("Update"));
			HarmonyInstance.Patch((MethodBase)typeof(MyTime).GetMethod("Update"), (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public void Awake()
		{
			OnLateInitializeMelon();
		}

		public static void FixedUpdate()
		{
			melonModRef.OnFixedUpdate();
		}

		public static void Update()
		{
			melonModRef.OnUpdate();
		}
	}
	public class MelonLogger
	{
		private static ManualLogSource log;

		private static bool logAdded;

		public static void Msg(string message)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			if (!logAdded)
			{
				log = new ManualLogSource(((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), inherit: false)[0]).Title);
				Logger.Sources.Add((ILogSource)(object)log);
				logAdded = true;
			}
			log.LogInfo((object)message);
		}

		public static void Error(string message)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			if (!logAdded)
			{
				log = new ManualLogSource(((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), inherit: false)[0]).Title);
				Logger.Sources.Add((ILogSource)(object)log);
				logAdded = true;
			}
			log.LogError((object)message);
		}
	}
}