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;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BetterSharedHealthPacks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterSharedHealthPacks")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0ac8e86e-a2e6-47d8-8201-9706ed66405d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterSharedHealthPacks;
[BepInPlugin("com.repo.kr.BetterSharedHealthPacks", "BetterSharedHealthPacks", "1.0.0")]
public class ModBehaviour : BaseUnityPlugin
{
[HarmonyPatch(typeof(PlayerHealth))]
public class PlayerHealth_path
{
[HarmonyPostfix]
[HarmonyPatch("HealOther")]
private static void HealOther_Postfix(PlayerHealth __instance, int healAmount, bool effect)
{
if (!healAllFrag)
{
return;
}
healAllFrag = false;
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
if ((Object)(object)item.playerHealth != (Object)(object)__instance)
{
item.playerHealth.HealOther(healAmount, effect);
}
}
}
}
[HarmonyPatch(typeof(ItemHealthPack))]
public class ItemHealthPack_path
{
[HarmonyPatch("Update")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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 methodInfo && methodInfo.Name == "HealOther")
{
Debug.Log((object)"find HealOther");
list.Insert(i, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ItemHealthPack_path), "setHealAll", (Type[])null, (Type[])null)));
i++;
break;
}
}
return list;
}
private static void setHealAll()
{
healAllFrag = true;
}
}
private Harmony harmony;
private static ManualLogSource Log;
private static bool healAllFrag;
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("com.repo.kr.BetterSharedHealthPacks");
harmony.PatchAll();
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"BetterSharedHealthPacks enble");
}
}