using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API.AutoVersionGen;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("R2API.Dot")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+733d42438524ee7fa178e1f85d00f8b8f9772b6a")]
[assembly: AssemblyProduct("R2API.Dot")]
[assembly: AssemblyTitle("R2API.Dot")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
}
namespace R2API
{
[AutoVersion]
public static class DotAPI
{
public delegate void CustomDotBehaviour(DotController self, DotStack dotStack);
public delegate void CustomDotVisual(DotController self);
[CompilerGenerated]
private static class <>O
{
public static Manipulator <0>__RetrieveVanillaCount;
public static Manipulator <1>__ResizeTimerArray;
public static hook_InitDotCatalog <2>__AddCustomDots;
public static hook_Awake <3>__TrackActiveCustomDots;
public static hook_OnDestroy <4>__TrackActiveCustomDots2;
public static hook_GetDotDef <5>__GetDotDef;
public static hook_FixedUpdate <6>__FixedUpdate;
public static Manipulator <7>__FixInflictDotReturnCheck;
public static Manipulator <8>__CallCustomDotBehaviours;
public static hook_HasDotActive <9>__OnHasDotActive;
public static Manipulator <10>__EvaluateDotStacksForType;
public static Manipulator <11>__FixDeathMark;
public static Func<DotController, int, int> <12>__CountCustomDots;
}
public const string PluginGUID = "com.bepis.r2api.dot";
public const string PluginName = "R2API.Dot";
private static readonly List<DotDef> CustomDots = new List<DotDef>();
public static int VanillaDotCount;
private static readonly Dictionary<DotController, bool[]> ActiveCustomDots = new Dictionary<DotController, bool[]>();
private static CustomDotBehaviour[] _customDotBehaviours = new CustomDotBehaviour[0];
private static CustomDotVisual[] _customDotVisuals = new CustomDotVisual[0];
private static bool _hooksEnabled = false;
public const string PluginVersion = "1.0.3";
[Obsolete("All submodules are automatically loaded and this property is now unused")]
public static bool Loaded => true;
private static DotDef[] DotDefs
{
get
{
return DotController.dotDefs;
}
set
{
DotController.dotDefs = value;
}
}
public static int CustomDotCount => CustomDots.Count;
private static void ResizeDotDefs(int newSize)
{
DotDef[] array = DotDefs;
Array.Resize(ref array, newSize);
DotDefs = array;
}
public static DotIndex RegisterDotDef(DotDef? dotDef, CustomDotBehaviour? customDotBehaviour = null, CustomDotVisual? customDotVisual = null)
{
SetHooks();
int num = VanillaDotCount + CustomDotCount;
if (DotDefs != null)
{
ResizeDotDefs(num + 1);
DotDefs[num] = dotDef;
}
CustomDots.Add(dotDef);
int num2 = _customDotBehaviours.Length;
Array.Resize(ref _customDotBehaviours, _customDotBehaviours.Length + 1);
_customDotBehaviours[num2] = customDotBehaviour;
Array.Resize(ref _customDotVisuals, _customDotVisuals.Length + 1);
_customDotVisuals[num2] = customDotVisual;
if ((Object)(object)dotDef.associatedBuff != (Object)null)
{
DotPlugin.Logger.LogInfo((object)$"Custom Dot (Index: {num}) that uses Buff : {((Object)dotDef.associatedBuff).name} added");
}
else
{
DotPlugin.Logger.LogInfo((object)$"Custom Dot (Index: {num}) with no associated Buff added");
}
return (DotIndex)num;
}
public static DotIndex RegisterDotDef(float interval, float damageCoefficient, DamageColorIndex colorIndex, BuffDef associatedBuff = null, CustomDotBehaviour customDotBehaviour = null, CustomDotVisual customDotVisual = null)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
SetHooks();
return RegisterDotDef(new DotDef
{
associatedBuff = associatedBuff,
damageCoefficient = damageCoefficient,
interval = interval,
damageColorIndex = colorIndex
}, customDotBehaviour, customDotVisual);
}
internal static void SetHooks()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Expected O, but got Unknown
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Expected O, but got Unknown
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Expected O, but got Unknown
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected O, but got Unknown
if (!_hooksEnabled)
{
object obj = <>O.<0>__RetrieveVanillaCount;
if (obj == null)
{
Manipulator val = RetrieveVanillaCount;
<>O.<0>__RetrieveVanillaCount = val;
obj = (object)val;
}
DotController.InitDotCatalog += (Manipulator)obj;
object obj2 = <>O.<1>__ResizeTimerArray;
if (obj2 == null)
{
Manipulator val2 = ResizeTimerArray;
<>O.<1>__ResizeTimerArray = val2;
obj2 = (object)val2;
}
DotController.Awake += (Manipulator)obj2;
object obj3 = <>O.<2>__AddCustomDots;
if (obj3 == null)
{
hook_InitDotCatalog val3 = AddCustomDots;
<>O.<2>__AddCustomDots = val3;
obj3 = (object)val3;
}
DotController.InitDotCatalog += (hook_InitDotCatalog)obj3;
object obj4 = <>O.<3>__TrackActiveCustomDots;
if (obj4 == null)
{
hook_Awake val4 = TrackActiveCustomDots;
<>O.<3>__TrackActiveCustomDots = val4;
obj4 = (object)val4;
}
DotController.Awake += (hook_Awake)obj4;
object obj5 = <>O.<4>__TrackActiveCustomDots2;
if (obj5 == null)
{
hook_OnDestroy val5 = TrackActiveCustomDots2;
<>O.<4>__TrackActiveCustomDots2 = val5;
obj5 = (object)val5;
}
DotController.OnDestroy += (hook_OnDestroy)obj5;
object obj6 = <>O.<5>__GetDotDef;
if (obj6 == null)
{
hook_GetDotDef val6 = GetDotDef;
<>O.<5>__GetDotDef = val6;
obj6 = (object)val6;
}
DotController.GetDotDef += (hook_GetDotDef)obj6;
object obj7 = <>O.<6>__FixedUpdate;
if (obj7 == null)
{
hook_FixedUpdate val7 = FixedUpdate;
<>O.<6>__FixedUpdate = val7;
obj7 = (object)val7;
}
DotController.FixedUpdate += (hook_FixedUpdate)obj7;
object obj8 = <>O.<7>__FixInflictDotReturnCheck;
if (obj8 == null)
{
Manipulator val8 = FixInflictDotReturnCheck;
<>O.<7>__FixInflictDotReturnCheck = val8;
obj8 = (object)val8;
}
DotController.InflictDot_refInflictDotInfo += (Manipulator)obj8;
object obj9 = <>O.<8>__CallCustomDotBehaviours;
if (obj9 == null)
{
Manipulator val9 = CallCustomDotBehaviours;
<>O.<8>__CallCustomDotBehaviours = val9;
obj9 = (object)val9;
}
DotController.AddDot += (Manipulator)obj9;
object obj10 = <>O.<9>__OnHasDotActive;
if (obj10 == null)
{
hook_HasDotActive val10 = OnHasDotActive;
<>O.<9>__OnHasDotActive = val10;
obj10 = (object)val10;
}
DotController.HasDotActive += (hook_HasDotActive)obj10;
object obj11 = <>O.<10>__EvaluateDotStacksForType;
if (obj11 == null)
{
Manipulator val11 = EvaluateDotStacksForType;
<>O.<10>__EvaluateDotStacksForType = val11;
obj11 = (object)val11;
}
DotController.EvaluateDotStacksForType += (Manipulator)obj11;
object obj12 = <>O.<11>__FixDeathMark;
if (obj12 == null)
{
Manipulator val12 = FixDeathMark;
<>O.<11>__FixDeathMark = val12;
obj12 = (object)val12;
}
GlobalEventManager.ProcessHitEnemy += (Manipulator)obj12;
_hooksEnabled = true;
}
}
internal static void UnsetHooks()
{
//IL_0010: 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)
//IL_001b: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Expected O, but got Unknown
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Expected O, but got Unknown
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Expected O, but got Unknown
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Expected O, but got Unknown
object obj = <>O.<0>__RetrieveVanillaCount;
if (obj == null)
{
Manipulator val = RetrieveVanillaCount;
<>O.<0>__RetrieveVanillaCount = val;
obj = (object)val;
}
DotController.InitDotCatalog -= (Manipulator)obj;
object obj2 = <>O.<1>__ResizeTimerArray;
if (obj2 == null)
{
Manipulator val2 = ResizeTimerArray;
<>O.<1>__ResizeTimerArray = val2;
obj2 = (object)val2;
}
DotController.Awake -= (Manipulator)obj2;
object obj3 = <>O.<3>__TrackActiveCustomDots;
if (obj3 == null)
{
hook_Awake val3 = TrackActiveCustomDots;
<>O.<3>__TrackActiveCustomDots = val3;
obj3 = (object)val3;
}
DotController.Awake -= (hook_Awake)obj3;
object obj4 = <>O.<4>__TrackActiveCustomDots2;
if (obj4 == null)
{
hook_OnDestroy val4 = TrackActiveCustomDots2;
<>O.<4>__TrackActiveCustomDots2 = val4;
obj4 = (object)val4;
}
DotController.OnDestroy -= (hook_OnDestroy)obj4;
object obj5 = <>O.<5>__GetDotDef;
if (obj5 == null)
{
hook_GetDotDef val5 = GetDotDef;
<>O.<5>__GetDotDef = val5;
obj5 = (object)val5;
}
DotController.GetDotDef -= (hook_GetDotDef)obj5;
object obj6 = <>O.<6>__FixedUpdate;
if (obj6 == null)
{
hook_FixedUpdate val6 = FixedUpdate;
<>O.<6>__FixedUpdate = val6;
obj6 = (object)val6;
}
DotController.FixedUpdate -= (hook_FixedUpdate)obj6;
object obj7 = <>O.<7>__FixInflictDotReturnCheck;
if (obj7 == null)
{
Manipulator val7 = FixInflictDotReturnCheck;
<>O.<7>__FixInflictDotReturnCheck = val7;
obj7 = (object)val7;
}
DotController.InflictDot_refInflictDotInfo -= (Manipulator)obj7;
object obj8 = <>O.<8>__CallCustomDotBehaviours;
if (obj8 == null)
{
Manipulator val8 = CallCustomDotBehaviours;
<>O.<8>__CallCustomDotBehaviours = val8;
obj8 = (object)val8;
}
DotController.AddDot -= (Manipulator)obj8;
object obj9 = <>O.<9>__OnHasDotActive;
if (obj9 == null)
{
hook_HasDotActive val9 = OnHasDotActive;
<>O.<9>__OnHasDotActive = val9;
obj9 = (object)val9;
}
DotController.HasDotActive -= (hook_HasDotActive)obj9;
object obj10 = <>O.<10>__EvaluateDotStacksForType;
if (obj10 == null)
{
Manipulator val10 = EvaluateDotStacksForType;
<>O.<10>__EvaluateDotStacksForType = val10;
obj10 = (object)val10;
}
DotController.EvaluateDotStacksForType -= (Manipulator)obj10;
object obj11 = <>O.<11>__FixDeathMark;
if (obj11 == null)
{
Manipulator val11 = FixDeathMark;
<>O.<11>__FixDeathMark = val11;
obj11 = (object)val11;
}
GlobalEventManager.ProcessHitEnemy -= (Manipulator)obj11;
_hooksEnabled = false;
}
private static void EvaluateDotStacksForType(ILContext il)
{
}
private static void RetrieveVanillaCount(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (!new ILCursor(il).TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction i) => ILPatternMatchingExt.MatchLdcI4(i, ref VanillaDotCount),
(Instruction i) => ILPatternMatchingExt.MatchNewarr<DotDef>(i)
}))
{
DotPlugin.Logger.LogError((object)"Failed finding IL Instructions. Aborting RetrieveVanillaCount IL Hook");
}
}
private static void ResizeTimerArray(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
if (val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction i) => ILPatternMatchingExt.MatchLdcI4(i, VanillaDotCount),
(Instruction i) => ILPatternMatchingExt.MatchNewarr<float>(i)
}))
{
int index = val.Index;
val.Index = index + 1;
val.EmitDelegate<Func<int, int>>((Func<int, int>)((int i) => DotDefs.Length));
}
else
{
DotPlugin.Logger.LogError((object)"Failed finding IL Instructions. Aborting ResizeTimerArray IL Hook");
}
}
private static void AddCustomDots(orig_InitDotCatalog orig)
{
orig.Invoke();
DotController.dotDefs = DotController.dotDefs.Concat(CustomDots).ToArray();
}
private static void TrackActiveCustomDots(orig_Awake orig, DotController self)
{
orig.Invoke(self);
ActiveCustomDots.Add(self, new bool[CustomDotCount]);
}
private static void TrackActiveCustomDots2(orig_OnDestroy orig, DotController self)
{
orig.Invoke(self);
ActiveCustomDots.Remove(self);
}
private static DotDef GetDotDef(orig_GetDotDef orig, DotIndex dotIndex)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return DotDefs[dotIndex];
}
private static void FixedUpdate(orig_FixedUpdate orig, DotController self)
{
orig.Invoke(self);
if (NetworkServer.active)
{
int num2 = default(int);
for (int i = VanillaDotCount; i < DotDefs.Length; i++)
{
DotDef val = DotDefs[i];
float[] dotTimers = self.dotTimers;
float num = dotTimers[i] - Time.fixedDeltaTime;
if (num <= 0f)
{
num += val.interval;
self.EvaluateDotStacksForType((DotIndex)i, val.interval, ref num2);
ActiveCustomDots[self][i - VanillaDotCount] = num2 != 0;
}
dotTimers[i] = num;
}
}
for (int j = 0; j < CustomDotCount; j++)
{
if (ActiveCustomDots[self][j])
{
_customDotVisuals[j]?.Invoke(self);
}
}
}
private static void FixInflictDotReturnCheck(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(InflictDotInfo), "dotIndex"),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, VanillaDotCount)
}))
{
val.Prev.OpCode = OpCodes.Ldc_I4;
val.Prev.Operand = int.MaxValue;
}
else
{
ILFailMessage(1);
}
static void ILFailMessage(int index)
{
DotPlugin.Logger.LogError((object)$"Failed finding IL Instructions. Aborting FixInflictDotReturnCheck IL Hook {index}");
}
}
private static void CallCustomDotBehaviours(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int dotStackLoc = 0;
MethodReference val2 = default(MethodReference);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
{
(Instruction i) => ILPatternMatchingExt.MatchLdsfld<DotController>(i, "dotStackPool"),
(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt(i, ref val2),
(Instruction i) => ILPatternMatchingExt.MatchStloc(i, ref dotStackLoc)
}))
{
int num2 = default(int);
ILLabel[] array = default(ILLabel[]);
if (!val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction i) => ILPatternMatchingExt.MatchLdarg(i, ref num2),
(Instruction i) => ILPatternMatchingExt.MatchSwitch(i, ref array)
}))
{
return;
}
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldloc, dotStackLoc);
val.EmitDelegate<Action<DotController, DotStack>>((Action<DotController, DotStack>)delegate(DotController self, DotStack dotStack)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected I4, but got Unknown
if ((int)dotStack.dotIndex >= VanillaDotCount)
{
int num = dotStack.dotIndex - VanillaDotCount;
_customDotBehaviours[num]?.Invoke(self, dotStack);
ActiveCustomDots[self][num] = true;
}
});
}
else
{
ILFailMessage(1);
}
static void ILFailMessage(int index)
{
DotPlugin.Logger.LogError((object)$"Failed finding IL Instructions. Aborting OnAddDot IL Hook {index}");
}
}
private static bool OnHasDotActive(orig_HasDotActive orig, DotController self, DotIndex dotIndex)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if ((int)dotIndex >= VanillaDotCount)
{
if (ActiveCustomDots.TryGetValue(self, out bool[] value))
{
return value[dotIndex - VanillaDotCount];
}
return false;
}
return orig.Invoke(self, dotIndex);
}
private static void FixDeathMark(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int dotControllerLoc = 0;
int numberOfDebuffAndDotLoc2 = 0;
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt(i, typeof(DotController), "HasDotActive")
}))
{
if (!val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction i) => ILPatternMatchingExt.MatchLdloc(i, ref numberOfDebuffAndDotLoc2)
}))
{
ILFailMessage(2);
}
}
else
{
ILFailMessage(1);
}
if (val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[2]
{
(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt(i, typeof(DotController), "FindDotController"),
(Instruction i) => ILPatternMatchingExt.MatchStloc(i, ref dotControllerLoc)
}))
{
val.Emit(OpCodes.Ldloc, dotControllerLoc);
val.Emit(OpCodes.Ldloc, numberOfDebuffAndDotLoc2);
val.EmitDelegate<Func<DotController, int, int>>((Func<DotController, int, int>)CountCustomDots);
val.Emit(OpCodes.Stloc, numberOfDebuffAndDotLoc2);
}
else
{
ILFailMessage(3);
}
static int CountCustomDots(DotController dotController, int numberOfDebuffAndDotLoc)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)dotController))
{
for (int j = VanillaDotCount; j < VanillaDotCount + CustomDotCount; j++)
{
DotIndex val2 = (DotIndex)j;
if (dotController.HasDotActive(val2))
{
numberOfDebuffAndDotLoc++;
}
}
}
return numberOfDebuffAndDotLoc;
}
static void ILFailMessage(int index)
{
DotPlugin.Logger.LogError((object)$"Failed finding IL Instructions. Aborting FixDeathMark IL Hook {index}");
}
}
}
[BepInPlugin("com.bepis.r2api.dot", "R2API.Dot", "1.0.3")]
public sealed class DotPlugin : BaseUnityPlugin
{
internal static ManualLogSource Logger { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
}
private void OnDestroy()
{
DotAPI.UnsetHooks();
}
}
}
namespace R2API.AutoVersionGen
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal class AutoVersionAttribute : Attribute
{
}
}