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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 ReviveHealth { [BepInPlugin("benjamin.revivehealth", "ReviveHealth", "1.0.1")] [BepInProcess("REPO.exe")] public class Plugin : BaseUnityPlugin { public const string Guid = "benjamin.revivehealth"; public const string Name = "ReviveHealth"; public const string Version = "1.0.1"; internal static ManualLogSource Log; private Harmony _harmony; internal static ConfigEntry Enabled; internal static ConfigEntry RevivePercent; internal static ConfigEntry MinimumHealth; internal static ConfigEntry Verbose; private void Awake() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Master switch. Turn off to restore vanilla revive health without uninstalling."); RevivePercent = ((BaseUnityPlugin)this).Config.Bind("Revive", "RevivePercent", 50, new ConfigDescription("Percent of the player's MAX health they come back with. Scales with health upgrades, so this stays fair all run rather than becoming irrelevant by level 10.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); MinimumHealth = ((BaseUnityPlugin)this).Config.Bind("Revive", "MinimumHealth", 10, new ConfigDescription("Floor, in absolute HP. Stops a low percentage on an un-upgraded player reviving them at 1 HP.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 200), Array.Empty())); Verbose = ((BaseUnityPlugin)this).Config.Bind("Debug", "Verbose", false, "Log every revive with the health granted."); _harmony = new Harmony("benjamin.revivehealth"); _harmony.PatchAll(typeof(RevivePatch)); Log.LogInfo((object)"ReviveHealth v1.0.1 loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void Trace(string msg) { if (Verbose != null && Verbose.Value) { Log.LogInfo((object)msg); } } } [HarmonyPatch(typeof(PlayerAvatar))] internal static class RevivePatch { [HarmonyPostfix] [HarmonyPatch("Revive")] private static void AfterRevive(PlayerAvatar __instance) { if (!Plugin.Enabled.Value) { return; } PlayerHealth playerHealth = __instance.playerHealth; if (!((Object)(object)playerHealth == (Object)null)) { int maxHealth = playerHealth.maxHealth; if (maxHealth > 0) { int num = Mathf.Max(Plugin.MinimumHealth.Value, Mathf.CeilToInt((float)maxHealth * ((float)Plugin.RevivePercent.Value / 100f))); num = Mathf.Min(num, maxHealth); int health = playerHealth.health; playerHealth.health = num; Plugin.Trace($"[ReviveHealth] {__instance.playerName}: revived at {health} -> {num}/{maxHealth}"); } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "ReviveHealth"; public const string PLUGIN_NAME = "ReviveHealth"; public const string PLUGIN_VERSION = "1.0.1"; } }