using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [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 NormalAIPeople.WandererRNoSelfDamage { [BepInPlugin("normalAIPeople.WandererRNoSelfDamage", "Wanderer R No Self Damage", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class WandererRNoSelfDamagePlugin : BaseUnityPlugin { private static ConfigEntry guardDuration; private static readonly Dictionary activeR = new Dictionary(); private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown guardDuration = ((BaseUnityPlugin)this).Config.Bind("Wanderer", "R Self-Damage Guard Duration", 3f, "Maximum R duration in seconds. Only self-inflicted damage is blocked; enemy and environmental damage are unchanged."); Type type = AccessTools.TypeByName("UnforgivenMod.Unforgiven.SkillStates.DashSpecial"); if (!(type == null)) { Harmony val = new Harmony("normalAIPeople.WandererRNoSelfDamage"); val.Patch((MethodBase)AccessTools.Method(type, "OnEnter", (Type[])null, (Type[])null), new HarmonyMethod(typeof(WandererRNoSelfDamagePlugin), "ROnEnterPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Type type2 = AccessTools.TypeByName("UnforgivenMod.Unforgiven.SkillStates.Special"); if (type2 != null) { val.Patch((MethodBase)AccessTools.Method(type2, "OnEnter", (Type[])null, (Type[])null), new HarmonyMethod(typeof(WandererRNoSelfDamagePlugin), "ROnEnterPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(type2, "OnExit", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(WandererRNoSelfDamagePlugin), "ROnExitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } val.Patch((MethodBase)AccessTools.Method(typeof(HealthComponent), "TakeDamage", (Type[])null, (Type[])null), new HarmonyMethod(typeof(WandererRNoSelfDamagePlugin), "SelfDamagePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo = AccessTools.Method(typeof(DotController), "InflictDot", new Type[1] { typeof(InflictDotInfo).MakeByRefType() }, (Type[])null); if (methodInfo != null) { val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(WandererRNoSelfDamagePlugin), "SelfDotPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private static void ROnEnterPrefix(object __instance) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) CharacterBody value = Traverse.Create(__instance).Property("characterBody", (object[])null).GetValue(); if ((Object)(object)value != (Object)null && value.bodyIndex == BodyCatalog.FindBodyIndex("UnforgivenBody")) { activeR[value] = Time.fixedTime + Math.Max(0f, guardDuration.Value); } } private static void ROnExitPostfix(object __instance) { CharacterBody value = Traverse.Create(__instance).Property("characterBody", (object[])null).GetValue(); if ((Object)(object)value != (Object)null && activeR.TryGetValue(value, out var value2)) { activeR[value] = Math.Max(value2, Time.fixedTime + 0.5f); } } private static bool IsRActive(CharacterBody body) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)body == (Object)null || body.bodyIndex != BodyCatalog.FindBodyIndex("UnforgivenBody")) { return false; } if (!activeR.TryGetValue(body, out var value)) { return false; } if (Time.fixedTime <= value) { return true; } activeR.Remove(body); return false; } private static bool SelfDamagePrefix(HealthComponent __instance, DamageInfo damageInfo) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Invalid comparison between Unknown and I4 if (!NetworkServer.active || (Object)(object)__instance == (Object)null || (Object)(object)__instance.body == (Object)null) { return true; } CharacterBody body = __instance.body; if (!IsRActive(body)) { return true; } bool flag = (Object)(object)damageInfo.attacker == (Object)(object)((Component)body).gameObject || (Object)(object)damageInfo.inflictor == (Object)(object)((Component)body).gameObject; bool flag2 = (Object)(object)damageInfo.attacker == (Object)null && (Object)(object)damageInfo.inflictor == (Object)null && (int)damageInfo.damageType.damageSource == 8; return !flag && !flag2; } private static bool SelfDotPrefix(ref InflictDotInfo inflictDotInfo) { if (!NetworkServer.active || (Object)(object)inflictDotInfo.victimObject == (Object)null) { return true; } CharacterBody component = inflictDotInfo.victimObject.GetComponent(); if (!IsRActive(component)) { return true; } return (Object)(object)inflictDotInfo.attackerObject != (Object)null && (Object)(object)inflictDotInfo.attackerObject != (Object)(object)((Component)component).gameObject; } } }