using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TeamHeals.Config;
using TeamHeals.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("TeamHeals")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TeamHeals")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8b363090-6f7a-451a-92a9-ed78838c26e0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TeamHeals
{
[BepInPlugin("EvilCheetah.REPO.TeamHeals", "R.E.P.O. Team Heals", "1.0.0")]
public class TeamHealsPlugin : BaseUnityPlugin
{
private const string mod_guid = "EvilCheetah.REPO.TeamHeals";
private const string mod_name = "R.E.P.O. Team Heals";
private const string mod_version = "1.0.0";
private readonly Harmony harmony = new Harmony("EvilCheetah.REPO.TeamHeals");
private static TeamHealsPlugin instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
Configuration.Init(((BaseUnityPlugin)this).Config);
mls = Logger.CreateLogSource("EvilCheetah.REPO.TeamHeals");
mls.LogInfo((object)"Team Heals mod has been activated");
harmony.PatchAll(typeof(TeamHealsPlugin));
harmony.PatchAll(typeof(ItemHealthPackPatch));
harmony.PatchAll(typeof(PunManagerPatch));
}
}
}
namespace TeamHeals.Patches
{
[HarmonyPatch(typeof(ItemHealthPack))]
internal class ItemHealthPackPatch
{
private static readonly FieldRef<ItemHealthPack, ItemToggle> item_toggle_ref = AccessTools.FieldRefAccess<ItemHealthPack, ItemToggle>("itemToggle");
private static readonly FieldRef<ItemToggle, int> player_photon_id_ref = AccessTools.FieldRefAccess<ItemToggle, int>("playerTogglePhotonID");
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void OverrideHealAmount(ItemHealthPack __instance)
{
__instance.healAmount = (int)Math.Ceiling((float)__instance.healAmount * Configuration.HealAmountMultiplier.Value);
}
[HarmonyPostfix]
[HarmonyPatch("OnDestroy")]
private static void HealAll(ItemHealthPack __instance)
{
ref ItemToggle reference = ref item_toggle_ref.Invoke(__instance);
PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(player_photon_id_ref.Invoke(reference));
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
if (item.photonView.ViewID != val.photonView.ViewID)
{
item.playerHealth.HealOther(__instance.healAmount, true);
}
}
}
}
[HarmonyPatch(typeof(PunManager), "ShopPopulateItemVolumes")]
internal class PunManagerPatch
{
private static readonly FieldRef<PunManager, ShopManager> shop_manager_ref = AccessTools.FieldRefAccess<PunManager, ShopManager>("shopManager");
public static bool Prefix(PunManager __instance)
{
List<Item> list = new HashSet<Item>(shop_manager_ref.Invoke(__instance).potentialItemHealthPacks).Distinct().ToList();
ManualLogSource val = Logger.CreateLogSource("Item");
val.LogInfo((object)$"Number of Items: {list.Count}");
for (int i = 0; i < list.Count; i++)
{
string itemName = list[i].itemName;
val.LogInfo((object)("Old Name: " + itemName));
string text = Regex.Replace(itemName, "\\d+", delegate(Match match)
{
int num = int.Parse(match.Value);
return ((int)Math.Ceiling((float)num * Configuration.HealAmountMultiplier.Value)).ToString();
});
list[i].itemName = text;
val.LogInfo((object)("New Name: `" + text + "`"));
}
return true;
}
}
}
namespace TeamHeals.Config
{
internal class Configuration
{
public static ConfigEntry<float> HealAmountMultiplier;
public static void Init(ConfigFile config)
{
HealAmountMultiplier = config.Bind<float>("General", "HealAmountMultiplier", 1f, "Multiplier applied to the health pack healing");
}
}
}