using 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 HarmonyLib;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("DaanDeReus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GodMode")]
[assembly: AssemblyTitle("GodMode")]
[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.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", "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;
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.");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: 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;
Logger.LogInfo((object)$"GodMode for {((Object)((Component)val).gameObject).name} is now {IsGodModeEnabled}.");
if (IsGodModeEnabled)
{
val.health = val.maxHealth;
}
}
}
catch (Exception ex)
{
Logger.LogError((object)("Error updating GodMode status: " + ex.Message));
}
}
private void OnGUI()
{
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_0075: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: 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)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: 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;
}
}
[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 ? "geactiveerd" : "gedeactiveerd") + " voor " + ((Object)((Component)__instance).gameObject).name));
if (GodMode.IsGodModeEnabled)
{
__instance.health = __instance.maxHealth;
GodMode.Logger.LogInfo((object)$"GodMode: Gezondheid gereset naar maximum ({__instance.maxHealth}) voor {((Object)((Component)__instance).gameObject).name}");
}
}
catch (Exception ex)
{
GodMode.Logger.LogError((object)("Fout bij het activeren van GodMode: " + ex.Message));
}
}
[HarmonyPrefix]
[HarmonyPatch("Hurt", new Type[]
{
typeof(int),
typeof(bool),
typeof(int)
})]
private static bool Hurt_Prefix(PlayerHealth __instance, ref int damage)
{
try
{
if (GodMode.IsGodModeEnabled)
{
GodMode.Logger.LogInfo((object)$"GodMode: Schade ({damage}) genegeerd voor {((Object)((Component)__instance).gameObject).name}");
damage = 0;
}
return true;
}
catch (Exception ex)
{
GodMode.Logger.LogError((object)("Fout in Hurt_Prefix: " + ex.Message));
return true;
}
}
[HarmonyPrefix]
[HarmonyPatch("HurtOther", new Type[]
{
typeof(int),
typeof(Vector3),
typeof(bool),
typeof(int)
})]
private static bool HurtOther_Prefix(PlayerHealth __instance, ref int damage)
{
try
{
if (GodMode.IsGodModeEnabled)
{
GodMode.Logger.LogInfo((object)$"GodMode: HurtOther schade ({damage}) genegeerd voor {((Object)((Component)__instance).gameObject).name}");
damage = 0;
}
return true;
}
catch (Exception ex)
{
GodMode.Logger.LogError((object)("Fout in HurtOther_Prefix: " + 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;
}
}
}
}