Decompiled source of Spiritbound v0.1.1

plugins/SpiritboundMod.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EmotesAPI;
using EntityStates;
using EntityStates.AI.Walker;
using EntityStates.BrotherMonster;
using EntityStates.GravekeeperMonster.Weapon;
using HG;
using HG.BlendableTypes;
using KinematicCharacterController;
using On.RoR2;
using On.RoR2.UI;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using RoR2.Achievements;
using RoR2.Audio;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using SpiritboundMod.Modules;
using SpiritboundMod.Modules.Achievements;
using SpiritboundMod.Modules.BaseStates;
using SpiritboundMod.Modules.Characters;
using SpiritboundMod.Spirit.Components;
using SpiritboundMod.Spirit.SkillStates;
using SpiritboundMod.Spiritbound;
using SpiritboundMod.Spiritbound.Components;
using SpiritboundMod.Spiritbound.Content;
using SpiritboundMod.Spiritbound.SkillStates;
using ThreeEyedGames;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SpiritboundMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+34804e740b3a89893e71c4a8f97bc84ee6e85c5e")]
[assembly: AssemblyProduct("SpiritboundMod")]
[assembly: AssemblyTitle("SpiritboundMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
internal enum SpiritboundCameraParams
{
	DEFAULT,
	AIM_PISTOL,
	AIM_SNIPER,
	EMOTE
}
namespace SpiritboundMod
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void ErrorAssetBundle(string assetName, string bundleName)
		{
			Error("failed to load asset, " + assetName + ", because it does not exist in asset bundle, " + bundleName);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.kenko.Spiritbound", "Spiritbound", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SpiritboundPlugin : BaseUnityPlugin
	{
		public const string MODUID = "com.kenko.Spiritbound";

		public const string MODNAME = "Spiritbound";

		public const string MODVERSION = "1.0.0";

		public const string DEVELOPER_PREFIX = "KENKO";

		public static SpiritboundPlugin instance;

		public static bool emotesInstalled => Chainloader.PluginInfos.ContainsKey("com.weliveinasociety.CustomEmotesAPI");

		public static bool scepterInstalled => Chainloader.PluginInfos.ContainsKey("com.DestroyedClone.AncientScepter");

		private void Awake()
		{
			instance = this;
			NetworkingAPI.RegisterMessageType<SyncBloodExplosion>();
			NetworkingAPI.RegisterMessageType<SyncStackOrb>();
			NetworkingAPI.RegisterMessageType<SyncHealOrb>();
			Log.Init(((BaseUnityPlugin)this).Logger);
			Language.Init();
			new SpiritboundSurvivor().Initialize();
			new SpiritCharacter().Initialize();
			new ContentPacks().Initialize();
		}

		private void Start()
		{
			SoundBanks.Init();
		}
	}
}
namespace SpiritboundMod.Spirit.SkillStates
{
	public class SpiritBarrage : BaseState
	{
		public float baseDuration = 0.1f;

		public string muzzleString;

		public float missileForce = GravekeeperBarrage.missileForce;

		public float damageCoefficient = SpiritboundStaticValues.wispDamageCoefficient;

		public float maxSpread = 0f;

		public GameObject projectilePrefab = SpiritboundAssets.spiritOrbPrefab;

		private GameObject muzzleFlashEffect = SpiritboundAssets.arrowMuzzleFlashEffect;

		private float duration;

		private ChildLocator childLocator;

		private float missileStopwatch;

		private int spiritOrbAmount;

		public override void OnEnter()
		{
			childLocator = ((EntityState)this).GetModelChildLocator();
			((BaseState)this).OnEnter();
			duration = baseDuration / base.attackSpeedStat;
			if (((EntityState)this).characterBody.baseNameToken == "KENKO_SPIRIT_NAME")
			{
				spiritOrbAmount = ((EntityState)this).GetComponent<SpiritController>().owner.GetComponent<CharacterBody>().GetBuffCount(SpiritboundBuffs.soulStacksBuff) + 1;
				int num = Random.Range(0, 2);
				muzzleString = ((num == 0) ? "MuzzleFlashL" : "MuzzleFlashR");
			}
			else
			{
				spiritOrbAmount = ((EntityState)this).characterBody.GetBuffCount(SpiritboundBuffs.soulStacksBuff) + 1;
				muzzleString = "FirePack";
			}
			((EntityState)this).characterBody.SetAimTimer(duration + 1f);
		}

		private void FireBlob(Ray projectileRay, float bonusPitch, float bonusYaw)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			((Ray)(ref projectileRay)).direction = Util.ApplySpread(((Ray)(ref projectileRay)).direction, 0f, maxSpread, 1f, 1f, bonusYaw, bonusPitch);
			EffectManager.SimpleMuzzleFlash(muzzleFlashEffect, ((EntityState)this).gameObject, muzzleString, true);
			if (NetworkServer.active)
			{
				ProjectileManager.instance.FireProjectile(projectilePrefab, ((Ray)(ref projectileRay)).origin, Util.QuaternionSafeLookRotation(((Ray)(ref projectileRay)).direction), ((EntityState)this).gameObject, base.damageStat * damageCoefficient, missileForce, Util.CheckRoll(base.critStat, ((EntityState)this).characterBody.master), (DamageColorIndex)0, (GameObject)null, -1f);
			}
		}

		public override void OnExit()
		{
			((EntityState)this).OnExit();
		}

		public override void FixedUpdate()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).FixedUpdate();
			missileStopwatch += Time.fixedDeltaTime;
			if (missileStopwatch >= duration / (float)spiritOrbAmount)
			{
				missileStopwatch = 0f;
				Transform val = childLocator.FindChild(muzzleString);
				if (Object.op_Implicit((Object)(object)val))
				{
					Ray projectileRay = default(Ray);
					((Ray)(ref projectileRay)).origin = val.position;
					Ray aimRay = ((BaseState)this).GetAimRay();
					((Ray)(ref projectileRay)).direction = ((Ray)(ref aimRay)).direction;
					float num = 1000f;
					RaycastHit val2 = default(RaycastHit);
					if (Physics.Raycast(((BaseState)this).GetAimRay(), ref val2, num, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask)))
					{
						((Ray)(ref projectileRay)).direction = ((RaycastHit)(ref val2)).point - val.position;
					}
					FireBlob(projectileRay, 0f, 0f);
				}
			}
			if (((EntityState)this).fixedAge >= duration * 1.25f && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)3;
		}
	}
	public class SpiritBite : BaseMeleeAttack
	{
		protected GameObject swingEffectInstance;

		public override void OnEnter()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			RefreshState();
			hitboxGroupName = "MeleeHitbox";
			damageType = (DamageType)8;
			damageCoefficient = SpiritboundStaticValues.spiritBiteDamageCoefficient;
			procCoefficient = 1f;
			pushForce = 300f;
			bonusForce = Vector3.zero;
			baseDuration = 1f;
			attackStartPercentTime = 0.2f;
			attackEndPercentTime = 0.4f;
			earlyExitPercentTime = 0.5f;
			hitStopDuration = 0.05f;
			attackRecoil = 2f / ((BaseState)this).attackSpeedStat;
			hitHopVelocity = 0f;
			swingSoundString = "";
			hitSoundString = "";
			playbackRateParam = "Bite.playbackRate";
			swingEffectPrefab = SpiritboundAssets.spiritBiteEffect;
			hitEffectPrefab = SpiritboundAssets.spiritboundHitEffect;
			impactSound = SpiritboundAssets.biteImpactSoundEvent.index;
			muzzleString = "BiteMuzzleFlash";
			if (((EntityState)this).characterBody.HasBuff(Buffs.WarCryBuff))
			{
				moddedDamageTypeHolder.Add(DamageTypes.CurrentHealthSpirit);
			}
			base.OnEnter();
		}

		protected override void OnHitEnemyAuthority()
		{
			Util.PlaySound(hitSoundString, ((EntityState)this).gameObject);
		}

		protected override void FireAttack()
		{
			base.FireAttack();
		}

		protected override void PlaySwingEffect()
		{
			Util.PlaySound(swingSoundString, ((EntityState)this).gameObject);
			if (Object.op_Implicit((Object)(object)swingEffectPrefab))
			{
				Transform val = ((BaseState)this).FindModelChild(muzzleString);
				if (Object.op_Implicit((Object)(object)val))
				{
					swingEffectInstance = Object.Instantiate<GameObject>(swingEffectPrefab, val);
				}
			}
		}

		protected override void PlayAttackAnimation()
		{
			RefreshState();
			((EntityState)this).PlayCrossfade("Gesture, Override", "Bite", playbackRateParam, duration * 1.3f, 0.05f);
		}

		public override void OnExit()
		{
			base.OnExit();
			if (Object.op_Implicit((Object)(object)swingEffectInstance))
			{
				EntityState.Destroy((Object)(object)swingEffectInstance);
			}
		}
	}
	public class SpiritLunge : BaseState
	{
		public static float giveUpDuration = 3f;

		public static float speedCoefficient = 6f;

		public Vector3 position;

		public float minDistanceFromPoint = 10f;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			((EntityState)this).characterBody.isSprinting = true;
			if (minDistanceFromPoint <= 0f)
			{
				minDistanceFromPoint = 1f;
			}
			((EntityState)this).PlayAnimation("FullBody, Override", "Dash", "Dash.playbackRate", giveUpDuration);
		}

		public override void FixedUpdate()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).FixedUpdate();
			PerformInputs();
			bool flag = Vector3.Distance(position, ((EntityState)this).transform.position) <= minDistanceFromPoint;
			bool flag2 = ((EntityState)this).fixedAge >= giveUpDuration;
			if ((flag || flag2) && ((EntityState)this).isAuthority)
			{
				if (flag2)
				{
					((BaseCharacterController)((EntityState)this).characterMotor).Motor.SetPosition(position, true);
				}
				((EntityState)this).outer.SetNextStateToMain();
			}
			if (((EntityState)this).isAuthority)
			{
				RigidbodyDirection rigidbodyDirection = ((EntityState)this).rigidbodyDirection;
				Vector3 val = position - ((EntityState)this).transform.position;
				rigidbodyDirection.aimDirection = ((Vector3)(ref val)).normalized;
				RigidbodyMotor rigidbodyMotor = ((EntityState)this).rigidbodyMotor;
				Vector3 rootMotion = rigidbodyMotor.rootMotion;
				val = position - ((EntityState)this).transform.position;
				rigidbodyMotor.rootMotion = rootMotion + ((Vector3)(ref val)).normalized * (speedCoefficient * base.moveSpeedStat * Time.fixedDeltaTime);
			}
		}

		private void PerformInputs()
		{
			if (Object.op_Implicit((Object)(object)((EntityState)this).skillLocator))
			{
				if (((EntityState)this).inputBank.skill1.down && Object.op_Implicit((Object)(object)((EntityState)this).skillLocator.primary))
				{
					((EntityState)this).skillLocator.primary.ExecuteIfReady();
				}
				if (((EntityState)this).inputBank.skill2.down && Object.op_Implicit((Object)(object)((EntityState)this).skillLocator.secondary))
				{
					((EntityState)this).skillLocator.secondary.ExecuteIfReady();
				}
				if (((EntityState)this).inputBank.skill3.down && Object.op_Implicit((Object)(object)((EntityState)this).skillLocator.utility))
				{
					((EntityState)this).skillLocator.utility.ExecuteIfReady();
				}
				if (((EntityState)this).inputBank.skill4.down && Object.op_Implicit((Object)(object)((EntityState)this).skillLocator.special))
				{
					((EntityState)this).skillLocator.special.ExecuteIfReady();
				}
			}
		}

		public override void OnExit()
		{
			((EntityState)this).characterBody.isSprinting = false;
			((EntityState)this).PlayCrossfade("FullBody, Override", "BufferEmpty", 0.2f);
			((EntityState)this).OnExit();
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)2;
		}
	}
	internal class SpiritMainState : BaseState
	{
		private Animator modelAnimator;

		private bool skill1InputReceived;

		private bool skill2InputReceived;

		private bool skill3InputReceived;

		private bool skill4InputReceived;

		private bool sprintInputReceived;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			modelAnimator = ((EntityState)this).GetModelAnimator();
			((EntityState)this).PlayAnimation("Body", "Idle");
			modelAnimator.SetFloat("Fly.rate", 1f);
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			PerformInputs();
		}

		public override void Update()
		{
			((EntityState)this).Update();
			if (!(Time.deltaTime <= 0f))
			{
				UpdateAnimParams();
			}
		}

		private void PerformInputs()
		{
			//IL_003e: 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_0053: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (!((EntityState)this).isAuthority)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).inputBank))
			{
				if (Object.op_Implicit((Object)(object)((EntityState)this).rigidbodyMotor))
				{
					((EntityState)this).rigidbodyMotor.moveVector = ((EntityState)this).inputBank.moveVector * ((EntityState)this).characterBody.moveSpeed;
				}
				if (Object.op_Implicit((Object)(object)((EntityState)this).rigidbodyDirection))
				{
					if (((EntityState)this).inputBank.moveVector != Vector3.zero)
					{
						((EntityState)this).rigidbodyDirection.aimDirection = ((EntityState)this).inputBank.moveVector;
					}
					else
					{
						((EntityState)this).rigidbodyDirection.aimDirection.y = 0f;
					}
				}
				skill1InputReceived = ((EntityState)this).inputBank.skill1.down;
				skill2InputReceived = ((EntityState)this).inputBank.skill2.down;
				skill3InputReceived = ((EntityState)this).inputBank.skill3.down;
				skill4InputReceived = ((EntityState)this).inputBank.skill4.down;
				sprintInputReceived |= ((EntityState)this).inputBank.sprint.down;
				if (((Vector3)(ref ((EntityState)this).inputBank.moveVector)).magnitude <= 0.5f)
				{
					sprintInputReceived = false;
				}
				((EntityState)this).characterBody.isSprinting = sprintInputReceived;
				if (sprintInputReceived)
				{
					modelAnimator.SetFloat("Fly.rate", 1.5f);
				}
				sprintInputReceived = false;
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).skillLocator))
			{
				if (skill1InputReceived && Object.op_Implicit((Object)(object)((EntityState)this).skillLocator.primary))
				{
					((EntityState)this).skillLocator.primary.ExecuteIfReady();
				}
				if (skill2InputReceived && Object.op_Implicit((Object)(object)((EntityState)this).skillLocator.secondary))
				{
					((EntityState)this).skillLocator.secondary.ExecuteIfReady();
				}
				if (skill3InputReceived && Object.op_Implicit((Object)(object)((EntityState)this).skillLocator.utility))
				{
					((EntityState)this).skillLocator.utility.ExecuteIfReady();
				}
				if (skill4InputReceived && Object.op_Implicit((Object)(object)((EntityState)this).skillLocator.special))
				{
					((EntityState)this).skillLocator.special.ExecuteIfReady();
				}
			}
		}

		private void UpdateAnimParams()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)modelAnimator))
			{
				Vector3 moveVector = ((EntityState)this).inputBank.moveVector;
				bool flag = moveVector != Vector3.zero && ((EntityState)this).characterBody.moveSpeed > Mathf.Epsilon;
				modelAnimator.SetBool("isMoving", flag);
			}
		}
	}
	public class SpiritRedirect : SpiritLunge
	{
		public bool isEmpower;

		public override void OnEnter()
		{
			base.OnEnter();
			if (NetworkServer.active && isEmpower)
			{
				((EntityState)this).characterBody.AddTimedBuff(Buffs.WarCryBuff, 8f);
			}
		}

		public override void OnExit()
		{
			base.OnExit();
			if (isEmpower)
			{
				((EntityState)this).gameObject.GetComponent<SpiritController>().inFrenzy = true;
			}
		}
	}
}
namespace SpiritboundMod.Spirit.Components
{
	public class SpiritController : MonoBehaviour
	{
		public static SkillDef missileSkillDef;

		public GameObject owner;

		private GameObject masterObject;

		private BaseAI baseAI;

		private AISkillDriver[] aISkillDrivers;

		private EntityStateMachine weaponMachine;

		private EntityStateMachine bodyMachine;

		public SkillLocator skillLocator;

		private bool attackMode = true;

		public CharacterBody characterBody;

		public Highlight targetHighlight;

		public bool inFrenzy;

		public GameObject currentTarget => baseAI.currentEnemy.gameObject;

		public HurtBox currentBestHurtbox => baseAI.currentEnemy.bestHurtBox;

		public bool inAttackMode => attackMode;

		private void Awake()
		{
			skillLocator = ((Component)this).GetComponent<SkillLocator>();
			((MonoBehaviour)this).Invoke("ApplyEffects", 0.3f);
		}

		private void Start()
		{
			characterBody = ((Component)this).GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)owner) && Object.op_Implicit((Object)(object)characterBody))
			{
				CharacterBody component = owner.GetComponent<CharacterBody>();
				if (component.skinIndex != characterBody.skinIndex)
				{
					ApplySpiritSkin(component);
				}
			}
			masterObject = ((Component)characterBody.master).gameObject;
			aISkillDrivers = masterObject.GetComponents<AISkillDriver>();
			baseAI = masterObject.GetComponent<BaseAI>();
			weaponMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Weapon");
			bodyMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Body");
			EnterFollowMode();
		}

		public void ApplySpiritSkin(CharacterBody ownerBody)
		{
			if (!Object.op_Implicit((Object)(object)ownerBody) || !Object.op_Implicit((Object)(object)characterBody))
			{
				return;
			}
			characterBody.skinIndex = ownerBody.skinIndex;
			ModelLocator component = ((Component)this).GetComponent<ModelLocator>();
			if (Object.op_Implicit((Object)(object)component))
			{
				GameObject gameObject = ((Component)component.modelTransform).gameObject;
				if (Object.op_Implicit((Object)(object)gameObject))
				{
					ModelSkinController component2 = gameObject.GetComponent<ModelSkinController>();
					component2.ApplySkin((int)characterBody.skinIndex);
				}
			}
		}

		public void ApplyEffects()
		{
			ModelLocator component = ((Component)this).GetComponent<ModelLocator>();
			ChildLocator componentInChildren = ((Component)component.modelBaseTransform).GetComponentInChildren<ChildLocator>();
			((Renderer)((Component)componentInChildren.FindChild("FireR")).gameObject.GetComponent<ParticleSystemRenderer>()).material = SpiritboundAssets.fireMatInFront;
			((Renderer)((Component)componentInChildren.FindChild("FireL")).gameObject.GetComponent<ParticleSystemRenderer>()).material = SpiritboundAssets.fireMatInFront;
		}

		public void SetTarget(HurtBox target)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			HealthComponent healthComponent = target.healthComponent;
			GameObject gameObject = ((Component)healthComponent).gameObject;
			if (Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)healthComponent) && healthComponent.alive && Object.op_Implicit((Object)(object)gameObject))
			{
				CreateHighlight(gameObject);
				baseAI.currentEnemy.gameObject = gameObject;
				baseAI.currentEnemy.bestHurtBox = target;
				baseAI.enemyAttention = 1f;
				baseAI.BeginSkillDriver(baseAI.EvaluateSkillDrivers());
			}
		}

		public void EnterAttackMode()
		{
			if (Util.HasEffectiveAuthority(owner))
			{
				Util.PlaySound("", ((Component)this).gameObject);
			}
			if (attackMode)
			{
				return;
			}
			attackMode = true;
			AISkillDriver[] array = aISkillDrivers;
			foreach (AISkillDriver val in array)
			{
				if (!((Behaviour)val).enabled && SpiritCharacter.attackDrivers.Contains(val.customName))
				{
					((Behaviour)val).enabled = true;
				}
			}
		}

		public void EnterFollowMode()
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			if (Util.HasEffectiveAuthority(owner))
			{
				Util.PlaySound("Play_gravekeeper_death_01", ((Component)this).gameObject);
			}
			if (!attackMode)
			{
				return;
			}
			attackMode = false;
			if (Object.op_Implicit((Object)(object)targetHighlight))
			{
				Object.Destroy((Object)(object)targetHighlight);
			}
			AISkillDriver[] array = aISkillDrivers;
			foreach (AISkillDriver val in array)
			{
				if (((Behaviour)val).enabled && SpiritCharacter.attackDrivers.Contains(val.customName))
				{
					((Behaviour)val).enabled = false;
				}
			}
			baseAI.currentEnemy.gameObject = null;
			baseAI.currentEnemy.bestHurtBox = null;
			baseAI.BeginSkillDriver(baseAI.EvaluateSkillDrivers());
		}

		public void LungeAtEnemy(CharacterBody victimBody)
		{
			//IL_0013: 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)
			bodyMachine.SetInterruptState((EntityState)(object)new SpiritLunge
			{
				position = victimBody.transform.position
			}, (InterruptPriority)2);
		}

		public void FreeOrb()
		{
			weaponMachine.SetInterruptState((EntityState)(object)new SpiritBarrage(), (InterruptPriority)2);
		}

		public void Redirect(Vector3 position, float minDistance, bool empower = true)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			bodyMachine.SetInterruptState((EntityState)(object)new SpiritRedirect
			{
				position = position,
				minDistanceFromPoint = minDistance,
				isEmpower = empower
			}, (InterruptPriority)2);
		}

		private void FixedUpdate()
		{
			if (characterBody.isPlayerControlled)
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)owner) && Object.op_Implicit((Object)(object)masterObject))
			{
				owner = masterObject.GetComponent<CharacterMaster>().minionOwnership.ownerMaster.bodyInstanceObject;
				if (!Object.op_Implicit((Object)(object)owner))
				{
					return;
				}
				SpiritMasterComponent component = owner.GetComponent<SpiritMasterComponent>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					if (characterBody.master.godMode)
					{
						characterBody.master.ToggleGod();
					}
					characterBody.master.TrueKill();
				}
				component.spiritController = this;
			}
			if (Object.op_Implicit((Object)(object)owner) && inFrenzy && !characterBody.HasBuff(Buffs.WarCryBuff))
			{
				inFrenzy = false;
				owner.GetComponent<SpiritMasterComponent>().FollowOrder();
			}
		}

		private void CreateHighlight(GameObject target)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)target.GetComponent<Highlight>()))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)targetHighlight))
			{
				Object.Destroy((Object)(object)targetHighlight);
			}
			ModelLocator component = target.GetComponent<ModelLocator>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			Transform modelTransform = component.modelTransform;
			if (!Object.op_Implicit((Object)(object)modelTransform))
			{
				return;
			}
			CharacterModel component2 = ((Component)modelTransform).GetComponent<CharacterModel>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				return;
			}
			RendererInfo[] baseRendererInfos = component2.baseRendererInfos;
			foreach (RendererInfo val in baseRendererInfos)
			{
				if (!val.ignoreOverlays)
				{
					targetHighlight = target.AddComponent<Highlight>();
					targetHighlight.highlightColor = (HighlightColor)1;
					targetHighlight.strength = 1.5f;
					targetHighlight.targetRenderer = val.renderer;
					targetHighlight.isOn = true;
					break;
				}
			}
		}
	}
}
namespace SpiritboundMod.Spiritbound
{
	public class SpiritboundSurvivor : SurvivorBase<SpiritboundSurvivor>
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Init <>9__61_0;

			internal void <Emotes>b__61_0(orig_Init orig)
			{
				orig.Invoke();
				GameObject val = SpiritboundAssets.mainAssetBundle.LoadAsset<GameObject>("spiritbound_emoteskeleton");
				CustomEmotesAPI.ImportArmature(characterPrefab, val, 0, true);
			}
		}

		public const string SOULBOUND_PREFIX = "KENKO_SPIRITBOUND_";

		internal static GameObject characterPrefab;

		public static SkillDef convictScepterSkillDef;

		public override string assetBundleName => "spiritbound";

		public override string bodyName => "SpiritboundBody";

		public override string masterName => "SpiritboundMonsterMaster";

		public override string modelPrefabName => "mdlSpiritbound";

		public override string displayPrefabName => "SpiritboundDisplay";

		public override string survivorTokenPrefix => "KENKO_SPIRITBOUND_";

		public override BodyInfo bodyInfo => new BodyInfo
		{
			bodyName = bodyName,
			bodyNameToken = "KENKO_SPIRITBOUND_NAME",
			subtitleNameToken = "KENKO_SPIRITBOUND_SUBTITLE",
			characterPortrait = assetBundle.LoadAsset<Texture>("texSpiritboundIcon"),
			bodyColor = SpiritboundAssets.spiritBoundColor,
			sortPosition = 6f,
			spreadBloomDecayTime = 0.7f,
			spreadBloomCurve = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Captain/CaptainBody.prefab").WaitForCompletion().gameObject.GetComponent<CharacterBody>().spreadBloomCurve,
			crosshair = SpiritboundAssets.spiritboundCrosshair,
			podPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/SurvivorPod"),
			maxHealth = 110f,
			damage = 12f,
			jumpCount = 1
		};

		public override CustomRendererInfo[] customRendererInfos => new CustomRendererInfo[7]
		{
			new CustomRendererInfo
			{
				childName = "Model"
			},
			new CustomRendererInfo
			{
				childName = "HairModel"
			},
			new CustomRendererInfo
			{
				childName = "HornModel"
			},
			new CustomRendererInfo
			{
				childName = "MaskModel"
			},
			new CustomRendererInfo
			{
				childName = "TrinketModel"
			},
			new CustomRendererInfo
			{
				childName = "PackModel"
			},
			new CustomRendererInfo
			{
				childName = "BowModel"
			}
		};

		public override UnlockableDef characterUnlockableDef => SpiritboundUnlockables.characterUnlockableDef;

		public override ItemDisplaysBase itemDisplays => new SpiritboundItemDisplays();

		public override AssetBundle assetBundle { get; protected set; }

		public override GameObject bodyPrefab { get; protected set; }

		public override CharacterBody prefabCharacterBody { get; protected set; }

		public override GameObject characterModelObject { get; protected set; }

		public override CharacterModel prefabCharacterModel { get; protected set; }

		public override GameObject displayPrefab { get; protected set; }

		public override void Initialize()
		{
			base.Initialize();
		}

		public override void InitializeCharacter()
		{
			SpiritboundAssets.Init(assetBundle);
			SpiritboundConfig.Init();
			SpiritboundUnlockables.Init();
			base.InitializeCharacter();
			CameraParams.InitializeParams();
			DamageTypes.Init();
			SpiritboundStates.Init();
			SpiritboundTokens.Init();
			SpiritboundBuffs.Init(assetBundle);
			InitializeEntityStateMachines();
			InitializeSkills();
			InitializeSkins();
			InitializeCharacterMaster();
			AdditionalBodySetup();
			characterPrefab = bodyPrefab;
			AddHooks();
		}

		private void AdditionalBodySetup()
		{
			AddHitboxes();
			bodyPrefab.AddComponent<SpiritboundController>();
			bodyPrefab.AddComponent<SpiritMasterComponent>();
		}

		public void AddHitboxes()
		{
		}

		public override void InitializeEntityStateMachines()
		{
			Prefabs.ClearEntityStateMachines(bodyPrefab);
			Prefabs.AddMainEntityStateMachine(bodyPrefab, "Body", typeof(MainState), typeof(SpawnTeleporterState));
			Prefabs.AddEntityStateMachine(bodyPrefab, "Weapon");
			Prefabs.AddEntityStateMachine(bodyPrefab, "Weapon2");
			Prefabs.AddEntityStateMachine(bodyPrefab, "Dash");
		}

		public override void InitializeSkills()
		{
			bodyPrefab.AddComponent<SpiritboundPassive>();
			Skills.CreateSkillFamilies(bodyPrefab);
			AddPassiveSkills();
			AddPrimarySkills();
			AddSecondarySkills();
			AddUtilitySkills();
			AddSpecialSkills();
		}

		private void AddPassiveSkills()
		{
			//IL_0082: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			SpiritboundPassive component = bodyPrefab.GetComponent<SpiritboundPassive>();
			SkillLocator component2 = bodyPrefab.GetComponent<SkillLocator>();
			component2.passiveSkill.enabled = false;
			component.spiritboundPassive = Skills.CreateSkillDef(new SkillDefInfo
			{
				skillName = "KENKO_SPIRITBOUND_PASSIVE_NAME",
				skillNameToken = "KENKO_SPIRITBOUND_PASSIVE_NAME",
				skillDescriptionToken = "KENKO_SPIRITBOUND_PASSIVE_DESCRIPTION",
				skillIcon = assetBundle.LoadAsset<Sprite>("texSpiritboundPassive"),
				keywordTokens = new string[1] { Tokens.spiritBoundStacksKeyword },
				activationState = new SerializableEntityStateType(typeof(Idle)),
				activationStateMachineName = "",
				baseMaxStock = 1,
				baseRechargeInterval = 0f,
				beginSkillCooldownOnSkillEnd = false,
				canceledFromSprinting = false,
				forceSprintDuringState = false,
				fullRestockOnAssign = true,
				interruptPriority = (InterruptPriority)0,
				resetCooldownTimerOnUse = false,
				isCombatSkill = false,
				mustKeyPress = false,
				cancelSprintingOnActivation = false,
				rechargeStock = 1,
				requiredStock = 2,
				stockToConsume = 1
			});
			Skills.AddPassiveSkills(component.passiveSkillSlot.skillFamily, component.spiritboundPassive);
		}

		private void AddPrimarySkills()
		{
			//IL_0065: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			SkillDefInfo skillDefInfo = new SkillDefInfo();
			skillDefInfo.skillName = "Bow";
			skillDefInfo.skillNameToken = "KENKO_SPIRITBOUND_PRIMARY_BOW_NAME";
			skillDefInfo.skillDescriptionToken = "KENKO_SPIRITBOUND_PRIMARY_BOW_DESCRIPTION";
			skillDefInfo.keywordTokens = new string[2]
			{
				Tokens.agileKeyword,
				Tokens.respiteKeyword
			};
			skillDefInfo.skillIcon = assetBundle.LoadAsset<Sprite>("tex");
			skillDefInfo.activationState = new SerializableEntityStateType(typeof(ChargeArrow));
			skillDefInfo.activationStateMachineName = "Weapon";
			skillDefInfo.interruptPriority = (InterruptPriority)0;
			skillDefInfo.baseMaxStock = 1;
			skillDefInfo.baseRechargeInterval = 1f;
			skillDefInfo.rechargeStock = 0;
			skillDefInfo.requiredStock = 0;
			skillDefInfo.stockToConsume = 0;
			skillDefInfo.resetCooldownTimerOnUse = false;
			skillDefInfo.fullRestockOnAssign = true;
			skillDefInfo.dontAllowPastMaxStocks = false;
			skillDefInfo.beginSkillCooldownOnSkillEnd = true;
			skillDefInfo.mustKeyPress = false;
			skillDefInfo.isCombatSkill = true;
			skillDefInfo.canceledFromSprinting = false;
			skillDefInfo.cancelSprintingOnActivation = false;
			skillDefInfo.forceSprintDuringState = false;
			SkillDef val = Skills.CreateSkillDef(skillDefInfo);
			Skills.AddPrimarySkills(bodyPrefab, val);
		}

		private void AddSecondarySkills()
		{
			//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_006c: Unknown result type (might be due to invalid IL or missing references)
			SkillDefInfo skillDefInfo = new SkillDefInfo();
			skillDefInfo.skillName = "Hop";
			skillDefInfo.skillNameToken = "KENKO_SPIRITBOUND_SECONDARY_HOP_NAME";
			skillDefInfo.skillDescriptionToken = "KENKO_SPIRITBOUND_SECONDARY_HOP_DESCRIPTION";
			skillDefInfo.keywordTokens = new string[0];
			skillDefInfo.skillIcon = assetBundle.LoadAsset<Sprite>("tex");
			skillDefInfo.activationState = new SerializableEntityStateType(typeof(HopFire));
			skillDefInfo.activationStateMachineName = "Weapon";
			skillDefInfo.interruptPriority = (InterruptPriority)2;
			skillDefInfo.baseMaxStock = 1;
			skillDefInfo.baseRechargeInterval = 7f;
			skillDefInfo.rechargeStock = 1;
			skillDefInfo.requiredStock = 1;
			skillDefInfo.stockToConsume = 1;
			skillDefInfo.resetCooldownTimerOnUse = false;
			skillDefInfo.fullRestockOnAssign = true;
			skillDefInfo.dontAllowPastMaxStocks = false;
			skillDefInfo.beginSkillCooldownOnSkillEnd = true;
			skillDefInfo.mustKeyPress = false;
			skillDefInfo.isCombatSkill = true;
			skillDefInfo.canceledFromSprinting = false;
			skillDefInfo.cancelSprintingOnActivation = false;
			skillDefInfo.forceSprintDuringState = true;
			SkillDef val = Skills.CreateSkillDef(skillDefInfo);
			Skills.AddSecondarySkills(bodyPrefab, val);
		}

		private void AddUtilitySkills()
		{
			//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_006c: Unknown result type (might be due to invalid IL or missing references)
			SkillDefInfo skillDefInfo = new SkillDefInfo();
			skillDefInfo.skillName = "Spirit Swap";
			skillDefInfo.skillNameToken = "KENKO_SPIRITBOUND_UTILITY_SWAP_NAME";
			skillDefInfo.skillDescriptionToken = "KENKO_SPIRITBOUND_UTILITY_SWAP_DESCRIPTION";
			skillDefInfo.keywordTokens = new string[0];
			skillDefInfo.skillIcon = assetBundle.LoadAsset<Sprite>("tex");
			skillDefInfo.activationState = new SerializableEntityStateType(typeof(SwapWithSpirit));
			skillDefInfo.activationStateMachineName = "Dash";
			skillDefInfo.interruptPriority = (InterruptPriority)1;
			skillDefInfo.baseRechargeInterval = 8f;
			skillDefInfo.baseMaxStock = 1;
			skillDefInfo.rechargeStock = 1;
			skillDefInfo.requiredStock = 1;
			skillDefInfo.stockToConsume = 1;
			skillDefInfo.resetCooldownTimerOnUse = false;
			skillDefInfo.fullRestockOnAssign = true;
			skillDefInfo.dontAllowPastMaxStocks = false;
			skillDefInfo.mustKeyPress = true;
			skillDefInfo.beginSkillCooldownOnSkillEnd = false;
			skillDefInfo.isCombatSkill = false;
			skillDefInfo.canceledFromSprinting = false;
			skillDefInfo.cancelSprintingOnActivation = false;
			skillDefInfo.forceSprintDuringState = true;
			SkillDef val = Skills.CreateSkillDef(skillDefInfo);
			Skills.AddUtilitySkills(bodyPrefab, val);
		}

		private void AddSpecialSkills()
		{
			//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_006c: Unknown result type (might be due to invalid IL or missing references)
			SkillDefInfo skillDefInfo = new SkillDefInfo();
			skillDefInfo.skillName = "Redirect";
			skillDefInfo.skillNameToken = "KENKO_SPIRITBOUND_SPECIAL_REDIRECT_NAME";
			skillDefInfo.skillDescriptionToken = "KENKO_SPIRITBOUND_SPECIAL_REDIRECT_DESCRIPTION";
			skillDefInfo.keywordTokens = new string[0];
			skillDefInfo.skillIcon = assetBundle.LoadAsset<Sprite>("texConvictIcon");
			skillDefInfo.activationState = new SerializableEntityStateType(typeof(RedirectSpirit));
			skillDefInfo.activationStateMachineName = "Weapon2";
			skillDefInfo.interruptPriority = (InterruptPriority)2;
			skillDefInfo.baseRechargeInterval = 16f;
			skillDefInfo.baseMaxStock = 1;
			skillDefInfo.rechargeStock = 1;
			skillDefInfo.requiredStock = 1;
			skillDefInfo.stockToConsume = 1;
			skillDefInfo.resetCooldownTimerOnUse = false;
			skillDefInfo.fullRestockOnAssign = true;
			skillDefInfo.dontAllowPastMaxStocks = false;
			skillDefInfo.mustKeyPress = true;
			skillDefInfo.beginSkillCooldownOnSkillEnd = false;
			skillDefInfo.isCombatSkill = true;
			skillDefInfo.canceledFromSprinting = false;
			skillDefInfo.cancelSprintingOnActivation = false;
			skillDefInfo.forceSprintDuringState = false;
			SkillDef val = Skills.CreateSkillDef(skillDefInfo);
			Skills.AddSpecialSkills(bodyPrefab, val);
		}

		public override void InitializeSkins()
		{
			ModelSkinController val = ((Component)prefabCharacterModel).gameObject.AddComponent<ModelSkinController>();
			ChildLocator component = ((Component)prefabCharacterModel).GetComponent<ChildLocator>();
			RendererInfo[] baseRendererInfos = prefabCharacterModel.baseRendererInfos;
			List<SkinDef> list = new List<SkinDef>();
			SkinDef val2 = Skins.CreateSkinDef("DEFAULT_SKIN", assetBundle.LoadAsset<Sprite>("texDefaultSkin"), baseRendererInfos, ((Component)prefabCharacterModel).gameObject);
			val2.meshReplacements = Skins.getMeshReplacements(assetBundle, baseRendererInfos, "meshBody", "meshHair", "meshHorns", "meshLambMask", "meshTrinket", "meshPack", "meshBow");
			list.Add(val2);
			val.skins = list.ToArray();
		}

		public override void InitializeCharacterMaster()
		{
			SpiritboundAI.Init(bodyPrefab, masterName);
		}

		private void AddHooks()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			HUD.onHudTargetChangedGlobal += HUDSetup;
			LoadoutPanelController.Rebuild += new hook_Rebuild(LoadoutPanelController_Rebuild);
			HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage);
			GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal;
			CharacterBody.RecalculateStats += new hook_RecalculateStats(CharacterBody_RecalculateStats);
			if (SpiritboundPlugin.emotesInstalled)
			{
				Emotes();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void Emotes()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__61_0;
			if (obj == null)
			{
				hook_Init val = delegate(orig_Init orig)
				{
					orig.Invoke();
					GameObject val2 = SpiritboundAssets.mainAssetBundle.LoadAsset<GameObject>("spiritbound_emoteskeleton");
					CustomEmotesAPI.ImportArmature(characterPrefab, val2, 0, true);
				};
				<>c.<>9__61_0 = val;
				obj = (object)val;
			}
			SurvivorCatalog.Init += (hook_Init)obj;
		}

		private static void LoadoutPanelController_Rebuild(orig_Rebuild orig, LoadoutPanelController self)
		{
			//IL_000f: 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)
			orig.Invoke(self);
			if (self.currentDisplayData.bodyIndex != BodyCatalog.FindBodyIndex("SpiritboundBody"))
			{
				return;
			}
			LanguageTextMeshController[] componentsInChildren = ((Component)self).gameObject.GetComponentsInChildren<LanguageTextMeshController>();
			foreach (LanguageTextMeshController val in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val) && val.token == "LOADOUT_SKILL_MISC")
				{
					val.token = "Passive";
				}
			}
		}

		private void CharacterBody_RecalculateStats(orig_RecalculateStats orig, CharacterBody self)
		{
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)self) && self.baseNameToken == "KENKO_SPIRITBOUND_NAME" && self.HasBuff(SpiritboundBuffs.spiritMovespeedStacksBuff))
			{
				self.moveSpeed += (float)self.GetBuffCount(SpiritboundBuffs.spiritMovespeedStacksBuff);
			}
		}

		private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if ((NetworkServer.active && self.alive) || !self.godMode || self.ospTimer <= 0f)
			{
				CharacterBody body = self.body;
				CharacterBody val = null;
				if (Object.op_Implicit((Object)(object)damageInfo.attacker))
				{
					val = damageInfo.attacker.GetComponent<CharacterBody>();
				}
				if (damageInfo.damage > 0f && !damageInfo.rejected && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)val) && val.baseNameToken == "KENKO_SPIRIT_NAME")
				{
					SpiritController component = ((Component)val).GetComponent<SpiritController>();
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)body) && DamageAPI.HasModdedDamageType(damageInfo, DamageTypes.CurrentHealthSpirit))
					{
						damageInfo.damage += body.healthComponent.health * (SpiritboundStaticValues.currentHPDamage + (float)component.owner.GetComponent<CharacterBody>().GetBuffCount(SpiritboundBuffs.soulStacksBuff) * SpiritboundStaticValues.currentHpStacking);
					}
				}
			}
			orig.Invoke(self, damageInfo);
		}

		private static void GlobalEventManager_onCharacterDeathGlobal(DamageReport damageReport)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody attackerBody = damageReport.attackerBody;
			if (NetworkServer.active && Object.op_Implicit((Object)(object)attackerBody) && Object.op_Implicit((Object)(object)damageReport.victim) && (damageReport.victim.body.isBoss || damageReport.victim.body.isChampion))
			{
				if (attackerBody.baseNameToken == "KENKO_SPIRITBOUND_NAME")
				{
					StackOrb stackOrb = new StackOrb();
					((Orb)stackOrb).origin = ((Component)damageReport.victim).transform.position;
					((Orb)stackOrb).target = Util.FindBodyMainHurtBox(attackerBody);
					OrbManager.instance.AddOrb((Orb)(object)stackOrb);
				}
				else if (attackerBody.baseNameToken == "KENKO_SPIRIT_NAME")
				{
					StackOrb stackOrb2 = new StackOrb();
					((Orb)stackOrb2).origin = ((Component)damageReport.victim).transform.position;
					((Orb)stackOrb2).target = Util.FindBodyMainHurtBox(((Component)attackerBody).GetComponent<SpiritController>().owner);
					OrbManager.instance.AddOrb((Orb)(object)stackOrb2);
				}
			}
		}

		private static void HUDSetup(HUD hud)
		{
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)hud.targetBodyObject) && Object.op_Implicit((Object)(object)hud.targetMaster) && (Object)(object)hud.targetMaster.bodyPrefab == (Object)(object)characterPrefab && ((NetworkBehaviour)hud.targetMaster).hasAuthority)
			{
				Transform parent = ((Component)hud.equipmentIcons[0]).gameObject.transform.parent;
				Transform val = ((Component)hud).transform.Find("MainContainer").Find("MainUIArea").Find("SpringCanvas")
					.Find("BottomLeftCluster")
					.Find("BarRoots")
					.Find("LevelDisplayCluster");
				GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)hud).transform.Find("MainContainer").Find("MainUIArea").Find("SpringCanvas")
					.Find("BottomLeftCluster"));
				((Object)val2).name = "HealthTracker";
				val2.transform.SetParent(((Component)hud).transform.Find("MainContainer").Find("MainUIArea").Find("CrosshairCanvas")
					.Find("CrosshairExtras"));
				Object.DestroyImmediate((Object)(object)((Component)val2.transform.GetChild(0)).gameObject);
				Object.Destroy((Object)(object)val2.GetComponentInChildren<LevelText>());
				Object.Destroy((Object)(object)val2.GetComponentInChildren<ExpBar>());
				((Component)val2.transform.Find("LevelDisplayRoot").Find("ValueText")).gameObject.SetActive(false);
				Object.DestroyImmediate((Object)(object)((Component)val2.transform.Find("ExpBarRoot")).gameObject);
				((Component)val2.transform.Find("LevelDisplayRoot")).GetComponent<RectTransform>().anchoredPosition = new Vector2(-12f, 0f);
				RectTransform component = val2.GetComponent<RectTransform>();
				((Transform)component).localScale = new Vector3(0.8f, 0.8f, 1f);
				component.anchorMin = new Vector2(0f, 0f);
				component.anchorMax = new Vector2(0f, 0f);
				component.offsetMin = new Vector2(120f, -40f);
				component.offsetMax = new Vector2(120f, -40f);
				component.pivot = new Vector2(0.5f, 0f);
				component.anchoredPosition = new Vector2(50f, 0f);
				((Transform)component).localPosition = new Vector3(120f, -40f, 0f);
				GameObject val3 = Object.Instantiate<GameObject>(SpiritboundAssets.mainAssetBundle.LoadAsset<GameObject>("WeaponChargeBar"));
				((Object)val3).name = "SpiritShieldMeter";
				val3.transform.SetParent(((Component)hud).transform.Find("MainContainer").Find("MainUIArea").Find("CrosshairCanvas")
					.Find("CrosshairExtras"));
				component = val3.GetComponent<RectTransform>();
				((Transform)component).localScale = new Vector3(0.75f, 0.1f, 1f);
				component.anchorMin = new Vector2(100f, 2f);
				component.anchorMax = new Vector2(100f, 2f);
				component.pivot = new Vector2(0.5f, 0f);
				component.anchoredPosition = new Vector2(100f, 2f);
				((Transform)component).localPosition = new Vector3(100f, 2f, 0f);
				((Transform)component).rotation = Quaternion.Euler(new Vector3(0f, 0f, 90f));
				PassiveHealHudController passiveHealHudController = val2.AddComponent<PassiveHealHudController>();
				passiveHealHudController.targetHUD = hud;
				passiveHealHudController.targetText = ((Component)val2.transform.Find("LevelDisplayRoot").Find("PrefixText")).gameObject.GetComponent<LanguageTextMeshController>();
				passiveHealHudController.durationDisplay = val3;
				passiveHealHudController.durationBar = ((Component)val3.transform.GetChild(1)).gameObject.GetComponent<Image>();
				passiveHealHudController.durationBarColor = ((Component)val3.transform.GetChild(0)).gameObject.GetComponent<Image>();
			}
		}
	}
	public class SpiritCharacter : CharacterBase<SpiritCharacter>
	{
		public const string SPIRIT_PREFIX = "KENKO_SPIRIT_";

		internal static GameObject characterPrefab;

		internal static List<string> attackDrivers = new List<string>();

		internal static List<string> spiritItemBlackList = new List<string> { "FreeChest", "TreasureCache", "TreasureCacheVoid", "AutoCastEquipment", "ExtraLife", "ExtraLifeVoid", "DroneWeapons" };

		public override string assetBundleName => "spiritbound";

		public override string bodyName => "SpiritBody";

		public override string modelPrefabName => "mdlSpirit";

		public override BodyInfo bodyInfo => new BodyInfo
		{
			bodyNameToClone = "FlameDrone",
			bodyName = bodyName,
			bodyNameToken = "KENKO_SPIRIT_NAME",
			crosshair = Assets.LoadCrosshair("Standard"),
			subtitleNameToken = "KENKO_SPIRIT_SUBTITLE",
			characterPortrait = assetBundle.LoadAsset<Texture>("texWolfIcon"),
			maxHealth = 100f,
			healthGrowth = 30.000002f,
			healthRegen = 1f,
			armor = 0f,
			moveSpeed = 10f,
			acceleration = 150f
		};

		public override CustomRendererInfo[] customRendererInfos => new CustomRendererInfo[3]
		{
			new CustomRendererInfo
			{
				childName = "Model",
				material = SpiritboundAssets.spiritBodyMat
			},
			new CustomRendererInfo
			{
				childName = "FurModel",
				material = SpiritboundAssets.spiritFurMat
			},
			new CustomRendererInfo
			{
				childName = "MaskModel",
				material = SpiritboundAssets.spiritBodyMat
			}
		};

		public override ItemDisplaysBase itemDisplays => new SpiritItemDisplays();

		public override AssetBundle assetBundle { get; protected set; }

		public override GameObject bodyPrefab { get; protected set; }

		public override CharacterBody prefabCharacterBody { get; protected set; }

		public override GameObject characterModelObject { get; protected set; }

		public override CharacterModel prefabCharacterModel { get; protected set; }

		public override void InitializeCharacter()
		{
			InitializeCharacterBodyPrefab();
			InitializeCharacterMaster();
			InitializeEntityStateMachines();
			InitializeSkills();
			AddHitboxes();
			InitializeSkins();
			AdditionalBodySetup();
			characterPrefab = bodyPrefab;
		}

		private void AdditionalBodySetup()
		{
			bodyPrefab.AddComponent<SpiritController>();
		}

		public void AddHitboxes()
		{
			Prefabs.SetupHitBoxGroup(characterModelObject, "MeleeHitbox", "MeleeHitbox");
		}

		public override void InitializeEntityStateMachines()
		{
			Prefabs.ClearEntityStateMachines(bodyPrefab);
			Prefabs.AddMainEntityStateMachine(bodyPrefab, "Body", typeof(SpiritMainState), typeof(SpawnTeleporterState));
			Prefabs.AddEntityStateMachine(bodyPrefab, "Weapon");
			Prefabs.AddEntityStateMachine(bodyPrefab, "Weapon2");
			AkEvent[] components = bodyPrefab.GetComponents<AkEvent>();
			foreach (AkEvent val in components)
			{
				Object.DestroyImmediate((Object)(object)val);
			}
		}

		public override void InitializeCharacterMaster()
		{
			//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)
			GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Drones/FlameDroneMaster.prefab").WaitForCompletion(), "SpiritMaster");
			CharacterMaster component = val.GetComponent<CharacterMaster>();
			component.bodyPrefab = bodyPrefab;
			BaseAI component2 = val.GetComponent<BaseAI>();
			component2.aimVectorMaxSpeed = 5000f;
			component2.aimVectorDampTime = 0.01f;
			AddSkillDrivers(val);
			SpiritboundMod.Modules.Content.AddMasterPrefab(val);
			SpiritMasterComponent.summonPrefab = val;
		}

		private void AddSkillDrivers(GameObject masterPrefab)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0659: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0719: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Unknown result type (might be due to invalid IL or missing references)
			//IL_073d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f5: Unknown result type (might be due to invalid IL or missing references)
			AISkillDriver[] componentsInChildren = masterPrefab.GetComponentsInChildren<AISkillDriver>();
			foreach (AISkillDriver val in componentsInChildren)
			{
				Object.DestroyImmediate((Object)(object)val);
			}
			AISkillDriver val2 = masterPrefab.AddComponent<AISkillDriver>();
			val2.customName = "BiteOffNodeGraph";
			val2.skillSlot = (SkillSlot)0;
			val2.requireSkillReady = true;
			val2.minUserHealthFraction = float.NegativeInfinity;
			val2.maxUserHealthFraction = float.PositiveInfinity;
			val2.minTargetHealthFraction = float.NegativeInfinity;
			val2.maxTargetHealthFraction = float.PositiveInfinity;
			val2.minDistance = 0f;
			val2.maxDistance = 5f;
			val2.activationRequiresAimConfirmation = false;
			val2.activationRequiresTargetLoS = false;
			val2.selectionRequiresTargetLoS = true;
			val2.maxTimesSelected = -1;
			val2.moveTargetType = (TargetType)0;
			val2.movementType = (MovementType)1;
			val2.aimType = (AimType)1;
			val2.moveInputScale = 1f;
			val2.ignoreNodeGraph = true;
			val2.buttonPressType = (ButtonPressType)0;
			if (!attackDrivers.Contains(val2.customName))
			{
				attackDrivers.Add(val2.customName);
			}
			AISkillDriver val3 = masterPrefab.AddComponent<AISkillDriver>();
			val3.customName = "FireWisps";
			val3.skillSlot = (SkillSlot)1;
			val3.requireSkillReady = true;
			val3.minUserHealthFraction = float.NegativeInfinity;
			val3.maxUserHealthFraction = float.PositiveInfinity;
			val3.minTargetHealthFraction = float.NegativeInfinity;
			val3.maxTargetHealthFraction = float.PositiveInfinity;
			val3.minDistance = 0f;
			val3.maxDistance = 20f;
			val3.activationRequiresAimConfirmation = true;
			val3.activationRequiresTargetLoS = true;
			val3.selectionRequiresTargetLoS = true;
			val3.maxTimesSelected = -1;
			val3.moveTargetType = (TargetType)0;
			val3.movementType = (MovementType)1;
			val3.aimType = (AimType)1;
			val3.moveInputScale = 1f;
			val3.ignoreNodeGraph = false;
			val3.buttonPressType = (ButtonPressType)0;
			if (!attackDrivers.Contains(val3.customName))
			{
				attackDrivers.Add(val3.customName);
			}
			AISkillDriver val4 = masterPrefab.AddComponent<AISkillDriver>();
			val4.customName = "StrafeNearTarget";
			val4.skillSlot = (SkillSlot)(-1);
			val4.requireSkillReady = true;
			val4.minUserHealthFraction = float.NegativeInfinity;
			val4.maxUserHealthFraction = float.PositiveInfinity;
			val4.minTargetHealthFraction = float.NegativeInfinity;
			val4.maxTargetHealthFraction = float.PositiveInfinity;
			val4.minDistance = 0f;
			val4.maxDistance = 5f;
			val4.activationRequiresAimConfirmation = false;
			val4.activationRequiresTargetLoS = false;
			val4.selectionRequiresTargetLoS = true;
			val4.maxTimesSelected = -1;
			val4.moveTargetType = (TargetType)0;
			val4.movementType = (MovementType)2;
			val4.aimType = (AimType)1;
			val4.moveInputScale = 1f;
			val4.ignoreNodeGraph = true;
			val4.buttonPressType = (ButtonPressType)0;
			if (!attackDrivers.Contains(val4.customName))
			{
				attackDrivers.Add(val4.customName);
			}
			AISkillDriver val5 = masterPrefab.AddComponent<AISkillDriver>();
			val5.customName = "ChaseTargetClose";
			val5.skillSlot = (SkillSlot)(-1);
			val5.requireSkillReady = true;
			val5.minUserHealthFraction = float.NegativeInfinity;
			val5.maxUserHealthFraction = float.PositiveInfinity;
			val5.minTargetHealthFraction = float.NegativeInfinity;
			val5.maxTargetHealthFraction = float.PositiveInfinity;
			val5.minDistance = 0f;
			val5.maxDistance = 10f;
			val5.activationRequiresAimConfirmation = false;
			val5.activationRequiresTargetLoS = false;
			val5.selectionRequiresTargetLoS = true;
			val5.maxTimesSelected = -1;
			val5.moveTargetType = (TargetType)0;
			val5.movementType = (MovementType)1;
			val5.aimType = (AimType)1;
			val5.moveInputScale = 1f;
			val5.ignoreNodeGraph = true;
			val5.buttonPressType = (ButtonPressType)0;
			if (!attackDrivers.Contains(val5.customName))
			{
				attackDrivers.Add(val5.customName);
			}
			AISkillDriver val6 = masterPrefab.AddComponent<AISkillDriver>();
			val6.customName = "ChaseFromAfar";
			val6.skillSlot = (SkillSlot)(-1);
			val6.requireSkillReady = true;
			val6.minUserHealthFraction = float.NegativeInfinity;
			val6.maxUserHealthFraction = float.PositiveInfinity;
			val6.minTargetHealthFraction = float.NegativeInfinity;
			val6.maxTargetHealthFraction = float.PositiveInfinity;
			val6.minDistance = 0f;
			val6.maxDistance = float.PositiveInfinity;
			val6.activationRequiresAimConfirmation = false;
			val6.activationRequiresTargetLoS = false;
			val6.selectionRequiresTargetLoS = false;
			val6.maxTimesSelected = -1;
			val6.moveTargetType = (TargetType)0;
			val6.movementType = (MovementType)1;
			val6.aimType = (AimType)1;
			val6.moveInputScale = 1f;
			val6.ignoreNodeGraph = false;
			val6.buttonPressType = (ButtonPressType)0;
			val6.shouldSprint = true;
			if (!attackDrivers.Contains(val6.customName))
			{
				attackDrivers.Add(val6.customName);
			}
			AISkillDriver val7 = masterPrefab.AddComponent<AISkillDriver>();
			val7.customName = "DoNothing";
			val7.skillSlot = (SkillSlot)(-1);
			val7.requireSkillReady = true;
			val7.minUserHealthFraction = float.NegativeInfinity;
			val7.maxUserHealthFraction = float.PositiveInfinity;
			val7.minTargetHealthFraction = float.NegativeInfinity;
			val7.maxTargetHealthFraction = float.PositiveInfinity;
			val7.minDistance = 0f;
			val7.maxDistance = float.PositiveInfinity;
			val7.activationRequiresAimConfirmation = false;
			val7.activationRequiresTargetLoS = false;
			val7.selectionRequiresTargetLoS = false;
			val7.maxTimesSelected = -1;
			val7.moveTargetType = (TargetType)0;
			val7.movementType = (MovementType)0;
			val7.aimType = (AimType)0;
			val7.moveInputScale = 1f;
			val7.ignoreNodeGraph = false;
			val7.buttonPressType = (ButtonPressType)0;
			if (!attackDrivers.Contains(val7.customName))
			{
				attackDrivers.Add(val7.customName);
			}
			AISkillDriver val8 = masterPrefab.AddComponent<AISkillDriver>();
			val8.customName = "HardLeashToLeader";
			val8.movementType = (MovementType)1;
			val8.moveTargetType = (TargetType)2;
			val8.activationRequiresAimConfirmation = false;
			val8.activationRequiresTargetLoS = false;
			val8.selectionRequiresTargetLoS = false;
			val8.maxTimesSelected = -1;
			val8.maxDistance = float.PositiveInfinity;
			val8.minDistance = 120f;
			val8.requireSkillReady = false;
			val8.aimType = (AimType)3;
			val8.ignoreNodeGraph = false;
			val8.moveInputScale = 1f;
			val8.driverUpdateTimerOverride = -1f;
			val8.shouldSprint = true;
			val8.shouldFireEquipment = false;
			val8.buttonPressType = (ButtonPressType)0;
			val8.minTargetHealthFraction = float.NegativeInfinity;
			val8.maxTargetHealthFraction = float.PositiveInfinity;
			val8.minUserHealthFraction = float.NegativeInfinity;
			val8.maxUserHealthFraction = float.PositiveInfinity;
			val8.skillSlot = (SkillSlot)(-1);
			AISkillDriver val9 = masterPrefab.AddComponent<AISkillDriver>();
			val9.customName = "SoftLeashToLeader";
			val9.movementType = (MovementType)1;
			val9.moveTargetType = (TargetType)2;
			val9.activationRequiresAimConfirmation = false;
			val9.activationRequiresTargetLoS = false;
			val9.selectionRequiresTargetLoS = false;
			val9.maxTimesSelected = -1;
			val9.maxDistance = float.PositiveInfinity;
			val9.minDistance = 10f;
			val9.requireSkillReady = false;
			val9.aimType = (AimType)2;
			val9.ignoreNodeGraph = false;
			val9.moveInputScale = 1f;
			val9.driverUpdateTimerOverride = -1f;
			val9.shouldSprint = false;
			val9.shouldFireEquipment = false;
			val9.buttonPressType = (ButtonPressType)0;
			val9.minTargetHealthFraction = float.NegativeInfinity;
			val9.maxTargetHealthFraction = float.PositiveInfinity;
			val9.minUserHealthFraction = float.NegativeInfinity;
			val9.maxUserHealthFraction = float.PositiveInfinity;
			val9.skillSlot = (SkillSlot)(-1);
			AISkillDriver val10 = masterPrefab.AddComponent<AISkillDriver>();
			val10.customName = "IdleNearLeader";
			val10.movementType = (MovementType)0;
			val10.moveTargetType = (TargetType)2;
			val10.activationRequiresAimConfirmation = false;
			val10.activationRequiresTargetLoS = false;
			val10.selectionRequiresTargetLoS = false;
			val10.maxTimesSelected = -1;
			val10.maxDistance = float.PositiveInfinity;
			val10.minDistance = 0f;
			val10.requireSkillReady = false;
			val10.aimType = (AimType)2;
			val10.ignoreNodeGraph = false;
			val10.moveInputScale = 1f;
			val10.driverUpdateTimerOverride = -1f;
			val10.shouldSprint = false;
			val10.shouldFireEquipment = false;
			val10.buttonPressType = (ButtonPressType)0;
			val10.minTargetHealthFraction = float.NegativeInfinity;
			val10.maxTargetHealthFraction = float.PositiveInfinity;
			val10.minUserHealthFraction = float.NegativeInfinity;
			val10.maxUserHealthFraction = float.PositiveInfinity;
			val10.skillSlot = (SkillSlot)(-1);
		}

		public override void InitializeSkills()
		{
			bodyPrefab.AddComponent<SpiritboundPassive>();
			Skills.CreateSkillFamilies(bodyPrefab);
			AddPassiveSkills();
			AddPrimarySkills();
			AddSecondarySkills();
			AddUtilitySkills();
			AddSpecialSkills();
		}

		private void AddPassiveSkills()
		{
			//IL_007a: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			SpiritboundPassive component = bodyPrefab.GetComponent<SpiritboundPassive>();
			SkillLocator component2 = bodyPrefab.GetComponent<SkillLocator>();
			component2.passiveSkill.enabled = false;
			component.spiritboundPassive = Skills.CreateSkillDef(new SkillDefInfo
			{
				skillName = "KENKO_SPIRIT_PASSIVE_NAME",
				skillNameToken = "KENKO_SPIRIT_PASSIVE_NAME",
				skillDescriptionToken = "KENKO_SPIRIT_PASSIVE_DESCRIPTION",
				skillIcon = assetBundle.LoadAsset<Sprite>("texDefaultSkin"),
				keywordTokens = new string[0],
				activationState = new SerializableEntityStateType(typeof(Idle)),
				activationStateMachineName = "",
				baseMaxStock = 1,
				baseRechargeInterval = 0f,
				beginSkillCooldownOnSkillEnd = false,
				canceledFromSprinting = false,
				forceSprintDuringState = false,
				fullRestockOnAssign = true,
				interruptPriority = (InterruptPriority)0,
				resetCooldownTimerOnUse = false,
				isCombatSkill = false,
				mustKeyPress = false,
				cancelSprintingOnActivation = false,
				rechargeStock = 1,
				requiredStock = 2,
				stockToConsume = 1
			});
			Skills.AddPassiveSkills(component.passiveSkillSlot.skillFamily, component.spiritboundPassive);
		}

		private void AddPrimarySkills()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			SteppedSkillDef val = Skills.CreateSkillDef<SteppedSkillDef>(new SkillDefInfo("Bite", "KENKO_SPIRIT_PRIMARY_BITE_NAME", "KENKO_SPIRIT_PRIMARY_BITE_DESCRIPTION", assetBundle.LoadAsset<Sprite>("texSpiritBiteIcon"), new SerializableEntityStateType(typeof(SpiritBite))));
			val.stepCount = 1;
			val.stepGraceDuration = 0.1f;
			Skills.AddPrimarySkills(bodyPrefab, (SkillDef)val);
		}

		private void AddSecondarySkills()
		{
			//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_006c: Unknown result type (might be due to invalid IL or missing references)
			SkillDefInfo skillDefInfo = new SkillDefInfo();
			skillDefInfo.skillName = "Fire Orb";
			skillDefInfo.skillNameToken = "KENKO_SPIRIT_SECONDARY_ORB_NAME";
			skillDefInfo.skillDescriptionToken = "KENKO_SPIRIT_SECONDARY_ORB_DESCRIPTION";
			skillDefInfo.keywordTokens = new string[0];
			skillDefInfo.skillIcon = assetBundle.LoadAsset<Sprite>("texSpiritOrbIcon");
			skillDefInfo.activationState = new SerializableEntityStateType(typeof(SpiritBarrage));
			skillDefInfo.activationStateMachineName = "Weapon2";
			skillDefInfo.interruptPriority = (InterruptPriority)2;
			skillDefInfo.baseMaxStock = 1;
			skillDefInfo.baseRechargeInterval = 3f;
			skillDefInfo.rechargeStock = 1;
			skillDefInfo.requiredStock = 1;
			skillDefInfo.stockToConsume = 1;
			skillDefInfo.resetCooldownTimerOnUse = false;
			skillDefInfo.fullRestockOnAssign = true;
			skillDefInfo.dontAllowPastMaxStocks = false;
			skillDefInfo.beginSkillCooldownOnSkillEnd = true;
			skillDefInfo.mustKeyPress = false;
			skillDefInfo.isCombatSkill = true;
			skillDefInfo.canceledFromSprinting = false;
			skillDefInfo.cancelSprintingOnActivation = false;
			skillDefInfo.forceSprintDuringState = false;
			SkillDef val = Skills.CreateSkillDef(skillDefInfo);
			Skills.AddSecondarySkills(bodyPrefab, val);
		}

		private void AddUtilitySkills()
		{
			//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_006c: Unknown result type (might be due to invalid IL or missing references)
			SkillDefInfo skillDefInfo = new SkillDefInfo();
			skillDefInfo.skillName = "Idle";
			skillDefInfo.skillNameToken = "KENKO_SPIRIT_IDLE_NAME";
			skillDefInfo.skillDescriptionToken = "KENKO_SPIRIT_IDLE_DESCRIPTION";
			skillDefInfo.keywordTokens = new string[0];
			skillDefInfo.skillIcon = assetBundle.LoadAsset<Sprite>("texFalsifyIcon");
			skillDefInfo.activationState = new SerializableEntityStateType(typeof(SpiritMainState));
			skillDefInfo.activationStateMachineName = "Weapon";
			skillDefInfo.interruptPriority = (InterruptPriority)1;
			skillDefInfo.baseRechargeInterval = 6f;
			skillDefInfo.baseMaxStock = 1;
			skillDefInfo.rechargeStock = 1;
			skillDefInfo.requiredStock = 1;
			skillDefInfo.stockToConsume = 1;
			skillDefInfo.resetCooldownTimerOnUse = false;
			skillDefInfo.fullRestockOnAssign = true;
			skillDefInfo.dontAllowPastMaxStocks = false;
			skillDefInfo.mustKeyPress = false;
			skillDefInfo.beginSkillCooldownOnSkillEnd = false;
			skillDefInfo.isCombatSkill = false;
			skillDefInfo.canceledFromSprinting = false;
			skillDefInfo.cancelSprintingOnActivation = false;
			skillDefInfo.forceSprintDuringState = true;
			SkillDef val = Skills.CreateSkillDef(skillDefInfo);
			Skills.AddUtilitySkills(bodyPrefab, val);
		}

		private void AddSpecialSkills()
		{
			//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_006c: Unknown result type (might be due to invalid IL or missing references)
			SkillDefInfo skillDefInfo = new SkillDefInfo();
			skillDefInfo.skillName = "Idle";
			skillDefInfo.skillNameToken = "KENKO_SPIRIT_IDLE_NAME";
			skillDefInfo.skillDescriptionToken = "KENKO_SPIRIT_IDLE_DESCRIPTION";
			skillDefInfo.keywordTokens = new string[0];
			skillDefInfo.skillIcon = assetBundle.LoadAsset<Sprite>("texFalsifyIcon");
			skillDefInfo.activationState = new SerializableEntityStateType(typeof(SpiritMainState));
			skillDefInfo.activationStateMachineName = "Weapon";
			skillDefInfo.interruptPriority = (InterruptPriority)1;
			skillDefInfo.baseRechargeInterval = 6f;
			skillDefInfo.baseMaxStock = 1;
			skillDefInfo.rechargeStock = 1;
			skillDefInfo.requiredStock = 1;
			skillDefInfo.stockToConsume = 1;
			skillDefInfo.resetCooldownTimerOnUse = false;
			skillDefInfo.fullRestockOnAssign = true;
			skillDefInfo.dontAllowPastMaxStocks = false;
			skillDefInfo.mustKeyPress = false;
			skillDefInfo.beginSkillCooldownOnSkillEnd = false;
			skillDefInfo.isCombatSkill = false;
			skillDefInfo.canceledFromSprinting = false;
			skillDefInfo.cancelSprintingOnActivation = false;
			skillDefInfo.forceSprintDuringState = true;
			SkillDef val = Skills.CreateSkillDef(skillDefInfo);
			Skills.AddSpecialSkills(bodyPrefab, val);
		}

		public override void InitializeSkins()
		{
			ModelSkinController val = ((Component)prefabCharacterModel).gameObject.AddComponent<ModelSkinController>();
			ChildLocator component = ((Component)prefabCharacterModel).GetComponent<ChildLocator>();
			RendererInfo[] baseRendererInfos = prefabCharacterModel.baseRendererInfos;
			List<SkinDef> list = new List<SkinDef>();
			SkinDef val2 = Skins.CreateSkinDef("DEFAULT_SKIN", assetBundle.LoadAsset<Sprite>("texDefaultSkin"), baseRendererInfos, ((Component)prefabCharacterModel).gameObject);
			val2.meshReplacements = Skins.getMeshReplacements(assetBundle, baseRendererInfos, "meshSpiritBody", "meshFur", "meshSpiritMask");
			list.Add(val2);
			val.skins = list.ToArray();
		}
	}
}
namespace SpiritboundMod.Spiritbound.SkillStates
{
	public class ChargeArrow : BaseSpiritboundSkillState
	{
		private GameObject chargeEffectPrefab = SpiritboundAssets.chargeEffect;

		private GameObject chargeFullEffectPrefab = SpiritboundAssets.fullChargeEffect;

		private GameObject muzzleFlashEffectPrefab = SpiritboundAssets.arrowMuzzleFlashEffect;

		private GameObject arrowPrefab = SpiritboundAssets.arrowPrefab;

		private GameObject arrowChargedPrefab = SpiritboundAssets.chargedArrowPrefab;

		public static float baseChargeDuration = 1f;

		public static float baseMaxChargeDuration = 2f;

		public static float minBloomRadius = 0f;

		public static float maxBloomRadius = 0.5f;

		public static float minChargeDuration = 0.3f;

		public static string muzzleName = "BowMuzzle";

		public static float fullChargeAnimationDuration = 0.34f;

		public float chargeDuration;

		public float maxChargeDuration;

		public Animator animator;

		public Transform muzzleTransform;

		public GameObject chargeEffectInstance;

		public uint loopSoundInstanceId;

		public bool playedFullChargeEffects = false;

		public override void OnEnter()
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			base.OnEnter();
			chargeDuration = baseChargeDuration / ((BaseState)this).attackSpeedStat;
			maxChargeDuration = baseMaxChargeDuration / ((BaseState)this).attackSpeedStat;
			if (NetworkServer.active && ((EntityState)this).characterBody.GetBuffCount(SpiritboundBuffs.quickShotBuff) > 0)
			{
				chargeDuration /= 2f;
				maxChargeDuration = chargeDuration;
			}
			animator = ((EntityState)this).GetModelAnimator();
			ChildLocator modelChildLocator = ((EntityState)this).GetModelChildLocator();
			if (Object.op_Implicit((Object)(object)modelChildLocator))
			{
				muzzleTransform = modelChildLocator.FindChild(muzzleName) ?? ((EntityState)this).characterBody.coreTransform;
				if (Object.op_Implicit((Object)(object)muzzleTransform) && Object.op_Implicit((Object)(object)chargeEffectPrefab))
				{
					chargeEffectInstance = Object.Instantiate<GameObject>(chargeEffectPrefab, muzzleTransform.position, muzzleTransform.rotation);
					chargeEffectInstance.transform.parent = muzzleTransform;
					ScaleParticleSystemDuration component = chargeEffectInstance.GetComponent<ScaleParticleSystemDuration>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.newDuration = chargeDuration;
					}
					ObjectScaleCurve component2 = chargeEffectInstance.GetComponent<ObjectScaleCurve>();
					if (Object.op_Implicit((Object)(object)component2))
					{
						component2.timeMax = chargeDuration;
					}
				}
			}
			Util.PlayAttackSpeedSound("Play_MULT_m1_snipe_charge", ((EntityState)this).gameObject, ((BaseState)this).attackSpeedStat);
			((EntityState)this).PlayAnimation("Gesture, Override", "ChargeArrow");
		}

		public float CalcCharge()
		{
			return Mathf.Clamp01(((EntityState)this).fixedAge / chargeDuration);
		}

		public override void Update()
		{
			((EntityState)this).Update();
			((EntityState)this).characterBody.SetAimTimer(1f);
			((EntityState)this).characterBody.SetSpreadBloom(((EntityState)this).age / chargeDuration, true);
		}

		public override void FixedUpdate()
		{
			base.FixedUpdate();
			float num = CalcCharge();
			if (!playedFullChargeEffects && num >= 1f)
			{
				playedFullChargeEffects = true;
				PlayFullChargeEffects();
			}
			if (((EntityState)this).isAuthority && (!((BaseSkillState)this).IsKeyDownAuthority() || ((EntityState)this).fixedAge >= maxChargeDuration) && ((EntityState)this).fixedAge >= minChargeDuration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public void PlayFullChargeEffects()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			AkSoundEngine.StopPlayingID(loopSoundInstanceId);
			if (Object.op_Implicit((Object)(object)chargeEffectInstance))
			{
				EntityState.Destroy((Object)(object)chargeEffectInstance);
			}
			EffectManager.SimpleMuzzleFlash(muzzleFlashEffectPrefab, ((EntityState)this).gameObject, muzzleName, false);
			chargeEffectInstance = Object.Instantiate<GameObject>(chargeFullEffectPrefab, muzzleTransform.position, muzzleTransform.rotation);
			chargeEffectInstance.transform.parent = muzzleTransform;
			loopSoundInstanceId = Util.PlaySound("Play_gravekeeper_attack1_fly_loop", ((EntityState)this).gameObject);
		}

		public void FireArrowAuthority()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			float num = CalcCharge();
			Ray aimRay = ((BaseState)this).GetAimRay();
			Util.PlaySound("Play_huntress_m1_shoot", ((EntityState)this).gameObject);
			if (num >= 1f)
			{
				Util.PlaySound("Play_clayboss_m1_shoot", ((EntityState)this).gameObject);
			}
			Quaternion val = Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction);
			float num2 = Random.Range(0f, ((EntityState)this).characterBody.spreadBloomAngle);
			float num3 = Random.Range(0f, 360f);
			Vector3 val2 = Quaternion.Euler(0f, 0f, num3) * (Quaternion.Euler(num2, 0f, 0f) * Vector3.forward);
			float y = val2.y;
			val2.y = 0f;
			float num4 = (Mathf.Atan2(val2.z, val2.x) * 57.29578f - 90f) * 1f;
			float num5 = Mathf.Atan2(y, ((Vector3)(ref val2)).magnitude) * 57.29578f * 1f;
			arrowChargedPrefab.GetComponent<ModdedDamageTypeHolderComponent>().Add(DamageTypes.MountingDread);
			if (((EntityState)this).characterBody.HasBuff(SpiritboundBuffs.spiritHealBuff))
			{
				arrowPrefab.GetComponent<ModdedDamageTypeHolderComponent>().Add(DamageTypes.Heal);
				arrowChargedPrefab.GetComponent<ModdedDamageTypeHolderComponent>().Add(DamageTypes.Heal);
			}
			FireProjectileInfo val3 = default(FireProjectileInfo);
			val3.damage = Util.Remap(num, 0f, 1f, SpiritboundStaticValues.arrowBaseDamageCoefficient, SpiritboundStaticValues.arrowFullDamageCoefficient) * ((BaseState)this).damageStat;
			val3.useSpeedOverride = true;
			((FireProjectileInfo)(ref val3)).speedOverride = Util.Remap(num, 0f, 1f, 50f + (float)(((EntityState)this).characterBody.GetBuffCount(SpiritboundBuffs.soulStacksBuff) * 5), 150f + (float)(((EntityState)this).characterBody.GetBuffCount(SpiritboundBuffs.soulStacksBuff) * 5));
			val3.crit = ((EntityState)this).characterBody.RollCrit();
			val3.position = ((Ray)(ref aimRay)).origin;
			val3.rotation = ((num < 1f) ? val : Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction));
			val3.owner = ((EntityState)this).gameObject;
			val3.force = 400f * num;
			val3.projectilePrefab = ((num < 1f) ? arrowPrefab : arrowChargedPrefab);
			FireProjectileInfo val4 = val3;
			ProjectileManager.instance.FireProjectile(val4);
		}

		public override void OnExit()
		{
			AkSoundEngine.StopPlayingID(loopSoundInstanceId);
			if (!((EntityState)this).outer.destroying)
			{
				((EntityState)this).PlayAnimation("Gesture, Override", "FireArrow");
				if (((EntityState)this).isAuthority)
				{
					FireArrowAuthority();
				}
			}
			if (Object.op_Implicit((Object)(object)chargeEffectInstance))
			{
				EntityState.Destroy((Object)(object)chargeEffectInstance);
			}
			if (NetworkServer.active && ((EntityState)this).characterBody.GetBuffCount(SpiritboundBuffs.quickShotBuff) > 0)
			{
				((EntityState)this).characterBody.RemoveBuff(SpiritboundBuffs.quickShotBuff);
			}
			((EntityState)this).OnExit();
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)2;
		}
	}
	public class HopFire : BaseSpiritboundSkillState
	{
		private GameObject muzzleFlashEffect = SpiritboundAssets.arrowMuzzleFlashEffect;

		protected Vector3 hopVector;

		public float duration = 0.3f;

		public float speedCoefficient = 7f;

		public float orbDamageCoefficient = SpiritboundStaticValues.wispDamageCoefficient;

		private ChildLocator childLocator;

		protected AimRequest request;

		private bool fired = false;

		private bool isCrit;

		public override void OnEnter()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			RefreshState();
			base.OnEnter();
			((EntityState)this).characterBody.SetAimTimer(2f);
			Transform modelTransform = ((EntityState)this).GetModelTransform();
			if (Object.op_Implicit((Object)(object)modelTransform))
			{
				childLocator = ((Component)modelTransform).GetComponent<ChildLocator>();
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).cameraTargetParams))
			{
				request = ((EntityState)this).cameraTargetParams.RequestAimType((AimType)2);
			}
			hopVector = GetHopVector();
			((EntityState)this).characterMotor.velocity = Vector3.zero;
			Vector3 aimDirection = ((EntityState)this).inputBank.aimDirection;
			aimDirection.y = 0f;
			if ((((EntityState)this).inputBank.aimDirection.y < 0f && Vector3.Angle(aimDirection, hopVector) <= 90f) || (((EntityState)this).inputBank.aimDirection.y > 0f && Vector3.Angle(aimDirection, hopVector) >= 90f))
			{
				hopVector.y *= -1f;
			}
			if (Vector3.Angle(((EntityState)this).inputBank.aimDirection, aimDirection) <= 45f)
			{
				hopVector.y = 0.25f;
			}
			hopVector.y = Mathf.Clamp(hopVector.y, 0.1f, 0.75f);
			((EntityState)this).characterDirection.moveVector = hopVector;
			((EntityState)this).PlayCrossfade("FullBody, Override", "Dash", "Dash.playbackRate", duration * 1.5f, 0.05f);
			((EntityState)this).PlayAnimation("Gesture, Override", "BufferEmpty");
			if (Object.op_Implicit((Object)(object)BaseSlideState.slideEffectPrefab) && Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
			{
				Vector3 val = ((EntityState)this).characterBody.footPosition;
				Quaternion val2 = Quaternion.identity;
				Transform val3 = ((BaseState)this).FindModelChild("Base");
				if (Object.op_Implicit((Object)(object)val3))
				{
					val = val3.position;
				}
				if (Object.op_Implicit((Object)(object)((EntityState)this).characterDirection))
				{
					val2 = Util.QuaternionSafeLookRotation(hopVector);
				}
				EffectManager.SimpleEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/FeatherEffect"), val, val2, true);
			}
			speedCoefficient = 0.3f * ((EntityState)this).characterBody.jumpPower * Mathf.Clamp(((EntityState)this).characterBody.moveSpeed / 4f, 5f, 20f);
			isCrit = Util.CheckRoll(((EntityState)this).characterBody.crit, ((EntityState)this).characterBody.master);
			if (NetworkServer.active)
			{
				((EntityState)this).characterBody.AddBuff(Buffs.HiddenInvincibility);
			}
			Util.PlaySound("sfx_driver_dash", ((EntityState)this).gameObject);
		}

		protected virtual Vector3 GetHopVector()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			Vector3 aimDirection = ((EntityState)this).inputBank.aimDirection;
			aimDirection.y = 0f;
			Vector3 val = -Vector3.Cross(Vector3.up, aimDirection);
			float num = Vector3.Angle(((EntityState)this).inputBank.aimDirection, aimDirection);
			if (((EntityState)this).inputBank.aimDirection.y < 0f)
			{
				num = 0f - num;
			}
			return Vector3.Normalize(Quaternion.AngleAxis(num, val) * ((EntityState)this).inputBank.moveVector);
		}

		public override void FixedUpdate()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			base.FixedUpdate();
			if (((EntityState)this).fixedAge >= duration / 2f && !fired)
			{
				fired = true;
				Fire();
				EntityStateMachine.FindByCustomName(((EntityState)this).gameObject, "Weapon2").SetInterruptState((EntityState)(object)new SpiritBarrage(), (InterruptPriority)2);
				spiritMasterComponent.SpiritOrbOrder();
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor) && Object.op_Implicit((Object)(object)((EntityState)this).characterDirection) && ((EntityState)this).isAuthority)
			{
				((BaseCharacterController)((EntityState)this).characterMotor).Motor.ForceUnground();
				((EntityState)this).characterMotor.velocity = hopVector * speedCoefficient;
			}
			if (((EntityState)this).fixedAge >= duration && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		protected virtual GenericDamageOrb CreateArrowOrb()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			return (GenericDamageOrb)new HuntressArrowOrb();
		}

		private void Fire()
		{
			//IL_000e: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			HurtBox[] hurtBoxes = new SphereSearch
			{
				origin = ((EntityState)this).transform.position,
				radius = 20f,
				mask = ((LayerIndex)(ref LayerIndex.entityPrecise)).mask
			}.RefreshCandidates().FilterCandidatesByHurtBoxTeam(TeamMask.GetEnemyTeams(((EntityState)this).characterBody.teamComponent.teamIndex)).OrderCandidatesByDistance()
				.FilterCandidatesByDistinctHurtBoxEntities()
				.GetHurtBoxes();
			if (hurtBoxes.Length == 0)
			{
				return;
			}
			int num = Mathf.Clamp(hurtBoxes.Length, 1, 3 + ((EntityState)this).characterBody.GetBuffCount(SpiritboundBuffs.soulStacksBuff));
			for (int i = 0; i < num; i++)
			{
				GenericDamageOrb val = CreateArrowOrb();
				val.damageValue = ((EntityState)this).characterBody.damage * SpiritboundStaticValues.arrowBaseDamageCoefficient;
				val.isCrit = isCrit;
				val.teamIndex = TeamComponent.GetObjectTeam(((EntityState)this).gameObject);
				val.attacker = ((EntityState)this).gameObject;
				val.procCoefficient = 0.7f;
				HurtBox val2 = hurtBoxes[i];
				if (Object.op_Implicit((Object)(object)val2))
				{
					Transform val3 = childLocator.FindChild("BowMuzzle");
					EffectManager.SimpleMuzzleFlash(muzzleFlashEffect, ((EntityState)this).gameObject, "BowMuzzle", true);
					((Orb)val).origin = val3.position;
					((Orb)val).target = val2;
					OrbManager.instance.AddOrb((Orb)(object)val);
				}
			}
		}

		public override void OnExit()
		{
			if (!fired)
			{
				Fire();
			}
			if (!((EntityState)this).outer.destroying && Object.op_Implicit((Object)(object)((EntityState)this).cameraTargetParams))
			{
				request.Dispose();
			}
			((EntityState)this).OnExit();
			if (NetworkServer.active)
			{
				((EntityState)this).characterBody.RemoveBuff(Buffs.HiddenInvincibility);
				for (int num = 5 - ((EntityState)this).characterBody.GetBuffCount(SpiritboundBuffs.quickShotBuff); num > 0; num--)
				{
					((EntityState)this).characterBody.AddTimedBuff(SpiritboundBuffs.quickShotBuff, 4f);
				}
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)4;
		}
	}
	public class MainState : GenericCharacterMain
	{
		private Animator animator;

		public LocalUser localUser;

		public override void OnEnter()
		{
			((GenericCharacterMain)this).OnEnter();
			animator = ((BaseCharacterMain)this).modelAnimator;
			FindLocalUser();
		}

		private void FindLocalUser()
		{
			if (localUser != null || !Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
			{
				return;
			}
			foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList)
			{
				if ((Object)(object)readOnlyLocalUsers.cachedBody == (Object)(object)((EntityState)this).characterBody)
				{
					localUser = readOnlyLocalUsers;
					break;
				}
			}
		}

		public override void FixedUpdate()
		{
			((GenericCharacterMain)this).FixedUpdate();
			if (Object.op_Implicit((Object)(object)animator))
			{
				bool flag = false;
				if (!((EntityState)this).characterBody.outOfDanger || !((EntityState)this).characterBody.outOfCombat)
				{
					flag = true;
				}
				animator.SetBool("inCombat", flag);
				if (((BaseState)this).isGrounded)
				{
					animator.SetFloat("airBlend", 0f);
				}
				else
				{
					animator.SetFloat("airBlend", 1f);
				}
			}
		}

		public override void ProcessJump()
		{
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Expected O, but got Unknown
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			if (!((BaseCharacterMain)this).hasCharacterMotor)
			{
				return;
			}