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 GodMode v2.1.0
BepInEx\plugins\DaanDeReus-GodMode\GodMode.dll
Decompiled 2 weeks 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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("DaanDeReus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.1.0.0")] [assembly: AssemblyInformationalVersion("2.1.0+6bf84a1a4f6489241cc9ff2362b22234f1aa16ae")] [assembly: AssemblyProduct("GodMode")] [assembly: AssemblyTitle("GodMode")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.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.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = 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 GodMode { [BepInPlugin("DaanDeReus.GodMode", "GodMode", "2.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class GodMode : BaseUnityPlugin { internal static bool IsGodModeEnabled = true; private GUIStyle? statusStyle; private GUIStyle? shadowStyle; private Vector2 statusSize = new Vector2(260f, 36f); private float padding = 16f; internal static GodMode Instance { get; private set; } = null; internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; GodModeConfig.Bind(((BaseUnityPlugin)this).Config); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); Logger.LogInfo((object)"Press 'G' to toggle GodMode."); if (GodModeConfig.InfiniteStamina.Value) { Logger.LogInfo((object)"InfiniteStamina is enabled (active while GodMode is on)."); } } internal void Patch() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0025: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { if (Input.GetKeyDown((KeyCode)103)) { ToggleGodMode(); } } public void ToggleGodMode() { IsGodModeEnabled = !IsGodModeEnabled; Logger.LogInfo((object)("GodMode is now " + (IsGodModeEnabled ? "ENABLED" : "DISABLED") + ".")); try { PlayerHealth[] array = Object.FindObjectsOfType<PlayerHealth>(); PlayerHealth[] array2 = array; foreach (PlayerHealth val in array2) { val.godMode = IsGodModeEnabled; if (IsGodModeEnabled) { val.health = val.maxHealth; } } if (!IsGodModeEnabled || !GodModeConfig.InfiniteStamina.Value) { return; } PlayerController[] array3 = Object.FindObjectsOfType<PlayerController>(); PlayerController[] array4 = array3; foreach (PlayerController val2 in array4) { if (val2.EnergyCurrent < val2.EnergyStart) { val2.EnergyCurrent = val2.EnergyStart; } } } catch (Exception ex) { Logger.LogError((object)("Error updating GodMode status: " + ex.Message)); } } private void OnGUI() { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0052: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0066: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0181: 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_019e: Unknown result type (might be due to invalid IL or missing references) if (statusStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.box) { fontSize = 18, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; val.normal.textColor = Color.white; val.padding = new RectOffset(12, 12, 6, 6); val.border = new RectOffset(8, 8, 8, 8); statusStyle = val; GUIStyle val2 = new GUIStyle(statusStyle); val2.normal.textColor = new Color(0f, 0f, 0f, 0.7f); shadowStyle = val2; } float num = (float)Screen.width - statusSize.x - padding; float num2 = (float)Screen.height - statusSize.y - padding; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(num, num2, statusSize.x, statusSize.y); Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = (IsGodModeEnabled ? new Color(0.2f, 0.7f, 0.2f, 0.85f) : new Color(0.7f, 0.2f, 0.2f, 0.85f)); string text = "GodMode: " + (IsGodModeEnabled ? "<b>ENABLED</b>" : "<b>DISABLED</b>") + " [G]"; Rect val4 = val3; ((Rect)(ref val4)).x = ((Rect)(ref val4)).x + 2f; ((Rect)(ref val4)).y = ((Rect)(ref val4)).y + 2f; GUI.Label(val4, text, shadowStyle); GUI.Box(val3, text, statusStyle); GUI.backgroundColor = backgroundColor; } } internal static class GodModeConfig { internal static ConfigEntry<bool> InfiniteStamina { get; private set; } internal static bool IsActive { get { if (InfiniteStamina.Value) { return GodMode.IsGodModeEnabled; } return false; } } internal static void Bind(ConfigFile config) { InfiniteStamina = config.Bind<bool>("General", "InfiniteStamina", true, "Refill energy (stamina) to maximum while GodMode is enabled (G key)."); } } [HarmonyPatch(typeof(PlayerController))] internal static class PlayerControllerPatch { [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start_Postfix(PlayerController __instance) { if (!GodModeConfig.IsActive) { return; } try { RefillEnergy(__instance); GodMode.Logger.LogInfo((object)$"InfiniteStamina: energy set to max ({__instance.EnergyStart})"); } catch (Exception ex) { GodMode.Logger.LogError((object)("InfiniteStamina Start postfix failed: " + ex.Message)); } } [HarmonyPostfix] [HarmonyPatch("Update")] private static void Update_Postfix(PlayerController __instance) { TryRefillEnergy(__instance); } [HarmonyPostfix] [HarmonyPatch("FixedUpdate")] private static void FixedUpdate_Postfix(PlayerController __instance) { TryRefillEnergy(__instance); } private static void TryRefillEnergy(PlayerController controller) { if (!GodModeConfig.IsActive) { return; } try { RefillEnergy(controller); } catch (Exception ex) { GodMode.Logger.LogError((object)("InfiniteStamina refill failed: " + ex.Message)); } } private static void RefillEnergy(PlayerController controller) { if (controller.EnergyCurrent < controller.EnergyStart) { controller.EnergyCurrent = controller.EnergyStart; } } } [HarmonyPatch(typeof(PlayerHealth))] internal static class PlayerHealthPatch { [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start_Postfix(PlayerHealth __instance) { try { __instance.godMode = GodMode.IsGodModeEnabled; GodMode.Logger.LogInfo((object)("GodMode: godMode " + (__instance.godMode ? "on" : "off"))); if (GodMode.IsGodModeEnabled) { __instance.health = __instance.maxHealth; GodMode.Logger.LogInfo((object)$"GodMode: health set to max ({__instance.maxHealth})"); } } catch (Exception ex) { GodMode.Logger.LogError((object)("GodMode Start postfix failed: " + ex.Message)); } } [HarmonyPrefix] [HarmonyPatch("Hurt", new Type[] { typeof(int), typeof(bool), typeof(int), typeof(bool) })] private static bool Hurt_Prefix(PlayerHealth __instance, ref int damage, bool savingGrace, int enemyIndex, bool hurtByHeal) { try { if (GodMode.IsGodModeEnabled) { GodMode.Logger.LogInfo((object)$"GodMode: damage ({damage}) blocked"); damage = 0; } return true; } catch (Exception ex) { GodMode.Logger.LogError((object)("Hurt_Prefix failed: " + ex.Message)); return true; } } [HarmonyPrefix] [HarmonyPatch("HurtOther", new Type[] { typeof(int), typeof(Vector3), typeof(bool), typeof(int), typeof(bool) })] private static bool HurtOther_Prefix(PlayerHealth __instance, ref int damage, Vector3 hurtPosition, bool savingGrace, int enemyIndex, bool hurtByHeal) { try { if (GodMode.IsGodModeEnabled) { GodMode.Logger.LogInfo((object)$"GodMode: HurtOther damage ({damage}) blocked"); damage = 0; } return true; } catch (Exception ex) { GodMode.Logger.LogError((object)("HurtOther_Prefix failed: " + ex.Message)); return true; } } [HarmonyPostfix] [HarmonyPatch("Update")] private static void Update_Postfix(PlayerHealth __instance) { if (GodMode.IsGodModeEnabled) { if (!__instance.godMode) { __instance.godMode = true; } if (__instance.health < __instance.maxHealth) { __instance.health = __instance.maxHealth; } } else if (__instance.godMode) { __instance.godMode = false; } } } }