using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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: AssemblyTitle("HTF")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HTF")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5208ed49-769e-472d-8164-a43d8313e78b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HTF_OnePunch;
[BepInPlugin("HTF.kr.OnePunch", "OnePunch", "1.0.0")]
public class ModBehaviour : BaseUnityPlugin
{
public class EnergyBar
{
private Image energyPercent;
private Image energyPercentLerped;
private int energy = 400;
private const int maxEnergy = 1000;
private void setPlayerEnergy(float percent)
{
percent = Mathf.Clamp01(percent);
LeanTween.cancel(((Component)energyPercentLerped).gameObject);
if (energyPercent.fillAmount > percent)
{
LeanTween.value(((Component)energyPercentLerped).gameObject, energyPercentLerped.fillAmount, percent, 0.5f).setEase((LeanTweenType)2).setOnUpdate((Action<float>)delegate(float val)
{
energyPercentLerped.fillAmount = val;
});
}
else
{
energyPercentLerped.fillAmount = percent;
}
energyPercent.fillAmount = percent;
}
private void updateBar()
{
setPlayerEnergy((float)energy / 1000f);
}
public void init(Image Percent, Image PercentLerped)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
energyBar.energyPercentLerped = Object.Instantiate<GameObject>(((Component)PercentLerped).gameObject, ((Component)PercentLerped).transform.parent).GetComponent<Image>();
energyBar.energyPercent = Object.Instantiate<GameObject>(((Component)Percent).gameObject, ((Component)Percent).transform.parent).GetComponent<Image>();
((Component)energyBar.energyPercent).GetComponent<RectTransform>().anchoredPosition = new Vector2(65f, 0f);
((Component)energyBar.energyPercentLerped).GetComponent<RectTransform>().anchoredPosition = new Vector2(65f, 0f);
((Graphic)energyBar.energyPercent).color = Color.blue;
((Graphic)energyBar.energyPercentLerped).color = Color.deepSkyBlue;
updateBar();
}
public void addEnergy(int val)
{
energy += val;
energy = ((energy < 1000) ? energy : 1000);
updateBar();
}
public bool useEnergy()
{
if (energy == 1000)
{
energy = 0;
updateBar();
return true;
}
return false;
}
}
[HarmonyPatch(typeof(VitalsUI))]
public class VitalsUI_path
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void Awake_Postfix(Image ____fullnessPercent, Image ____fullnessPercentLerped)
{
energyBar.init(____fullnessPercent, ____fullnessPercentLerped);
}
}
[HarmonyPatch(typeof(Server))]
public class Server_path
{
[HarmonyPostfix]
[HarmonyPatch("FinishEatingCreature")]
private static void FinishEatingCreature_Postfix(Creature creature)
{
energyBar.addEnergy(creature.FullnessToRestore);
}
}
[HarmonyPatch(typeof(PlayerPunching))]
public class PlayerPunching_path
{
[HarmonyTranspiler]
[HarmonyPatch("HitTarget")]
private static IEnumerable<CodeInstruction> HitTarget_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
for (int i = 0; i < list.Count; i++)
{
if (!(list[i].opcode == OpCodes.Callvirt) || !(list[i].operand is MethodInfo))
{
continue;
}
MethodInfo methodInfo = list[i].operand as MethodInfo;
MethodInfo methodInfo2 = AccessTools.Method(typeof(PlayerPunching_path), "setDamage", (Type[])null, (Type[])null);
if (methodInfo.Name == "LocalHit")
{
if (methodInfo.DeclaringType == typeof(Item))
{
Debug.Log((object)"find Item LocalHit");
list.Insert(i - 3, new CodeInstruction(OpCodes.Call, (object)methodInfo2));
i++;
}
else if (methodInfo.DeclaringType == typeof(PlayerVitals))
{
Debug.Log((object)"find PlayerVitals LocalHit");
list.Insert(i - 5, new CodeInstruction(OpCodes.Call, (object)methodInfo2));
break;
}
}
}
return list;
}
private static int setDamage(int damage)
{
if (energyBar.useEnergy())
{
return 999;
}
energyBar.addEnergy(1);
return damage;
}
}
private Harmony harmony;
private static ManualLogSource Log;
private static EnergyBar energyBar = new EnergyBar();
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
harmony = new Harmony("HTF.kr.OnePunch");
harmony.PatchAll();
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"OnePunch enble");
}
}