Decompiled source of EnemyAbilities v1.0.0

plugins/EnemyAbilities.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EnemyAbilities.Abilities;
using EntityStates;
using EntityStates.Vulture;
using Grumpy;
using JetBrains.Annotations;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.CharacterAI;
using RoR2.Projectile;
using RoR2.Scripts.GameBehaviors;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPaths.Version_1_35_0;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EnemyAbilities")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EnemyAbilities")]
[assembly: AssemblyTitle("EnemyAbilities")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EnemyAbilities
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Skeletogne.EnemyAbilities", "EnemyAbilities", "1.0.0")]
	public class EnemyAbilities : BaseUnityPlugin
	{
		public class ModuleInfoAttribute : Attribute
		{
			public string ModuleName { get; }

			public string Description { get; }

			public string Section { get; }

			public bool RequiresRestart { get; }

			public ModuleInfoAttribute(string moduleName, string description, string section, bool requiresRestart)
			{
				ModuleName = moduleName;
				Description = description;
				Section = section;
				RequiresRestart = requiresRestart;
			}
		}

		public const string PluginGUID = "Skeletogne.EnemyAbilities";

		public const string PluginAuthor = "Skeletogne";

		public const string PluginName = "EnemyAbilities";

		public const string PluginVersion = "1.0.0";

		public Dictionary<Type, ConfigEntry<bool>> configEntries = new Dictionary<Type, ConfigEntry<bool>>();

		internal static bool RooInstalled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		public static EnemyAbilities Instance { get; private set; }

		internal string DirectoryName => Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);

		public void Awake()
		{
			Instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			PluginConfig.Init(((BaseUnityPlugin)this).Config);
			foreach (KeyValuePair<Type, ConfigEntry<bool>> configEntry in configEntries)
			{
				ConfigEntry<bool> value = configEntry.Value;
				Type key = configEntry.Key;
				if (value.Value)
				{
					((Component)Instance).gameObject.AddComponent(key);
				}
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	internal static class PluginConfig
	{
		public static void Init(ConfigFile cfg)
		{
			if (EnemyAbilities.RooInstalled)
			{
				InitRoO();
			}
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Type[] array = (from type in executingAssembly.GetTypes()
				where type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(BaseModule))
				select type).ToArray();
			Type[] array2 = array;
			foreach (Type type2 in array2)
			{
				EnemyAbilities.ModuleInfoAttribute customAttribute = type2.GetCustomAttribute<EnemyAbilities.ModuleInfoAttribute>();
				if (customAttribute != null)
				{
					ConfigEntry<bool> value = cfg.BindOption(customAttribute.Section ?? "", customAttribute.ModuleName ?? "", defaultValue: true, customAttribute.Description ?? "", customAttribute.RequiresRestart);
					EnemyAbilities.Instance.configEntries.Add(type2, value);
				}
				else
				{
					Log.Error("ModuleInfo for " + type2.FullName + " does not exist! No PluginConfig entry has been created.");
				}
			}
		}

		public static void InitRoO()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ModSettingsManager.SetModDescription("Give enemies new abilities!", "Skeletogne.EnemyAbilities", "EnemyAbilities");
				byte[] array = File.ReadAllBytes(Path.Combine(EnemyAbilities.Instance.DirectoryName, "enemyAbilitiesIcon.png"));
				Texture2D val = new Texture2D(256, 256);
				ImageConversion.LoadImage(val, array);
				Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f));
				ModSettingsManager.SetModIcon(modIcon);
			}
			catch (Exception ex)
			{
				Log.Debug(ex.ToString());
			}
		}

		public static ConfigEntry<T> BindOption<T>(this ConfigFile myConfig, string section, string name, T defaultValue, string description = "", bool restartRequired = false)
		{
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			bool flag = ((defaultValue is int || defaultValue is float) ? true : false);
			if (flag && !typeof(T).IsEnum)
			{
				Log.Warning("Config entry " + name + " in section " + section + " is a numeric " + typeof(T).Name + " type, but has been registered without using BindOptionSlider. Lower and upper bounds will be set to the defaults [0, 20]. Was this intentional?");
				return myConfig.BindOptionSlider(section, name, defaultValue, description, 0f, 20f, restartRequired);
			}
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			if (restartRequired)
			{
				description += " (restart required)";
			}
			AcceptableValueBase val = null;
			if (typeof(T).IsEnum)
			{
				val = (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(T)));
			}
			ConfigEntry<T> val2 = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, val, Array.Empty<object>()));
			if (EnemyAbilities.RooInstalled)
			{
				TryRegisterOption<T>(val2, restartRequired);
			}
			return val2;
		}

		public static ConfigEntry<T> BindOptionSlider<T>(this ConfigFile myConfig, string section, string name, T defaultValue, string description = "", float min = 0f, float max = 20f, bool restartRequired = false)
		{
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			bool flag = ((defaultValue is int || defaultValue is float) ? true : false);
			if (!flag || typeof(T).IsEnum)
			{
				Log.Warning("Config entry " + name + " in section " + section + " is a not a numeric " + typeof(T).Name + " type, but has been registered as a slider option using BindOptionSlider. Was this intentional?");
				return myConfig.BindOption(section, name, defaultValue, description, restartRequired);
			}
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			string text = description;
			T val = defaultValue;
			description = text + " (Default: " + val?.ToString() + ")";
			if (restartRequired)
			{
				description += " (restart required)";
			}
			AcceptableValueBase val2 = (AcceptableValueBase)((typeof(T) == typeof(int)) ? ((object)new AcceptableValueRange<int>((int)min, (int)max)) : ((object)new AcceptableValueRange<float>(min, max)));
			ConfigEntry<T> val3 = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, val2, Array.Empty<object>()));
			if (EnemyAbilities.RooInstalled)
			{
				TryRegisterOptionSlider<T>(val3, min, max, restartRequired);
			}
			return val3;
		}

		public static ConfigEntry<T> BindOptionSteppedSlider<T>(this ConfigFile myConfig, string section, string name, T defaultValue, float increment = 1f, string description = "", float min = 0f, float max = 20f, bool restartRequired = false)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			string text = description;
			T val = defaultValue;
			description = text + " (Default: " + val?.ToString() + ")";
			if (restartRequired)
			{
				description += " (restart required)";
			}
			ConfigEntry<T> val2 = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>()));
			if (EnemyAbilities.RooInstalled)
			{
				TryRegisterOptionSteppedSlider<T>(val2, increment, min, max, restartRequired);
			}
			return val2;
		}

		public static void TryRegisterOption<T>(ConfigEntry<T> entry, bool restartRequired)
		{
			//IL_0012: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			if (entry is ConfigEntry<string> val)
			{
				ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(val, new InputFieldConfig
				{
					submitOn = (SubmitEnum)6,
					restartRequired = restartRequired
				}));
				return;
			}
			if (entry is ConfigEntry<bool> val2)
			{
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val2, restartRequired));
				return;
			}
			if (entry is ConfigEntry<KeyboardShortcut> val3)
			{
				ModSettingsManager.AddOption((BaseOption)new KeyBindOption(val3, restartRequired));
				return;
			}
			if (typeof(T).IsEnum)
			{
				ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, restartRequired));
				return;
			}
			Log.Warning("Config entry " + ((ConfigEntryBase)entry).Definition.Key + " in section " + ((ConfigEntryBase)entry).Definition.Section + " with type " + typeof(T).Name + " could not be registered in Risk Of Options using TryRegisterOption.");
		}

		public static void TryRegisterOptionSlider<T>(ConfigEntry<T> entry, float min, float max, bool restartRequired)
		{
			//IL_0012: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			if (entry is ConfigEntry<int> val)
			{
				ModSettingsManager.AddOption((BaseOption)new IntSliderOption(val, new IntSliderConfig
				{
					min = (int)min,
					max = (int)max,
					formatString = "{0:0}",
					restartRequired = restartRequired
				}));
			}
			else if (entry is ConfigEntry<float> val2)
			{
				ModSettingsManager.AddOption((BaseOption)new SliderOption(val2, new SliderConfig
				{
					min = min,
					max = max,
					FormatString = "{0:0.000}",
					restartRequired = restartRequired
				}));
			}
			else
			{
				Log.Warning("Config entry " + ((ConfigEntryBase)entry).Definition.Key + " in section " + ((ConfigEntryBase)entry).Definition.Section + " with type " + typeof(T).Name + " could not be registered in Risk Of Options using TryRegisterOptionSlider.");
			}
		}

		public static void TryRegisterOptionSteppedSlider<T>(ConfigEntry<T> entry, float increment, float min, float max, bool restartRequired)
		{
			//IL_0012: 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_001e: 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)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			if (entry is ConfigEntry<float> val)
			{
				ModSettingsManager.AddOption((BaseOption)new StepSliderOption(val, new StepSliderConfig
				{
					increment = increment,
					min = min,
					max = max,
					FormatString = "{0:0}",
					restartRequired = restartRequired
				}));
			}
			else
			{
				Log.Warning("Config entry " + ((ConfigEntryBase)entry).Definition.Key + " in section " + ((ConfigEntryBase)entry).Definition.Section + " with type " + typeof(T).Name + " could not be registered in Risk Of Options using TryRegisterOptionSteppedSlider.");
			}
		}
	}
	public static class Utils
	{
		public static void ReorderSkillDrivers(this GameObject master, AISkillDriver targetSkill, int targetIdx)
		{
			AISkillDriver[] components = master.GetComponents<AISkillDriver>();
			master.ReorderSkillDrivers(components, Array.IndexOf(components, targetSkill), targetIdx);
		}

		public static void ReorderSkillDrivers(this GameObject master, AISkillDriver[] skills, int currentIdx, int targetIdx)
		{
			if (currentIdx < 0 || currentIdx >= skills.Length)
			{
				Log.Error($"{currentIdx} index not found or out of range. Must be less than {skills.Length}");
				return;
			}
			string targetName = skills[currentIdx].customName;
			if (targetIdx < 0 || targetIdx >= skills.Length)
			{
				Log.Error($"Unable to reorder skilldriver {targetName} into position {targetIdx}. target must be less than {skills.Length}");
				return;
			}
			if (targetIdx == currentIdx)
			{
				Log.Warning($"Skilldriver {targetName} already has the target index of {targetIdx}");
				return;
			}
			Dictionary<string, string> dictionary = skills.Where((AISkillDriver s) => (Object)(object)s.nextHighPriorityOverride != (Object)null).ToDictionary((AISkillDriver s) => s.customName, (AISkillDriver s) => s.nextHighPriorityOverride.customName);
			if (targetIdx > currentIdx)
			{
				master.AddComponentCopy<AISkillDriver>(skills[currentIdx]);
				Object.DestroyImmediate((Object)(object)skills[currentIdx]);
			}
			for (int i = targetIdx; i < skills.Length; i++)
			{
				if (i != currentIdx)
				{
					master.AddComponentCopy<AISkillDriver>(skills[i]);
					Object.DestroyImmediate((Object)(object)skills[i]);
				}
			}
			skills = master.GetComponents<AISkillDriver>();
			AISkillDriver val = ((IEnumerable<AISkillDriver>)skills).FirstOrDefault((Func<AISkillDriver, bool>)((AISkillDriver s) => s.customName == targetName));
			if ((Object)(object)val != (Object)null && Array.IndexOf(skills, val) == targetIdx)
			{
				Log.Debug($"Successfully set {targetName} to {targetIdx}");
			}
			else
			{
				Log.Error($"Done fucked it up on {targetName} with {targetIdx}");
			}
			if (!dictionary.Any())
			{
				return;
			}
			foreach (AISkillDriver val2 in skills)
			{
				if (Object.op_Implicit((Object)(object)val2) && dictionary.TryGetValue(val2.customName, out var target))
				{
					AISkillDriver val3 = ((IEnumerable<AISkillDriver>)skills).FirstOrDefault((Func<AISkillDriver, bool>)((AISkillDriver s) => s.customName == target));
					if ((Object)(object)val3 == (Object)null)
					{
						Log.Error("Unable to reset skill override for " + val2.customName + " targeting " + target);
						continue;
					}
					val2.nextHighPriorityOverride = val3;
					Log.Debug("successfully reset override for " + val2.customName + " targeting " + target);
				}
			}
		}

		public static T GetCopyOf<T>(this Component comp, T other) where T : Component
		{
			Type type = ((object)comp).GetType();
			if (type != ((object)other).GetType())
			{
				return default(T);
			}
			BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			PropertyInfo[] properties = type.GetProperties(bindingAttr);
			PropertyInfo[] array = properties;
			foreach (PropertyInfo propertyInfo in array)
			{
				if (propertyInfo.CanWrite)
				{
					try
					{
						propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null);
					}
					catch
					{
					}
				}
			}
			FieldInfo[] fields = type.GetFields(bindingAttr);
			FieldInfo[] array2 = fields;
			foreach (FieldInfo fieldInfo in array2)
			{
				fieldInfo.SetValue(comp, fieldInfo.GetValue(other));
			}
			return (T)(object)((comp is T) ? comp : null);
		}

		public static T AddComponentCopy<T>(this GameObject go, T toAdd) where T : Component
		{
			return ((Component)(object)go.AddComponent<T>()).GetCopyOf(toAdd);
		}
	}
}
namespace EnemyAbilities.Abilities
{
	public class BaseModule : MonoBehaviour
	{
		public virtual void Awake()
		{
			Log.Debug("Loading module " + ((object)this).GetType().Name);
		}
	}
}
namespace EnemyAbilities.Abilities.SolusProspector
{
	[EnemyAbilities.ModuleInfo("Drill Burrow", "Gives Solus Prospectors a new Secondary ability: \n- Drill Burrow: Allows the Prospector to disappear underground to remain hidden for 1 second, before burrowing up beneath a nearby target.", "Solus Prospector", true)]
	public class DrillBurrowModule : BaseModule
	{
		private static GameObject bodyPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC3_WorkerUnit.WorkerUnitBody_prefab).WaitForCompletion();

		private static GameObject masterPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC3_WorkerUnit.WorkerUnitMaster_prefab).WaitForCompletion();

		public override void Awake()
		{
			base.Awake();
			CreateSkill();
		}

		public void CreateSkill()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0083: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			SkillDef val = ScriptableObject.CreateInstance<SkillDef>();
			((Object)val).name = "WorkerUnitBodyDrillBurrow";
			val.skillName = "WorkerUnitDrillBurrow";
			val.activationStateMachineName = "Weapon";
			bool flag = default(bool);
			val.activationState = ContentAddition.AddEntityState<DrillBurrow>(ref flag);
			val.baseRechargeInterval = 15f;
			val.cancelSprintingOnActivation = true;
			val.isCombatSkill = true;
			ContentAddition.AddSkillDef(val);
			SkillFamily val2 = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val2).name = "WorkerUnitSecondaryFamily";
			val2.variants = (Variant[])(object)new Variant[1]
			{
				new Variant
				{
					skillDef = val
				}
			};
			GenericSkill val3 = bodyPrefab.AddComponent<GenericSkill>();
			val3.skillName = "WorkerUnitDrillBurrow";
			val3._skillFamily = val2;
			SkillLocator component = bodyPrefab.GetComponent<SkillLocator>();
			component.secondary = val3;
			ContentAddition.AddSkillFamily(val2);
			AISkillDriver val4 = masterPrefab.AddComponent<AISkillDriver>();
			val4.customName = "useSecondary";
			val4.skillSlot = (SkillSlot)1;
			val4.requireSkillReady = true;
			val4.minDistance = 20f;
			val4.maxDistance = 50f;
			val4.selectionRequiresOnGround = true;
			val4.movementType = (MovementType)0;
			val4.aimType = (AimType)0;
			val4.ignoreNodeGraph = true;
			val4.maxUserHealthFraction = 1f;
			masterPrefab.ReorderSkillDrivers(val4, 0);
		}
	}
	public class DrillBurrow : BaseSkillState
	{
		private enum DrillBurrowState
		{
			None,
			Windup,
			Burrowed,
			Telegraphing,
			Attacking
		}

		public static float baseWindupDuration = 1f;

		public static float baseBurrowDuration = 1f;

		public static float baseTelegraphDuration = 1.5f;

		public static float baseAttackDuration = 1f;

		public static float blastRadius = 6f;

		public static float force = 1500f;

		public static Vector3 bonusForce = new Vector3(0f, 2500f, 0f);

		public static float damageCoefficient = 3f;

		public static float exitSpeedMultiplier = 2.5f;

		private static GameObject indicatorPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Common.TeamAreaIndicator__GroundOnly_prefab).WaitForCompletion();

		private static GameObject explosionPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_BeetleGuard.BeetleGuardGroundSlam_prefab).WaitForCompletion();

		private static GameObject burrowPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_MiniMushroom.MiniMushroomPlantEffect_prefab).WaitForCompletion();

		private float windupDuration;

		private float burrowDuration;

		private float telegraphDuration;

		private float attackDuration;

		private float totalDuration;

		private float stopwatch = 0f;

		private int originalLayerIndex;

		private Vector3 targetPos;

		private GameObject indicatorInstance;

		private ChildLocator childLocator;

		private Animator animator;

		private bool reachedApex;

		private float burrowEffectTimer = 0f;

		private float burrowEffectInterval = 0.1f;

		private DrillBurrowState currentState = DrillBurrowState.None;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			animator = ((EntityState)this).GetModelAnimator();
			childLocator = ((Component)animator).GetComponent<ChildLocator>();
			originalLayerIndex = ((EntityState)this).gameObject.layer;
			windupDuration = baseWindupDuration / ((BaseState)this).attackSpeedStat;
			burrowDuration = baseBurrowDuration / ((BaseState)this).attackSpeedStat;
			telegraphDuration = baseTelegraphDuration;
			attackDuration = baseAttackDuration / ((BaseState)this).attackSpeedStat;
			totalDuration = windupDuration + burrowDuration + telegraphDuration + attackDuration;
			currentState = DrillBurrowState.Windup;
		}

		public override void OnExit()
		{
			((EntityState)this).OnExit();
			SetSprintEffectState(active: false);
			if (currentState != DrillBurrowState.Attacking)
			{
				Emerge();
			}
		}

		public void SpawnDirtEffect()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0040: 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_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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			EffectData val = new EffectData();
			if (currentState == DrillBurrowState.Windup)
			{
				val._origin = ((EntityState)this).characterBody.footPosition + Random.insideUnitSphere * 3f;
			}
			else
			{
				val._origin = targetPos;
			}
			val.scale = 2f;
			EffectManager.SpawnEffect(burrowPrefab, val, true);
		}

		public override void FixedUpdate()
		{
			//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_0138: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).FixedUpdate();
			stopwatch += Time.fixedDeltaTime;
			if (currentState == DrillBurrowState.Windup)
			{
				((EntityState)this).characterMotor.velocity = Vector3.zero;
			}
			if (stopwatch > windupDuration && currentState == DrillBurrowState.Windup)
			{
				Burrow();
				currentState = DrillBurrowState.Burrowed;
			}
			if (stopwatch > windupDuration + burrowDuration && currentState == DrillBurrowState.Burrowed)
			{
				Telegraph();
				burrowEffectTimer = 0f;
				currentState = DrillBurrowState.Telegraphing;
			}
			if (stopwatch > windupDuration + burrowDuration + telegraphDuration && currentState == DrillBurrowState.Telegraphing)
			{
				FireAttack();
				currentState = DrillBurrowState.Attacking;
			}
			if (currentState == DrillBurrowState.Attacking && !reachedApex)
			{
				if (((EntityState)this).characterMotor.velocity.y <= 0f)
				{
					reachedApex = true;
					OnReachedApex();
				}
				else
				{
					((EntityState)this).inputBank.aimDirection = Vector3.up;
				}
			}
			if (stopwatch > totalDuration && ((EntityState)this).characterMotor.isGrounded)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
			if (currentState == DrillBurrowState.Windup || currentState == DrillBurrowState.Telegraphing)
			{
				burrowEffectTimer -= Time.fixedDeltaTime;
				if (burrowEffectTimer < 0f)
				{
					burrowEffectTimer += burrowEffectInterval;
					SpawnDirtEffect();
				}
			}
		}

		public void OnReachedApex()
		{
			SetSprintEffectState(active: false);
		}

		public void Burrow()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)((EntityState)this).characterBody == (Object)null) && !((Object)(object)((EntityState)this).characterMotor == (Object)null))
			{
				((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = 0f;
				if (((EntityState)this).characterBody.GetBuffCount(Buffs.HiddenInvincibility.buffIndex) < 1)
				{
					((EntityState)this).characterBody.AddBuff(Buffs.HiddenInvincibility.buffIndex);
				}
				originalLayerIndex = ((EntityState)this).gameObject.layer;
				((EntityState)this).gameObject.layer = LayerIndex.GetAppropriateFakeLayerForTeam(((EntityState)this).teamComponent.teamIndex).intVal;
				((BaseCharacterController)((EntityState)this).characterMotor).Motor.RebuildCollidableLayers();
				if ((Object)(object)((EntityState)this).modelLocator != (Object)null && (Object)(object)((EntityState)this).modelLocator.modelTransform != (Object)null)
				{
					((Component)((EntityState)this).modelLocator.modelTransform).gameObject.SetActive(false);
				}
			}
		}

		public void Telegraph()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			BullseyeSearch val = new BullseyeSearch();
			targetPos = ((EntityState)this).transform.position;
			val.viewer = ((EntityState)this).characterBody;
			val.teamMaskFilter = TeamMask.allButNeutral;
			((TeamMask)(ref val.teamMaskFilter)).RemoveTeam(((EntityState)this).characterBody.teamComponent.teamIndex);
			val.sortMode = (SortMode)3;
			val.minDistanceFilter = 0f;
			val.maxDistanceFilter = 60f;
			val.searchOrigin = ((EntityState)this).inputBank.aimOrigin;
			val.searchDirection = ((EntityState)this).inputBank.aimDirection;
			val.maxAngleFilter = 360f;
			val.filterByLoS = false;
			val.RefreshCandidates();
			HurtBox val2 = val.GetResults().FirstOrDefault();
			if ((Object)(object)val2 != (Object)null)
			{
				targetPos = val2.healthComponent.body.footPosition;
				Util.PlaySound("Play_GildedElite_Pillar_Spawn", ((Component)val2.healthComponent.body).gameObject);
			}
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(targetPos, Vector3.down, ref val3, 1000f, LayerMask.op_Implicit(CommonMasks.bullet)))
			{
				targetPos = ((RaycastHit)(ref val3)).point;
			}
			indicatorInstance = Object.Instantiate<GameObject>(indicatorPrefab, targetPos, Util.QuaternionSafeLookRotation(Vector3.up));
			indicatorInstance.transform.localScale = Vector3.one * blastRadius;
			TeamAreaIndicator component = indicatorInstance.GetComponent<TeamAreaIndicator>();
			if ((Object)(object)component != (Object)null)
			{
				component.teamComponent = ((EntityState)this).teamComponent;
			}
		}

		private void SetSprintEffectState(bool active)
		{
			if (Object.op_Implicit((Object)(object)childLocator))
			{
				Transform obj = childLocator.FindChild("SprintEffect");
				if (obj != null)
				{
					((Component)obj).gameObject.SetActive(active);
				}
			}
		}

		public void FireAttack()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			TeleportHelper.TeleportBody(((EntityState)this).characterBody, targetPos, false);
			Util.PlaySound("Play_MULT_m2_secondary_explode", ((EntityState)this).gameObject);
			Emerge();
			SetSprintEffectState(active: true);
			((EntityState)this).PlayAnimation("Gesture, Additive", "FrenziedMeleeAttack", "attack.playbackRate", 1f, 0f);
			BlastAttack val = new BlastAttack();
			val.attacker = ((EntityState)this).gameObject;
			val.attackerFiltering = (AttackerFiltering)2;
			val.baseDamage = damageCoefficient * ((BaseState)this).damageStat;
			val.baseForce = force;
			val.bonusForce = bonusForce;
			val.crit = ((BaseState)this).RollCrit();
			val.damageColorIndex = (DamageColorIndex)0;
			val.damageType = DamageTypeCombo.op_Implicit((DamageType)0);
			val.falloffModel = (FalloffModel)2;
			val.inflictor = ((EntityState)this).gameObject;
			val.position = targetPos;
			val.procCoefficient = 1f;
			val.procChainMask = default(ProcChainMask);
			val.radius = blastRadius;
			val.teamIndex = ((EntityState)this).teamComponent.teamIndex;
			val.Fire();
			if ((Object)(object)((EntityState)this).characterMotor != (Object)null)
			{
				((BaseCharacterController)((EntityState)this).characterMotor).Motor.ForceUnground(0.1f);
				((EntityState)this).characterMotor.velocity = new Vector3(0f, ((BaseState)this).moveSpeedStat * 2.5f, 0f);
			}
			EffectManager.SpawnEffect(explosionPrefab, new EffectData
			{
				origin = ((EntityState)this).characterBody.transform.position,
				scale = blastRadius
			}, true);
		}

		public void Emerge()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)((EntityState)this).characterBody == (Object)null) && !((Object)(object)((EntityState)this).characterMotor == (Object)null))
			{
				if ((Object)(object)indicatorInstance != (Object)null)
				{
					Object.Destroy((Object)(object)indicatorInstance);
				}
				((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = 1f;
				((EntityState)this).characterBody.RemoveBuff(Buffs.HiddenInvincibility.buffIndex);
				((EntityState)this).gameObject.layer = originalLayerIndex;
				((BaseCharacterController)((EntityState)this).characterMotor).Motor.RebuildCollidableLayers();
				if ((Object)(object)((EntityState)this).modelLocator != (Object)null && (Object)(object)((EntityState)this).modelLocator.modelTransform != (Object)null)
				{
					((Component)((EntityState)this).modelLocator.modelTransform).gameObject.SetActive(true);
				}
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)2;
		}
	}
}
namespace EnemyAbilities.Abilities.Vulture
{
	[EnemyAbilities.ModuleInfo("Swoop", "Gives Alloy Vultures a new secondary:\n- Swoop: Allows Alloy Vultures to swoop towards the player in an arc, dealing contact damage.", "Alloy Vulture", true)]
	public class SwoopModule : BaseModule
	{
		private static GameObject bodyPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Vulture.VultureBody_prefab).WaitForCompletion();

		private static GameObject masterPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Vulture.VultureMaster_prefab).WaitForCompletion();

		public override void Awake()
		{
			base.Awake();
			TargetingAndPredictionController val = bodyPrefab.AddComponent<TargetingAndPredictionController>();
			val.manualTrackingMaxDistance = 100f;
			val.manualTrackingMaxAngle = 360f;
			CreateSkill();
			CharacterBody.onBodyStartGlobal += AddMeleeHitBox;
		}

		private void AddMeleeHitBox(CharacterBody characterBody)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)characterBody == (Object)null) && !((Object)(object)characterBody.master == (Object)null) && (Object)(object)characterBody.master.bodyPrefab != (Object)null && (Object)(object)characterBody.master.bodyPrefab == (Object)(object)bodyPrefab)
			{
				GameObject gameObject = ((Component)characterBody).gameObject;
				Transform modelTransform = characterBody.modelLocator.modelTransform;
				GameObject gameObject2 = ((Component)modelTransform).gameObject;
				CreateHitBoxAndGroup(modelTransform, "VultureMelee", new Vector3(0f, -2f, 0f), new Vector3(30f, 30f, 30f));
			}
		}

		public void CreateSkill()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0083: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			SwoopSkillDef swoopSkillDef = ScriptableObject.CreateInstance<SwoopSkillDef>();
			((Object)swoopSkillDef).name = "VultureBodySwoop";
			((SkillDef)swoopSkillDef).skillName = "VultureSwoop";
			((SkillDef)swoopSkillDef).activationStateMachineName = "Body";
			bool flag = default(bool);
			((SkillDef)swoopSkillDef).activationState = ContentAddition.AddEntityState<SwoopWindup>(ref flag);
			((SkillDef)swoopSkillDef).baseRechargeInterval = 12f;
			((SkillDef)swoopSkillDef).cancelSprintingOnActivation = true;
			((SkillDef)swoopSkillDef).isCombatSkill = true;
			ContentAddition.AddSkillDef((SkillDef)(object)swoopSkillDef);
			SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val).name = "VultureSecondaryFamily";
			val.variants = (Variant[])(object)new Variant[1]
			{
				new Variant
				{
					skillDef = (SkillDef)(object)swoopSkillDef
				}
			};
			GenericSkill val2 = bodyPrefab.AddComponent<GenericSkill>();
			val2.skillName = "VultureSwoop";
			val2._skillFamily = val;
			SkillLocator component = bodyPrefab.GetComponent<SkillLocator>();
			component.secondary = val2;
			ContentAddition.AddSkillFamily(val);
			AISkillDriver val3 = masterPrefab.AddComponent<AISkillDriver>();
			val3.customName = "strafeAndUseSecondary";
			val3.skillSlot = (SkillSlot)1;
			val3.requiredSkill = (SkillDef)(object)swoopSkillDef;
			val3.requireSkillReady = true;
			val3.minDistance = 25f;
			val3.maxDistance = 50f;
			val3.moveTargetType = (TargetType)0;
			val3.movementType = (MovementType)2;
			masterPrefab.ReorderSkillDrivers(val3, 2);
			ContentAddition.AddEntityState<Swoop>(ref flag);
		}

		private void CreateHitBoxAndGroup(Transform modelTransform, string hitBoxGroupName, Vector3 localPosition, Vector3 localScale, string hitBoxGroupObjName = "", string hitBoxObjName = "")
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0046: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			hitBoxGroupObjName = ((hitBoxGroupObjName == "") ? hitBoxGroupName : hitBoxGroupObjName);
			hitBoxObjName = ((hitBoxObjName == "") ? hitBoxGroupName : hitBoxObjName);
			GameObject val = new GameObject(hitBoxGroupObjName);
			val.transform.SetParent(modelTransform);
			val.transform.localPosition = localPosition;
			val.transform.localScale = localScale;
			val.transform.localRotation = Quaternion.identity;
			HitBox val2 = val.AddComponent<HitBox>();
			((Object)((Component)val2).gameObject).name = hitBoxObjName;
			HitBoxGroup val3 = ((Component)modelTransform).gameObject.AddComponent<HitBoxGroup>();
			val3.groupName = hitBoxGroupName;
			val3.hitBoxes = (HitBox[])(object)new HitBox[1] { val2 };
		}
	}
	public class SwoopSkillDef : SkillDef
	{
		private class InstanceData : BaseSkillInstanceData
		{
			public CharacterBody body;

			public EntityStateMachine flightEsm;
		}

		public override BaseSkillInstanceData OnAssigned(GenericSkill skillSlot)
		{
			CharacterBody characterBody = skillSlot.characterBody;
			EntityStateMachine flightEsm = ((IEnumerable<EntityStateMachine>)((Component)characterBody).GetComponents<EntityStateMachine>()).FirstOrDefault((Func<EntityStateMachine, bool>)((EntityStateMachine esm) => esm.customName == "Flight"));
			return (BaseSkillInstanceData)(object)new InstanceData
			{
				body = characterBody,
				flightEsm = flightEsm
			};
		}

		public override bool IsReady([NotNull] GenericSkill skillSlot)
		{
			//IL_0061: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			InstanceData instanceData = skillSlot.skillInstanceData as InstanceData;
			if ((Object)(object)instanceData?.flightEsm == (Object)null || (Object)(object)instanceData.body == (Object)null)
			{
				return false;
			}
			if (!(instanceData.flightEsm.state is Fly))
			{
				return false;
			}
			if (Physics.Raycast(instanceData.body.corePosition, Vector3.down, 8f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				return false;
			}
			if ((Object)(object)instanceData.body.characterMotor != (Object)null && instanceData.body.characterMotor.isGrounded)
			{
				return false;
			}
			return ((SkillDef)this).IsReady(skillSlot);
		}
	}
	public class SwoopWindup : BaseSkillState
	{
		private float duration;

		private static float baseDuration = 0.5f;

		private Vector3 targetLocation;

		private BaseAI ai;

		private bool success;

		private GameObject jumpEffect = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Vulture.VultureJumpEffect_prefab).WaitForCompletion();

		public override void OnEnter()
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			duration = baseDuration / ((BaseState)this).attackSpeedStat;
			((EntityState)this).skillLocator.utility.SetSkillOverride((object)((EntityState)this).gameObject, CommonAssets.disabledSkill, (SkillOverridePriority)4);
			CharacterMaster master = ((EntityState)this).characterBody.master;
			if ((Object)(object)master != (Object)null)
			{
				ai = ((Component)master).gameObject.GetComponent<BaseAI>();
			}
			if ((Object)(object)ai != (Object)null && ai.currentEnemy != null && (Object)(object)ai.currentEnemy.characterBody != (Object)null)
			{
				targetLocation = ai.currentEnemy.characterBody.transform.position;
			}
			Vector3 val = ((EntityState)this).characterBody.corePosition - targetLocation;
			val.y = 0f;
			((Vector3)(ref val)).Normalize();
			if ((Object)(object)((EntityState)this).characterMotor != (Object)null)
			{
				EffectManager.SpawnEffect(jumpEffect, new EffectData
				{
					scale = 2f,
					origin = ((EntityState)this).characterBody.footPosition,
					rotation = Util.QuaternionSafeLookRotation(Vector3.down)
				}, true);
				((EntityState)this).characterMotor.velocity = val * 10f + new Vector3(0f, 25f, 0f);
			}
		}

		public override void OnExit()
		{
			((EntityState)this).OnExit();
			if (!success)
			{
				((EntityState)this).skillLocator.utility.UnsetSkillOverride((object)((EntityState)this).gameObject, CommonAssets.disabledSkill, (SkillOverridePriority)4);
			}
		}

		public override void FixedUpdate()
		{
			//IL_005e: 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)
			((EntityState)this).FixedUpdate();
			if ((Object)(object)((EntityState)this).characterMotor != (Object)null && ((EntityState)this).characterMotor.isGrounded)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
			if (((EntityState)this).fixedAge > duration)
			{
				if (ai.currentEnemy.characterBody.transform.position.y < ((EntityState)this).characterBody.transform.position.y)
				{
					((EntityState)this).outer.SetNextStateToMain();
				}
				success = true;
				((EntityState)this).outer.SetNextState((EntityState)(object)new Swoop());
			}
		}

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

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)2;
		}
	}
	public class Swoop : BaseSkillState
	{
		public static float predictionDuration = 0.5f;

		private static float swoopDurationTilTarget = 1.5f;

		private static float recoverDuration = 0.5f;

		private static GameObject slashEffect = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Croco.CrocoSlash_prefab).WaitForCompletion();

		private static GameObject hitEffect = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Common_VFX.OmniImpactVFXSlash_prefab).WaitForCompletion();

		private GameObject slashEffectInstance;

		private EffectManagerHelper _emh_slashEffectInstance;

		private GameObject jumpEffect = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Vulture.VultureJumpEffect_prefab).WaitForCompletion();

		private static float effectInterval = 0.25f;

		private float effectTimer;

		private static int maxSwingCount = 5;

		private int swingCount = 0;

		private bool startLeftFoot;

		private static float firstSwingDelay = 1.1f;

		private static float swingInterval = 0.2f;

		private float nextSwingTime;

		private float recoverTimer = 0f;

		private float swoopStopwatch = 0f;

		private float swoopFullDuration = 3f;

		private TargetingAndPredictionController targetController;

		private Transform trackedTarget;

		private Vector3 vultureStartPosition;

		private Vector3 finalTarget;

		private bool madePrediction = false;

		private bool finishedSwoop = false;

		private bool pastTarget = false;

		private float damageCoefficient = 1.25f;

		private float procCoefficient = 1f;

		private float crashAngle = 40f;

		private OverlapAttack attack;

		private int _origLayer;

		public override void OnEnter()
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			((BaseState)this).OnEnter();
			nextSwingTime = firstSwingDelay;
			if ((Object)(object)((EntityState)this).characterMotor != (Object)null && ((EntityState)this).characterMotor.isGrounded)
			{
				((EntityState)this).outer.SetNextStateToMain();
				return;
			}
			swoopFullDuration = swoopDurationTilTarget * 2f;
			targetController = ((EntityState)this).GetComponent<TargetingAndPredictionController>();
			if ((Object)(object)targetController != (Object)null && ((EntityState)this).isAuthority)
			{
				trackedTarget = targetController.StartPredictTarget((Action)OnTargetLost);
			}
			if ((Object)(object)((EntityState)this).characterMotor != (Object)null)
			{
				((EntityState)this).characterMotor.onMovementHit += new MovementHitDelegate(OnMovementHit);
			}
			startLeftFoot = Random.RandomRangeInt(0, 2) == 1;
			DisableCollision();
			attack = new OverlapAttack();
			attack.attacker = ((EntityState)this).gameObject;
			attack.inflictor = ((EntityState)this).gameObject;
			attack.teamIndex = ((EntityState)this).teamComponent.teamIndex;
			attack.damage = damageCoefficient * ((BaseState)this).damageStat;
			attack.hitEffectPrefab = hitEffect;
			attack.isCrit = ((BaseState)this).RollCrit();
			attack.procCoefficient = procCoefficient;
			attack.damageType = DamageTypeCombo.op_Implicit((DamageType)1024);
			attack.hitBoxGroup = ((BaseState)this).FindHitBoxGroup("VultureMelee");
			attack.forceVector = ((EntityState)this).characterDirection.forward * 500f;
		}

		private void OnMovementHit(ref MovementHitInfo movementHitInfo)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (((Vector3)(ref ((EntityState)this).characterMotor.velocity)).magnitude < 5f)
			{
				return;
			}
			Vector3 normalized = ((Vector3)(ref ((EntityState)this).characterMotor.velocity)).normalized;
			Vector3 hitNormal = movementHitInfo.hitNormal;
			float num = Vector3.Angle(normalized, hitNormal);
			if (num > 180f - crashAngle)
			{
				SetStateOnHurt component = ((Component)((EntityState)this).characterBody).gameObject.GetComponent<SetStateOnHurt>();
				if ((Object)(object)component != (Object)null)
				{
					component.SetStun(1f);
				}
			}
		}

		public override void OnExit()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			((EntityState)this).OnExit();
			((EntityState)this).skillLocator.utility.UnsetSkillOverride((object)((EntityState)this).gameObject, CommonAssets.disabledSkill, (SkillOverridePriority)4);
			((EntityState)this).characterMotor.velocity = new Vector3(0f, 0f, 0f);
			((EntityState)this).characterMotor.onMovementHit -= new MovementHitDelegate(OnMovementHit);
			EnableCollision();
			if ((Object)(object)_emh_slashEffectInstance != (Object)null && _emh_slashEffectInstance.OwningPool != null)
			{
				((GenericPool<EffectManagerHelper>)(object)_emh_slashEffectInstance.OwningPool).ReturnObject(_emh_slashEffectInstance);
			}
			else if (Object.op_Implicit((Object)(object)slashEffectInstance))
			{
				EntityState.Destroy((Object)(object)slashEffectInstance);
			}
			slashEffectInstance = null;
			_emh_slashEffectInstance = null;
		}

		public override void FixedUpdate()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: 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_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Expected O, but got Unknown
			((EntityState)this).FixedUpdate();
			if (!madePrediction)
			{
				CharacterMotor characterMotor = ((EntityState)this).characterMotor;
				characterMotor.velocity /= 1.2f;
			}
			if (((EntityState)this).fixedAge > predictionDuration && !madePrediction)
			{
				Vector3 position = default(Vector3);
				if (!targetController.GetPredictionPositionConsumePredictor(swoopDurationTilTarget, ref position))
				{
					position = trackedTarget.position;
				}
				finalTarget = position + new Vector3(0f, 4f, 0f);
				vultureStartPosition = ((EntityState)this).characterBody.corePosition;
				if (finalTarget.y > vultureStartPosition.y)
				{
					((EntityState)this).outer.SetNextStateToMain();
					return;
				}
				madePrediction = true;
				swoopStopwatch = 0f;
			}
			if (madePrediction && !finishedSwoop)
			{
				if (((EntityState)this).characterMotor.isGrounded)
				{
					((BaseCharacterController)((EntityState)this).characterMotor).Motor.ForceUnground(0.1f);
				}
				swoopStopwatch += Time.fixedDeltaTime;
				float num = finalTarget.x - vultureStartPosition.x;
				float num2 = finalTarget.y - vultureStartPosition.y;
				float num3 = finalTarget.z - vultureStartPosition.z;
				float num4 = 2f * num / Mathf.Pow(swoopDurationTilTarget, 2f);
				float num5 = 2f * num3 / Mathf.Pow(swoopDurationTilTarget, 2f);
				float num6 = 2f * num2 / Mathf.Pow(swoopDurationTilTarget, 2f);
				float num7 = 0f;
				float num8 = 0f;
				float num9 = 0f;
				if (!pastTarget)
				{
					num7 = num4 * swoopStopwatch;
					num8 = num6 * (swoopDurationTilTarget - swoopStopwatch);
					num9 = num5 * swoopStopwatch;
				}
				if (pastTarget)
				{
					num7 = num4 * (swoopFullDuration - swoopStopwatch);
					num8 = 0f - num6 * (swoopStopwatch - swoopDurationTilTarget);
					num9 = num5 * (swoopFullDuration - swoopStopwatch);
				}
				if (swoopStopwatch > firstSwingDelay && swoopStopwatch < firstSwingDelay + (float)maxSwingCount * swingInterval)
				{
					attack.Fire((List<HurtBox>)null);
				}
				if (swoopStopwatch > nextSwingTime && swingCount < maxSwingCount)
				{
					SwingEffect();
					swingCount++;
					nextSwingTime += swingInterval;
				}
				Vector3 velocity = default(Vector3);
				((Vector3)(ref velocity))..ctor(num7, num8, num9);
				((EntityState)this).characterMotor.velocity = velocity;
				if ((Object)(object)((EntityState)this).characterDirection != (Object)null)
				{
					((EntityState)this).characterDirection.moveVector = ((Vector3)(ref velocity)).normalized;
				}
				effectTimer -= Time.fixedDeltaTime;
				if (effectTimer < 0f)
				{
					effectTimer += effectInterval;
					EffectManager.SpawnEffect(jumpEffect, new EffectData
					{
						scale = 2f,
						origin = ((EntityState)this).characterBody.footPosition,
						rotation = Util.QuaternionSafeLookRotation(((EntityState)this).characterMotor.velocity)
					}, true);
				}
			}
			if (swoopStopwatch > swoopDurationTilTarget)
			{
				pastTarget = true;
			}
			if (swoopStopwatch > swoopFullDuration)
			{
				finishedSwoop = true;
				CharacterMotor characterMotor2 = ((EntityState)this).characterMotor;
				characterMotor2.velocity /= 1.2f;
				recoverTimer += Time.fixedDeltaTime;
				if (recoverTimer > recoverDuration)
				{
					((EntityState)this).outer.SetNextStateToMain();
				}
			}
		}

		private void OnTargetLost()
		{
			if (((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		private void SwingEffect()
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			Util.PlaySound("Play_acrid_m1_slash", ((EntityState)this).gameObject);
			string text = "";
			int num = swingCount % 2;
			text = ((num != ((!startLeftFoot) ? 1 : 0)) ? "FootR" : "FootL");
			if (!Object.op_Implicit((Object)(object)slashEffect) || !Object.op_Implicit((Object)(object)slashEffect))
			{
				return;
			}
			Transform val = ((BaseState)this).FindModelChild(text);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			if (!EffectManager.ShouldUsePooledEffect(slashEffect))
			{
				if ((Object)(object)slashEffectInstance != (Object)null)
				{
					EntityState.Destroy((Object)(object)slashEffectInstance);
					slashEffectInstance = null;
				}
				slashEffectInstance = Object.Instantiate<GameObject>(slashEffect, val);
				slashEffectInstance.transform.localScale = Vector3.one;
			}
			else
			{
				if ((Object)(object)_emh_slashEffectInstance != (Object)null && _emh_slashEffectInstance.OwningPool != null)
				{
					((GenericPool<EffectManagerHelper>)(object)_emh_slashEffectInstance.OwningPool).ReturnObject(_emh_slashEffectInstance);
					_emh_slashEffectInstance = null;
				}
				_emh_slashEffectInstance = EffectManager.GetAndActivatePooledEffect(slashEffect, val, true);
				slashEffectInstance = ((Component)_emh_slashEffectInstance).gameObject;
				slashEffectInstance.transform.localScale = Vector3.one;
			}
			ScaleParticleSystemDuration component = slashEffectInstance.GetComponent<ScaleParticleSystemDuration>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.newDuration = component.initialDuration;
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)2;
		}

		private void DisableCollision()
		{
			//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)
			if ((Object)(object)((EntityState)this).characterMotor != (Object)null)
			{
				_origLayer = ((EntityState)this).gameObject.layer;
				((EntityState)this).gameObject.layer = LayerIndex.GetAppropriateFakeLayerForTeam(((EntityState)this).teamComponent.teamIndex).intVal;
				((BaseCharacterController)((EntityState)this).characterMotor).Motor.RebuildCollidableLayers();
			}
		}

		private void EnableCollision()
		{
			if ((Object)(object)((EntityState)this).characterMotor != (Object)null)
			{
				((EntityState)this).gameObject.layer = _origLayer;
				((BaseCharacterController)((EntityState)this).characterMotor).Motor.RebuildCollidableLayers();
			}
		}
	}
}
namespace EnemyAbilities.Abilities.IronHauler
{
	[EnemyAbilities.ModuleInfo("Tractor Beam & Fling", "Gives Solus Transporters a pair of new utility abilities:\n- Tractor Beam: The Transporter picks up and manoeuvres a unit that is valid for cargo.\n- Fling: Toss it's cargo at it's target. Deals impact damage based on the cargo's weight.", "Solus Transporter", true)]
	public class TractorBeamModule : BaseModule
	{
		private static GameObject bodyPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC3_IronHauler.IronHaulerBody_prefab).WaitForCompletion();

		private static GameObject masterPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC3_IronHauler.IronHaulerMaster_prefab).WaitForCompletion();

		public static SkillDef tractorBeamSkillDef;

		public static SkillDef flingSkillDef;

		public static BuffDef cargoBuffDef;

		public static float maxCargoChaseDistance = 125f;

		public static GameObject tetherPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_moon2.BloodSiphonTetherVFX_prefab).WaitForCompletion(), "tractorBeamTetherVFX");

		public static Sprite buffIcon = Addressables.LoadAssetAsync<Sprite>((object)RoR2_DLC2.texBuffDisableAllSkillsIcon_png).WaitForCompletion();

		public static GameObject tractorBeamVFX = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC3_IronHauler.IronHaulerAirLaunchProjectileGhost_prefab).WaitForCompletion();

		public static GameObject gravityWellProjectile = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC3_IronHauler.IronHaulerGravityWellProjectile_prefab).WaitForCompletion();

		private static Material laserMaterial = Addressables.LoadAssetAsync<Material>((object)RoR2_DLC1_MajorAndMinorConstruct.matMajorConstructBeam_mat).WaitForCompletion();

		public static GameObject sphereVFX;

		public override void Awake()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			base.Awake();
			bodyPrefab.AddComponent<IronHaulerDriverController>();
			CreateSkills();
			CreateBuffDef();
			((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)ModifyTransporter);
			EntityStateMachine.SetState += new hook_SetState(DropCargoOnStun);
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(AddArmor);
			SetupTetherPrefab();
			Transform[] componentsInChildren = gravityWellProjectile.GetComponentsInChildren<Transform>();
			if (componentsInChildren.Length != 0)
			{
				Transform val = componentsInChildren.Where((Transform t) => ((Object)t).name == "Sphere").FirstOrDefault();
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null)
				{
					GameObject val2 = PrefabAPI.InstantiateClone(((Component)val).gameObject, "Clone");
					sphereVFX = val2;
				}
			}
			if ((Object)(object)sphereVFX != (Object)null)
			{
				MeshRenderer component = sphereVFX.GetComponent<MeshRenderer>();
				MeshFilter component2 = sphereVFX.GetComponent<MeshFilter>();
			}
		}

		private void AddArmor(CharacterBody sender, StatHookEventArgs args)
		{
			if (!((Object)(object)sender == (Object)null) && sender.HasBuff(cargoBuffDef))
			{
				args.armorAdd += 30f;
			}
		}

		private void DropCargoOnStun(orig_SetState orig, EntityStateMachine entityStateMachine, EntityState entityState)
		{
			orig.Invoke(entityStateMachine, entityState);
			if (entityState == null || (!(entityState is FrozenState) && !(entityState is StunState)))
			{
				return;
			}
			CharacterBody characterBody = entityStateMachine.commonComponents.characterBody;
			if ((Object)(object)characterBody != (Object)null)
			{
				IronHaulerDriverController component = ((Component)characterBody).gameObject.GetComponent<IronHaulerDriverController>();
				if ((Object)(object)component != (Object)null && component.hasCargo)
				{
					component.DetachCargo();
				}
			}
		}

		private void ModifyTransporter()
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			BodyIndex val = BodyCatalog.FindBodyIndexCaseInsensitive("IronHaulerBody");
			CharacterBody bodyPrefabBodyComponent = BodyCatalog.GetBodyPrefabBodyComponent(val);
			bodyPrefabBodyComponent.baseMoveSpeed *= 1.5f;
			bodyPrefabBodyComponent.baseAcceleration = bodyPrefabBodyComponent.baseMoveSpeed * 6f;
		}

		public void CreateSkills()
		{
			//IL_0040: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: 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_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			tractorBeamSkillDef = ScriptableObject.CreateInstance<SkillDef>();
			((Object)tractorBeamSkillDef).name = "IronHaulerBodyTractorBeam";
			tractorBeamSkillDef.skillName = "IronHaulerTractorBeam";
			tractorBeamSkillDef.activationStateMachineName = "Weapon";
			bool flag = default(bool);
			tractorBeamSkillDef.activationState = ContentAddition.AddEntityState<TractorBeam>(ref flag);
			tractorBeamSkillDef.baseRechargeInterval = 10f;
			tractorBeamSkillDef.cancelSprintingOnActivation = true;
			tractorBeamSkillDef.isCombatSkill = true;
			tractorBeamSkillDef.beginSkillCooldownOnSkillEnd = false;
			ContentAddition.AddSkillDef(tractorBeamSkillDef);
			flingSkillDef = ScriptableObject.CreateInstance<SkillDef>();
			((Object)flingSkillDef).name = "IronHaulerBodyFling";
			flingSkillDef.skillName = "IronHaulerFling";
			flingSkillDef.activationStateMachineName = "Weapon";
			flingSkillDef.activationState = ContentAddition.AddEntityState<Fling>(ref flag);
			flingSkillDef.baseRechargeInterval = 1f;
			flingSkillDef.cancelSprintingOnActivation = true;
			flingSkillDef.isCombatSkill = true;
			ContentAddition.AddSkillDef(flingSkillDef);
			SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val).name = "IronHaulerUtilityFamily";
			val.variants = (Variant[])(object)new Variant[1]
			{
				new Variant
				{
					skillDef = tractorBeamSkillDef
				}
			};
			GenericSkill val2 = bodyPrefab.AddComponent<GenericSkill>();
			val2.skillName = "IronHaulerTractorBeam";
			val2._skillFamily = val;
			SkillLocator component = bodyPrefab.GetComponent<SkillLocator>();
			component.utility = val2;
			ContentAddition.AddSkillFamily(val);
			AISkillDriver[] components = masterPrefab.GetComponents<AISkillDriver>();
			AISkillDriver[] array = components;
			foreach (AISkillDriver val3 in array)
			{
				val3.moveInputScale = 1f;
			}
			AISkillDriver val4 = masterPrefab.AddComponent<AISkillDriver>();
			val4.customName = "fleeWithCargo";
			val4.skillSlot = (SkillSlot)(-1);
			val4.minDistance = 0f;
			val4.maxDistance = 40f;
			val4.moveTargetType = (TargetType)3;
			val4.selectionRequiresTargetLoS = false;
			val4.movementType = (MovementType)3;
			val4.moveInputScale = 1f;
			masterPrefab.ReorderSkillDrivers(val4, 0);
			AISkillDriver val5 = masterPrefab.AddComponent<AISkillDriver>();
			val5.customName = "strafeWithCargo";
			val5.skillSlot = (SkillSlot)2;
			val5.requiredSkill = flingSkillDef;
			val5.minDistance = 0f;
			val5.maxDistance = 60f;
			val5.moveTargetType = (TargetType)3;
			val5.activationRequiresAimTargetLoS = true;
			val5.selectionRequiresTargetLoS = false;
			val5.movementType = (MovementType)2;
			val5.moveInputScale = 0.75f;
			masterPrefab.ReorderSkillDrivers(val5, 1);
			AISkillDriver val6 = masterPrefab.AddComponent<AISkillDriver>();
			val6.customName = "chaseWithCargo";
			val6.skillSlot = (SkillSlot)2;
			val6.requiredSkill = flingSkillDef;
			val6.minDistance = 0f;
			val6.maxDistance = 150f;
			val6.moveTargetType = (TargetType)3;
			val6.activationRequiresAimTargetLoS = true;
			val6.selectionRequiresTargetLoS = false;
			val6.movementType = (MovementType)1;
			val6.moveInputScale = 0.75f;
			masterPrefab.ReorderSkillDrivers(val6, 2);
			AISkillDriver val7 = masterPrefab.AddComponent<AISkillDriver>();
			val7.customName = "chaseWithCargoFar";
			val7.skillSlot = (SkillSlot)(-1);
			val7.minDistance = 0f;
			val7.maxDistance = float.PositiveInfinity;
			val7.moveTargetType = (TargetType)3;
			val7.selectionRequiresTargetLoS = false;
			val7.movementType = (MovementType)1;
			val7.moveInputScale = 0.75f;
			masterPrefab.ReorderSkillDrivers(val7, 3);
			AISkillDriver val8 = masterPrefab.AddComponent<AISkillDriver>();
			val8.customName = "useUtilityOnCargoTarget";
			val8.skillSlot = (SkillSlot)2;
			val8.requiredSkill = tractorBeamSkillDef;
			val8.requireSkillReady = true;
			val8.minDistance = 0f;
			val8.maxDistance = 40f;
			val8.moveTargetType = (TargetType)3;
			val8.selectionRequiresTargetLoS = false;
			val8.activationRequiresAimTargetLoS = true;
			val8.movementType = (MovementType)2;
			val8.moveInputScale = 1f;
			masterPrefab.ReorderSkillDrivers(val8, 4);
			AISkillDriver val9 = masterPrefab.AddComponent<AISkillDriver>();
			val9.customName = "chaseCargoTarget";
			val9.skillSlot = (SkillSlot)(-1);
			val9.minDistance = 0f;
			val9.maxDistance = maxCargoChaseDistance;
			val9.moveTargetType = (TargetType)3;
			val9.activationRequiresTargetLoS = false;
			val9.movementType = (MovementType)1;
			val9.moveInputScale = 1f;
			masterPrefab.ReorderSkillDrivers(val9, 5);
		}

		public void CreateBuffDef()
		{
			cargoBuffDef = ScriptableObject.CreateInstance<BuffDef>();
			((Object)cargoBuffDef).name = "CargoBuff";
			cargoBuffDef.isDebuff = true;
			cargoBuffDef.canStack = false;
			cargoBuffDef.iconSprite = buffIcon;
			cargoBuffDef.isHidden = false;
			ContentAddition.AddBuffDef(cargoBuffDef);
		}

		public void SetupTetherPrefab()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			LineRenderer component = tetherPrefab.GetComponent<LineRenderer>();
			if ((Object)(object)component == (Object)null)
			{
				Log.Error("TractorBeamModule.SetupTetherPrefab failed - tetherPrefab has no LineRenderer!");
				return;
			}
			Material val = new Material(laserMaterial);
			val.mainTextureScale = Vector2.one;
			((Renderer)component).material = val;
		}

		public static bool TargetIsValidForCargoSelection(CharacterBody targetBody, CharacterBody haulerBody)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targetBody == (Object)null || (Object)(object)haulerBody == (Object)null)
			{
				return false;
			}
			if ((Object)(object)targetBody.healthComponent == (Object)null || !targetBody.healthComponent.alive)
			{
				return false;
			}
			if ((Object)(object)haulerBody.healthComponent == (Object)null || !haulerBody.healthComponent.alive)
			{
				return false;
			}
			Vector3 corePosition = targetBody.corePosition;
			Vector3 corePosition2 = haulerBody.corePosition;
			if (Vector3.Distance(corePosition2, corePosition) > maxCargoChaseDistance)
			{
				return false;
			}
			if (targetBody.isChampion)
			{
				return false;
			}
			if (targetBody.bodyIndex == BodyCatalog.FindBodyIndexCaseInsensitive("IronHaulerBody"))
			{
				return false;
			}
			if (targetBody.isPlayerControlled)
			{
				return false;
			}
			if ((Object)(object)targetBody.master == (Object)null)
			{
				return false;
			}
			if ((Object)(object)((Component)targetBody).gameObject.GetComponent<IronHaulerCargoController>() != (Object)null)
			{
				return false;
			}
			if ((Object)(object)targetBody.rigidbody == (Object)null && (Object)(object)targetBody.characterMotor == (Object)null)
			{
				return false;
			}
			if ((Object)(object)((Component)targetBody).GetComponent<SetStateOnHurt>() == (Object)null)
			{
				return false;
			}
			return true;
		}
	}
	public class TractorBeam : BaseSkillState
	{
		private IronHaulerDriverController driverController;

		private BaseAI ai;

		private float duration;

		public static float baseDuration = 0.5f;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			duration = baseDuration / ((BaseState)this).attackSpeedStat;
			if ((Object)(object)((EntityState)this).characterBody == (Object)null || (Object)(object)((Component)((EntityState)this).characterBody).gameObject == (Object)null || (Object)(object)((EntityState)this).characterBody.master == (Object)null)
			{
				return;
			}
			driverController = ((Component)((EntityState)this).characterBody).gameObject.GetComponent<IronHaulerDriverController>();
			if ((Object)(object)driverController == (Object)null)
			{
				return;
			}
			ai = ((Component)((EntityState)this).characterBody.master).GetComponent<BaseAI>();
			if (!((Object)(object)ai == (Object)null) && (ai.customTarget != null || !((Object)(object)ai.customTarget.characterBody == (Object)null)))
			{
				CharacterBody characterBody = ai.customTarget.characterBody;
				if (!TractorBeamModule.TargetIsValidForCargoSelection(characterBody, ((EntityState)this).characterBody))
				{
					RefundSkill();
					return;
				}
				IronHaulerCargoController ironHaulerCargoController = ((Component)characterBody).gameObject.AddComponent<IronHaulerCargoController>();
				ironHaulerCargoController.haulerBody = ((EntityState)this).characterBody;
				ironHaulerCargoController.haulerDriverController = driverController;
				driverController.cargoBody = characterBody;
				driverController.cargoController = ironHaulerCargoController;
				driverController.TryFindCustomTarget();
				((BaseSkillState)this).activatorSkillSlot.SetSkillOverride((object)((Component)((EntityState)this).characterBody).gameObject, TractorBeamModule.flingSkillDef, (SkillOverridePriority)3);
				((BaseSkillState)this).activatorSkillSlot.rechargeStopwatch = 0f;
				((BaseSkillState)this).activatorSkillSlot.RemoveAllStocks();
			}
		}

		public void ExitToMain()
		{
			((EntityState)this).outer.SetNextStateToMain();
		}

		public void RefundSkill()
		{
			((BaseSkillState)this).activatorSkillSlot.AddOneStock();
			((BaseSkillState)this).activatorSkillSlot.baseRechargeStopwatch = ((BaseSkillState)this).activatorSkillSlot._cooldownOverride;
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge > duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)2;
		}
	}
	public class Fling : BaseSkillState
	{
		private enum FlingState
		{
			None,
			LockOn,
			Windup,
			PostFling
		}

		private static float baseDuration = 6f;

		private float duration;

		private IronHaulerDriverController driverController;

		private IronHaulerCargoController cargoController;

		private CharacterBody cargoBody;

		private static float baseDamageCoefficient = 2f;

		private static float baseForce = 1500f;

		private static Vector3 bonusForce = new Vector3(0f, 1500f, 0f);

		private static float procCoefficient = 1f;

		private static float baseRadius = 12f;

		private static float lockOnDuration = 1f;

		private float lockOnTimer = 0f;

		private static float windupMaxDuration = 5f;

		private float windUpTimer = 0f;

		private static float spinDownDuration = 2f;

		private float spinDownTimer = 0f;

		private CharacterMaster master;

		private BaseAI ai;

		private CharacterBody targetBody;

		private QuaternionPID angularVelocityPID;

		private VectorPID torquePID;

		private VectorPID forcePID;

		private Vector3 savedTorquePID;

		private Vector3 savedAngularVelocityPID;

		private float savedAngularDrag;

		private float savedMaxAngularVelocity;

		private static float maxSpinAngularVelocity = 80f;

		private Vector3 flingVelocity;

		private bool cargoDetached;

		private Vector3 randomSpinDownDirection;

		private bool collidersDisabled;

		private FlingState flingState;

		public override void OnEnter()
		{
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			driverController = ((Component)((EntityState)this).characterBody).gameObject.GetComponent<IronHaulerDriverController>();
			cargoController = driverController.cargoController;
			cargoController.tractorBeamBonusDistance = 4f;
			cargoBody = cargoController.body;
			duration = baseDuration;
			lockOnTimer = 0f;
			master = ((EntityState)this).characterBody.master;
			driverController.TryFindCustomTarget();
			if ((Object)(object)master != (Object)null)
			{
				ai = ((Component)master).gameObject.GetComponent<BaseAI>();
				if ((Object)(object)ai != (Object)null && ai.customTarget != null && (Object)(object)ai.customTarget.characterBody != (Object)null)
				{
					targetBody = ai.customTarget.characterBody;
				}
				ai.aimVectorMaxSpeed = 180f;
			}
			angularVelocityPID = ((Component)((EntityState)this).characterBody).gameObject.GetComponent<QuaternionPID>();
			torquePID = (from pid in ((Component)((EntityState)this).characterBody).gameObject.GetComponents<VectorPID>()
				where pid.customName == "torquePID"
				select pid).FirstOrDefault();
			forcePID = (from pid in ((Component)((EntityState)this).characterBody).gameObject.GetComponents<VectorPID>()
				where pid.customName == "Force PID"
				select pid).FirstOrDefault();
			if ((Object)(object)torquePID != (Object)null)
			{
				savedTorquePID = torquePID.PID;
				torquePID.PID = new Vector3(8f, 0f, 0f);
				torquePID.gain = 1f;
				torquePID.ResetPID();
			}
			if ((Object)(object)angularVelocityPID != (Object)null)
			{
				savedAngularVelocityPID = angularVelocityPID.PID;
				angularVelocityPID.PID = new Vector3(80f, 0f, 4f);
				angularVelocityPID.ResetPID();
			}
			if ((Object)(object)((EntityState)this).rigidbody != (Object)null)
			{
				savedAngularDrag = ((EntityState)this).rigidbody.angularDrag;
				savedMaxAngularVelocity = ((EntityState)this).rigidbody.maxAngularVelocity;
			}
			flingState = FlingState.LockOn;
			SetColliders(enable: false);
		}

		private void SetColliders(bool enable)
		{
			Collider[] components = ((Component)((EntityState)this).characterBody).gameObject.GetComponents<Collider>();
			foreach (Collider val in components)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.enabled = enable;
					if (collidersDisabled == !enable)
					{
						collidersDisabled = enable;
					}
				}
			}
		}

		public override void OnExit()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).OnExit();
			if (collidersDisabled)
			{
				SetColliders(enable: true);
			}
			if ((Object)(object)cargoController != (Object)null)
			{
				cargoController.inWindupState = false;
				cargoController.tractorBeamBonusDistance = 11f;
			}
			if ((Object)(object)torquePID != (Object)null)
			{
				torquePID.PID = savedTorquePID;
				torquePID.gain = 3f;
				((Behaviour)torquePID).enabled = true;
				torquePID.ResetPID();
			}
			if ((Object)(object)angularVelocityPID != (Object)null)
			{
				angularVelocityPID.PID = savedAngularVelocityPID;
				angularVelocityPID.ResetPID();
			}
			if ((Object)(object)((EntityState)this).rigidbody != (Object)null)
			{
				((EntityState)this).rigidbody.maxAngularVelocity = savedMaxAngularVelocity;
				((EntityState)this).rigidbody.angularDrag = savedAngularDrag;
			}
			ai.aimVectorMaxSpeed = 60f;
		}

		public override void FixedUpdate()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: 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_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Expected O, but got Unknown
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: 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_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).FixedUpdate();
			if ((Object)(object)targetBody == (Object)null || (Object)(object)targetBody.healthComponent == (Object)null || !targetBody.healthComponent.alive)
			{
				((EntityState)this).outer.SetNextStateToMain();
				return;
			}
			if (flingState == FlingState.LockOn)
			{
				if ((Object)(object)((EntityState)this).rigidbody != (Object)null)
				{
					((EntityState)this).rigidbody.velocity = Vector3.zero;
				}
				lockOnTimer += Time.fixedDeltaTime;
				if (lockOnTimer >= lockOnDuration)
				{
					((Behaviour)torquePID).enabled = false;
					((EntityState)this).rigidbody.angularVelocity = Vector3.zero;
					((EntityState)this).rigidbody.angularDrag = 0f;
					((EntityState)this).rigidbody.maxAngularVelocity = maxSpinAngularVelocity / cargoController.hullRadius + 4f;
					ai.aimVectorMaxSpeed = 180f;
					flingState = FlingState.Windup;
					cargoController.inWindupState = true;
				}
			}
			if (flingState == FlingState.Windup)
			{
				if (windUpTimer > windupMaxDuration)
				{
					((EntityState)this).outer.SetNextStateToMain();
				}
				if ((Object)(object)((EntityState)this).rigidbody != (Object)null)
				{
					((EntityState)this).rigidbody.velocity = Vector3.zero;
				}
				windUpTimer += Time.fixedDeltaTime;
				Vector3 right = ((EntityState)this).characterBody.transform.right;
				float num = 0.2f;
				Vector3 val = cargoBody.transform.position - ((EntityState)this).characterBody.transform.position;
				Vector3 currentVelocity = Vector3.Cross(((EntityState)this).rigidbody.angularVelocity, val);
				Vector3 val2 = FindRequiredLaunchVelocity(currentVelocity);
				float num2 = Vector3.Dot(((Vector3)(ref currentVelocity)).normalized, ((Vector3)(ref val2)).normalized);
				if (num2 > 0.95f)
				{
					flingVelocity = val2;
					flingState = FlingState.PostFling;
					cargoController.PrepareForFling(flingVelocity);
					randomSpinDownDirection = Random.insideUnitSphere;
				}
				if (((Vector3)(ref val2)).magnitude > ((Vector3)(ref currentVelocity)).magnitude && flingState == FlingState.Windup)
				{
					Rigidbody rigidbody = ((EntityState)this).rigidbody;
					rigidbody.angularVelocity += right * num;
				}
			}
			if (flingState == FlingState.PostFling && !cargoDetached)
			{
				torquePID.PID = new Vector3(0.25f, 0f, 0f);
				((Behaviour)torquePID).enabled = true;
				torquePID.ResetPID();
				cargoDetached = true;
				float num3 = 0f;
				if ((Object)(object)cargoBody.rigidbody != (Object)null)
				{
					num3 = cargoBody.rigidbody.mass;
				}
				if ((Object)(object)cargoBody.characterMotor != (Object)null)
				{
					num3 = cargoBody.characterMotor.mass;
				}
				BlastAttack val3 = new BlastAttack();
				val3.attacker = ((Component)((EntityState)this).characterBody).gameObject;
				val3.attackerFiltering = (AttackerFiltering)2;
				val3.baseDamage = ((BaseState)this).damageStat * (baseDamageCoefficient + num3 / 200f);
				val3.baseForce = baseForce + num3 * 3f;
				val3.bonusForce = bonusForce + new Vector3(0f, num3 * 1.5f, 0f);
				val3.crit = ((BaseState)this).RollCrit();
				val3.damageColorIndex = (DamageColorIndex)0;
				val3.damageType = DamageTypeCombo.Generic;
				val3.falloffModel = (FalloffModel)2;
				val3.inflictor = ((Component)((EntityState)this).characterBody).gameObject;
				val3.procCoefficient = procCoefficient;
				val3.radius = baseRadius + num3 / 50f;
				val3.teamIndex = ((EntityState)this).characterBody.teamComponent.teamIndex;
				cargoController.blastAttack = val3;
				((EntityState)this).skillLocator.primary.rechargeStopwatch = ((EntityState)this).skillLocator.primary.cooldownOverride - 3f;
				driverController.DetachCargo();
				if (collidersDisabled)
				{
					SetColliders(enable: true);
				}
			}
			if (flingState == FlingState.PostFling)
			{
				spinDownTimer += Time.fixedDeltaTime;
				Rigidbody rigidbody2 = ((EntityState)this).rigidbody;
				rigidbody2.angularVelocity += randomSpinDownDirection * 0.2f;
				if (spinDownTimer > spinDownDuration)
				{
					((EntityState)this).outer.SetNextStateToMain();
				}
			}
		}

		private Vector3 FindRequiredLaunchVelocity(Vector3 currentVelocity)
		{
			//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_0012: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			Vector3 gravity = Physics.gravity;
			Vector3 position = cargoBody.transform.position;
			Vector3 footPosition = ai.customTarget.characterBody.footPosition;
			float num = 3f;
			Vector3 val = (footPosition - position) / num;
			Vector3 val2 = 0.5f * gravity * num;
			return val - val2;
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)5;
		}
	}
	public class IronHaulerCargoController : MonoBehaviour
	{
		public class OriginalBehaviours
		{
			public bool HasCharMotor;

			public bool HasRigidBody;

			public bool HasRigidBodyMotor;

			public bool CharMotorGravity;

			public float CharMotorGravityScale;

			public bool RigidBodyGravity;

			public bool IgnoreFallDamage;

			public bool RespectImpactDamage;

			public bool HasPseudoMotor;

			public int GravityCount;

			public int FlightCount;

			public OriginalBehaviours(bool hasCharMotor = false, bool hasRigidBody = false, bool hasRigidBodyMotor = false, bool characterMotorGravity = false, float characterMotorGravityScale = 0f, bool rigidBodyGravity = false, bool ignoreFallDamage = false, bool respectImpactDamage = false, bool hasPseudoMotor = false, int gravityCount = 0, int flightCount = 0)
			{
				HasCharMotor = hasCharMotor;
				HasRigidBody = hasRigidBody;
				HasRigidBodyMotor = hasRigidBodyMotor;
				CharMotorGravity = characterMotorGravity;
				CharMotorGravityScale = characterMotorGravityScale;
				RigidBodyGravity = rigidBodyGravity;
				IgnoreFallDamage = ignoreFallDamage;
				RespectImpactDamage = respectImpactDamage;
				HasPseudoMotor = hasPseudoMotor;
				GravityCount = gravityCount;
				FlightCount = flightCount;
			}
		}

		public CharacterBody haulerBody;

		public IronHaulerDriverController haulerDriverController;

		public CharacterBody body;

		private int fixedUpdatesWithoutHauler;

		private int maxFixedUpdatesWithoutHauler = 1;

		public static float baseTractorBeamBonusDistance = 11f;

		public float tractorBeamBonusDistance;

		private float pullStrength;

		private float stopwatch;

		public OriginalBehaviours originalBehaviours;

		private Rigidbody rigid;

		private RigidbodyMotor rigidMotor;

		private CharacterMotor motor;

		private SetStateOnHurt stateOnHurt;

		private PseudoCharacterMotor pseudoMotor;

		private bool origBehavioursRecorded;

		private float stunRefreshTimer;

		private static float stunRefreshDuration = 0.25f;

		private bool tempCanBeStunned;

		public float hullRadius;

		private ChildMonsterController childMonsterController;

		public bool inWindupState = false;

		public bool readyToFling = false;

		private Vector3 flingVelocity;

		public bool flung = false;

		private VectorPID forcePID;

		public BlastAttack blastAttack;

		private float drag;

		private static GameObject explosionPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Loader.LoaderGroundSlam_prefab).WaitForCompletion();

		private int _origLayer;

		private GameObject sphereVFXInstance;

		private static float delayBeforeRestoring = 0.2f;

		private float delayTimer = 0f;

		public bool restore = false;

		private bool firedBlast = false;

		public void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected I4, but got Unknown
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			body = ((Component)this).GetComponent<CharacterBody>();
			body.SetBuffCount(TractorBeamModule.cargoBuffDef.buffIndex, 1);
			motor = ((Component)this).GetComponent<CharacterMotor>();
			rigid = ((Component)this).GetComponent<Rigidbody>();
			rigidMotor = ((Component)this).GetComponent<RigidbodyMotor>();
			stateOnHurt = ((Component)this).GetComponent<SetStateOnHurt>();
			pseudoMotor = ((Component)this).GetComponent<PseudoCharacterMotor>();
			childMonsterController = ((Component)this).GetComponent<ChildM