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 InsanityMeter v1.0.0
InsanityMeter.dll
Decompiled 2 years agousing System; 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 GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("InsanityMeter")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyCopyright("Copyright © 2023 MegaPiggy")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("InsanityMeter")] [assembly: AssemblyTitle("InsanityMeter")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace InsanityMeter { [BepInPlugin("MegaPiggy.InsanityMeter", "Insanity Meter", "1.0.0")] public class InsanityMeterMod : BaseUnityPlugin { [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void AwakePostfix(HUDManager __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004b: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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) //IL_00d8: 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_011d: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Component)__instance.HUDElements[2].canvasGroup).transform.parent; GameObject val = new GameObject("InsanityMeter", new Type[2] { typeof(Image), typeof(CanvasGroup) }); __instance.HUDElements = CollectionExtensions.AddToArray<HUDElement>(__instance.HUDElements, new HUDElement { canvasGroup = val.GetComponent<CanvasGroup>(), targetAlpha = 1f }); RectTransform component = val.GetComponent<RectTransform>(); component.pivot = Vector2.one * 0.5f; component.sizeDelta = new Vector2(150f, 20f); component.anchoredPosition3D = new Vector3(0f, 220f, -0.075f); Image component2 = val.GetComponent<Image>(); component2.sprite = CreateSpriteFromTexture(Texture2D.whiteTexture); ((Graphic)component2).color = Color.black; ((Component)component2).transform.SetParent(parent, false); GameObject val2 = new GameObject("InsanityBar", new Type[2] { typeof(Image), typeof(InsanityMeterUI) }); RectTransform component3 = val2.GetComponent<RectTransform>(); component3.pivot = Vector2.one * 0.5f; component3.sizeDelta = new Vector2(150f, 20f); Image component4 = val2.GetComponent<Image>(); component4.fillMethod = (FillMethod)0; component4.type = (Type)3; component4.sprite = CreateSpriteFromTexture(Texture2D.whiteTexture); ((Graphic)component4).color = Color32.op_Implicit(new Color32((byte)123, (byte)0, (byte)236, byte.MaxValue)); val2.transform.SetParent(((Component)component2).transform, false); } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerPatch { [HarmonyPatch("LateUpdate")] [HarmonyPostfix] public static void LateUpdatePostfix(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject) && __instance.isPlayerControlled && !__instance.isPlayerDead) { InsanityMeterUI.Instance.UpdatePercentage(__instance.GetInsanityPercentage()); } } } private const string modGUID = "MegaPiggy.InsanityMeter"; private const string modName = "Insanity Meter"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("MegaPiggy.InsanityMeter"); private static InsanityMeterMod Instance { get; set; } private static ManualLogSource LoggerInstance => ((BaseUnityPlugin)Instance).Logger; public static Sprite CreateSpriteFromTexture(Texture2D texture2D) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Sprite val = Sprite.Create(texture2D, new Rect(0f, 0f, (float)((Texture)texture2D).width, (float)((Texture)texture2D).height), new Vector2(0.5f, 0.5f)); ((Object)val).name = ((Object)texture2D).name; return val; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Insanity Meter is loaded with version 1.0.0!"); } } public class InsanityMeterUI : MonoBehaviour { private Image image; public static InsanityMeterUI Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } image = ((Component)this).GetComponent<Image>(); } public void UpdatePercentage(float insanityPercentage) { image.fillAmount = insanityPercentage; } } public static class PlayerExtensions { public static float GetInsanityPercentage(this PlayerControllerB player) { return player.insanityLevel / player.maxInsanityLevel; } } }