Decompiled source of R2API CharacterBody v1.4.0

plugins/R2API.CharacterBody/R2API.CharacterBody.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
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.Logging;
using EntityStates;
using HarmonyLib;
using IL.RoR2;
using IL.RoR2.CameraModes;
using IL.RoR2.Skills;
using IL.RoR2.UI;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates;
using R2API.AutoVersionGen;
using R2API.Utils;
using Rewired;
using RoR2;
using RoR2.CameraModes;
using RoR2.ConVar;
using RoR2.Skills;
using RoR2.UI;
using RoR2BepInExPack.Utilities;
using UnityEngine;
using UnityEngine.UI;

[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.CharacterBody")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+b18ad407f6a7dd91f8942af84dbefd9ed003cade")]
[assembly: AssemblyProduct("R2API.CharacterBody")]
[assembly: AssemblyTitle("R2API.CharacterBody")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.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.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]
	[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]
	[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 CharacterBodyAPI
	{
		public delegate bool CanAlwaysSprint(CharacterBody characterBody);

		public enum ModdedBodyFlag
		{

		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__SprintIcon_FixedUpdate;

			public static hook_HandleMovements <1>__GenericCharacterMain_HandleMovements;

			public static Manipulator <2>__PlayerCharacterMasterController_PollButtonInput;

			public static Manipulator <3>__CameraModePlayerBasic_CollectLookInputInternal;

			public static Manipulator <4>__SkillDef_OnExecute;

			public static Manipulator <5>__SkillDef_OnFixedUpdate;

			public static Manipulator <6>__CameraModePlayerBasic_UpdateInternal;

			public static Manipulator <7>__CrosshairManager_UpdateCrosshair;

			public static Action<SprintIcon> <8>__SetSprintIconCustomSprintColor;

			public static Func<SprintIcon, bool> <9>__CheckCustomSprintIcon;

			public static Action<SprintIcon> <10>__SetSprintIconCustomSprintIcon;

			public static Func<SprintIcon, GameObject> <11>__GetCustomIconObject;

			public static Action<GameObject> <12>__NullcheckAndDeactivateCustomIconObject;
		}

		public const string PluginGUID = "com.bepis.r2api.character_body";

		public const string PluginName = "R2API.CharacterBody";

		private static List<CanAlwaysSprint> canAlwaysSprints = new List<CanAlwaysSprint>();

		private static bool _hooksEnabled = false;

		public const string PluginVersion = "1.4.0";

		public static ModdedBodyFlag AlwaysSprint { get; private set; }

		public static Color DefaultSprintColor => new Color(0.816f, 0.9655f, 1f, 1f);

		[Obsolete("All submodules are automatically loaded and this property is now unused")]
		public static bool Loaded => true;

		public static int ModdedBodyFlagCount { get; private set; }

		internal static void SetHooks()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			if (!_hooksEnabled)
			{
				_hooksEnabled = true;
				AlwaysSprint = ReserveBodyFlag();
				object obj = <>O.<0>__SprintIcon_FixedUpdate;
				if (obj == null)
				{
					Manipulator val = SprintIcon_FixedUpdate;
					<>O.<0>__SprintIcon_FixedUpdate = val;
					obj = (object)val;
				}
				SprintIcon.FixedUpdate += (Manipulator)obj;
				object obj2 = <>O.<1>__GenericCharacterMain_HandleMovements;
				if (obj2 == null)
				{
					hook_HandleMovements val2 = GenericCharacterMain_HandleMovements;
					<>O.<1>__GenericCharacterMain_HandleMovements = val2;
					obj2 = (object)val2;
				}
				GenericCharacterMain.HandleMovements += (hook_HandleMovements)obj2;
				object obj3 = <>O.<2>__PlayerCharacterMasterController_PollButtonInput;
				if (obj3 == null)
				{
					Manipulator val3 = PlayerCharacterMasterController_PollButtonInput;
					<>O.<2>__PlayerCharacterMasterController_PollButtonInput = val3;
					obj3 = (object)val3;
				}
				PlayerCharacterMasterController.PollButtonInput += (Manipulator)obj3;
				object obj4 = <>O.<3>__CameraModePlayerBasic_CollectLookInputInternal;
				if (obj4 == null)
				{
					Manipulator val4 = CameraModePlayerBasic_CollectLookInputInternal;
					<>O.<3>__CameraModePlayerBasic_CollectLookInputInternal = val4;
					obj4 = (object)val4;
				}
				CameraModePlayerBasic.CollectLookInputInternal += (Manipulator)obj4;
				object obj5 = <>O.<4>__SkillDef_OnExecute;
				if (obj5 == null)
				{
					Manipulator val5 = SkillDef_OnExecute;
					<>O.<4>__SkillDef_OnExecute = val5;
					obj5 = (object)val5;
				}
				SkillDef.OnExecute += (Manipulator)obj5;
				object obj6 = <>O.<5>__SkillDef_OnFixedUpdate;
				if (obj6 == null)
				{
					Manipulator val6 = SkillDef_OnFixedUpdate;
					<>O.<5>__SkillDef_OnFixedUpdate = val6;
					obj6 = (object)val6;
				}
				SkillDef.OnFixedUpdate += (Manipulator)obj6;
				object obj7 = <>O.<6>__CameraModePlayerBasic_UpdateInternal;
				if (obj7 == null)
				{
					Manipulator val7 = CameraModePlayerBasic_UpdateInternal;
					<>O.<6>__CameraModePlayerBasic_UpdateInternal = val7;
					obj7 = (object)val7;
				}
				CameraModePlayerBasic.UpdateInternal += (Manipulator)obj7;
				object obj8 = <>O.<7>__CrosshairManager_UpdateCrosshair;
				if (obj8 == null)
				{
					Manipulator val8 = CrosshairManager_UpdateCrosshair;
					<>O.<7>__CrosshairManager_UpdateCrosshair = val8;
					obj8 = (object)val8;
				}
				CrosshairManager.UpdateCrosshair += (Manipulator)obj8;
			}
		}

		internal static void UnsetHooks()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			if (_hooksEnabled)
			{
				_hooksEnabled = false;
				object obj = <>O.<0>__SprintIcon_FixedUpdate;
				if (obj == null)
				{
					Manipulator val = SprintIcon_FixedUpdate;
					<>O.<0>__SprintIcon_FixedUpdate = val;
					obj = (object)val;
				}
				SprintIcon.FixedUpdate -= (Manipulator)obj;
				object obj2 = <>O.<1>__GenericCharacterMain_HandleMovements;
				if (obj2 == null)
				{
					hook_HandleMovements val2 = GenericCharacterMain_HandleMovements;
					<>O.<1>__GenericCharacterMain_HandleMovements = val2;
					obj2 = (object)val2;
				}
				GenericCharacterMain.HandleMovements -= (hook_HandleMovements)obj2;
				object obj3 = <>O.<2>__PlayerCharacterMasterController_PollButtonInput;
				if (obj3 == null)
				{
					Manipulator val3 = PlayerCharacterMasterController_PollButtonInput;
					<>O.<2>__PlayerCharacterMasterController_PollButtonInput = val3;
					obj3 = (object)val3;
				}
				PlayerCharacterMasterController.PollButtonInput -= (Manipulator)obj3;
				object obj4 = <>O.<3>__CameraModePlayerBasic_CollectLookInputInternal;
				if (obj4 == null)
				{
					Manipulator val4 = CameraModePlayerBasic_CollectLookInputInternal;
					<>O.<3>__CameraModePlayerBasic_CollectLookInputInternal = val4;
					obj4 = (object)val4;
				}
				CameraModePlayerBasic.CollectLookInputInternal -= (Manipulator)obj4;
				object obj5 = <>O.<4>__SkillDef_OnExecute;
				if (obj5 == null)
				{
					Manipulator val5 = SkillDef_OnExecute;
					<>O.<4>__SkillDef_OnExecute = val5;
					obj5 = (object)val5;
				}
				SkillDef.OnExecute -= (Manipulator)obj5;
				object obj6 = <>O.<5>__SkillDef_OnFixedUpdate;
				if (obj6 == null)
				{
					Manipulator val6 = SkillDef_OnFixedUpdate;
					<>O.<5>__SkillDef_OnFixedUpdate = val6;
					obj6 = (object)val6;
				}
				SkillDef.OnFixedUpdate -= (Manipulator)obj6;
				object obj7 = <>O.<6>__CameraModePlayerBasic_UpdateInternal;
				if (obj7 == null)
				{
					Manipulator val7 = CameraModePlayerBasic_UpdateInternal;
					<>O.<6>__CameraModePlayerBasic_UpdateInternal = val7;
					obj7 = (object)val7;
				}
				CameraModePlayerBasic.UpdateInternal -= (Manipulator)obj7;
				object obj8 = <>O.<7>__CrosshairManager_UpdateCrosshair;
				if (obj8 == null)
				{
					Manipulator val8 = CrosshairManager_UpdateCrosshair;
					<>O.<7>__CrosshairManager_UpdateCrosshair = val8;
					obj8 = (object)val8;
				}
				CrosshairManager.UpdateCrosshair -= (Manipulator)obj8;
			}
		}

		private static void GenericCharacterMain_HandleMovements(orig_HandleMovements orig, GenericCharacterMain self)
		{
			if (self != null && Object.op_Implicit((Object)(object)((EntityState)self).characterBody) && ((EntityState)self).characterBody.GetAlwaysSprint())
			{
				self.sprintInputReceived = true;
			}
			orig.Invoke(self);
		}

		private static void SprintIcon_FixedUpdate(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction val2 = il.Instrs[il.Instrs.Count - 1];
			Instruction val3 = il.Instrs[0];
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Action<SprintIcon>>((Action<SprintIcon>)SetSprintIconCustomSprintColor);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<SprintIcon, bool>>((Func<SprintIcon, bool>)CheckCustomSprintIcon);
			val.Emit(OpCodes.Brfalse_S, val3);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Action<SprintIcon>>((Action<SprintIcon>)SetSprintIconCustomSprintIcon);
			val.Emit(OpCodes.Br, val2);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<SprintIcon>(x, "sprintIconObject"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameObject>(x, "SetActive")
			}))
			{
				_ = val.Next;
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<SprintIcon, GameObject>>((Func<SprintIcon, GameObject>)GetCustomIconObject);
				val.EmitDelegate<Action<GameObject>>((Action<GameObject>)NullcheckAndDeactivateCustomIconObject);
			}
			else
			{
				CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!"));
			}
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<SprintIcon>(x, "sprintIconObject"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<GameObject>(x, "SetActive")
			}))
			{
				_ = val.Next;
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<SprintIcon, GameObject>>((Func<SprintIcon, GameObject>)GetCustomIconObject);
				val.EmitDelegate<Action<GameObject>>((Action<GameObject>)NullcheckAndDeactivateCustomIconObject);
			}
			else
			{
				CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 2 failed!"));
			}
		}

		private static void PlayerCharacterMasterController_PollButtonInput(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 16),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 6)
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				Instruction next = val.Next;
				_ = val.Next.Next;
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<PlayerCharacterMasterController, bool>>((Func<PlayerCharacterMasterController, bool>)GetFlag);
				val.Emit(OpCodes.Brfalse_S, next);
				val.Emit(OpCodes.Pop);
				val.Emit(OpCodes.Ldloc, 13);
				val.Emit(OpCodes.Ldc_I4, 18);
				val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.Method(typeof(Player), "GetButton", new Type[1] { typeof(int) }, (Type[])null));
			}
			else
			{
				CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!"));
			}
			static bool GetFlag(PlayerCharacterMasterController playerCharacterMasterController)
			{
				return playerCharacterMasterController.body.GetAlwaysSprint();
			}
		}

		private static void CameraModePlayerBasic_CollectLookInputInternal(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel iLLabel = null;
			if (val.TryGotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld<CameraRigController>(x, "enableSprintSensitivitySlowdown"),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<BoolConVar>(x, "get_value"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref iLLabel)
			}))
			{
				val.Emit(OpCodes.Ldarg_2);
				val.Emit<CameraModeContext>(OpCodes.Ldflda, "targetInfo");
				val.Emit<TargetInfo>(OpCodes.Ldfld, "body");
				val.EmitDelegate<Func<CharacterBody, bool>>((Func<CharacterBody, bool>)((CharacterBody cb) => Object.op_Implicit((Object)(object)cb) && cb.GetAlwaysSprint()));
				val.Emit(OpCodes.Brtrue_S, (object)iLLabel);
			}
			else
			{
				CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!"));
			}
		}

		private static void SkillDef_OnExecute(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel iLLabel = null;
			if (val.TryGotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<SkillDef>(x, "cancelSprintingOnActivation"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref iLLabel)
			}))
			{
				val.Emit(OpCodes.Ldarg_1);
				val.EmitDelegate<Func<GenericSkill, bool>>((Func<GenericSkill, bool>)((GenericSkill cb) => cb.characterBody.GetAlwaysSprint()));
				val.Emit(OpCodes.Brtrue_S, (object)iLLabel);
			}
			else
			{
				CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!"));
			}
		}

		private static void SkillDef_OnFixedUpdate(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel iLLabel = null;
			if (val.TryGotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<GenericSkill>(x, "get_characterBody"),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_isSprinting"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref iLLabel)
			}))
			{
				val.Emit(OpCodes.Ldarg_1);
				val.EmitDelegate<Func<GenericSkill, bool>>((Func<GenericSkill, bool>)((GenericSkill cb) => Object.op_Implicit((Object)(object)cb) && Object.op_Implicit((Object)(object)cb.characterBody) && cb.characterBody.GetAlwaysSprint()));
				val.Emit(OpCodes.Brtrue_S, (object)iLLabel);
			}
			else
			{
				CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!"));
			}
		}

		private static void CameraModePlayerBasic_UpdateInternal(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel iLLabel = null;
			if (val.TryGotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 2),
				(Instruction x) => ILPatternMatchingExt.MatchLdflda<CameraModeContext>(x, "targetInfo"),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<TargetInfo>(x, "isSprinting"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref iLLabel)
			}))
			{
				val.Emit(OpCodes.Ldarg_2);
				val.EmitDelegate<<>F{00000001}<CameraModeContext, bool>>((<>F{00000001}<CameraModeContext, bool>)method);
				val.Emit(OpCodes.Brtrue_S, (object)iLLabel);
			}
			else
			{
				CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!"));
			}
			static bool method(ref CameraModeContext cameraModeContext)
			{
				if ((Object)(object)cameraModeContext.targetInfo.body != (Object)null)
				{
					return cameraModeContext.targetInfo.body.GetAlwaysSprint();
				}
				return true;
			}
		}

		private static void CrosshairManager_UpdateCrosshair(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0103: 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)
			ILCursor val = new ILCursor(il);
			ILLabel iLLabel = null;
			ILLabel iLLabel2 = null;
			if (val.TryGotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<CrosshairManager>(x, "cameraRigController"),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<CameraRigController>(x, "get_hasOverride"),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref iLLabel)
			}) && val.TryGotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_isSprinting"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref iLLabel2)
			}))
			{
				val.Emit(OpCodes.Ldarg_1);
				val.EmitDelegate<Func<CharacterBody, bool>>((Func<CharacterBody, bool>)((CharacterBody cb) => cb.GetAlwaysSprint()));
				val.Emit(OpCodes.Brtrue_S, (object)iLLabel);
			}
			else
			{
				CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!"));
			}
		}

		private static void NullcheckAndDeactivateCustomIconObject(GameObject gameObject)
		{
			if (gameObject != null)
			{
				gameObject.SetActive(false);
			}
		}

		private static bool CheckCustomSprintIcon(SprintIcon sprintIcon)
		{
			if (Object.op_Implicit((Object)(object)sprintIcon.body))
			{
				return Object.op_Implicit((Object)(object)sprintIcon.body.GetCustomSprintIcon());
			}
			return false;
		}

		private static void SetSprintIconCustomSprintColor(SprintIcon sprintIcon)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)sprintIcon) && Object.op_Implicit((Object)(object)sprintIcon.body))
			{
				Color? customSprintColor = sprintIcon.body.GetCustomSprintColor();
				Color? currentCustomSprintColor = sprintIcon.GetCurrentCustomSprintColor();
				Color? val = customSprintColor;
				if (currentCustomSprintColor.HasValue != val.HasValue || (currentCustomSprintColor.HasValue && currentCustomSprintColor.GetValueOrDefault() != val.GetValueOrDefault()))
				{
					SetGameObjectCustomSprintColor(sprintIcon.GetCustomIconObject(), customSprintColor.HasValue ? customSprintColor.Value : DefaultSprintColor);
					SetGameObjectCustomSprintColor(sprintIcon.descendIconObject, customSprintColor.HasValue ? customSprintColor.Value : DefaultSprintColor);
					SetGameObjectCustomSprintColor(sprintIcon.sprintIconObject, customSprintColor.HasValue ? customSprintColor.Value : DefaultSprintColor);
					sprintIcon.SetCurrentCustomSprintColor(customSprintColor);
				}
			}
		}

		private static void SetGameObjectCustomSprintColor(GameObject gameObject, Color color)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)gameObject))
			{
				((Graphic)gameObject.GetComponent<Image>()).color = color;
			}
		}

		private static void SetSprintIconCustomSprintIcon(SprintIcon sprintIcon)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			Sprite customSprintIcon = sprintIcon.body.GetCustomSprintIcon();
			GameObject val = sprintIcon.GetCustomIconObject();
			if (Object.op_Implicit((Object)(object)val))
			{
				if ((Object)(object)sprintIcon.GetCurrentCustomSprintIcon() != (Object)(object)customSprintIcon)
				{
					val.GetComponent<Image>().sprite = customSprintIcon;
					sprintIcon.SetCurrentCustomSprintIcon(customSprintIcon);
				}
			}
			else
			{
				Transform val2 = ((Component)sprintIcon).transform.Find("SprintIcon");
				if (Object.op_Implicit((Object)(object)val2))
				{
					val = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)sprintIcon).transform);
					val.transform.position = val2.position;
					val.transform.rotation = val2.rotation;
					val.transform.localScale = val2.localScale;
					sprintIcon.SetCustomIconObject(val);
					Image component = val.GetComponent<Image>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.sprite = customSprintIcon;
						sprintIcon.SetCurrentCustomSprintIcon(customSprintIcon);
					}
				}
			}
			if (val != null)
			{
				val.SetActive(true);
			}
			GameObject descendIconObject = sprintIcon.descendIconObject;
			if (descendIconObject != null)
			{
				descendIconObject.SetActive(false);
			}
			GameObject sprintIconObject = sprintIcon.sprintIconObject;
			if (sprintIconObject != null)
			{
				sprintIconObject.SetActive(false);
			}
		}

		public static ModdedBodyFlag ReserveBodyFlag()
		{
			SetHooks();
			if (ModdedBodyFlagCount >= 1152)
			{
				throw new IndexOutOfRangeException($"Reached the limit of {1152} ModdedBodyFlags. Please contact R2API developers to increase the limit");
			}
			ModdedBodyFlagCount++;
			return (ModdedBodyFlag)ModdedBodyFlagCount;
		}

		public static void AddModdedBodyFlag(this CharacterBody characterBody, ModdedBodyFlag moddedBodyFlag)
		{
			AddModdedBodyFlagInternal(characterBody, moddedBodyFlag);
		}

		public static bool RemoveModdedBodyFlag(this CharacterBody characterBody, ModdedBodyFlag moddedBodyFlag)
		{
			return RemoveModdedBodyFlagInternal(characterBody, moddedBodyFlag);
		}

		public static bool HasAnyModdedBodyFlag(this CharacterBody characterBody)
		{
			SetHooks();
			byte[] moddedBodyFlags = CharacterBodyInterop.GetModdedBodyFlags(characterBody);
			if (moddedBodyFlags != null)
			{
				return moddedBodyFlags.Length != 0;
			}
			return false;
		}

		public static bool HasModdedBodyFlag(this CharacterBody characterBody, ModdedBodyFlag moddedBodyFlag)
		{
			return HasModdedBodyFlagInternal(characterBody, moddedBodyFlag);
		}

		private static void AddModdedBodyFlagInternal(CharacterBody characterBody, ModdedBodyFlag moddedBodyFlag)
		{
			SetHooks();
			if (CheckRange(characterBody, moddedBodyFlag))
			{
				byte[] moddedBodyFlags = CharacterBodyInterop.GetModdedBodyFlags(characterBody);
				CompressedFlagArrayUtilities.AddImmutable(ref moddedBodyFlags, (int)(moddedBodyFlag - 1));
				CharacterBodyInterop.SetModdedBodyFlags(characterBody, moddedBodyFlags);
			}
		}

		private static bool RemoveModdedBodyFlagInternal(CharacterBody characterBody, ModdedBodyFlag moddedBodyFlag)
		{
			SetHooks();
			if (!CheckRange(characterBody, moddedBodyFlag))
			{
				return false;
			}
			byte[] moddedBodyFlags = CharacterBodyInterop.GetModdedBodyFlags(characterBody);
			bool result = CompressedFlagArrayUtilities.RemoveImmutable(ref moddedBodyFlags, (int)(moddedBodyFlag - 1));
			CharacterBodyInterop.SetModdedBodyFlags(characterBody, moddedBodyFlags);
			return result;
		}

		private static bool HasModdedBodyFlagInternal(CharacterBody characterBody, ModdedBodyFlag moddedBodyFlag)
		{
			SetHooks();
			if (!CheckRange(characterBody, moddedBodyFlag))
			{
				return false;
			}
			return CompressedFlagArrayUtilities.Has(CharacterBodyInterop.GetModdedBodyFlags(characterBody), (int)(moddedBodyFlag - 1));
		}

		private static bool CheckRange(CharacterBody characterBody, ModdedBodyFlag moddedBodyFlag)
		{
			if ((int)moddedBodyFlag > ModdedBodyFlagCount || moddedBodyFlag < (ModdedBodyFlag)1)
			{
				CharacterBodyPlugin.Logger.LogError((object)string.Format("Parameter '{0}' with value {1} is out of range of registered types (1-{2})\n{3}", "moddedBodyFlag", moddedBodyFlag, ModdedBodyFlagCount, new StackTrace(fNeedFileInfo: true)));
				return false;
			}
			return true;
		}

		public static Sprite GetCustomSprintIcon(this CharacterBody characterBody)
		{
			return CharacterBodyInterop.GetCustomSprintIcon(characterBody);
		}

		public static void SetCustomSprintIcon(this CharacterBody characterBody, Sprite sprite)
		{
			CharacterBodyInterop.SetCustomSprintIcon(characterBody, sprite);
		}

		public static Color? GetCustomSprintColor(this CharacterBody characterBody)
		{
			return CharacterBodyInterop.GetCustomSprintColor(characterBody);
		}

		public static void SetCustomSprintColor(this CharacterBody characterBody, Color? color)
		{
			CharacterBodyInterop.SetCustomSprintColor(characterBody, color);
		}

		public static bool GetAlwaysSprint(this CharacterBody characterBody)
		{
			SetHooks();
			if (characterBody.HasModdedBodyFlag(AlwaysSprint))
			{
				return true;
			}
			foreach (CanAlwaysSprint canAlwaysSprint in canAlwaysSprints)
			{
				if (canAlwaysSprint != null && canAlwaysSprint(characterBody))
				{
					return true;
				}
			}
			return false;
		}

		public static void AddAlwaysSprintCondition(CanAlwaysSprint canAlwaysSprint)
		{
			canAlwaysSprints.Add(canAlwaysSprint);
		}

		private static GameObject GetCustomIconObject(this SprintIcon sprintIcon)
		{
			return CharacterBodyInterop.GetCustomIconObject(sprintIcon);
		}

		private static void SetCustomIconObject(this SprintIcon sprintIcon, GameObject gameobject)
		{
			CharacterBodyInterop.SetCustomIconObject(sprintIcon, gameobject);
		}

		private static Sprite GetCurrentCustomSprintIcon(this SprintIcon sprintIcon)
		{
			return CharacterBodyInterop.GetCurrentCustomSprintIcon(sprintIcon);
		}

		private static void SetCurrentCustomSprintIcon(this SprintIcon sprintIcon, Sprite sprite)
		{
			CharacterBodyInterop.SetCurrentCustomSprintIcon(sprintIcon, sprite);
		}

		private static Color? GetCurrentCustomSprintColor(this SprintIcon sprintIcon)
		{
			return CharacterBodyInterop.GetCurrentCustomSprintColor(sprintIcon);
		}

		private static void SetCurrentCustomSprintColor(this SprintIcon sprintIcon, Color? color)
		{
			CharacterBodyInterop.SetCurrentCustomSprintColor(sprintIcon, color);
		}
	}
	[BepInPlugin("com.bepis.r2api.character_body", "R2API.CharacterBody", "1.4.0")]
	public sealed class CharacterBodyPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			CharacterBodyAPI.SetHooks();
			HealthBarAPI.SetHooks();
			FootstepAPI.SetHooks();
		}

		private void OnDestroy()
		{
			CharacterBodyAPI.UnsetHooks();
			HealthBarAPI.UnsetHooks();
			FootstepAPI.UnsetHooks();
		}
	}
	public static class FootstepAPI
	{
		public struct FootstepReport
		{
			public Transform childTransform;

			public int childIndex;

			public string childName;

			public FootstepHandler footstepHandler;

			public SurfaceDef surfaceDef;

			public RaycastHit raycastHit;

			public GameObject footstepEffect;
		}

		public delegate void Footstep(FootstepReport footstepReport);

		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__FootstepHandler_Footstep_string_GameObject;

			public static <>A{00000200}<Transform, int, string, RaycastHit, SurfaceDef, FootstepHandler, GameObject> <1>__HandleFootstep;
		}

		private static bool _hooksEnabled;

		public static event Footstep OnFootstep;

		internal static void SetHooks()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if (!_hooksEnabled)
			{
				_hooksEnabled = true;
				object obj = <>O.<0>__FootstepHandler_Footstep_string_GameObject;
				if (obj == null)
				{
					Manipulator val = FootstepHandler_Footstep_string_GameObject;
					<>O.<0>__FootstepHandler_Footstep_string_GameObject = val;
					obj = (object)val;
				}
				FootstepHandler.Footstep_string_GameObject += (Manipulator)obj;
			}
		}

		private static void FootstepHandler_Footstep_string_GameObject(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_014b: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int childTransformLocal = 0;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<ChildLocator>(x, "FindChild"),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref childTransformLocal)
			}))
			{
				int childIndexLocal = 0;
				if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<ChildLocator>(x, "FindChildIndex"),
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref childIndexLocal)
				}))
				{
					int raycastHitLocal = 0;
					if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref raycastHitLocal),
						(Instruction x) => ILPatternMatchingExt.MatchInitobj<RaycastHit>(x)
					}))
					{
						int surfaceDefLocal = 0;
						if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
						{
							(Instruction x) => ILPatternMatchingExt.MatchCall<SurfaceDefProvider>(x, "GetObjectSurfaceDef"),
							(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref surfaceDefLocal)
						}))
						{
							val.Emit(OpCodes.Ldloc, childTransformLocal);
							val.Emit(OpCodes.Ldloc, childIndexLocal);
							val.Emit(OpCodes.Ldarg_1);
							val.Emit(OpCodes.Ldloca, raycastHitLocal);
							val.Emit(OpCodes.Ldloc, surfaceDefLocal);
							val.Emit(OpCodes.Ldarg_0);
							val.Emit(OpCodes.Ldarg_2);
							val.EmitDelegate<<>A{00000200}<Transform, int, string, RaycastHit, SurfaceDef, FootstepHandler, GameObject>>((<>A{00000200}<Transform, int, string, RaycastHit, SurfaceDef, FootstepHandler, GameObject>)HandleFootstep);
						}
						else
						{
							CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 4 failed!"));
						}
					}
					else
					{
						CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 3 failed!"));
					}
				}
				else
				{
					CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 2 failed!"));
				}
			}
			else
			{
				CharacterBodyPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!"));
			}
		}

		private static void HandleFootstep(Transform transform, int index, string name, ref RaycastHit raycastHit, SurfaceDef surfaceDef, FootstepHandler footstepHandler, GameObject footstepEffect)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			FootstepReport footstepReport = new FootstepReport
			{
				childIndex = index,
				childName = name,
				childTransform = transform,
				raycastHit = raycastHit,
				footstepHandler = footstepHandler,
				surfaceDef = surfaceDef,
				footstepEffect = footstepEffect
			};
			FootstepAPI.OnFootstep?.Invoke(footstepReport);
		}

		internal static void UnsetHooks()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if (_hooksEnabled)
			{
				_hooksEnabled = false;
				object obj = <>O.<0>__FootstepHandler_Footstep_string_GameObject;
				if (obj == null)
				{
					Manipulator val = FootstepHandler_Footstep_string_GameObject;
					<>O.<0>__FootstepHandler_Footstep_string_GameObject = val;
					obj = (object)val;
				}
				FootstepHandler.Footstep_string_GameObject -= (Manipulator)obj;
			}
		}
	}
	public static class HealthBarAPI
	{
		internal delegate void HealthValuesRefPasser(HealthBar source, AssignedOverlaysData data, ref float current, ref float max);

		public class BarOverlayInfo
		{
			public delegate void ModifyBarInfoCallback(HealthBar source, ref BarInfo barInfo);

			public delegate void ModifyHealthValuesCallback(HealthBar source, ref float currentHealth, ref float maxHealth);

			public BarInfo BarInfo;

			public bool BodySpecific;

			public ModifyBarInfoCallback ModifyBarInfo;

			public ModifyHealthValuesCallback ModifyHealthValues;

			public BarOverlayIndex OverlayIndex;
		}

		public enum BarOverlayIndex
		{
			None = -1
		}

		internal class AssignedOverlaysData
		{
			internal bool[] AssignedOverlays = new bool[OverlayInfos.Count];

			internal void UpdateSize()
			{
				if (OverlayInfos.Count > AssignedOverlays.Length)
				{
					bool[] array = new bool[AssignedOverlays.Length + 32];
					for (int i = 0; i < AssignedOverlays.Length; i++)
					{
						array[i] = AssignedOverlays[i];
					}
					AssignedOverlays = array;
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__HandleBarInfos;

			public static Manipulator <1>__HandleBarValues;
		}

		private static bool _hooksEnabled;

		private static bool alreadyLoaded;

		private static bool valuesHookFailed;

		private static bool overlaysHookFailed;

		private static List<BarOverlayInfo> OverlayInfos = new List<BarOverlayInfo>();

		private static FixedConditionalWeakTable<HealthComponent, AssignedOverlaysData> HealthBarData = new FixedConditionalWeakTable<HealthComponent, AssignedOverlaysData>();

		private static MethodInfo get_source;

		private static MethodInfo get_combinedHealth;

		private static int lastClaimedBarIndex = 0;

		internal static void SetHooks(bool reset = false)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			if (!reset)
			{
				RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
				{
					alreadyLoaded = true;
					if (OverlayInfos.Count > 0)
					{
						EvaluateHooks();
					}
				});
				get_source = AccessTools.PropertyGetter(typeof(HealthBar), "source");
				get_combinedHealth = AccessTools.PropertyGetter(typeof(HealthComponent), "combinedHealth");
				return;
			}
			_hooksEnabled = true;
			if (!overlaysHookFailed)
			{
				object obj = <>O.<0>__HandleBarInfos;
				if (obj == null)
				{
					Manipulator val = HandleBarInfos;
					<>O.<0>__HandleBarInfos = val;
					obj = (object)val;
				}
				HealthBar.ApplyBars += (Manipulator)obj;
			}
			if (!valuesHookFailed)
			{
				object obj2 = <>O.<1>__HandleBarValues;
				if (obj2 == null)
				{
					Manipulator val2 = HandleBarValues;
					<>O.<1>__HandleBarValues = val2;
					obj2 = (object)val2;
				}
				HealthBar.UpdateHealthbar += (Manipulator)obj2;
			}
			if (valuesHookFailed)
			{
				object obj3 = <>O.<1>__HandleBarValues;
				if (obj3 == null)
				{
					Manipulator val3 = HandleBarValues;
					<>O.<1>__HandleBarValues = val3;
					obj3 = (object)val3;
				}
				HealthBar.UpdateHealthbar -= (Manipulator)obj3;
			}
			if (overlaysHookFailed)
			{
				object obj4 = <>O.<0>__HandleBarInfos;
				if (obj4 == null)
				{
					Manipulator val4 = HandleBarInfos;
					<>O.<0>__HandleBarInfos = val4;
					obj4 = (object)val4;
				}
				HealthBar.ApplyBars -= (Manipulator)obj4;
			}
		}

		internal static void UnsetHooks()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			_hooksEnabled = false;
			if (!overlaysHookFailed)
			{
				object obj = <>O.<0>__HandleBarInfos;
				if (obj == null)
				{
					Manipulator val = HandleBarInfos;
					<>O.<0>__HandleBarInfos = val;
					obj = (object)val;
				}
				HealthBar.ApplyBars -= (Manipulator)obj;
			}
			if (!valuesHookFailed)
			{
				object obj2 = <>O.<1>__HandleBarValues;
				if (obj2 == null)
				{
					Manipulator val2 = HandleBarValues;
					<>O.<1>__HandleBarValues = val2;
					obj2 = (object)val2;
				}
				HealthBar.UpdateHealthbar -= (Manipulator)obj2;
			}
		}

		internal static void EvaluateHooks()
		{
			if (_hooksEnabled)
			{
				UnsetHooks();
			}
			SetHooks(reset: true);
		}

		internal static void HandleBarValues(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			VariableDefinition val2 = new VariableDefinition(il.Import(typeof(float)));
			il.Method.Body.Variables.Add(val2);
			VariableDefinition val3 = new VariableDefinition(il.Import(typeof(AssignedOverlaysData)));
			il.Method.Body.Variables.Add(val3);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<HealthBar, AssignedOverlaysData>>((Func<HealthBar, AssignedOverlaysData>)((HealthBar source) => Object.op_Implicit((Object)(object)source.source) ? HealthBarData.GetOrCreateValue(source.source) : null));
			val.Emit(OpCodes.Stloc, val3);
			int fullHealthIndex = -1;
			val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "get_fullHealth"),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref fullHealthIndex)
			});
			if (fullHealthIndex < 0)
			{
				valuesHookFailed = true;
				return;
			}
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Call, (MethodBase)get_source);
			val.Emit(OpCodes.Call, (MethodBase)get_combinedHealth);
			val.Emit(OpCodes.Stloc, val2);
			foreach (BarOverlayInfo overlay in OverlayInfos)
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc, val3);
				val.Emit(OpCodes.Ldloca, val2);
				val.Emit(OpCodes.Ldloca, fullHealthIndex);
				val.EmitDelegate<HealthValuesRefPasser>((HealthValuesRefPasser)delegate(HealthBar source, AssignedOverlaysData data, ref float currentHealth, ref float maxHealth)
				{
					if (data != null && (!overlay.BodySpecific || data.AssignedOverlays[(int)overlay.OverlayIndex]))
					{
						overlay.ModifyHealthValues?.Invoke(source, ref currentHealth, ref maxHealth);
					}
				});
			}
			int index = val.Next.Offset;
			Assert(val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, fullHealthIndex) && x.Offset > index
			}));
			int num2 = default(int);
			Assert(val.TryGotoPrev((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num2) && x.Offset > index
			}));
			if (valuesHookFailed)
			{
				return;
			}
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldloc, val2);
			Assert(val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)get_combinedHealth),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<HealthBar>(x, "oldHealth")
			}));
			if (valuesHookFailed)
			{
				return;
			}
			int index2 = val.Index;
			val.Index = index2 + 1;
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldloc, val2);
			for (int num = 0; num < 2; num++)
			{
				Assert(val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)get_combinedHealth)
				}));
				if (valuesHookFailed)
				{
					break;
				}
				val.Emit(OpCodes.Pop);
				val.Emit(OpCodes.Ldloc, val2);
			}
			static void Assert(bool flag)
			{
				if (!flag)
				{
					valuesHookFailed = true;
					CharacterBodyPlugin.Logger.LogError((object)"Failed to apply HandleBarValues hook.");
				}
			}
		}

		internal static void HandleBarInfos(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MethodReference handleBar = null;
			VariableDefinition val2 = null;
			int allocatorIndex = -1;
			bool flag = val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref handleBar) && handleBar != null && ((MemberReference)handleBar).Name.StartsWith("<ApplyBars>g__HandleBar|")
			});
			bool flag2 = val.TryGotoPrev(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref allocatorIndex)
			});
			if (!flag || !flag2 || allocatorIndex < 0 || allocatorIndex >= il.Method.Body.Variables.Count)
			{
				overlaysHookFailed = true;
				CharacterBodyPlugin.Logger.LogError((object)"Failed to apply IL hook for ApplyBars.");
				return;
			}
			val2 = il.Method.Body.Variables[allocatorIndex];
			TypeReference val3 = il.Import(typeof(BarInfo));
			val.Index = 0;
			VariableDefinition val4 = new VariableDefinition(il.Import(typeof(AssignedOverlaysData)));
			il.Method.Body.Variables.Add(val4);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<HealthBar, AssignedOverlaysData>>((Func<HealthBar, AssignedOverlaysData>)((HealthBar source) => Object.op_Implicit((Object)(object)source.source) ? HealthBarData.GetOrCreateValue(source.source) : null));
			val.Emit(OpCodes.Stloc, val4);
			int index = val.Index;
			foreach (BarOverlayInfo overlay in OverlayInfos)
			{
				val.Index = index;
				VariableDefinition val5 = new VariableDefinition(val3);
				il.Method.Body.Variables.Add(val5);
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc, val4);
				val.EmitDelegate<Func<HealthBar, AssignedOverlaysData, BarInfo>>((Func<HealthBar, AssignedOverlaysData, BarInfo>)delegate(HealthBar source, AssignedOverlaysData data)
				{
					//IL_0002: 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)
					//IL_0031: Unknown result type (might be due to invalid IL or missing references)
					//IL_005a: Unknown result type (might be due to invalid IL or missing references)
					//IL_005f: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
					BarInfo barInfo = new BarInfo
					{
						enabled = overlay.BarInfo.enabled,
						color = overlay.BarInfo.color,
						sprite = overlay.BarInfo.sprite,
						imageType = overlay.BarInfo.imageType,
						sizeDelta = overlay.BarInfo.sizeDelta,
						normalizedXMax = overlay.BarInfo.normalizedXMax,
						normalizedXMin = overlay.BarInfo.normalizedXMin
					};
					if (data == null || (overlay.BodySpecific && !data.AssignedOverlays[(int)overlay.OverlayIndex]))
					{
						barInfo.enabled = false;
						return barInfo;
					}
					overlay.ModifyBarInfo?.Invoke(source, ref barInfo);
					return barInfo;
				});
				val.Emit(OpCodes.Stloc, val5);
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<BarInfoCollection>(x, "GetActiveCount")
				}))
				{
					overlaysHookFailed = true;
					CharacterBodyPlugin.Logger.LogError((object)"Failed to find GetActiveCount in ApplyBars.");
					break;
				}
				val.Emit(OpCodes.Ldloca, val5);
				val.EmitDelegate<<>F{00000018}<int, BarInfo, int>>((<>F{00000018}<int, BarInfo, int>)delegate(int count, in BarInfo barInfo)
				{
					if (barInfo.enabled)
					{
						count++;
					}
					return count;
				});
				val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchRet(x)
				});
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloca, val5);
				val.Emit(OpCodes.Ldloca, val2);
				val.Emit(OpCodes.Call, handleBar);
			}
		}

		public static BarOverlayIndex RegisterBarOverlay(BarOverlayInfo overlayInfo)
		{
			if (alreadyLoaded)
			{
				CharacterBodyPlugin.Logger.LogError((object)"Mod attempted to add a BarOverlayInfo after game load. This is not allowed.");
				return BarOverlayIndex.None;
			}
			overlayInfo.OverlayIndex = (BarOverlayIndex)lastClaimedBarIndex;
			lastClaimedBarIndex++;
			OverlayInfos.Add(overlayInfo);
			foreach (KeyValuePair<HealthComponent, AssignedOverlaysData> healthBarDatum in HealthBarData)
			{
				healthBarDatum.Value.UpdateSize();
			}
			return overlayInfo.OverlayIndex;
		}

		public static void AddOverlayToBody(CharacterBody body, BarOverlayIndex index)
		{
			if (index >= (BarOverlayIndex)0)
			{
				AssignedOverlaysData orCreateValue = HealthBarData.GetOrCreateValue(body.healthComponent);
				if (orCreateValue.AssignedOverlays.Length >= (int)index)
				{
					orCreateValue.AssignedOverlays[(int)index] = true;
				}
			}
		}

		public static void RemoveOverlayFromBody(CharacterBody body, BarOverlayIndex index)
		{
			if (index >= (BarOverlayIndex)0)
			{
				AssignedOverlaysData orCreateValue = HealthBarData.GetOrCreateValue(body.healthComponent);
				if (orCreateValue.AssignedOverlays.Length >= (int)index)
				{
					orCreateValue.AssignedOverlays[(int)index] = false;
				}
			}
		}
	}
}
namespace R2API.AutoVersionGen
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	internal class AutoVersionAttribute : Attribute
	{
	}
}

plugins/R2API.CharacterBody/R2API.CharacterBody.Interop.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("R2API.CharacterBody")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("R2API.CharacterBody.Interop")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b18ad407f6a7dd91f8942af84dbefd9ed003cade")]
[assembly: AssemblyProduct("R2API.CharacterBody.Interop")]
[assembly: AssemblyTitle("R2API.CharacterBody.Interop")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.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]
	[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]
	[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 R2API
{
	internal static class CharacterBodyInterop
	{
		public static byte[] GetModdedBodyFlags(CharacterBody characterBody)
		{
			return characterBody.r2api_moddedBodyFlags;
		}

		public static void SetModdedBodyFlags(CharacterBody characterBody, byte[] value)
		{
			characterBody.r2api_moddedBodyFlags = value;
		}

		public static Sprite GetCustomSprintIcon(CharacterBody characterBody)
		{
			return characterBody.r2api_customSprintIcon;
		}

		public static void SetCustomSprintIcon(CharacterBody characterBody, Sprite value)
		{
			characterBody.r2api_customSprintIcon = value;
		}

		public static Color? GetCustomSprintColor(CharacterBody characterBody)
		{
			return characterBody.r2api_customSprintColor;
		}

		public static void SetCustomSprintColor(CharacterBody characterBody, Color? value)
		{
			characterBody.r2api_customSprintColor = value;
		}

		public static GameObject GetCustomIconObject(SprintIcon sprintIcon)
		{
			return sprintIcon.r2api_customIconObject;
		}

		public static void SetCustomIconObject(SprintIcon sprintIcon, GameObject value)
		{
			sprintIcon.r2api_customIconObject = value;
		}

		public static Sprite GetCurrentCustomSprintIcon(SprintIcon sprintIcon)
		{
			return sprintIcon.r2api_currentCustomSprintIcon;
		}

		public static void SetCurrentCustomSprintIcon(SprintIcon sprintIcon, Sprite value)
		{
			sprintIcon.r2api_currentCustomSprintIcon = value;
		}

		public static Color? GetCurrentCustomSprintColor(SprintIcon sprintIcon)
		{
			return sprintIcon.r2api_currentCustomSprintColor;
		}

		public static void SetCurrentCustomSprintColor(SprintIcon sprintIcon, Color? value)
		{
			sprintIcon.r2api_currentCustomSprintColor = value;
		}
	}
}

patchers/R2API.CharacterBody/R2API.CharacterBody.Patcher.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
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: AssemblyCompany("R2API.CharacterBody.Patcher")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b18ad407f6a7dd91f8942af84dbefd9ed003cade")]
[assembly: AssemblyProduct("R2API.CharacterBody.Patcher")]
[assembly: AssemblyTitle("R2API.CharacterBody.Patcher")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.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]
	[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]
	[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 R2API
{
	internal static class CharacterBodyPatcher
	{
		public static IEnumerable<string> TargetDLLs
		{
			get
			{
				yield return "RoR2.dll";
			}
		}

		public static void Patch(AssemblyDefinition assembly)
		{
			PatchCharacterBody(assembly);
			PatchSprintIcon(assembly);
		}

		private static void PatchSprintIcon(AssemblyDefinition assembly)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			TypeDefinition type = assembly.MainModule.GetType("RoR2.UI.SprintIcon");
			if (type != null)
			{
				type.Fields.Add(new FieldDefinition("r2api_customIconObject", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(GameObject))));
				type.Fields.Add(new FieldDefinition("r2api_currentCustomSprintIcon", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(Sprite))));
				type.Fields.Add(new FieldDefinition("r2api_currentCustomSprintColor", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(Color?))));
			}
		}

		private static void PatchCharacterBody(AssemblyDefinition assembly)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			TypeDefinition type = assembly.MainModule.GetType("RoR2", "CharacterBody");
			if (type != null)
			{
				type.Fields.Add(new FieldDefinition("r2api_moddedBodyFlags", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(byte[]))));
				type.Fields.Add(new FieldDefinition("r2api_customSprintIcon", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(Sprite))));
				type.Fields.Add(new FieldDefinition("r2api_customSprintColor", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(Color?))));
			}
		}
	}
}