Decompiled source of MoonGUIMod v1.0.3

MoonGUIMod.dll

Decompiled 4 minutes ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using DunGen;
using DunGen.Graph;
using HarmonyLib;
using LethalConfig;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.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 MoonGUIMod
{
	[BepInPlugin("custom.moonguimod", "MoonGUIMod", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<bool> ShowPopupTip;

		public static ConfigEntry<bool> ShowChatMessage;

		public static ConfigEntry<bool> ShowWatermark;

		public static ConfigEntry<string> WatermarkText;

		private GUIStyle watermarkStyle;

		private void Awake()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			ShowPopupTip = ((BaseUnityPlugin)this).Config.Bind<bool>("Notifications", "ShowPopupTip", true, "Show the orange HUD popup notification upon landing on a moon.");
			ShowChatMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("Notifications", "ShowChatMessage", true, "Send the moon info message to your local chat upon landing.");
			ShowWatermark = ((BaseUnityPlugin)this).Config.Bind<bool>("Watermark", "ShowWatermark", true, "Show a watermark on the screen.");
			WatermarkText = ((BaseUnityPlugin)this).Config.Bind<string>("Watermark", "WatermarkText", "MoonGUIMod v1.0.3", "Custom text for the on-screen watermark.");
			if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
			{
				SetupLethalConfig();
			}
			new Harmony("custom.moonguimod").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MoonGUIMod v1.0.3 loaded!");
		}

		private void OnGUI()
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (ShowWatermark != null && ShowWatermark.Value)
			{
				if (watermarkStyle == null)
				{
					watermarkStyle = new GUIStyle(GUI.skin.label)
					{
						fontSize = 15,
						fontStyle = (FontStyle)1,
						alignment = (TextAnchor)8
					};
					watermarkStyle.normal.textColor = new Color(0f, 1f, 0.45f, 0.55f);
				}
				Rect val = default(Rect);
				((Rect)(ref val))..ctor((float)(Screen.width - 320), (float)(Screen.height - 40), 300f, 25f);
				GUI.Label(val, WatermarkText.Value, watermarkStyle);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void SetupLethalConfig()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			using Stream stream = executingAssembly.GetManifestResourceStream("MoonGUIMod.icon.png");
			if (stream != null)
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				Texture2D val = new Texture2D(2, 2);
				if (ImageConversion.LoadImage(val, array))
				{
					Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
					LethalConfigManager.SetModIcon(modIcon);
				}
			}
			LethalConfigManager.SetModDescription("MoonGUIMod: Shows the interior type, scrap count, and total value in chat/HUD upon landing, plus an optional watermark.");
		}
	}
	[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
	public class LevelPatch
	{
		[HarmonyPostfix]
		public static void Postfix(RoundManager __instance)
		{
			RuntimeDungeon dungeonGenerator = __instance.dungeonGenerator;
			object obj;
			if (dungeonGenerator == null)
			{
				obj = null;
			}
			else
			{
				DungeonGenerator generator = dungeonGenerator.Generator;
				if (generator == null)
				{
					obj = null;
				}
				else
				{
					DungeonFlow dungeonFlow = generator.DungeonFlow;
					obj = ((dungeonFlow != null) ? ((Object)dungeonFlow).name : null);
				}
			}
			if (obj == null)
			{
				obj = "Unknown";
			}
			string text = (string)obj;
			text = text.Replace("Flow", "").Replace("Level1", "Factory").Replace("Level2", "Mansion")
				.Replace("Level3", "Mineshaft");
			List<GrabbableObject> list = (from item in Object.FindObjectsOfType<GrabbableObject>()
				where (Object)(object)item.itemProperties != (Object)null && item.itemProperties.isScrap && !item.isInShipRoom
				select item).ToList();
			int count = list.Count;
			int num = list.Sum((GrabbableObject item) => item.scrapValue);
			string text2 = $"{text} | {count} | {num}";
			if (Plugin.ShowPopupTip.Value)
			{
				HUDManager.Instance.DisplayTip("Moon Info", text2, false, false, "LC_Tip1");
			}
			if (Plugin.ShowChatMessage.Value)
			{
				string text3 = "<color=#00FF00>" + text2 + "</color>";
				typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(HUDManager.Instance, new object[2] { text3, "" });
			}
		}
	}
}

Release/MoonGUIMod.dll

Decompiled 4 minutes ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using DunGen;
using DunGen.Graph;
using HarmonyLib;
using LethalConfig;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.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 MoonGUIMod
{
	[BepInPlugin("custom.moonguimod", "MoonGUIMod", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<bool> ShowPopupTip;

		public static ConfigEntry<bool> ShowChatMessage;

		public static ConfigEntry<bool> ShowWatermark;

		public static ConfigEntry<string> WatermarkText;

		private GUIStyle watermarkStyle;

		private void Awake()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			ShowPopupTip = ((BaseUnityPlugin)this).Config.Bind<bool>("Notifications", "ShowPopupTip", true, "Show the orange HUD popup notification upon landing on a moon.");
			ShowChatMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("Notifications", "ShowChatMessage", true, "Send the moon info message to your local chat upon landing.");
			ShowWatermark = ((BaseUnityPlugin)this).Config.Bind<bool>("Watermark", "ShowWatermark", true, "Show a watermark on the screen.");
			WatermarkText = ((BaseUnityPlugin)this).Config.Bind<string>("Watermark", "WatermarkText", "MoonGUIMod v1.0.3", "Custom text for the on-screen watermark.");
			if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
			{
				SetupLethalConfig();
			}
			new Harmony("custom.moonguimod").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MoonGUIMod v1.0.3 loaded!");
		}

		private void OnGUI()
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (ShowWatermark != null && ShowWatermark.Value)
			{
				if (watermarkStyle == null)
				{
					watermarkStyle = new GUIStyle(GUI.skin.label)
					{
						fontSize = 15,
						fontStyle = (FontStyle)1,
						alignment = (TextAnchor)8
					};
					watermarkStyle.normal.textColor = new Color(0f, 1f, 0.45f, 0.55f);
				}
				Rect val = default(Rect);
				((Rect)(ref val))..ctor((float)(Screen.width - 320), (float)(Screen.height - 40), 300f, 25f);
				GUI.Label(val, WatermarkText.Value, watermarkStyle);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void SetupLethalConfig()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			using Stream stream = executingAssembly.GetManifestResourceStream("MoonGUIMod.icon.png");
			if (stream != null)
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				Texture2D val = new Texture2D(2, 2);
				if (ImageConversion.LoadImage(val, array))
				{
					Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
					LethalConfigManager.SetModIcon(modIcon);
				}
			}
			LethalConfigManager.SetModDescription("MoonGUIMod: Shows the interior type, scrap count, and total value in chat/HUD upon landing, plus an optional watermark.");
		}
	}
	[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
	public class LevelPatch
	{
		[HarmonyPostfix]
		public static void Postfix(RoundManager __instance)
		{
			RuntimeDungeon dungeonGenerator = __instance.dungeonGenerator;
			object obj;
			if (dungeonGenerator == null)
			{
				obj = null;
			}
			else
			{
				DungeonGenerator generator = dungeonGenerator.Generator;
				if (generator == null)
				{
					obj = null;
				}
				else
				{
					DungeonFlow dungeonFlow = generator.DungeonFlow;
					obj = ((dungeonFlow != null) ? ((Object)dungeonFlow).name : null);
				}
			}
			if (obj == null)
			{
				obj = "Unknown";
			}
			string text = (string)obj;
			text = text.Replace("Flow", "").Replace("Level1", "Factory").Replace("Level2", "Mansion")
				.Replace("Level3", "Mineshaft");
			List<GrabbableObject> list = (from item in Object.FindObjectsOfType<GrabbableObject>()
				where (Object)(object)item.itemProperties != (Object)null && item.itemProperties.isScrap && !item.isInShipRoom
				select item).ToList();
			int count = list.Count;
			int num = list.Sum((GrabbableObject item) => item.scrapValue);
			string text2 = $"{text} | {count} | {num}";
			if (Plugin.ShowPopupTip.Value)
			{
				HUDManager.Instance.DisplayTip("Moon Info", text2, false, false, "LC_Tip1");
			}
			if (Plugin.ShowChatMessage.Value)
			{
				string text3 = "<color=#00FF00>" + text2 + "</color>";
				typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(HUDManager.Instance, new object[2] { text3, "" });
			}
		}
	}
}