Decompiled source of EngiTurretEquipment v1.0.1

plugins/EngiTurretEquipment/EngiTurretEquipment.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using EngiTurretEquipment.Components;
using EngiTurretEquipment.Equipment;
using EngiTurretEquipment.Modules;
using IL.RoR2.Projectile;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2.Navigation;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EngiTurretEquipment")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EngiTurretEquipment")]
[assembly: AssemblyTitle("EngiTurretEquipment")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace EngiTurretEquipment
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Moffein.EngiTurretEquipment", "EngiTurretEquipment", "1.0.0")]
	public class EngiTurretEquipmentPlugin : BaseUnityPlugin
	{
		public static PluginInfo PInfo;

		public static List<EquipmentBase> Equipments = new List<EquipmentBase>();

		public static Action onFinishScanning;

		internal void Awake()
		{
			PInfo = ((BaseUnityPlugin)this).Info;
			new PluginContentPack().Initialize();
			Assets.LoadAssetBundle();
			LanguageOverrides.Initialize();
			AddToAssembly();
		}

		private void AddToAssembly()
		{
			IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(EquipmentBase))
				select type;
			List<string> list = new List<string>();
			List<EquipmentBase> list2 = new List<EquipmentBase>();
			foreach (Type item in enumerable)
			{
				EquipmentBase equipmentBase = (EquipmentBase)Activator.CreateInstance(item);
				if (equipmentBase.ParentEquipmentName != null)
				{
					list2.Add(equipmentBase);
				}
				else if (ValidateEquipment(equipmentBase, Equipments))
				{
					equipmentBase.Init(((BaseUnityPlugin)this).Config);
					list.Add(equipmentBase.EquipmentName);
				}
			}
			foreach (EquipmentBase item2 in list2)
			{
				if (list.Contains(item2.ParentEquipmentName))
				{
					item2.Init(((BaseUnityPlugin)this).Config);
				}
			}
			onFinishScanning?.Invoke();
		}

		public bool ValidateEquipment(EquipmentBase equipment, List<EquipmentBase> equipmentList)
		{
			string text = "Should this equipment appear in runs?";
			if (equipment.Unfinished)
			{
				text = "UNFINISHED! " + text;
			}
			if (((BaseUnityPlugin)this).Config.Bind<bool>(equipment.ConfigCategory, "Enable Equipment?", true, text).Value)
			{
				equipmentList.Add(equipment);
				return true;
			}
			return false;
		}
	}
	internal static class PluginUtils
	{
		internal static bool SetAddressableEntityStateField(string fullEntityStatePath, string fieldName, string value)
		{
			//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)
			EntityStateConfiguration val = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)fullEntityStatePath).WaitForCompletion();
			for (int i = 0; i < val.serializedFieldsCollection.serializedFields.Length; i++)
			{
				if (val.serializedFieldsCollection.serializedFields[i].fieldName == fieldName)
				{
					val.serializedFieldsCollection.serializedFields[i].fieldValue.stringValue = value;
					return true;
				}
			}
			return false;
		}
	}
}
namespace EngiTurretEquipment.Modules
{
	public static class Assets
	{
		public static AssetBundle mainAssetBundle;

		internal static void LoadAssetBundle()
		{
			if ((Object)(object)mainAssetBundle == (Object)null)
			{
				using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EngiTurretEquipment.engiturretequipmentbundle"))
				{
					mainAssetBundle = AssetBundle.LoadFromStream(stream);
				}
			}
		}
	}
	internal class LanguageOverrides
	{
		public struct ReplacementToken
		{
			public string assignedToken;

			public string formatToken;

			public object[] args;
		}

		public const string LanguageTokenPrefix = "ENGITURRETEQUIPMENT_";

		public const string LanguageTokenPrefixArtifact = "ENGITURRETEQUIPMENT_ARTIFACT_";

		public const string LanguageTokenPrefixItem = "ENGITURRETEQUIPMENT_ITEM_";

		public const string LanguageTokenPrefixEquipment = "ENGITURRETEQUIPMENT_EQUIPMENT_";

		public const string LanguageTokenPrefixEliteEquipment = "ENGITURRETEQUIPMENT_ELITE_EQUIPMENT_";

		public const string LanguageTokenPrefixElite = "ENGITURRETEQUIPMENT_ELITE_";

		public const string LanguageTokenPrefixBuffs = "ENGITURRETEQUIPMENT_BUFF_";

		public static List<ReplacementToken> replacementTokens = new List<ReplacementToken>();

		public static List<ReplacementToken> postReplacementTokens = new List<ReplacementToken>();

		public static List<Type> configEntries = new List<Type>();

		public static Dictionary<string, string> logbookTokenOverrideDict = new Dictionary<string, string>();

		public static void DeferToken(string token, params object[] args)
		{
			replacementTokens.Add(new ReplacementToken
			{
				assignedToken = token,
				formatToken = token,
				args = args
			});
		}

		public static void DeferLateTokens(string token, params object[] args)
		{
			postReplacementTokens.Add(new ReplacementToken
			{
				assignedToken = token,
				formatToken = token,
				args = args
			});
		}

		public static void DeferUniqueToken(string assignedToken, string formatToken, params object[] args)
		{
			replacementTokens.Add(new ReplacementToken
			{
				assignedToken = assignedToken,
				formatToken = formatToken,
				args = args
			});
		}

		public static void DeferLateUniqueTokens(string assignedToken, string formatToken, params object[] args)
		{
			postReplacementTokens.Add(new ReplacementToken
			{
				assignedToken = assignedToken,
				formatToken = formatToken,
				args = args
			});
		}

		public static void Initialize()
		{
			Language.collectLanguageRootFolders += CollectLanguageRootFolders;
			Language.onCurrentLanguageChanged += Language_onCurrentLanguageChanged;
		}

		private static void Language_onCurrentLanguageChanged()
		{
			Language currentLanguage = Language.currentLanguage;
			foreach (ReplacementToken replacementToken in replacementTokens)
			{
				string localizedFormattedStringByToken = currentLanguage.GetLocalizedFormattedStringByToken(replacementToken.formatToken, replacementToken.args);
				currentLanguage.SetStringByToken(replacementToken.assignedToken, localizedFormattedStringByToken);
			}
			foreach (ReplacementToken postReplacementToken in postReplacementTokens)
			{
				List<string> list = new List<string>();
				object[] args = postReplacementToken.args;
				foreach (object obj in args)
				{
					list.Add(currentLanguage.GetLocalizedStringByToken(obj.ToString()));
					string text = postReplacementToken.formatToken;
					if (postReplacementToken.assignedToken == null || postReplacementToken.assignedToken != postReplacementToken.formatToken)
					{
						text = postReplacementToken.assignedToken;
					}
					string formatToken = postReplacementToken.formatToken;
					object[] array = list.ToArray();
					string localizedFormattedStringByToken2 = currentLanguage.GetLocalizedFormattedStringByToken(formatToken, array);
					currentLanguage.SetStringByToken(text, localizedFormattedStringByToken2);
				}
			}
		}

		private static void CollectLanguageRootFolders(List<string> folders)
		{
			folders.Add(Path.Combine(Path.GetDirectoryName(EngiTurretEquipmentPlugin.PInfo.Location), "Language"));
		}
	}
	public class PluginContentPack : IContentPackProvider
	{
		[CompilerGenerated]
		private sealed class <FinalizeAsync>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public FinalizeAsyncArgs args;

			public PluginContentPack <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FinalizeAsync>d__10(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				args.ReportProgress(1f);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <GenerateContentPackAsync>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GetContentPackAsyncArgs args;

			public PluginContentPack <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GenerateContentPackAsync>d__11(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				ContentPack.Copy(content, args.output);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadStaticContentAsync>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public LoadStaticContentAsyncArgs args;

			public PluginContentPack <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LoadStaticContentAsync>d__12(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				content.networkedObjectPrefabs.Add(networkedObjectPrefabs.ToArray());
				content.bodyPrefabs.Add(bodyPrefabs.ToArray());
				content.masterPrefabs.Add(masterPrefabs.ToArray());
				content.equipmentDefs.Add(equipmentDefs.ToArray());
				content.projectilePrefabs.Add(projectilePrefabs.ToArray());
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static ContentPack content = new ContentPack();

		public static List<GameObject> networkedObjectPrefabs = new List<GameObject>();

		public static List<GameObject> bodyPrefabs = new List<GameObject>();

		public static List<GameObject> masterPrefabs = new List<GameObject>();

		public static List<GameObject> projectilePrefabs = new List<GameObject>();

		public static List<EquipmentDef> equipmentDefs = new List<EquipmentDef>();

		public string identifier => "EngiTurretEquipment.content";

		internal void Initialize()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
		}

		private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
		{
			addContentPackProvider.Invoke((IContentPackProvider)(object)this);
		}

		[IteratorStateMachine(typeof(<FinalizeAsync>d__10))]
		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FinalizeAsync>d__10(0)
			{
				<>4__this = this,
				args = args
			};
		}

		[IteratorStateMachine(typeof(<GenerateContentPackAsync>d__11))]
		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateContentPackAsync>d__11(0)
			{
				<>4__this = this,
				args = args
			};
		}

		[IteratorStateMachine(typeof(<LoadStaticContentAsync>d__12))]
		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadStaticContentAsync>d__12(0)
			{
				<>4__this = this,
				args = args
			};
		}
	}
}
namespace EngiTurretEquipment.Equipment
{
	public abstract class EquipmentBase<T> : EquipmentBase where T : EquipmentBase<T>
	{
		public static T Instance { get; private set; }

		public EquipmentBase()
		{
			if (Instance != null)
			{
				throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting EquipmentBoilerplate/Equipment was instantiated twice");
			}
			Instance = this as T;
		}
	}
	public abstract class EquipmentBase
	{
		public EquipmentDef EquipmentDef;

		public GameObject ItemBodyModelPrefab;

		public abstract string EquipmentName { get; }

		public abstract string EquipmentLangTokenName { get; }

		public virtual string EquipmentPickupToken => "ENGITURRETEQUIPMENT_EQUIPMENT_" + EquipmentLangTokenName + "_PICKUP";

		public virtual object[] EquipmentPickupDescParams { get; }

		public virtual string EquipmentDescriptionToken => "ENGITURRETEQUIPMENT_EQUIPMENT_" + EquipmentLangTokenName + "_DESCRIPTION";

		public virtual object[] EquipmentFullDescriptionParams { get; }

		public virtual string EquipmentUniquePickupToken { get; }

		public virtual string EquipmentUniqueDescriptionToken { get; }

		public abstract GameObject EquipmentModel { get; }

		public abstract Sprite EquipmentIcon { get; }

		public virtual bool AppearsInSinglePlayer { get; } = true;


		public virtual bool AppearsInMultiPlayer { get; } = true;


		public virtual bool CanDrop { get; } = true;


		public virtual float Cooldown { get; } = 60f;


		public virtual bool EnigmaCompatible { get; } = true;


		public virtual bool IsBoss { get; } = false;


		public virtual bool IsLunar { get; } = false;


		public virtual bool CanBeRandomlyTriggered { get; } = true;


		public virtual EquipmentBase DependentEquipment { get; } = null;


		public virtual string ParentEquipmentName { get; } = null;


		public virtual ExpansionDef ExpansionDef { get; }

		public virtual bool Unfinished { get; } = false;


		public string ConfigCategory => "Equipment: " + EquipmentName;

		public abstract ItemDisplayRuleDict CreateItemDisplayRules();

		public virtual void Init(ConfigFile config)
		{
			CreateConfig(config);
			CreateAssets(config);
			CreateLang();
			CreateEquipment();
			Hooks();
		}

		public virtual void CreateAssets(ConfigFile config)
		{
		}

		protected virtual void CreateConfig(ConfigFile config)
		{
		}

		protected virtual void CreateCraftableDef()
		{
		}

		protected virtual void CreateLang()
		{
			object[] equipmentPickupDescParams = EquipmentPickupDescParams;
			bool flag = equipmentPickupDescParams != null && equipmentPickupDescParams.Length != 0;
			object[] equipmentFullDescriptionParams = EquipmentFullDescriptionParams;
			bool flag2 = equipmentFullDescriptionParams != null && equipmentFullDescriptionParams.Length != 0;
			if (flag2 && flag)
			{
				return;
			}
			if (flag)
			{
				if (Utility.IsNullOrWhiteSpace(EquipmentUniquePickupToken))
				{
					LanguageOverrides.DeferToken(EquipmentPickupToken, EquipmentPickupDescParams);
				}
				else
				{
					LanguageOverrides.DeferUniqueToken(EquipmentUniquePickupToken, EquipmentPickupToken, EquipmentPickupDescParams);
				}
			}
			if (flag2)
			{
				if (Utility.IsNullOrWhiteSpace(EquipmentUniqueDescriptionToken))
				{
					LanguageOverrides.DeferToken(EquipmentDescriptionToken, EquipmentFullDescriptionParams);
				}
				else
				{
					LanguageOverrides.DeferUniqueToken(EquipmentUniqueDescriptionToken, EquipmentDescriptionToken, EquipmentFullDescriptionParams);
				}
			}
		}

		protected void CreateEquipment()
		{
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			string text = "ENGITURRETEQUIPMENT_EQUIPMENT_";
			EquipmentDef = ScriptableObject.CreateInstance<EquipmentDef>();
			((Object)EquipmentDef).name = text + EquipmentLangTokenName;
			EquipmentDef.nameToken = text + EquipmentLangTokenName + "_NAME";
			EquipmentDef.pickupToken = EquipmentPickupToken;
			EquipmentDef.descriptionToken = EquipmentDescriptionToken;
			EquipmentDef.loreToken = text + EquipmentLangTokenName + "_LORE";
			EquipmentDef.pickupModelPrefab = EquipmentModel;
			EquipmentDef.pickupIconSprite = EquipmentIcon;
			EquipmentDef.appearsInSinglePlayer = AppearsInSinglePlayer;
			EquipmentDef.appearsInMultiPlayer = AppearsInMultiPlayer;
			EquipmentDef.canDrop = CanDrop;
			EquipmentDef.cooldown = Cooldown;
			EquipmentDef.enigmaCompatible = EnigmaCompatible;
			EquipmentDef.isBoss = IsBoss;
			EquipmentDef.isLunar = IsLunar;
			EquipmentDef.canBeRandomlyTriggered = CanBeRandomlyTriggered;
			if (Object.op_Implicit((Object)(object)ExpansionDef))
			{
				EquipmentDef.requiredExpansion = ExpansionDef;
			}
			if (IsLunar)
			{
				EquipmentDef.colorIndex = (ColorIndex)4;
			}
			ItemAPI.Add(new CustomEquipment(EquipmentDef, CreateItemDisplayRules()));
			EquipmentSlot.PerformEquipmentAction += new hook_PerformEquipmentAction(PerformEquipmentAction);
		}

		private bool PerformEquipmentAction(orig_PerformEquipmentAction orig, EquipmentSlot self, EquipmentDef equipmentDef)
		{
			if ((Object)(object)equipmentDef == (Object)(object)EquipmentDef)
			{
				return ActivateEquipment(self);
			}
			return orig.Invoke(self, equipmentDef);
		}

		protected abstract bool ActivateEquipment(EquipmentSlot slot);

		public virtual void Hooks()
		{
		}
	}
	public class StationaryTurret : EquipmentBase<StationaryTurret>
	{
		private static GameObject _equipmentModel;

		public static GameObject bodyPrefab;

		public static GameObject masterPrefab;

		public static GameObject projectilePrefab;

		public static CharacterSpawnCard spawnCard;

		public static float _cooldown;

		public static float baseHealth;

		public static float baseDamage;

		public static float baseRegen;

		public static int maxActive;

		public override string EquipmentName => "Stationary Turret";

		public override string EquipmentLangTokenName => "STATIONARY";

		public override GameObject EquipmentModel => GetEquipmentModel();

		public override Sprite EquipmentIcon => Assets.mainAssetBundle.LoadAsset<Sprite>("texEngiTurretEquipmentIcon.png");

		public override float Cooldown => _cooldown;

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			ItemDisplayRuleDict val = new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
			GameObject equipmentModel = EquipmentModel;
			if (!Object.op_Implicit((Object)(object)equipmentModel))
			{
				return val;
			}
			val.Add("EquipmentDroneBody", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = EquipmentModel,
					ruleType = (ItemDisplayRuleType)0,
					childName = "GunBarrelBase",
					localPos = new Vector3(0f, 0f, 2.3f),
					localAngles = new Vector3(270f, 0f, 0f),
					localScale = new Vector3(0.5f, 0.5f, 0.5f)
				}
			});
			return val;
		}

		protected override bool ActivateEquipment(EquipmentSlot slot)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody characterBody = slot.characterBody;
			CharacterMaster val = (((Object)(object)characterBody != (Object)null) ? characterBody.master : null);
			if (!Object.op_Implicit((Object)(object)val) || val.IsDeployableLimited((DeployableSlot)14))
			{
				return false;
			}
			Ray aimRay = slot.GetAimRay();
			Quaternion rotation = Quaternion.LookRotation(((Ray)(ref aimRay)).direction);
			FireProjectileInfo val2 = default(FireProjectileInfo);
			val2.projectilePrefab = projectilePrefab;
			val2.crit = slot.characterBody.RollCrit();
			val2.damage = 0f;
			val2.damageColorIndex = (DamageColorIndex)3;
			val2.force = 0f;
			val2.owner = ((Component)slot).gameObject;
			val2.position = ((Ray)(ref aimRay)).origin;
			val2.rotation = rotation;
			FireProjectileInfo val3 = val2;
			ProjectileManager.instance.FireProjectile(val3);
			return true;
		}

		protected override void CreateConfig(ConfigFile config)
		{
			base.CreateConfig(config);
			baseHealth = config.Bind<float>("Stationary Turret", "Base Health", 65f, (ConfigDescription)null).Value;
			baseDamage = config.Bind<float>("Stationary Turret", "Base Damage", 8f, (ConfigDescription)null).Value;
			baseRegen = config.Bind<float>("Stationary Turret", "Base Regen", 1f, (ConfigDescription)null).Value;
			_cooldown = config.Bind<float>("Stationary Turret", "Cooldown", 90f, (ConfigDescription)null).Value;
			maxActive = config.Bind<int>("Stationary Turret", "Max Active with Extra Equip Slots", -1, (ConfigDescription)null).Value;
		}

		public override void CreateAssets(ConfigFile config)
		{
			base.CreateAssets(config);
			CreateBodyPrefab();
			CreateMasterPrefab();
			CreateSpawnCard();
			CreateEquipmentModel();
			CreateProjectilePrefab();
		}

		private void CreateSpawnCard()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)masterPrefab))
			{
				CreateMasterPrefab();
			}
			if (!Object.op_Implicit((Object)(object)spawnCard))
			{
				spawnCard = ScriptableObject.CreateInstance<CharacterSpawnCard>();
				((SpawnCard)spawnCard).directorCreditCost = 35;
				((SpawnCard)spawnCard).hullSize = (HullClassification)0;
				((SpawnCard)spawnCard).nodeGraphType = (GraphType)0;
				((SpawnCard)spawnCard).prefab = masterPrefab;
				((SpawnCard)spawnCard).sendOverNetwork = true;
				((SpawnCard)spawnCard).occupyPosition = false;
				((SpawnCard)spawnCard).forbiddenFlags = (NodeFlags)4;
				spawnCard.inventoryItemCopyFilter = Inventory.DefaultItemCopyFilter;
				((Object)spawnCard).name = "cscMoffeinETEStationaryTurret";
			}
		}

		private void CreateProjectilePrefab()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)spawnCard))
			{
				CreateSpawnCard();
			}
			if (!Object.op_Implicit((Object)(object)projectilePrefab))
			{
				GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/MinorConstructOnKill/MinorConstructOnKillProjectile.prefab").WaitForCompletion(), "MoffeinETE_StationaryTurretProjectile", true);
				val.GetComponent<ProjectileController>().ghostPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/Drifter/DrifterToolbotCrateGhost.prefab").WaitForCompletion();
				ProjectileSpawnMaster component = val.GetComponent<ProjectileSpawnMaster>();
				component.spawnCard = spawnCard;
				component.deployableSlot = (DeployableSlot)35;
				PluginContentPack.projectilePrefabs.Add(val);
				projectilePrefab = val;
				ProjectileSpawnMaster.SpawnMaster += new Manipulator(ProjectileSpawnMaster_SpawnMaster);
			}
		}

		private void ProjectileSpawnMaster_SpawnMaster(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<DirectorCore>(x, "TrySpawnObject")
			}))
			{
				val.EmitDelegate<Func<DirectorSpawnRequest, DirectorSpawnRequest>>((Func<DirectorSpawnRequest, DirectorSpawnRequest>)delegate(DirectorSpawnRequest req)
				{
					//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
					//IL_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_00c3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)(object)req.spawnCard == (Object)(object)spawnCard && (Object)(object)req.summonerBodyObject != (Object)null)
					{
						CharacterBody component = req.summonerBodyObject.GetComponent<CharacterBody>();
						if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
						{
							SpawnCard obj = req.spawnCard;
							CharacterSpawnCard val2 = (CharacterSpawnCard)(object)((obj is CharacterSpawnCard) ? obj : null);
							CharacterSpawnCard val3 = ScriptableObject.CreateInstance<CharacterSpawnCard>();
							((SpawnCard)val3).prefab = ((SpawnCard)spawnCard).prefab;
							((SpawnCard)val3).occupyPosition = ((SpawnCard)spawnCard).occupyPosition;
							((SpawnCard)val3).sendOverNetwork = ((SpawnCard)spawnCard).sendOverNetwork;
							((SpawnCard)val3).hullSize = ((SpawnCard)spawnCard).hullSize;
							((SpawnCard)val3).nodeGraphType = ((SpawnCard)spawnCard).nodeGraphType;
							((SpawnCard)val3).forbiddenFlags = ((SpawnCard)spawnCard).forbiddenFlags;
							val3.inventoryItemCopyFilter = spawnCard.inventoryItemCopyFilter;
							val3.inventoryToCopy = component.inventory;
							req.spawnCard = (SpawnCard)(object)val3;
						}
						req.ignoreTeamMemberLimit = true;
					}
					return req;
				});
			}
			else
			{
				Debug.LogError((object)"EngiTurretEquipment: Stationary Turret ProjectileSpawnMaster_SpawnMaster IL hook failed.");
			}
		}

		private void CreateBodyPrefab()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)bodyPrefab))
			{
				GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Engi/EngiTurretBody.prefab").WaitForCompletion(), "MoffeinETE_StationaryTurretBody", true);
				CharacterBody component = val.GetComponent<CharacterBody>();
				component.baseMaxHealth = baseHealth;
				component.levelMaxHealth = baseHealth * 0.3f;
				component.baseDamage = baseDamage;
				component.levelDamage = baseDamage * 0.2f;
				component.baseRegen = baseRegen;
				component.levelRegen = baseRegen * 0.2f;
				ModelLocator component2 = val.GetComponent<ModelLocator>();
				component2.normalizeToFloor = true;
				val.AddComponent<RegisterStationaryTurret>();
				PluginContentPack.bodyPrefabs.Add(val);
				bodyPrefab = val;
			}
		}

		private void CreateMasterPrefab()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)masterPrefab))
			{
				if (!Object.op_Implicit((Object)(object)bodyPrefab))
				{
					CreateBodyPrefab();
				}
				GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Engi/EngiTurretMaster.prefab").WaitForCompletion(), "MoffeinETE_StationaryTurretMaster", true);
				CharacterMaster component = val.GetComponent<CharacterMaster>();
				component.bodyPrefab = bodyPrefab;
				PluginContentPack.masterPrefabs.Add(val);
				masterPrefab = val;
			}
		}

		private static void CreateEquipmentModel()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_equipmentModel))
			{
				return;
			}
			GameObject val = Assets.mainAssetBundle.LoadAsset<GameObject>("mdlEngiTurretStationary");
			Renderer componentInChildren = val.GetComponentInChildren<Renderer>();
			componentInChildren.material = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Engi/matEngiTurret.mat").WaitForCompletion();
			ItemDisplay val2 = val.AddComponent<ItemDisplay>();
			List<Renderer> list = new List<Renderer> { componentInChildren };
			List<RendererInfo> list2 = new List<RendererInfo>();
			foreach (Renderer item2 in list)
			{
				RendererInfo item = default(RendererInfo);
				item.renderer = item2;
				item.defaultMaterial = item2.material;
				item.defaultShadowCastingMode = item2.shadowCastingMode;
				item.ignoreOverlays = false;
				item.hideOnDeath = false;
				list2.Add(item);
			}
			val2.rendererInfos = list2.ToArray();
			_equipmentModel = val;
		}

		private static GameObject GetEquipmentModel()
		{
			if (!Object.op_Implicit((Object)(object)_equipmentModel))
			{
				CreateEquipmentModel();
			}
			return _equipmentModel;
		}
	}
	public class WalkerTurret : EquipmentBase<WalkerTurret>
	{
		private static GameObject _equipmentModel;

		public static GameObject bodyPrefab;

		public static GameObject masterPrefab;

		public static GameObject projectilePrefab;

		public static CharacterSpawnCard spawnCard;

		public static float moveSpeed;

		public static float _cooldown;

		public static float baseHealth;

		public static float baseDamage;

		public static float baseRegen;

		public static bool increaseRange;

		public static bool alwaysSprint;

		public static int maxActive;

		public override string EquipmentName => "Mobile Turret";

		public override string EquipmentLangTokenName => "WALKER";

		public override GameObject EquipmentModel => GetEquipmentModel();

		public override Sprite EquipmentIcon => Assets.mainAssetBundle.LoadAsset<Sprite>("texEngiWalkerTurretEquipmentIcon.png");

		public override float Cooldown => _cooldown;

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			ItemDisplayRuleDict val = new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
			GameObject equipmentModel = EquipmentModel;
			if (!Object.op_Implicit((Object)(object)equipmentModel))
			{
				return val;
			}
			val.Add("EquipmentDroneBody", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					followerPrefab = EquipmentModel,
					ruleType = (ItemDisplayRuleType)0,
					childName = "GunBarrelBase",
					localPos = new Vector3(0f, 0f, 2.6f),
					localAngles = new Vector3(270f, 0f, 0f),
					localScale = new Vector3(0.5f, 0.5f, 0.5f)
				}
			});
			return val;
		}

		protected override bool ActivateEquipment(EquipmentSlot slot)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody characterBody = slot.characterBody;
			CharacterMaster val = (((Object)(object)characterBody != (Object)null) ? characterBody.master : null);
			if (!Object.op_Implicit((Object)(object)val) || val.IsDeployableLimited((DeployableSlot)14))
			{
				return false;
			}
			Ray aimRay = slot.GetAimRay();
			Quaternion rotation = Quaternion.LookRotation(((Ray)(ref aimRay)).direction);
			FireProjectileInfo val2 = default(FireProjectileInfo);
			val2.projectilePrefab = projectilePrefab;
			val2.crit = slot.characterBody.RollCrit();
			val2.damage = 0f;
			val2.damageColorIndex = (DamageColorIndex)3;
			val2.force = 0f;
			val2.owner = ((Component)slot).gameObject;
			val2.position = ((Ray)(ref aimRay)).origin;
			val2.rotation = rotation;
			FireProjectileInfo val3 = val2;
			ProjectileManager.instance.FireProjectile(val3);
			return true;
		}

		protected override void CreateConfig(ConfigFile config)
		{
			base.CreateConfig(config);
			baseHealth = config.Bind<float>("Mobile Turret", "Base Health", 65f, (ConfigDescription)null).Value;
			baseDamage = config.Bind<float>("Mobile Turret", "Base Damage", 8f, (ConfigDescription)null).Value;
			baseRegen = config.Bind<float>("Mobile Turret", "Base Regen", 1f, (ConfigDescription)null).Value;
			_cooldown = config.Bind<float>("Mobile Turret", "Cooldown", 90f, (ConfigDescription)null).Value;
			moveSpeed = config.Bind<float>("Mobile Turret", "Move Speed", 7f, (ConfigDescription)null).Value;
			increaseRange = config.Bind<bool>("Mobile Turret", "Increase Range", true, (ConfigDescription)null).Value;
			alwaysSprint = config.Bind<bool>("Mobile Turret", "Always Sprint", true, (ConfigDescription)null).Value;
			maxActive = config.Bind<int>("Mobile Turret", "Max Active with Extra Equip Slots", -1, (ConfigDescription)null).Value;
		}

		public override void CreateAssets(ConfigFile config)
		{
			base.CreateAssets(config);
			CreateBodyPrefab();
			CreateMasterPrefab();
			CreateSpawnCard();
			CreateEquipmentModel();
			CreateProjectilePrefab();
		}

		private void CreateSpawnCard()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)masterPrefab))
			{
				CreateMasterPrefab();
			}
			if (!Object.op_Implicit((Object)(object)spawnCard))
			{
				spawnCard = ScriptableObject.CreateInstance<CharacterSpawnCard>();
				((SpawnCard)spawnCard).directorCreditCost = 35;
				((SpawnCard)spawnCard).hullSize = (HullClassification)0;
				((SpawnCard)spawnCard).nodeGraphType = (GraphType)0;
				((SpawnCard)spawnCard).prefab = masterPrefab;
				((SpawnCard)spawnCard).sendOverNetwork = true;
				((SpawnCard)spawnCard).occupyPosition = false;
				((SpawnCard)spawnCard).forbiddenFlags = (NodeFlags)4;
				spawnCard.inventoryItemCopyFilter = Inventory.DefaultItemCopyFilter;
				((Object)spawnCard).name = "cscMoffeinETEWalkerTurret";
			}
		}

		private void CreateProjectilePrefab()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)spawnCard))
			{
				CreateSpawnCard();
			}
			if (!Object.op_Implicit((Object)(object)projectilePrefab))
			{
				GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/MinorConstructOnKill/MinorConstructOnKillProjectile.prefab").WaitForCompletion(), "MoffeinETE_WalkerTurretProjectile", true);
				val.GetComponent<ProjectileController>().ghostPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/Drifter/DrifterToolbotCrateGhost.prefab").WaitForCompletion();
				ProjectileSpawnMaster component = val.GetComponent<ProjectileSpawnMaster>();
				component.spawnCard = spawnCard;
				component.deployableSlot = (DeployableSlot)35;
				PluginContentPack.projectilePrefabs.Add(val);
				projectilePrefab = val;
				ProjectileSpawnMaster.SpawnMaster += new Manipulator(ProjectileSpawnMaster_SpawnMaster);
			}
		}

		private void ProjectileSpawnMaster_SpawnMaster(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<DirectorCore>(x, "TrySpawnObject")
			}))
			{
				val.EmitDelegate<Func<DirectorSpawnRequest, DirectorSpawnRequest>>((Func<DirectorSpawnRequest, DirectorSpawnRequest>)delegate(DirectorSpawnRequest req)
				{
					//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
					//IL_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_00c3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)(object)req.spawnCard == (Object)(object)spawnCard && (Object)(object)req.summonerBodyObject != (Object)null)
					{
						CharacterBody component = req.summonerBodyObject.GetComponent<CharacterBody>();
						if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
						{
							SpawnCard obj = req.spawnCard;
							CharacterSpawnCard val2 = (CharacterSpawnCard)(object)((obj is CharacterSpawnCard) ? obj : null);
							CharacterSpawnCard val3 = ScriptableObject.CreateInstance<CharacterSpawnCard>();
							((SpawnCard)val3).prefab = ((SpawnCard)spawnCard).prefab;
							((SpawnCard)val3).occupyPosition = ((SpawnCard)spawnCard).occupyPosition;
							((SpawnCard)val3).sendOverNetwork = ((SpawnCard)spawnCard).sendOverNetwork;
							((SpawnCard)val3).hullSize = ((SpawnCard)spawnCard).hullSize;
							((SpawnCard)val3).nodeGraphType = ((SpawnCard)spawnCard).nodeGraphType;
							((SpawnCard)val3).forbiddenFlags = ((SpawnCard)spawnCard).forbiddenFlags;
							val3.inventoryItemCopyFilter = spawnCard.inventoryItemCopyFilter;
							val3.inventoryToCopy = component.inventory;
							req.spawnCard = (SpawnCard)(object)val3;
						}
						req.ignoreTeamMemberLimit = true;
					}
					return req;
				});
			}
			else
			{
				Debug.LogError((object)"EngiTurretEquipment: Walker Turret ProjectileSpawnMaster_SpawnMaster IL hook failed.");
			}
		}

		private void CreateBodyPrefab()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)bodyPrefab))
			{
				GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Engi/EngiWalkerTurretBody.prefab").WaitForCompletion(), "MoffeinETE_WalkerTurretBody", true);
				CharacterBody component = val.GetComponent<CharacterBody>();
				component.baseMaxHealth = baseHealth;
				component.levelMaxHealth = baseHealth * 0.3f;
				component.baseDamage = baseDamage;
				component.levelDamage = baseDamage * 0.2f;
				component.baseRegen = baseRegen;
				component.levelRegen = baseRegen * 0.2f;
				component.portraitIcon = (Texture)(object)Assets.mainAssetBundle.LoadAsset<Texture2D>("texEngiWalkerTurretBodyIcon.png");
				val.AddComponent<RegisterWalkerTurret>();
				PluginContentPack.bodyPrefabs.Add(val);
				bodyPrefab = val;
			}
		}

		private void CreateMasterPrefab()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)masterPrefab))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)bodyPrefab))
			{
				CreateBodyPrefab();
			}
			GameObject val = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Engi/EngiWalkerTurretMaster.prefab").WaitForCompletion(), "MoffeinETE_WalkerTurretMaster", true);
			CharacterMaster component = val.GetComponent<CharacterMaster>();
			component.bodyPrefab = bodyPrefab;
			PluginContentPack.masterPrefabs.Add(val);
			masterPrefab = val;
			AISkillDriver[] components = val.GetComponents<AISkillDriver>();
			AISkillDriver[] array = components;
			foreach (AISkillDriver val2 in array)
			{
				if (alwaysSprint && val2.customName != "Rest")
				{
					val2.shouldSprint = true;
				}
				if (increaseRange && val2.customName == "ChaseAndFireAtEnemy")
				{
					val2.maxDistance = 45f;
				}
			}
			if (increaseRange)
			{
				PluginUtils.SetAddressableEntityStateField("RoR2/Base/Engi/EntityStates.EngiTurret.EngiTurretWeapon.FireBeam.asset", "maxDistance", "45");
			}
		}

		private static void CreateEquipmentModel()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_equipmentModel))
			{
				return;
			}
			GameObject val = Assets.mainAssetBundle.LoadAsset<GameObject>("mdlEngiTurretWalker");
			Renderer componentInChildren = val.GetComponentInChildren<Renderer>();
			componentInChildren.material = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Engi/matEngiTurret.mat").WaitForCompletion();
			ItemDisplay val2 = val.AddComponent<ItemDisplay>();
			List<Renderer> list = new List<Renderer> { componentInChildren };
			List<RendererInfo> list2 = new List<RendererInfo>();
			foreach (Renderer item2 in list)
			{
				RendererInfo item = default(RendererInfo);
				item.renderer = item2;
				item.defaultMaterial = item2.material;
				item.defaultShadowCastingMode = item2.shadowCastingMode;
				item.ignoreOverlays = false;
				item.hideOnDeath = false;
				list2.Add(item);
			}
			val2.rendererInfos = list2.ToArray();
			_equipmentModel = val;
		}

		private static GameObject GetEquipmentModel()
		{
			if (!Object.op_Implicit((Object)(object)_equipmentModel))
			{
				CreateEquipmentModel();
			}
			return _equipmentModel;
		}
	}
}
namespace EngiTurretEquipment.Components
{
	public class MasterStationaryTurretCounter : MonoBehaviour
	{
		private Inventory inventory;

		public Queue<CharacterMaster> activeTurrets = new Queue<CharacterMaster>();

		private void Start()
		{
			if (!Object.op_Implicit((Object)(object)inventory))
			{
				inventory = ((Component)this).GetComponent<Inventory>();
			}
		}

		private void UpdateActiveTurrets()
		{
			Queue<CharacterMaster> queue = new Queue<CharacterMaster>();
			foreach (CharacterMaster activeTurret in activeTurrets)
			{
				if (Object.op_Implicit((Object)(object)activeTurret) && !queue.Contains(activeTurret))
				{
					CharacterBody body = activeTurret.GetBody();
					if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
					{
						queue.Enqueue(activeTurret);
					}
				}
			}
			activeTurrets.Clear();
			activeTurrets = queue;
		}

		public bool CanSpawnTurret()
		{
			UpdateActiveTurrets();
			int maxTurrets = GetMaxTurrets();
			return activeTurrets.Count < maxTurrets;
		}

		protected EquipmentDef GetEquipmentDef()
		{
			return (EquipmentBase<StationaryTurret>.Instance != null) ? EquipmentBase<StationaryTurret>.Instance.EquipmentDef : null;
		}

		public int GetMaxTurrets()
		{
			//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_006c: Unknown result type (might be due to invalid IL or missing references)
			int maxActive = StationaryTurret.maxActive;
			EquipmentDef equipmentDef = GetEquipmentDef();
			if (Object.op_Implicit((Object)(object)inventory) && Object.op_Implicit((Object)(object)equipmentDef))
			{
				int num = 0;
				EquipmentState[][] equipmentStateSlots = inventory._equipmentStateSlots;
				foreach (EquipmentState[] array in equipmentStateSlots)
				{
					if (array == null)
					{
						continue;
					}
					EquipmentState[] array2 = array;
					foreach (EquipmentState val in array2)
					{
						if ((Object)(object)val.equipmentDef == (Object)(object)equipmentDef)
						{
							num++;
						}
					}
				}
				int num2 = Mathf.Max(1, num);
				if (maxActive > 0)
				{
					num2 = Mathf.Min(num2, maxActive);
				}
				return num2;
			}
			return 1;
		}

		public void AddTurretServer(CharacterMaster newTurret)
		{
			if (!NetworkServer.active)
			{
				return;
			}
			UpdateActiveTurrets();
			int maxTurrets = GetMaxTurrets();
			int num = activeTurrets.Count + 1 - maxTurrets;
			if (num > 0)
			{
				for (int i = 0; i < num; i++)
				{
					if (activeTurrets.TryDequeue(out CharacterMaster result))
					{
						result.TrueKill();
					}
				}
			}
			activeTurrets.Enqueue(newTurret);
		}
	}
	public class MasterWalkerTurretCounter : MonoBehaviour
	{
		private Inventory inventory;

		public Queue<CharacterMaster> activeTurrets = new Queue<CharacterMaster>();

		private void Start()
		{
			if (!Object.op_Implicit((Object)(object)inventory))
			{
				inventory = ((Component)this).GetComponent<Inventory>();
			}
		}

		private void UpdateActiveTurrets()
		{
			Queue<CharacterMaster> queue = new Queue<CharacterMaster>();
			foreach (CharacterMaster activeTurret in activeTurrets)
			{
				if (Object.op_Implicit((Object)(object)activeTurret) && !queue.Contains(activeTurret))
				{
					CharacterBody body = activeTurret.GetBody();
					if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
					{
						queue.Enqueue(activeTurret);
					}
				}
			}
			activeTurrets.Clear();
			activeTurrets = queue;
		}

		public bool CanSpawnTurret()
		{
			UpdateActiveTurrets();
			int maxTurrets = GetMaxTurrets();
			return activeTurrets.Count < maxTurrets;
		}

		protected EquipmentDef GetEquipmentDef()
		{
			return (EquipmentBase<WalkerTurret>.Instance != null) ? EquipmentBase<WalkerTurret>.Instance.EquipmentDef : null;
		}

		public int GetMaxTurrets()
		{
			//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_006c: Unknown result type (might be due to invalid IL or missing references)
			int maxActive = WalkerTurret.maxActive;
			EquipmentDef equipmentDef = GetEquipmentDef();
			if (Object.op_Implicit((Object)(object)inventory) && Object.op_Implicit((Object)(object)equipmentDef))
			{
				int num = 0;
				EquipmentState[][] equipmentStateSlots = inventory._equipmentStateSlots;
				foreach (EquipmentState[] array in equipmentStateSlots)
				{
					if (array == null)
					{
						continue;
					}
					EquipmentState[] array2 = array;
					foreach (EquipmentState val in array2)
					{
						if ((Object)(object)val.equipmentDef == (Object)(object)equipmentDef)
						{
							num++;
						}
					}
				}
				int num2 = Mathf.Max(1, num);
				if (maxActive > 0)
				{
					num2 = Mathf.Min(num2, maxActive);
				}
				return num2;
			}
			return 1;
		}

		public void AddTurretServer(CharacterMaster newTurret)
		{
			if (!NetworkServer.active)
			{
				return;
			}
			UpdateActiveTurrets();
			int maxTurrets = GetMaxTurrets();
			int num = activeTurrets.Count + 1 - maxTurrets;
			if (num > 0)
			{
				for (int i = 0; i < num; i++)
				{
					if (activeTurrets.TryDequeue(out CharacterMaster result))
					{
						result.TrueKill();
					}
				}
			}
			activeTurrets.Enqueue(newTurret);
		}
	}
	public class RegisterStationaryTurret : MonoBehaviour
	{
		private void Start()
		{
			if (NetworkServer.active)
			{
				CharacterBody component = ((Component)this).GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component.master) && Object.op_Implicit((Object)(object)component.master.minionOwnership) && Object.op_Implicit((Object)(object)component.master.minionOwnership.ownerMaster))
				{
					MasterStationaryTurretCounter masterStationaryTurretCounter = ((Component)component.master.minionOwnership.ownerMaster).gameObject.GetComponent<MasterStationaryTurretCounter>();
					if (!Object.op_Implicit((Object)(object)masterStationaryTurretCounter))
					{
						masterStationaryTurretCounter = ((Component)component.master.minionOwnership.ownerMaster).gameObject.AddComponent<MasterStationaryTurretCounter>();
					}
					masterStationaryTurretCounter.AddTurretServer(component.master);
				}
			}
			Object.Destroy((Object)(object)this);
		}
	}
	public class RegisterWalkerTurret : MonoBehaviour
	{
		private void Start()
		{
			if (NetworkServer.active)
			{
				CharacterBody component = ((Component)this).GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component.master) && Object.op_Implicit((Object)(object)component.master.minionOwnership) && Object.op_Implicit((Object)(object)component.master.minionOwnership.ownerMaster))
				{
					MasterWalkerTurretCounter masterWalkerTurretCounter = ((Component)component.master.minionOwnership.ownerMaster).gameObject.GetComponent<MasterWalkerTurretCounter>();
					if (!Object.op_Implicit((Object)(object)masterWalkerTurretCounter))
					{
						masterWalkerTurretCounter = ((Component)component.master.minionOwnership.ownerMaster).gameObject.AddComponent<MasterWalkerTurretCounter>();
					}
					masterWalkerTurretCounter.AddTurretServer(component.master);
				}
			}
			Object.Destroy((Object)(object)this);
		}
	}
}