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; [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 ShopSafety { [BepInPlugin("benjamin.shopsafety", "ShopSafety", "1.0.0")] [BepInProcess("REPO.exe")] public class Plugin : BaseUnityPlugin { public const string Guid = "benjamin.shopsafety"; public const string Name = "ShopSafety"; public const string Version = "1.0.0"; internal static ManualLogSource Log; private Harmony _harmony; internal static ConfigEntry Enabled; internal static ConfigEntry BlockAllDamage; internal static ConfigEntry Verbose; private void Awake() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Master switch."); BlockAllDamage = ((BaseUnityPlugin)this).Config.Bind("Safety", "BlockAllDamage", false, "Block every source of damage in the shop, not just enemy damage. Off by default so you can still fall off things - the shop's threat is the occasional wandering enemy, not fall damage."); Verbose = ((BaseUnityPlugin)this).Config.Bind("Debug", "Verbose", false, "Log every block."); _harmony = new Harmony("benjamin.shopsafety"); _harmony.PatchAll(typeof(ShopDamagePatch)); Log.LogInfo((object)"ShopSafety v1.0.0 loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void Trace(string m) { if (Verbose != null && Verbose.Value) { Log.LogInfo((object)m); } } } [HarmonyPatch(typeof(PlayerHealth))] internal static class ShopDamagePatch { private static bool Block(int enemyIndex) { if (!Plugin.Enabled.Value) { return false; } if (!SemiFunc.RunIsShop()) { return false; } if (!Plugin.BlockAllDamage.Value) { return enemyIndex >= 0; } return true; } [HarmonyPrefix] [HarmonyPatch("Hurt")] private static bool BeforeHurt(int damage, int enemyIndex) { if (!Block(enemyIndex)) { return true; } Plugin.Trace($"[ShopSafety] Blocked {damage} damage in shop."); return false; } [HarmonyPrefix] [HarmonyPatch("HurtOther")] private static bool BeforeHurtOther(int damage, int enemyIndex) { if (!Block(enemyIndex)) { return true; } Plugin.Trace($"[ShopSafety] Blocked {damage} remote damage in shop."); return false; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "ShopSafety"; public const string PLUGIN_NAME = "ShopSafety"; public const string PLUGIN_VERSION = "1.0.0"; } }