Decompiled source of TechnicalItems v1.0.21

TechnicalItems.dll

Decompiled 3 weeks 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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DM;
using FhpSLib;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.AI.Components;
using Landfall.TABS.UnitEditor;
using SLMA;
using TFBGames;
using TI;
using TI.Patched;
using TI.Patched.Generated;
using TIComponents;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("TechnicalItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("TechnicalItems")]
[assembly: AssemblyCopyright("Copyright © 4Ever")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.21.0")]
[module: UnverifiableCode]
namespace TIHarmonyPatches
{
	[HarmonyPatch(typeof(HealthHandler), "TakeDamage")]
	internal class HealthHandlerTakeDamagePatch
	{
		private static readonly FieldInfo dataField;

		private static readonly FieldInfo invulnField;

		private static void Prefix(HealthHandler __instance, float damage)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			if (float.IsNaN(damage) || float.IsInfinity(damage) || damage == 0f)
			{
				return;
			}
			FieldInfo fieldInfo = dataField;
			object obj = ((fieldInfo != null) ? fieldInfo.GetValue(__instance) : null);
			DataHandler val = (DataHandler)((obj is DataHandler) ? obj : null);
			FieldInfo fieldInfo2 = invulnField;
			bool valueOrDefault = ((fieldInfo2 != null) ? fieldInfo2.GetValue(__instance) : null) as bool? == true;
			if ((Object)(object)val == (Object)null || val.Dead || valueOrDefault)
			{
				return;
			}
			if (val.lifeTime >= 0.3f && (val.immunityForSeconds <= 0f || damage < 0f))
			{
				SmartHealingItemBehaviour componentInChildren = ((Component)val.unit).GetComponentInChildren<SmartHealingItemBehaviour>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.sinceDamaged = 3f;
				}
			}
			if (val.lifeTime >= 0.3f && damage >= val.health)
			{
				SmartTransformToRiderBehaviour componentInChildren2 = ((Component)val.unit).GetComponentInChildren<SmartTransformToRiderBehaviour>();
				if ((Object)(object)componentInChildren2 != (Object)null && componentInChildren2.onDeathActivate)
				{
					val.immunityForSeconds = float.PositiveInfinity;
					val.health = float.PositiveInfinity;
					componentInChildren2.Spawn();
				}
			}
		}

		static HealthHandlerTakeDamagePatch()
		{
			dataField = typeof(HealthHandler).GetField("data", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			invulnField = typeof(HealthHandler).GetField("isInvulnerable", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
	}
	[HarmonyPatch(typeof(SetParent), "Doit")]
	internal static class SetParentDoitPatch
	{
		private static bool Prefix(SetParent __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(CheckLater(__instance));
			return true;
		}

		public static void DestroyChildModels(GameObject inObject)
		{
			Renderer[] componentsInChildren = inObject.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!(val is ParticleSystemRenderer))
				{
					Object.Destroy((Object)(object)val);
				}
			}
		}

		private static IEnumerator CheckLater(SetParent setParent)
		{
			yield return (object)new WaitForSeconds(0.1f);
			if (!((Object)(object)setParent == (Object)null) && !((Object)(object)setParent.parentBefore == (Object)null))
			{
				Transform root = setParent.parentBefore.root;
				Loader.Log("Transform root on: " + ((Object)root).name);
				if ((Object)(object)((Component)root).GetComponentInChildren<DestroyAbilitiesModelBehaviour>(true) != (Object)null)
				{
					Loader.Log("Deleting child models on: " + ((Object)((Component)setParent).gameObject).name);
					DestroyChildModels(((Component)setParent).gameObject);
				}
				if ((Object)(object)((Component)root).GetComponentInChildren<DestroyAbilitiesParticlesBehaviour>(true) != (Object)null)
				{
					Loader.Log("Deleting child particles on: " + ((Object)((Component)setParent).gameObject).name);
					DestroyChildParticles(((Component)setParent).gameObject);
				}
				else
				{
					Loader.LogWarning("No Hide Ability Model found.");
				}
			}
		}

		public static void DestroyChildParticles(GameObject inObject)
		{
			Renderer[] componentsInChildren = inObject.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (val is ParticleSystemRenderer)
				{
					Object.Destroy((Object)(object)val);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Unit), "Awake")]
	public class UnitAwakePatch
	{
		private static bool enable;

		private static void Postfix(Unit __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.data == (Object)null || !enable || (int)__instance.unitType != 1 || (int)__instance.RigType != 0)
			{
				return;
			}
			if ((Object)(object)__instance.data.mainRig == (Object)null)
			{
				Debug.LogWarning((object)"[UnitAwakePatch] Unit.data.mainRig is null, skipping.");
				return;
			}
			Debug.Log((object)("[UnitAwakePatch] Checking warmachine rig: " + ((Object)__instance).name));
			if ((Object)(object)((Component)__instance).GetComponentInChildren<UnitRig>() != (Object)null)
			{
				Debug.Log((object)"[UnitAwakePatch] Existing UnitRig found in child object.");
				return;
			}
			Loader.Log("[UnitAwakePatch] Injecting custom UnitRig.");
			UnitRig val = ((Component)__instance).gameObject.AddComponent<UnitRig>();
			Transform transform = ((Component)__instance.data.mainRig).transform;
			Transform val2 = transform.Find("Rigidbodies") ?? new GameObject("Rigidbodies").transform;
			val2.SetParent(transform, false);
			val2.localPosition = Vector3.zero;
			Transform parent = CreateBone("M_Armature", val2);
			val.m_waist = AssignIfNull(val.m_waist, CreateBone("M_Hip", parent));
			val.m_torso = AssignIfNull(val.m_torso, CreateBone("M_Torso", val.m_waist));
			val.m_neck = AssignIfNull(val.m_neck, CreateBone("M_Neck", val.m_torso));
			val.m_head = AssignIfNull(val.m_head, CreateBone("M_Head", val.m_neck));
			val.m_legLeft = AssignIfNull(val.m_legLeft, CreateBone("M_Leg_Left", val.m_waist));
			val.m_footLeft = AssignIfNull(val.m_footLeft, CreateBone("M_Foot_Left", val.m_legLeft));
			val.m_legRight = AssignIfNull(val.m_legRight, CreateBone("M_Leg_Right", val.m_waist));
			val.m_footRight = AssignIfNull(val.m_footRight, CreateBone("M_Foot_Right", val.m_legRight));
			val.m_armLeft = AssignIfNull(val.m_armLeft, CreateBone("M_Arm_Left", val.m_torso));
			val.m_shoulderLeft = AssignIfNull(val.m_shoulderLeft, CreateBone("M_Shoulder_Left", val.m_armLeft));
			val.m_wristLeft = AssignIfNull(val.m_wristLeft, CreateBone("M_Wrist_Left", val.m_shoulderLeft));
			CreateBone("M_Hand_Left", val.m_wristLeft);
			val.m_armRight = AssignIfNull(val.m_armRight, CreateBone("M_Arm_Right", val.m_torso));
			val.m_shoulderRight = AssignIfNull(val.m_shoulderRight, CreateBone("M_Shoulder_Right", val.m_armRight));
			val.m_wristRight = AssignIfNull(val.m_wristRight, CreateBone("M_Wrist_Right", val.m_shoulderRight));
			CreateBone("M_Hand_Right", val.m_wristRight);
		}

		private static Transform CreateBone(string name, Transform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			GameObject val2 = new GameObject(name);
			val2.transform.SetParent(parent, false);
			val2.transform.localPosition = Vector3.zero;
			return val2.transform;
		}

		private static Transform AssignIfNull(Transform current, Transform fallback)
		{
			if (!((Object)(object)current != (Object)null))
			{
				return fallback;
			}
			return current;
		}

		static UnitAwakePatch()
		{
			enable = true;
		}
	}
}
namespace TIComponents
{
	public class AbilityRemoveSoundBehaviour : MonoBehaviour
	{
		private void Start()
		{
			SpecialAbility[] componentsInChildren = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentsInChildren<SpecialAbility>();
			foreach (SpecialAbility val in componentsInChildren)
			{
				AudioSource[] componentsInChildren2 = ((Component)val).gameObject.GetComponentsInChildren<AudioSource>();
				for (int j = 0; j < componentsInChildren2.Length; j++)
				{
					Object.Destroy((Object)(object)componentsInChildren2[j]);
				}
				PlaySoundEffect[] componentsInChildren3 = ((Component)val).gameObject.GetComponentsInChildren<PlaySoundEffect>();
				for (int k = 0; k < componentsInChildren3.Length; k++)
				{
					Object.Destroy((Object)(object)componentsInChildren3[k]);
				}
			}
		}
	}
	public class AdaptiveBurstBehaviour : MonoBehaviour
	{
		private Color color;

		private Unit unit;

		private RangeWeapon[] rangeWeapons;

		private SpawnObject[] spawnObjects;

		private ParticleSystem[] particleSystems;

		private ParticleSystemRenderer[] particleRenderers;

		private GameObject currentProjectile;

		private float refreshTimer;

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			spawnObjects = ((Component)this).GetComponentsInChildren<SpawnObject>();
			particleSystems = ((Component)this).GetComponentsInChildren<ParticleSystem>();
			particleRenderers = ((Component)this).GetComponentsInChildren<ParticleSystemRenderer>();
			Refresh();
		}

		private void Update()
		{
			refreshTimer += Time.deltaTime;
			if (refreshTimer >= 0.25f)
			{
				refreshTimer = 0f;
				Refresh();
			}
		}

		private void Refresh()
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)unit == (Object)null)
			{
				return;
			}
			rangeWeapons = ((Component)unit).GetComponentsInChildren<RangeWeapon>();
			if (rangeWeapons == null || rangeWeapons.Length == 0)
			{
				return;
			}
			int num = Random.Range(0, rangeWeapons.Length);
			if ((Object)(object)rangeWeapons[num] == (Object)null || (Object)(object)rangeWeapons[num].ObjectToSpawn == (Object)null)
			{
				return;
			}
			GameObject objectToSpawn = rangeWeapons[num].ObjectToSpawn;
			if ((Object)(object)objectToSpawn == (Object)(object)currentProjectile)
			{
				return;
			}
			currentProjectile = objectToSpawn;
			for (int i = 0; i < spawnObjects.Length; i++)
			{
				spawnObjects[i].objectToSpawn = objectToSpawn;
			}
			Renderer componentInChildren = objectToSpawn.GetComponentInChildren<Renderer>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				color = componentInChildren.sharedMaterial.color;
			}
			for (int j = 0; j < particleSystems.Length; j++)
			{
				MainModule main = particleSystems[j].main;
				((MainModule)(ref main)).startColor = new MinMaxGradient(color);
			}
			for (int k = 0; k < particleRenderers.Length; k++)
			{
				if ((Object)(object)((Renderer)particleRenderers[k]).sharedMaterial != (Object)null)
				{
					((Renderer)particleRenderers[k]).sharedMaterial.color = color;
				}
				if ((Object)(object)particleRenderers[k].trailMaterial != (Object)null)
				{
					particleRenderers[k].trailMaterial.color = color;
				}
			}
		}
	}
	public class AdaptiveCastBehaviour : MonoBehaviour
	{
		public delegate void AttackedEventHandler(Rigidbody target, int useAttackID);

		public UnityEvent shootEvent;

		private ShootPosition[] swordPoints;

		private List<SpookySword> swords = new List<SpookySword>();

		public GameObject projToCopyCodeAnimation;

		private GameObject hiddenParent;

		private RangeWeapon[] rangeWeapons;

		private Unit unit;

		public float followSpeed = 1f;

		public float throwSpeed = 100f;

		public AnimationCurve throwCurve;

		private float counter;

		private DataHandler data;

		private bool done;

		public float attackRate;

		private float attackspeedMulti = 1f;

		private int attackID;

		public GameObject sourceSword;

		private GameObject currentProjectilePrefab;

		private float projectileRefreshTimer;

		public event AttackedEventHandler Attacked;

		private void Start()
		{
			((MonoBehaviour)this).StartCoroutine(DelayedInit());
		}

		private void Update()
		{
			//IL_0362: 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_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//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_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				projectileRefreshTimer += Time.deltaTime;
				if (projectileRefreshTimer >= 0.25f)
				{
					projectileRefreshTimer = 0f;
					RefreshProjectile();
				}
				if (rangeWeapons != null && (Object)(object)unit != (Object)null)
				{
					if (rangeWeapons.Length == 0)
					{
						Loader.LogWarning("No RangeWeapons found on unit.");
					}
					else
					{
						int num = Random.Range(0, rangeWeapons.Length);
						RangeWeapon val = rangeWeapons[num];
						GameObject val2 = (((Object)(object)val != (Object)null) ? val.ObjectToSpawn : null);
						if ((Object)(object)val2 == (Object)null)
						{
							Loader.LogError("Selected RangeWeapon has null ObjectToSpawn.");
						}
						else
						{
							sourceSword = MakeTempCopy(val2);
						}
					}
				}
				if (done)
				{
					return;
				}
				if ((Object)(object)data != (Object)null && data.Dead)
				{
					done = true;
					for (int i = 0; i < swords.Count; i++)
					{
						attackID = i;
						Attack(data.mainRig, attackID);
					}
					return;
				}
				float num2 = Mathf.Clamp(Time.deltaTime, 0f, 0.02f);
				DataHandler val3 = data;
				if ((Object)(object)(((Object)(object)val3 != (Object)null) ? val3.weaponHandler : null) != (Object)null)
				{
					attackspeedMulti = data.weaponHandler.attackSpeedMultiplier;
				}
				DataHandler val4 = data;
				bool num3 = (Object)(object)(((Object)(object)val4 != (Object)null) ? val4.unit : null) == (Object)null || !data.unit.IsRemotelyControlled;
				counter += Time.deltaTime * attackspeedMulti;
				if (num3)
				{
					DataHandler val5 = data;
					if ((Object)(object)(((Object)(object)val5 != (Object)null) ? val5.targetMainRig : null) != (Object)null && counter > attackRate)
					{
						float num4 = 999f;
						for (int j = 0; j < swordPoints.Length; j++)
						{
							if (swords.Count > j && swords[j] != null && !((Object)(object)swordPoints[j] == (Object)null))
							{
								float num5 = Vector3.Angle(data.targetMainRig.position - ((Component)this).transform.position, ((Component)swordPoints[j]).transform.position - ((Component)this).transform.position);
								if (num5 < num4 && swords[j].sinceSpawn > 1.5f)
								{
									num4 = num5;
									attackID = j;
								}
							}
						}
						if (data.distanceToTarget < 10f)
						{
							Attack(data.targetMainRig, attackID);
						}
					}
				}
				for (int k = 0; k < swords.Count; k++)
				{
					SpookySword val6 = swords[k];
					if (!((Object)(object)val6?.gameObject == (Object)null) && swordPoints.Length > k && !((Object)(object)swordPoints[k] == (Object)null))
					{
						val6.sinceSpawn += num2;
						val6.move.velocity = float3.op_Implicit(float3.op_Implicit(((Component)swordPoints[k]).transform.position) - float3.op_Implicit(val6.gameObject.transform.position)) * followSpeed;
						val6.gameObject.transform.rotation = quaternion.op_Implicit(quaternion.LookRotation(float3.op_Implicit(Vector3.up), float3.op_Implicit(((Component)swordPoints[k]).transform.position) - float3.op_Implicit(((Component)this).transform.position)));
					}
				}
			}
			catch (Exception ex)
			{
				Loader.LogError("Error in Update: " + ex.Message);
			}
		}

		public void Attack(Rigidbody target, int useAttackID)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				counter = 0f;
				if (useAttackID < 0 || useAttackID >= swords.Count || useAttackID >= swordPoints.Length)
				{
					Loader.LogWarning($"[AdaptiveCast] Invalid attackID: {useAttackID}. swords.Count = {swords.Count}, swordPoints.Length = {swordPoints.Length}");
					return;
				}
				SpookySword val = swords[useAttackID];
				if (val == null || (Object)(object)val.gameObject == (Object)null)
				{
					return;
				}
				((MonoBehaviour)this).StartCoroutine(DoAttack(val, target));
				UnityEvent val2 = shootEvent;
				if (val2 != null)
				{
					val2.Invoke();
				}
				if (!done)
				{
					swords[useAttackID] = CreateNewSword(((Component)swordPoints[useAttackID]).transform.position, quaternion.op_Implicit(((Component)swordPoints[useAttackID]).transform.rotation));
				}
				else
				{
					ProjectileHit component = val.gameObject.GetComponent<ProjectileHit>();
					if ((Object)(object)component != (Object)null)
					{
						component.ignoreTeamMates = false;
					}
				}
				this.Attacked?.Invoke(target, useAttackID);
			}
			catch (Exception ex)
			{
				Loader.LogError("[AdaptiveCast] Error in Attack: " + ex.Message);
			}
		}

		private void OnDestroy()
		{
			try
			{
				((MonoBehaviour)this).StopAllCoroutines();
				foreach (SpookySword sword in swords)
				{
					if ((Object)(object)sword?.gameObject != (Object)null)
					{
						Object.Destroy((Object)(object)sword.gameObject);
					}
				}
			}
			catch (Exception ex)
			{
				Loader.LogError("[AdaptiveCast] Error in OnDestroy: " + ex.Message);
			}
		}

		private IEnumerator DoAttack(SpookySword attackSword, Rigidbody targ)
		{
			if ((Object)(object)attackSword?.gameObject == (Object)null || (Object)(object)targ == (Object)null)
			{
				yield break;
			}
			float counter = 0f;
			float duration = ((Keyframe)(ref throwCurve.keys[throwCurve.length - 1])).time;
			ProjectileStick stick = attackSword.gameObject.GetComponent<ProjectileStick>();
			RaycastTrail component = attackSword.gameObject.GetComponent<RaycastTrail>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = true;
			}
			while (counter < duration && ((Object)(object)stick == (Object)null || !stick.stuck))
			{
				if ((Object)(object)attackSword.gameObject == (Object)null || (Object)(object)targ == (Object)null)
				{
					yield break;
				}
				float num = Mathf.Clamp(Time.deltaTime, 0f, 0.02f);
				counter += Time.deltaTime;
				Vector3 val = targ.position - attackSword.gameObject.transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				attackSword.move.velocity = Vector3.Lerp(attackSword.move.velocity, throwCurve.Evaluate(counter) * throwSpeed * normalized, num * 8f);
				attackSword.gameObject.transform.rotation = Quaternion.Lerp(attackSword.gameObject.transform.rotation, quaternion.op_Implicit(quaternion.LookRotation(float3.op_Implicit(normalized), float3.op_Implicit(Vector3.up))), num * 7f);
				yield return null;
			}
			counter = 0f;
			while (counter < 0.5f && ((Object)(object)stick == (Object)null || !stick.stuck))
			{
				float num2 = Mathf.Clamp(Time.deltaTime, 0f, 0.02f);
				counter += Time.deltaTime;
				if ((Object)(object)attackSword.gameObject != (Object)null)
				{
					attackSword.gameObject.transform.rotation = Quaternion.Lerp(attackSword.gameObject.transform.rotation, quaternion.op_Implicit(quaternion.LookRotation(float3.op_Implicit(attackSword.move.velocity), float3.op_Implicit(Vector3.up))), num2 * 15f);
				}
				yield return null;
			}
		}

		private SpookySword CreateNewSword(Vector3 pos, quaternion rot)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0028: 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_002a: 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)
			SpookySword val = new SpookySword();
			if ((Object)(object)sourceSword == (Object)null)
			{
				Loader.LogError("[AdaptiveCast] CreateNewSword failed: sourceSword is null.");
				return null;
			}
			try
			{
				val.gameObject = Object.Instantiate<GameObject>(sourceSword, pos, quaternion.op_Implicit(rot));
				val.move = val.gameObject.GetComponent<MoveTransform>();
				TeamHolder val2 = GameObjectExtensions.FetchComponent<TeamHolder>(val.gameObject);
				if ((Object)(object)val2 != (Object)null && (Object)(object)data != (Object)null)
				{
					val2.team = data.team;
				}
				CodeAnimation componentInChildren = val.gameObject.GetComponentInChildren<CodeAnimation>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.animationSpeed = attackspeedMulti;
				}
			}
			catch (Exception ex)
			{
				Loader.LogError("[AdaptiveCast] Error in CreateNewSword: " + ex.Message);
				return null;
			}
			return val;
		}

		private void SetHiddenParent()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			hiddenParent = new GameObject
			{
				hideFlags = (HideFlags)61
			};
			hiddenParent.SetActive(false);
		}

		private GameObject MakeTempCopy(GameObject gameObjectToCopy)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0055: 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)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			if ((Object)(object)gameObjectToCopy == (Object)null)
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(gameObjectToCopy, hiddenParent.transform);
			RaycastTrail componentInChildren = val.GetComponentInChildren<RaycastTrail>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((Behaviour)componentInChildren).enabled = false;
			}
			MoveTransform componentInChildren2 = val.GetComponentInChildren<MoveTransform>();
			if ((Object)(object)componentInChildren2 != (Object)null)
			{
				componentInChildren2.worldImpulse = Vector3.zero;
				componentInChildren2.selfImpulse = Vector3.zero;
				componentInChildren2.gravity = 0f;
				componentInChildren2.velocity = Vector3.zero;
				componentInChildren2.drag = 0f;
				componentInChildren2.randomVelocitySpread = 0f;
				componentInChildren2.sprea = 0f;
				componentInChildren2.rotationFollowVelocity = false;
				componentInChildren2.UseCappedDeltaTime = true;
				componentInChildren2.lateVelocityInit = false;
			}
			RemoveAfterSeconds componentInChildren3 = val.GetComponentInChildren<RemoveAfterSeconds>();
			if ((Object)(object)componentInChildren3 != (Object)null)
			{
				componentInChildren3.seconds = float.PositiveInfinity;
			}
			if ((Object)(object)val.GetComponentInChildren<CodeAnimation>() == (Object)null && (Object)(object)projToCopyCodeAnimation != (Object)null)
			{
				CodeAnimation componentInChildren4 = projToCopyCodeAnimation.GetComponentInChildren<CodeAnimation>();
				if ((Object)(object)componentInChildren4 != (Object)null)
				{
					s.DeepCopyOf<CodeAnimation>(val.AddComponent<CodeAnimation>(), componentInChildren4);
				}
			}
			if ((Object)(object)val.GetComponentInChildren<TeamHolder>() == (Object)null && (Object)(object)unit != (Object)null)
			{
				TeamHolder val2 = new TeamHolder
				{
					spawner = ((Component)this).gameObject,
					team = unit.Team
				};
				TeamHolder.AddTeamHolder(val, unit, val2);
			}
			return val;
		}

		private void Awake()
		{
			try
			{
				swordPoints = ((Component)this).GetComponentsInChildren<ShootPosition>();
				unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
				SetHiddenParent();
				if ((Object)(object)unit != (Object)null)
				{
					RefreshProjectile();
				}
			}
			catch (Exception ex)
			{
				Loader.LogError("[AdaptiveCast] Error in Awake: " + ex.Message);
			}
		}

		private IEnumerator DelayedInit()
		{
			yield return (object)new WaitForSeconds(0.5f);
			try
			{
				unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
				if ((Object)(object)unit != (Object)null && (Object)(object)sourceSword == (Object)null)
				{
					RefreshProjectile();
				}
				data = ((Component)((Component)this).transform.root).GetComponentInChildren<DataHandler>();
				List<Renderer> list = new List<Renderer>();
				ShootPosition[] array = swordPoints;
				foreach (ShootPosition val in array)
				{
					if (!((Object)(object)val == (Object)null))
					{
						SpookySword val2 = CreateNewSword(((Component)val).transform.position + Vector3.up * 2f, quaternion.op_Implicit(((Component)val).transform.rotation));
						if ((Object)(object)val2?.gameObject != (Object)null)
						{
							list.AddRange(val2.gameObject.GetComponentsInChildren<Renderer>());
							swords.Add(val2);
						}
					}
				}
				DataHandler val3 = data;
				if ((Object)(object)(((Object)(object)val3 != (Object)null) ? val3.unit : null) != (Object)null)
				{
					data.unit.AddRenderersToShowHide(list.ToArray(), data.unit.IsSpawnedInBlindPlacement);
				}
			}
			catch (Exception ex)
			{
				Loader.LogError("[AdaptiveCast] Error in DelayedInit: " + ex.Message);
			}
		}

		private void RefreshProjectile()
		{
			if ((Object)(object)unit == (Object)null)
			{
				return;
			}
			rangeWeapons = ((Component)unit).GetComponentsInChildren<RangeWeapon>();
			if (rangeWeapons == null || rangeWeapons.Length == 0)
			{
				return;
			}
			int num = Random.Range(0, rangeWeapons.Length);
			RangeWeapon val = rangeWeapons[num];
			if ((Object)(object)val == (Object)null || (Object)(object)val.ObjectToSpawn == (Object)null)
			{
				return;
			}
			GameObject objectToSpawn = val.ObjectToSpawn;
			if (!((Object)(object)objectToSpawn == (Object)(object)currentProjectilePrefab))
			{
				currentProjectilePrefab = objectToSpawn;
				if ((Object)(object)sourceSword != (Object)null)
				{
					Object.Destroy((Object)(object)sourceSword);
				}
				sourceSword = MakeTempCopy(objectToSpawn);
			}
		}
	}
	public class AdaptiveThrowBehaviour : MonoBehaviour
	{
		private Unit unit;

		private RangeWeapon[] rangeWeapons;

		private int lastRangeWeaponCount;

		private int lastSpawnObjectCount;

		private SpawnObject[] spawnObjects;

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			rangeWeapons = ((Component)unit).GetComponentsInChildren<RangeWeapon>();
		}

		private void Update()
		{
			int num = ((Component)unit).GetComponentsInChildren<RangeWeapon>().Length;
			int num2 = ((Component)this).GetComponentsInChildren<SpawnObject>().Length;
			if (num != lastRangeWeaponCount || num2 != lastSpawnObjectCount)
			{
				lastRangeWeaponCount = num;
				lastSpawnObjectCount = num2;
				rangeWeapons = ((Component)unit).GetComponentsInChildren<RangeWeapon>();
				spawnObjects = ((Component)this).GetComponentsInChildren<SpawnObject>();
			}
			if (rangeWeapons != null && rangeWeapons.Length != 0)
			{
				GameObject objectToSpawn = rangeWeapons[Random.Range(0, rangeWeapons.Length)].ObjectToSpawn;
				for (int i = 0; i < spawnObjects.Length; i++)
				{
					spawnObjects[i].objectToSpawn = objectToSpawn;
				}
			}
		}
	}
	public class AddMeleeBlinkBehaviour : MonoBehaviour
	{
		private Unit unit;

		private MeleeWeapon[] meleeWeapons;

		private void Start()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			meleeWeapons = ((Component)unit).GetComponentsInChildren<MeleeWeapon>();
			MeleeWeapon[] array = meleeWeapons;
			for (int i = 0; i < array.Length; i++)
			{
				List<AttackEffect> list = new List<AttackEffect>(((Weapon)array[i]).attackEffects);
				list.Add((AttackEffect)((Component)array[i]).gameObject.AddComponent<BlinkDagger>());
				((Weapon)array[i]).attackEffects = list.ToArray();
			}
		}
	}
	public class AddMeleeDissarmBehaviour : MonoBehaviour
	{
		private Unit unit;

		private MeleeWeapon[] meleeWeapons;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			meleeWeapons = ((Component)unit).GetComponentsInChildren<MeleeWeapon>();
			MeleeWeapon[] array = meleeWeapons;
			for (int i = 0; i < array.Length; i++)
			{
				((Component)array[i]).gameObject.AddComponent<MeleeWeaponDissarm>();
			}
		}
	}
	public class AddSmartMeleeDashBehaviour : MonoBehaviour
	{
		public enum AnimationProperty
		{
			RigForce,
			Delay
		}

		private Unit unit;

		private MeleeWeapon[] meleeWeapons;

		private void Start()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0145: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			meleeWeapons = ((Component)unit).GetComponentsInChildren<MeleeWeapon>();
			float x = ((Component)this).transform.localScale.x;
			float y = ((Component)this).transform.localScale.y;
			MeleeWeapon[] array = meleeWeapons;
			for (int i = 0; i < array.Length; i++)
			{
				MeleeWeapon val = array[i];
				((Weapon)val).maxRange = ((Weapon)val).maxRange * ((Component)this).transform.localScale.z;
				WeaponForceAnimation componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<WeaponForceAnimation>();
				if ((Object)(object)componentInChildren == (Object)null)
				{
					List<AttackEffect> list = new List<AttackEffect>(((Weapon)array[i]).attackEffects);
					WeaponForceAnimation val2 = ((Component)array[i]).gameObject.AddComponent<WeaponForceAnimation>();
					s.DeepCopyOf<WeaponForceAnimation>(val2, ((GameObject)SLMALoader.SDic["weapons"]["shogunSword"]).GetComponentInChildren<WeaponForceAnimation>());
					SetDefaultProperty(val2, 100f);
					SetAnimationProperty(val2, AnimationProperty.RigForce, x);
					SetAnimationProperty(val2, AnimationProperty.Delay, y);
					list.Add((AttackEffect)val2);
					((Weapon)array[i]).attackEffects = list.ToArray();
				}
				else
				{
					s.DeepCopyOf<WeaponForceAnimation>(componentInChildren, ((GameObject)SLMALoader.SDic["weapons"]["shogunSword"]).GetComponentInChildren<WeaponForceAnimation>());
					SetDefaultProperty(componentInChildren, 100f);
					SetAnimationProperty(componentInChildren, AnimationProperty.RigForce, x);
					SetAnimationProperty(componentInChildren, AnimationProperty.Delay, y);
				}
			}
		}

		private void SetAnimationProperty(WeaponForceAnimation anim, AnimationProperty property, float value)
		{
			if ((Object)(object)anim == (Object)null || anim.animations == null || anim.animations.Length == 0)
			{
				Debug.LogWarning((object)"Animation or animation data missing.");
				return;
			}
			switch (property)
			{
			case AnimationProperty.RigForce:
			{
				SpellAnimation obj2 = anim.animations[0];
				obj2.rigAnimationForce *= value;
				break;
			}
			case AnimationProperty.Delay:
			{
				SpellAnimation obj = anim.animations[0];
				obj.animationDelay *= value;
				break;
			}
			default:
				Debug.LogWarning((object)"Unknown animation property!");
				break;
			}
		}

		private void SetDefaultProperty(WeaponForceAnimation anim, float value)
		{
			if ((Object)(object)anim == (Object)null || anim.animations == null || anim.animations.Length == 0)
			{
				Debug.LogWarning((object)"Animation or animation data missing.");
				return;
			}
			Debug.Log((object)"Set the animation to default value");
			anim.animations[0].rigAnimationForce = value;
		}
	}
	public class BindSiegeHealthBehaviour : MonoBehaviour
	{
		public enum BindType
		{
			UnbindVehicleHealth,
			UnbindRiderHealth,
			BindVehicleHealth,
			BindRiderHealth
		}

		private Unit unit;

		public BindType HealthBindType;

		public void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null)
			{
				Debug.LogWarning((object)"Unit component not found.");
				return;
			}
			MountPos[] componentsInChildren = ((Component)unit).GetComponentsInChildren<MountPos>();
			foreach (MountPos val in componentsInChildren)
			{
				switch (HealthBindType)
				{
				case BindType.UnbindVehicleHealth:
					val.killVehicleIfRiderDies = false;
					break;
				case BindType.UnbindRiderHealth:
					val.killRiderIfVehicleDies = false;
					break;
				case BindType.BindVehicleHealth:
					val.killVehicleIfRiderDies = true;
					break;
				case BindType.BindRiderHealth:
					val.killRiderIfVehicleDies = true;
					break;
				}
			}
		}
	}
	public class ChangeAbilityProjectileHomingBehaviour : MonoBehaviour
	{
		private Unit unit;

		public float scaleM;

		private GameObject hiddenParent;

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			SetHiddenParent();
			SpawnObject[] componentsInChildren = ((Component)unit).gameObject.GetComponentsInChildren<SpawnObject>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				GameObject objectToSpawn = MakeTempCopy(componentsInChildren[i].objectToSpawn);
				componentsInChildren[i].objectToSpawn = objectToSpawn;
			}
		}

		private GameObject MakeTempCopy(GameObject gameObjectToCopy)
		{
			GameObject obj = Object.Instantiate<GameObject>(gameObjectToCopy, hiddenParent.transform);
			obj.AddComponent<HomingProjCustomizedBehaviour>().force *= 6f;
			return obj;
		}

		private void SetHiddenParent()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			hiddenParent = new GameObject
			{
				hideFlags = (HideFlags)61
			};
			hiddenParent.SetActive(false);
		}
	}
	public class ChangeWeaponProjectileHomingBehaviour : MonoBehaviour
	{
		private Unit unit;

		public float scaleM;

		private GameObject hiddenParent;

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			SetHiddenParent();
			RangeWeapon[] componentsInChildren = ((Component)unit).gameObject.GetComponentsInChildren<RangeWeapon>();
			foreach (RangeWeapon val in componentsInChildren)
			{
				GameObject objectToSpawn = MakeTempCopy(val.ObjectToSpawn);
				val.ObjectToSpawn = objectToSpawn;
			}
		}

		private GameObject MakeTempCopy(GameObject gameObjectToCopy)
		{
			GameObject obj = Object.Instantiate<GameObject>(gameObjectToCopy, hiddenParent.transform);
			obj.AddComponent<HomingProjCustomizedBehaviour>().force *= 6f;
			return obj;
		}

		private void SetHiddenParent()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			hiddenParent = new GameObject
			{
				hideFlags = (HideFlags)61
			};
			hiddenParent.SetActive(false);
		}
	}
	public class ColorableAbilityProjBehaviour : MonoBehaviour
	{
		public enum ChangeType
		{
			Model,
			Particle
		}

		private Unit unit;

		private GameObject hiddenParent;

		private Material curMat;

		public ChangeType MaterialChangeType;

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null)
			{
				Loader.LogWarning("Unit component not found.");
				return;
			}
			SetHiddenParent();
			SpawnObject[] componentsInChildren = ((Component)unit).GetComponentsInChildren<SpawnObject>();
			foreach (SpawnObject val in componentsInChildren)
			{
				val.objectToSpawn = MakeTempCopy(val.objectToSpawn);
			}
		}

		private GameObject MakeTempCopy(GameObject gameObjectToCopy)
		{
			GameObject val = Object.Instantiate<GameObject>(gameObjectToCopy, hiddenParent.transform);
			MeshRenderer componentInChildren = ((Component)this).GetComponentInChildren<MeshRenderer>();
			curMat = (((Object)(object)componentInChildren != (Object)null) ? ((Renderer)componentInChildren).materials[0] : null);
			if ((Object)(object)curMat != (Object)null)
			{
				switch (MaterialChangeType)
				{
				case ChangeType.Particle:
					ApplyMaterialToRenderers<ParticleSystemRenderer>(val);
					break;
				case ChangeType.Model:
					ApplyMaterialToRenderers<MeshRenderer>(val);
					ApplyMaterialToRenderers<SkinnedMeshRenderer>(val);
					break;
				}
			}
			return val;
		}

		private void SetHiddenParent()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			hiddenParent = new GameObject
			{
				hideFlags = (HideFlags)61
			};
			hiddenParent.SetActive(false);
		}

		private void ApplyMaterialToRenderers<T>(GameObject obj) where T : Renderer
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			T[] componentsInChildren = obj.GetComponentsInChildren<T>();
			foreach (T val in componentsInChildren)
			{
				List<Material> list = new List<Material>();
				Material[] materials = ((Renderer)val).materials;
				for (int j = 0; j < materials.Length; j++)
				{
					_ = materials[j];
					list.Add(new Material(curMat));
				}
				((Renderer)val).materials = list.ToArray();
			}
		}
	}
	public class ColorableWeaponProjBehaviour : MonoBehaviour
	{
		public enum ChangeType
		{
			Model,
			Particle
		}

		private Unit unit;

		private GameObject hiddenParent;

		private Material curMat;

		public ChangeType MaterialChangeType;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null)
			{
				Loader.LogWarning("Unit component not found.");
				return;
			}
			SetHiddenParent();
			RangeWeapon[] componentsInChildren = ((Component)unit).GetComponentsInChildren<RangeWeapon>();
			foreach (RangeWeapon val in componentsInChildren)
			{
				val.ObjectToSpawn = MakeTempCopy(val.ObjectToSpawn);
			}
		}

		private GameObject MakeTempCopy(GameObject gameObjectToCopy)
		{
			GameObject val = Object.Instantiate<GameObject>(gameObjectToCopy, hiddenParent.transform);
			MeshRenderer componentInChildren = ((Component)this).GetComponentInChildren<MeshRenderer>();
			curMat = (((Object)(object)componentInChildren != (Object)null) ? ((Renderer)componentInChildren).materials[0] : null);
			if ((Object)(object)curMat != (Object)null)
			{
				switch (MaterialChangeType)
				{
				case ChangeType.Particle:
					ApplyMaterialToRenderers<ParticleSystemRenderer>(val);
					break;
				case ChangeType.Model:
					ApplyMaterialToRenderers<MeshRenderer>(val);
					ApplyMaterialToRenderers<SkinnedMeshRenderer>(val);
					break;
				}
			}
			return val;
		}

		private void SetHiddenParent()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			hiddenParent = new GameObject
			{
				hideFlags = (HideFlags)61
			};
			hiddenParent.SetActive(false);
		}

		private void ApplyMaterialToRenderers<T>(GameObject obj) where T : Renderer
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			T[] componentsInChildren = obj.GetComponentsInChildren<T>();
			foreach (T val in componentsInChildren)
			{
				List<Material> list = new List<Material>();
				Material[] materials = ((Renderer)val).materials;
				for (int j = 0; j < materials.Length; j++)
				{
					_ = materials[j];
					list.Add(new Material(curMat));
				}
				((Renderer)val).materials = list.ToArray();
			}
		}
	}
	public class DestroyAbilitiesModelBehaviour : MonoBehaviour
	{
		private void Awake()
		{
			SpecialAbility[] componentsInChildren = ((Component)((Component)this).transform.root).GetComponentsInChildren<SpecialAbility>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				DestroyChild(((Component)componentsInChildren[i]).gameObject);
			}
		}

		public void DestroyChild(GameObject gameObject)
		{
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (((object)componentsInChildren[i]).GetType() != typeof(ParticleSystemRenderer))
				{
					Object.Destroy((Object)(object)componentsInChildren[i]);
				}
			}
		}

		private void Start()
		{
			SpecialAbility[] componentsInChildren = ((Component)((Component)this).transform.root).GetComponentsInChildren<SpecialAbility>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				DestroyChild(((Component)componentsInChildren[i]).gameObject);
			}
		}
	}
	public class DestroyAbilitiesParticlesBehaviour : MonoBehaviour
	{
		private void Awake()
		{
			SpecialAbility[] componentsInChildren = ((Component)((Component)this).transform.root).GetComponentsInChildren<SpecialAbility>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				DestroyChild(((Component)componentsInChildren[i]).gameObject);
			}
		}

		public void DestroyChild(GameObject gameObject)
		{
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (((object)componentsInChildren[i]).GetType() == typeof(ParticleSystemRenderer))
				{
					Object.Destroy((Object)(object)componentsInChildren[i]);
				}
			}
		}

		private void Start()
		{
			SpecialAbility[] componentsInChildren = ((Component)((Component)this).transform.root).GetComponentsInChildren<SpecialAbility>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				DestroyChild(((Component)componentsInChildren[i]).gameObject);
			}
		}
	}
	public class DestroyIfUnitNullBehaviour : MonoBehaviour
	{
		public Unit targetUnit;

		private Unit unit;

		public void Update()
		{
			if ((Object)(object)targetUnit == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
		}

		private void Destroy()
		{
			if ((Object)(object)unit != (Object)null && (Object)(object)unit.data != (Object)null && (Object)(object)unit.data.healthHandler != (Object)null && unit.data.healthHandler.Die((Unit)null))
			{
				Object.Destroy((Object)(object)((Component)unit).gameObject);
			}
		}
	}
	public class DisableUnitOutlineBehaviour : MonoBehaviour
	{
		private Unit unit;

		private Outline outline;

		public bool includeChildren = true;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			outline = ((Component)unit).GetComponentInChildren<Outline>();
			if (includeChildren)
			{
				Transform[] componentsInChildren = ((Component)unit).GetComponentsInChildren<Transform>(true);
				foreach (Transform val in componentsInChildren)
				{
					DisableOutlineComponents(((Component)val).gameObject);
				}
			}
			else
			{
				DisableOutlineComponents(((Component)unit).gameObject);
			}
		}

		private void Update()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)outline != (Object)null)
			{
				((Behaviour)outline).enabled = false;
				outline.OutlineColor = new Color(0f, 0f, 0f, 0f);
			}
		}

		public void DisableOutlineComponents(GameObject obj)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			Component[] components = obj.GetComponents<Component>();
			foreach (Component val in components)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				string text = ((object)val).GetType().Name.ToLower();
				if (!((Object)(object)val == (Object)(object)this) && !(text == "disableunitoutlinebehaviour") && text.Contains("outline"))
				{
					Behaviour val2 = (Behaviour)((val is Behaviour) ? val : null);
					if ((Object)(object)val2 != (Object)null)
					{
						val2.enabled = false;
						Debug.Log((object)("Disabled: " + text + " on " + ((Object)obj).name));
					}
					else
					{
						Object.Destroy((Object)(object)val);
						Debug.Log((object)("Destroyed: " + text + " on " + ((Object)obj).name));
					}
				}
			}
		}
	}
	public class DynamicPropSetupBehaviour : MonoBehaviour
	{
		private Unit unit;

		public List<GameObject> meshes;

		private PropItemData propItemData;

		public float multiplier = 1f;

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			propItemData = ((CharacterItem)((Component)this).GetComponentInChildren<PropItem>()).PropData;
			if ((Object)(object)unit == (Object)null)
			{
				Debug.LogError((object)"Unit not found in hierarchy.");
				return;
			}
			GoToBodyPart[] componentsInChildren = ((Component)this).GetComponentsInChildren<GoToBodyPart>();
			foreach (GoToBodyPart val in componentsInChildren)
			{
				meshes.Add(((Component)val).gameObject);
				val.GoToPart();
			}
		}

		private void Update()
		{
			//IL_002a: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			if (propItemData == null)
			{
				return;
			}
			foreach (GameObject mesh in meshes)
			{
				mesh.transform.localScale = ((Component)this).transform.localScale * multiplier;
				mesh.transform.localPosition = propItemData.m_positionOffset;
			}
		}
	}
	public class DynamicPropWeaponBehaviour : MonoBehaviour
	{
		private Unit unit;

		private PropItemData propItemData;

		private GameObject meshObject;

		public bool right;

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			propItemData = ((CharacterItem)((Component)this).GetComponentInChildren<PropItem>()).PropData;
			if ((Object)(object)unit == (Object)null)
			{
				Debug.LogError((object)"Unit not found in hierarchy.");
				return;
			}
			meshObject = ((Component)((Component)this).GetComponentInChildren<MeshRenderer>()).gameObject;
			Weapon val = (right ? unit.data.weaponHandler.rightWeapon : unit.data.weaponHandler.leftWeapon);
			if ((Object)(object)val != (Object)null && (Object)(object)meshObject != (Object)null)
			{
				MoveToWeapon(((Component)val).gameObject, meshObject);
			}
		}

		private void Update()
		{
			//IL_0027: 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)
			if (propItemData != null && (Object)(object)meshObject != (Object)null)
			{
				meshObject.transform.localScale = ((Component)this).transform.localScale;
				meshObject.transform.localPosition = propItemData.m_positionOffset;
			}
		}

		private void MoveToWeapon(GameObject weaponObject, GameObject box)
		{
			box.transform.SetParent(weaponObject.transform);
		}
	}
	public class ExpirationBehaviourBehaviour : MonoBehaviour
	{
		public Unit unit;

		public float seconds = 10f;

		private float counter;

		private void Update()
		{
			counter += Time.deltaTime;
			if (counter >= seconds)
			{
				Destroy();
			}
		}

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
		}

		private void Destroy()
		{
			if ((Object)(object)unit != (Object)null && (Object)(object)unit.data != (Object)null && (Object)(object)unit.data.healthHandler != (Object)null && unit.data.healthHandler.Die((Unit)null))
			{
				Object.Destroy((Object)(object)((Component)unit).gameObject);
			}
		}
	}
	public class EyeKeepOpenedBehaviour : MonoBehaviour
	{
		public void Update()
		{
			try
			{
				GooglyEye[] componentsInChildren = ((Component)((Component)this).gameObject.transform.root).GetComponentsInChildren<GooglyEye>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].SetState((EyeState)0);
				}
			}
			catch (Exception)
			{
				Debug.LogWarning((object)"No eye detected");
			}
		}
	}
	public class ForcedSkinChangeBehaviour : MonoBehaviour
	{
		private sealed class RendererMaterialEntry
		{
			public SkinnedMeshRenderer renderer;

			public Material[] forcedMaterials;
		}

		public Unit unit;

		private Material clonedMat;

		[SerializeField]
		private float updateInterval = 0.5f;

		private float timer;

		private readonly List<RendererMaterialEntry> cachedRenderers = new List<RendererMaterialEntry>();

		private readonly Dictionary<int, Material[]> materialArrayCache = new Dictionary<int, Material[]>();

		private void Start()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			MeshRenderer componentInChildren = ((Component)this).GetComponentInChildren<MeshRenderer>();
			if ((Object)(object)componentInChildren == (Object)null || ((Renderer)componentInChildren).sharedMaterials.Length == 0)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			clonedMat = new Material(((Renderer)componentInChildren).sharedMaterials[0]);
			SkinnedMeshRenderer[] componentsInChildren = ((Component)unit).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				if ((Object)(object)((Component)val).GetComponentInParent<PropItem>() == (Object)null && (Object)(object)((Component)val).GetComponentInParent<WeaponItem>() == (Object)null && (Object)(object)((Component)val).GetComponentInParent<CharacterItem>() == (Object)null && (Object)(object)((Component)val).GetComponentInParent<SpecialAbility>() == (Object)null)
				{
					cachedRenderers.Add(new RendererMaterialEntry
					{
						renderer = val,
						forcedMaterials = GetMaterialArray(((Renderer)val).sharedMaterials.Length)
					});
				}
			}
			ForceMaterials();
		}

		private void OnDestroy()
		{
			if ((Object)(object)clonedMat != (Object)null)
			{
				Object.Destroy((Object)(object)clonedMat);
			}
		}

		private void Update()
		{
			timer += Time.deltaTime;
			if (!(timer < updateInterval))
			{
				timer = 0f;
				ForceMaterials();
			}
		}

		private Material[] GetMaterialArray(int count)
		{
			if (!materialArrayCache.TryGetValue(count, out var value))
			{
				value = (Material[])(object)new Material[count];
				for (int i = 0; i < count; i++)
				{
					value[i] = clonedMat;
				}
				materialArrayCache.Add(count, value);
			}
			return value;
		}

		private void ForceMaterials()
		{
			for (int num = cachedRenderers.Count - 1; num >= 0; num--)
			{
				RendererMaterialEntry rendererMaterialEntry = cachedRenderers[num];
				if ((Object)(object)rendererMaterialEntry.renderer == (Object)null)
				{
					cachedRenderers.RemoveAt(num);
				}
				else if (((Renderer)rendererMaterialEntry.renderer).sharedMaterials != rendererMaterialEntry.forcedMaterials)
				{
					((Renderer)rendererMaterialEntry.renderer).sharedMaterials = rendererMaterialEntry.forcedMaterials;
				}
			}
			if (cachedRenderers.Count == 0)
			{
				((Behaviour)this).enabled = false;
			}
		}
	}
	public class ForcePointAddReaperScytheEffectBehaviour : MonoBehaviour
	{
		private Unit unit;

		private Material curMat;

		public GameObject trailObject;

		private List<ParticleSystemRenderer> trails;

		private void Start()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			unit = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null)
			{
				Debug.LogError((object)"Unit not found in hierarchy.");
				return;
			}
			trails = new List<ParticleSystemRenderer>();
			ForcePoint[] componentsInChildren = ((Component)unit).GetComponentsInChildren<ForcePoint>();
			foreach (ForcePoint val in componentsInChildren)
			{
				GameObject obj = Object.Instantiate<GameObject>(trailObject, ((Component)val).transform);
				obj.transform.localScale = ((Component)this).gameObject.transform.localScale;
				ParticleSystemRenderer componentInChildren = obj.GetComponentInChildren<ParticleSystemRenderer>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					trails.Add(componentInChildren);
				}
				else
				{
					Debug.LogWarning((object)"Trail object does not contain a ParticleSystemRenderer component.");
				}
			}
		}

		private void Update()
		{
			if ((Object)(object)curMat == (Object)null)
			{
				MeshRenderer componentInChildren = ((Component)this).gameObject.GetComponentInChildren<MeshRenderer>();
				if ((Object)(object)componentInChildren != (Object)null && ((Renderer)componentInChildren).materials.Length != 0)
				{
					curMat = ((Renderer)componentInChildren).materials[0];
				}
			}
			if (!((Object)(object)curMat != (Object)null))
			{
				return;
			}
			foreach (ParticleSystemRenderer trail in trails)
			{
				if ((Object)(object)trail.trailMaterial != (Object)(object)curMat)
				{
					trail.trailMaterial = curMat;
				}
			}
		}
	}
	public class FusionMechanicBehaviour : MonoBehaviour
	{
		private Unit rider;

		private GetAndDeleteRiderBehaviour getAndDeleteRiderBehaviour;

		private UnitBlueprint riderToSpawn;

		private Unit rootUnit;

		private bool hasTriggered;

		private void Start()
		{
			rootUnit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			getAndDeleteRiderBehaviour = ((Component)this).GetComponentInChildren<GetAndDeleteRiderBehaviour>();
			riderToSpawn = getAndDeleteRiderBehaviour.riderBlueprint;
			if (!hasTriggered)
			{
				hasTriggered = true;
				rider = Spawn(riderToSpawn);
			}
		}

		private void Update()
		{
			if (((Object)(object)rootUnit != (Object)null) & ((Object)(object)rider != (Object)null))
			{
				MirrorRigs(rider, rootUnit);
			}
		}

		private void MirrorRigs(Unit unit, Unit target)
		{
			//IL_007d: 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_0041: 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)
			Rigidbody[] allRigs = unit.data.allRigs.AllRigs;
			Rigidbody[] allRigs2 = target.data.allRigs.AllRigs;
			for (int i = 0; i < allRigs.Length; i++)
			{
				if (allRigs.Length == allRigs2.Length)
				{
					((Component)allRigs[i]).transform.position = ((Component)allRigs2[i]).transform.position;
					((Component)allRigs[i]).transform.rotation = ((Component)allRigs2[i]).transform.rotation;
				}
				else
				{
					unit.data.mainRig.position = target.data.mainRig.position;
					unit.data.mainRig.rotation = target.data.mainRig.rotation;
				}
			}
		}

		public Unit Spawn(UnitBlueprint unitBlueprint)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Unit val = null;
			unitBlueprint.Spawn(rootUnit.data.mainRig.position, rootUnit.data.mainRig.rotation, rootUnit.Team, ref val, 1f, false, true, 0, (UnitPoolInfo?)null);
			if ((Object)(object)val != (Object)null)
			{
				((Component)val).gameObject.AddComponent<DestroyIfUnitNullBehaviour>().targetUnit = rootUnit;
				return val;
			}
			return null;
		}
	}
	public class GetAndDeleteRiderBehaviour : MonoBehaviour
	{
		public UnitSpawner unitSpawner;

		public UnitBlueprint riderBlueprint;

		private void Start()
		{
			GameObject val = ((Component)((Component)this).transform.root).GetComponentInChildren<RiderHolder>().riders[0];
			riderBlueprint = val.GetComponentInChildren<Unit>().unitBlueprint;
			UnitSpawner componentInChildren = ((Component)this).GetComponentInChildren<UnitSpawner>();
			if ((Object)(object)componentInChildren != (Object)null && (Object)(object)riderBlueprint != (Object)null)
			{
				unitSpawner = componentInChildren;
				unitSpawner.unitBlueprint = riderBlueprint;
				unitSpawner.rangedUnitBlueprint = riderBlueprint;
			}
			Object.Destroy((Object)(object)val.gameObject);
		}
	}
	[RequireComponent(typeof(MoveTransform), typeof(SpellTarget))]
	public class HomingProjCustomizedBehaviour : MonoBehaviour
	{
		private MoveTransform move;

		public Transform upTarget;

		public float minRot = 300f;

		public float maxRot = 700f;

		public float drag = 15f;

		public float force = 50f;

		public float upForce = 200f;

		public AnimationCurve upForceOverRange;

		public AnimationCurve upForceOverTimes;

		public AnimationCurve dragOverTime;

		public AnimationCurve forceOverTime;

		public float prediction;

		private float rot;

		private float counter;

		private SpellTarget target;

		public float expiration = float.PositiveInfinity;

		private void Start()
		{
			//IL_013f: 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)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0095: Expected O, but got Unknown
			move = GetOrAddComponent<MoveTransform>();
			target = GetOrAddComponent<SpellTarget>();
			minRot = 300f;
			maxRot = 700f;
			drag = 15f;
			force = 50f;
			upForce = 200f;
			Dictionary<string, object> dictionary;
			if (SLMALoader.SDic.TryGetValue("projectiles", out var value) && (dictionary = value) != null)
			{
				if (dictionary.TryGetValue("P_MagicMissile", out var value2))
				{
					GameObject val = (GameObject)((value2 is GameObject) ? value2 : null);
					GameObject val2 = val;
					if ((Object)val != (Object)null)
					{
						MoveTransformMissile component = val2.GetComponent<MoveTransformMissile>();
						if ((Object)(object)component != (Object)null)
						{
							upTarget = component.upTarget;
							upForceOverRange = component.upForceOverRange;
							upForceOverTimes = component.upForceOverTimes;
							dragOverTime = component.dragOverTime;
							forceOverTime = component.forceOverTime;
						}
						else
						{
							Debug.LogWarning((object)"MoveTransformMissile component not found in P_MagicMissile.");
						}
						goto IL_010e;
					}
				}
				Debug.LogWarning((object)"P_MagicMissile not found or is not a GameObject.");
			}
			else
			{
				Debug.LogWarning((object)"Projectiles dictionary not found in SLMALoader.SDic.");
			}
			goto IL_010e;
			IL_010e:
			rot = Random.Range(minRot, maxRot);
			if ((Object)(object)upTarget != (Object)null)
			{
				upTarget.Rotate(((Component)this).transform.forward * Random.Range(0f, 360f), (Space)0);
			}
			else
			{
				Debug.LogWarning((object)"upTarget is not set. Homing behavior may not work correctly.");
			}
		}

		private void Update()
		{
			//IL_0051: 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)
			//IL_0077: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_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)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			counter += Time.deltaTime;
			if (counter >= expiration)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			SpellTarget val = target;
			if ((Object)(object)(((Object)(object)val != (Object)null) ? val.rig : null) != (Object)null)
			{
				float num = Vector3.Distance(((Component)this).transform.position, target.rig.position);
				Vector3 val2 = target.rig.position + target.rig.velocity * prediction - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				MoveTransform obj = move;
				obj.velocity += normalized * force * forceOverTime.Evaluate(counter) * Time.deltaTime;
				if ((Object)(object)upTarget != (Object)null)
				{
					MoveTransform obj2 = move;
					obj2.velocity += upTarget.forward * upForce * upForceOverRange.Evaluate(num) * upForceOverTimes.Evaluate(counter) * Time.deltaTime;
				}
				MoveTransform obj3 = move;
				obj3.velocity -= move.velocity * drag * dragOverTime.Evaluate(counter) * Time.deltaTime;
			}
			if ((Object)(object)upTarget != (Object)null)
			{
				upTarget.Rotate(((Component)this).transform.forward * rot * Time.deltaTime, (Space)0);
			}
		}

		private T GetOrAddComponent<T>() where T : Component
		{
			T val = ((Component)this).GetComponentInChildren<T>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)this).gameObject.AddComponent<T>();
				Debug.Log((object)("Added missing component: " + typeof(T).Name));
			}
			return val;
		}
	}
	public class KeepNormalUnitColorInstanceBehaviour : MonoBehaviour
	{
		private Unit unit;

		private UnitColorHandler colorHandler;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null)
			{
				Debug.LogError((object)"Unit not found in hierarchy.");
				return;
			}
			colorHandler = ((Component)unit).GetComponentInChildren<UnitColorHandler>();
			if ((Object)(object)colorHandler == (Object)null)
			{
				Debug.LogError((object)"UnitColorHandler not found on the unit.");
			}
		}

		private void Update()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			if (!((Object)(object)unit == (Object)null) && !((Object)(object)colorHandler == (Object)null) && colorHandler.colors != null)
			{
				colorHandler.effectColor = Color.clear;
				UnitColorInstance val = new UnitColorInstance
				{
					acceptWhenDead = false,
					color = Color.clear,
					currentValue = 0f,
					colorName = "NormalValue"
				};
				colorHandler.SetColor(val, 0f);
				colorHandler.colors = null;
			}
		}
	}
	public class MakeUnitBasePropableBehaviour : MonoBehaviour
	{
		private Unit unit;

		private UnitRig rig;

		private UnitBlueprint unitBlueprint;

		private Transform mainTransform;

		private void Awake()
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null || (Object)(object)unit.data == (Object)null)
			{
				Loader.LogError("Unit or Unit.data is missing.");
				return;
			}
			unitBlueprint = unit.unitBlueprint;
			mainTransform = ((Component)unit.data.mainRig).transform;
			rig = ((Component)unit).GetComponent<UnitRig>();
			if ((Object)(object)rig == (Object)null)
			{
				Loader.LogWarning("UnitRig component not found on unit.");
				return;
			}
			SetUnitRigIfNull();
			if ((Object)(object)rig == (Object)null || (Object)(object)unit == (Object)null || (Object)(object)unitBlueprint == (Object)null)
			{
				return;
			}
			Loader.Log("Spawning Props!");
			((Component)unit.data.mainRig).GetComponentsInChildren<GameObject>(true);
			rig.SpawnProps(unitBlueprint.m_props, unitBlueprint.m_propData, (RigType)1, unit.Team);
			foreach (Transform item in ((Component)unit).transform)
			{
				Transform val = item;
				if ((Object)(object)((Component)val).GetComponent<PropItem>() != (Object)null && (Object)(object)val.parent != (Object)(object)((Component)unit.data.mainRig).transform)
				{
					val.SetParent(((Component)unit.data.mainRig).transform, true);
					Loader.Log("Re-parented prop: " + ((Object)val).name);
				}
			}
			if (!(typeof(UnitRig).GetField("m_items", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(rig) is List<CharacterItem> list))
			{
				return;
			}
			foreach (CharacterItem item2 in list)
			{
				if ((Object)(object)item2 != (Object)null && (Object)(object)((Component)item2).transform.parent == (Object)null)
				{
					((Component)item2).transform.SetParent(mainTransform, true);
					Loader.Log("Re-parented item: " + ((Object)item2).name);
				}
			}
		}

		public void SetUnitRigIfNull()
		{
			if ((Object)(object)rig != (Object)null && (Object)(object)mainTransform != (Object)null)
			{
				if ((Object)(object)rig.m_head == (Object)null)
				{
					rig.m_head = mainTransform;
				}
				if ((Object)(object)rig.m_neck == (Object)null)
				{
					rig.m_neck = mainTransform;
				}
				if ((Object)(object)rig.m_shoulderLeft == (Object)null)
				{
					rig.m_shoulderLeft = mainTransform;
				}
				if ((Object)(object)rig.m_shoulderRight == (Object)null)
				{
					rig.m_shoulderRight = mainTransform;
				}
				if ((Object)(object)rig.m_armLeft == (Object)null)
				{
					rig.m_armLeft = mainTransform;
				}
				if ((Object)(object)rig.m_armRight == (Object)null)
				{
					rig.m_armRight = mainTransform;
				}
				if ((Object)(object)rig.m_wristLeft == (Object)null)
				{
					rig.m_wristLeft = mainTransform;
				}
				if ((Object)(object)rig.m_wristRight == (Object)null)
				{
					rig.m_wristRight = mainTransform;
				}
				if ((Object)(object)rig.m_torso == (Object)null)
				{
					rig.m_torso = mainTransform;
				}
				if ((Object)(object)rig.m_waist == (Object)null)
				{
					rig.m_waist = mainTransform;
				}
				if ((Object)(object)rig.m_legLeft == (Object)null)
				{
					rig.m_legLeft = mainTransform;
				}
				if ((Object)(object)rig.m_legRight == (Object)null)
				{
					rig.m_legRight = mainTransform;
				}
				if ((Object)(object)rig.m_footLeft == (Object)null)
				{
					rig.m_footLeft = mainTransform;
				}
				if ((Object)(object)rig.m_footRight == (Object)null)
				{
					rig.m_footRight = mainTransform;
				}
			}
		}
	}
	public class MeleeAddStickBehaviour : MonoBehaviour
	{
		private Unit unit;

		private void Start()
		{
			//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)
			unit = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null)
			{
				return;
			}
			MeleeWeapon[] componentsInChildren = ((Component)unit).GetComponentsInChildren<MeleeWeapon>();
			foreach (MeleeWeapon val in componentsInChildren)
			{
				ForcePoint componentInChildren = ((Component)val).GetComponentInChildren<ForcePoint>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					if ((Object)(object)((Component)val).GetComponentInChildren<StickPosition>() == (Object)null)
					{
						StickPosition obj = ((Component)componentInChildren).gameObject.AddComponent<StickPosition>();
						obj.lockRotation = true;
						Vector3 localScale = ((Component)val).transform.localScale;
						obj.radius = 0.5f * ((Vector3)(ref localScale)).magnitude;
					}
					if ((Object)(object)((Component)val).GetComponent<MeleeWeaponStick>() == (Object)null)
					{
						MeleeWeaponStick obj2 = ((Component)val).gameObject.AddComponent<MeleeWeaponStick>();
						obj2.hardStick = true;
						obj2.breakForce = 50000f;
						obj2.downwardsForceOnStuckRig = -50f;
						obj2.walkBackwardsWhenStuck = false;
						obj2.time = 5f;
						obj2.onlyOtherTeam = true;
					}
				}
			}
		}
	}
	public class MeleeHitFasterBehaviour : MonoBehaviour
	{
		private Unit unit;

		public float curveForceM = 1f;

		public float screenShakeM = 1f;

		public float knockbackM = 1f;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			CollisionWeapon[] componentsInChildren = ((Component)unit).gameObject.GetComponentsInChildren<CollisionWeapon>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].hitFasterAfterDealDamage = true;
			}
		}
	}
	public class MeleeTrailBehaviour : MonoBehaviour
	{
		private Unit unit;

		public bool right;

		public Material curMat;

		private void Start()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			curMat = ((Component)this).gameObject.GetComponentInChildren<Renderer>().materials[0];
			AnimationCurve val = new AnimationCurve();
			val.AddKey(0f, 0f);
			val.AddKey(0.75f, 0.1f);
			val.AddKey(1f, 0f);
			GameObject val2 = ((!right) ? ((Component)unit.data.weaponHandler.leftWeapon).gameObject : ((Component)unit.data.weaponHandler.rightWeapon).gameObject);
			MeshRenderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<MeshRenderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			AddTrail(((Component)val2.GetComponentInChildren<ForcePoint>()).gameObject, curMat, val);
		}

		private void AddTrail(GameObject point, Material material, AnimationCurve widthCurve)
		{
			TrailRenderer obj = point.AddComponent<TrailRenderer>();
			obj.time = 0.5f;
			((Renderer)obj).material = material;
			obj.widthCurve = widthCurve;
		}
	}
	public class NeverShowHealthBarBehaviour : MonoBehaviour
	{
		private Unit unit;

		public void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<Unit>();
		}

		public void Update()
		{
			unit.SetHealthBarActive(false);
		}
	}
	public class NoFallDamageBehaviour : MonoBehaviour
	{
		private Unit unit;

		private UnitDontWalkFor unitDontWalkFor;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
		}

		private void Update()
		{
			if ((Object)(object)unit != (Object)null && (Object)(object)unit.data != (Object)null)
			{
				unit.data.takeFallDamage = false;
				unit.data.canFall = false;
			}
		}
	}
	public class NullifyAllDelayBehaviour : MonoBehaviour
	{
		private Unit unit;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			DelayEvent[] componentsInChildren = ((Component)unit).GetComponentsInChildren<DelayEvent>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].delay = 0f;
				componentsInChildren[i].randomDelay = 0f;
			}
		}
	}
	public class OnHitEffectAddonBehaviour : MonoBehaviour
	{
		private Unit unit;

		public GameObject explosion;

		private float counter;

		private const float Timer = 0.5f;

		public float scaleMultiplier = 1f;

		public int amountToSpawn = 1;

		public bool randomExplosion;

		public GameObject[] explosions;

		public float offset;

		public float damageMultiplier;

		public float delayPerSpawn;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null)
			{
				Debug.LogError((object)"Unit not found in hierarchy.");
			}
		}

		private void Update()
		{
			counter += Time.deltaTime;
		}

		private void OnCollisionEnter(Collision collision)
		{
			//IL_0066: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			Debug.LogError((object)"IM COLLIDING SO GOOD OHHHHHH");
			if ((Object)(object)collision.gameObject == (Object)null)
			{
				Debug.Log((object)"Collision has no gameObject.");
				return;
			}
			if (counter < 0.5f)
			{
				Debug.Log((object)"Collision ignored due to counter < 0.5f");
				return;
			}
			Unit componentInChildren = ((Component)collision.gameObject.transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				Debug.Log((object)"No Unit component found in collided object.");
				return;
			}
			if (componentInChildren.Team == unit.Team)
			{
				Debug.Log((object)"Collided Unit is on the same team. Ignoring.");
				return;
			}
			if ((Object)(object)componentInChildren == (Object)(object)unit)
			{
				Debug.Log((object)"Collided with self. Ignoring.");
				return;
			}
			Debug.Log((object)"Valid collision! Preparing explosion.");
			counter = 0f;
			if (randomExplosion)
			{
				Debug.Log((object)"Spawning random explosion.");
				((MonoBehaviour)this).StartCoroutine(SpawnExplosionRandom(explosions, collision.transform.position));
			}
			else if ((Object)(object)explosion != (Object)null)
			{
				Debug.Log((object)"Spawning specific explosion.");
				((MonoBehaviour)this).StartCoroutine(SpawnExplosion(explosion, collision.transform.position));
			}
			else
			{
				Debug.Log((object)"No explosion prefab assigned.");
			}
		}

		private IEnumerator SpawnExplosionRandom(GameObject[] explosions, Vector3 spawnPos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < amountToSpawn; i++)
			{
				int num = Random.Range(0, explosions.Length);
				GameObject obj = Object.Instantiate<GameObject>(explosions[num], setOffset(spawnPos), Quaternion.identity, (Transform)null);
				Transform transform = obj.transform;
				transform.localScale *= scaleMultiplier;
				TeamHolder val = new TeamHolder
				{
					getRootTeamOnAwake = true,
					team = unit.Team,
					spawner = ((Component)unit).gameObject
				};
				Explosion componentInChildren = obj.GetComponentInChildren<Explosion>();
				componentInChildren.damage *= damageMultiplier;
				TeamHolder.AddTeamHolder(obj, unit, val);
				yield return (object)new WaitForSeconds(delayPerSpawn);
			}
		}

		private IEnumerator SpawnExplosion(GameObject explosion, Vector3 spawnPos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < amountToSpawn; i++)
			{
				GameObject obj = Object.Instantiate<GameObject>(explosion, setOffset(spawnPos), Quaternion.identity, (Transform)null);
				Transform transform = obj.transform;
				transform.localScale *= scaleMultiplier;
				TeamHolder val = new TeamHolder
				{
					getRootTeamOnAwake = true,
					team = unit.Team,
					spawner = ((Component)unit).gameObject
				};
				Explosion componentInChildren = obj.GetComponentInChildren<Explosion>();
				componentInChildren.damage *= damageMultiplier;
				TeamHolder.AddTeamHolder(obj, unit, val);
				yield return (object)new WaitForSeconds(delayPerSpawn);
			}
		}

		private Vector3 setOffset(Vector3 mainPos)
		{
			//IL_0000: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			float num = mainPos.x + Random.Range(0f - offset, offset);
			float num2 = mainPos.y + Random.Range(0f - offset, offset);
			float num3 = mainPos.z + Random.Range(0f - offset, offset);
			return new Vector3(num, num2, num3);
		}
	}
	public class RemoveTurnadoBehaviour : MonoBehaviour
	{
		private Unit unit;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<Unit>();
			SpinToWinBehaviour[] componentsInChildren = ((Component)unit).gameObject.GetComponentsInChildren<SpinToWinBehaviour>();
			foreach (SpinToWinBehaviour obj in componentsInChildren)
			{
				obj.turnadoStartEvent = obj.turnadoEndEvent;
			}
		}
	}
	public class RemoveWeaponParticlesBehaviour : MonoBehaviour
	{
		private Unit unit;

		private Weapon weapon;

		public bool right;

		private void Start()
		{
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			if (right)
			{
				weapon = unit.data.weaponHandler.rightWeapon;
			}
			if (!right)
			{
				weapon = unit.data.weaponHandler.leftWeapon;
			}
			ParticleSystem[] componentsInChildren = ((Component)weapon).gameObject.GetComponentsInChildren<ParticleSystem>();
			foreach (ParticleSystem obj in componentsInChildren)
			{
				Object.Destroy((Object)(object)((Component)obj).gameObject.GetComponentInChildren<ParticleSystemRenderer>());
				Object.Destroy((Object)(object)obj);
			}
		}
	}
	public class ScaleWeaponBehaviour : MonoBehaviour
	{
		private Unit unit;

		public bool right;

		public float scaleMultiplier;

		private void Start()
		{
			//IL_0048: 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_0085: 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)
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			if (right)
			{
				Transform transform = ((Component)unit.data.weaponHandler.rightWeapon).gameObject.transform;
				transform.localScale *= scaleMultiplier;
			}
			if (!right)
			{
				Transform transform2 = ((Component)unit.data.weaponHandler.leftWeapon).gameObject.transform;
				transform2.localScale *= scaleMultiplier;
			}
		}
	}
	public class SetPropRotationBehaviour : MonoBehaviour
	{
		public enum RotationType
		{
			Static,
			Perpetual
		}

		private Unit unit;

		private PropItem propItem;

		private PropItemData propItemData;

		private GameObject objectToSpin;

		private bool checkOnDeath;

		private float speed;

		public RotationType rotationType;

		public int id;

		private void Start()
		{
			//IL_0062: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			propItem = ((Component)this).GetComponentInChildren<PropItem>();
			propItemData = ((CharacterItem)propItem).PropData;
			if ((Object)(object)unit != (Object)null && (Object)(object)propItem != (Object)null)
			{
				SetDefaultIfZero();
				id = Mathf.FloorToInt(((Component)this).transform.localScale.x);
				speed = ((Component)this).transform.localScale.y;
				checkOnDeath = ((Component)this).transform.localScale.z >= 1f;
				List<GameObject> list = new List<GameObject>();
				PropItem[] componentsInChildren = ((Component)unit).GetComponentsInChildren<PropItem>();
				object[] array = componentsInChildren;
				object[] args = array;
				Loader.Log(string.Format("Here is prop items that are detected: {0}", args));
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					GameObject gameObject = ((Component)componentsInChildren[i]).gameObject;
					SkinnedMeshRenderer componentInChildren = gameObject.GetComponentInChildren<SkinnedMeshRenderer>();
					MeshRenderer componentInChildren2 = gameObject.GetComponentInChildren<MeshRenderer>();
					if ((Object)(object)gameObject != (Object)null && (Object)(object)componentInChildren == (Object)null && (Object)(object)componentInChildren2 != (Object)null)
					{
						list.Add(gameObject);
					}
				}
				GameObject[] array2 = list.ToArray();
				if (array2 != null && id >= 0 && id < array2.Length)
				{
					objectToSpin = array2[id];
				}
				Loader.Log("Set Object to spin: " + ((Object)objectToSpin).name);
			}
			else
			{
				Loader.LogError("No unit or prop found");
			}
		}

		private void Update()
		{
			//IL_001c: 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_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)
			//IL_0035: 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)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)objectToSpin != (Object)null)
			{
				if (rotationType == RotationType.Static)
				{
					Vector3 positionOffset = propItemData.m_positionOffset;
					if (!(objectToSpin.transform.localRotation == Quaternion.Euler(positionOffset)))
					{
						objectToSpin.transform.localRotation = Quaternion.Euler(positionOffset);
					}
				}
				else if (!checkOnDeath || (checkOnDeath && !unit.data.Dead))
				{
					RotateObject(speed);
				}
				return;
			}
			List<GameObject> list = new List<GameObject>();
			PropItem[] componentsInChildren = ((Component)unit).GetComponentsInChildren<PropItem>();
			object[] array = componentsInChildren;
			object[] args = array;
			Loader.Log(string.Format("Here is prop items that are detected: {0}", args));
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				GameObject gameObject = ((Component)componentsInChildren[i]).gameObject;
				SkinnedMeshRenderer componentInChildren = gameObject.GetComponentInChildren<SkinnedMeshRenderer>();
				MeshRenderer componentInChildren2 = gameObject.GetComponentInChildren<MeshRenderer>();
				if ((Object)(object)gameObject != (Object)null && (Object)(object)componentInChildren == (Object)null && (Object)(object)componentInChildren2 != (Object)null)
				{
					list.Add(gameObject);
				}
			}
			GameObject[] array2 = list.ToArray();
			if (array2 != null && id >= 0 && id < array2.Length)
			{
				objectToSpin = array2[id];
			}
			Loader.Log("Set Object to spin: " + ((Object)objectToSpin).name);
		}

		private void RotateObject(float spinSpeed)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			Vector3 positionOffset = propItemData.m_positionOffset;
			objectToSpin.transform.Rotate(positionOffset * spinSpeed * Time.deltaTime, (Space)1);
		}

		private void SetDefaultIfZero()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (propItemData.m_positionOffset == Vector3.zero)
			{
				propItemData.m_positionOffset = Vector3.one;
			}
			if (((Component)this).transform.localPosition == Vector3.zero)
			{
				((Component)this).transform.localPosition = Vector3.one;
			}
		}
	}
	public class SkinnedChangesBehaviour : MonoBehaviour
	{
		private Unit unit;

		private Material curMat;

		private void Start()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			curMat = ((Component)this).gameObject.GetComponentInChildren<Renderer>().materials[0];
			if ((Object)(object)curMat == (Object)null)
			{
				return;
			}
			Renderer[] componentsInChildren = ((Component)unit).gameObject.GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				if (((Component)val).tag == "UnitMesh" && (Object)(object)val.materials[0] != (Object)(object)curMat)
				{
					List<Material> list = new List<Material>();
					Material[] materials = val.materials;
					for (int j = 0; j < materials.Length; j++)
					{
						list.Add(new Material(curMat));
					}
					val.materials = list.ToArray();
				}
			}
		}
	}
	public class SmartAdaptiveProjSpawnerBehaviour : MonoBehaviour
	{
		public SpawnObject spawnObject;

		private Unit unit;

		public GameObject smokeObject;

		public int amountToSpawn;

		public float distance;

		public float counter;

		public float timer;

		public Material curMat;

		private float weaponRefresh;

		private RangeWeapon[] rangeWeapons;

		private GameObject[] projectilePool;

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			rangeWeapons = ((Component)unit).GetComponentsInChildren<RangeWeapon>();
			spawnObject = ((Component)this).gameObject.AddComponent<SpawnObject>();
			spawnObject.spawnIfUnitDead = false;
			SetSettings();
		}

		private void Update()
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			counter += Time.deltaTime;
			weaponRefresh += Time.deltaTime;
			if (weaponRefresh >= 1f)
			{
				weaponRefresh = 0f;
				rangeWeapons = ((Component)unit).GetComponentsInChildren<RangeWeapon>();
			}
			if ((Object)(object)curMat == (Object)null)
			{
				MeshRenderer componentInChildren = ((Component)this).gameObject.GetComponentInChildren<MeshRenderer>();
				if ((Object)(object)componentInChildren != (Object)null && ((Renderer)componentInChildren).materials.Length != 0)
				{
					curMat = ((Renderer)componentInChildren).materials[0];
				}
			}
			if ((Object)(object)unit == (Object)null || (Object)(object)unit.data == (Object)null || !(unit.data.distanceToTarget <= distance) || !(counter >= timer))
			{
				return;
			}
			counter = 0f;
			for (int i = 0; i < amountToSpawn; i++)
			{
				spawnObject.objectToSpawn = GetProjectile();
				spawnObject.SpawnTowardsTarget();
				if ((Object)(object)smokeObject != (Object)null)
				{
					ParticleSystemRenderer componentInChildren2 = Object.Instantiate<GameObject>(smokeObject, ((Component)this).transform.position, Quaternion.identity, (Transform)null).GetComponentInChildren<ParticleSystemRenderer>();
					if ((Object)(object)componentInChildren2 != (Object)null)
					{
						((Renderer)componentInChildren2).material = curMat;
						componentInChildren2.trailMaterial = curMat;
					}
				}
			}
		}

		private void SetSettings()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localScale = ((Component)this).transform.localScale;
			timer = localScale.x;
			distance = localScale.y;
			amountToSpawn = Mathf.RoundToInt(localScale.z);
		}

		private GameObject GetProjectile()
		{
			if (rangeWeapons == null || rangeWeapons.Length == 0)
			{
				return null;
			}
			return rangeWeapons[Random.Range(0, rangeWeapons.Length)].ObjectToSpawn;
		}
	}
	public class SmartBodyPartScaleSizing : MonoBehaviour
	{
		public enum RigType
		{
			Head,
			Neck,
			Torso,
			LegLeft,
			LegRight,
			FootLeft,
			FootRight,
			LeftHand,
			RightHand,
			LeftArm,
			RightArm,
			Hip
		}

		private Unit unit;

		public RigType rigType;

		private void Start()
		{
			unit = ((Component)((Component)this).transform.root).GetComponentInChildren<Unit>();
			if ((Object)(object)unit == (Object)null)
			{
				Debug.LogError((object)"Unit not found in hierarchy.");
			}
		}

		private void Update()
		{
			if ((Object)(object)unit != (Object)null)
			{
				UpdateRigData();
			}
		}

		private void UpdateRigData()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: 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_018f: Unknown result type (might be due to invalid IL or missing references)
			UnitRig componentInChildren = ((Component)unit).GetComponentInChildren<UnitRig>();
			switch (rigType)
			{
			case RigType.Head:
				((Component)componentInChildren.m_head).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.Neck:
				((Component)componentInChildren.m_neck).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.Torso:
				((Component)componentInChildren.m_torso).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.LegLeft:
				((Component)componentInChildren.m_legLeft).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.LegRight:
				((Component)componentInChildren.m_legRight).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.FootLeft:
				((Component)componentInChildren.m_footLeft).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.FootRight:
				((Component)componentInChildren.m_footRight).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.LeftHand:
				((Component)componentInChildren.m_wristLeft).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.RightHand:
				((Component)componentInChildren.m_wristRight).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.LeftArm:
				((Component)componentInChildren.m_armLeft).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.RightArm:
				((Component)componentInChildren.m_armRight).transform.localScale = ((Component)this).transform.localScale;
				break;
			case RigType.Hip:
				((Component)componentInChildren.m_waist).transform.localScale = ((Component)this).transform.localScale;
				break;
			}
		}
	}
	public class SmartConditionalEventManagerSet : MonoBehaviour
	{
		private Unit unit;

		private void Start()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0071: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Invalid comparison between Unknown and I4
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Invalid comparison between Unknown and I4
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			unit = ((Component)((Component)this).gameObject.transform.root).gameObject.GetComponentInChildren<Unit>();
			Vector3 loc