using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("UKButYouAreV2")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UKButYouAreV2")]
[assembly: AssemblyTitle("UKButYouAreV2")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 UKButYouAreV2
{
[BepInPlugin("UKButYouAreV2.adry.ultrakill", "UK But You Are V2", "2.0.0")]
public class UKButYouAreV2 : BaseUnityPlugin
{
[HarmonyPatch(typeof(NewMovement))]
public class NewMovementPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPostfix(NewMovement __instance)
{
if (!((Object)(object)PluginInstance != (Object)null) || PluginInstance.modEnabled.Value)
{
__instance.hp = 400;
Debug.Log((object)"[UKButYouAreV2] Initial HP set to 400.");
}
}
[HarmonyPatch("GetHealth")]
[HarmonyPrefix]
public static bool GetHealthPrefix(NewMovement __instance, ref int health, ref bool silent, ref bool fromExplosion)
{
if ((Object)(object)PluginInstance != (Object)null && !PluginInstance.modEnabled.Value)
{
return true;
}
if ((Object)(object)PluginInstance != (Object)null && PluginInstance.enableRegeneration.Value)
{
if (__instance.hp < 400)
{
__instance.hp = Mathf.Min(__instance.hp + health, 400);
}
return false;
}
return true;
}
[HarmonyPatch("Respawn")]
[HarmonyPostfix]
public static void RespawnPostfix(NewMovement __instance)
{
if (!((Object)(object)PluginInstance != (Object)null) || PluginInstance.modEnabled.Value)
{
__instance.hp = 400;
Debug.Log((object)"[UKButYouAreV2] HP restored to 400 after respawn.");
}
}
[HarmonyPatch("SuperCharge")]
[HarmonyPrefix]
public static bool SuperChargePrefix(NewMovement __instance)
{
if ((Object)(object)PluginInstance != (Object)null && !PluginInstance.modEnabled.Value)
{
return true;
}
__instance.hp = 800;
Debug.Log((object)"[UKButYouAreV2] HP set to 800 during SuperCharge.");
return false;
}
[HarmonyPatch("ForceAddAntiHP")]
[HarmonyPrefix]
public static bool ForceAddAntiHPPrefix(NewMovement __instance)
{
if ((Object)(object)PluginInstance != (Object)null && !PluginInstance.modEnabled.Value)
{
return true;
}
return false;
}
[HarmonyPatch("ForceAntiHP")]
[HarmonyPrefix]
public static bool ForceAntiHPPrefix(NewMovement __instance)
{
if ((Object)(object)PluginInstance != (Object)null && !PluginInstance.modEnabled.Value)
{
return true;
}
__instance.antiHp = 0f;
return false;
}
[HarmonyPatch("GetHurt")]
[HarmonyPrefix]
public static void GetHurtPrefix(NewMovement __instance, ref int damage)
{
if ((Object)(object)PluginInstance != (Object)null && PluginInstance.modEnabled.Value)
{
float num = (float)PluginInstance.damageReduction.Value / 100f;
damage = Mathf.RoundToInt((float)damage * (1f - num));
Debug.Log((object)$"[UKButYouAreV2] Damage reduced to {damage} (reduction: {num * 100f}%).");
}
}
}
[HarmonyPatch(typeof(HealthBar))]
public class HealthBarPatch
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
public static void UpdatePrefix(HealthBar __instance)
{
if (!((Object)(object)PluginInstance != (Object)null) || PluginInstance.modEnabled.Value)
{
object? value = AccessTools.Field(typeof(HealthBar), "nmov").GetValue(__instance);
NewMovement val = (NewMovement)((value is NewMovement) ? value : null);
if ((Object)(object)val != (Object)null)
{
val.antiHp = 0f;
}
}
}
}
[HarmonyPatch(typeof(FistControl))]
public class FistControlPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPostfix(FistControl __instance)
{
if (!((Object)(object)PluginInstance != (Object)null) || PluginInstance.modEnabled.Value)
{
__instance.ResetFists();
AccessTools.Field(typeof(FistControl), "currentVarNum").SetValue(__instance, 1);
List<int> list = AccessTools.Field(typeof(FistControl), "spawnedArmNums").GetValue(__instance) as List<int>;
list.Clear();
list.Add(1);
AccessTools.Field(typeof(FistControl), "spawnedArmNums").SetValue(__instance, list);
__instance.ForceArm(1, false);
Debug.Log((object)"[UKButYouAreV2] Knuckleblaster forced as the initial arm.");
}
}
[HarmonyPatch("ResetFists")]
[HarmonyPrefix]
public static bool ResetFistsPrefix(FistControl __instance)
{
if ((Object)(object)PluginInstance != (Object)null && !PluginInstance.modEnabled.Value)
{
return true;
}
List<GameObject> list = AccessTools.Field(typeof(FistControl), "spawnedArms").GetValue(__instance) as List<GameObject>;
List<int> list2 = AccessTools.Field(typeof(FistControl), "spawnedArmNums").GetValue(__instance) as List<int>;
if (list.Count > 0)
{
for (int i = 0; i < list.Count; i++)
{
Object.Destroy((Object)(object)list[i]);
}
list.Clear();
list2.Clear();
}
MonoSingleton<HookArm>.Instance.equipped = false;
GameObject item = Object.Instantiate<GameObject>(AddressablesExtensions.ToAsset(__instance.redArm), ((Component)__instance).transform);
list.Add(item);
list2.Add(1);
AccessTools.Field(typeof(FistControl), "spawnedArms").SetValue(__instance, list);
AccessTools.Field(typeof(FistControl), "spawnedArmNums").SetValue(__instance, list2);
AccessTools.Method(typeof(FistControl), "CheckFist", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { "arm2" });
AccessTools.Method(typeof(FistControl), "CheckFist", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { "arm3" });
GameObject[] array = (GameObject[])AccessTools.Field(typeof(FistControl), "fistPanels").GetValue(__instance);
for (int j = 0; j < array.Length; j++)
{
array[j].SetActive(false);
}
__instance.ForceArm(1, false);
__instance.UpdateFistIcon();
return false;
}
[HarmonyPatch("Update")]
[HarmonyPrefix]
public static void UpdatePrefix(FistControl __instance)
{
if (!((Object)(object)PluginInstance != (Object)null) || PluginInstance.modEnabled.Value)
{
List<GameObject> list = AccessTools.Field(typeof(FistControl), "spawnedArms").GetValue(__instance) as List<GameObject>;
List<int> list2 = AccessTools.Field(typeof(FistControl), "spawnedArmNums").GetValue(__instance) as List<int>;
if (list.Count > 1 && !__instance.shopping && ((Object)(object)MonoSingleton<SpawnMenu>.Instance == (Object)null || !((Component)MonoSingleton<SpawnMenu>.Instance).gameObject.activeInHierarchy))
{
__instance.ArmChange(list2.IndexOf(1));
}
}
}
[HarmonyPatch("ScrollArm")]
[HarmonyPrefix]
public static bool ScrollArmPrefix(FistControl __instance)
{
if ((Object)(object)PluginInstance != (Object)null && !PluginInstance.modEnabled.Value)
{
return true;
}
return false;
}
}
private ConfigEntry<bool> modEnabled;
private ConfigEntry<bool> enableRegeneration;
private ConfigEntry<int> damageReduction;
private static UKButYouAreV2 PluginInstance => Object.FindObjectOfType<UKButYouAreV2>();
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
Harmony val = new Harmony("UKButYouAreV2.adry.ultrakill");
val.PatchAll();
modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Mod", true, "Enables or disables the mod.");
enableRegeneration = ((BaseUnityPlugin)this).Config.Bind<bool>("Health", "Enable HP Regeneration", false, "Enables or disables health regeneration.");
damageReduction = ((BaseUnityPlugin)this).Config.Bind<int>("Defense", "Damage Reduction", 0, new ConfigDescription("Damage reduction percentage (0% - 100%).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
((BaseUnityPlugin)this).Logger.LogInfo((object)"[UKButYouAreV2] Mod initialized.");
}
}
}