Decompiled source of ActiveCombat v0.5.0

ActiveCombat.dll

Decompiled 18 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using ActiveCombat.Actions;
using ActiveCombat.Adrenaline;
using ActiveCombat.Core;
using ActiveCombat.DualWield;
using ActiveCombat.Falling;
using ActiveCombat.Food;
using ActiveCombat.Magic;
using ActiveCombat.Movement;
using ActiveCombat.Movesets;
using ActiveCombat.Progression;
using ActiveCombat.Regen;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("ActiveCombat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("More active combat that stays just as dangerous: attacks that change with how you move, dual wielding with power stances, stamina that keeps flowing, and skills that grow the harder you fight.")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0+fa023677c3acf5025a53315d2627ba0fe4d835fa")]
[assembly: AssemblyProduct("ActiveCombat")]
[assembly: AssemblyTitle("ActiveCombat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.5.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ActiveCombat
{
	[BepInPlugin("javidahmed64592.activecombat", "Active Combat", "0.5.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class ActiveCombatPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "javidahmed64592.activecombat";

		public const string PluginName = "Active Combat";

		public const string PluginVersion = "0.5.0";

		private Harmony _harmony;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			CombatConfig.Bind(((BaseUnityPlugin)this).Config);
			ActiveCombat.Movesets.Movesets.BindConfig(((BaseUnityPlugin)this).Config);
			Stances.BindConfig(((BaseUnityPlugin)this).Config);
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TestKitCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ReloadConfigCommand(((BaseUnityPlugin)this).Config));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new PlayAnimationCommand());
			Translations.Load();
			_harmony = new Harmony("javidahmed64592.activecombat");
			SafePatcher.PatchAll(_harmony, ((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger);
			if (SafePatcher.IsOn("Sliding past creatures"))
			{
				CharacterContacts.Subscribe();
			}
			WeightClasses.Subscribe();
		}

		private void OnDestroy()
		{
			CharacterContacts.Unsubscribe();
			WeightClasses.Unsubscribe();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace ActiveCombat.Regen
{
	internal static class ActionRegen
	{
		public static bool StaminaRegenBlocked(Player player)
		{
			if ((!((Character)player).IsSwimming() || ((Character)player).IsOnGround()) && !((Character)player).m_wallRunning)
			{
				return ((Character)player).IsEncumbered();
			}
			return true;
		}

		public static void Apply(Player player, float dt)
		{
			if (CombatConfig.StaminaRegenWhileActing.Value <= 0f || ((Character)player).InIntro() || ((Character)player).IsTeleporting() || (!((Character)player).InAttack() && !((Character)player).InDodge()) || StaminaRegenBlocked(player) || player.m_staminaRegenTimer > 0f)
			{
				return;
			}
			float num = Share(player);
			if (num <= 0f)
			{
				return;
			}
			float maxStamina = ((Character)player).GetMaxStamina();
			if (!(maxStamina <= 0f) && !(player.m_stamina >= maxStamina))
			{
				float num2 = player.m_staminaRegen + (1f - player.m_stamina / maxStamina) * player.m_staminaRegen * player.m_staminaRegenTimeMultiplier;
				if (((Character)player).IsBlocking())
				{
					num2 *= 0.8f;
				}
				float num3 = 1f;
				((Character)player).m_seman.ModifyStaminaRegen(ref num3);
				player.m_stamina = Mathf.Min(maxStamina, player.m_stamina + num2 * num3 * num * dt * Game.m_staminaRegenRate);
				((Character)player).m_nview.GetZDO().Set(ZDOVars.s_stamina, player.m_stamina);
			}
		}

		private static float Share(Player player)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			float num;
			if (((Character)player).InDodge())
			{
				num = ((Character)player).GetSkillFactor((SkillType)108);
			}
			else
			{
				ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon();
				num = ((currentWeapon != null) ? ((Character)player).GetSkillFactor(currentWeapon.m_shared.m_skillType) : 0f);
			}
			return CombatConfig.StaminaRegenWhileActing.Value * num;
		}
	}
	internal static class SkillRegen
	{
		public const string Feature = "Skill regen bonus";

		private static readonly SkillType[] AgilitySkills;

		public static float StaminaBonus(Player player)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			SkillType[] agilitySkills = AgilitySkills;
			foreach (SkillType val in agilitySkills)
			{
				num += ((Character)player).GetSkillFactor(val);
			}
			return CombatConfig.AgilityRegenBonus.Value * num / (float)AgilitySkills.Length;
		}

		public static float EitrBonus(Player player)
		{
			float num = Mathf.Max(((Character)player).GetSkillFactor((SkillType)9), ((Character)player).GetSkillFactor((SkillType)10));
			return CombatConfig.MagicRegenBonus.Value * num;
		}

		public static float Combine(float effectsMultiplier, float skillBonus)
		{
			if (effectsMultiplier < 1f)
			{
				return effectsMultiplier * (1f + skillBonus);
			}
			float num = effectsMultiplier - 1f;
			return 1f + Mathf.Max(num, skillBonus) + CombatConfig.SkillStackShare.Value * Mathf.Min(num, skillBonus);
		}

		static SkillRegen()
		{
			SkillType[] array = new SkillType[5];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			AgilitySkills = (SkillType[])(object)array;
		}
	}
	internal static class StaminaTiming
	{
		public static float RegenDelay(Player player)
		{
			return player.m_staminaRegenDelay * CombatConfig.StaminaRegenDelayMultiplier.Value;
		}
	}
}
namespace ActiveCombat.Progression
{
	internal static class CombatSkills
	{
		public static bool Contains(SkillType skill)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			if ((int)skill <= 14)
			{
				if (skill - 1 <= 10 || (int)skill == 14)
				{
					goto IL_001f;
				}
			}
			else if (skill - 100 <= 3 || (int)skill == 108)
			{
				goto IL_001f;
			}
			return false;
			IL_001f:
			return true;
		}
	}
	internal static class DeathPenalty
	{
		public const string Feature = "Death penalty";

		private const float HardestRate = 1.5f;

		public static void LowerAllSkills(Skills skills, float factor)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			float num = ProgressLoss(skills, factor);
			foreach (KeyValuePair<SkillType, Skill> skillDatum in skills.m_skillData)
			{
				Skill value = skillDatum.Value;
				if (CombatSkills.Contains(skillDatum.Key))
				{
					float num2 = num * value.GetNextLevelRequirement();
					value.m_accumulator = Mathf.Max(0f, value.m_accumulator - num2);
				}
				else
				{
					value.m_level -= value.m_level * factor;
					value.m_accumulator = 0f;
				}
			}
		}

		private static float ProgressLoss(Skills skills, float factor)
		{
			if (skills.m_DeathLowerFactor <= 0f)
			{
				return 0f;
			}
			float num = factor / skills.m_DeathLowerFactor;
			return Mathf.Clamp01(CombatConfig.DeathProgressLoss.Value * num / 1.5f);
		}
	}
	internal static class DodgeXp
	{
		public const string Feature = "Dodge experience";

		private const float VanillaDodgeRaise = 0.1f;

		private const float CombatRange = 15f;

		public static void OnDodgeStarted(Player player)
		{
			float num = (NearAlertedEnemy(player) ? CombatConfig.DodgeCombatXp.Value : 1f);
			((Character)player).GetSkills().RaiseSkill((SkillType)108, 0.1f * num);
		}

		public static void RaisePerfect(Skills skills, SkillType skill, float value)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			skills.RaiseSkill(skill, value * CombatConfig.PerfectDodgeXp.Value);
		}

		private static bool NearAlertedEnemy(Player player)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//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_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)
			Vector3 position = ((Component)player).transform.position;
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if ((Object)(object)allCharacter == (Object)(object)player || allCharacter.IsDead())
				{
					continue;
				}
				Vector3 val = ((Component)allCharacter).transform.position - position;
				if (!(((Vector3)(ref val)).sqrMagnitude > 225f))
				{
					BaseAI baseAI = allCharacter.GetBaseAI();
					if ((Object)(object)baseAI != (Object)null && baseAI.IsAlerted() && BaseAI.IsEnemy((Character)(object)player, allCharacter))
					{
						return true;
					}
				}
			}
			return false;
		}
	}
	internal static class LevelCurve
	{
		public const string Feature = "Level curve";

		public static bool TryGetRequirement(Skill skill, out float requirement)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			requirement = 0f;
			if (skill?.m_info == null || !CombatSkills.Contains(skill.m_info.m_skill))
			{
				return false;
			}
			float num = Mathf.Floor(skill.m_level + 1f);
			requirement = Mathf.Pow(num, CombatConfig.LevelCurveExponent.Value) * CombatConfig.LevelCurveScale.Value + 0.5f;
			return true;
		}
	}
	internal static class SkillXp
	{
		private struct Hit
		{
			public Character Attacker;

			public SkillType Skill;

			public float Weight;

			public int Frame;
		}

		public const string Feature = "Damage-based experience";

		private const float MinDamageFactor = 0.5f;

		private const float MaxDamageFactor = 3f;

		private static readonly List<Hit> Pending = new List<Hit>();

		private static readonly List<float> Weights = new List<float>();

		private static float _blockFactor = 1f;

		private static bool _blocking;

		public static void OnHit(Character target, HitData hit)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			Character attacker = hit.GetAttacker();
			if (!((Object)(object)attacker == (Object)null) && !((Object)(object)attacker == (Object)(object)target) && EarnsForLocalPlayer(attacker))
			{
				float damage = Mathf.Min(HitDamage.LandedDamage(target, hit), target.GetHealth());
				Pending.Add(new Hit
				{
					Attacker = attacker,
					Skill = hit.m_skill,
					Weight = DamageFactor(damage) * Toughness(target),
					Frame = Time.frameCount
				});
			}
		}

		public static void Raise(Character character, SkillType skill, float value)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			character.RaiseSkill(skill, value * TakeWeight(character, skill));
		}

		public static void BeginBlock(Character blocker, HitData hit, Character attacker)
		{
			_blocking = (Object)(object)blocker == (Object)(object)Player.m_localPlayer;
			_blockFactor = (_blocking ? (DamageFactor(hit.GetTotalBlockableDamage()) * Toughness(attacker)) : 1f);
		}

		public static void EndBlock()
		{
			_blocking = false;
			_blockFactor = 1f;
		}

		public static void RaiseBlock(Character character, SkillType skill, float value)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			character.RaiseSkill(skill, _blocking ? (value * _blockFactor) : value);
		}

		private static bool EarnsForLocalPlayer(Character attacker)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Invalid comparison between Unknown and I4
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return false;
			}
			if ((Object)(object)attacker == (Object)(object)localPlayer)
			{
				return true;
			}
			if (attacker.IsTamed())
			{
				BaseAI baseAI = attacker.GetBaseAI();
				MonsterAI val = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null);
				if (val != null && !((Object)(object)val.GetFollowTarget() != (Object)(object)((Component)localPlayer).gameObject))
				{
					Tameable component = ((Component)attacker).GetComponent<Tameable>();
					if ((Object)(object)component != (Object)null)
					{
						return (int)component.m_levelUpOwnerSkill > 0;
					}
					return false;
				}
			}
			return false;
		}

		private static float TakeWeight(Character character, SkillType skill)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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)
			int frameCount = Time.frameCount;
			Weights.Clear();
			for (int num = Pending.Count - 1; num >= 0; num--)
			{
				Hit hit = Pending[num];
				if (hit.Frame != frameCount)
				{
					Pending.RemoveAt(num);
				}
				else if ((Object)(object)hit.Attacker == (Object)(object)character && hit.Skill == skill)
				{
					Weights.Add(hit.Weight);
					Pending.RemoveAt(num);
				}
			}
			bool flag = !(character is Player) || CombatSkills.Contains(skill);
			if (Weights.Count == 0 || !flag)
			{
				return 1f;
			}
			Weights.Sort();
			float value = CombatConfig.XpExtraTargetShare.Value;
			float num2 = Weights[Weights.Count - 1];
			for (int i = 0; i < Weights.Count - 1; i++)
			{
				num2 += Weights[i] * value;
			}
			return num2;
		}

		private static float DamageFactor(float damage)
		{
			float value = CombatConfig.XpDamageScaling.Value;
			float value2 = CombatConfig.XpDamageReference.Value;
			if (value <= 0f || value2 <= 0f)
			{
				return 1f;
			}
			return Mathf.Clamp((damage > 0f) ? Mathf.Pow(damage / value2, value) : 0f, 0.5f, 3f);
		}

		private static float Toughness(Character character)
		{
			if ((Object)(object)character == (Object)null)
			{
				return 1f;
			}
			float num = 1f + CombatConfig.XpStarBonus.Value * (float)Mathf.Max(0, character.GetLevel() - 1);
			if (character.IsBoss())
			{
				num *= CombatConfig.XpBossMultiplier.Value;
			}
			return num;
		}
	}
}
namespace ActiveCombat.Patches
{
	internal static class HitAdrenaline
	{
		private static readonly MethodInfo Replacement = AccessTools.Method(typeof(AdrenalineFlow), "AddHitAdrenaline", (Type[])null, (Type[])null);

		public static IEnumerable<CodeInstruction> Patch(IEnumerable<CodeInstruction> instructions, string patchName)
		{
			return Transpile.ReplaceCall(instructions, "AddAdrenaline", Replacement, patchName);
		}
	}
	[HarmonyPatch(typeof(Attack), "DoMeleeAttack")]
	[Feature("Adrenaline")]
	internal static class Attack_DoMeleeAttack_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return HitAdrenaline.Patch(instructions, "Attack_DoMeleeAttack_Patch");
		}
	}
	[HarmonyPatch(typeof(Attack), "DoAreaAttack")]
	[Feature("Adrenaline")]
	internal static class Attack_DoAreaAttack_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return HitAdrenaline.Patch(instructions, "Attack_DoAreaAttack_Patch");
		}
	}
	[HarmonyPatch(typeof(Projectile), "OnHit")]
	[Feature("Adrenaline")]
	internal static class Projectile_OnHit_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return HitAdrenaline.Patch(instructions, "Projectile_OnHit_Patch");
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	[Feature("Adrenaline")]
	internal static class Character_Damage_Patch
	{
		private static void Prefix(Character __instance, HitData hit)
		{
			if (hit != null)
			{
				HitDamage.OnHit(__instance, hit);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "AddAdrenaline")]
	[Feature("Adrenaline")]
	internal static class Player_AddAdrenaline_Patch
	{
		private static void Prefix(Player __instance, out float __state)
		{
			__state = __instance.m_adrenaline;
		}

		private static void Postfix(Player __instance, float v, float __state)
		{
			AdrenalineFlow.AfterAdd(__instance, v, __state);
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateStats", new Type[] { typeof(float) })]
	[Feature("Adrenaline")]
	internal static class Player_UpdateStats_Patch
	{
		private static readonly FieldInfo DegenCurve = AccessTools.Field(typeof(Player), "m_adrenalineDegen");

		private static readonly MethodInfo Evaluate = AccessTools.Method(typeof(AnimationCurve), "Evaluate", (Type[])null, (Type[])null);

		private static readonly MethodInfo Scale = AccessTools.Method(typeof(AdrenalineFlow), "ScaleDecay", (Type[])null, (Type[])null);

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			bool afterCurve = false;
			int count = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				yield return instruction;
				if (CodeInstructionExtensions.LoadsField(instruction, DegenCurve, false))
				{
					afterCurve = true;
				}
				else if (afterCurve && CodeInstructionExtensions.Calls(instruction, Evaluate))
				{
					yield return new CodeInstruction(OpCodes.Call, (object)Scale);
					afterCurve = false;
					count++;
				}
			}
			if (count == 0)
			{
				throw new InvalidOperationException("Player_UpdateStats_Patch found nothing to patch");
			}
		}
	}
	[HarmonyPatch(typeof(Attack), "GetAttackHealth")]
	[Feature("Blood magic cost")]
	internal static class Attack_GetAttackHealth_Patch
	{
		private static void Postfix(Attack __instance, ref float __result)
		{
			if (__result > 0f && __instance.m_character is Player)
			{
				__result = BloodMagicCost.Scale(__result);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "ApplyDamage")]
	[Feature("Mana shield")]
	internal static class Character_ApplyDamage_Patch
	{
		public const string Feature = "Mana shield";

		private static void Prefix(Character __instance, HitData hit)
		{
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (val != null && (Object)(object)val == (Object)(object)Player.m_localPlayer && hit != null)
			{
				ManaShield.Absorb(val, hit);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "Awake")]
	[Feature("Sliding past creatures")]
	internal static class Character_Awake_ContactsPatch
	{
		private static void Postfix(Character __instance)
		{
			CharacterContacts.Register(__instance);
		}
	}
	[HarmonyPatch(typeof(Character), "OnDestroy")]
	[Feature("Sliding past creatures")]
	internal static class Character_OnDestroy_ContactsPatch
	{
		private static void Postfix(Character __instance)
		{
			CharacterContacts.Unregister(__instance);
		}
	}
	[HarmonyPatch(typeof(Player), "SetLocalPlayer")]
	[Feature("Sliding past creatures")]
	internal static class Player_SetLocalPlayer_ContactsPatch
	{
		private static void Postfix(Player __instance)
		{
			CharacterContacts.SetLocalPlayer(__instance);
		}
	}
	[HarmonyPatch(typeof(Character), "UpdateGroundContact")]
	[Feature("Falling")]
	internal static class Character_UpdateGroundContact_Patch
	{
		public const string Feature = "Falling";

		private static void Prefix(Character __instance)
		{
			FallHeight.Update(__instance);
		}
	}
	[HarmonyPatch(typeof(Humanoid), "StartAttack")]
	[Feature("Attack out of a roll")]
	internal static class Humanoid_StartAttack_RollPatch
	{
		private static readonly MethodInfo Replacement = AccessTools.Method(typeof(DodgeRoll), "BlocksAttack", (Type[])null, (Type[])null);

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return Transpile.ReplaceCall(instructions, "InDodge", Replacement, "Humanoid_StartAttack_RollPatch");
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateDodge")]
	[Feature("Roll waits for a started attack")]
	internal static class Player_UpdateDodge_StartedAttackPatch
	{
		private static readonly MethodInfo Replacement = AccessTools.Method(typeof(DodgeRoll), "BlocksRoll", (Type[])null, (Type[])null);

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return Transpile.ReplaceCall(instructions, "InAttack", Replacement, "Player_UpdateDodge_StartedAttackPatch");
		}
	}
	[HarmonyPatch(typeof(Player), "Dodge")]
	[Feature("Dodge experience")]
	internal static class Player_Dodge_XpPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return Transpile.RemoveCall(instructions, "RaiseSkill", 3, "Player_Dodge_XpPatch");
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateDodge")]
	[Feature("Dodge experience")]
	internal static class Player_UpdateDodge_XpPatch
	{
		private static void Prefix(Player __instance, float dt, out bool __state)
		{
			__state = __instance.m_queuedDodgeTimer > dt;
		}

		private static void Postfix(Player __instance, bool __state)
		{
			if (__state && __instance.m_queuedDodgeTimer == 0f && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				DodgeXp.OnDodgeStarted(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "RPC_HitWhileDodging")]
	[Feature("Dodge experience")]
	internal static class Player_RPC_HitWhileDodging_XpPatch
	{
		private static readonly MethodInfo Replacement = AccessTools.Method(typeof(DodgeXp), "RaisePerfect", (Type[])null, (Type[])null);

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return Transpile.ReplaceCall(instructions, "RaiseSkill", Replacement, "Player_RPC_HitWhileDodging_XpPatch");
		}
	}
	[HarmonyPatch(typeof(Player), "ToggleEquipped")]
	[Feature("Dual wield")]
	internal static class Player_ToggleEquipped_DualWieldPatch
	{
		private static void Prefix(Player __instance, ItemData item)
		{
			OffHand.BeforeToggle(__instance, item);
		}
	}
	[HarmonyPatch(typeof(Humanoid), "EquipItem")]
	[Feature("Dual wield")]
	internal static class Humanoid_EquipItem_DualWieldPatch
	{
		private static bool Prefix(Humanoid __instance, ItemData item, bool triggerEquipEffects, ref bool __result, out ItemData __state)
		{
			__state = null;
			if (OffHand.TryEquipLeft(__instance, item, triggerEquipEffects, out var result))
			{
				__result = result;
				return false;
			}
			__state = OffHand.SetAsideOffHand(__instance, item);
			return true;
		}

		private static void Postfix(Humanoid __instance, ItemData __state)
		{
			OffHand.AfterEquip(__instance, __state);
		}
	}
	[HarmonyPatch(typeof(VisEquipment), "AttachBackItem")]
	[Feature("Dual wield")]
	internal static class VisEquipment_AttachBackItem_DualWieldPatch
	{
		private static bool Prefix(VisEquipment __instance, int hash, int variant, bool rightHand, int quality, ref GameObject __result)
		{
			if (rightHand || (Object)(object)ObjectDB.instance == (Object)null)
			{
				return true;
			}
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(hash);
			ItemData item = ((!((Object)(object)itemPrefab != (Object)null)) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData);
			if (!OffHand.IsEligible(item))
			{
				return true;
			}
			Transform val = OffHandSheath.Joint(__instance, item);
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			__result = __instance.AttachItem(hash, variant, val, false, true, quality);
			return false;
		}
	}
	[HarmonyPatch(typeof(VisEquipment), "SetBackEquipped")]
	[Feature("Dual wield")]
	internal static class VisEquipment_SetBackEquipped_DualWieldPatch
	{
		private static void Postfix(VisEquipment __instance, bool __result)
		{
			if (__result)
			{
				OffHandSheath.AfterBackRebuilt(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "SetupAnimationState")]
	[Feature("Dual wield")]
	internal static class Humanoid_SetupAnimationState_DualWieldPatch
	{
		private static void Postfix(Humanoid __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (OffHand.IsDualWielding(__instance))
			{
				__instance.SetAnimationState(OffHand.Pose(__instance));
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "OnAttackTrigger")]
	[HarmonyPriority(200)]
	[Feature("Dual wield")]
	internal static class Humanoid_OnAttackTrigger_DualWieldPatch
	{
		private static void Prefix(Humanoid __instance, bool __runOriginal, out Stances.HitState __state)
		{
			__state = (__runOriginal ? Stances.BeforeHit(__instance) : null);
		}

		private static void Finalizer(Stances.HitState __state)
		{
			Stances.AfterHit(__state);
		}
	}
	[HarmonyPatch(typeof(Hud), "UpdateHealth")]
	[Feature("Food regen")]
	internal static class Hud_UpdateHealth_Patch
	{
		private static readonly FieldRef<GuiBar, float> DelayTimer = AccessTools.FieldRefAccess<GuiBar, float>("m_delayTimer");

		private static void Postfix(Hud __instance)
		{
			if (FoodRegen.Continuous && (Object)(object)__instance.m_healthBarFast != (Object)null)
			{
				DelayTimer.Invoke(__instance.m_healthBarFast) = 0f;
			}
		}
	}
	[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
	{
		typeof(ItemData),
		typeof(int),
		typeof(bool),
		typeof(float),
		typeof(int),
		typeof(bool)
	})]
	[Feature("Item tooltips")]
	internal static class ItemData_GetTooltip_Patch
	{
		public const string Feature = "Item tooltips";

		private static void Postfix(ItemData item, ref string __result)
		{
			if (SafePatcher.IsOn("Blood magic cost"))
			{
				__result = BloodMagicCost.AdjustTooltip(__result);
			}
			if (item?.m_shared != null && SafePatcher.IsOn("Food regen"))
			{
				__result = FoodTooltip.AddRegen(__result, item.m_shared);
			}
		}
	}
	[HarmonyPatch(typeof(ItemData), "GetWeaponLoadingTime")]
	[Feature("Faster loading")]
	internal static class ItemData_GetWeaponLoadingTime_Patch
	{
		public const string Feature = "Faster loading";

		private static void Postfix(ItemData __instance, ref float __result)
		{
			if (__instance.m_shared.m_attack.m_requiresReload)
			{
				__result = ActionTiming.ScaleReloadTime(__result);
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "StartAttack")]
	[Feature("Movesets")]
	internal static class Humanoid_StartAttack_MovesetPatch
	{
		private static readonly MethodInfo Replacement = AccessTools.Method(typeof(ActiveCombat.Movesets.Movesets), "Clone", (Type[])null, (Type[])null);

		private static void Prefix(Humanoid __instance, bool secondaryAttack)
		{
			ActiveCombat.Movesets.Movesets.BeforeStartAttack(__instance, secondaryAttack);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return Transpile.ReplaceCall(instructions, "Clone", Replacement, "Humanoid_StartAttack_MovesetPatch");
		}

		private static void Finalizer(Humanoid __instance)
		{
			ActiveCombat.Movesets.Movesets.AfterStartAttack(__instance);
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateDodge")]
	[Feature("Movesets")]
	internal static class Player_UpdateDodge_MovesetPatch
	{
		private static void Postfix(Player __instance)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && ((Character)__instance).InDodge())
			{
				AttackContexts.Rolled();
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "BlockAttack")]
	[Feature("Movesets")]
	internal static class Humanoid_BlockAttack_MovesetPatch
	{
		private static void Prefix(Humanoid __instance, out bool __state)
		{
			ItemData val = (((Object)(object)__instance == (Object)(object)Player.m_localPlayer) ? __instance.GetCurrentBlocker() : null);
			__state = val != null && val.m_shared.m_timedBlockBonus > 1f && __instance.m_blockTimer != -1f && __instance.m_blockTimer < 0.25f;
		}

		private static void Postfix(bool __result, bool __state)
		{
			if (__result && __state)
			{
				AttackContexts.Parried();
			}
		}
	}
	[HarmonyPatch(typeof(CharacterAnimEvent), "Speed")]
	[Feature("Movesets")]
	internal static class CharacterAnimEvent_Speed_MovesetPatch
	{
		private static void Prefix(CharacterAnimEvent __instance, ref float speedScale)
		{
			speedScale = MovesetMotion.ScaleSpeed(__instance.m_character, speedScale);
		}
	}
	[HarmonyPatch(typeof(CharacterAnimEvent), "TrailOn")]
	[Feature("Movesets")]
	internal static class CharacterAnimEvent_TrailOn_MovesetPatch
	{
		private static void Postfix(CharacterAnimEvent __instance)
		{
			MovesetMotion.SwingStarts(__instance.m_character, __instance.m_animator);
		}
	}
	[HarmonyPatch(typeof(CharacterAnimEvent), "CustomFixedUpdate")]
	[Feature("Movesets")]
	internal static class CharacterAnimEvent_CustomFixedUpdate_MovesetPatch
	{
		private static void Postfix(CharacterAnimEvent __instance, float fixedDeltaTime)
		{
			MovesetMotion.FixedUpdate(__instance.m_character, __instance.m_animator, fixedDeltaTime);
		}
	}
	[HarmonyPatch(typeof(Humanoid), "OnAttackTrigger")]
	[Feature("Movesets")]
	internal static class Humanoid_OnAttackTrigger_MovesetPatch
	{
		private static bool Prefix(Humanoid __instance)
		{
			return MovesetMotion.AllowHit((Character)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(Player), "EatFood")]
	[Feature("Eating fills bars")]
	internal static class Player_EatFood_Patch
	{
		public const string Feature = "Eating fills bars";

		private static void Prefix(Player __instance, out FoodFill.Maximums __state)
		{
			__state = FoodFill.Maximums.Of(__instance);
		}

		private static void Postfix(Player __instance, bool __result, FoodFill.Maximums __state)
		{
			if (__result)
			{
				FoodFill.Apply(__instance, __state);
			}
		}
	}
	internal static class EquipDuration
	{
		public const string Feature = "Instant gear changes";

		private static readonly FieldInfo Field = AccessTools.Field(typeof(SharedData), "m_equipDuration");

		private static readonly MethodInfo Scale = AccessTools.Method(typeof(ActionTiming), "ScaleEquipDuration", (Type[])null, (Type[])null);

		public static IEnumerable<CodeInstruction> Patch(IEnumerable<CodeInstruction> instructions, string patchName)
		{
			return Transpile.ScaleField(instructions, Field, Scale, patchName);
		}
	}
	[HarmonyPatch(typeof(Player), "ToggleEquipped")]
	[Feature("Instant gear changes")]
	internal static class Player_ToggleEquipped_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return EquipDuration.Patch(instructions, "Player_ToggleEquipped_Patch");
		}
	}
	[HarmonyPatch(typeof(Player), "QueueEquipAction")]
	[Feature("Instant gear changes")]
	internal static class Player_QueueEquipAction_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return EquipDuration.Patch(instructions, "Player_QueueEquipAction_Patch");
		}
	}
	[HarmonyPatch(typeof(Player), "QueueUnequipAction")]
	[Feature("Instant gear changes")]
	internal static class Player_QueueUnequipAction_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return EquipDuration.Patch(instructions, "Player_QueueUnequipAction_Patch");
		}
	}
	internal static class MovementClear
	{
		public const string Feature = "Movement doesn't cancel actions";

		private static readonly MethodInfo Replacement = AccessTools.Method(typeof(ActionTiming), "ClearUnlessMovementKeepsActions", (Type[])null, (Type[])null);

		public static IEnumerable<CodeInstruction> Patch(IEnumerable<CodeInstruction> instructions, string patchName)
		{
			return Transpile.ReplaceCall(instructions, "ClearActionQueue", Replacement, patchName);
		}
	}
	[HarmonyPatch(typeof(Player), "CheckRun")]
	[Feature("Movement doesn't cancel actions")]
	internal static class Player_CheckRun_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return MovementClear.Patch(instructions, "Player_CheckRun_Patch");
		}
	}
	[HarmonyPatch(typeof(Player), "OnJump")]
	[Feature("Movement doesn't cancel actions")]
	internal static class Player_OnJump_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return MovementClear.Patch(instructions, "Player_OnJump_Patch");
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateDodge")]
	[Feature("Movement doesn't cancel actions")]
	internal static class Player_UpdateDodge_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return MovementClear.Patch(instructions, "Player_UpdateDodge_Patch");
		}
	}
	[HarmonyPatch(typeof(Player), "QueueReloadAction")]
	[Feature("Loading uses no stamina")]
	internal static class Player_QueueReloadAction_Patch
	{
		public const string Feature = "Loading uses no stamina";

		private static readonly FieldInfo Field = AccessTools.Field(typeof(Attack), "m_reloadStaminaDrain");

		private static readonly MethodInfo Scale = AccessTools.Method(typeof(ActionTiming), "ScaleReloadStaminaDrain", (Type[])null, (Type[])null);

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return Transpile.ScaleField(instructions, Field, Scale, "Player_QueueReloadAction_Patch");
		}
	}
	[HarmonyPatch(typeof(Player), "RPC_UseStamina")]
	[Feature("Shorter stamina delay")]
	internal static class Player_RPC_UseStamina_Patch
	{
		public const string Feature = "Shorter stamina delay";

		private static void Postfix(Player __instance, float v)
		{
			if (v != 0f)
			{
				__instance.m_staminaRegenTimer = StaminaTiming.RegenDelay(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateFood")]
	[Feature("Food regen")]
	internal static class Player_UpdateFood_Patch
	{
		private static void Prefix(Player __instance, float dt, bool forceUpdate, out bool __state)
		{
			__state = false;
			if (!forceUpdate)
			{
				if (FoodRegen.Continuous)
				{
					__instance.m_foodRegenTimer = 0f;
					__state = true;
				}
				else
				{
					__state = __instance.m_foodRegenTimer + dt >= 10f;
				}
			}
		}

		private static void Postfix(Player __instance, float dt, bool __state)
		{
			if (__state)
			{
				FoodRegen.Restore(__instance, FoodRegen.Continuous ? dt : 10f);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateStats", new Type[] { typeof(float) })]
	[Feature("Regen during actions")]
	internal static class Player_UpdateStats_ActionRegen_Patch
	{
		public const string Feature = "Regen during actions";

		private static void Postfix(Player __instance, float dt)
		{
			ActionRegen.Apply(__instance, dt);
		}
	}
	[HarmonyPatch(typeof(SEMan), "ModifyStaminaRegen")]
	[Feature("Skill regen bonus")]
	internal static class SEMan_ModifyStaminaRegen_Patch
	{
		private static void Postfix(SEMan __instance, ref float staminaMultiplier)
		{
			Character character = __instance.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null)
			{
				staminaMultiplier = SkillRegen.Combine(staminaMultiplier, SkillRegen.StaminaBonus(val));
			}
		}
	}
	[HarmonyPatch(typeof(SEMan), "ModifyEitrRegen")]
	[Feature("Skill regen bonus")]
	internal static class SEMan_ModifyEitrRegen_Patch
	{
		private static void Postfix(SEMan __instance, ref float eitrMultiplier)
		{
			Character character = __instance.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null)
			{
				eitrMultiplier = SkillRegen.Combine(eitrMultiplier, SkillRegen.EitrBonus(val));
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "HideHandItems")]
	[Feature("Sheathe speed")]
	internal static class Humanoid_HideHandItems_Patch
	{
		private static void Postfix(Humanoid __instance, bool animation, bool __result)
		{
			if (__result && animation)
			{
				SheatheTiming.Started(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "ShowHandItems")]
	[Feature("Sheathe speed")]
	internal static class Humanoid_ShowHandItems_Patch
	{
		private static void Prefix(ItemData ___m_hiddenLeftItem, ItemData ___m_hiddenRightItem, out bool __state)
		{
			__state = ___m_hiddenLeftItem != null || ___m_hiddenRightItem != null;
		}

		private static void Postfix(Humanoid __instance, bool animation, bool __state)
		{
			if (__state && animation)
			{
				SheatheTiming.Started(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "InMinorAction")]
	[Feature("Sheathe speed")]
	internal static class Player_InMinorAction_Patch
	{
		private static void Postfix(Player __instance, Animator ___m_animator, ref bool __result)
		{
			if (__result && SheatheTiming.EndedEarly(__instance, ___m_animator))
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "InMinorActionSlowdown")]
	[Feature("Sheathe speed")]
	internal static class Player_InMinorActionSlowdown_Patch
	{
		private static void Postfix(Player __instance, Animator ___m_animator, ref bool __result)
		{
			if (__result && SheatheTiming.EndedEarly(__instance, ___m_animator))
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "Save")]
	[Feature("Sheathed weapons saved")]
	internal static class Player_Save_SheathedWeaponsPatch
	{
		private static void Prefix(Player __instance, out List<ItemData> __state)
		{
			__state = SheathedWeaponsSaved.BeforeSave(__instance);
		}

		private static void Finalizer(List<ItemData> __state)
		{
			SheathedWeaponsSaved.AfterSave(__state);
		}
	}
	[HarmonyPatch(typeof(Skill), "GetNextLevelRequirement")]
	[Feature("Level curve")]
	internal static class Skill_GetNextLevelRequirement_Patch
	{
		private static bool Prefix(Skill __instance, ref float __result)
		{
			return !LevelCurve.TryGetRequirement(__instance, out __result);
		}
	}
	[HarmonyPatch(typeof(Skills), "LowerAllSkills")]
	[Feature("Death penalty")]
	internal static class Skills_LowerAllSkills_Patch
	{
		private static bool Prefix(Skills __instance, float factor)
		{
			DeathPenalty.LowerAllSkills(__instance, factor);
			((Character)__instance.m_player).Message((MessageType)1, "$msg_skills_lowered", 0, (Sprite)null, false);
			return false;
		}
	}
	internal static class HitXp
	{
		private static readonly MethodInfo Replacement = AccessTools.Method(typeof(SkillXp), "Raise", (Type[])null, (Type[])null);

		public static IEnumerable<CodeInstruction> Patch(IEnumerable<CodeInstruction> instructions, string patchName)
		{
			return Transpile.ReplaceCall(instructions, "RaiseSkill", Replacement, patchName);
		}
	}
	[HarmonyPatch(typeof(Attack), "DoMeleeAttack")]
	[Feature("Damage-based experience")]
	internal static class Attack_DoMeleeAttack_XpPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return HitXp.Patch(instructions, "Attack_DoMeleeAttack_XpPatch");
		}
	}
	[HarmonyPatch(typeof(Attack), "DoAreaAttack")]
	[Feature("Damage-based experience")]
	internal static class Attack_DoAreaAttack_XpPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return HitXp.Patch(instructions, "Attack_DoAreaAttack_XpPatch");
		}
	}
	[HarmonyPatch(typeof(Projectile), "OnHit")]
	[Feature("Damage-based experience")]
	internal static class Projectile_OnHit_XpPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return HitXp.Patch(instructions, "Projectile_OnHit_XpPatch");
		}
	}
	[HarmonyPatch(typeof(Aoe), "OnHit")]
	[Feature("Damage-based experience")]
	internal static class Aoe_OnHit_XpPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return HitXp.Patch(instructions, "Aoe_OnHit_XpPatch");
		}
	}
	[HarmonyPatch(typeof(Humanoid), "BlockAttack")]
	[Feature("Damage-based experience")]
	internal static class Humanoid_BlockAttack_XpPatch
	{
		private static readonly MethodInfo Replacement = AccessTools.Method(typeof(SkillXp), "RaiseBlock", (Type[])null, (Type[])null);

		private static void Prefix(Humanoid __instance, HitData hit, Character attacker)
		{
			SkillXp.BeginBlock((Character)(object)__instance, hit, attacker);
		}

		private static void Finalizer()
		{
			SkillXp.EndBlock();
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return Transpile.ReplaceCall(instructions, "RaiseSkill", Replacement, "Humanoid_BlockAttack_XpPatch");
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	[Feature("Damage-based experience")]
	internal static class Character_Damage_XpPatch
	{
		private static void Prefix(Character __instance, HitData hit)
		{
			if (hit != null)
			{
				SkillXp.OnHit(__instance, hit);
			}
		}
	}
}
namespace ActiveCombat.Movesets
{
	internal enum AttackContext
	{
		None,
		Sprint,
		Roll,
		Jump,
		Plunge,
		Counter
	}
	internal static class AttackContexts
	{
		private static float _lastRoll = -100f;

		private static float _lastParry = -100f;

		public static void Rolled()
		{
			_lastRoll = Time.time;
		}

		public static void Parried()
		{
			_lastParry = Time.time;
		}

		public static AttackContext Setting(AttackContext context)
		{
			if (context != AttackContext.Plunge)
			{
				return context;
			}
			return AttackContext.Jump;
		}

		public static AttackContext Detect(Player player, out float fallen)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			fallen = 0f;
			if (!((Character)player).IsOnGround() && !((Character)player).InWater())
			{
				fallen = Mathf.Max(0f, ((Character)player).m_maxAirAltitude - ((Component)player).transform.position.y);
				if (!((Object)(object)((Character)player).m_body != (Object)null) || !(((Character)player).m_body.linearVelocity.y < -1f) || !(fallen >= CombatConfig.PlungeMinHeight.Value))
				{
					return AttackContext.Jump;
				}
				return AttackContext.Plunge;
			}
			if (Time.time - _lastParry <= CombatConfig.CounterWindow.Value)
			{
				return AttackContext.Counter;
			}
			if (((Character)player).InDodge() || Time.time - _lastRoll <= CombatConfig.RollWindow.Value)
			{
				return AttackContext.Roll;
			}
			Vector3 val = (((Object)(object)((Character)player).m_body != (Object)null) ? ((Character)player).m_body.linearVelocity : Vector3.zero);
			val.y = 0f;
			if (!((Character)player).IsRunning() || !(((Vector3)(ref val)).magnitude > 3f))
			{
				return AttackContext.None;
			}
			return AttackContext.Sprint;
		}
	}
	internal static class MovesetAnimations
	{
		public const string Weapon = "Weapon";

		public static readonly string[] All = new string[43]
		{
			"unarmed_attack0", "unarmed_attack1", "unarmed_kick", "knife_stab0", "knife_stab1", "knife_stab2", "knife_secondary", "dual_knives0", "dual_knives1", "dual_knives2",
			"dual_knives_secondary", "swing_longsword0", "swing_longsword1", "swing_longsword2", "sword_secondary", "greatsword0", "greatsword1", "greatsword2", "greatsword_secondary", "swing_axe0",
			"swing_axe1", "swing_axe2", "axe_secondary", "dualaxes0", "dualaxes1", "dualaxes2", "dualaxes3", "dualaxes_secondary", "battleaxe_attack0", "battleaxe_attack1",
			"battleaxe_attack2", "battleaxe_secondary", "mace_secondary", "swing_sledge", "spear_poke", "spear_throw", "atgeir_attack0", "atgeir_attack1", "atgeir_attack2", "atgeir_secondary",
			"swing_pickaxe", "scything", "shovel_secondary"
		};
	}
	internal enum MovesetAttackType
	{
		Weapon,
		Horizontal,
		Vertical,
		Area
	}
	internal sealed class MovesetEntry(string animation)
	{
		public string Animation = animation;

		public float Damage = 1f;

		public float Stamina = 1f;

		public float Stagger = 1f;

		public float Force = 1f;

		public float Range = 1f;

		public float Angle;

		public MovesetAttackType Type;

		public float Windup = 1f;

		public float Speed = 1f;

		public bool Hold;

		public void ApplyTo(Attack attack, float damage, float stamina)
		{
			//IL_00ba: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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)
			attack.m_attackAnimation = animation;
			attack.m_attackChainLevels = 0;
			attack.m_attackRandomAnimations = 0;
			attack.m_damageMultiplier *= Damage * damage;
			attack.m_attackStamina *= Stamina * stamina;
			attack.m_staggerMultiplier *= Stagger;
			attack.m_forceMultiplier *= Force;
			attack.m_attackRange *= Range;
			if (Angle > 0f)
			{
				attack.m_attackAngle = Angle;
			}
			if (Type == MovesetAttackType.Area)
			{
				MakeArea(attack);
				return;
			}
			attack.m_attackType = (AttackType)(Type switch
			{
				MovesetAttackType.Horizontal => 0, 
				MovesetAttackType.Vertical => 1, 
				_ => attack.m_attackType, 
			});
		}

		public static void MakeArea(Attack attack)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if ((int)attack.m_attackType != 4)
			{
				attack.m_attackType = (AttackType)4;
				attack.m_attackRayWidth = Mathf.Max(attack.m_attackRayWidth, CombatConfig.AreaRadius.Value);
				attack.m_attackRange = Mathf.Min(attack.m_attackRange, 1.5f);
			}
		}
	}
	internal static class MovesetMotion
	{
		private const float FreezeLength = 0.5f;

		private const float FreezeRenew = 0.25f;

		private const float MaxHold = 6f;

		private static Attack _attack;

		private static MovesetEntry _entry;

		private static bool _hold;

		private static float _clipSpeed = 1f;

		private static bool _started;

		private static bool _swinging;

		private static bool _frozen;

		private static bool _hitHeld;

		private static bool _holdUsed;

		private static float _holdTime;

		private static float _renewTime;

		private static bool _releasing;

		private static float Factor
		{
			get
			{
				if (!_swinging)
				{
					return _entry.Windup;
				}
				return _entry.Speed;
			}
		}

		public static void Started(Attack attack, MovesetEntry entry, bool plunge = false)
		{
			_hold = entry.Hold || plunge;
			Unfreeze();
			_attack = attack;
			_entry = entry;
			_clipSpeed = 1f;
			_started = false;
			_swinging = false;
			_hitHeld = false;
			_holdUsed = false;
		}

		private static bool IsActive(Character character, out Player player)
		{
			player = (Player)(object)((character is Player) ? character : null);
			if (_attack != null && (Object)(object)player != (Object)null && (Object)(object)player == (Object)(object)Player.m_localPlayer && ((Humanoid)player).m_currentAttack == _attack)
			{
				return !_attack.IsDone();
			}
			return false;
		}

		public static float ScaleSpeed(Character character, float speed)
		{
			if (!IsActive(character, out var _))
			{
				return speed;
			}
			_clipSpeed = speed;
			_started = true;
			return speed * Factor;
		}

		public static void SwingStarts(Character character, Animator animator)
		{
			if (IsActive(character, out var player) && !_swinging)
			{
				_swinging = true;
				animator.speed = _clipSpeed * Factor;
				if (_hold && !_holdUsed && !((Character)player).IsOnGround())
				{
					_holdUsed = true;
					Freeze(player);
				}
			}
		}

		public static bool AllowHit(Character character)
		{
			if (_releasing || !IsActive(character, out var player) || !_hold || _hitHeld || ((Character)player).IsOnGround())
			{
				return true;
			}
			_hitHeld = true;
			_holdUsed = true;
			Freeze(player);
			return false;
		}

		public static void FixedUpdate(Character character, Animator animator, float dt)
		{
			if (_attack == null || (Object)(object)character != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			if (!IsActive(character, out var player))
			{
				Unfreeze();
				_attack = null;
				_entry = null;
				return;
			}
			if (!_started && !_frozen && ((Character)player).InAttack())
			{
				_started = true;
				animator.speed = _clipSpeed * Factor;
			}
			if (!_frozen)
			{
				return;
			}
			_holdTime += dt;
			if (((Character)player).IsStaggering())
			{
				Unfreeze();
				_hitHeld = false;
			}
			else if (((Character)player).IsOnGround() || _holdTime > 6f)
			{
				Unfreeze();
				if (_hitHeld)
				{
					_releasing = true;
					try
					{
						((Character)player).OnAttackTrigger();
					}
					finally
					{
						_releasing = false;
					}
				}
			}
			else
			{
				_renewTime += dt;
				if (_renewTime >= 0.25f)
				{
					_renewTime = 0f;
					((Character)player).FreezeFrame(0.5f);
				}
			}
		}

		private static void Freeze(Player player)
		{
			_frozen = true;
			_holdTime = 0f;
			_renewTime = 0f;
			((Character)player).FreezeFrame(0.5f);
		}

		private static void Unfreeze()
		{
			if (_frozen)
			{
				_frozen = false;
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null)
				{
					((Character)localPlayer).FreezeFrame(0.001f);
				}
			}
		}
	}
	internal static class Movesets
	{
		public const string Feature = "Movesets";

		private static readonly AttackContext[] Contexts = new AttackContext[4]
		{
			AttackContext.Sprint,
			AttackContext.Roll,
			AttackContext.Jump,
			AttackContext.Counter
		};

		private static readonly Dictionary<WeaponClass, MovesetEntry[]> Defaults = new Dictionary<WeaponClass, MovesetEntry[]>
		{
			[WeaponClass.Fists] = new MovesetEntry[4]
			{
				new MovesetEntry("dual_knives_secondary")
				{
					Damage = 1f,
					Stamina = 1f,
					Stagger = 2f,
					Force = 2f
				},
				new MovesetEntry("unarmed_attack1")
				{
					Damage = 0.9f,
					Stamina = 0.8f,
					Windup = 1.15f,
					Speed = 1.15f
				},
				new MovesetEntry("unarmed_kick")
				{
					Damage = 1f,
					Stamina = 1f,
					Stagger = 2f,
					Windup = 1.3f,
					Speed = 1.3f,
					Hold = true
				},
				new MovesetEntry("unarmed_attack1")
				{
					Damage = 1.75f,
					Stamina = 0.8f,
					Stagger = 2f,
					Windup = 1.2f,
					Speed = 1.2f
				}
			},
			[WeaponClass.Knives] = new MovesetEntry[4]
			{
				new MovesetEntry("knife_stab2")
				{
					Damage = 1f,
					Stamina = 1f,
					Range = 1.2f
				},
				new MovesetEntry("knife_stab2")
				{
					Damage = 0.9f,
					Stamina = 0.8f,
					Windup = 1.25f,
					Speed = 1.25f
				},
				new MovesetEntry("knife_secondary")
				{
					Damage = 1f,
					Stamina = 1f,
					Windup = 1.8f,
					Hold = true
				},
				new MovesetEntry("knife_stab2")
				{
					Damage = 1.75f,
					Stamina = 1f,
					Windup = 1.25f,
					Speed = 1.25f
				}
			},
			[WeaponClass.DualKnives] = new MovesetEntry[4]
			{
				new MovesetEntry("dual_knives2")
				{
					Damage = 1f,
					Stamina = 1f,
					Range = 1.2f,
					Windup = 1.25f,
					Speed = 1.25f
				},
				new MovesetEntry("dual_knives2")
				{
					Damage = 0.9f,
					Stamina = 0.8f,
					Windup = 1.3f,
					Speed = 1.3f
				},
				new MovesetEntry("dual_knives_secondary")
				{
					Damage = 1f,
					Stamina = 1.2f,
					Hold = true
				},
				new MovesetEntry("dual_knives2")
				{
					Damage = 1.75f,
					Stamina = 1f
				}
			},
			[WeaponClass.Swords] = new MovesetEntry[4]
			{
				new MovesetEntry("swing_longsword1")
				{
					Damage = 1f,
					Stamina = 1.1f,
					Range = 1.2f,
					Windup = 1.2f,
					Speed = 1.2f
				},
				new MovesetEntry("swing_longsword2")
				{
					Damage = 0.9f,
					Stamina = 1f
				},
				new MovesetEntry("swing_longsword2")
				{
					Damage = 1f,
					Stamina = 1.2f,
					Type = MovesetAttackType.Vertical,
					Hold = true
				},
				new MovesetEntry("swing_longsword1")
				{
					Damage = 1.75f,
					Stamina = 1f
				}
			},
			[WeaponClass.Greatswords] = new MovesetEntry[4]
			{
				new MovesetEntry("greatsword0")
				{
					Damage = 1f,
					Stamina = 1.2f,
					Range = 1.1f,
					Windup = 1.3f,
					Speed = 1.3f
				},
				new MovesetEntry("greatsword_secondary")
				{
					Damage = 0.9f,
					Stamina = 1.2f,
					Windup = 2f,
					Speed = 1.5f
				},
				new MovesetEntry("greatsword2")
				{
					Damage = 1f,
					Stamina = 1.3f,
					Windup = 1.25f,
					Speed = 1.25f,
					Hold = true
				},
				new MovesetEntry("greatsword2")
				{
					Damage = 1.75f,
					Stamina = 1f,
					Windup = 1.15f,
					Speed = 1.15f
				}
			},
			[WeaponClass.Axes] = new MovesetEntry[4]
			{
				new MovesetEntry("swing_axe1")
				{
					Damage = 1f,
					Stamina = 1.1f,
					Range = 1.1f,
					Windup = 1.25f,
					Speed = 1.25f
				},
				new MovesetEntry("swing_axe2")
				{
					Damage = 0.9f,
					Stamina = 1f,
					Windup = 1.25f,
					Speed = 1.25f
				},
				new MovesetEntry("axe_secondary")
				{
					Damage = 1f,
					Stamina = 1.2f,
					Type = MovesetAttackType.Vertical,
					Windup = 2f,
					Hold = true
				},
				new MovesetEntry("swing_axe2")
				{
					Damage = 1.75f,
					Stamina = 1f,
					Windup = 1.15f,
					Speed = 1.15f
				}
			},
			[WeaponClass.DualAxes] = new MovesetEntry[4]
			{
				new MovesetEntry("dualaxes_secondary")
				{
					Damage = 1f,
					Stamina = 1.2f,
					Windup = 1.8f
				},
				new MovesetEntry("dualaxes2")
				{
					Damage = 0.5f,
					Stamina = 1f,
					Windup = 1.25f,
					Speed = 1.25f
				},
				new MovesetEntry("swing_axe2")
				{
					Damage = 1f,
					Stamina = 1.2f,
					Type = MovesetAttackType.Vertical,
					Hold = true
				},
				new MovesetEntry("dualaxes3")
				{
					Damage = 1f,
					Stamina = 1f
				}
			},
			[WeaponClass.Battleaxes] = new MovesetEntry[4]
			{
				new MovesetEntry("battleaxe_secondary")
				{
					Damage = 0.6f,
					Stamina = 1.3f,
					Stagger = 3f,
					Force = 2f,
					Angle = 30f,
					Windup = 1.2f,
					Speed = 1.2f
				},
				new MovesetEntry("battleaxe_attack2")
				{
					Damage = 0.9f,
					Stamina = 1.1f
				},
				new MovesetEntry("battleaxe_attack2")
				{
					Damage = 1f,
					Stamina = 1.3f,
					Hold = true
				},
				new MovesetEntry("battleaxe_attack1")
				{
					Damage = 1.75f,
					Stamina = 1f
				}
			},
			[WeaponClass.Maces] = new MovesetEntry[4]
			{
				new MovesetEntry("swing_longsword2")
				{
					Damage = 1f,
					Stamina = 1.1f
				},
				new MovesetEntry("swing_longsword2")
				{
					Damage = 0.9f,
					Stamina = 1f
				},
				new MovesetEntry("swing_longsword2")
				{
					Damage = 1f,
					Stamina = 1.2f,
					Type = MovesetAttackType.Vertical,
					Hold = true
				},
				new MovesetEntry("swing_longsword1")
				{
					Damage = 1.75f,
					Stamina = 1f,
					Stagger = 2f
				}
			},
			[WeaponClass.Sledges] = new MovesetEntry[4]
			{
				new MovesetEntry("battleaxe_secondary")
				{
					Damage = 0.5f,
					Stamina = 1.3f,
					Stagger = 3f,
					Force = 2f,
					Angle = 30f
				},
				new MovesetEntry("battleaxe_secondary")
				{
					Damage = 0.5f,
					Stamina = 1.2f,
					Stagger = 3f,
					Force = 2f,
					Angle = 30f
				},
				new MovesetEntry("swing_sledge")
				{
					Damage = 0.8f,
					Stamina = 1.2f,
					Type = MovesetAttackType.Area,
					Windup = 2.2f,
					Hold = true
				},
				new MovesetEntry("swing_sledge")
				{
					Damage = 1.75f,
					Stamina = 1f,
					Type = MovesetAttackType.Area,
					Windup = 1.4f
				}
			},
			[WeaponClass.Spears] = new MovesetEntry[4]
			{
				new MovesetEntry("spear_poke")
				{
					Damage = 1f,
					Stamina = 1.2f,
					Range = 1.3f
				},
				new MovesetEntry("spear_poke")
				{
					Damage = 0.9f,
					Stamina = 0.9f
				},
				new MovesetEntry("spear_poke")
				{
					Damage = 1f,
					Stamina = 1f,
					Hold = true
				},
				new MovesetEntry("spear_poke")
				{
					Damage = 1.75f,
					Stamina = 1f
				}
			},
			[WeaponClass.Atgeirs] = new MovesetEntry[4]
			{
				new MovesetEntry("atgeir_attack1")
				{
					Damage = 1f,
					Stamina = 1.1f,
					Range = 1.1f,
					Windup = 1.15f,
					Speed = 1.15f
				},
				new MovesetEntry("atgeir_attack1")
				{
					Damage = 0.9f,
					Stamina = 1f,
					Windup = 1.5f
				},
				new MovesetEntry("atgeir_attack2")
				{
					Damage = 1f,
					Stamina = 1.2f,
					Hold = true
				},
				new MovesetEntry("atgeir_secondary")
				{
					Damage = 1.5f,
					Stamina = 1f,
					Windup = 1.5f,
					Speed = 1.2f
				}
			}
		};

		private static readonly Dictionary<(WeaponClass, AttackContext), MovesetSettings> Entries = new Dictionary<(WeaponClass, AttackContext), MovesetSettings>();

		private static MovesetEntry _pending;

		private static Attack _pendingBase;

		private static bool _pendingArea;

		private static bool _pendingPlunge;

		private static Attack _lastClone;

		private static float _pendingDamage = 1f;

		private static float _pendingStamina = 1f;

		private static readonly HashSet<string> Warned = new HashSet<string>();

		private static HashSet<int> _triggers;

		public static IEnumerable<WeaponClass> Classes => Defaults.Keys;

		public static void BindConfig(ConfigFile config)
		{
			foreach (KeyValuePair<WeaponClass, MovesetEntry[]> @default in Defaults)
			{
				for (int i = 0; i < Contexts.Length; i++)
				{
					AttackContext attackContext = Contexts[i];
					Entries[(@default.Key, attackContext)] = new MovesetSettings(config, $"Moveset.{@default.Key}.{attackContext}", $"{@default.Key} attack when {Describe(attackContext)}", @default.Value[i]);
				}
			}
			RemoveOldEntries(config);
		}

		private static void RemoveOldEntries(ConfigFile config)
		{
			if (!(AccessTools.Property(typeof(ConfigFile), "OrphanedEntries")?.GetValue(config) is Dictionary<ConfigDefinition, string> dictionary))
			{
				return;
			}
			List<ConfigDefinition> list = dictionary.Keys.Where((ConfigDefinition key) => (key.Section.StartsWith("Moveset.", StringComparison.Ordinal) && key.Section.IndexOf('.', "Moveset.".Length) < 0) || ((key.Section.StartsWith("Moveset.", StringComparison.Ordinal) || key.Section.StartsWith("Stance.", StringComparison.Ordinal)) && key.Section.EndsWith(".Plunge", StringComparison.Ordinal))).ToList();
			if (list.Count == 0)
			{
				return;
			}
			foreach (ConfigDefinition item in list)
			{
				dictionary.Remove(item);
			}
			config.Save();
		}

		internal static string Describe(AttackContext context)
		{
			switch (context)
			{
			case AttackContext.Sprint:
				return "sprinting";
			case AttackContext.Roll:
				return "rolling or just after a roll";
			case AttackContext.Jump:
			case AttackContext.Plunge:
				return "in the air (a plunge when falling far enough, see Movesets.PlungeDamage)";
			default:
				return "just after a perfect block";
			}
		}

		public static void BeforeStartAttack(Humanoid humanoid, bool secondaryAttack)
		{
			_pending = null;
			_pendingBase = null;
			_pendingArea = false;
			_pendingPlunge = false;
			Player val = (Player)(object)((humanoid is Player) ? humanoid : null);
			if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			float fallen;
			AttackContext attackContext = AttackContexts.Detect(val, out fallen);
			bool value = CombatConfig.MovesetsEnabled.Value;
			if (value && !secondaryAttack && attackContext != AttackContext.None)
			{
				Stances.StanceAttack stanceAttack = Stances.BeginContext(val, attackContext);
				if (stanceAttack != null && HasAnimation(val, stanceAttack.Entry.animation))
				{
					_pending = stanceAttack.Entry;
					_pendingDamage = ((attackContext == AttackContext.Plunge) ? PlungeBonus(fallen) : 1f);
					_pendingArea = attackContext == AttackContext.Plunge && CombatConfig.PlungeHitsArea.Value;
					_pendingPlunge = attackContext == AttackContext.Plunge;
					_pendingStamina = ((attackContext == AttackContext.Sprint || attackContext == AttackContext.Roll) ? ArmourStamina(val) : 1f);
					if (CombatConfig.ShowMovesetMessages.Value)
					{
						((Character)val).Message((MessageType)1, stanceAttack.Describe(), 0, (Sprite)null, false);
					}
					return;
				}
				Stances.Abandon();
			}
			if (secondaryAttack || attackContext == AttackContext.None || !value)
			{
				Stances.StanceAttack stanceAttack2 = Stances.Begin(val, secondaryAttack);
				if (stanceAttack2 != null && HasAnimation(val, stanceAttack2.Entry.animation))
				{
					_pending = stanceAttack2.Entry;
					_pendingBase = (secondaryAttack ? stanceAttack2.MainHand.m_shared.m_attack : null);
					_pendingDamage = 1f;
					_pendingStamina = 1f;
					if (CombatConfig.ShowMovesetMessages.Value)
					{
						((Character)val).Message((MessageType)1, stanceAttack2.Describe(), 0, (Sprite)null, false);
					}
					return;
				}
				Stances.Abandon();
			}
			if (secondaryAttack || !value)
			{
				return;
			}
			WeaponClass weaponClass = WeaponClasses.Of(((Humanoid)val).GetCurrentWeapon());
			if (weaponClass == WeaponClass.None || attackContext == AttackContext.None || !Entries.TryGetValue((weaponClass, AttackContexts.Setting(attackContext)), out var value2))
			{
				return;
			}
			MovesetEntry movesetEntry = value2.Entry();
			if (movesetEntry != null && !HasAnimation(val, movesetEntry.animation))
			{
				if (Warned.Add(movesetEntry.animation))
				{
					ActiveCombatPlugin.Log.LogWarning((object)($"Moveset.{weaponClass}.{attackContext}: there's no attack animation " + "'" + movesetEntry.animation + "', so the weapon's own attack plays"));
				}
				movesetEntry = null;
			}
			if (movesetEntry != null)
			{
				_pending = movesetEntry;
				_pendingDamage = ((attackContext == AttackContext.Plunge) ? PlungeBonus(fallen) : 1f);
				_pendingArea = attackContext == AttackContext.Plunge && CombatConfig.PlungeHitsArea.Value;
				_pendingPlunge = attackContext == AttackContext.Plunge;
				_pendingStamina = ((attackContext == AttackContext.Sprint || attackContext == AttackContext.Roll) ? ArmourStamina(val) : 1f);
				if (CombatConfig.ShowMovesetMessages.Value)
				{
					((Character)val).Message((MessageType)1, $"{weaponClass} {attackContext}: {movesetEntry.animation}", 0, (Sprite)null, false);
				}
			}
		}

		private static bool HasAnimation(Player player, string animation)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			if (_triggers == null)
			{
				if ((Object)(object)((Character)player).m_animator == (Object)null)
				{
					return true;
				}
				_triggers = new HashSet<int>();
				AnimatorControllerParameter[] parameters = ((Character)player).m_animator.parameters;
				foreach (AnimatorControllerParameter val in parameters)
				{
					if ((int)val.type == 9)
					{
						_triggers.Add(val.nameHash);
					}
				}
			}
			return _triggers.Contains(Animator.StringToHash(animation));
		}

		public static Attack Clone(Attack attack)
		{
			Attack val = ((_pending != null && _pendingBase != null) ? _pendingBase : attack).Clone();
			_lastClone = null;
			if (_pending != null)
			{
				_pending.ApplyTo(val, _pendingDamage, _pendingStamina);
				if (_pendingArea)
				{
					MovesetEntry.MakeArea(val);
				}
				MovesetMotion.Started(val, _pending, _pendingPlunge);
				_lastClone = val;
			}
			return val;
		}

		public static void AfterStartAttack(Humanoid humanoid)
		{
			if (_pending != null)
			{
				Stances.Started(humanoid, _lastClone);
			}
			_pending = null;
			_pendingBase = null;
			_lastClone = null;
		}

		private static float PlungeBonus(float fallen)
		{
			float num = Mathf.Clamp01((fallen - CombatConfig.PlungeMinHeight.Value) / 10f);
			return CombatConfig.PlungeDamage.Value * (1f + CombatConfig.PlungeHeightBonus.Value * num);
		}

		private static float ArmourStamina(Player player)
		{
			float num = 0f;
			ItemData[] array = (ItemData[])(object)new ItemData[5]
			{
				((Humanoid)player).m_chestItem,
				((Humanoid)player).m_legItem,
				((Humanoid)player).m_helmetItem,
				((Humanoid)player).m_shoulderItem,
				((Humanoid)player).m_utilityItem
			};
			for (int i = 0; i < array.Length; i++)
			{
				num += array[i]?.m_shared.m_movementModifier ?? 0f;
			}
			return Mathf.Clamp(1f - CombatConfig.ArmourStaminaScale.Value * num, 0.5f, 2f);
		}
	}
	internal sealed class MovesetSettings
	{
		private readonly ConfigEntry<string> _animation;

		private readonly ConfigEntry<float> _damage;

		private readonly ConfigEntry<float> _stamina;

		private readonly ConfigEntry<float> _stagger;

		private readonly ConfigEntry<float> _force;

		private readonly ConfigEntry<float> _range;

		private readonly ConfigEntry<float> _angle;

		private readonly ConfigEntry<MovesetAttackType> _type;

		private readonly ConfigEntry<float> _windup;

		private readonly ConfigEntry<float> _speed;

		private readonly ConfigEntry<bool> _hold;

		private readonly ConfigEntry<StanceHands> _hands;

		public StanceHands Hands => _hands?.Value ?? StanceHands.Right;

		public MovesetSettings(ConfigFile config, string section, string attack, MovesetEntry defaults, StanceHands? hands = null)
		{
			int order = 100;
			string text = "Weapon";
			string[] all = MovesetAnimations.All;
			int num = 0;
			string[] array = new string[1 + all.Length];
			array[num] = text;
			num++;
			string[] array2 = all;
			foreach (string text2 in array2)
			{
				array[num] = text2;
				num++;
			}
			string[] array3 = array;
			_animation = config.Bind<string>(section, "Animation", defaults?.Animation ?? "Weapon", Describe("The animation of the " + attack + ". Weapon plays the weapon's own attack instead, and the rest of this section is ignored. Try them in game with activecombat_anim.", (AcceptableValueBase)(object)new AcceptableValueList<string>(array3)));
			if (hands.HasValue)
			{
				_hands = config.Bind<StanceHands>(section, "Hands", hands.Value, Describe("Which weapon each hit uses: Right (main hand), Left (off-hand), Both (each weapon deals half the damage), or RightThenLeft and LeftThenRight for animations that hit twice."));
			}
			_damage = config.Bind<float>(section, "Damage", defaults?.Damage ?? 1f, Describe("Damage, times the weapon's own primary attack.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f)));
			_stamina = config.Bind<float>(section, "Stamina", defaults?.Stamina ?? 1f, Describe("Stamina cost, times the weapon's own primary attack.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f)));
			_stagger = config.Bind<float>(section, "Stagger", defaults?.Stagger ?? 1f, Describe("Stagger, times the weapon's own primary attack.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f)));
			_force = config.Bind<float>(section, "Knockback", defaults?.Force ?? 1f, Describe("Knockback, times the weapon's own primary attack.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f)));
			_range = config.Bind<float>(section, "Reach", defaults?.Range ?? 1f, Describe("Reach, times the weapon's own primary attack.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f)));
			_angle = config.Bind<float>(section, "Arc", defaults?.Angle ?? 0f, Describe("The swing's arc in degrees; 360 hits all around. 0 keeps the weapon's own.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 360f)));
			_type = config.Bind<MovesetAttackType>(section, "HitType", defaults?.Type ?? MovesetAttackType.Weapon, Describe("How it hits: Horizontal or Vertical swing, or Area (everything around the impact, like a sledge). Weapon keeps the weapon's own."));
			_windup = config.Bind<float>(section, "WindupSpeed", defaults?.Windup ?? 1f, Describe("How fast the wind-up plays, until the swing starts. Higher gets into the attack sooner.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 4f)));
			_speed = config.Bind<float>(section, "SwingSpeed", defaults?.Speed ?? 1f, Describe("How fast the swing and recovery play.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 4f)));
			_hold = config.Bind<bool>(section, "HoldUntilLanding", defaults?.Hold ?? false, Describe("In the air, the attack holds the top of its wind-up as you fall and swings when you land."));
			ConfigDescription Describe(string text3, AcceptableValueBase range = null)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: 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_003d: Expected O, but got Unknown
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Expected O, but got Unknown
				return new ConfigDescription(text3 + " (Synced with server)", range, new object[1] { (object)new ConfigurationManagerAttributes
				{
					IsAdminOnly = true,
					Order = order--
				} });
			}
		}

		public MovesetEntry Entry()
		{
			string text = _animation.Value?.Trim();
			if (!string.IsNullOrEmpty(text) && !(text == "Weapon"))
			{
				return new MovesetEntry(text)
				{
					Damage = _damage.Value,
					Stamina = _stamina.Value,
					Stagger = _stagger.Value,
					Force = _force.Value,
					Range = _range.Value,
					Angle = _angle.Value,
					Type = _type.Value,
					Windup = _windup.Value,
					Speed = _speed.Value,
					Hold = _hold.Value
				};
			}
			return null;
		}
	}
	internal sealed class TestKitCommand : ConsoleCommand
	{
		private static readonly (WeaponClass Class, string Prefab)[] Kit = new(WeaponClass, string)[12]
		{
			(WeaponClass.Fists, "FistFenrirClaw"),
			(WeaponClass.Knives, "KnifeSilver"),
			(WeaponClass.DualKnives, "KnifeSkollAndHati"),
			(WeaponClass.Swords, "SwordIron"),
			(WeaponClass.Greatswords, "THSwordKrom"),
			(WeaponClass.Axes, "AxeIron"),
			(WeaponClass.DualAxes, "AxeBerzerkr"),
			(WeaponClass.Battleaxes, "Battleaxe"),
			(WeaponClass.Maces, "MaceIron"),
			(WeaponClass.Sledges, "SledgeIron"),
			(WeaponClass.Spears, "SpearBronze"),
			(WeaponClass.Atgeirs, "AtgeirIron")
		};

		private static readonly string[] Shields = new string[2] { "ShieldBronzeBuckler", "ShieldBanded" };

		private static readonly string[] OffHands = new string[4] { "SwordBronze", "AxeBronze", "MaceBronze", "KnifeCopper" };

		public override string Name => "activecombat_testkit";

		public override string Help => "[quality 1-4] Gives one weapon of every ActiveCombat moveset class, a buckler, a round shield, and a second sword, axe, mace and knife for dual wielding.";

		public override bool IsCheat => true;

		public override void Run(string[] args)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			int num = ((args.Length == 0 || !int.TryParse(args[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) ? 1 : result);
			num = Mathf.Clamp(num, 1, 4);
			Inventory inventory = ((Humanoid)localPlayer).GetInventory();
			List<string> list = new List<string>();
			int num2 = 0;
			foreach (string item in Prefabs())
			{
				if (inventory.AddItem(item, 1, num, 0, localPlayer.GetPlayerID(), localPlayer.GetPlayerName(), true, false) != null)
				{
					num2++;
				}
				else
				{
					list.Add(item);
				}
			}
			string text = $"ActiveCombat test kit: added {num2} items at quality {num}.";
			if (list.Count > 0)
			{
				text = text + " Not added (inventory full or item missing): " + string.Join(", ", list);
			}
			Console.instance.Print(text);
		}

		private static IEnumerable<string> Prefabs()
		{
			(WeaponClass Class, string Prefab)[] kit = Kit;
			for (int i = 0; i < kit.Length; i++)
			{
				yield return kit[i].Prefab;
			}
			string[] shields = Shields;
			for (int i = 0; i < shields.Length; i++)
			{
				yield return shields[i];
			}
			shields = OffHands;
			for (int i = 0; i < shields.Length; i++)
			{
				yield return shields[i];
			}
		}
	}
	internal sealed class ReloadConfigCommand(ConfigFile config) : ConsoleCommand()
	{
		public override string Name => "activecombat_reload";

		public override string Help => "Reloads ActiveCombat's config file. On a server, synced settings still use the server's values.";

		public override void Run(string[] args)
		{
			config.Reload();
			Console.instance.Print("ActiveCombat config reloaded.");
		}
	}
	internal sealed class PlayAnimationCommand : ConsoleCommand
	{
		public override string Name => "activecombat_anim";

		public override string Help => "<animation> Plays a player attack animation, for picking moveset entries. Without one, lists them.";

		public override bool IsCheat => true;

		public override List<string> CommandOptionList()
		{
			return MovesetAnimations.All.ToList();
		}

		public override void Run(string[] args)
		{
			Player localPlayer = Player.m_localPlayer;
			if (args.Length == 0 || (Object)(object)localPlayer == (Object)null)
			{
				Console.instance.Print("Animations: " + string.Join(", ", MovesetAnimations.All));
				return;
			}
			((Character)localPlayer).m_zanim.SetTrigger(args[0]);
			Console.instance.Print("Playing " + args[0] + ".");
		}
	}
	internal enum WeaponClass
	{
		None,
		Fists,
		Knives,
		DualKnives,
		Swords,
		Greatswords,
		Axes,
		DualAxes,
		Battleaxes,
		Maces,
		Sledges,
		Spears,
		Atgeirs
	}
	internal static class WeaponClasses
	{
		public static WeaponClass Of(ItemData weapon)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected I4, but got Unknown
			if (weapon == null)
			{
				return WeaponClass.None;
			}
			SharedData shared = weapon.m_shared;
			ItemType itemType = shared.m_itemType;
			if ((int)itemType == 15 || (int)itemType == 19)
			{
				return WeaponClass.None;
			}
			bool flag = (int)itemType == 14 || (int)itemType == 22;
			string text = shared.m_attack?.m_attackAnimation ?? "";
			SkillType skillType = shared.m_skillType;
			switch (skillType - 1)
			{
			case 10:
				return WeaponClass.Fists;
			case 1:
				return flag ? WeaponClass.DualKnives : WeaponClass.Knives;
			case 0:
				if (text == "greatsword")
				{
					return WeaponClass.Greatswords;
				}
				if (text == "swing_longsword")
				{
					return WeaponClass.Swords;
				}
				break;
			case 6:
				switch (text)
				{
				case "dualaxes":
					return WeaponClass.DualAxes;
				case "battleaxe_attack":
					return WeaponClass.Battleaxes;
				case "swing_axe":
					return WeaponClass.Axes;
				}
				break;
			case 2:
				if (text == "swing_sledge")
				{
					return WeaponClass.Sledges;
				}
				if (text == "swing_longsword")
				{
					return WeaponClass.Maces;
				}
				break;
			case 4:
				if (text == "spear_poke")
				{
					return WeaponClass.Spears;
				}
				break;
			case 3:
				return WeaponClass.Atgeirs;
			}
			return WeaponClass.None;
		}
	}
}
namespace ActiveCombat.Movement
{
	internal static class CharacterContacts
	{
		public const string Feature = "Sliding past creatures";

		private static readonly HashSet<int> CharacterBodies = new HashSet<int>();

		private static int _playerCollider;

		public static void Subscribe()
		{
			Physics.ContactModifyEvent += OnContactModify;
		}

		public static void Unsubscribe()
		{
			Physics.ContactModifyEvent -= OnContactModify;
		}

		public static void Register(Character character)
		{
			if ((Object)(object)character.m_body != (Object)null)
			{
				CharacterBodies.Add(((Object)character.m_body).GetInstanceID());
			}
		}

		public static void Unregister(Character character)
		{
			if ((Object)(object)character.m_body != (Object)null)
			{
				CharacterBodies.Remove(((Object)character.m_body).GetInstanceID());
			}
		}

		public static void SetLocalPlayer(Player player)
		{
			if (!((Object)(object)((Character)player).m_collider == (Object)null))
			{
				((Collider)((Character)player).m_collider).hasModifiableContacts = true;
				_playerCollider = ((Object)((Character)player).m_collider).GetInstanceID();
			}
		}

		private static void OnContactModify(PhysicsScene scene, NativeArray<ModifiableContactPair> pairs)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!CombatConfig.SlidePastCharacters.Value)
			{
				return;
			}
			for (int i = 0; i < pairs.Length; i++)
			{
				ModifiableContactPair val = pairs[i];
				int item;
				if (((ModifiableContactPair)(ref val)).colliderInstanceID == _playerCollider)
				{
					item = ((ModifiableContactPair)(ref val)).otherBodyInstanceID;
				}
				else
				{
					if (((ModifiableContactPair)(ref val)).otherColliderInstanceID != _playerCollider)
					{
						continue;
					}
					item = ((ModifiableContactPair)(ref val)).bodyInstanceID;
				}
				if (CharacterBodies.Contains(item))
				{
					for (int j = 0; j < ((ModifiableContactPair)(ref val)).contactCount; j++)
					{
						((ModifiableContactPair)(ref val)).SetStaticFriction(j, 0f);
						((ModifiableContactPair)(ref val)).SetDynamicFriction(j, 0f);
					}
				}
			}
		}
	}
	internal static class DodgeRoll
	{
		public const string Feature = "Attack out of a roll";

		public const string StartedAttackFeature = "Roll waits for a started attack";

		private const float StartedAttackWait = 0.5f;

		private const float TumbleEnd = 0.53f;

		private const float RollLength = 0.8823529f;

		private static readonly int DodgeTag = Animator.StringToHash("dodge");

		public static bool BlocksAttack(Character character)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (!character.InDodge())
			{
				return false;
			}
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer || !CombatConfig.AttackOutOfRoll.Value || !SafePatcher.IsOn("Attack out of a roll") || val.m_dodgeInvincible)
			{
				return true;
			}
			Animator animator = ((Character)val).m_animator;
			if ((Object)(object)animator == (Object)null || animator.IsInTransition(0))
			{
				return true;
			}
			AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
			if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).tagHash != DodgeTag)
			{
				return true;
			}
			float num = 0.53f + CombatConfig.RollAttackDelay.Value * (1f - ((Character)val).GetSkillFactor((SkillType)108));
			return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime * 0.8823529f < num;
		}

		public static bool BlocksRoll(Character character)
		{
			if (!character.InAttack())
			{
				Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null);
				if (val != null && SafePatcher.IsOn("Roll waits for a started attack"))
				{
					Attack currentAttack = val.m_currentAttack;
					if (currentAttack != null && !currentAttack.IsDone() && !currentAttack.m_wasInAttack)
					{
						return currentAttack.m_time < 0.5f;
					}
				}
				return false;
			}
			return true;
		}
	}
	internal static class WeightClasses
	{
		private const float Greatsword = -0.1f;

		private const float Massive = -0.15f;

		private const float Buckler = -0.02f;

		private static readonly Dictionary<SharedData, float> Vanilla = new Dictionary<SharedData, float>();

		public static void Subscribe()
		{
			ItemManager.OnItemsRegisteredFejd += ApplyToCurrent;
			ItemManager.OnItemsRegistered += ApplyToCurrent;
		}

		public static void Unsubscribe()
		{
			ItemManager.OnItemsRegisteredFejd -= ApplyToCurrent;
			ItemManager.OnItemsRegistered -= ApplyToCurrent;
		}

		private static void ApplyToCurrent()
		{
			Apply(ObjectDB.instance);
		}

		public static void Apply(ObjectDB db)
		{
			if ((Object)(object)db == (Object)null || db.m_items == null)
			{
				return;
			}
			bool value = CombatConfig.WeightClasses.Value;
			foreach (GameObject item in db.m_items)
			{
				SharedData val = ((!((Object)(object)item != (Object)null)) ? null : item.GetComponent<ItemDrop>()?.m_itemData?.m_shared);
				if (val != null)
				{
					if (!Vanilla.TryGetValue(val, out var value2))
					{
						value2 = val.m_movementModifier;
					}
					float? num = (value ? Target(((Object)item).name, val, value2) : ((float?)null));
					if (num.HasValue && num.Value != value2)
					{
						Vanilla[val] = value2;
						val.m_movementModifier = num.Value;
					}
					else if (Vanilla.Remove(val))
					{
						val.m_movementModifier = value2;
					}
				}
			}
		}

		private static float? Target(string prefab, SharedData shared, float vanilla)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			if ((int)shared.m_itemType == 5)
			{
				if (!prefab.Contains("Buckler") || !(vanilla <= -0.05f))
				{
					return null;
				}
				return -0.02f;
			}
			if ((int)shared.m_itemType == 14)
			{
				float? result;
				switch (shared.m_attack?.m_attackAnimation)
				{
				case "greatsword":
					result = -0.1f;
					break;
				case "battleaxe_attack":
				case "swing_sledge":
					result = -0.15f;
					break;
				default:
					result = null;
					break;
				}
				return result;
			}
			return null;
		}
	}
}
namespace ActiveCombat.Magic
{
	internal static class BloodMagicCost
	{
		public const string Feature = "Blood magic cost";

		private static readonly Regex HealthUse = new Regex("\\n\\$item_healthuse: <color=orange>(?<value>[0-9]+(?:\\.[0-9]+)?)(?<percent>%?)</color>", RegexOptions.Compiled);

		public static float Scale(float cost)
		{
			return cost * CombatConfig.BloodMagicHealthMultiplier.Value;
		}

		public static string AdjustTooltip(string tooltip)
		{
			float multiplier = CombatConfig.BloodMagicHealthMultiplier.Value;
			if (tooltip != null && !Mathf.Approximately(multiplier, 1f) && tooltip.IndexOf("$item_healthuse", StringComparison.Ordinal) >= 0)
			{
				return HealthUse.Replace(tooltip, delegate(Match match)
				{
					if (multiplier <= 0f)
					{
						return "";
					}
					float num = float.Parse(match.Groups["value"].Value, CultureInfo.InvariantCulture) * multiplier;
					string value = match.Groups["percent"].Value;
					string text = ((value.Length > 0) ? num.ToString("0.0", CultureInfo.InvariantCulture) : num.ToString("0.##", CultureInfo.InvariantCulture));
					return "\n$item_healthuse: <color=orange>" + text + value + "</color>";
				});
			}
			return tooltip;
		}
	}
	internal static class ManaShield
	{
		public static void Absorb(Player player, HitData hit)
		{
			float value = CombatConfig.ManaShieldShare.Value;
			float value2 = CombatConfig.ManaShieldEitrPerDamage.Value;
			float eitr = player.GetEitr();
			float totalDamage = hit.GetTotalDamage();
			if (!(value <= 0f) && !(eitr <= 0f) && !(totalDamage <= 0f))
			{
				float num = value2 * Game.m_eitrRate;
				float num2 = totalDamage * value;
				bool drained = false;
				if (num > 0f && num2 * num >= eitr)
				{
					num2 = eitr / num;
					drained = true;
				}
				if (!(num2 <= 0f))
				{
					hit.ApplyModifier((totalDamage - num2) / totalDamage);
					((Character)player).UseEitr(num2 * value2);
					ManaShieldEffects.Play(player, hit, drained);
				}
			}
		}
	}
	internal static class ManaShieldEffects
	{
		private const string HitPrefab = "fx_StaffShield_Hit";

		private const string BreakPrefab = "fx_StaffShield_Break";

		private const float HitCooldown = 0.5f;

		private static float _lastHitTime = float.NegativeInfinity;

		public static void Play(Player player, HitData hit, bool drained)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0072: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_00b2: 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)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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)
			if (CombatConfig.ManaShieldEffects.Value && !((Object)(object)ZNetScene.instance == (Object)null))
			{
				if (drained)
				{
					Spawn("fx_StaffShield_Break", ((Character)player).GetCenterPoint(), ((Component)player).transform.rotation, ((Character)player).GetRadius() * 2f);
					_lastHitTime = Time.time;
				}
				else if (!(Time.time - _lastHitTime < 0.5f))
				{
					_lastHitTime = Time.time;
					Vector3 position = ((hit.m_point != Vector3.zero) ? hit.m_point : ((Character)player).GetCenterPoint());
					Quaternion rotation = ((((Vector3)(ref hit.m_dir)).sqrMagnitude > 0.001f) ? Quaternion.LookRotation(-hit.m_dir) : ((Component)player).transform.rotation);
					Spawn("fx_StaffShield_Hit", position, rotation, 1f);
				}
			}
		}

		private static void Spawn(string prefabName, Vector3 position, Quaternion rotation, float scale)
		{
			//IL_0017: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ZNetScene.instance.GetPrefab(prefabName);
			if (!((Object)(object)prefab == (Object)null))
			{
				Object.Instantiate<GameObject>(prefab, position, rotation).transform.localScale = new Vector3(scale, scale, scale);
			}
		}
	}
}
namespace ActiveCombat.Food
{
	internal static class FoodFill
	{
		public readonly struct Maximums
		{
			public readonly float Health;

			public readonly float Stamina;

			public readonly float Eitr;

			public Maximums(float health, float stamina, float eitr)
			{
				Health = health;
				Stamina = stamina;
				Eitr = eitr;
			}

			public static Maximums Of(Player player)
			{
				return new Maximums(((Character)player).GetMaxHealth(), ((Character)player).GetMaxStamina(), ((Character)player).GetMaxEitr());
			}
		}

		public static void Apply(Player player, Maximums before)
		{
			if (CombatConfig.FoodFillsBars.Value)
			{
				Maximums maximums = Maximums.Of(player);
				if (maximums.Health > before.Health)
				{
					((Character)player).Heal(maximums.Health - before.Health, true);
				}
				if (maximums.Stamina > before.Stamina)
				{
					((Character)player).AddStamina(maximums.Stamina - before.Stamina);
				}
				if (maximums.Eitr > before.Eitr)
				{
					((Character)player).AddEitr(maximums.Eitr - before.Eitr);
				}
			}
		}
	}
	internal static class FoodRegen
	{
		public const string Feature = "Food regen";

		public const float TickSeconds = 10f;

		public static bool Continuous => CombatConfig.FoodContinuousRegen.Value;

		public static float Stamina(SharedData food)
		{
			return PerTick(food, food.m_foodStamina) * CombatConfig.FoodStaminaRegen.Value;
		}

		public static float Eitr(SharedData food)
		{
			return PerTick(food, food.m_foodEitr) * CombatConfig.FoodEitrRegen.Value;
		}

		public static void Restore(Player player, float seconds)
		{
			float num = seconds / 10f;
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			foreach (Food food in player.m_foods)
			{
				num2 += food.m_item.m_shared.m_foodRegen;
				num3 += Stamina(food.m_item.m_shared);
				num4 += Eitr(food.m_item.m_shared);
			}
			if (Continuous && num2 > 0f)
			{
				float num5 = 1f;
				((Character)player).m_seman.ModifyHealthRegen(ref num5);
				((Character)player).Heal(num2 * num5 * num, false);
			}
			num3 *= num;
			num4 *= num;
			if (num3 > 0f && !ActionRegen.StaminaRegenBlocked(player))
			{
				((Character)player).AddStamina(num3);
			}
			if (num4 > 0f)
			{
				((Character)player).AddEitr(num4);
			}
		}

		private static float PerTick(SharedData food, float amount)
		{
			if (!(food.m_food > 0f))
			{
				return 0f;
			}
			return food.m_foodRegen * amount / food.m_food;
		}
	}
	internal static class FoodTooltip
	{
		private static readonly Regex HealthRegenLine = new Regex("(\\$item_food_regen: <color=orange>[^<]*hp/tick</color>)");

		public static string AddRegen(string tooltip, SharedData food)
		{
			float num = FoodRegen.Stamina(food);
			float num2 = FoodRegen.Eitr(food);
			if (num <= 0f && num2 <= 0f)
			{
				return tooltip;
			}
			string extra = "";
			if (num > 0f)
			{
				extra = extra + ", <color=#ffff80ff>" + Format(num) + " $activecombat_stamina_per_tick</color>";
			}
			if (num2 > 0f)
			{
				extra = extra + ", <color=#9090ffff>" + Format(num2) + " $activecombat_eitr_per_tick</color>";
			}
			return HealthRegenLine.Replace(tooltip, (Match match) => match.Value + extra, 1);
		}

		private static string Format(float value)
		{
			return value.ToString("0.#", CultureInfo.InvariantCulture);
		}
	}
}
namespace ActiveCombat.Falling
{
	internal static class FallHeight
	{
		private const float SafeHeight = 4f;

		private const float DamageRange = 16f;

		private static float _takeOffHeight = float.NegativeInfinity;

		private static float _fastestFall;

		public static void Update(Character character)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)character != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			float y = ((Component)character).transform.position.y;
			if (!character.m_groundContact)
			{
				_fastestFall = Mathf.Max(_fastestFall, 0f - character.m_body.linearVelocity.y);
				return;
			}
			float num = Mathf.Max(0f, character.m_maxAirAltitude - y);
			if (CombatConfig.FairFallDamage.Value)
			{
				num = Mathf.Min(new float[3]
				{
					num,
					Mathf.Max(0f, _takeOffHeight - y),
					FreeFallHeight(_fastestFall)
				});
			}
			character.m_maxAirAltitude = y + Curve(num);
			_takeOffHeight = y;
			_fastestFall = 0f;
		}

		private static float Curve(float fall)
		{
			float value = CombatConfig.FallDamageCurve.Value;
			if (!(fall <= 4f) && !(fall >= 20f) && !Mathf.Approximately(value, 1f))
			{
				return 4f + 16f * Mathf.Pow((fall - 4f) / 16f, value);
			}
			return fall;
		}

		private static float FreeFallHeight(float speed)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Abs(Physics.gravity.y);
			if (!(num > 0f))
			{
				return float.PositiveInfinity;
			}
			return speed * speed / (2f * num);
		}
	}
}
namespace ActiveCombat.DualWield
{
	internal enum DualStance
	{
		None,
		TwinBlades,
		TwinChops,
		SwordPair,
		MainGauche
	}
	internal enum StanceHands
	{
		Right,
		Left,
		Both,
		RightThenLeft,
		LeftThenRight
	}
	internal static class DualStances
	{
		public static DualStance Of(Humanoid humanoid)
		{
			if (!OffHand.IsDualWielding(humanoid))
			{
				return DualStance.None;
			}
			WeaponClass weaponClass = WeaponClasses.Of(humanoid.m_rightItem);
			WeaponClass weaponClass2 = WeaponClasses.Of(humanoid.m_leftItem);
			if (weaponClass != WeaponClass.Knives)
			{
				if (weaponClass2 != WeaponClass.Knives)
				{
					if ((weaponClass == WeaponClass.Axes || weaponClass == WeaponClass.Maces) && (weaponClass2 == WeaponClass.Axes || weaponClass2 == WeaponClass.Maces))
					{
						return DualStance.TwinChops;
					}
					return DualStance.SwordPair;
				}
				return DualStance.MainGauche;
			}
			return DualStance.TwinBlades;
		}
	}
	internal enum OffHandModifier
	{
		Shift = 1,
		Ctrl,
		Alt
	}
	internal static class OffHand
	{
		public const string Feature = "Dual wield";

		private const string MarkKey = "activecombat_offhand";

		private static bool Enabled => CombatConfig.DualWield.Value;

		public static bool IsEligible(ItemData item)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			bool flag = item != null && (int)item.m_shared.m_itemType == 3;
			if (flag)
			{
				bool flag2;
				switch (WeaponClasses.Of(item))
				{
				case WeaponClass.Knives:
				case WeaponClass.Swords:
				case WeaponClass.Axes:
				case WeaponClass.Maces:
					flag2 = true;
					break;
				default:
					flag2 = false;
					break;
				}
				flag = flag2;
			}
			return flag;
		}

		public static bool IsMarked(ItemData item)
		{
			if (item?.m_customData != null)
			{
				return item.m_customData.ContainsKey("activecombat_offhand");
			}
			return false;
		}

		private static bool ModifierHeld()
		{
			return CombatConfig.OffHandModifier.Value switch
			{
				OffHandModifier.Shift => UnityInput.Current.GetKey((KeyCode)304) || UnityInput.Current.GetKey((KeyCode)303), 
				OffHandModifier.Ctrl => UnityInput.Current.GetKey((KeyCode)306) || UnityInput.Current.GetKey((KeyCode)305), 
				_ => UnityInput.Current.GetKey((KeyCode)308) || UnityInput.Current.GetKey((KeyCode)307), 
			};
		}

		public static bool IsDualWielding(Humanoid humanoid)
		{
			if (Enabled && humanoid is Player && IsEligible(humanoid.m_rightItem))
			{
				return IsEligible(humanoid.m_leftItem);
			}
			return false;
		}

		public static AnimationState Pose(Humanoid humanoid)
		{
			if (WeaponClasses.Of(humanoid.m_rightItem) != WeaponClass.Knives && WeaponClasses.Of(humanoid.m_leftItem) != WeaponClass.Knives)
			{
				return (AnimationState)15;
			}
			return (AnimationState)11;
		}

		public static void BeforeToggle(Player player, ItemData item)
		{
			if (IsEligible(item) && !((Humanoid)player).IsItemEquiped(item))
			{
				ItemData rightItem = ((Humanoid)player).m_rightItem;
				if (Enabled && ModifierHeld() && IsEligible(rightItem) && rightItem != item)
				{
					item.m_customData["activecombat_offhand"] = "1";
				}
				else
				{
					item.m_customData.Remove("activecombat_offhand");
				}
			}
		}

		public static bool TryEquipLeft(Humanoid humanoid, ItemData item, bool triggerEquipEffects, out bool result)
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			result = false;
			if (!Enabled || !(humanoid is Player) || !IsMarked(item) || !IsEligible(item))
			{
				return false;
			}
			ItemData rightItem = humanoid.m_rightItem;
			if (rightItem == item)
			{
				return false;
			}
			if (rightItem != null && !IsEligible(rightItem))
			{
				item.m_customData.Remove("activecombat_offhand");
				return false;
			}
			if (humanoid.IsItemEquiped(item) || !humanoid.m_inventory.ContainsItem(item) || ((Character)humanoid).InAttack() || ((Character)humanoid).InDodge() || (!((Character)humanoid).IsDead() && ((Character)humanoid).IsSwimming() && !((Character)humanoid).IsOnGround()) || (item.m_shared.m_useDurability && item.m_durability <= 0f))
			{
				return true;
			}
			humanoid.UnequipItem(humanoid.m_leftItem, triggerEquipEffects);
			humanoid.m_leftItem = item;
			VisEquipment visEquipment = humanoid.m_visEquipment;
			if ((Object)(object)visEquipment != (Object)null && visEquipment.m_isPlayer && (Object)(object)FejdStartup.instance == (Object)null)
			{
				item.m_shared.m_equipEffect.Create(visEquipment.m_leftHand.position, visEquipment.m_leftHand.rotation, (Transform)null, 1f, -1, ((Character)humanoid).GetZDOID());
			}
			humanoid.m_hiddenRightItem = null;
			humanoid.m_hiddenLeftItem = null;
			item.m_equipped = true;
			humanoid.SetupEquipment();
			if (triggerEquipEffects)
			{
				humanoid.TriggerEquipEffect(item);
			}
			result = true;
			return true;
		}

		public static ItemData SetAsideOffHand(Humanoid humanoid, ItemData item)
		{
			ItemData leftItem = humanoid.m_leftItem;
			if (!Enabled || !(humanoid is Player) || !IsEligible(item) || IsMarked(item) || !IsMarked(leftItem) || !IsEligible(leftItem))
			{
				return null;
			}
			humanoid.m_leftItem = null;
			return leftItem;
		}

		public static void AfterEquip(Humanoid humanoid, ItemData setAside)
		{
			if (setAside == null || humanoid.m_leftItem != null)
			{
				if (setAside != null && humanoid.m_leftItem != setAside)
				{
					setAside.m_equipped = false;
				}
				return;
			}
			ItemData rightItem = humanoid.m_rightItem;
			if ((rightItem == null || IsEligible(rightItem)) && rightItem != setAside && humanoid.m_inventory.ContainsItem(setAside))
			{
				humanoid.m_leftItem = setAside;
			}
			else
			{
				setAside.m_equipped = false;
			}
			humanoid.SetupEquipment();
		}
	}
	internal static class OffHandSheath
	{
		private const string LeftBackSlot = "activecombat_BackOneHandedLeft_attach";

		public static void AfterBackRebuilt(VisEquipment vis)
		{
			//IL_0055: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			GameObject leftBackItemInstance = vis.m_leftBackItemInstance;
			GameObject rightBackItemInstance = vis.m_rightBackItemInstance;
			if (!((Object)(object)leftBackItemInstance == (Object)null) && !((Object)(object)right