Decompiled source of BadAssEngi v1.3.9

BadAssEngi/BadAssEngi.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 BadAssEngi.Animations;
using BadAssEngi.Assets;
using BadAssEngi.Assets.SeekerMissileScripts;
using BadAssEngi.Assets.Sound;
using BadAssEngi.AssetsScripts;
using BadAssEngi.Networking;
using BadAssEngi.Skills;
using BadAssEngi.Skills.Primary.SeekerMissile;
using BadAssEngi.Skills.Primary.States;
using BadAssEngi.Skills.Secondary.ClusterMine;
using BadAssEngi.Skills.Secondary.ClusterMine.EngiStates;
using BadAssEngi.Skills.Secondary.ClusterMine.MineStates.ArmingStateMachine;
using BadAssEngi.Skills.Secondary.ClusterMine.MineStates.MainStateMachine;
using BadAssEngi.Skills.Secondary.OrbitalStrike;
using BadAssEngi.Skills.Secondary.OrbitalStrike.EngiStates;
using BadAssEngi.Skills.Secondary.OrbitalStrike.MineState.ArmingStateMachine;
using BadAssEngi.Skills.Secondary.OrbitalStrike.MineState.MainStateMachine;
using BadAssEngi.Skills.Secondary.SatchelMine.EngiStates;
using BadAssEngi.Skills.Secondary.SatchelMine.MineStates.ArmingStateMachine;
using BadAssEngi.Skills.Secondary.SatchelMine.MineStates.MainStateMachine;
using BadAssEngi.Skills.Special;
using BadAssEngi.Skills.Special.ShotgunTurret;
using BadAssEngi.Util;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Engi.EngiWeapon;
using EntityStates.Engi.Mine;
using EntityStates.EngiTurret.EngiTurretWeapon;
using EntityStates.Toolbot;
using IL.EntityStates.EngiTurret.EngiTurretWeapon;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.EntityStates.Engi.EngiWeapon;
using On.EntityStates.EngiTurret.EngiTurretWeapon;
using On.RoR2;
using On.RoR2.Orbs;
using On.RoR2.Projectile;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using Rewired;
using RoR2;
using RoR2.CameraModes;
using RoR2.CharacterAI;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BadAssEngi")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a59c321834349fd680e57555917165824321341e")]
[assembly: AssemblyProduct("BadAssEngi")]
[assembly: AssemblyTitle("BadAssEngi")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace BadAssEngi
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("iDeathHD.BadAssEngi", "BadAssEngi", "1.3.9")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class BadAssEngi : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__ChangeEngiColorAndAddMissileTrackerOnRespawn;

			public static Manipulator <1>__BlastAttackMultiplySelfMineDamage;

			public static Action <2>__RetrieveFirstGamePad;

			public static Manipulator <3>__ExpendMaxMinesCount;

			public static Func<BlastAttack, BlastAttackDamageInfo, HurtBox, BlastAttackDamageInfo> <4>__ScaleMineDamageDelegate;
		}

		public const string ModGuid = "iDeathHD.BadAssEngi";

		private const string ModName = "BadAssEngi";

		private const string ModVer = "1.3.9";

		internal static BodyIndex EngiBodyIndex;

		private const string EngiBodyPrefabName = "EngiBody";

		internal static Texture2D OrigEngiTexture;

		internal static Texture2D OrigAltEngiTexture;

		internal static Texture2D OrigTurretTexture;

		internal static BadAssEngi Instance { get; private set; }

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			Configuration.Init(((BaseUnityPlugin)this).Config);
			BaeAssets.Init();
			SoundHelper.AddSoundBank();
			InitBadAssEngi();
			InitNetworking();
			InitHooks();
			Instance = this;
		}

		public void Update()
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && !Application.isBatchMode)
			{
				KeybindController.Update();
			}
		}

		private static void InitNetworking()
		{
			NetworkingAPI.RegisterMessageType<AnimMsg>();
			NetworkingAPI.RegisterMessageType<DetonateMsg>();
			NetworkingAPI.RegisterMessageType<EngiColorMsg>();
			NetworkingAPI.RegisterMessageType<PlaySoundMsg>();
			NetworkingAPI.RegisterMessageType<PlaySoundAndDestroyMsg>();
			NetworkingAPI.RegisterMessageType<TurretHooks.SendRecalcStat>();
			NetworkingAPI.RegisterMessageType<StopAnimMsg>();
			NetworkingAPI.RegisterMessageType<StopSoundMsg>();
			NetworkingAPI.RegisterMessageType<TurretColorDelayedMsgToServer>();
			NetworkingAPI.RegisterMessageType<TurretColorMsg>();
			NetworkingAPI.RegisterMessageType<TurretTypeMsgToServer>();
		}

		private static void InitHooks()
		{
			//IL_0048: 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_0053: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			CommandHelper.AddToConsoleWhenReady();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				EngiBodyIndex = BodyCatalog.FindBodyIndex("EngiBody");
			});
			object obj = <>O.<0>__ChangeEngiColorAndAddMissileTrackerOnRespawn;
			if (obj == null)
			{
				Manipulator val = ChangeEngiColorAndAddMissileTrackerOnRespawn;
				<>O.<0>__ChangeEngiColorAndAddMissileTrackerOnRespawn = val;
				obj = (object)val;
			}
			Stage.RespawnLocalPlayers += (Manipulator)obj;
			object obj2 = <>O.<1>__BlastAttackMultiplySelfMineDamage;
			if (obj2 == null)
			{
				Manipulator val2 = BlastAttackMultiplySelfMineDamage;
				<>O.<1>__BlastAttackMultiplySelfMineDamage = val2;
				obj2 = (object)val2;
			}
			BlastAttack.HandleHits += (Manipulator)obj2;
			ModCompatibilities();
			EmotesHooks.Init();
			OrbitalHooks.Init();
			TurretHooks.Init();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(KeybindController.RetrieveFirstGamePad));
		}

		private static void ModCompatibilities()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			bool flag = false;
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				if (pluginInfo.Value.Metadata.GUID.Equals("at.aster.charactercustomizer"))
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				object obj = <>O.<3>__ExpendMaxMinesCount;
				if (obj == null)
				{
					Manipulator val = ExpendMaxMinesCount;
					<>O.<3>__ExpendMaxMinesCount = val;
					obj = (object)val;
				}
				CharacterMaster.GetDeployableSameSlotLimit += (Manipulator)obj;
			}
		}

		private static void InitBadAssEngi()
		{
			SkillLoader.Init();
			BadAssTurret.Buffs = (from buff in Configuration.SharedBuffsWithTurret.Value.Split(',')
				select (BuffIndex)int.Parse(buff)).ToArray();
		}

		private static void ChangeEngiColorAndAddMissileTrackerOnRespawn(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			int num = default(int);
			val.GotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdloc(i, ref num),
				(Instruction i) => ILPatternMatchingExt.MatchLdstr(i, ""),
				(Instruction i) => ILPatternMatchingExt.MatchCallvirt<CharacterMaster>(i, "CallCmdRespawn")
			});
			int index = val.Index;
			val.Index = index + 1;
			val.EmitDelegate<Action>((Action)delegate
			{
				((MonoBehaviour)Instance).StartCoroutine(DelayedEngiColorChangeAndUpdateGrenadeType(1f));
			});
		}

		private static void BlastAttackMultiplySelfMineDamage(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int damageInfoLoc = 0;
			int targetLoc = 0;
			val.GotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdfld<HitPoint>(i, "hurtBox"),
				(Instruction i) => ILPatternMatchingExt.MatchLdfld<HurtBox>(i, "healthComponent"),
				(Instruction i) => ILPatternMatchingExt.MatchStloc(i, ref targetLoc)
			});
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchInitobj(i, "RoR2.BlastAttack/BlastAttackDamageInfo")
			});
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchStloc(i, ref damageInfoLoc)
			});
			int index = val.Index;
			val.Index = index + 1;
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Ldloc, damageInfoLoc);
			val.Emit(OpCodes.Ldloc, targetLoc);
			val.EmitDelegate<Func<BlastAttack, BlastAttackDamageInfo, HurtBox, BlastAttackDamageInfo>>((Func<BlastAttack, BlastAttackDamageInfo, HurtBox, BlastAttackDamageInfo>)ScaleMineDamageDelegate);
			val.Emit(OpCodes.Stloc, damageInfoLoc);
		}

		private static BlastAttackDamageInfo ScaleMineDamageDelegate(BlastAttack blastAttack, BlastAttackDamageInfo blastAttackDamageInfo, HurtBox target)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if ((int)blastAttack.attackerFiltering == 1 && (Object)(object)((Component)target).gameObject == (Object)(object)blastAttackDamageInfo.attacker && ((Object)blastAttack.inflictor).name.Contains("Mine"))
			{
				if (Object.op_Implicit((Object)(object)blastAttack.inflictor.GetComponent<RecursiveMine>()))
				{
					blastAttackDamageInfo.damage *= 2f;
				}
				else
				{
					blastAttackDamageInfo.damage *= 0.05f;
				}
			}
			return blastAttackDamageInfo;
		}

		private static void ExpendMaxMinesCount(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdcI4(i, 4),
				(Instruction i) => ILPatternMatchingExt.MatchStloc(i, 0)
			});
			val.Next.OpCode = OpCodes.Ldc_I4;
			val.Next.Operand = 10000;
			val.GotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdarg(i, 0),
				(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterMaster>(i, "get_bodyInstanceObject"),
				(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt<GameObject>(i, "GetComponent")
			});
			val.RemoveRange(5);
			val.Emit(OpCodes.Ldc_I4, 10000);
		}

		private static IEnumerator DelayedEngiColorChangeAndUpdateGrenadeType(float seconds)
		{
			yield return (object)new WaitForSeconds(seconds);
			foreach (NetworkUser readOnlyLocalPlayers in NetworkUser.readOnlyLocalPlayersList)
			{
				CharacterMaster master = readOnlyLocalPlayers.master;
				if (Object.op_Implicit((Object)(object)master))
				{
					CharacterBody body = master.GetBody();
					if (Object.op_Implicit((Object)(object)body))
					{
						BodyIndex bodyIndex = body.bodyIndex;
						if (bodyIndex != EngiBodyIndex)
						{
							continue;
						}
						uint skillVariant = readOnlyLocalPlayers.master.loadout.bodyLoadoutManager.GetSkillVariant(bodyIndex, 0);
						if (skillVariant == SkillLoader.SeekerSwarmSkillVariant)
						{
							if (!Object.op_Implicit((Object)(object)((Component)body).GetComponent<MissileTracker>()))
							{
								((Component)body).gameObject.AddComponent<MissileTracker>();
							}
						}
						else if (skillVariant == 0 || skillVariant == SkillLoader.SwappableGrenadeSkillVariant)
						{
							MissileTracker component = ((Component)body).GetComponent<MissileTracker>();
							if (Object.op_Implicit((Object)(object)component))
							{
								Object.Destroy((Object)(object)component);
							}
						}
						EngiColorMsg engiColorMsg = default(EngiColorMsg);
						engiColorMsg.NetId = ((Component)body).GetComponent<NetworkIdentity>().netId;
						EngiColorMsg engiColorMsg2 = engiColorMsg;
						if (Configuration.CustomEngiColor.Value)
						{
							string[] array = Configuration.EngiColor.Value.Split(',');
							engiColorMsg2.Color = new Color(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]));
						}
						else
						{
							engiColorMsg2.Color = new Color(-1f, -1f, -1f);
						}
						NetMessageExtensions.Send((INetMessage)(object)engiColorMsg2, (NetworkDestination)1);
					}
					else
					{
						((MonoBehaviour)Instance).StartCoroutine(DelayedEngiColorChangeAndUpdateGrenadeType(1f));
					}
				}
				else
				{
					((MonoBehaviour)Instance).StartCoroutine(DelayedEngiColorChangeAndUpdateGrenadeType(1f));
				}
			}
		}
	}
	internal static class Configuration
	{
		private static ConfigFile _file;

		internal static IControllerTemplateDPad DPad;

		private const string BaeEmoteVolumeUsage = "Change the music volume of the emotes. Exemple Usage : bae_emote_volume 100 (range is 0-100)";

		internal static ConfigEntry<string> TurretTypeKeyBind { get; private set; }

		internal static ConfigEntry<string> GrenadeTypeKeyBind { get; private set; }

		internal static ConfigEntry<string> MineTypeKeyBind { get; private set; }

		internal static ConfigEntry<string> SatchelManualDetonateKeyBind { get; private set; }

		internal static ConfigEntry<string> EngiColor { get; private set; }

		internal static ConfigEntry<string> TurretColor { get; private set; }

		internal static ConfigEntry<string> TrackerIndicatorColor { get; private set; }

		internal static ConfigEntry<string> ClusterMineColor { get; private set; }

		internal static ConfigEntry<bool> CustomEngiColor { get; private set; }

		internal static ConfigEntry<bool> CustomTurretColor { get; private set; }

		internal static ConfigEntry<bool> CustomTrackerIndicatorColor { get; private set; }

		internal static ConfigEntry<bool> CustomClusterMineColor { get; private set; }

		internal static ConfigEntry<string> SharedBuffsWithTurret { get; private set; }

		internal static ConfigEntry<float> DefaultTurretDamageCoefficient { get; private set; }

		internal static ConfigEntry<float> DefaultTurretAttackSpeed { get; private set; }

		internal static ConfigEntry<float> DefaultTurretDamagePerLevel { get; private set; }

		internal static ConfigEntry<float> DefaultTurretMaxDistanceTargeting { get; private set; }

		internal static ConfigEntry<float> MinigunTurretDamageCoefficient { get; private set; }

		internal static ConfigEntry<float> MinigunTurretAttackSpeed { get; private set; }

		internal static ConfigEntry<float> MinigunTurretDamagePerLevel { get; private set; }

		internal static ConfigEntry<float> MinigunTurretMaxDistanceTargeting { get; private set; }

		internal static ConfigEntry<float> MinigunTurretProcCoefficient { get; private set; }

		internal static ConfigEntry<float> RailgunTurretDamageCoefficient { get; private set; }

		internal static ConfigEntry<float> RailgunTurretAttackSpeed { get; private set; }

		internal static ConfigEntry<float> RailgunTurretDamagePerLevel { get; private set; }

		internal static ConfigEntry<float> RailgunTurretMaxDistanceTargeting { get; private set; }

		internal static ConfigEntry<float> ShotgunTurretDamageCoefficient { get; private set; }

		internal static ConfigEntry<float> ShotgunTurretAttackSpeed { get; private set; }

		internal static ConfigEntry<float> ShotgunTurretDamagePerLevel { get; private set; }

		internal static ConfigEntry<float> ShotgunTurretMaxDistanceTargeting { get; private set; }

		internal static ConfigEntry<int> ShotgunTurretBaseProjectileNumber { get; private set; }

		internal static ConfigEntry<float> ShotgunTurretSpreadCoefficient { get; private set; }

		internal static ConfigEntry<float> SeekerMissileDamageCoefficient { get; private set; }

		internal static ConfigEntry<int> SeekerMissileMaxProjectileNumber { get; private set; }

		internal static ConfigEntry<float> ClusterMineDamageCoefficient { get; private set; }

		internal static ConfigEntry<int> ClusterMineBaseMaxStock { get; private set; }

		internal static ConfigEntry<float> ClusterMineCooldown { get; private set; }

		internal static ConfigEntry<bool> ClusterMineVisualBouncing { get; private set; }

		internal static ConfigEntry<float> SatchelMineDamageCoefficient { get; private set; }

		internal static ConfigEntry<float> SatchelMineForce { get; private set; }

		internal static ConfigEntry<float> OrbitalStrikeBaseDamage { get; private set; }

		internal static ConfigEntry<float> OrbitalStrikeCooldown { get; private set; }

		internal static ConfigEntry<int> OrbitalStrikeRequiredStock { get; private set; }

		internal static ConfigEntry<Vector3> EmoteWindowPosition { get; private set; }

		internal static ConfigEntry<Vector3> EmoteWindowSize { get; private set; }

		internal static ConfigEntry<int> EmoteButtonUIPosX { get; private set; }

		internal static ConfigEntry<int> EmoteButtonUIPosY { get; private set; }

		internal static ConfigEntry<float> EmoteVolume { get; private set; }

		internal static void Init(ConfigFile file)
		{
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_065f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			_file = file;
			TurretTypeKeyBind = _file.Bind<string>("Keybinds", "TurretType", "f1", "What keybind should be used for changing the type of turret. List of possible keybind at the end of this page : https://docs.unity3d.com/Manual/ConventionalGameInput.html");
			GrenadeTypeKeyBind = _file.Bind<string>("Keybinds", "GrenadeType", "f3", "What keybind should be used for changing the type of grenades.");
			MineTypeKeyBind = _file.Bind<string>("Keybinds", "MineType", "f4", "What keybind should be used for changing the type of mines.");
			SatchelManualDetonateKeyBind = _file.Bind<string>("Keybinds", "Satchel Manual Detonate", "c", "What keybind should be used for manually detonating satchel mines.");
			CustomEngiColor = _file.Bind<bool>("Colors", "Enable Custom Engi Color", false, "Should the Engi have his custom colors activated ?");
			CustomTurretColor = _file.Bind<bool>("Colors", "Enable Custom Turret Color", false, "Should the Engi's Turrets have its custom colors activated ?");
			CustomTrackerIndicatorColor = _file.Bind<bool>("Colors", "Enable Custom Missile Tracker Indicator Color", false, "Should the Missile Tracker Indicator have a custom color ?");
			CustomClusterMineColor = _file.Bind<bool>("Colors", "Enable Custom Cluster Mine Color", false, "Should the Cluster Mine have a custom color ?");
			string text = string.Join(",", new float[3] { 1f, 5f, 1f });
			EngiColor = _file.Bind<string>("Colors", "Engineer", text, "What color should the Engineer be. Example : 7.5 8 18.6");
			string text2 = string.Join(",", new float[3] { 0f, 80f, 0f });
			TurretColor = _file.Bind<string>("Colors", "Turret", text2, "What color should the Turrets be.");
			string text3 = string.Join(",", new float[3] { 0f, 80f, 0f });
			TrackerIndicatorColor = _file.Bind<string>("Colors", "Missile Tracker Indicator", text3, "What color should the missile tracker indicator be.");
			string text4 = string.Join(",", new float[3] { 2.1f, 0f, 0f });
			ClusterMineColor = _file.Bind<string>("Colors", "Cluster Mine", text4, "What color should the cluster mine effect be.");
			string text5 = string.Join(",", new int[9] { 10, 11, 17, 27, 28, 29, 30, 31, 33 });
			SharedBuffsWithTurret = _file.Bind<string>("Shared", "Buffs", text5, "What buffs should be shared between the Engineer and its turrets. https://pastebin.com/EsYMneGY");
			DefaultTurretDamageCoefficient = _file.Bind<float>("Default Turret", "Damage Coefficient", 0.7f, "What should be the damage coefficient for the Default Turret.");
			DefaultTurretAttackSpeed = _file.Bind<float>("Default Turret", "Attack Speed", 1f, "How much attack speed should the Default Turret have.");
			DefaultTurretDamagePerLevel = _file.Bind<float>("Default Turret", "Base Damage per Level", 3.8f, "How much base damage should the Default Turret get per level.");
			DefaultTurretMaxDistanceTargeting = _file.Bind<float>("Default Turret", "Max Distance Targeting", 60f, "How far should the Default Turret target monsters.");
			MinigunTurretDamageCoefficient = _file.Bind<float>("Minigun Turret", "Damage Coefficient", 0.134375f, "What should be the damage coefficient for the Minigun Turret.");
			MinigunTurretAttackSpeed = _file.Bind<float>("Minigun Turret", "Attack Speed", 6.9166f, "How much attack speed should the Minigun Turret have.");
			MinigunTurretDamagePerLevel = _file.Bind<float>("Minigun Turret", "Base Damage per Level", 3.8f, "How much base damage should the Minigun Turret get per level.");
			MinigunTurretMaxDistanceTargeting = _file.Bind<float>("Minigun Turret", "Max Distance Targeting", 50f, "How far should the Minigun Turret target monsters.");
			MinigunTurretProcCoefficient = _file.Bind<float>("Minigun Turret", "Proc Coefficient", 0.5f, "Defines how strong or frequent procs happen on an on-hit basis (0 to 1).");
			RailgunTurretDamageCoefficient = _file.Bind<float>("Railgun Turret", "Damage Coefficient", 7.25f, "What should be the damage coefficient for the Railgun Turret.");
			RailgunTurretAttackSpeed = _file.Bind<float>("Railgun Turret", "Attack Speed", 0.1f, "How much attack speed should the Railgun Turret have.");
			RailgunTurretDamagePerLevel = _file.Bind<float>("Railgun Turret", "Base Damage per Level", 3.8f, "How much base damage should the Railgun Turret get per level.");
			RailgunTurretMaxDistanceTargeting = _file.Bind<float>("Railgun Turret", "Max Distance Targeting", 99999f, "How far should the Railgun Turret target monsters.");
			ShotgunTurretDamageCoefficient = _file.Bind<float>("Shotgun Turret", "Damage Coefficient", 0.4f, "What should be the damage coefficient for the Shotgun Turret.");
			ShotgunTurretAttackSpeed = _file.Bind<float>("Shotgun Turret", "Attack Speed", 0.33f, "How much attack speed should the Shotgun Turret have.");
			ShotgunTurretDamagePerLevel = _file.Bind<float>("Shotgun Turret", "Base Damage per Level", 3.8f, "How much base damage should the Shotgun Turret get per level.");
			ShotgunTurretMaxDistanceTargeting = _file.Bind<float>("Shotgun Turret", "Max Distance Targeting", 40f, "How far should the Shotgun Turret target monsters.");
			ShotgunTurretBaseProjectileNumber = _file.Bind<int>("Shotgun Turret", "Base Projectile Number", 12, "How many projectiles should the shotgun have by default.");
			ShotgunTurretSpreadCoefficient = _file.Bind<float>("Shotgun Turret", "Spread Coefficient", 1.75f, "How strong the spread coefficient for the shotgun should be.");
			SeekerMissileDamageCoefficient = _file.Bind<float>("Seeker Missile", "Damage Coefficient", 0.225f, "By how much the damage should be multiplied by.");
			SeekerMissileMaxProjectileNumber = _file.Bind<int>("Seeker Missile", "Projectile Number", 24, "How many missiles can you fire at max charge.");
			ClusterMineDamageCoefficient = _file.Bind<float>("Cluster Mine", "Damage Coefficient", 0.0355f, "By how much the damage should be multiplied by.");
			ClusterMineBaseMaxStock = _file.Bind<int>("Cluster Mine", "Base Stock", 3, "How many stock charge should the Engineer get by default.");
			ClusterMineCooldown = _file.Bind<float>("Cluster Mine", "Cooldown", 20f, "How long the cooldown between each recharges should be.");
			ClusterMineVisualBouncing = _file.Bind<bool>("Cluster Mine", "Bounce", false, "Should the cluster mines projectiles B O U N C E ?");
			SatchelMineDamageCoefficient = _file.Bind<float>("Satchel Mine", "Damage Coefficient", 3f, "By how much the damage should be multiplied by.");
			SatchelMineForce = _file.Bind<float>("Satchel Mine", "Force", 3000f, "How strong the force vector should be.");
			OrbitalStrikeBaseDamage = _file.Bind<float>("Orbital Strike Mine", "Base Damage", 50f, "How much base damage should the Orbital Strike Mine deal.");
			OrbitalStrikeCooldown = _file.Bind<float>("Orbital Strike Mine", "Recharge Cooldown", 3f, "How long the recharge cooldown for getting 1 stock should be.");
			OrbitalStrikeRequiredStock = _file.Bind<int>("Orbital Strike Mine", "Required number of stock", 100, "How many stock are required for using the mine.");
			Vector3 one = Vector3.one;
			EmoteWindowPosition = _file.Bind<Vector3>("Emotes", "Emote Window Position", one, "The position of the Emote Window");
			Vector3 one2 = Vector3.one;
			EmoteWindowSize = _file.Bind<Vector3>("Emotes", "Emote Window Size", one2, "The size of the Emote Window");
			EmoteButtonUIPosX = _file.Bind<int>("Emotes", "Emote Button X Position", -170, "The X position of the Credit Button relative to the position of the primary skill square box. Higher X value is more left");
			EmoteButtonUIPosY = _file.Bind<int>("Emotes", "Emote Button Y Position", -155, "The Y position of the Credit Button relative to the position of the primary skill square box. Higher Y value is more down");
			EmoteVolume = _file.Bind<float>("Emotes", "Music Volume", 100f, "The volume value of the emotes music.");
		}

		private static void Reload()
		{
			_file.Reload();
		}

		internal static void Save()
		{
			_file.Save();
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCReloadConfig(ConCommandArgs _)
		{
			Reload();
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCChangeEngiColor(ConCommandArgs args)
		{
			//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_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			if (((ConCommandArgs)(ref args)).Count == 1)
			{
				if (((ConCommandArgs)(ref args))[0].ToLower().Equals("disable"))
				{
					CustomEngiColor.Value = false;
				}
				else if (((ConCommandArgs)(ref args))[0].ToLower().Equals("enable"))
				{
					CustomEngiColor.Value = true;
				}
			}
			if (Object.op_Implicit((Object)(object)Run.instance))
			{
				GameObject gameObject = ((Component)CameraRigController.readOnlyInstancesList.First().viewer.master.GetBody()).gameObject;
				if (((ConCommandArgs)(ref args)).Count == 3)
				{
					EngiColor.Value = string.Join(",", ((ConCommandArgs)(ref args))[0].ToString(CultureInfo.InvariantCulture), ((ConCommandArgs)(ref args))[1].ToString(CultureInfo.InvariantCulture), ((ConCommandArgs)(ref args))[2].ToString(CultureInfo.InvariantCulture));
					CustomEngiColor.Value = true;
					_file.Save();
					string[] array = EngiColor.Value.Split(',');
					EngiColorMsg engiColorMsg = default(EngiColorMsg);
					engiColorMsg.Color = new Color(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]));
					engiColorMsg.NetId = gameObject.GetComponent<NetworkIdentity>().netId;
					NetMessageExtensions.Send((INetMessage)(object)engiColorMsg, (NetworkDestination)1);
				}
				else if (((ConCommandArgs)(ref args)).Count == 0 || ((ConCommandArgs)(ref args)).Count == 1)
				{
					EngiColorMsg engiColorMsg = default(EngiColorMsg);
					engiColorMsg.NetId = gameObject.GetComponent<NetworkIdentity>().netId;
					EngiColorMsg engiColorMsg2 = engiColorMsg;
					if (!CustomEngiColor.Value)
					{
						engiColorMsg2.Color = new Color(-1f, -1f, -1f);
					}
					else
					{
						string[] array2 = EngiColor.Value.Split(',');
						engiColorMsg2.Color = new Color(float.Parse(array2[0]), float.Parse(array2[1]), float.Parse(array2[2]));
					}
					NetMessageExtensions.Send((INetMessage)(object)engiColorMsg2, (NetworkDestination)1);
				}
				else
				{
					Debug.Log((object)"Usage : bae_engi_color R G B  / bae_engi_color enable/disable. Exemple Usage : bae_engi_color 7 76 3.75. Or just \"bae_engi_color\" to force a color update.");
				}
			}
			else
			{
				Debug.Log((object)"Please launch a game run to use this command.");
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCChangeTurretColor(ConCommandArgs args)
		{
			if (((ConCommandArgs)(ref args)).Count == 3)
			{
				TurretColor.Value = string.Join(",", ((ConCommandArgs)(ref args))[0].ToString(CultureInfo.InvariantCulture), ((ConCommandArgs)(ref args))[1].ToString(CultureInfo.InvariantCulture), ((ConCommandArgs)(ref args))[2].ToString(CultureInfo.InvariantCulture));
				CustomTurretColor.Value = true;
			}
			else if (((ConCommandArgs)(ref args)).Count == 1)
			{
				if (((ConCommandArgs)(ref args))[0].ToLower().Equals("disable"))
				{
					CustomTurretColor.Value = false;
				}
				else if (((ConCommandArgs)(ref args))[0].ToLower().Equals("enable"))
				{
					CustomTurretColor.Value = true;
				}
			}
			_file.Save();
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCChangeIndicatorColor(ConCommandArgs args)
		{
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			if (((ConCommandArgs)(ref args)).Count == 3)
			{
				TrackerIndicatorColor.Value = string.Join(",", ((ConCommandArgs)(ref args))[0].ToString(CultureInfo.InvariantCulture), ((ConCommandArgs)(ref args))[1].ToString(CultureInfo.InvariantCulture), ((ConCommandArgs)(ref args))[2].ToString(CultureInfo.InvariantCulture));
				CustomTrackerIndicatorColor.Value = true;
			}
			else if (((ConCommandArgs)(ref args)).Count == 1)
			{
				if (((ConCommandArgs)(ref args))[0].ToLower().Equals("disable"))
				{
					CustomTrackerIndicatorColor.Value = false;
				}
				else if (((ConCommandArgs)(ref args))[0].ToLower().Equals("enable"))
				{
					CustomTrackerIndicatorColor.Value = true;
				}
			}
			else if (((ConCommandArgs)(ref args)).Count == 0)
			{
				Debug.Log((object)("Current Color for Missile Tracker Indicator : " + (CustomTrackerIndicatorColor.Value ? TrackerIndicatorColor.Value : "Default")));
			}
			_file.Save();
			if (!Object.op_Implicit((Object)(object)Run.instance) || Application.isBatchMode || LocalUserManager.readOnlyLocalUsersList.Count <= 0)
			{
				return;
			}
			NetworkUser currentNetworkUser = LocalUserManager.GetFirstLocalUser().currentNetworkUser;
			if (!Object.op_Implicit((Object)(object)currentNetworkUser))
			{
				return;
			}
			CharacterBody currentBody = currentNetworkUser.GetCurrentBody();
			if (Object.op_Implicit((Object)(object)currentBody) && currentBody.bodyIndex == BadAssEngi.EngiBodyIndex)
			{
				MissileTracker component = ((Component)currentBody).GetComponent<MissileTracker>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Object.Destroy((Object)(object)component);
					((Component)currentBody).gameObject.AddComponent<MissileTracker>();
				}
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCChangeClusterColor(ConCommandArgs args)
		{
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			if (((ConCommandArgs)(ref args)).Count == 3)
			{
				ClusterMineColor.Value = string.Join(",", ((ConCommandArgs)(ref args))[0].ToString(CultureInfo.InvariantCulture), ((ConCommandArgs)(ref args))[1].ToString(CultureInfo.InvariantCulture), ((ConCommandArgs)(ref args))[2].ToString(CultureInfo.InvariantCulture));
				CustomClusterMineColor.Value = true;
			}
			else if (((ConCommandArgs)(ref args)).Count == 1)
			{
				if (((ConCommandArgs)(ref args))[0].ToLower().Equals("disable"))
				{
					CustomClusterMineColor.Value = false;
				}
				else if (((ConCommandArgs)(ref args))[0].ToLower().Equals("enable"))
				{
					CustomClusterMineColor.Value = true;
				}
			}
			else if (((ConCommandArgs)(ref args)).Count == 0)
			{
				Debug.Log((object)("Current Color for Cluster Mine : " + (CustomClusterMineColor.Value ? ClusterMineColor.Value : "Default")));
			}
			_file.Save();
			GameObject obj = (ClusterMineVisualBouncing.Value ? BaeAssets.PrefabEngiClusterMineVisualBounce : BaeAssets.PrefabEngiClusterMineVisual);
			string[] array = ClusterMineColor.Value.Split(',');
			Color val = default(Color);
			((Color)(ref val))..ctor(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]));
			Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>();
			foreach (Renderer obj2 in componentsInChildren)
			{
				List<Material> list = new List<Material>();
				obj2.GetMaterials(list);
				int num = 0;
				foreach (Material item in list)
				{
					item.color = (CustomClusterMineColor.Value ? val : BaeAssets.OriginalClusterMineVisual[num]);
					num++;
				}
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCBaeEmoteVolume(ConCommandArgs args)
		{
			if (((ConCommandArgs)(ref args)).Count == 1)
			{
				if (float.TryParse(((ConCommandArgs)(ref args))[0], out var result))
				{
					EmoteVolume.Value = result;
					_file.Save();
				}
				else
				{
					Debug.Log((object)"Couldn't parse correctly the volume value. Change the music volume of the emotes. Exemple Usage : bae_emote_volume 100 (range is 0-100)");
				}
			}
			else
			{
				Debug.Log((object)("Current emote volume value is " + EmoteVolume.Value));
				Debug.Log((object)"Change the music volume of the emotes. Exemple Usage : bae_emote_volume 100 (range is 0-100)");
			}
			if (AkSoundEngine.IsInitialized())
			{
				SetEmoteVolumeRTPC();
			}
		}

		internal static void SetEmoteVolumeRTPC()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			AkSoundEngine.SetRTPCValue("Volume_Emote", EmoteVolume.Value);
		}
	}
	internal static class KeybindController
	{
		internal static void RetrieveFirstGamePad()
		{
			foreach (Controller controller in ReInput.controllers.Controllers)
			{
				IGamepadTemplate template = controller.GetTemplate<IGamepadTemplate>();
				if (template != null)
				{
					Configuration.DPad = template.dPad;
					break;
				}
			}
		}

		internal static void Update()
		{
			//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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			foreach (NetworkUser readOnlyLocalPlayers in NetworkUser.readOnlyLocalPlayersList)
			{
				CharacterBody currentBody = readOnlyLocalPlayers.GetCurrentBody();
				if (!Object.op_Implicit((Object)(object)currentBody) || currentBody.bodyIndex != BadAssEngi.EngiBodyIndex)
				{
					continue;
				}
				BodyLoadoutManager val = currentBody.master?.loadout.bodyLoadoutManager;
				if (val == null)
				{
					break;
				}
				uint skillVariant = val.GetSkillVariant(currentBody.bodyIndex, 0);
				uint skillVariant2 = val.GetSkillVariant(currentBody.bodyIndex, 1);
				uint skillVariant3 = val.GetSkillVariant(currentBody.bodyIndex, 3);
				if (GetKeyBindInput(Configuration.TurretTypeKeyBind) && skillVariant3 == SkillLoader.SwappableTurretSkillVariant)
				{
					switch (TurretTypeController.CurrentTurretType)
					{
					case TurretType.Default:
						TurretTypeController.CurrentTurretType = TurretType.Minigun;
						Chat.AddMessage("<style=cIsUtility>Turret Type is now: </style><style=cDeath>[Minigun]</style>");
						break;
					case TurretType.Minigun:
						TurretTypeController.CurrentTurretType = TurretType.Railgun;
						Chat.AddMessage("<style=cIsUtility>Turret Type is now: </style><style=cDeath>[Railgun]</style>");
						break;
					case TurretType.Railgun:
						TurretTypeController.CurrentTurretType = TurretType.Shotgun;
						Chat.AddMessage("<style=cIsUtility>Turret Type is now: </style><style=cDeath>[Hydra Launcher]</style>");
						break;
					case TurretType.Shotgun:
						TurretTypeController.CurrentTurretType = TurretType.Default;
						Chat.AddMessage("<style=cIsUtility>Turret Type is now: </style><style=cDeath>[WeakBoy]</style>");
						break;
					}
				}
				if (GetKeyBindInput(Configuration.GrenadeTypeKeyBind) && skillVariant == SkillLoader.SwappableGrenadeSkillVariant)
				{
					GenericSkill val2 = (Object.op_Implicit((Object)(object)currentBody.skillLocator) ? currentBody.skillLocator.primary : null);
					if (Object.op_Implicit((Object)(object)val2))
					{
						MissileTracker component = ((Component)currentBody).GetComponent<MissileTracker>();
						if (Object.op_Implicit((Object)(object)component))
						{
							val2.UnsetSkillOverride((object)currentBody, SkillLoader.ChargeSeekerMissileSkillDef, (SkillOverridePriority)3);
							if (Object.op_Implicit((Object)(object)currentBody) && currentBody.bodyIndex == BadAssEngi.EngiBodyIndex && Object.op_Implicit((Object)(object)component))
							{
								Object.Destroy((Object)(object)component);
							}
							Chat.AddMessage("<style=cIsUtility>Grenade Type is now: </style><style=cDeath>[Default]</style>");
						}
						else
						{
							val2.SetSkillOverride((object)currentBody, SkillLoader.ChargeSeekerMissileSkillDef, (SkillOverridePriority)3);
							if (Object.op_Implicit((Object)(object)currentBody) && currentBody.bodyIndex == BadAssEngi.EngiBodyIndex)
							{
								((Component)currentBody).gameObject.AddComponent<MissileTracker>();
							}
							Chat.AddMessage("<style=cIsUtility>Grenade Type is now: </style><style=cDeath>[Seeker]</style>");
						}
					}
				}
				if (GetKeyBindInput(Configuration.MineTypeKeyBind) && skillVariant2 == SkillLoader.SwappableMineSkillVariant)
				{
					GenericSkill val3 = (Object.op_Implicit((Object)(object)currentBody.skillLocator) ? currentBody.skillLocator.secondary : null);
					if (Object.op_Implicit((Object)(object)val3))
					{
						if ((Object)(object)val3.skillDef == (Object)(object)SkillLoader.SatchelMineSkillDef)
						{
							float rechargeStopwatch = val3.rechargeStopwatch;
							int stock = val3.stock;
							val3.UnsetSkillOverride((object)currentBody, SkillLoader.SatchelMineSkillDef, (SkillOverridePriority)3);
							val3.rechargeStopwatch = rechargeStopwatch;
							val3.stock = stock;
							Chat.AddMessage("<style=cIsUtility>Mine Type is now: </style><style=cDeath>[Cluster]</style>");
						}
						else
						{
							float rechargeStopwatch2 = val3.rechargeStopwatch;
							int stock2 = val3.stock;
							val3.SetSkillOverride((object)currentBody, SkillLoader.SatchelMineSkillDef, (SkillOverridePriority)3);
							val3.rechargeStopwatch = rechargeStopwatch2;
							val3.stock = stock2;
							Chat.AddMessage("<style=cIsUtility>Mine Type is now: </style><style=cDeath>[Satchel]</style>");
						}
					}
				}
				if (GetKeyBindInput(Configuration.SatchelManualDetonateKeyBind))
				{
					if (NetworkServer.active)
					{
						List<DeployableInfo> deployablesList = readOnlyLocalPlayers.master.deployablesList;
						if (deployablesList != null && deployablesList.Count >= 1)
						{
							foreach (DeployableInfo item in deployablesList)
							{
								if ((int)item.slot == 0 && Object.op_Implicit((Object)(object)currentBody.skillLocator) && (Object)(object)currentBody.skillLocator.secondary.skillDef == (Object)(object)SkillLoader.SatchelMineSkillDef && !Object.op_Implicit((Object)(object)((Component)item.deployable).GetComponent<RecursiveMine>()))
								{
									EntityStateMachine.FindByCustomName(((Component)item.deployable).gameObject, "Arming").SetNextState((EntityState)(object)new MineArmingFullSatchel());
									EntityStateMachine.FindByCustomName(((Component)item.deployable).gameObject, "Main").SetNextState((EntityState)(object)new DetonateSatchel());
								}
							}
						}
					}
					else
					{
						DetonateMsg detonateMsg = default(DetonateMsg);
						detonateMsg.SenderUserNetId = ((NetworkBehaviour)readOnlyLocalPlayers).netId;
						NetMessageExtensions.Send((INetMessage)(object)detonateMsg, (NetworkDestination)2);
					}
				}
				if ((currentBody.characterMotor.velocity != Vector3.zero || currentBody.inputBank.CheckAnyButtonDown()) && EngiEmoteController.IsEmoting && ((Component)currentBody).gameObject.GetComponent<EntityStateMachine>().CanInterruptState((InterruptPriority)1))
				{
					StopAnimMsg stopAnimMsg = default(StopAnimMsg);
					stopAnimMsg.EngiNetId = ((Component)currentBody).GetComponent<NetworkIdentity>().netId;
					NetMessageExtensions.Send((INetMessage)(object)stopAnimMsg, (NetworkDestination)1);
					EngiEmoteController.IsEmoting = false;
				}
			}
		}

		private static bool GetKeyBindInput(ConfigEntry<string> entry)
		{
			if (entry.Value.Equals("dpadup"))
			{
				return Configuration.DPad.up.justPressed;
			}
			if (entry.Value.Equals("dpaddown"))
			{
				return Configuration.DPad.down.justPressed;
			}
			if (entry.Value.Equals("dpadleft"))
			{
				return Configuration.DPad.left.justPressed;
			}
			if (entry.Value.Equals("dpadright"))
			{
				return Configuration.DPad.right.justPressed;
			}
			return Input.GetKeyDown(entry.Value);
		}
	}
	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 class ConstructTurretMessage : MessageBase
	{
		public GameObject builder;

		public Vector3 position;

		public Quaternion rotation;

		public override void Serialize(NetworkWriter writer)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(builder);
			writer.Write(position);
			writer.Write(rotation);
		}

		public override void Deserialize(NetworkReader reader)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			builder = reader.ReadGameObject();
			position = reader.ReadVector3();
			rotation = reader.ReadQuaternion();
		}
	}
}
namespace BadAssEngi.Util
{
	internal static class CoroutineUtil
	{
		internal static IEnumerator DelayedMethod(float seconds, Action method)
		{
			yield return (object)new WaitForSeconds(seconds);
			method();
		}

		internal static IEnumerator DelayedSound(string soundName, GameObject soundEmitter, float seconds)
		{
			yield return (object)new WaitForSeconds(seconds);
			float attackSpeed = soundEmitter.GetComponent<CharacterMaster>().GetBodyObject().GetComponent<CharacterBody>()
				.attackSpeed;
			soundEmitter.GetComponent<BadAssTurret>().SoundGunId = Util.PlaySound(soundName, soundEmitter, "Turret_Attack_Speed", attackSpeed);
			Log.Debug("Railgun Turret Attack Speed : " + attackSpeed);
		}

		internal static IEnumerator DelayedDestroy(GameObject gameObject, float seconds)
		{
			yield return (object)new WaitForSeconds(seconds);
			Object.Destroy((Object)(object)gameObject);
		}
	}
	internal static class SkillExtensions
	{
		internal static SkillFamily AddSkillFamily(string skillFamilyName, params SkillDef[] skills)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_004e: 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)
			SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val).name = skillFamilyName;
			val.variants = (Variant[])(object)new Variant[skills.Length];
			for (int i = 0; i < skills.Length; i++)
			{
				Variant[] variants = val.variants;
				int num = i;
				Variant val2 = new Variant
				{
					skillDef = skills[i]
				};
				((Variant)(ref val2)).viewableNode = new Node(skills[i].skillName, false, (Node)null);
				variants[num] = val2;
				ContentAddition.AddSkillDef(skills[i]);
				LoadoutAPI.AddSkill(((SerializableEntityStateType)(ref skills[i].activationState)).stateType);
			}
			ContentAddition.AddSkillFamily(val);
			return val;
		}

		internal static void SetSkillFamily(this GenericSkill genericSkill, string skillFamilyName, params SkillDef[] skills)
		{
			SkillFamily skillFamily = AddSkillFamily(skillFamilyName, skills);
			genericSkill._skillFamily = skillFamily;
		}
	}
	internal static class TextureUtil
	{
		internal static Texture2D ReplaceWithRamp(Texture2D origTex, Vector3 vec, float startGrad)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_00c3: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(((Texture)origTex).width, ((Texture)origTex).height, (TextureFormat)4, false);
			int num = Mathf.CeilToInt(startGrad * 255f);
			int num2 = ((Texture)val).width - num;
			Color32 val2 = default(Color32);
			((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			Color32 val3 = default(Color32);
			((Color32)(ref val3))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			for (int i = 0; i < ((Texture)val).width; i++)
			{
				if (i >= num)
				{
					float num3 = ((float)i - (float)num) / (float)num2;
					val3.r = (byte)Mathf.RoundToInt(255f * num3 * vec.x);
					val3.g = (byte)Mathf.RoundToInt(255f * num3 * vec.y);
					val3.b = (byte)Mathf.RoundToInt(255f * num3 * vec.z);
					val3.a = (byte)Mathf.RoundToInt(128f * num3);
				}
				else
				{
					val3 = val2;
				}
				for (int j = 0; j < ((Texture)val).height; j++)
				{
					val.SetPixel(i, j, Color32.op_Implicit(val3));
				}
			}
			((Texture)val).wrapMode = (TextureWrapMode)1;
			val.Apply();
			return val;
		}
	}
}
namespace BadAssEngi.Skills
{
	internal static class SkillLoader
	{
		private static SkillLocator _engiSkillLocator;

		internal static int SwappableGrenadeSkillVariant;

		internal static int SeekerSwarmSkillVariant;

		internal static int SatchelMineSkillVariant;

		internal static int SwappableMineSkillVariant;

		internal static int OrbitalStrikeSkillVariant;

		internal static int SwappableTurretSkillVariant;

		internal static SkillDef ChargeSwappableGrenadesSkillDef { get; private set; }

		internal static SkillDef ChargeSeekerMissileSkillDef { get; private set; }

		internal static SkillDef SwappableMineSkillDef { get; private set; }

		internal static SkillDef SatchelMineSkillDef { get; private set; }

		internal static SkillDef OrbitalStrikeSkillDef { get; private set; }

		internal static SkillDef SwappableTurretSkillDef { get; private set; }

		internal static void Init()
		{
			_engiSkillLocator = BaeAssets.EngiBodyPrefab.GetComponent<SkillLocator>();
			InitEngiPrimarySkills();
			InitEngiSecondarySkills();
			InitEngiSpecialSkills();
			RegisterStatesTypes();
		}

		private static void InitEngiPrimarySkills()
		{
			SeekerMissile();
			SwappableGrenade();
			List<SkillDef> list = _engiSkillLocator.primary._skillFamily.variants.Select((Variant variant) => variant.skillDef).ToList();
			SeekerSwarmSkillVariant = list.Count;
			list.Add(ChargeSeekerMissileSkillDef);
			SwappableGrenadeSkillVariant = list.Count;
			list.Add(ChargeSwappableGrenadesSkillDef);
			_engiSkillLocator.primary.SetSkillFamily(_engiSkillLocator.primary._skillFamily.name, list.ToArray());
		}

		private static void InitEngiSecondarySkills()
		{
			SwappableMine();
			SatchelMine();
			OrbitalStrikeMine();
			List<SkillDef> list = _engiSkillLocator.secondary._skillFamily.variants.Select((Variant variant) => variant.skillDef).ToList();
			SatchelMineSkillVariant = 0;
			list[SatchelMineSkillVariant] = SatchelMineSkillDef;
			SwappableMineSkillVariant = list.Count;
			list.Add(SwappableMineSkillDef);
			OrbitalStrikeSkillVariant = list.Count;
			list.Add(OrbitalStrikeSkillDef);
			_engiSkillLocator.secondary.SetSkillFamily(_engiSkillLocator.secondary._skillFamily.name, list.ToArray());
		}

		private static void InitEngiSpecialSkills()
		{
			SwappableTurret();
			List<SkillDef> list = _engiSkillLocator.special._skillFamily.variants.Select((Variant variant) => variant.skillDef).ToList();
			SwappableTurretSkillVariant = list.Count;
			list.Add(SwappableTurretSkillDef);
			_engiSkillLocator.special.SetSkillFamily(_engiSkillLocator.special._skillFamily.name, list.ToArray());
		}

		private static void SeekerMissile()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			ChargeSeekerMissileSkillDef = ScriptableObject.CreateInstance<SkillDef>();
			((Object)ChargeSeekerMissileSkillDef).name = "BAESeekerSwarm";
			ChargeSeekerMissileSkillDef.skillName = "BAESeekerSwarm";
			ChargeSeekerMissileSkillDef.skillNameToken = "Seeker Swarm";
			ChargeSeekerMissileSkillDef.skillDescriptionToken = "Seeker : Auto-targeting. Charge up to <style=cIsDamage>" + Configuration.SeekerMissileMaxProjectileNumber.Value + "</style> missiles that deal <style=cIsDamage>" + Configuration.SeekerMissileDamageCoefficient.Value * 100f + "% damage</style> each.";
			ChargeSeekerMissileSkillDef.activationStateMachineName = "Weapon";
			ChargeSeekerMissileSkillDef.activationState = new SerializableEntityStateType(typeof(ChargeSeekerMissile));
			ChargeSeekerMissileSkillDef.interruptPriority = (InterruptPriority)0;
			ChargeSeekerMissileSkillDef.baseRechargeInterval = 0f;
			ChargeSeekerMissileSkillDef.baseMaxStock = 1;
			ChargeSeekerMissileSkillDef.rechargeStock = 1;
			ChargeSeekerMissileSkillDef.beginSkillCooldownOnSkillEnd = false;
			ChargeSeekerMissileSkillDef.requiredStock = 1;
			ChargeSeekerMissileSkillDef.stockToConsume = 1;
			ChargeSeekerMissileSkillDef.isCombatSkill = true;
			ChargeSeekerMissileSkillDef.cancelSprintingOnActivation = true;
			ChargeSeekerMissileSkillDef.canceledFromSprinting = false;
			ChargeSeekerMissileSkillDef.mustKeyPress = false;
			ChargeSeekerMissileSkillDef.icon = BaeAssets.IconMissileM1;
		}

		private static void SwappableGrenade()
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			ChargeSwappableGrenadesSkillDef = ScriptableObject.CreateInstance<SkillDef>();
			((Object)ChargeSwappableGrenadesSkillDef).name = "BAESwappableGrenade";
			ChargeSwappableGrenadesSkillDef.skillName = "BAESwappableGrenade";
			ChargeSwappableGrenadesSkillDef.skillNameToken = "Bouncing Grenades and Seeker Swarm";
			ChargeSwappableGrenadesSkillDef.skillDescriptionToken = "Current Key Bind for switching : <style=cIsUtility>" + Configuration.GrenadeTypeKeyBind.Value + "</style>" + Environment.NewLine + "Bouncing : Charge up to <style=cIsDamage>8</style> grenades that deal <style=cIsDamage>100% damage</style> each." + Environment.NewLine + "Seeker : Auto-targeting. Charge up to <style=cIsDamage>" + Configuration.SeekerMissileMaxProjectileNumber.Value + "</style> missiles that deal <style=cIsDamage>" + Configuration.SeekerMissileDamageCoefficient.Value * 100f + "% damage</style> each.";
			ChargeSwappableGrenadesSkillDef.activationStateMachineName = "Weapon";
			ChargeSwappableGrenadesSkillDef.activationState = new SerializableEntityStateType(typeof(ChargeGrenades));
			ChargeSwappableGrenadesSkillDef.interruptPriority = (InterruptPriority)0;
			ChargeSwappableGrenadesSkillDef.baseRechargeInterval = 0f;
			ChargeSwappableGrenadesSkillDef.baseMaxStock = 1;
			ChargeSwappableGrenadesSkillDef.rechargeStock = 1;
			ChargeSwappableGrenadesSkillDef.beginSkillCooldownOnSkillEnd = false;
			ChargeSwappableGrenadesSkillDef.requiredStock = 1;
			ChargeSwappableGrenadesSkillDef.stockToConsume = 1;
			ChargeSwappableGrenadesSkillDef.isCombatSkill = true;
			ChargeSwappableGrenadesSkillDef.cancelSprintingOnActivation = true;
			ChargeSwappableGrenadesSkillDef.canceledFromSprinting = false;
			ChargeSwappableGrenadesSkillDef.mustKeyPress = false;
			ChargeSwappableGrenadesSkillDef.icon = BaeAssets.IconSwappableGrenades;
		}

		private static void SwappableMine()
		{
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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)
			SwappableMineSkillDef = ScriptableObject.CreateInstance<SkillDef>();
			((Object)SwappableMineSkillDef).name = "BAESwappableMine";
			SwappableMineSkillDef.rechargeStock = 1;
			SwappableMineSkillDef.requiredStock = 1;
			SwappableMineSkillDef.stockToConsume = 1;
			SwappableMineSkillDef.fullRestockOnAssign = false;
			SwappableMineSkillDef.skillName = "BAESwappableMine";
			SwappableMineSkillDef.skillNameToken = "Cluster and Satchel Pressured Mines";
			SwappableMineSkillDef.skillDescriptionToken = Environment.NewLine + Environment.NewLine + "Current Key Bind for switching : <style=cIsUtility>" + Configuration.MineTypeKeyBind.Value + "</style>. Current Key Bind for detonating Satchels : <style=cIsUtility>" + Configuration.SatchelManualDetonateKeyBind.Value + "</style>" + Environment.NewLine + "<style=cIsUtility>Cluster</style> : Place a mine that explode into <style=cIsDamage>rebars</style> for <style=cIsDamage>30x" + Configuration.ClusterMineDamageCoefficient.Value * 100f + "% damage</style> when an enemy walks nearby. " + Environment.NewLine + "The first mine and the second set of mines explodes into <style=cIsDamage>3</style> mines." + Environment.NewLine + "<style=cIsUtility>Satchel</style> : Place a mine that will explode for <style=cIsDamage>" + Configuration.SatchelMineDamageCoefficient.Value * 100f + "% damage</style> when an enemy walks nearby. \n<style=cIsDamage>Can be manually detonated</style>. <style=cIsUtility>Knockback nearby units</style>." + Environment.NewLine + "Base stock : " + Configuration.ClusterMineBaseMaxStock.Value + "." + Environment.NewLine + Environment.NewLine;
			SwappableMineSkillDef.baseMaxStock = Configuration.ClusterMineBaseMaxStock.Value;
			SwappableMineSkillDef.baseRechargeInterval = Configuration.ClusterMineCooldown.Value;
			SwappableMineSkillDef.activationStateMachineName = "Weapon";
			SwappableMineSkillDef.activationState = new SerializableEntityStateType(typeof(FireClusterMines));
			SwappableMineSkillDef.beginSkillCooldownOnSkillEnd = true;
			SwappableMineSkillDef.interruptPriority = (InterruptPriority)0;
			SwappableMineSkillDef.isCombatSkill = true;
			SwappableMineSkillDef.cancelSprintingOnActivation = true;
			SwappableMineSkillDef.canceledFromSprinting = false;
			SwappableMineSkillDef.mustKeyPress = false;
			SwappableMineSkillDef.icon = BaeAssets.IconSwappableMines;
		}

		private static void SatchelMine()
		{
			//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_0131: Unknown result type (might be due to invalid IL or missing references)
			SatchelMineSkillDef = ScriptableObject.CreateInstance<SkillDef>();
			SatchelMineSkillDef.rechargeStock = 1;
			SatchelMineSkillDef.requiredStock = 1;
			SatchelMineSkillDef.stockToConsume = 1;
			SatchelMineSkillDef.fullRestockOnAssign = false;
			((Object)SatchelMineSkillDef).name = "BAESatchelPressuredMine";
			SatchelMineSkillDef.skillName = "BAESatchelPressuredMine";
			SatchelMineSkillDef.skillNameToken = "Satchel Pressured Mines";
			SatchelMineSkillDef.skillDescriptionToken = Environment.NewLine + "Current Key Bind for detonating Satchels : <style=cIsUtility>" + Configuration.SatchelManualDetonateKeyBind.Value + "</style>" + Environment.NewLine + "<style=cIsUtility>Satchel</style> : Place a mine that will explode for <style=cIsDamage>" + Configuration.SatchelMineDamageCoefficient.Value * 100f + "% damage</style> when an enemy walks nearby. \n<style=cIsDamage>Can be manually detonated</style>. <style=cIsUtility>Knockback nearby units</style>.";
			SatchelMineSkillDef.baseMaxStock = Configuration.ClusterMineBaseMaxStock.Value;
			SatchelMineSkillDef.baseRechargeInterval = Configuration.ClusterMineCooldown.Value;
			SatchelMineSkillDef.activationStateMachineName = "Weapon";
			SatchelMineSkillDef.activationState = new SerializableEntityStateType(typeof(FireSatchelMines));
			SatchelMineSkillDef.beginSkillCooldownOnSkillEnd = true;
			SatchelMineSkillDef.interruptPriority = (InterruptPriority)0;
			SatchelMineSkillDef.isCombatSkill = true;
			SatchelMineSkillDef.cancelSprintingOnActivation = true;
			SatchelMineSkillDef.canceledFromSprinting = false;
			SatchelMineSkillDef.mustKeyPress = false;
			SatchelMineSkillDef.icon = _engiSkillLocator.secondary._skillFamily.variants[0].skillDef.icon;
		}

		private static void OrbitalStrikeMine()
		{
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			OrbitalStrikeSkillDef = ScriptableObject.CreateInstance<SkillDef>();
			OrbitalStrikeSkillDef.baseRechargeInterval = Configuration.OrbitalStrikeCooldown.Value;
			OrbitalStrikeSkillDef.baseMaxStock = Configuration.OrbitalStrikeRequiredStock.Value;
			OrbitalStrikeSkillDef.rechargeStock = 1;
			OrbitalStrikeSkillDef.requiredStock = Configuration.OrbitalStrikeRequiredStock.Value;
			OrbitalStrikeSkillDef.stockToConsume = Configuration.OrbitalStrikeRequiredStock.Value;
			OrbitalStrikeSkillDef.fullRestockOnAssign = false;
			((Object)OrbitalStrikeSkillDef).name = "BAEOrbitalMine";
			OrbitalStrikeSkillDef.skillName = "BAEOrbitalMine";
			OrbitalStrikeSkillDef.skillNameToken = "Orbital Strike";
			OrbitalStrikeSkillDef.skillDescriptionToken = Environment.NewLine + "Fire an Orbital Strike at the mine position." + Environment.NewLine + "Require <style=cIsUtility>100 stocks</style> to be used." + Environment.NewLine + "<style=cIsUtility>3 Second cooldown for each charges</style>." + Environment.NewLine + "The <style=cIsDamage>cooldown is shared across stages</style>.";
			OrbitalStrikeSkillDef.activationStateMachineName = "Weapon";
			OrbitalStrikeSkillDef.activationState = new SerializableEntityStateType(typeof(FireOrbitalMines));
			OrbitalStrikeSkillDef.beginSkillCooldownOnSkillEnd = true;
			OrbitalStrikeSkillDef.interruptPriority = (InterruptPriority)0;
			OrbitalStrikeSkillDef.isCombatSkill = true;
			OrbitalStrikeSkillDef.cancelSprintingOnActivation = false;
			OrbitalStrikeSkillDef.canceledFromSprinting = false;
			OrbitalStrikeSkillDef.mustKeyPress = true;
			OrbitalStrikeSkillDef.icon = BaeAssets.IconOrbitalStrike;
		}

		private static void SwappableTurret()
		{
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			SwappableTurretSkillDef = ScriptableObject.CreateInstance<SkillDef>();
			((Object)SwappableTurretSkillDef).name = "BAESwappableTurret";
			SwappableTurretSkillDef.skillName = "BAESwappableTurret";
			SwappableTurretSkillDef.skillNameToken = "TR69 MultiFunctional Auto-Turret";
			SwappableTurretSkillDef.skillDescriptionToken = Environment.NewLine + Environment.NewLine + Environment.NewLine + "Current Key Bind for switching : <style=cIsUtility>" + Configuration.TurretTypeKeyBind.Value + "</style>" + Environment.NewLine + "Place a turret that <style=cIsUtility>inherits all your items.</style> You can <color=green>ping</color> your turrets to swap between the modes." + Environment.NewLine + "<style=cIsUtility>Default Mode</style> : Fire a cannon for <style=cIsDamage>" + Configuration.DefaultTurretDamageCoefficient.Value * 100f + " damage</style> with <style=cIsUtility>" + Configuration.DefaultTurretAttackSpeed.Value + " base attack speed</style>." + Environment.NewLine + "<style=cIsUtility>Minigun Mode</style> : Fire a minigun for <style=cIsDamage>" + Configuration.MinigunTurretDamageCoefficient.Value * 100f + " damage</style> with <style=cIsUtility>" + Configuration.MinigunTurretAttackSpeed.Value + " base attack speed</style>." + Environment.NewLine + "<style=cIsUtility>Railgun Mode</style> : Fire a railgun for <style=cIsDamage>" + Configuration.RailgunTurretDamageCoefficient.Value * 100f + " damage</style> with <style=cIsUtility>" + Configuration.RailgunTurretAttackSpeed.Value + " base attack speed</style>." + Environment.NewLine + "<style=cIsUtility>Shotgun Mode</style> : Fire rockets for <style=cIsDamage>" + Configuration.ShotgunTurretDamageCoefficient.Value * 100f + " damage</style> with <style=cIsUtility>" + Configuration.ShotgunTurretAttackSpeed.Value + " base attack speed</style>." + Environment.NewLine + "Can place up to 2.";
			SwappableTurretSkillDef.activationStateMachineName = "Weapon";
			SwappableTurretSkillDef.activationState = new SerializableEntityStateType(typeof(PlaceTurret));
			SwappableTurretSkillDef.interruptPriority = (InterruptPriority)1;
			SwappableTurretSkillDef.baseRechargeInterval = 30f;
			SwappableTurretSkillDef.baseMaxStock = 2;
			SwappableTurretSkillDef.rechargeStock = 1;
			SwappableTurretSkillDef.beginSkillCooldownOnSkillEnd = false;
			SwappableTurretSkillDef.requiredStock = 1;
			SwappableTurretSkillDef.stockToConsume = 0;
			SwappableTurretSkillDef.isCombatSkill = false;
			SwappableTurretSkillDef.cancelSprintingOnActivation = true;
			SwappableTurretSkillDef.canceledFromSprinting = false;
			SwappableTurretSkillDef.mustKeyPress = false;
			SwappableTurretSkillDef.fullRestockOnAssign = false;
			SwappableTurretSkillDef.icon = BaeAssets.IconSwappableTurrets;
		}

		private static void RegisterStatesTypes()
		{
			RegisterClusterMinesStates();
			RegisterSatchelMinesStates();
			RegisterOrbitalMinesStates();
		}

		private static void RegisterClusterMinesStates()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = default(bool);
			ContentAddition.AddEntityState<MineArmingFullCluster>(ref flag);
			ContentAddition.AddEntityState<MineArmingUnarmedCluster>(ref flag);
			ContentAddition.AddEntityState<MineArmingWeakCluster>(ref flag);
			ContentAddition.AddEntityState<ArmCluster>(ref flag);
			ContentAddition.AddEntityState<DetonateCluster>(ref flag);
			ContentAddition.AddEntityState<PreDetonateCluster>(ref flag);
			ContentAddition.AddEntityState<WaitForStickCluster>(ref flag);
			ContentAddition.AddEntityState<WaitForTargetCluster>(ref flag);
		}

		private static void RegisterSatchelMinesStates()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = default(bool);
			ContentAddition.AddEntityState<MineArmingFullSatchel>(ref flag);
			ContentAddition.AddEntityState<MineArmingUnarmedSatchel>(ref flag);
			ContentAddition.AddEntityState<MineArmingWeakSatchel>(ref flag);
			ContentAddition.AddEntityState<ArmSatchel>(ref flag);
			ContentAddition.AddEntityState<DetonateSatchel>(ref flag);
			ContentAddition.AddEntityState<PreDetonateSatchel>(ref flag);
			ContentAddition.AddEntityState<WaitForStickSatchel>(ref flag);
			ContentAddition.AddEntityState<WaitForTargetSatchel>(ref flag);
		}

		private static void RegisterOrbitalMinesStates()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = default(bool);
			ContentAddition.AddEntityState<MineArmingFullOrbital>(ref flag);
			ContentAddition.AddEntityState<MineArmingUnarmedOrbital>(ref flag);
			ContentAddition.AddEntityState<MineArmingWeakOrbital>(ref flag);
			ContentAddition.AddEntityState<ArmOrbital>(ref flag);
			ContentAddition.AddEntityState<DetonateOrbital>(ref flag);
			ContentAddition.AddEntityState<PreDetonateOrbital>(ref flag);
			ContentAddition.AddEntityState<WaitForStickOrbital>(ref flag);
			ContentAddition.AddEntityState<WaitForTargetOrbital>(ref flag);
		}
	}
}
namespace BadAssEngi.Skills.Special
{
	internal enum TurretType
	{
		Default,
		Minigun,
		Railgun,
		Shotgun
	}
	internal class BadAssTurret : MonoBehaviour
	{
		internal TurretType Index;

		internal uint SoundGunId;

		internal CharacterMaster OwnerCharacterMaster;

		internal static BuffIndex[] Buffs;

		internal void Init()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			OwnerCharacterMaster.inventory.onInventoryChanged += UpdateInventory;
			CharacterBody.UpdateBuffs += new hook_UpdateBuffs(CharacterBodyOnUpdateBuffs);
			AkSoundEngine.PostEvent("Turret_Alive_Play_69", ((Component)this).gameObject);
			if (Index == TurretType.Railgun)
			{
				SoundGunId = AkSoundEngine.PostEvent("Railgun_Turret_Targeting_Play_69", ((Component)this).gameObject);
			}
			else if (Index == TurretType.Shotgun)
			{
				SoundGunId = AkSoundEngine.PostEvent("Rocket_Turret_Single_Reload_Play_69", ((Component)this).gameObject);
			}
		}

		private void UpdateInventory()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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)
			if ((Object)(object)((Component)this).gameObject == (Object)null)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			CharacterMaster component = ((Component)this).gameObject.GetComponent<CharacterMaster>();
			if (!((Object)(object)component == (Object)null) && Object.op_Implicit((Object)(object)component))
			{
				Inventory inventory = component.inventory;
				if ((Object)(object)OwnerCharacterMaster.inventory == (Object)null || !Object.op_Implicit((Object)(object)OwnerCharacterMaster.inventory))
				{
					OwnerCharacterMaster = ((Component)this).gameObject.GetComponent<Deployable>().ownerMaster;
				}
				int itemCount = inventory.GetItemCount(Items.ExtraLife.itemIndex);
				int itemCount2 = inventory.GetItemCount(Items.ExtraLifeConsumed.itemIndex);
				inventory.CopyItemsFrom(OwnerCharacterMaster.inventory);
				inventory.ResetItem(Items.WardOnLevel.itemIndex);
				inventory.ResetItem(Items.BeetleGland.itemIndex);
				inventory.ResetItem(Items.CrippleWardOnLevel.itemIndex);
				inventory.ResetItem(Items.ExtraLife.itemIndex);
				inventory.ResetItem(Items.ExtraLifeConsumed.itemIndex);
				inventory.GiveItem(Items.ExtraLife.itemIndex, itemCount);
				inventory.GiveItem(Items.ExtraLifeConsumed.itemIndex, itemCount2);
				if (inventory.infusionBonus > OwnerCharacterMaster.inventory.infusionBonus)
				{
					OwnerCharacterMaster.inventory.infusionBonus = inventory.infusionBonus;
					OwnerCharacterMaster.GetBody().RecalculateStats();
				}
				else
				{
					inventory.infusionBonus = OwnerCharacterMaster.inventory.infusionBonus;
					component.GetBody().RecalculateStats();
				}
			}
		}

		private void CharacterBodyOnUpdateBuffs(orig_UpdateBuffs orig, CharacterBody self, float deltaTime)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_01d7: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_01f7: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, deltaTime);
			if ((Object)(object)((Component)this).gameObject == (Object)null)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			CharacterMaster component = ((Component)this).gameObject.GetComponent<CharacterMaster>();
			if ((Object)(object)component == (Object)null || !Object.op_Implicit((Object)(object)component) || (Object)(object)component.GetBody() == (Object)null || !Object.op_Implicit((Object)(object)component.GetBody()) || (Object)(object)OwnerCharacterMaster == (Object)null || !Object.op_Implicit((Object)(object)OwnerCharacterMaster) || (Object)(object)OwnerCharacterMaster.GetBody() == (Object)null || !Object.op_Implicit((Object)(object)OwnerCharacterMaster.GetBody()))
			{
				return;
			}
			BuffIndex[] buffs = Buffs;
			foreach (BuffIndex val in buffs)
			{
				CharacterMaster component2 = ((Component)this).gameObject.GetComponent<CharacterMaster>();
				if (OwnerCharacterMaster.GetBody().HasBuff(val))
				{
					if (val == Buffs.AffixBlue.buffIndex || val == Buffs.AffixWhite.buffIndex || val == Buffs.AffixRed.buffIndex || val == Buffs.AffixPoison.buffIndex || val == Buffs.NoCooldowns.buffIndex)
					{
						if (component2.GetBody().HasBuff(val))
						{
							continue;
						}
						foreach (TimedBuff timedBuff in OwnerCharacterMaster.GetBody().timedBuffs)
						{
							if (timedBuff.buffIndex == val)
							{
								float timer = timedBuff.timer;
								if (!(timer <= 1f))
								{
									component2.GetBody().AddTimedBuff(val, timer);
								}
								break;
							}
						}
					}
					else if (val != Buffs.NoCooldowns.buffIndex)
					{
						component2.GetBody().AddBuff(val);
					}
				}
				else
				{
					if (!component2.GetBody().HasBuff(val))
					{
						continue;
					}
					if (val == Buffs.AffixBlue.buffIndex || val == Buffs.AffixWhite.buffIndex || val == Buffs.AffixRed.buffIndex || val == Buffs.AffixPoison.buffIndex || val == Buffs.NoCooldowns.buffIndex)
					{
						if (OwnerCharacterMaster.GetBody().HasBuff(val))
						{
							continue;
						}
						foreach (TimedBuff timedBuff2 in component2.GetBody().timedBuffs)
						{
							if (timedBuff2.buffIndex == val)
							{
								float timer2 = timedBuff2.timer;
								if (!(timer2 <= 1f))
								{
									OwnerCharacterMaster.GetBody().AddTimedBuff(val, timer2);
								}
								break;
							}
						}
					}
					else
					{
						component2.GetBody().RemoveBuff(val);
					}
				}
			}
		}

		private void OnDisable()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			OwnerCharacterMaster.inventory.onInventoryChanged -= UpdateInventory;
			CharacterBody.UpdateBuffs -= new hook_UpdateBuffs(CharacterBodyOnUpdateBuffs);
			AkSoundEngine.StopPlayingID(SoundGunId);
			Object.Destroy((Object)(object)this);
		}
	}
	internal static class TurretHooks
	{
		internal struct SendRecalcStat : INetMessage, ISerializableObject
		{
			internal NetworkInstanceId NetId;

			public void Serialize(NetworkWriter writer)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(NetId);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				NetId = reader.ReadNetworkId();
			}

			public void OnReceived()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = NetworkServer.FindLocalObject(NetId);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.GetComponent<CharacterBody>().RecalculateStats();
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__BaseStateOnEnterCallerModifier;

			public static Manipulator <1>__TurretFiringHook;

			public static hook_OnEnter <2>__TurretFiringRocket;

			public static hook_FixedUpdate <3>__OnPlaceTurretSendTurretType;

			public static Manipulator <4>__SendTurretColorHook;

			public static Manipulator <5>__TurretAddOwnerAndCustomColorHookAndTurretTypeHandler;

			public static hook_OnArrival <6>__InfusionStackSharedTurret;

			public static hook_AddDeployable <7>__AddBATComponentOnAddDeployableHook;

			public static hook_SetCurrentPing <8>__ChangeTurretTypeOnPing;
		}

		private static void BaseStateOnEnterCaller(FireGauss self)
		{
		}

		private static void BaseStateOnEnterCallerModifier(ILContext il)
		{
			//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_0007: 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)
			ILCursor val = new ILCursor(il);
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Call, (MethodBase)typeof(BaseState).GetMethod("OnEnter", (BindingFlags)(-1)));
		}

		internal static void Init()
		{
			//IL_0030: 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_0030: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0086: 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_0091: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			MethodInfo? method = typeof(TurretHooks).GetMethod("BaseStateOnEnterCaller", (BindingFlags)(-1));
			object obj = <>O.<0>__BaseStateOnEnterCallerModifier;
			if (obj == null)
			{
				Manipulator val = BaseStateOnEnterCallerModifier;
				<>O.<0>__BaseStateOnEnterCallerModifier = val;
				obj = (object)val;
			}
			new ILHook((MethodBase)method, (Manipulator)obj);
			object obj2 = <>O.<1>__TurretFiringHook;
			if (obj2 == null)
			{
				Manipulator val2 = TurretFiringHook;
				<>O.<1>__TurretFiringHook = val2;
				obj2 = (object)val2;
			}
			FireGauss.OnEnter += (Manipulator)obj2;
			object obj3 = <>O.<2>__TurretFiringRocket;
			if (obj3 == null)
			{
				hook_OnEnter val3 = TurretFiringRocket;
				<>O.<2>__TurretFiringRocket = val3;
				obj3 = (object)val3;
			}
			FireGauss.OnEnter += (hook_OnEnter)obj3;
			object obj4 = <>O.<3>__OnPlaceTurretSendTurretType;
			if (obj4 == null)
			{
				hook_FixedUpdate val4 = OnPlaceTurretSendTurretType;
				<>O.<3>__OnPlaceTurretSendTurretType = val4;
				obj4 = (object)val4;
			}
			PlaceTurret.FixedUpdate += (hook_FixedUpdate)obj4;
			object obj5 = <>O.<4>__SendTurretColorHook;
			if (obj5 == null)
			{
				Manipulator val5 = SendTurretColorHook;
				<>O.<4>__SendTurretColorHook = val5;
				obj5 = (object)val5;
			}
			CharacterBody.SendConstructTurret += (Manipulator)obj5;
			object obj6 = <>O.<5>__TurretAddOwnerAndCustomColorHookAndTurretTypeHandler;
			if (obj6 == null)
			{
				Manipulator val6 = TurretAddOwnerAndCustomColorHookAndTurretTypeHandler;
				<>O.<5>__TurretAddOwnerAndCustomColorHookAndTurretTypeHandler = val6;
				obj6 = (object)val6;
			}
			CharacterBody.HandleConstructTurret += (Manipulator)obj6;
			object obj7 = <>O.<6>__InfusionStackSharedTurret;
			if (obj7 == null)
			{
				hook_OnArrival val7 = InfusionStackSharedTurret;
				<>O.<6>__InfusionStackSharedTurret = val7;
				obj7 = (object)val7;
			}
			InfusionOrb.OnArrival += (hook_OnArrival)obj7;
			object obj8 = <>O.<7>__AddBATComponentOnAddDeployableHook;
			if (obj8 == null)
			{
				hook_AddDeployable val8 = AddBATComponentOnAddDeployableHook;
				<>O.<7>__AddBATComponentOnAddDeployableHook = val8;
				obj8 = (object)val8;
			}
			CharacterMaster.AddDeployable += (hook_AddDeployable)obj8;
			object obj9 = <>O.<8>__ChangeTurretTypeOnPing;
			if (obj9 == null)
			{
				hook_SetCurrentPing val9 = ChangeTurretTypeOnPing;
				<>O.<8>__ChangeTurretTypeOnPing = val9;
				obj9 = (object)val9;
			}
			PingerController.SetCurrentPing += (hook_SetCurrentPing)obj9;
		}

		private static void TurretFiringHook(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0028: 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_0054: 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_0120: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: 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_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			TurretType index = TurretType.Default;
			BadAssTurret currentTurret = null;
			PlaySoundMsg soundMsg = default(PlaySoundMsg);
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Call, (MethodBase)Reflection.GetMethodCached(typeof(EntityState), "get_characterBody"));
			val.Emit(OpCodes.Callvirt, (MethodBase)Reflection.GetMethodCached(typeof(CharacterBody), "get_master"));
			val.EmitDelegate<Action<CharacterMaster>>((Action<CharacterMaster>)delegate(CharacterMaster characterMaster)
			{
				currentTurret = ((Component)characterMaster).GetComponent<BadAssTurret>();
				if ((Object)(object)currentTurret != (Object)null)
				{
					StopSoundMsg stopSoundMsg = default(StopSoundMsg);
					stopSoundMsg.soundPlayId = currentTurret.SoundGunId;
					NetMessageExtensions.Send((INetMessage)(object)stopSoundMsg, (NetworkDestination)1);
					index = currentTurret.Index;
				}
			});
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdsfld<FireGauss>(i, "attackSoundString")
			});
			val.Remove();
			val.EmitDelegate<Func<string>>((Func<string>)delegate
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				if (index == TurretType.Minigun)
				{
					soundMsg.NetId = ((Component)currentTurret).gameObject.GetComponent<NetworkIdentity>().netId;
					soundMsg.SoundName = "Minigun_Turret_Shot_Play_69";
					NetMessageExtensions.Send((INetMessage)(object)soundMsg, (NetworkDestination)1);
					return "";
				}
				if (index == TurretType.Railgun)
				{
					soundMsg.NetId = ((Component)currentTurret).gameObject.GetComponent<NetworkIdentity>().netId;
					soundMsg.SoundName = "Railgun_Turret_Shot_Play_69";
					NetMessageExtensions.Send((INetMessage)(object)soundMsg, (NetworkDestination)1);
					return "";
				}
				return FireGauss.attackSoundString;
			});
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCall<EntityState>(i, "get_gameObject")
			});
			int index2 = val.Index;
			val.Index = index2 + 1;
			val.Emit(OpCodes.Ldstr, "Turret_Attack_Speed");
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Ldfld, Reflection.GetFieldCached(typeof(BaseState), "attackSpeedStat"));
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCall(i, (MethodBase)Reflection.GetMethodCached(typeof(Util), "PlaySound", new Type[2]
				{
					typeof(string),
					typeof(GameObject)
				}))
			});
			val.Remove();
			val.Emit(OpCodes.Call, (MethodBase)Reflection.GetMethodCached(typeof(Util), "PlaySound", new Type[4]
			{
				typeof(string),
				typeof(GameObject),
				typeof(string),
				typeof(float)
			}));
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdfld<FireGauss>(i, "duration")
			});
			index2 = val.Index;
			val.Index = index2 + 1;
			val.EmitDelegate<Func<float, float>>((Func<float, float>)((float duration) => (index == TurretType.Minigun) ? 1E-07f : duration));
			val.GotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdsfld<FireGauss>(i, "tracerEffectPrefab"),
				(Instruction i) => ILPatternMatchingExt.MatchStfld<BulletAttack>(i, "tracerEffectPrefab")
			});
			index2 = val.Index;
			val.Index = index2 + 1;
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<GameObject, FireGauss, GameObject>>((Func<GameObject, FireGauss, GameObject>)delegate(GameObject tracerEffectPrefab, FireGauss fireGaussInstance)
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				if (index == TurretType.Minigun)
				{
					tracerEffectPrefab = BaeAssets.MiniGunPrefab;
				}
				if (index == TurretType.Railgun)
				{
					tracerEffectPrefab = null;
					Transform turretMuzzle = GetTurretMuzzle(((EntityState)fireGaussInstance).gameObject);
					GameObject prefabEngiTurretRailGunPrefab = BaeAssets.PrefabEngiTurretRailGunPrefab;
					Vector3 position = turretMuzzle.position;
					Ray aimRay = ((BaseState)fireGaussInstance).GetAimRay();
					NetworkServer.Spawn(Object.Instantiate<GameObject>(prefabEngiTurretRailGunPrefab, position, Quaternion.LookRotation(((Ray)(ref aimRay)).direction, ((EntityState)fireGaussInstance).transform.up)));
				}
				return tracerEffectPrefab;
			});
			val.Index += 2;
			val.Emit(OpCodes.Ldc_R4, Configuration.RailgunTurretMaxDistanceTargeting.Value + 1f);
			val.Emit(OpCodes.Callvirt, (MethodBase)Reflection.GetMethodCached(typeof(BulletAttack), "set_maxDistance"));
			val.Emit(OpCodes.Dup);
			val.Emit(OpCodes.Ldc_R4, 0f);
			val.EmitDelegate<Func<float, float>>((Func<float, float>)delegate(float spread)
			{
				if (index == TurretType.Minigun)
				{
					spread = 1f;
				}
				return spread;
			});
			val.Emit(OpCodes.Stfld, Reflection.GetFieldCached(typeof(BulletAttack), "spreadPitchScale"));
			val.Emit(OpCodes.Dup);
			val.Emit(OpCodes.Ldc_R4, 0f);
			val.EmitDelegate<Func<float, float>>((Func<float, float>)delegate(float spread)
			{
				if (index == TurretType.Minigun)
				{
					spread = 1f;
				}
				return spread;
			});
			val.Emit(OpCodes.Stfld, Reflection.GetFieldCached(typeof(BulletAttack), "spreadYawScale"));
			val.Emit(OpCodes.Dup);
			val.Emit(OpCodes.Ldc_R4, 1f);
			val.EmitDelegate<Func<float, float>>((Func<float, float>)delegate(float procCoefficient)
			{
				if (index == TurretType.Minigun)
				{
					procCoefficient = Configuration.MinigunTurretProcCoefficient.Value;
				}
				return procCoefficient;
			});
			val.Emit(OpCodes.Stfld, Reflection.GetFieldCached(typeof(BulletAttack), "procCoefficient"));
			val.Emit(OpCodes.Dup);
			val.GotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdsfld<FireGauss>(i, "damageCoefficient")
			});
			val.EmitDelegate<Func<float, float>>((Func<float, float>)delegate(float damageCoefficient)
			{
				if (index == TurretType.Default)
				{
					damageCoefficient = Configuration.DefaultTurretDamageCoefficient.Value;
				}
				else if (index == TurretType.Minigun)
				{
					damageCoefficient = Configuration.MinigunTurretDamageCoefficient.Value;
				}
				else if (index == TurretType.Railgun)
				{
					damageCoefficient = Configuration.RailgunTurretDamageCoefficient.Value;
				}
				else if (index == TurretType.Shotgun)
				{
					damageCoefficient = Configuration.ShotgunTurretDamageCoefficient.Value;
				}
				return damageCoefficient;
			});
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt<BulletAttack>(i, "Fire")
			});
			val.EmitDelegate<Func<BulletAttack, BulletAttack>>((Func<BulletAttack, BulletAttack>)delegate(BulletAttack bulletAttack)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				if (index == TurretType.Railgun)
				{
					bulletAttack.stopperMask = ((LayerIndex)(ref LayerIndex.world)).mask;
					bulletAttack.hitEffectPrefab = null;
				}
				return bulletAttack;
			});
			static Transform GetTurretMuzzle(GameObject obj)
			{
				ModelLocator component = obj.GetComponent<ModelLocator>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.modelTransform))
				{
					ChildLocator component2 = ((Component)component.modelTransform).GetComponent<ChildLocator>();
					if (Object.op_Implicit((Object)(object)component2))
					{
						int num = component2.FindChildIndex("Muzzle");
						component2.FindChild(num);
						return component2.FindChild(num);
					}
				}
				return null;
			}
		}

		private static void TurretFiringRocket(orig_OnEnter orig, FireGauss self)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown resul