Decompiled source of SpookifiedMod v0.2.0

Terren-HalloweenMod.dll

Decompiled 11 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using DM;
using HalloweenMod.Classes;
using HalloweenMod.Patches;
using HalloweenMod.Tags;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.GameMode;
using Landfall.TABS.GameState;
using Landfall.TABS.UnitEditor;
using Landfall.TABS.Workshop;
using Landfall.TABS_Input;
using TFBGames;
using UFoxLib;
using UFoxLib.Classes;
using UFoxLib.SecretManagement;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("Terren")]
[assembly: AssemblyTitle("Harren's Halloween Mod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HalloweenMod.Classes
{
	public class AddEffectVariation : TargetableEffect
	{
		public UnitEffectBase EffectPrefab;

		public UnitEffectBase EffectForWings;

		public List<string> exceptionUnits;

		[Header("BUG DLC")]
		public UnitEffectBase EBugPrefab;

		public UnitEffectBase EBugForWingsPrefab;

		private GameModeService gameModeService;

		private bool isRestricedInGameMode;

		public override void DoEffect(Transform startPoint, Transform target)
		{
			DataHandler componentInChildren = ((Component)((Component)target).transform.root).GetComponentInChildren<DataHandler>();
			if ((Object.op_Implicit((Object)(object)componentInChildren) && componentInChildren.Dead) || !Object.op_Implicit((Object)(object)componentInChildren))
			{
				return;
			}
			Wings componentInChildren2 = ((Component)((Component)target).transform.root).GetComponentInChildren<Wings>();
			if (Object.op_Implicit((Object)(object)componentInChildren2) && !exceptionUnits.Contains(componentInChildren.unit.unitBlueprint.Entity.Name.ToString()))
			{
				if (componentInChildren2.useWings)
				{
					EffectOnWings(target);
				}
				if (!componentInChildren2.useWings)
				{
					EffectOnAny(target);
				}
			}
			else if (!Object.op_Implicit((Object)(object)componentInChildren2) || exceptionUnits.Contains(componentInChildren.unit.unitBlueprint.Entity.Name.ToString()))
			{
				EffectOnAny(target);
			}
		}

		public override void DoEffect(Vector3 startPoint, Vector3 endPoint, Rigidbody targetRig = null)
		{
		}

		private void EffectOnWings(Transform targ)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (!Application.isEditor)
			{
				ActivateBugDLC();
			}
			UnitEffectBase val = UnitEffectBase.AddEffectToTarget(((Component)targ).gameObject, EffectForWings);
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)EffectForWings).gameObject, ((Component)targ).transform.root);
				val2.transform.position = ((Component)targ).transform.root.position;
				UnitEffectBase component = val2.GetComponent<UnitEffectBase>();
				component.damageMultiplier = base.damageMultiplier;
				component.DoEffect();
				if (Object.op_Implicit((Object)(object)val2))
				{
					TeamHolder.AddTeamHolder(val2, ((Component)this).gameObject);
				}
			}
			else
			{
				val.Ping();
			}
		}

		private void EffectOnAny(Transform targ)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (!Application.isEditor)
			{
				ActivateBugDLC();
			}
			UnitEffectBase val = UnitEffectBase.AddEffectToTarget(((Component)targ).gameObject, EffectPrefab);
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)EffectPrefab).gameObject, ((Component)targ).transform.root);
				val2.transform.position = ((Component)targ).transform.root.position;
				UnitEffectBase component = val2.GetComponent<UnitEffectBase>();
				component.damageMultiplier = base.damageMultiplier;
				component.DoEffect();
				if (Object.op_Implicit((Object)(object)val2))
				{
					TeamHolder.AddTeamHolder(val2, ((Component)this).gameObject);
				}
			}
			else
			{
				val.Ping();
			}
		}

		private void Awake()
		{
			gameModeService = ServiceLocator.GetService<GameModeService>();
			if ((Object)(object)gameModeService != (Object)null)
			{
				isRestricedInGameMode = gameModeService.IsGameModeRestricted();
			}
		}

		private void ActivateBugDLC()
		{
			if (Bugs._DLC_ACTIVATED && SpookifiedNewContentManager.value_BugFlagmanSayan == 1)
			{
				if (Object.op_Implicit((Object)(object)EBugPrefab))
				{
					EffectPrefab = EBugPrefab;
				}
				if (Object.op_Implicit((Object)(object)EBugForWingsPrefab))
				{
					EffectForWings = EBugForWingsPrefab;
				}
			}
		}
	}
	public class Effect_KnockOut : UnitEffectBase
	{
		private Unit unit;

		private StandingHandler stand;

		private DataHandler data;

		private ParticleSystem particle;

		private GooglyEye[] eyes;

		public float removedStand;

		private bool mimir;

		public bool m_Initialized;

		public float knockedFor;

		private Wings[] wings;

		public bool affectWings = true;

		private float wingSpeed1;

		private float wingSpeed2;

		private bool wingsHaveAnimator;

		public UnityEvent onStunEvent;

		public UnityEvent onUnstunEvent;

		private float timer;

		private bool canTimer;

		public override void DoEffect()
		{
			if (!canTimer)
			{
				canTimer = true;
			}
			if (!mimir)
			{
				mimir = true;
			}
			if (!m_Initialized)
			{
				m_Initialized = true;
				Init();
			}
			((MonoBehaviour)this).StartCoroutine(NockEmOut());
		}

		public override void Ping()
		{
			if ((Object)(object)particle != (Object)null)
			{
				particle.Play();
			}
			_ = knockedFor;
			timer += knockedFor;
		}

		private void Init()
		{
			//IL_012e: 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)
			particle = ((Component)this).GetComponentInChildren<ParticleSystem>();
			Random.InitState(((Object)((Component)this).transform.root).GetInstanceID());
			unit = ((Component)((Component)this).transform.parent).GetComponentInChildren<Unit>();
			data = ((Component)((Component)this).transform.parent).GetComponentInChildren<DataHandler>();
			stand = ((Component)((Component)this).transform.parent).GetComponentInChildren<StandingHandler>();
			eyes = ((Component)((Component)this).transform.parent).GetComponentsInChildren<GooglyEye>();
			if (affectWings)
			{
				wings = ((Component)((Component)this).transform.parent).GetComponentsInChildren<Wings>();
			}
			for (int i = 0; i < wings.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)wings[i].animator1) && Object.op_Implicit((Object)(object)wings[i].animator2))
				{
					wingSpeed1 = wings[i].animator1.speed;
					wingSpeed2 = wings[i].animator2.speed;
					wingsHaveAnimator = true;
				}
			}
			Transform transform = ((Component)((Component)((Component)this).transform.parent).GetComponentInChildren<Head>()).transform;
			if (Object.op_Implicit((Object)(object)transform))
			{
				((Component)this).transform.position = transform.position;
				((Component)this).transform.rotation = transform.rotation;
				((Component)this).transform.parent = transform;
			}
		}

		private void Update()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			if (canTimer)
			{
				timer = knockedFor - Time.deltaTime;
			}
			if (mimir)
			{
				for (int i = 0; i < eyes.Length; i++)
				{
					if ((int)eyes[i].currentEyeState != 3)
					{
						eyes[i].SetState((EyeState)3);
					}
				}
				if ((Object)(object)unit.data.weaponHandler != (Object)null)
				{
					unit.data.weaponHandler.StopAttacksFor(1f + Time.deltaTime);
				}
			}
			if (unit.data.health <= 0f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				particle.Stop();
				((MonoBehaviour)this).StopCoroutine(NockEmOut());
			}
		}

		private IEnumerator NockEmOut()
		{
			yield return (object)new WaitForSeconds(0.02f);
			OnStun();
			yield return (object)new WaitForSeconds(timer);
			OnUnstun();
		}

		public Effect_KnockOut()
		{
			removedStand = 5f;
			mimir = true;
			knockedFor = 5f;
		}

		private void OnStun()
		{
			onStunEvent.Invoke();
			if (Object.op_Implicit((Object)(object)stand))
			{
				StandingHandler obj = stand;
				obj.selfOffset += removedStand;
			}
			if (!affectWings)
			{
				return;
			}
			for (int i = 0; i < wings.Length; i++)
			{
				if (wings[i].useWings)
				{
					if (wingsHaveAnimator)
					{
						wings[i].animator1.speed = 0f;
						wings[i].animator2.speed = 0f;
					}
					wings[i].DiableFlight();
				}
			}
		}

		private void OnUnstun()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			onUnstunEvent.Invoke();
			if (Object.op_Implicit((Object)(object)stand))
			{
				StandingHandler obj = stand;
				obj.selfOffset -= removedStand;
			}
			if (affectWings)
			{
				for (int i = 0; i < wings.Length; i++)
				{
					if (!wings[i].useWings)
					{
						if (wingsHaveAnimator)
						{
							wings[i].animator1.speed = wingSpeed1;
							wings[i].animator2.speed = wingSpeed2;
						}
						wings[i].EnableFlight();
					}
				}
			}
			if (!mimir)
			{
				return;
			}
			mimir = false;
			for (int j = 0; j < eyes.Length; j++)
			{
				if ((int)eyes[j].currentEyeState != 0)
				{
					eyes[j].SetState((EyeState)0);
				}
			}
			if ((Object)(object)unit.data.weaponHandler != (Object)null)
			{
				unit.data.weaponHandler.StopAttacksFor(0f);
			}
		}

		public void ResetTimer()
		{
			timer = 0f;
		}
	}
	public class ExplosionAddEVariation : ExplosionEffect
	{
		public UnitEffectBase EffectPrefab;

		public UnitEffectBase EffectForWings;

		public List<string> exceptionUnits;

		public override void DoEffect(GameObject target)
		{
			Wings componentInChildren = ((Component)target.transform.root).GetComponentInChildren<Wings>();
			if (Object.op_Implicit((Object)(object)componentInChildren) && !exceptionUnits.Contains(((Component)target.transform.root).GetComponent<Unit>().unitBlueprint.Entity.Name.ToString()))
			{
				if (componentInChildren.useWings)
				{
					EffectOnWings(target);
				}
				if (!componentInChildren.useWings)
				{
					EffectOnAny(target);
				}
			}
			else if (!Object.op_Implicit((Object)(object)componentInChildren) || exceptionUnits.Contains(((Component)target.transform.root).GetComponent<Unit>().unitBlueprint.Entity.Name.ToString()))
			{
				EffectOnAny(target);
			}
		}

		private void EffectOnAny(GameObject target)
		{
			//IL_0056: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			((object)EffectPrefab).GetType();
			UnitEffectBase val = UnitEffectBase.AddEffectToTarget(target.gameObject, EffectPrefab);
			if ((Object)(object)val == (Object)null)
			{
				GameObject obj = Object.Instantiate<GameObject>(((Component)EffectPrefab).gameObject, target.transform.root);
				obj.transform.position = target.transform.root.position;
				obj.transform.rotation = Quaternion.LookRotation(target.transform.root.position - ((Component)this).transform.position);
				TeamHolder.AddTeamHolder(obj, ((Component)((Component)this).transform.root).gameObject);
				obj.GetComponent<UnitEffectBase>().DoEffect();
				val = obj.GetComponent<UnitEffectBase>();
			}
			else
			{
				val.Ping();
			}
			TargetableEffect[] componentsInChildren = ((Component)val).gameObject.GetComponentsInChildren<TargetableEffect>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].DoEffect(((Component)this).transform, target.transform);
			}
		}

		private void EffectOnWings(GameObject target)
		{
			//IL_0056: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			((object)EffectForWings).GetType();
			UnitEffectBase val = UnitEffectBase.AddEffectToTarget(target.gameObject, EffectForWings);
			if ((Object)(object)val == (Object)null)
			{
				GameObject obj = Object.Instantiate<GameObject>(((Component)EffectForWings).gameObject, target.transform.root);
				obj.transform.position = target.transform.root.position;
				obj.transform.rotation = Quaternion.LookRotation(target.transform.root.position - ((Component)this).transform.position);
				TeamHolder.AddTeamHolder(obj, ((Component)((Component)this).transform.root).gameObject);
				obj.GetComponent<UnitEffectBase>().DoEffect();
				val = obj.GetComponent<UnitEffectBase>();
			}
			else
			{
				val.Ping();
			}
			TargetableEffect[] componentsInChildren = ((Component)val).gameObject.GetComponentsInChildren<TargetableEffect>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].DoEffect(((Component)this).transform, target.transform);
			}
		}
	}
	public class MapPropExtened : GameStateListener
	{
		public bool external_isDestructible;

		public UnityEvent eventsOnBreak;

		public bool external_destructibleStateCheck;

		public GameObject activeClonedProp;

		public override void OnEnterBattleState()
		{
			if (!external_destructibleStateCheck)
			{
				external_destructibleStateCheck = true;
			}
			if (Object.op_Implicit((Object)(object)activeClonedProp))
			{
				Rigidbody component = activeClonedProp.GetComponent<Rigidbody>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.isKinematic = false;
				}
			}
		}

		public override void OnEnterPlacementState()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (external_destructibleStateCheck)
			{
				external_destructibleStateCheck = false;
			}
			((Component)this).gameObject.SetActive(false);
			Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.isKinematic = true;
			}
			if (Object.op_Implicit((Object)(object)activeClonedProp))
			{
				Object.Destroy((Object)(object)activeClonedProp);
			}
			activeClonedProp = Object.Instantiate<GameObject>(((Component)this).gameObject, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform.parent);
			activeClonedProp.SetActive(true);
			Object.Destroy((Object)(object)activeClonedProp.GetComponent<MapProp>());
		}

		public void PropBreak()
		{
			eventsOnBreak.Invoke();
			if (Object.op_Implicit((Object)(object)activeClonedProp))
			{
				Object.Destroy((Object)(object)activeClonedProp);
			}
		}
	}
	public class MapPropBreakableModule : Damagable
	{
		public float m_propHealth = 100f;

		private MapPropExtened m_prop;

		private float m_currentDamage;

		public float m_minimumDamage;

		private void Start()
		{
			m_prop = ((Component)this).gameObject.GetComponent<MapPropExtened>();
		}

		public override void TakeDamage(float damage, Vector3 direction, Unit unit, DamageType damageType = 0)
		{
			if (Object.op_Implicit((Object)(object)m_prop) && m_prop.external_isDestructible && m_prop.external_destructibleStateCheck)
			{
				m_currentDamage += damage;
				if (m_currentDamage >= m_propHealth && damage > m_minimumDamage)
				{
					Destruct();
				}
			}
		}

		private void Destruct()
		{
			m_prop.PropBreak();
		}
	}
	public class MeleeWeaponCollisionEnrage : MonoBehaviour
	{
		private bool canDoSpecialEvents;

		public UnityEvent dealDamageEvent;

		public bool playAura;

		public float chance;

		public float stayFor;

		public ParticleSystem idleAura;

		private Unit self;

		public float timeBetweenSwings = 0.3f;

		private MeleeWeapon meleeWeapon;

		public float maxChance;

		private bool isEnragedAlready;

		private float baseDamage;

		public float plusToDamage;

		private CollisionWeapon colWeapon;

		public float stopForWhenSwinging;

		public int amountOfSwings;

		public void ChanceDecide()
		{
			if (!isEnragedAlready && Random.Range(0f, maxChance) >= chance)
			{
				((MonoBehaviour)this).StartCoroutine(Boost());
			}
		}

		private void Start()
		{
			meleeWeapon = ((Component)this).GetComponent<MeleeWeapon>();
			colWeapon = ((Component)this).GetComponent<CollisionWeapon>();
			if (Object.op_Implicit((Object)(object)colWeapon))
			{
				baseDamage = colWeapon.damage;
			}
			self = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			CollisionEvent component = ((Component)this).GetComponent<CollisionEvent>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.collisionAction = (Action<Collision>)Delegate.Combine(component.collisionAction, new Action<Collision>(DoCollision));
			}
			CollisionWeapon component2 = ((Component)this).GetComponent<CollisionWeapon>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.AddDealDamageAction((Action<Collision, float, Vector3>)DoWeaponCollision);
			}
		}

		private void DoCollision(Collision collision)
		{
			if (canDoSpecialEvents)
			{
				dealDamageEvent.Invoke();
			}
		}

		public void DoWeaponCollision(Collision collision, float damage, Vector3 dir)
		{
			DoCollision(collision);
		}

		private IEnumerator Boost()
		{
			if (!isEnragedAlready)
			{
				isEnragedAlready = true;
			}
			if (!canDoSpecialEvents)
			{
				canDoSpecialEvents = true;
			}
			if (Object.op_Implicit((Object)(object)idleAura) && playAura)
			{
				idleAura.Play();
			}
			self.WeaponHandler.StopAttacksFor(stopForWhenSwinging);
			CollisionWeapon obj = colWeapon;
			obj.damage += plusToDamage;
			for (int i = 0; i < amountOfSwings; i++)
			{
				Swing(self.data.targetData.torso.position, self.data.targetMainRig, Vector3.zero, recursive: false);
				yield return (object)new WaitForSeconds(timeBetweenSwings);
			}
			yield return (object)new WaitForSeconds(stayFor);
			CollisionWeapon obj2 = colWeapon;
			obj2.damage += baseDamage;
			self.WeaponHandler.StopAttacksFor(0f);
			if (canDoSpecialEvents)
			{
				canDoSpecialEvents = false;
			}
			if (Object.op_Implicit((Object)(object)idleAura) && playAura)
			{
				idleAura.Stop();
			}
			if (isEnragedAlready)
			{
				isEnragedAlready = false;
			}
		}

		private void Swing(Vector3 position, Rigidbody targetRig, Vector3 forcedDirection, bool recursive)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			((Weapon)meleeWeapon).Attack(position, targetRig, forcedDirection, false);
		}
	}
	public class StoneSkin : MonoBehaviour
	{
		private DataHandler data;

		public UnityEvent whatHappensWhenHurt;

		public ParticleSystem hurtParticle;

		private ShapeModule partShapeModule;

		private int stacks = 2;

		public int maxEmmits;

		private SkinnedMeshRenderer[] allSkinnedMeshes;

		private SkinnedMeshRenderer mainSkinnedMesh;

		[Tooltip("Set to small values. Doing this because some effects like life drain will make this boy go wild with particles and such ( ..)")]
		public float cooldownTime;

		private bool cooldownIsGoing;

		public float strengthCap;

		public float speedCap;

		private float prevDamageMultiplier = 1f;

		private float prevSpeedMultiplier = 1f;

		private float damageMultiplier = 1f;

		private float speedMultiplier = 1f;

		private List<CollisionWeapon> colWeapon = new List<CollisionWeapon>();

		private float prevPartMultiplier = 1f;

		private float partMultiplier = 1f;

		private void Start()
		{
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			data = ((Component)((Component)this).transform.root).GetComponentInChildren<DataHandler>();
			data.unit.AddWasDamagedAction((Action<Rigidbody, Rigidbody>)OnUnitDamaged);
			allSkinnedMeshes = ((Component)((Component)this).transform.root).GetComponentsInChildren<SkinnedMeshRenderer>();
			if (Object.op_Implicit((Object)(object)data.weaponHandler))
			{
				if (Object.op_Implicit((Object)(object)data.weaponHandler.rightWeapon) && Object.op_Implicit((Object)(object)((Component)data.weaponHandler.rightWeapon).GetComponent<CollisionWeapon>()))
				{
					colWeapon.Add(((Component)data.weaponHandler.rightWeapon).GetComponent<CollisionWeapon>());
				}
				if (Object.op_Implicit((Object)(object)data.weaponHandler.leftWeapon) && Object.op_Implicit((Object)(object)((Component)data.weaponHandler.leftWeapon).GetComponent<CollisionWeapon>()))
				{
					colWeapon.Add(((Component)data.weaponHandler.leftWeapon).GetComponent<CollisionWeapon>());
				}
			}
			for (int i = 0; i < allSkinnedMeshes.Length; i++)
			{
				if (((Component)allSkinnedMeshes[i]).CompareTag("UnitMesh"))
				{
					mainSkinnedMesh = allSkinnedMeshes[i];
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)mainSkinnedMesh))
			{
				partShapeModule = hurtParticle.shape;
				((ShapeModule)(ref partShapeModule)).skinnedMeshRenderer = mainSkinnedMesh;
			}
		}

		private void Update()
		{
		}

		public void OnUnitDamaged(Rigidbody enemyWeapon, Rigidbody enemyTorso)
		{
			if (!cooldownIsGoing)
			{
				((MonoBehaviour)this).StartCoroutine(CooldownEvents());
			}
		}

		private void ParticleEmmision()
		{
			if (stacks < maxEmmits)
			{
				partMultiplier = Mathf.Clamp(1f + data.maxHealth / data.health, 2f, (float)maxEmmits);
				stacks += (int)((float)stacks * (partMultiplier - prevPartMultiplier));
				prevPartMultiplier = partMultiplier;
			}
			hurtParticle.Emit(stacks);
		}

		private IEnumerator CooldownEvents()
		{
			if (!cooldownIsGoing)
			{
				cooldownIsGoing = true;
				if (!data.Dead)
				{
					whatHappensWhenHurt.Invoke();
					ParticleEmmision();
					MeleeBuff();
				}
			}
			yield return (object)new WaitForSeconds(cooldownTime);
			if (cooldownIsGoing)
			{
				cooldownIsGoing = false;
			}
		}

		private void MeleeBuff()
		{
			damageMultiplier = Mathf.Clamp(1f + data.maxHealth / data.health, 1f, strengthCap);
			foreach (CollisionWeapon item in colWeapon)
			{
				item.damage += item.damage * (damageMultiplier - prevDamageMultiplier);
			}
			prevDamageMultiplier = damageMultiplier;
			speedMultiplier = Mathf.Clamp(1f + data.maxHealth / data.health, 1f, speedCap);
			WeaponHandler weaponHandler = data.weaponHandler;
			weaponHandler.attackSpeedMultiplier += data.weaponHandler.attackSpeedMultiplier * (speedMultiplier - prevSpeedMultiplier);
			prevSpeedMultiplier = speedMultiplier;
		}
	}
	public class TombstonePieceTag : MonoBehaviour
	{
	}
	public class TombstonePiecesManager : MonoBehaviour
	{
		public float removeAfter;

		public float forceForward;

		public bool debug;

		private TombstonePieceTag[] pieces;

		public float rigMass = 13f;

		public float rigDrags = 3f;

		private List<MeshRenderer> meshes = new List<MeshRenderer>();

		private List<MeshCollider> collision = new List<MeshCollider>();

		public void WakeUpPieces()
		{
			if (pieces == null)
			{
				Debug.LogError((object)(((Object)((Component)this).gameObject).name.ToString() + " is erroring for some reason. You need to have pieces objects in prefab"));
			}
			else
			{
				GoForAll(removeAfter, forceForward, rigMass, rigDrags);
			}
		}

		private void Start()
		{
			pieces = ((Component)this).GetComponentsInChildren<TombstonePieceTag>();
			List<MeshRenderer> list = new List<MeshRenderer>();
			List<MeshCollider> list2 = new List<MeshCollider>();
			for (int i = 0; i < pieces.Length; i++)
			{
				MeshRenderer component = ((Component)pieces[i]).GetComponent<MeshRenderer>();
				MeshCollider component2 = ((Component)pieces[i]).GetComponent<MeshCollider>();
				list.Add(component);
				list2.Add(component2);
			}
			meshes.AddRange(list);
			collision.AddRange(list2);
			foreach (MeshRenderer mesh in meshes)
			{
				if (((Renderer)mesh).enabled)
				{
					((Renderer)mesh).enabled = false;
				}
			}
			foreach (MeshCollider item in collision)
			{
				if (((Collider)item).enabled)
				{
					((Collider)item).enabled = false;
				}
			}
		}

		private void GoForAll(float removeTime, float force, float mass, float drag)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < pieces.Length; i++)
			{
				((Component)pieces[i]).transform.SetParent((Transform)null, true);
				Rigidbody val = ((Component)pieces[i]).gameObject.AddComponent<Rigidbody>();
				if (Object.op_Implicit((Object)(object)val))
				{
					val.mass = mass;
					val.drag = drag;
					val.angularDrag = drag;
					val.interpolation = (RigidbodyInterpolation)1;
					RemoveAfterSeconds obj = ((Component)pieces[i]).gameObject.AddComponent<RemoveAfterSeconds>();
					obj.shrink = true;
					obj.extraRandom = 0.5f;
					obj.seconds = removeTime;
					AddForce obj2 = ((Component)pieces[i]).gameObject.AddComponent<AddForce>();
					obj2.force = new Vector3(0f, 0f, force);
					obj2.playOnStart = true;
				}
			}
			foreach (MeshRenderer mesh in meshes)
			{
				if (!((Renderer)mesh).enabled)
				{
					((Renderer)mesh).enabled = true;
				}
			}
			foreach (MeshCollider item in collision)
			{
				if (!((Collider)item).enabled)
				{
					((Collider)item).enabled = true;
				}
			}
		}
	}
	public class VampireLifeDrain : MonoBehaviour
	{
		private Unit unit;

		private DataHandler targetData;

		public ParticleSystem part;

		public Transform partForceField;

		public Transform partFollow;

		private ShapeModule shape;

		private bool setPositions;

		private DataHandler myData;

		public float healthToTakePer;

		public float rate;

		public float maxDist;

		private bool checkerOnce;

		public Transform soundChecker;

		private bool onCooldown;

		public float cooldown = 8f;

		public float healthToAddPer;

		public UnityEvent eventsForTransformation;

		private SkinnedMeshRenderer ownSkinnedMesh;

		public int neededForTransformation;

		private int counterForTransformation;

		public bool useSameHealthVal;

		private bool overdoseChecker;

		public UnityEvent eachBiteEvent;

		public bool sendDebugLog;

		public float targetMass;

		private UnitHalfHealhtEvent myCaller;

		[Header("Target Color")]
		public AnimationCurve curveTarget;

		public UnitColorInstance colorTarget;

		private void Start()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			unit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			myData = unit.data;
			shape = part.shape;
			SkinnedMeshRenderer componentInChildren = ((Component)((Component)unit).transform.root).GetComponentInChildren<SkinnedMeshRenderer>();
			if (Object.op_Implicit((Object)(object)componentInChildren) && ((Component)componentInChildren).CompareTag("UnitMesh"))
			{
				ownSkinnedMesh = componentInChildren;
			}
			myCaller = ((Component)((Component)this).transform).GetComponent<UnitHalfHealhtEvent>();
		}

		private void Update()
		{
			//IL_0063: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (setPositions)
			{
				((Component)partFollow).transform.position = targetData.torso.position;
				((Component)partFollow).transform.rotation = targetData.torso.rotation;
			}
			((Component)partForceField).transform.position = unit.data.head.position;
			((Component)partForceField).transform.rotation = unit.data.head.rotation;
		}

		private IEnumerator DoRemoteBite()
		{
			if (!myData.Dead && Object.op_Implicit((Object)(object)targetData))
			{
				SkinnedMeshRenderer componentInChildren = ((Component)((Component)targetData).transform.root).GetComponentInChildren<SkinnedMeshRenderer>();
				if (Object.op_Implicit((Object)(object)componentInChildren) && ((Component)componentInChildren).CompareTag("UnitMesh"))
				{
					((ShapeModule)(ref shape)).skinnedMeshRenderer = componentInChildren;
				}
				while (!overdoseChecker && !myData.Dead && !targetData.Dead && myData.health < myData.maxHealth && Vector3.Distance(myData.torso.position, targetData.torso.position) < maxDist)
				{
					if (!checkerOnce)
					{
						part.Play();
						if (!((Component)soundChecker).gameObject.activeSelf)
						{
							((Component)soundChecker).gameObject.SetActive(true);
						}
						checkerOnce = true;
					}
					if (!setPositions)
					{
						setPositions = true;
					}
					YouAndMeGetHurt();
					int num = counterForTransformation;
					eachBiteEvent.Invoke();
					counterForTransformation = num + 1;
					if (counterForTransformation > neededForTransformation)
					{
						((MonoBehaviour)this).StartCoroutine(OverdoseEvent());
					}
					yield return (object)new WaitForSeconds(rate);
				}
				if (!onCooldown)
				{
					onCooldown = true;
				}
				part.Stop();
				yield return (object)new WaitForSeconds(0.2f);
				if (setPositions)
				{
					setPositions = false;
				}
				if (((Component)soundChecker).gameObject.activeSelf)
				{
					((Component)soundChecker).gameObject.SetActive(false);
				}
				myCaller.ForceResetChecker();
				checkerOnce = false;
			}
			yield return (object)new WaitForSeconds(cooldown);
			if (onCooldown)
			{
				onCooldown = false;
			}
		}

		private void YouAndMeGetHurt()
		{
			//IL_002e: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)myData) && Object.op_Implicit((Object)(object)targetData))
			{
				((Damagable)targetData.healthHandler).TakeDamage(healthToTakePer, Vector3.down, (Unit)null, (DamageType)0);
				if (useSameHealthVal)
				{
					((Damagable)myData.healthHandler).TakeDamage(0f - healthToTakePer, Vector3.zero, (Unit)null, (DamageType)0);
				}
				if (!useSameHealthVal)
				{
					((Damagable)myData.healthHandler).TakeDamage(0f - healthToAddPer, Vector3.zero, (Unit)null, (DamageType)0);
				}
				((MonoBehaviour)this).StartCoroutine(DoColor());
			}
		}

		public void StartDrain()
		{
			if (!overdoseChecker && !onCooldown)
			{
				targetData = myData.targetData;
				if (targetData.unit.unitBlueprint.massMultiplier <= targetMass)
				{
					((MonoBehaviour)this).StartCoroutine(DoRemoteBite());
				}
			}
		}

		private IEnumerator OverdoseEvent()
		{
			((MonoBehaviour)this).StopCoroutine(DoRemoteBite());
			if (part.isPlaying)
			{
				part.Stop();
			}
			if (((Component)soundChecker).gameObject.activeSelf)
			{
				((Component)soundChecker).gameObject.SetActive(false);
			}
			eventsForTransformation.Invoke();
			if (!overdoseChecker)
			{
				overdoseChecker = true;
				if (sendDebugLog)
				{
					Debug.Log((object)("Reached " + counterForTransformation));
				}
			}
			yield break;
		}

		private IEnumerator DoColor()
		{
			UnitColorHandler componentInParent = ((Component)targetData).GetComponentInParent<UnitColorHandler>();
			if (Object.op_Implicit((Object)(object)componentInParent))
			{
				float num = 0f;
				float time = ((Keyframe)(ref curveTarget.keys[curveTarget.keys.Length - 1])).time;
				while (num < time)
				{
					componentInParent.SetColor(colorTarget, curveTarget.Evaluate(num));
				}
			}
			yield break;
		}
	}
}
namespace HalloweenMod.Tags
{
	public class Tag_SpecterBody : MonoBehaviour
	{
	}
	public class Tag_ShieldProjectileEvent : MonoBehaviour
	{
		public UnityEvent projectileHitEvent;

		public bool canDoEvents;

		public float cooldownTime;

		private bool cooldownIsGoing;

		public bool AllowEventing
		{
			get
			{
				return canDoEvents;
			}
			set
			{
				canDoEvents = value;
			}
		}

		public IEnumerator CooldownEvents()
		{
			if (!cooldownIsGoing)
			{
				cooldownIsGoing = true;
				if (canDoEvents)
				{
					projectileHitEvent.Invoke();
				}
			}
			yield return (object)new WaitForSeconds(cooldownTime);
			if (cooldownIsGoing)
			{
				cooldownIsGoing = false;
			}
		}

		public void DoEvents()
		{
			((MonoBehaviour)this).StartCoroutine(CooldownEvents());
		}
	}
}
namespace HalloweenMod.Patches
{
	[HarmonyPatch(typeof(ProjectileHit), "Hit")]
	internal class SpecterProjectileHitPatch
	{
		public static GameObject hitPoof;

		public static bool Prefix(ProjectileHit __instance, RaycastHit sentHit)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			Tag_SpecterBody tag_SpecterBody = ((!Object.op_Implicit((Object)(object)((RaycastHit)(ref sentHit)).rigidbody)) ? ((Component)((RaycastHit)(ref sentHit)).collider).gameObject.GetComponentInChildren<Tag_SpecterBody>() : ((Component)((RaycastHit)(ref sentHit)).rigidbody).gameObject.GetComponentInChildren<Tag_SpecterBody>());
			if (Object.op_Implicit((Object)(object)tag_SpecterBody))
			{
				Object.Instantiate<GameObject>(hitPoof, ((Component)__instance).transform.position, Quaternion.identity);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ProjectileHit), "Hit")]
	internal class HMShieldProjectilePatch
	{
		public static bool Prefix(ProjectileHit __instance, RaycastHit sentHit)
		{
			Tag_ShieldProjectileEvent tag_ShieldProjectileEvent = ((!Object.op_Implicit((Object)(object)((RaycastHit)(ref sentHit)).rigidbody)) ? ((Component)((RaycastHit)(ref sentHit)).collider).gameObject.GetComponentInChildren<Tag_ShieldProjectileEvent>() : ((Component)((RaycastHit)(ref sentHit)).rigidbody).gameObject.GetComponentInChildren<Tag_ShieldProjectileEvent>());
			if (Object.op_Implicit((Object)(object)tag_ShieldProjectileEvent) && tag_ShieldProjectileEvent.canDoEvents)
			{
				tag_ShieldProjectileEvent.DoEvents();
			}
			return true;
		}
	}
}
namespace HalloweenMod.Classes
{
	public class SoulessDeathEffect : UnitEffectBase
	{
		public UnityEvent pingEvent;

		private UnitColorHandler unitColorHandler;

		private int amountCurrent;

		public int amountPerEffect = 1;

		public int amountCap = 8;

		private SkinnedMeshRenderer[] allSkinnedMeshes;

		private SkinnedMeshRenderer mainSkinnedMesh;

		public UnityEvent deathEvent;

		public List<ParticleSystem> fullBodyParticles = new List<ParticleSystem>();

		private ShapeModule partShapeModule_start;

		private ShapeModule partShapeModule_loop;

		public Material deadMat;

		public override void DoEffect()
		{
			SetupParticle();
			((UnitEffectBase)this).Ping();
		}

		public override void Ping()
		{
			AddEffect();
			pingEvent.Invoke();
		}

		private void AddEffect()
		{
			if (amountCurrent >= amountCap)
			{
				unitColorHandler = ((Component)this).GetComponentInParent<UnitColorHandler>();
				if (Object.op_Implicit((Object)(object)unitColorHandler))
				{
					unitColorHandler.SetMaterial(deadMat);
				}
				DataHandler data = ((Component)((Component)this).transform.root).GetComponent<Unit>().data;
				if (Object.op_Implicit((Object)(object)data) && Object.op_Implicit((Object)(object)data.healthHandler) && !data.Dead)
				{
					for (int i = 0; i < data.allRigs.AllRigs.Length; i++)
					{
						data.allRigs.AllRigs[i].useGravity = false;
					}
					((UnityEventBase)data.healthHandler.deathEvent).RemoveAllListeners();
					data.healthHandler.Die((Unit)null);
				}
				deathEvent.Invoke();
			}
			else
			{
				amountCurrent += amountPerEffect;
			}
		}

		private void SetupParticle()
		{
			//IL_0067: 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)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			allSkinnedMeshes = ((Component)((Component)this).transform.root).GetComponentsInChildren<SkinnedMeshRenderer>();
			for (int i = 0; i < allSkinnedMeshes.Length; i++)
			{
				if (((Component)allSkinnedMeshes[i]).CompareTag("UnitMesh"))
				{
					mainSkinnedMesh = allSkinnedMeshes[i];
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)mainSkinnedMesh))
			{
				partShapeModule_start = fullBodyParticles[0].shape;
				partShapeModule_loop = fullBodyParticles[1].shape;
				((ShapeModule)(ref partShapeModule_start)).skinnedMeshRenderer = mainSkinnedMesh;
				((ShapeModule)(ref partShapeModule_loop)).skinnedMeshRenderer = mainSkinnedMesh;
			}
		}
	}
}
namespace HalloweenMod
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("terren.modHalloweenUnits", "HarrensHalloweenMod", "0.2.0")]
	public class HalloweenModInit : BaseUnityPlugin
	{
		private static readonly string code_credit;

		public static ConfigEntry<bool> ConfigFlagmanSayanMode;

		public static ConfigEntry<bool> ConfigArachnophobiaFilter;

		private void Awake()
		{
			SpookifiedNewContentManager.compabilityFlag_holiday = Chainloader.PluginInfos.ContainsKey("teamgrad.holiday");
			((MonoBehaviour)this).StartCoroutine(WaitForService());
		}

		static HalloweenModInit()
		{
			code_credit = "24th of January 2023 i finally finished working on project-side of this mod and was ready to import it into game, only to find out i lost all loader code i made sometime ago. Got tilted for some time, but now i rewrote it and (hopefully) even better, but not without help. Infinite thanks to BD, Arargd and others";
		}

		private IEnumerator WaitForService()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
			yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
			LoadMod_Delayed();
		}

		private void LoadMod_Delayed()
		{
			new SpookifiedNewContentManager();
			SettingsManager();
		}

		private void SettingsManager()
		{
			ConfigFlagmanSayanMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Bug", "StandardBearerSayanMode", true, "Enables true powers within Standard Bearer and it's weapon.");
			ConfigArachnophobiaFilter = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "ArachnophobiaFilter", true, "Disables certain spider-like designs and replaces with less triggering appearance.");
			TerrenModUtilities.CreateSetting(true, (SettingsType)0, "BUG_HM_FLAGMANSAYANMODE", "Standard Bearer True Power", "tooltip sucks amiright", "BUG", 0f, (float)((!ConfigFlagmanSayanMode.Value) ? 1 : 0), new string[2] { "Disabled", "E N A B L E D" }, 0f, 1f).OnValueChanged += SpookifiedNewContentManager.FlagmanSayanMode_OnValueChanged;
			TerrenModUtilities.CreateSetting(true, (SettingsType)0, "SETTING_HM_SPIDERFILTER", "Arachnophobia Filter", "tooltip sucks amiright", "GAMEPLAY", 0f, (float)((!ConfigArachnophobiaFilter.Value) ? 1 : 0), new string[2] { "Disabled", "Enabled" }, 0f, 1f).OnValueChanged += SpookifiedNewContentManager.SpiderFilter_OnValueChanged;
		}

		public static void Dummy_OnValueChanged(int value)
		{
		}
	}
}
namespace HalloweenMod.Tags
{
	public class Tag_ArachnophobiaFilter : MonoBehaviour
	{
		public UnityEvent enabled;

		public UnityEvent disabled;

		public void Start()
		{
			if (SpookifiedNewContentManager.value_spiderFilter == 1)
			{
				enabled.Invoke();
			}
			if (SpookifiedNewContentManager.value_spiderFilter == 0)
			{
				disabled.Invoke();
			}
			Object.Destroy((Object)(object)this);
		}
	}
}
namespace HalloweenMod.Patches
{
	[HarmonyPatch(typeof(ModalPanel), "DelayUnlockPanel")]
	internal class ModalPanelSecretPatch
	{
		public class PatchHolder
		{
			[Header("This patch was made with modified Assembly-CSharp.dll so do not edit this. You won't be able to re-compile this anyway")]
			public static AudioClip changedClip;

			public static List<string> triggerDescriptions;

			public static IEnumerator DelayUnlockPanel_Prefix(ModalPanel __instance, float delayTime)
			{
				if (__instance.m_delayUnlock)
				{
					yield break;
				}
				__instance.m_delayUnlock = true;
				yield return (object)new WaitForSecondsRealtime(delayTime);
				__instance.m_delayUnlock = false;
				if (__instance.m_secretUnlockQueue.Count < 1)
				{
					yield break;
				}
				SecretUnlockInfo val = __instance.m_secretUnlockQueue.Dequeue();
				__instance.m_unlockText.LocaleID = val.m_description;
				__instance.m_unlockImage.sprite = val.m_icon;
				__instance.m_LastFrameOpen = Time.frameCount;
				((UnityEventBase)__instance.m_unlockButton.onClick).RemoveAllListeners();
				((UnityEvent)__instance.m_unlockButton.onClick).AddListener(new UnityAction(__instance.CloseUnlockPanel));
				__instance.m_unlockPanelObject.SetActive(true);
				__instance.m_unlockPanelObject.GetComponent<CodeAnimation>().PlayIn();
				AudioSource component = ((Component)__instance).GetComponent<AudioSource>();
				if ((Object)(object)component != (Object)null)
				{
					if (triggerDescriptions.Contains(val.m_description.ToString()))
					{
						component.PlayOneShot(changedClip);
					}
					else
					{
						component.Play();
					}
				}
				if ((int)PlayerActions.Instance.InputType == 0)
				{
					((Selectable)__instance.m_unlockButton).Select();
					if ((Object)(object)__instance.m_BackButtonImage != (Object)null)
					{
						((Behaviour)__instance.m_BackButtonImage).enabled = false;
					}
				}
				else if ((Object)(object)__instance.m_BackButtonImage != (Object)null && !((Behaviour)__instance.m_BackButtonImage).isActiveAndEnabled)
				{
					((Behaviour)__instance.m_BackButtonImage).enabled = true;
				}
				__instance.m_pauseGame = true;
			}

			static PatchHolder()
			{
				triggerDescriptions = new List<string>();
			}
		}

		[HarmonyPrefix]
		public static bool Prefix(ModalPanel __instance, ref IEnumerator __result, float delayTime)
		{
			__result = PatchHolder.DelayUnlockPanel_Prefix(__instance, delayTime);
			return false;
		}
	}
}
namespace HalloweenMod.Classes
{
	public class UndeadFlagAttack : UnitEffectBase
	{
		public enum attackType
		{
			Ground,
			AntiAir
		}

		public LayerMask m_mapMask;

		private bool isWinged;

		private bool m_initialized;

		private Unit m_unit;

		public SpawnObject spawner;

		public UnityEvent initEvent;

		public float spawnDelay;

		public float removeDelay;

		public Transform[] rangedPoints;

		public attackType m_attackType;

		public override void DoEffect()
		{
			if (!m_initialized)
			{
				m_initialized = true;
				Init();
			}
		}

		public override void Ping()
		{
			((UnitEffectBase)this).DoEffect();
		}

		private void Init()
		{
			m_unit = ((Component)((Component)this).transform.parent).GetComponentInChildren<Unit>();
			if (m_attackType == attackType.Ground)
			{
				((MonoBehaviour)this).StartCoroutine(SpawnAttackTimed());
			}
			if (m_attackType == attackType.AntiAir)
			{
				((MonoBehaviour)this).StartCoroutine(ShootAttackTimed());
			}
		}

		private void SpawnAttack()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			Physics.Raycast(new Ray(m_unit.data.hip.position, Vector3.down), ref val, 150f, LayerMask.op_Implicit(m_mapMask));
			spawner.Spawn(((RaycastHit)(ref val)).point, Vector3.zero);
		}

		private IEnumerator SpawnAttackTimed()
		{
			if (Object.op_Implicit((Object)(object)m_unit) && !m_unit.data.Dead)
			{
				initEvent.Invoke();
				yield return (object)new WaitForSeconds(spawnDelay);
				SpawnAttack();
				yield return (object)new WaitForSeconds(removeDelay);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private IEnumerator ShootAttackTimed()
		{
			if (Object.op_Implicit((Object)(object)m_unit) && !m_unit.data.Dead)
			{
				initEvent.Invoke();
				yield return (object)new WaitForSeconds(spawnDelay);
				Transform[] array = rangedPoints;
				for (int i = 0; i < array.Length; i++)
				{
					array[i].LookAt(m_unit.data.torso, Vector3.forward);
					((Component)array[i]).GetComponent<SpawnObject>().SpawnAtObjectRotation();
				}
				yield return (object)new WaitForSeconds(removeDelay);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public class Effect_CurseOfWeakness : UnitEffectBase
	{
		private bool m_inited;

		public UnityEvent effectEvent;

		public UnityEvent pingEvent;

		public float effectDuration;

		private Unit self;

		private WeaponHandler weaponHandler;

		[Header("Public for debug purposes")]
		public float m_holdableLeftForce;

		public float m_holdableLeftTorque;

		public float m_holdableLeftMass;

		public float m_holdableRightForce;

		public float m_holdableRightTorque;

		public float m_holdableRightMass;

		public Holdable m_holdableLeft;

		public Holdable m_holdableRight;

		public float rigMassMultiplier;

		public void Start()
		{
		}

		public override void DoEffect()
		{
			if (Object.op_Implicit((Object)(object)self))
			{
				return;
			}
			self = ((Component)((Component)this).transform.root).GetComponent<Unit>();
			if (Object.op_Implicit((Object)(object)self))
			{
				weaponHandler = self.data.weaponHandler;
				if (Object.op_Implicit((Object)(object)weaponHandler))
				{
					DoTheThing();
				}
			}
		}

		public override void Ping()
		{
			((UnitEffectBase)this).DoEffect();
			pingEvent.Invoke();
		}

		private void DoTheThing()
		{
			if (!m_inited)
			{
				m_inited = true;
				Weapon rightWeapon = weaponHandler.rightWeapon;
				if (Object.op_Implicit((Object)(object)rightWeapon))
				{
					m_holdableRight = ((Component)rightWeapon).GetComponent<Holdable>();
				}
				Weapon leftWeapon = weaponHandler.leftWeapon;
				if (Object.op_Implicit((Object)(object)leftWeapon))
				{
					m_holdableLeft = ((Component)leftWeapon).GetComponent<Holdable>();
				}
				((MonoBehaviour)this).StartCoroutine(DoWeakness());
				effectEvent.Invoke();
			}
		}

		private IEnumerator DoWeakness()
		{
			if (Object.op_Implicit((Object)(object)m_holdableLeft))
			{
				Rigidbody component = ((Component)m_holdableLeft).GetComponent<Rigidbody>();
				float mass = component.mass * rigMassMultiplier;
				m_holdableLeftForce = m_holdableLeft.pidData.proportionalForce;
				m_holdableLeftTorque = m_holdableLeft.pidData.proportionalTorque;
				m_holdableLeftMass = component.mass;
				m_holdableLeft.pidData.proportionalForce = 0f;
				m_holdableLeft.pidData.proportionalTorque = 0f;
				component.mass = mass;
			}
			if (Object.op_Implicit((Object)(object)m_holdableRight))
			{
				Rigidbody component2 = ((Component)m_holdableRight).GetComponent<Rigidbody>();
				float mass2 = component2.mass * rigMassMultiplier;
				m_holdableRightForce = m_holdableRight.pidData.proportionalForce;
				m_holdableRightTorque = m_holdableRight.pidData.proportionalTorque;
				m_holdableRightMass = component2.mass;
				m_holdableRight.pidData.proportionalForce = 0f;
				m_holdableRight.pidData.proportionalTorque = 0f;
				component2.mass = mass2;
			}
			yield return (object)new WaitForSeconds(effectDuration);
			if (Object.op_Implicit((Object)(object)m_holdableLeft))
			{
				Rigidbody component3 = ((Component)m_holdableLeft).GetComponent<Rigidbody>();
				m_holdableLeft.pidData.proportionalForce = m_holdableLeftForce;
				m_holdableLeft.pidData.proportionalTorque = m_holdableLeftTorque;
				component3.mass = m_holdableLeftMass;
			}
			if (Object.op_Implicit((Object)(object)m_holdableRight))
			{
				Rigidbody component4 = ((Component)m_holdableRight).GetComponent<Rigidbody>();
				m_holdableRight.pidData.proportionalForce = m_holdableRightForce;
				m_holdableRight.pidData.proportionalTorque = m_holdableRightTorque;
				component4.mass = m_holdableRightMass;
			}
		}
	}
}
namespace HalloweenMod
{
	public class SpookifiedNewContentManager
	{
		public static AssetBundle spookifiedContent;

		public static bool compabilityFlag_holiday;

		private string comment = "";

		public static int value_BugFlagmanSayan;

		public static int value_spiderFilter;

		public SpookifiedNewContentManager()
		{
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)spookifiedContent))
			{
				Debug.LogError((object)"---SPOOKIFIED MOD ERROR: Embedded Asset Bundle have failed to load, please reinstall mod from Thunderstore page or from mod manager. If nothing helped, contact the mod author on discord (Terren#9430)");
				return;
			}
			ContentDatabase database = ContentDatabase.Instance();
			TerrenModAssetDatabase component = spookifiedContent.LoadAsset<GameObject>("SpookifiedDatabase").GetComponent<TerrenModAssetDatabase>();
			if (!compabilityFlag_holiday)
			{
				TerrenModUtilities.DeactivateBonusUnit(spookifiedContent, component, "UNIT_ELFZOMB", "Faction_HalloweenMod");
			}
			SoundBank soundBank = ServiceLocator.GetService<SoundPlayer>().soundBank;
			SoundBank[] array = spookifiedContent.LoadAllAssets<SoundBank>();
			foreach (SoundBank val in array)
			{
				SoundBankCategory[] categories = val.Categories;
				for (int j = 0; j < categories.Length; j++)
				{
					categories[j].categoryMixerGroup = soundBank.Categories[0].categoryMixerGroup;
				}
				List<SoundBankCategory> list = soundBank.Categories.ToList();
				list.AddRange(val.Categories);
				soundBank.Categories = list.ToArray();
			}
			TerrenModUtilities.AddLocalization(component.m_localizationEntries);
			ModSceneLoadManagerGlobal.onMapUnlocks.Add(spookifiedContent.LoadAsset<GameObject>("SecretManager").GetComponent<SecretPropCollection>());
			if (compabilityFlag_holiday)
			{
				MainMenuUnlockEntry item = new MainMenuUnlockEntry
				{
					key = "HM_BONUS_ELFZOMBIE",
					description = "BONUS_ELFZOMB_DESC",
					icon = spookifiedContent.LoadAsset<Sprite>("PORTRAIT_ZELF")
				};
				ModSceneLoadManagerGlobal.mainMenuUnlocks.Add(item);
			}
			List<UnitBlueprint> list2 = new List<UnitBlueprint>();
			UnitBlueprint item2 = spookifiedContent.LoadAsset<UnitBlueprint>("CustomZombieHM");
			list2.Add(item2);
			ModSceneLoadManagerGlobal.editorUnitBases.AddRange(list2);
			SpecterProjectileHitPatch.hitPoof = (GameObject)spookifiedContent.LoadAsset("VFX_SpecterEffect");
			ModalPanelSecretPatch.PatchHolder.changedClip = spookifiedContent.LoadAsset<AudioClip>("Unit Unlocked_HalloweenMod");
			ModalPanelSecretPatch.PatchHolder.triggerDescriptions = component.m_secretDescriptionTriggers.ToList();
			new Harmony("HarmoweenMod").PatchAll();
			LoadContentIntoDatabase(database, component);
		}

		public void LoadContentIntoDatabase(ContentDatabase database, TerrenModAssetDatabase modDatabase)
		{
			TerrenModUtilities.AddFactions(database, modDatabase);
			TerrenModUtilities.AddUnitBlueprints(database, modDatabase);
			TerrenModUtilities.AddUnitCreatorPass(database, modDatabase);
			TerrenModUtilities.AddTeamColorPalette(spookifiedContent.LoadAsset<UnitEditorColorPalette>("SpookifiedTeamColors"));
			ServiceLocator.GetService<CustomContentLoaderModIO>().QuickRefresh((WorkshopContentType)0, (Action)null);
			Debug.Log((object)"---SPOOKIFIED MOD: Done loading into database, everything's up and runnin!");
		}

		static SpookifiedNewContentManager()
		{
			spookifiedContent = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("spookifiedcontent"));
			value_BugFlagmanSayan = 0;
			value_spiderFilter = 0;
		}

		public static void FlagmanSayanMode_OnValueChanged(int value)
		{
			value_BugFlagmanSayan = value;
		}

		public static void SpiderFilter_OnValueChanged(int value)
		{
			value_spiderFilter = value;
		}

		private void DebugItemGuids(TerrenModAssetDatabase items)
		{
			//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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"---Start printing items...");
			Debug.Log((object)"---PROPS...");
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			DatabaseID gUID;
			for (int i = 0; i < items.m_props.Count; i++)
			{
				PropItem component = items.m_props[i].GetComponent<PropItem>();
				Debug.Log((object)((CharacterItem)component).Entity.Name.ToString());
				gUID = ((CharacterItem)component).Entity.GUID;
				if (dictionary.ContainsKey(((object)(DatabaseID)(ref gUID)).ToString()))
				{
					Debug.Log((object)("Have faulty guid: " + ((CharacterItem)component).Entity.Name.ToString()));
					continue;
				}
				gUID = ((CharacterItem)component).Entity.GUID;
				dictionary.Add(((object)(DatabaseID)(ref gUID)).ToString(), ((CharacterItem)component).Entity.Name.ToString());
			}
			dictionary.Clear();
			Debug.Log((object)"---WEPONS...");
			for (int j = 0; j < items.m_weapons.Count; j++)
			{
				WeaponItem component2 = items.m_weapons[j].GetComponent<WeaponItem>();
				Debug.Log((object)((CharacterItem)component2).Entity.Name.ToString());
				gUID = ((CharacterItem)component2).Entity.GUID;
				if (dictionary.ContainsKey(((object)(DatabaseID)(ref gUID)).ToString()))
				{
					Debug.Log((object)("Have faulty guid: " + ((CharacterItem)component2).Entity.Name.ToString()));
					continue;
				}
				gUID = ((CharacterItem)component2).Entity.GUID;
				dictionary.Add(((object)(DatabaseID)(ref gUID)).ToString(), ((CharacterItem)component2).Entity.Name.ToString());
			}
			dictionary.Clear();
			Debug.Log((object)"---PROJIES...");
			for (int k = 0; k < items.m_projectiles.Count; k++)
			{
				ProjectileEntity component3 = items.m_projectiles[k].GetComponent<ProjectileEntity>();
				Debug.Log((object)component3.Entity.Name.ToString());
				gUID = component3.Entity.GUID;
				if (dictionary.ContainsKey(((object)(DatabaseID)(ref gUID)).ToString()))
				{
					Debug.Log((object)("Have faulty guid: " + component3.Entity.Name.ToString()));
					continue;
				}
				gUID = component3.Entity.GUID;
				dictionary.Add(((object)(DatabaseID)(ref gUID)).ToString(), component3.Entity.Name.ToString());
			}
			dictionary.Clear();
			Debug.Log((object)"---MOVES...");
			for (int l = 0; l < items.m_combatMoves.Count; l++)
			{
				SpecialAbility component4 = items.m_combatMoves[l].GetComponent<SpecialAbility>();
				Debug.Log((object)((CharacterItem)component4).Entity.Name.ToString());
				gUID = ((CharacterItem)component4).Entity.GUID;
				if (dictionary.ContainsKey(((object)(DatabaseID)(ref gUID)).ToString()))
				{
					Debug.Log((object)("Have faulty guid: " + ((CharacterItem)component4).Entity.Name.ToString()));
					continue;
				}
				gUID = ((CharacterItem)component4).Entity.GUID;
				dictionary.Add(((object)(DatabaseID)(ref gUID)).ToString(), ((CharacterItem)component4).Entity.Name.ToString());
			}
			dictionary.Clear();
			Debug.Log((object)"---Done printing guids for items");
		}
	}
}
namespace HalloweenMod.Classes
{
	public class ArmorWraithSummon : MonoBehaviour
	{
		private List<Unit> wraiths = new List<Unit>();

		public Unit u;

		public Transform[] spawnPoints;

		public Transform linePoint;

		public UnitBlueprint bp_mainAttacker;

		public Transform unitHip;

		public void Go()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			Transform[] array = spawnPoints;
			Unit val2 = default(Unit);
			foreach (Transform val in array)
			{
				bp_mainAttacker.Spawn(val.position, val.rotation, u.Team, ref val2, 1f, false, false, 0, (UnitPoolInfo?)null);
				Rope[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Rope>();
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					componentsInChildren[j].positionobject2 = linePoint;
				}
				wraiths.Add(val2);
			}
		}

		public void RemoveUnit(Unit guy)
		{
			wraiths.Remove(guy);
		}

		private void Start()
		{
			u = ((Component)((Component)this).transform.root).GetComponentInParent<Unit>();
			unitHip = ((Component)u.data.hip).transform;
		}
	}
	public class ArmorWraith_Behavior : MonoBehaviour
	{
		[HideInInspector]
		public ArmorWraithSummon master;

		public Unit unit;

		public float rebuildDelay;

		public UnityEvent breakEvent;

		public UnityEvent deadEvent;

		public UnityEvent rebuildEvent;

		public UnityEvent doneEvent;

		private bool died;

		public Collider[] unitCols;

		public float breakHealth;

		private float breakHealthMax;

		[Tooltip("Speed Multiplier")]
		public float rebuildTime;

		private bool isBroken;

		public AnimationCurve returnCurve;

		[Tooltip("DEPREKATED")]
		public List<Rigidbody> breakRigs = new List<Rigidbody>();

		[Tooltip("DEPREKATED")]
		public List<Rigidbody> unitRigs = new List<Rigidbody>();

		public Vector2 randomRebuildSpeed;

		public List<ParticleSystem> allParticles = new List<ParticleSystem>();

		public List<TrailRenderer> allTrails = new List<TrailRenderer>();

		private List<Tag_ArmorWraithWeapon> armorWraithWeapons = new List<Tag_ArmorWraithWeapon>();

		public List<ConfigurableJoint> joints = new List<ConfigurableJoint>();

		public void SetMaster(ArmorWraithSummon transform)
		{
			master = transform;
		}

		private void Start()
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			breakHealth = unit.data.maxHealth;
			breakHealthMax = breakHealth;
			Weapon leftWeapon = unit.data.weaponHandler.leftWeapon;
			Weapon rightWeapon = unit.data.weaponHandler.rightWeapon;
			if (Object.op_Implicit((Object)(object)leftWeapon) && Object.op_Implicit((Object)(object)((Component)leftWeapon).GetComponent<Tag_ArmorWraithWeapon>()))
			{
				armorWraithWeapons.Add(((Component)leftWeapon).GetComponent<Tag_ArmorWraithWeapon>());
			}
			if (Object.op_Implicit((Object)(object)rightWeapon) && Object.op_Implicit((Object)(object)((Component)rightWeapon).GetComponent<Tag_ArmorWraithWeapon>()))
			{
				armorWraithWeapons.Add(((Component)rightWeapon).GetComponent<Tag_ArmorWraithWeapon>());
			}
			unit.data.healthHandler.deathEvent.AddListener(new UnityAction(Death));
		}

		public void Death()
		{
			if (!isBroken)
			{
				((MonoBehaviour)this).StartCoroutine(BreakApartDead());
				return;
			}
			((MonoBehaviour)this).StopAllCoroutines();
			((MonoBehaviour)this).StartCoroutine(BreakApartDead());
		}

		public IEnumerator BreakApartNormal()
		{
			breakEvent.Invoke();
			FreezeUnit(freeze: true);
			if (!isBroken)
			{
				isBroken = true;
			}
			for (int i = 0; i < breakRigs.Count; i++)
			{
				breakRigs[i].isKinematic = false;
				((Component)breakRigs[i]).GetComponentInChildren<Collider>().enabled = true;
			}
			for (int j = 0; j < armorWraithWeapons.Count; j++)
			{
				armorWraithWeapons[j].weaponCollider.GetComponent<Collider>().enabled = false;
				armorWraithWeapons[j].dropRig.isKinematic = false;
				armorWraithWeapons[j].dropCollider.GetComponent<Collider>().enabled = true;
			}
			yield return (object)new WaitForSeconds(rebuildDelay);
			float time = ((Keyframe)(ref returnCurve.keys[returnCurve.keys.Length - 1])).time;
			float c = 0f;
			rebuildEvent.Invoke();
			while (c < time)
			{
				for (int k = 0; k < breakRigs.Count; k++)
				{
					breakRigs[k].isKinematic = true;
					((Component)breakRigs[k]).transform.localPosition = Vector3.Lerp(((Component)breakRigs[k]).transform.localPosition, Vector3.zero, returnCurve.Evaluate(c) * Random.Range(randomRebuildSpeed.x, randomRebuildSpeed.y));
					((Component)breakRigs[k]).transform.localRotation = Quaternion.Lerp(((Component)breakRigs[k]).transform.localRotation, Quaternion.identity, returnCurve.Evaluate(c) * Random.Range(randomRebuildSpeed.x, randomRebuildSpeed.y));
				}
				for (int l = 0; l < armorWraithWeapons.Count; l++)
				{
					((Component)armorWraithWeapons[l].dropRig).transform.localPosition = Vector3.Lerp(((Component)armorWraithWeapons[l].dropRig).transform.localPosition, Vector3.zero, returnCurve.Evaluate(c) * Random.Range(randomRebuildSpeed.x, randomRebuildSpeed.y));
					((Component)armorWraithWeapons[l]).transform.localRotation = Quaternion.Lerp(((Component)armorWraithWeapons[l]).transform.localRotation, Quaternion.identity, returnCurve.Evaluate(c) * Random.Range(randomRebuildSpeed.x, randomRebuildSpeed.y));
				}
				c += Time.deltaTime * rebuildTime;
				yield return null;
			}
			breakHealthMax = breakHealth;
			FreezeUnit(freeze: false);
			for (int m = 0; m < armorWraithWeapons.Count; m++)
			{
				armorWraithWeapons[m].weaponCollider.GetComponent<Collider>().enabled = true;
				armorWraithWeapons[m].dropRig.isKinematic = true;
				armorWraithWeapons[m].dropCollider.GetComponent<Collider>().enabled = false;
			}
			for (int n = 0; n < breakRigs.Count; n++)
			{
				((Component)breakRigs[n]).GetComponentInChildren<Collider>().enabled = false;
			}
			doneEvent.Invoke();
			yield return (object)new WaitForSeconds(1f);
			if (isBroken)
			{
				isBroken = false;
			}
		}

		public IEnumerator BreakApartDead()
		{
			deadEvent.Invoke();
			FreezeUnit(freeze: true);
			yield break;
		}

		private void FreezeUnit(bool freeze)
		{
			for (int i = 0; i < unitRigs.Count; i++)
			{
				unitRigs[i].isKinematic = freeze;
			}
			if (!freeze)
			{
				for (int j = 0; j < unitCols.Length; j++)
				{
					if (!unitCols[j].enabled)
					{
						unitCols[j].enabled = true;
					}
				}
				return;
			}
			for (int k = 0; k < unitCols.Length; k++)
			{
				if (unitCols[k].enabled)
				{
					unitCols[k].enabled = false;
				}
			}
		}

		public void TakeDamage(float dmg)
		{
			if (!isBroken)
			{
				breakHealth -= dmg;
				breakHealth = Mathf.Clamp(breakHealth, float.NegativeInfinity, breakHealthMax);
				if (breakHealth <= 0f)
				{
					((MonoBehaviour)this).StartCoroutine(BreakApartJoints());
				}
			}
		}

		public void ManageParticles(bool hide)
		{
			if (!hide)
			{
				for (int i = 0; i < allParticles.Count; i++)
				{
					allParticles[i].Play();
				}
				for (int j = 0; j < allTrails.Count; j++)
				{
					allTrails[j].emitting = false;
				}
			}
			else
			{
				for (int k = 0; k < allParticles.Count; k++)
				{
					allParticles[k].Stop();
				}
				for (int l = 0; l < allTrails.Count; l++)
				{
					allTrails[l].emitting = true;
				}
			}
		}

		public IEnumerator BreakApartJoints()
		{
			breakEvent.Invoke();
			if (!isBroken)
			{
				isBroken = true;
			}
			for (int i = 0; i < joints.Count; i++)
			{
				joints[i].xMotion = (ConfigurableJointMotion)2;
				joints[i].yMotion = (ConfigurableJointMotion)2;
				joints[i].zMotion = (ConfigurableJointMotion)2;
			}
			yield return (object)new WaitForSeconds(rebuildDelay);
			for (int j = 0; j < joints.Count; j++)
			{
				joints[j].xMotion = (ConfigurableJointMotion)0;
				joints[j].yMotion = (ConfigurableJointMotion)0;
				joints[j].zMotion = (ConfigurableJointMotion)0;
			}
			rebuildEvent.Invoke();
			breakHealthMax = breakHealth;
			doneEvent.Invoke();
			yield return (object)new WaitForSeconds(1f);
			if (isBroken)
			{
				isBroken = false;
			}
		}
	}
}
namespace HalloweenMod.Tags
{
	public class Tag_ArmorWraithBodyPart : MonoBehaviour
	{
		public Transform originalTransform;

		private void Start()
		{
			originalTransform = ((Component)this).transform;
		}
	}
}
namespace HalloweenMod.Classes
{
	public class WarlockHandDraw : MonoBehaviour
	{
		public bool drawOnStart;

		[HideInInspector]
		public bool drawn;

		public bool callEvents = true;

		public UnityEvent DrawEvent;

		[HideInInspector]
		public bool stopAim;

		private bool hasHand;

		private DataHandler data;

		private Transform target;

		private Transform startPos;

		private Transform originalParent;

		private ConfigurableJoint handJoint;

		private Rigidbody handToCheck;

		private HealthHandler healthHandler;

		private RangeWeapon bow;

		private ConfigurableJoint[] handjoints;

		private void Start()
		{
			if (drawOnStart)
			{
				GoToHand(callEvents);
			}
		}

		public void GoToHand(bool callEvents)
		{
			if (!hasHand)
			{
				bow = ((Component)((Component)this).transform).GetComponentInParent<RangeWeapon>();
				if ((Object)(object)bow == (Object)null)
				{
					return;
				}
				startPos = ((Component)((Component)((Component)bow).transform).GetComponentInChildren<StringStartPos>()).transform;
				originalParent = ((Component)this).transform.parent;
				target = ((Component)((Component)((Component)this).transform.root).GetComponentInChildren<HandRight>()).transform;
				healthHandler = ((Component)((Component)this).transform.root).GetComponentInChildren<HealthHandler>();
				if (Object.op_Implicit((Object)(object)healthHandler))
				{
					healthHandler.AddDieAction((Action)ResetPos);
				}
				handjoints = ((Component)((Component)bow).transform).GetComponents<ConfigurableJoint>();
				for (int i = 0; i < handjoints.Length; i++)
				{
					if (handjoints.Length > 1)
					{
						handToCheck = ((Joint)handjoints[i]).connectedBody;
						if (Object.op_Implicit((Object)(object)handToCheck) && Object.op_Implicit((Object)(object)((Component)((Component)handToCheck).transform).GetComponent<HandLeft>()))
						{
							handJoint = handjoints[i];
							hasHand = true;
						}
					}
				}
			}
			if (drawn || !hasHand)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)handJoint))
			{
				handJoint.yMotion = (ConfigurableJointMotion)2;
			}
			if (Object.op_Implicit((Object)(object)target))
			{
				((Component)this).transform.SetParent(target);
				if (callEvents)
				{
					DrawEvent.Invoke();
				}
			}
			drawn = true;
		}

		public void GoToStartPos()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (drawn)
			{
				if (Object.op_Implicit((Object)(object)handJoint))
				{
					handJoint.yMotion = (ConfigurableJointMotion)0;
				}
				((Component)this).transform.SetParent(originalParent);
				((Component)this).transform.localPosition = startPos.localPosition;
				((Component)this).transform.localRotation = startPos.localRotation;
				((Component)this).transform.localScale = startPos.localScale;
				drawn = false;
			}
		}

		public void ResetPos()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.SetParent(originalParent);
			((Component)this).transform.localPosition = startPos.localPosition;
			((Component)this).transform.localRotation = startPos.localRotation;
			if (Object.op_Implicit((Object)(object)handJoint))
			{
				handJoint.yMotion = (ConfigurableJointMotion)0;
			}
			stopAim = true;
			drawn = false;
		}
	}
}
namespace HalloweenMod.Patches
{
	[HarmonyPatch(typeof(HealthHandler), "TakeDamage")]
	internal class ArmorWraithTakeHit
	{
		public static bool Prefix(ProjectileHit __instance, float damage, Vector3 direction, Unit damager = null, DamageType damageType = 0)
		{
			ArmorWraith_Behavior componentInChildren = ((Component)((Component)__instance).transform.root).GetComponentInChildren<ArmorWraith_Behavior>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				componentInChildren.TakeDamage(damage);
				return false;
			}
			return true;
		}
	}
}
namespace HalloweenMod.Tags
{
	public class Tag_ArmorWraithWeapon : MonoBehaviour
	{
		public Rigidbody dropRig;

		public GameObject dropCollider;

		public GameObject weaponCollider;
	}
}
namespace HalloweenMod.Classes
{
	public class ProjectileFlyEater : ProjectileHitEffect
	{
		public float force;

		private Unit currentTarget;

		private SphereCastUnitsTarget target;

		private bool homing;

		public float velocityPreditction;

		public Transform mid;

		public UnityEvent eventOnBounce;

		private ProjectileHit phit;

		public UnityEvent eventOnFail;

		private void Start()
		{
			phit = ((Component)this).GetComponent<ProjectileHit>();
			target = ((Component)this).GetComponent<SphereCastUnitsTarget>();
		}

		public override bool DoEffect(HitData hit)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)hit.transform).gameObject.layer != LayerMask.NameToLayer("Map"))
			{
				return false;
			}
			eventOnBounce.Invoke();
			Unit unitTarget = target.GetUnitTarget();
			if ((Object)(object)unitTarget != (Object)null)
			{
				currentTarget = unitTarget;
				ResetProjectile();
				phit.move.velocity = Vector3.zero;
				phit.move.UpdateVelMultiplier(2f);
				if (!homing)
				{
					phit.move.gravity = 0f;
					homing = true;
				}
				return false;
			}
			eventOnFail.Invoke();
			return true;
		}

		private void Update()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			if (homing)
			{
				if ((Object)(object)currentTarget != (Object)null)
				{
					MoveTransform move = phit.move;
					Vector3 velocity = move.velocity;
					Vector3 val = currentTarget.data.mainRig.position + currentTarget.data.mainRig.velocity * velocityPreditction - ((Component)this).transform.position;
					move.velocity = velocity + ((Vector3)(ref val)).normalized * force * Time.deltaTime * force;
				}
				else
				{
					homing = false;
				}
			}
		}

		public void ResetProjectile()
		{
			phit.stick.stuck = false;
			phit.stick.target = null;
			phit.stick.targetRig = null;
			phit.done = false;
			phit.allowRepeat = true;
			if (Object.op_Implicit((Object)(object)phit.move) && Object.op_Implicit((Object)(object)phit.stick))
			{
				((Behaviour)phit.move).enabled = true;
			}
			if (Object.op_Implicit((Object)(object)phit.trail))
			{
				((Behaviour)phit.trail).enabled = true;
			}
		}
	}
	public class ManflyWingControl : MonoBehaviour
	{
		public float offDelay;

		public string onAnim;

		public string offAnim;

		private DataHandler data;

		private bool wingsEnabled;

		private Wings wings;

		public PlayAnimationByEvent m_animation;

		private void Start()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			data = ((Component)((Component)this).transform.root).GetComponentInChildren<DataHandler>();
			wings = ((Component)this).GetComponent<Wings>();
			if ((Object)(object)data.weaponHandler.rightWeapon != (Object)null)
			{
				RangeWeapon val = default(RangeWeapon);
				((Component)data.weaponHandler.rightWeapon).TryGetComponent<RangeWeapon>(ref val);
				if ((Object)(object)val != (Object)null)
				{
					val.AddAttackCallRecievedAction((Action)Enable);
					val.shootEndEvent.AddListener(new UnityAction(Disable));
				}
			}
			if ((Object)(object)data.weaponHandler.leftWeapon != (Object)null)
			{
				RangeWeapon val2 = default(RangeWeapon);
				((Component)data.weaponHandler.leftWeapon).TryGetComponent<RangeWeapon>(ref val2);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.AddAttackCallRecievedAction((Action)Enable);
					val2.shootEndEvent.AddListener(new UnityAction(Disable));
				}
			}
		}

		public void Enable()
		{
			if (!wingsEnabled)
			{
				wingsEnabled = true;
				wings.EnableFlight();
				m_animation.PlayForAll(onAnim);
			}
		}

		public void Disable()
		{
			if (wingsEnabled)
			{
				wingsEnabled = false;
				((MonoBehaviour)this).StartCoroutine(DisableDelay());
			}
		}

		private IEnumerator DisableDelay()
		{
			yield return (object)new WaitForSeconds(offDelay);
			DisableWings();
		}

		private void DisableWings()
		{
			wings.DiableFlight();
			m_animation.PlayForAll(offAnim);
		}
	}
	public class Effect_Stinky : UnitEffectBase
	{
		public float forceTorque = 100f;

		public float forceAcceler = 2000f;

		public float removeTime = 0.5f;

		[SerializeField]
		private int fliesAttached;

		private float timer;

		public float rate;

		public float damagePerFly;

		public override void DoEffect()
		{
			((UnitEffectBase)this).Ping();
		}

		public override void Ping()
		{
			((MonoBehaviour)this).StartCoroutine(AddFlyBite());
		}

		private void FixedUpdate()
		{
			//IL_0032: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (fliesAttached > 0)
			{
				for (int i = 0; i < ((Component)((Component)((Component)this).transform.root).GetComponent<Unit>().data).GetComponent<RigidbodyHolder>().AllRigs.Length; i++)
				{
					Rigidbody obj = ((Component)((Component)((Component)this).transform.root).GetComponent<Unit>().data).GetComponent<RigidbodyHolder>().AllRigs[i];
					obj.AddTorque(Random.insideUnitSphere * (forceTorque * Mathf.Cos(Time.time * 10f)), (ForceMode)0);
					obj.AddTorque(Random.insideUnitSphere * (forceAcceler * Mathf.Cos(Time.time * 10f)), (ForceMode)5);
				}
			}
		}

		private IEnumerator AddFlyBite()
		{
			fliesAttached++;
			yield return (object)new WaitForSeconds(removeTime);
			if (fliesAttached > 0)
			{
				fliesAttached--;
			}
		}

		public void Update()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (fliesAttached <= 0)
			{
				return;
			}
			HealthHandler componentInParent = ((Component)((Component)this).transform).GetComponentInParent<HealthHandler>();
			if (Object.op_Implicit((Object)(object)componentInParent))
			{
				timer += 1f * Time.deltaTime;
				if (timer >= rate)
				{
					timer = 0f;
					((Damagable)componentInParent).TakeDamage((float)fliesAttached * damagePerFly, Vector3.down, (Unit)null, (DamageType)0);
				}
			}
		}
	}
	public class SayanParticles : MonoBehaviour
	{
		private void Start()
		{
			if (!Application.isEditor && Bugs._DLC_ACTIVATED && SpookifiedNewContentManager.value_BugFlagmanSayan == 1)
			{
				((Component)this).GetComponentInChildren<ParticleSystem>().Play();
			}
		}
	}
}