Decompiled source of TinkersSatchel v6.0.1

TinkersSatchel.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using AncientScepter;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Bandit2;
using EntityStates.Captain.Weapon;
using EntityStates.CaptainSupplyDrop;
using EntityStates.Commando;
using EntityStates.Commando.CommandoWeapon;
using EntityStates.Croco;
using EntityStates.Drone;
using EntityStates.Engi.EngiBubbleShield;
using EntityStates.Engi.EngiMissilePainter;
using EntityStates.Engi.EngiWeapon;
using EntityStates.GlobalSkills.LunarNeedle;
using EntityStates.GolemMonster;
using EntityStates.Headstompers;
using EntityStates.Huntress;
using EntityStates.Huntress.HuntressWeapon;
using EntityStates.LaserTurbine;
using EntityStates.Loader;
using EntityStates.Mage.Weapon;
using EntityStates.Merc;
using EntityStates.SiphonItem;
using EntityStates.Toolbot;
using EntityStates.Treebot;
using EntityStates.Treebot.Weapon;
using EntityStates.VoidSurvivor.Vent;
using EntityStates.VoidSurvivor.Weapon;
using HG;
using IL.EntityStates.Drone;
using IL.RoR2;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates;
using On.EntityStates.Bandit2;
using On.EntityStates.Captain.Weapon;
using On.EntityStates.Commando;
using On.EntityStates.Croco;
using On.EntityStates.Drone;
using On.EntityStates.Engi.EngiBubbleShield;
using On.EntityStates.Engi.EngiMissilePainter;
using On.EntityStates.Engi.EngiWeapon;
using On.EntityStates.Headstompers;
using On.EntityStates.Huntress;
using On.EntityStates.Huntress.HuntressWeapon;
using On.EntityStates.LaserTurbine;
using On.EntityStates.Loader;
using On.EntityStates.Mage.Weapon;
using On.EntityStates.Merc;
using On.EntityStates.SiphonItem;
using On.EntityStates.Toolbot;
using On.EntityStates.Treebot;
using On.EntityStates.Treebot.Weapon;
using On.EntityStates.VoidSurvivor.Vent;
using On.EntityStates.VoidSurvivor.Weapon;
using On.RoR2;
using On.RoR2.CharacterAI;
using On.RoR2.Networking;
using On.RoR2.Orbs;
using On.RoR2.Projectile;
using On.RoR2.UI;
using On.RoR2.UI.LogBook;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Achievements;
using RoR2.Artifacts;
using RoR2.CharacterAI;
using RoR2.EntitlementManagement;
using RoR2.ExpansionManagement;
using RoR2.Navigation;
using RoR2.Networking;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.Stats;
using RoR2.UI;
using RoR2.UI.LogBook;
using ThinkInvisible.Dronemeld;
using ThinkInvisible.NavYoink;
using UnityEngine;
using UnityEngine.AddressableAssets;
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("TinkersSatchel")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f53f09264f0e5b1860730f4727e227160c7ac889")]
[assembly: AssemblyProduct("TinkersSatchel")]
[assembly: AssemblyTitle("TinkersSatchel")]
[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 ThinkInvisible.TinkersSatchel
{
	public class AntiAir : Artifact<AntiAir>
	{
		[AutoConfig("Incoming damage multiplier applied to airborne characters while Artifact of Suppression is active.", AutoConfigFlags.None, new object[]
		{
			1f,
			float.MaxValue
		})]
		public float hurtMod { get; private set; } = 5f;


		public AntiAir()
		{
			base.iconResource = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/antiair_on.png");
			base.iconResourceDisabled = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/antiair_off.png");
		}

		public override void Install()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.Install();
			HealthComponent.TakeDamage += new hook_TakeDamage(On_HCTakeDamage);
		}

		public override void Uninstall()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.Uninstall();
			HealthComponent.TakeDamage -= new hook_TakeDamage(On_HCTakeDamage);
		}

		private void On_HCTakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			if (IsActiveAndEnabled() && (Object)(object)self.body != (Object)null && (Object)(object)self.body.teamComponent != (Object)null && (int)self.body.teamComponent.teamIndex == 1 && (Object)(object)self.body.characterMotor != (Object)null && !self.body.characterMotor.isGrounded)
			{
				damageInfo.damage *= hurtMod;
			}
			orig.Invoke(self, damageInfo);
		}
	}
	public class Butterknife : Artifact<Butterknife>
	{
		private readonly MethodInfo cbDamageSetter;

		private readonly MethodInfo cbAttackSetter;

		public Butterknife()
		{
			base.iconResource = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/butterknife_on.png");
			base.iconResourceDisabled = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/butterknife_off.png");
			cbDamageSetter = Reflection.GetPropertyCached(typeof(CharacterBody), "damage").GetSetMethod(nonPublic: true);
			cbAttackSetter = Reflection.GetPropertyCached(typeof(CharacterBody), "attackSpeed").GetSetMethod(nonPublic: true);
		}

		public override void Install()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.Install();
			CharacterBody.RecalculateStats += new hook_RecalculateStats(On_CBRecalcStats);
		}

		public override void Uninstall()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.Uninstall();
			CharacterBody.RecalculateStats -= new hook_RecalculateStats(On_CBRecalcStats);
		}

		private void On_CBRecalcStats(orig_RecalculateStats orig, CharacterBody self)
		{
			orig.Invoke(self);
			if (IsActiveAndEnabled())
			{
				cbDamageSetter.Invoke(self, new object[1] { self.damage / 20f });
				cbAttackSetter.Invoke(self, new object[1] { self.attackSpeed * 10f });
			}
		}
	}
	public class Danger : Artifact<Danger>
	{
		public Danger()
		{
			base.iconResource = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/danger_on.png");
			base.iconResourceDisabled = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/danger_off.png");
		}

		public override void Install()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.Install();
			CharacterBody.RecalculateStats += new Manipulator(IL_CBRecalcStats);
		}

		public override void Uninstall()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.Uninstall();
			CharacterBody.RecalculateStats -= new Manipulator(IL_CBRecalcStats);
		}

		private void IL_CBRecalcStats(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "set_hasOneShotProtection")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<bool, CharacterBody, bool>>((Func<bool, CharacterBody, bool>)((bool origSet, CharacterBody body) => body.isPlayerControlled && !IsActiveAndEnabled()));
			}
			else
			{
				TinkersSatchelPlugin._logger.LogError((object)"failed to apply IL patch (Artifact of Danger, set OHP flag)! Artifact will not prevent OHP while enabled.");
			}
		}
	}
	public class DelayLoot : Artifact<DelayLoot>
	{
		public enum AnnounceItemsMode
		{
			Nothing,
			Vague,
			ItemTier,
			ItemName
		}

		public enum AnnounceDropMode
		{
			Nothing,
			TotalItemCount
		}

		private bool shouldDeferDrops = true;

		private Vector3 lootShowerLoc = Vector3.zero;

		private float lootShowerTimer;

		private readonly List<GameObject> deferredDrops = new List<GameObject>();

		private List<Vector3> launchVelocities = new List<Vector3>();

		[AutoConfig("What to display in chat when an item is taken for safekeeping.", AutoConfigFlags.None, new object[] { })]
		public AnnounceItemsMode announceItems { get; private set; } = AnnounceItemsMode.ItemName;


		[AutoConfig("What to display in chat when the teleporter boss is killed.", AutoConfigFlags.None, new object[] { })]
		public AnnounceDropMode announceDrop { get; private set; } = AnnounceDropMode.TotalItemCount;


		public DelayLoot()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			base.iconResource = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/delayitems_on.png");
			base.iconResourceDisabled = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/delayitems_off.png");
		}

		public override void Install()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			base.Install();
			Stage.onServerStageBegin += Stage_onServerStageBegin;
			PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += new Manipulator(PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3);
			GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal;
			Run.FixedUpdate += new hook_FixedUpdate(Run_FixedUpdate);
		}

		public override void Uninstall()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			base.Uninstall();
			Stage.onServerStageBegin -= Stage_onServerStageBegin;
			PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 -= new Manipulator(PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3);
			GlobalEventManager.onCharacterDeathGlobal -= GlobalEventManager_onCharacterDeathGlobal;
			Run.FixedUpdate -= new hook_FixedUpdate(Run_FixedUpdate);
		}

		private void Run_FixedUpdate(orig_FixedUpdate orig, Run self)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!NetworkServer.active || !IsActiveAndEnabled() || shouldDeferDrops || deferredDrops.Count <= 0)
			{
				return;
			}
			lootShowerTimer -= Time.fixedDeltaTime;
			if (!(lootShowerTimer <= 0f))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)deferredDrops[0]))
			{
				deferredDrops.RemoveAt(0);
				return;
			}
			Vector3 val = launchVelocities[0];
			launchVelocities.RemoveAt(0);
			launchVelocities.Add(val);
			Rigidbody component = deferredDrops[0].GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.velocity = val;
				component.drag = 0f;
			}
			((Behaviour)deferredDrops[0].GetComponent<ConstantForce>()).enabled = false;
			deferredDrops[0].transform.position = lootShowerLoc;
			deferredDrops[0].SetActive(true);
			deferredDrops.RemoveAt(0);
			lootShowerTimer = 0.125f;
		}

		private void Stage_onServerStageBegin(Stage obj)
		{
			shouldDeferDrops = true;
		}

		private void GlobalEventManager_onCharacterDeathGlobal(DamageReport report)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0094: 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_00be: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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)
			if (!IsActiveAndEnabled() || !report.victimIsBoss || !Object.op_Implicit((Object)(object)TeleporterInteraction.instance) || TeleporterInteraction.instance.bossGroup.combatSquad.memberCount > 1)
			{
				return;
			}
			shouldDeferDrops = false;
			lootShowerLoc = ((Component)report.victim).transform.position + Vector3.up * 3f;
			NodeGraph nodeGraph = SceneInfo.instance.GetNodeGraph((GraphType)0);
			launchVelocities = MathUtil.CollectNearestNodeLaunchVelocities(nodeGraph, deferredDrops.Count, 10f, 1000f, lootShowerLoc, 5f, 0.625f, 3f, 10, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask), (QueryTriggerInteraction)1, (HullMask)1);
			if (launchVelocities.Count < deferredDrops.Count)
			{
				Vector3 source = ((Component)TeleporterInteraction.instance).transform.position + Vector3.up * 3f;
				List<Vector3> list = MathUtil.CollectNearestNodeLaunchVelocities(nodeGraph, deferredDrops.Count, 10f, 1000f, source, 5f, 0.625f, 3f, 10, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask), (QueryTriggerInteraction)1, (HullMask)1);
				if (launchVelocities.Count == 0 && list.Count == 0)
				{
					TinkersSatchelPlugin._logger.LogWarning((object)"DelayLoot: found no free navnodes to drop items at, using fallback circle");
					lootShowerLoc = source;
					for (int i = 0; i < deferredDrops.Count; i++)
					{
						float num = (float)i / (float)deferredDrops.Count * MathF.PI * 2f;
						launchVelocities.Add(new Vector3(Mathf.Cos(num) * 10f, 20f, Mathf.Sin(num) * 10f));
					}
				}
				else if (list.Count > launchVelocities.Count)
				{
					TinkersSatchelPlugin._logger.LogWarning((object)"DelayLoot: couldn't find enough free navnodes to drop items at from boss, falling back to TP");
					launchVelocities = list;
					lootShowerLoc = source;
				}
				if (launchVelocities.Count < deferredDrops.Count)
				{
					TinkersSatchelPlugin._logger.LogWarning((object)"DelayLoot: couldn't find enough free navnodes to drop items at from any source, some items will stack");
				}
			}
			if (announceDrop == AnnounceDropMode.TotalItemCount && deferredDrops.Count > 0)
			{
				SimpleChatMessage val = new SimpleChatMessage();
				val.paramTokens = new string[1] { deferredDrops.Count.ToString() };
				val.baseToken = "TKSAT_DELAYLOOT_MSG_KILL";
				Chat.SendBroadcastChat((ChatMessageBase)(object)val);
			}
		}

		private void PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<NetworkServer>(x, "Spawn")
			}))
			{
				val.Emit(OpCodes.Dup);
				val.EmitDelegate<Action<GameObject>>((Action<GameObject>)delegate(GameObject obj)
				{
					if (IsActiveAndEnabled() && shouldDeferDrops && Object.op_Implicit((Object)(object)TeleporterInteraction.instance))
					{
						DeferDroplet(obj);
					}
				});
			}
			else
			{
				TinkersSatchelPlugin._logger.LogError((object)"DelayLoot failed to apply IL hook (PickupDropletController_CreatePickupDroplet): couldn't find target instructions");
			}
		}

		private void DeferDroplet(GameObject droplet)
		{
			//IL_0032: 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_00b4: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)droplet))
			{
				return;
			}
			deferredDrops.Add(droplet);
			droplet.SetActive(false);
			PickupDropletController component = droplet.GetComponent<PickupDropletController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			PickupDef val = PickupCatalog.GetPickupDef(component.pickupState.pickupIndex);
			if (val != null && announceItems != 0)
			{
				string text = Language.GetString((announceItems == AnnounceItemsMode.ItemName) ? val.nameToken : "TKSAT_DELAYLOOT_MSG_DELAY_VAGUE");
				if (announceItems != AnnounceItemsMode.Vague)
				{
					text = "<color=#" + Util.RGBToHex(Color32.op_Implicit(val.baseColor)) + ">" + text + "</color>";
				}
				SimpleChatMessage val2 = new SimpleChatMessage();
				val2.paramTokens = new string[1] { text };
				val2.baseToken = "TKSAT_DELAYLOOT_MSG_DELAY";
				Chat.SendBroadcastChat((ChatMessageBase)(object)val2);
			}
		}
	}
	public class PackTactics : Artifact<PackTactics>
	{
		[AutoConfig("Combatants within this distance (in meters) of teammates will buff them if Artifact of Tactics is enabled.", AutoConfigFlags.None, new object[]
		{
			0f,
			float.MaxValue
		})]
		public float baseRadius { get; private set; } = 25f;


		[AutoConfig("Extra move speed multiplier added per stack of the Tactics buff.", AutoConfigFlags.None, new object[]
		{
			0f,
			float.MaxValue
		})]
		public float speedMod { get; private set; } = 0.05f;


		[AutoConfig("Extra damage multiplier added per stack of the Tactics buff.", AutoConfigFlags.None, new object[]
		{
			0f,
			float.MaxValue
		})]
		public float damageMod { get; private set; } = 0.1f;


		[AutoConfig("Extra armor added per stack of the Tactics buff.", AutoConfigFlags.None, new object[]
		{
			0f,
			float.MaxValue
		})]
		public float armorMod { get; private set; } = 15f;


		public BuffDef tacticsBuff { get; private set; }

		public GameObject tacticsWardPrefab { get; private set; }

		public PackTactics()
		{
			base.iconResource = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/tactics_on.png");
			base.iconResourceDisabled = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/ArtifactIcons/tactics_off.png");
		}

		public override void SetupConfig()
		{
			base.SetupConfig();
			base.ConfigEntryChanged += delegate(object sender, AutoConfigUpdateActionEventArgs args)
			{
				if (args.target.boundProperty.Name == "baseRadius" && NetworkServer.active)
				{
					foreach (TacticsWard instance in TacticsWard.instances)
					{
						((Component)instance).GetComponent<BuffWard>().Networkradius = (float)args.newValue;
					}
				}
			};
		}

		public override void SetupAttributes()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			base.SetupAttributes();
			tacticsBuff = ScriptableObject.CreateInstance<BuffDef>();
			tacticsBuff.buffColor = Color.white;
			tacticsBuff.canStack = true;
			tacticsBuff.isDebuff = false;
			((Object)tacticsBuff).name = base.modInfo.shortIdentifier + "TacticsBuff";
			tacticsBuff.iconSprite = base.iconResource;
			ContentAddition.AddBuffDef(tacticsBuff);
			GameObject val = new GameObject("TacticsAuraPrefabPrefab");
			val.AddComponent<NetworkIdentity>();
			val.AddComponent<TeamFilter>();
			val.AddComponent<NetworkedBodyAttachment>().forceHostAuthority = true;
			val.AddComponent<TacticsWard>();
			BuffWard obj = val.AddComponent<BuffWard>();
			obj.invertTeamFilter = false;
			obj.expires = false;
			obj.animateRadius = false;
			obj.radius = baseRadius;
			obj.rangeIndicator = null;
			obj.Networkradius = baseRadius;
			obj.buffDuration = 1f;
			obj.interval = 1f;
			obj.buffDef = tacticsBuff;
			tacticsWardPrefab = PrefabAPI.InstantiateClone(val, "TacticsAuraPrefab", true);
			Object.Destroy((Object)(object)val);
		}

		public override void Install()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			base.Install();
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(Evt_GetStatCoefficients);
			if (IsActiveAndEnabled())
			{
				foreach (CharacterMaster item in CharacterMaster.readOnlyInstancesList.Where((CharacterMaster x) => x.hasBody && x.GetBody().healthComponent.alive).ToList())
				{
					if (item.hasBody)
					{
						AddWard(item.GetBody());
					}
				}
			}
			CharacterMaster.OnBodyStart += new hook_OnBodyStart(On_CMOnBodyStart);
		}

		public override void Uninstall()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			base.Uninstall();
			CharacterMaster.OnBodyStart -= new hook_OnBodyStart(On_CMOnBodyStart);
			foreach (TacticsWard instance in TacticsWard.instances)
			{
				Object.Destroy((Object)(object)((Component)instance).gameObject);
			}
			RecalculateStatsAPI.GetStatCoefficients -= new StatHookEventHandler(Evt_GetStatCoefficients);
		}

		private void Evt_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
		{
			if (Object.op_Implicit((Object)(object)sender))
			{
				int num = Mathf.Max(sender.GetBuffCount(tacticsBuff) - 1, 0);
				args.moveSpeedMultAdd += (float)num * speedMod;
				args.baseDamageAdd += (float)num * damageMod;
				args.armorAdd += (float)num * armorMod;
			}
		}

		private void On_CMOnBodyStart(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
		{
			orig.Invoke(self, body);
			if (NetworkServer.active && IsActiveAndEnabled())
			{
				AddWard(body);
			}
		}

		private void AddWard(CharacterBody body)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)body))
			{
				TacticsWard componentInChildren = ((Component)body).GetComponentInChildren<TacticsWard>();
				if (!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)((Component)componentInChildren).gameObject))
				{
					GameObject obj = Object.Instantiate<GameObject>(tacticsWardPrefab);
					obj.GetComponent<TeamFilter>().teamIndex = body.teamComponent.teamIndex;
					obj.GetComponent<NetworkedBodyAttachment>().AttachToGameObjectAndSpawn(((Component)body).gameObject, (string)null);
				}
			}
		}
	}
	internal class TacticsWard : MonoBehaviour
	{
		internal static List<TacticsWard> instances = new List<TacticsWard>();

		private void Awake()
		{
			instances.Add(this);
		}

		private void OnDestroy()
		{
			instances.Remove(this);
		}
	}
	public class BulwarkDrone : Module<BulwarkDrone>
	{
		public GameObject bulwarkDroneInteractablePrefab { get; private set; }

		public GameObject bulwarkDroneBodyPrefab { get; private set; }

		public GameObject bulwarkDroneMasterPrefab { get; private set; }

		public InteractableSpawnCard bulwarkDroneSpawnCard { get; private set; }

		public DirectorCard bulwarkDroneDirectorCard { get; private set; }

		public DirectorCardHolder bulwarkDroneDCH { get; private set; }

		internal CommonCode.ConditionalDirectorCardHolder bulwarkDroneCDCH { get; private set; }

		public override void SetupAttributes()
		{
			base.SetupAttributes();
			bulwarkDroneBodyPrefab = TinkersSatchelPlugin.resources.LoadAsset<GameObject>("Assets/TinkersSatchel/Prefabs/Characters/BulwarkDrone/BulwarkDroneBody.prefab");
			ModifyBodyPrefabWithVanillaAssets();
			bulwarkDroneMasterPrefab = TinkersSatchelPlugin.resources.LoadAsset<GameObject>("Assets/TinkersSatchel/Prefabs/Characters/BulwarkDrone/BulwarkDroneMaster.prefab");
			bulwarkDroneInteractablePrefab = TinkersSatchelPlugin.resources.LoadAsset<GameObject>("Assets/TinkersSatchel/Prefabs/Characters/BulwarkDrone/BulwarkDroneBroken.prefab");
			ModifyInteractablePrefabWithVanillaAssets();
			SetupSpawnCard();
			ContentAddition.AddBody(bulwarkDroneBodyPrefab);
			ContentAddition.AddMaster(bulwarkDroneMasterPrefab);
			ContentAddition.AddNetworkedObject(bulwarkDroneInteractablePrefab);
		}

		public override void SetupBehavior()
		{
			base.SetupBehavior();
		}

		public override void SetupConfig()
		{
			base.SetupConfig();
		}

		public override void Install()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.Install();
			DeathState.OnImpactServer += new hook_OnImpactServer(DeathState_OnImpactServer);
			CommonCode.dchList.Add(bulwarkDroneCDCH);
			if (Object.op_Implicit((Object)(object)ClassicStageInfo.instance))
			{
				Helpers.TryApplyChangesNow();
			}
		}

		public override void Uninstall()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.Uninstall();
			DeathState.OnImpactServer -= new hook_OnImpactServer(DeathState_OnImpactServer);
			CommonCode.dchList.Remove(bulwarkDroneCDCH);
			if (Object.op_Implicit((Object)(object)ClassicStageInfo.instance))
			{
				Helpers.TryApplyChangesNow();
			}
		}

		private void ModifyBodyPrefabWithVanillaAssets()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Expected O, but got Unknown
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: 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_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Expected O, but got Unknown
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: 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_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/EquipmentDroneBody"), "TkSatTempSetupPrefab2", false);
			bulwarkDroneBodyPrefab.GetComponent<CameraTargetParams>().cameraParams = Addressables.LoadAssetAsync<CharacterCameraParams>((object)"RoR2/Base/Common/ccpStandard.asset").WaitForCompletion();
			((Collider)bulwarkDroneBodyPrefab.GetComponent<BoxCollider>()).material = Addressables.LoadAssetAsync<PhysicMaterial>((object)"RoR2/Base/Common/physmatItems.physicMaterial").WaitForCompletion();
			AkEvent[] components = val.GetComponents<AkEvent>();
			foreach (AkEvent val2 in components)
			{
				AkEvent obj = bulwarkDroneBodyPrefab.AddComponent<AkEvent>();
				((AkTriggerHandler)obj).triggerList = ((AkTriggerHandler)val2).triggerList.ToArray().ToList();
				((AkTriggerHandler)obj).useOtherObject = ((AkTriggerHandler)val2).useOtherObject;
				obj.actionOnEventType = val2.actionOnEventType;
				obj.curveInterpolation = val2.curveInterpolation;
				obj.enableActionOnEvent = val2.enableActionOnEvent;
				obj.data = val2.data;
				obj.useCallbacks = val2.useCallbacks;
				obj.Callbacks = val2.Callbacks.ToArray().ToList();
				obj.playingId = val2.playingId;
				obj.soundEmitterObject = bulwarkDroneBodyPrefab;
				obj.transitionDuration = val2.transitionDuration;
			}
			Material val3 = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Common/TrimSheets/matTrimSheetConstructionBlue.mat").WaitForCompletion();
			CharacterModel component = ((Component)bulwarkDroneBodyPrefab.transform.Find("Model Base/BulwarkDrone")).GetComponent<CharacterModel>();
			component.itemDisplayRuleSet.SetDisplayRuleGroup((Object)(object)Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/DLC1/DroneWeapons/DroneWeaponsDisplay1.asset").WaitForCompletion(), new DisplayRuleGroup
			{
				rules = (ItemDisplayRule[])(object)new ItemDisplayRule[2]
				{
					new ItemDisplayRule
					{
						ruleType = (ItemDisplayRuleType)0,
						followerPrefabAddress = new AssetReferenceGameObject(""),
						followerPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/DroneWeapons/DisplayDroneWeaponLauncher.prefab").WaitForCompletion(),
						childName = "BulwarkDroneModel",
						localPos = new Vector3(0f, 0.78087f, 0.72665f),
						localAngles = new Vector3(356.5202f, 0f, 0f),
						localScale = new Vector3(1f, 1f, 1f)
					},
					new ItemDisplayRule
					{
						ruleType = (ItemDisplayRuleType)0,
						followerPrefabAddress = new AssetReferenceGameObject(""),
						followerPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/DroneWeapons/DisplayDroneWeaponRobotArm.prefab").WaitForCompletion(),
						childName = "BulwarkDroneModel",
						localPos = new Vector3(0.48613f, 0f, 0.41692f),
						localAngles = new Vector3(82.44529f, 86.80688f, 0.00014f),
						localScale = new Vector3(1.5f, 1.5f, 1.5f)
					}
				}
			});
			component.itemDisplayRuleSet.SetDisplayRuleGroup((Object)(object)Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/DLC1/DroneWeapons/DroneWeaponsDisplay2.asset").WaitForCompletion(), new DisplayRuleGroup
			{
				rules = (ItemDisplayRule[])(object)new ItemDisplayRule[2]
				{
					new ItemDisplayRule
					{
						ruleType = (ItemDisplayRuleType)0,
						followerPrefabAddress = new AssetReferenceGameObject(""),
						followerPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/DroneWeapons/DisplayDroneWeaponMinigun.prefab").WaitForCompletion(),
						childName = "BulwarkDroneModel",
						localPos = new Vector3(0f, 0.37601f, 0f),
						localAngles = new Vector3(-1E-05f, 180f, 180f),
						localScale = new Vector3(1f, 1f, 1f)
					},
					new ItemDisplayRule
					{
						ruleType = (ItemDisplayRuleType)0,
						followerPrefabAddress = new AssetReferenceGameObject(""),
						followerPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/DroneWeapons/DisplayDroneWeaponLauncher.prefab").WaitForCompletion(),
						childName = "BulwarkDroneModel",
						localPos = new Vector3(0f, 0.78087f, 0.72665f),
						localAngles = new Vector3(356.5202f, 0f, 0f),
						localScale = new Vector3(1f, 1f, 1f)
					}
				}
			});
			component.baseRendererInfos[0].defaultMaterial = val3;
			component.baseRendererInfos[0].renderer.material = val3;
			Material material = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Common/VFX/matOpaqueDustLargeDirectional.mat").WaitForCompletion();
			((Renderer)((Component)bulwarkDroneBodyPrefab.transform.Find("Model Base/BulwarkDrone/ThrusterExhaust")).GetComponent<ParticleSystemRenderer>()).material = material;
			Object.Destroy((Object)(object)val);
		}

		private void ModifyInteractablePrefabWithVanillaAssets()
		{
			//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)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Material material = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Drones/matDroneBrokenGeneric.mat").WaitForCompletion();
			((Renderer)((Component)bulwarkDroneInteractablePrefab.transform.Find("Model Base/BulwarkDrone")).GetComponent<MeshRenderer>()).material = material;
			Sprite visual = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texDroneIconOutlined.png").WaitForCompletion();
			bulwarkDroneInteractablePrefab.GetComponent<GenericInspectInfoProvider>().InspectInfo.Info.Visual = visual;
		}

		private void SetupSpawnCard()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			bulwarkDroneSpawnCard = TinkersSatchelPlugin.resources.LoadAsset<InteractableSpawnCard>("Assets/TinkersSatchel/Prefabs/Characters/BulwarkDrone/iscTkSatBulwarkDrone.asset");
			bulwarkDroneDirectorCard = new DirectorCard
			{
				spawnCard = (SpawnCard)(object)bulwarkDroneSpawnCard,
				minimumStageCompletions = 0,
				preventOverhead = false,
				selectionWeight = 2,
				spawnDistance = (MonsterSpawnDistance)0
			};
			bulwarkDroneDCH = new DirectorCardHolder
			{
				Card = bulwarkDroneDirectorCard,
				InteractableCategory = (InteractableCategory)5,
				MonsterCategory = (MonsterCategory)0
			};
			bulwarkDroneCDCH = new CommonCode.ConditionalDirectorCardHolder(bulwarkDroneDCH, CommonCode.expansionDef);
		}

		private void DeathState_OnImpactServer(orig_OnImpactServer orig, DeathState self, Vector3 contactPoint)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Invalid comparison between Unknown and I4
			orig.Invoke(self, contactPoint);
			if (!Object.op_Implicit((Object)(object)((EntityState)self).characterBody) || !((Object)(object)BodyCatalog.GetBodyPrefab(((EntityState)self).characterBody.bodyIndex) == (Object)(object)bulwarkDroneBodyPrefab))
			{
				return;
			}
			GameObject val = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)bulwarkDroneSpawnCard, new DirectorPlacementRule
			{
				placementMode = (PlacementMode)0,
				position = contactPoint
			}, base.rng));
			if (Object.op_Implicit((Object)(object)val))
			{
				PurchaseInteraction component = val.GetComponent<PurchaseInteraction>();
				if (Object.op_Implicit((Object)(object)component) && (int)component.costType == 1)
				{
					component.Networkcost = Run.instance.GetDifficultyScaledCost(component.cost);
				}
			}
		}
	}
	[RequireComponent(typeof(TeamComponent), typeof(CharacterBody))]
	public class TauntNearbyBehaviour : MonoBehaviour
	{
		public float range = 100f;

		public float tauntChancePerTargetPerInterval = 0.25f;

		public float scanInterval = 5f;

		public HurtBox hurtbox;

		private TeamComponent teamcpt;

		private CharacterBody body;

		private float stopwatch;

		private void Awake()
		{
			teamcpt = ((Component)this).GetComponent<TeamComponent>();
			body = ((Component)this).GetComponent<CharacterBody>();
		}

		private void FixedUpdate()
		{
			if (!NetworkServer.active)
			{
				return;
			}
			stopwatch -= Time.fixedDeltaTime;
			if (!(stopwatch <= 0f))
			{
				return;
			}
			float rangeSq = range * range;
			stopwatch = scanInterval;
			IEnumerable<BaseAI> source = from x in CharacterBody.readOnlyInstancesList.Where(delegate(CharacterBody x)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: 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_0053: Unknown result type (might be due to invalid IL or missing references)
					//IL_0060: Unknown result type (might be due to invalid IL or missing references)
					//IL_0066: Invalid comparison between Unknown and I4
					Vector3 val = x.transform.position - ((Component)this).transform.position;
					return ((Vector3)(ref val)).sqrMagnitude < rangeSq && Object.op_Implicit((Object)(object)x.master) && x.teamComponent.teamIndex != teamcpt.teamIndex && (int)x.teamComponent.teamIndex > 0;
				})
				select ((Component)x.master).GetComponent<BaseAI>() into x
				where Object.op_Implicit((Object)(object)x)
				select x;
			int num = (Object.op_Implicit((Object)(object)body.master) ? Compat_Dronemeld.SafeGetStackCount(body.master.inventory) : 0);
			float num2 = 1f - Mathf.Pow(1f - tauntChancePerTargetPerInterval, (float)(num + 1));
			source = source.OrderBy((BaseAI t) => Module<BulwarkDrone>.instance.rng.nextNormalizedFloat).Take(Mathf.RoundToInt((float)source.Count() * num2));
			foreach (BaseAI item in source)
			{
				TauntDebuffController.ApplyTaunt(item, body, scanInterval);
			}
		}
	}
	public static class CatalogUtil
	{
		public static bool TryGetItemDef(PickupIndex pickupIndex, out ItemDef itemDef)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			itemDef = null;
			if (pickupIndex == PickupIndex.none)
			{
				return false;
			}
			PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
			if (pickupDef == null || (int)pickupDef.itemIndex == -1)
			{
				return false;
			}
			itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
			return (Object)(object)itemDef != (Object)null;
		}

		public static bool TryGetItemDef(PickupDef pickupDef, out ItemDef itemDef)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			itemDef = null;
			if (pickupDef == null || (int)pickupDef.itemIndex == -1)
			{
				return false;
			}
			itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
			return (Object)(object)itemDef != (Object)null;
		}

		public static bool TryGetItemDef(ItemIndex itemIndex, out ItemDef itemDef)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			itemDef = null;
			if ((int)itemIndex == -1)
			{
				return false;
			}
			itemDef = ItemCatalog.GetItemDef(itemIndex);
			return (Object)(object)itemDef != (Object)null;
		}

		public static bool TryGetEquipmentDef(PickupIndex pickupIndex, out EquipmentDef equipmentDef)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			equipmentDef = null;
			if (pickupIndex == PickupIndex.none)
			{
				return false;
			}
			PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
			if (pickupDef == null || (int)pickupDef.equipmentIndex == -1)
			{
				return false;
			}
			equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
			return (Object)(object)equipmentDef != (Object)null;
		}

		public static bool TryGetEquipmentDef(PickupDef pickupDef, out EquipmentDef equipmentDef)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			equipmentDef = null;
			if (pickupDef == null || (int)pickupDef.equipmentIndex == -1)
			{
				return false;
			}
			equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
			return (Object)(object)equipmentDef != (Object)null;
		}

		public static bool TryGetEquipmentDef(EquipmentIndex equipmentIndex, out EquipmentDef equipmentDef)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			equipmentDef = null;
			if ((int)equipmentIndex == -1)
			{
				return false;
			}
			equipmentDef = EquipmentCatalog.GetEquipmentDef(equipmentIndex);
			return (Object)(object)equipmentDef != (Object)null;
		}
	}
	public class CommonCode : Module<CommonCode>
	{
		internal class ConditionalDirectorCardHolder
		{
			public DirectorCardHolder directorCardHolder;

			public ExpansionDef[] requiredExpansions;

			public ConditionalDirectorCardHolder(DirectorCardHolder dch, params ExpansionDef[] exps)
			{
				directorCardHolder = dch;
				requiredExpansions = exps;
			}
		}

		public static ExpansionDef expansionDef;

		public static ExpansionDef voidExpansionDef;

		public static DirectorCardCategorySelection globalInteractablesDccs;

		private static GameObject _worldSpaceWeaponDummy = null;

		internal static HashSet<ConditionalDirectorCardHolder> dchList = new HashSet<ConditionalDirectorCardHolder>();

		public override bool managedEnable => false;

		[Obsolete("Replaced by TimedSkillDisableModule.disabledSkillDef.")]
		public static SkillDef disabledSkillDef => TimedSkillDisableModule.disabledSkillDef;

		[Obsolete("Replaced by TauntDebuffModule.tauntDebuff.")]
		public static BuffDef tauntDebuff => TauntDebuffModule.tauntDebuff;

		public static GameObject worldSpaceWeaponDummy
		{
			get
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				if (!Object.op_Implicit((Object)(object)_worldSpaceWeaponDummy))
				{
					_worldSpaceWeaponDummy = new GameObject("Workaround for an Inconvenient Quirk of BulletAttack");
				}
				return _worldSpaceWeaponDummy;
			}
		}

		private void _SetupExpansions()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			expansionDef = TinkersSatchelPlugin.resources.LoadAsset<ExpansionDef>("Assets/TinkersSatchel/TinkersSatchelExpansion.asset");
			voidExpansionDef = TinkersSatchelPlugin.resources.LoadAsset<ExpansionDef>("Assets/TinkersSatchel/TinkersSatchelVoidExpansion.asset");
			Sprite disabledIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texUnlockIcon.png").WaitForCompletion();
			expansionDef.disabledIconSprite = disabledIconSprite;
			voidExpansionDef.disabledIconSprite = disabledIconSprite;
			voidExpansionDef.requiredEntitlement = Addressables.LoadAssetAsync<EntitlementDef>((object)"RoR2/DLC1/Common/entitlementDLC1.asset").WaitForCompletion();
			ContentAddition.AddExpansionDef(expansionDef);
			ContentAddition.AddExpansionDef(voidExpansionDef);
		}

		private void _SetupInteractablesCategory()
		{
			globalInteractablesDccs = TinkersSatchelPlugin.resources.LoadAsset<DirectorCardCategorySelection>("Assets/TinkersSatchel/dccsTkSatGlobalInteractables.asset");
			DirectorAPI.InteractableActions += DirectorAPI_InteractableActions;
		}

		private void DirectorAPI_InteractableActions(DccsPool arg1, StageInfo arg2)
		{
			IEnumerable<ConditionalDirectorCardHolder> enumerable = dchList.Where((ConditionalDirectorCardHolder dch) => dch.requiredExpansions.All((ExpansionDef ed) => Run.instance.IsExpansionEnabled(ed)));
			Category[] poolCategories = arg1.poolCategories;
			foreach (Category val in poolCategories)
			{
				PoolEntry[] alwaysIncluded = val.alwaysIncluded;
				foreach (PoolEntry val2 in alwaysIncluded)
				{
					foreach (ConditionalDirectorCardHolder item in enumerable)
					{
						DirectorAPI.AddCard(val2.dccs, item.directorCardHolder);
					}
				}
				ConditionalPoolEntry[] includedIfConditionsMet = val.includedIfConditionsMet;
				foreach (ConditionalPoolEntry val3 in includedIfConditionsMet)
				{
					foreach (ConditionalDirectorCardHolder item2 in enumerable)
					{
						DirectorAPI.AddCard(((PoolEntry)val3).dccs, item2.directorCardHolder);
					}
				}
				alwaysIncluded = val.includedIfNoConditionsMet;
				foreach (PoolEntry val4 in alwaysIncluded)
				{
					foreach (ConditionalDirectorCardHolder item3 in enumerable)
					{
						DirectorAPI.AddCard(val4.dccs, item3.directorCardHolder);
					}
				}
			}
		}

		public override void SetupAttributes()
		{
			base.SetupAttributes();
			_SetupExpansions();
			_SetupInteractablesCategory();
		}

		public override void SetupBehavior()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.SetupBehavior();
			BulletAttack.FireSingle += new hook_FireSingle(BulletAttack_FireSingle);
		}

		private void BulletAttack_FireSingle(orig_FireSingle orig, BulletAttack self, FireSingleArgs args)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)self.weapon == (Object)(object)worldSpaceWeaponDummy)
			{
				self.weapon = null;
			}
			orig.Invoke(self, args);
		}

		internal static void RetrieveDefaultMaterials(ItemDisplay disp)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < disp.rendererInfos.Length; i++)
			{
				RendererInfo val = disp.rendererInfos[i];
				val.defaultMaterial = val.renderer.material;
				disp.rendererInfos[i] = val;
			}
		}

		public static GameObject GetRootWithLocators(GameObject target, int maxSearch = 5)
		{
			if (!Object.op_Implicit((Object)(object)target))
			{
				return null;
			}
			GameObject val = target;
			EntityLocator val2 = default(EntityLocator);
			for (int i = 0; i < maxSearch; i++)
			{
				if (val.TryGetComponent<EntityLocator>(ref val2) && Object.op_Implicit((Object)(object)val2.entity))
				{
					val = val2.entity;
					continue;
				}
				Transform root = val.transform.root;
				if (Object.op_Implicit((Object)(object)root) && (Object)(object)((Component)root).gameObject != (Object)(object)val)
				{
					val = ((Component)root).gameObject;
					continue;
				}
				return val;
			}
			return val;
		}

		internal static GameObject FindNearestInteractable(GameObject senderObj, HashSet<string> validObjectNames, Ray aim, float maxAngle, float maxDistance, bool requireLoS)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			float num = default(float);
			aim = CameraRigController.ModifyAimRayIfApplicable(aim, senderObj, ref num);
			Collider[] array = Physics.OverlapSphere(((Ray)(ref aim)).origin, maxDistance + num, -1, (QueryTriggerInteraction)2);
			float num2 = Mathf.Cos(Mathf.Clamp(maxAngle, 0f, 180f) * MathF.PI / 180f);
			GameObject result = null;
			float num3 = float.MaxValue;
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)((Component)val).gameObject))
				{
					continue;
				}
				GameObject rootWithLocators = GetRootWithLocators(((Component)val).gameObject);
				if (!validObjectNames.Contains(((Object)rootWithLocators).name.Replace("(Clone)", "")))
				{
					continue;
				}
				Vector3 direction = ((Ray)(ref aim)).direction;
				Vector3 val2 = rootWithLocators.transform.position - ((Ray)(ref aim)).origin;
				float num4 = Vector3.Dot(direction, ((Vector3)(ref val2)).normalized);
				if (!(num4 < num2) && (!requireLoS || Physics.Linecast(((Ray)(ref aim)).origin, rootWithLocators.transform.position, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask))))
				{
					float num5 = num4 * Vector3.Distance(rootWithLocators.transform.position, ((Ray)(ref aim)).origin);
					if (num5 < num3)
					{
						num3 = num5;
						result = rootWithLocators;
					}
				}
			}
			return result;
		}

		public static bool PickupIndexIsAISafe(PickupIndex pind)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (CatalogUtil.TryGetItemDef(pind, out var itemDef))
			{
				return !itemDef.ContainsTag((ItemTag)4);
			}
			return false;
		}

		public static PickupIndex GenerateAISafePickup(Xoroshiro128Plus rng, List<PickupIndex> selection)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			IEnumerable<PickupIndex> source = selection.Where((PickupIndex pind) => PickupIndexIsAISafe(pind));
			if (source.Count() == 0)
			{
				TinkersSatchelPlugin._logger.LogError((object)"GenerateAISafePickup (single uniform list): selection contained 0 valid items");
				return PickupIndex.none;
			}
			return rng.NextElementUniform<PickupIndex>(source.ToArray());
		}

		public static PickupIndex GenerateAISafePickup(Xoroshiro128Plus rng, WeightedSelection<List<PickupIndex>> selection)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			WeightedSelection<PickupIndex> val = new WeightedSelection<PickupIndex>(8);
			ChoiceInfo<List<PickupIndex>>[] choices = selection.choices;
			for (int i = 0; i < choices.Length; i++)
			{
				ChoiceInfo<List<PickupIndex>> val2 = choices[i];
				foreach (PickupIndex item in val2.value)
				{
					if (PickupIndexIsAISafe(item))
					{
						val.AddChoice(item, val2.weight);
					}
				}
			}
			if (val.choices.Length == 0)
			{
				TinkersSatchelPlugin._logger.LogError((object)"GenerateAISafePickup (single selection): selection contained 0 valid items");
				return PickupIndex.none;
			}
			return val.Evaluate(rng.nextNormalizedFloat);
		}

		public static PickupIndex GenerateAISafePickup(Xoroshiro128Plus rng, PickupDropTable dropTable, WeightedSelection<List<PickupIndex>> fallback)
		{
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			WeightedSelection<UniquePickup> val = new WeightedSelection<UniquePickup>(8);
			BasicPickupDropTable val2 = (BasicPickupDropTable)(object)((dropTable is BasicPickupDropTable) ? dropTable : null);
			if (val2 != null)
			{
				foreach (ChoiceInfo<UniquePickup> item in val2.selector.choices.Where((ChoiceInfo<UniquePickup> c) => PickupIndexIsAISafe(c.value.pickupIndex)))
				{
					val.AddChoice(item);
				}
			}
			else
			{
				ExplicitPickupDropTable val3 = (ExplicitPickupDropTable)(object)((dropTable is ExplicitPickupDropTable) ? dropTable : null);
				if (val3 != null)
				{
					foreach (ChoiceInfo<UniquePickup> item2 in val3.weightedSelection.choices.Where((ChoiceInfo<UniquePickup> c) => PickupIndexIsAISafe(c.value.pickupIndex)))
					{
						val.AddChoice(item2);
					}
				}
			}
			if (val.choices.Length == 0)
			{
				ChoiceInfo<List<PickupIndex>>[] choices = fallback.choices;
				for (int i = 0; i < choices.Length; i++)
				{
					ChoiceInfo<List<PickupIndex>> val4 = choices[i];
					foreach (PickupIndex item3 in val4.value)
					{
						if (PickupIndexIsAISafe(item3))
						{
							val.AddChoice(new UniquePickup(item3), val4.weight);
						}
					}
				}
			}
			if (val.choices.Length == 0)
			{
				TinkersSatchelPlugin._logger.LogError((object)"GenerateAISafePickup (droptable and weighted fallback): both normal and fallback selections contained 0 valid items");
				return PickupIndex.none;
			}
			return val.Evaluate(rng.nextNormalizedFloat).pickupIndex;
		}

		public static PickupIndex GenerateAISafePickup(Xoroshiro128Plus rng, PickupDropTable dropTable, List<PickupIndex> fallback)
		{
			//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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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)
			WeightedSelection<UniquePickup> val = new WeightedSelection<UniquePickup>(8);
			BasicPickupDropTable val2 = (BasicPickupDropTable)(object)((dropTable is BasicPickupDropTable) ? dropTable : null);
			if (val2 != null)
			{
				foreach (ChoiceInfo<UniquePickup> item in val2.selector.choices.Where((ChoiceInfo<UniquePickup> c) => PickupIndexIsAISafe(c.value.pickupIndex)))
				{
					val.AddChoice(item);
				}
			}
			else
			{
				ExplicitPickupDropTable val3 = (ExplicitPickupDropTable)(object)((dropTable is ExplicitPickupDropTable) ? dropTable : null);
				if (val3 != null)
				{
					foreach (ChoiceInfo<UniquePickup> item2 in val3.weightedSelection.choices.Where((ChoiceInfo<UniquePickup> c) => PickupIndexIsAISafe(c.value.pickupIndex)))
					{
						val.AddChoice(item2);
					}
				}
			}
			if (val.choices.Length == 0)
			{
				foreach (PickupIndex item3 in fallback)
				{
					if (PickupIndexIsAISafe(item3))
					{
						val.AddChoice(new UniquePickup(item3), 1f);
					}
				}
			}
			if (val.choices.Length == 0)
			{
				TinkersSatchelPlugin._logger.LogError((object)"GenerateAISafePickup (droptable and uniform fallback): both normal and fallback selections contained 0 valid items");
				return PickupIndex.none;
			}
			return val.Evaluate(rng.nextNormalizedFloat).pickupIndex;
		}

		public static List<TeamComponent> GatherEnemies(TeamIndex allyIndex, params TeamIndex[] ignore)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			List<TeamComponent> list = new List<TeamComponent>();
			bool flag = (int)FriendlyFireManager.friendlyFireMode > 0;
			foreach (TeamIndex item in ((TeamIndex[])Enum.GetValues(typeof(TeamIndex))).Except(ignore))
			{
				if (flag || allyIndex != item)
				{
					list.AddRange(TeamComponent.GetTeamMembers(item));
				}
			}
			return list;
		}

		public static Language GetBestLanguage(string langID)
		{
			return ((langID == null) ? null : Language.FindLanguageByName(langID)) ?? Language.currentLanguage ?? Language.english;
		}
	}
	public static class CommonCodeExtensions
	{
		internal static Quaternion ApplyRandomSpread(this Xoroshiro128Plus rng, Quaternion targetRotation, float coneHalfAngleDegr)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			float num = rng.nextNormalizedFloat * MathF.PI * 2f;
			float num2 = Mathf.Lerp(Mathf.Cos(coneHalfAngleDegr * MathF.PI / 180f), 1f, rng.nextNormalizedFloat);
			float num3 = Mathf.Sqrt(1f - num2 * num2);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(num3 * Mathf.Cos(num), num3 * Mathf.Sin(num), num2);
			return targetRotation * Quaternion.LookRotation(val);
		}

		public static void ReflAddEventHandler(this EventInfo evt, object o, Action<object, EventArgs> lam)
		{
			ParameterExpression[] array = (from p in evt.EventHandlerType.GetMethod("Invoke").GetParameters()
				select Expression.Parameter(p.ParameterType)).ToArray();
			Delegate handler = Expression.Lambda(evt.EventHandlerType, Expression.Call(Expression.Constant(lam), lam.GetType().GetMethod("Invoke"), array[0], array[1]), array).Compile();
			evt.AddEventHandler(o, handler);
		}
	}
	public class FilingDictionary<T> : IEnumerable<T>, IEnumerable
	{
		private readonly Dictionary<Type, T> _dict = new Dictionary<Type, T>();

		public int Count => _dict.Count;

		public void Add(T inst)
		{
			_dict.Add(inst.GetType(), inst);
		}

		public void Add<subT>(subT inst) where subT : T
		{
			_dict.Add(typeof(subT), (T)(object)inst);
		}

		public void Set<subT>(subT inst) where subT : T
		{
			_dict[typeof(subT)] = (T)(object)inst;
		}

		public subT Get<subT>() where subT : T
		{
			return (subT)(object)_dict[typeof(subT)];
		}

		public void Remove(T inst)
		{
			_dict.Remove(inst.GetType());
		}

		public void RemoveWhere(Func<T, bool> predicate)
		{
			foreach (T item in _dict.Values.Where(predicate).ToList())
			{
				_dict.Remove(item.GetType());
			}
		}

		public IEnumerator<T> GetEnumerator()
		{
			return _dict.Values.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		public ReadOnlyFilingDictionary<T> AsReadOnly()
		{
			return new ReadOnlyFilingDictionary<T>(this);
		}
	}
	public class ReadOnlyFilingDictionary<T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
	{
		private readonly FilingDictionary<T> baseCollection;

		public int Count => baseCollection.Count;

		public ReadOnlyFilingDictionary(FilingDictionary<T> baseCollection)
		{
			this.baseCollection = baseCollection;
		}

		public IEnumerator<T> GetEnumerator()
		{
			return baseCollection.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return baseCollection.GetEnumerator();
		}
	}
	public class FloatDebuffModule : Module<FloatDebuffModule>
	{
		public static BuffDef floatDebuff;

		public override bool managedEnable => false;

		public override void SetupAttributes()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			base.SetupAttributes();
			floatDebuff = ScriptableObject.CreateInstance<BuffDef>();
			floatDebuff.buffColor = Color.white;
			floatDebuff.canStack = false;
			floatDebuff.isDebuff = true;
			((Object)floatDebuff).name = "TKSATFloat";
			floatDebuff.iconSprite = TinkersSatchelPlugin.resources.LoadAsset<Sprite>("Assets/TinkersSatchel/Textures/MiscIcons/floatDebuffIcon.png");
			floatDebuff.ignoreGrowthNectar = true;
			ContentAddition.AddBuffDef(floatDebuff);
		}

		public override void SetupBehavior()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			base.SetupBehavior();
			Util.CleanseBody += new hook_CleanseBody(Util_CleanseBody);
		}

		private void Util_CleanseBody(orig_CleanseBody orig, CharacterBody characterBody, bool removeDebuffs, bool removeBuffs, bool removeCooldownBuffs, bool removeDots, bool removeStun, bool removeNearbyProjectiles)
		{
			orig.Invoke(characterBody, removeDebuffs, removeBuffs, removeCooldownBuffs, removeDots, removeStun, removeNearbyProjectiles);
			FloatDebuffController floatDebuffController = default(FloatDebuffController);
			if (removeDebuffs && Object.op_Implicit((Object)(object)characterBody) && ((Component)characterBody).TryGetComponent<FloatDebuffController>(ref floatDebuffController))
			{
				Object.Destroy((Object)(object)floatDebuffController);
			}
		}

		public static void Inflict(HealthComponent target, DamageInfo damageInfo, FloatDebuffController.FloatDebuffParams debuffParams)
		{
			FloatDebuffController floatDebuffController = ((Component)target).gameObject.GetComponent<FloatDebuffController>();
			if (!Object.op_Implicit((Object)(object)floatDebuffController))
			{
				floatDebuffController = ((Component)target).gameObject.AddComponent<FloatDebuffController>();
			}
			floatDebuffController.Inflict(damageInfo, debuffParams);
		}
	}
	[RequireComponent(typeof(HealthComponent))]
	public class FloatDebuffController : MonoBehaviour
	{
		public struct FloatDebuffParams
		{
			public float duration;

			public float height;

			public float wobbleRadius;

			public float wobbleSpeed;

			public float wobbleForce;

			public float slamForce;
		}

		private HealthComponent healthComponent;

		private IPhysMotor motor;

		private bool started;

		public Vector3 targetHoldPos;

		public float holdStopwatch;

		public float wobbleSeed;

		public DamageInfo deferredDamageInfo;

		public FloatDebuffParams debuffParams;

		private void Awake()
		{
			healthComponent = ((Component)this).GetComponent<HealthComponent>();
		}

		private void FixedUpdate()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00ca: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			if (started)
			{
				holdStopwatch -= Time.fixedDeltaTime;
				float num = (holdStopwatch + wobbleSeed) * MathF.PI * debuffParams.wobbleSpeed;
				Vector3 val = targetHoldPos + new Vector3(Mathf.Cos(num), Mathf.Cos(num * 2f), Mathf.Cos(num * 3f)) * debuffParams.wobbleRadius - healthComponent.body.transform.position;
				float num2 = Mathf.Min(debuffParams.wobbleForce, ((Vector3)(ref val)).magnitude);
				val = ((Vector3)(ref val)).normalized * Mathf.Pow(num2 / debuffParams.wobbleForce, 0.5f) * debuffParams.wobbleForce;
				IPhysMotor obj = motor;
				PhysForceInfo val2 = new PhysForceInfo
				{
					force = (val - motor.velocity) * motor.mass
				};
				((PhysForceInfo)(ref val2)).ignoreGroundStick = true;
				((PhysForceInfo)(ref val2)).disableAirControlUntilCollision = false;
				obj.ApplyForceImpulse(ref val2);
				if (holdStopwatch <= 0f)
				{
					IPhysMotor obj2 = motor;
					val2 = new PhysForceInfo
					{
						force = new Vector3(0f, 0f - debuffParams.slamForce, 0f) * motor.mass
					};
					((PhysForceInfo)(ref val2)).ignoreGroundStick = true;
					((PhysForceInfo)(ref val2)).disableAirControlUntilCollision = false;
					obj2.ApplyForceImpulse(ref val2);
					healthComponent.TakeDamage(deferredDamageInfo);
					Object.Destroy((Object)(object)this);
				}
			}
		}

		public void Inflict(DamageInfo damageInfo, FloatDebuffParams debuffParams)
		{
			//IL_008b: 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_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)
			if (!healthComponent.alive)
			{
				return;
			}
			if (deferredDamageInfo != null)
			{
				healthComponent.TakeDamage(deferredDamageInfo);
			}
			deferredDamageInfo = damageInfo;
			this.debuffParams = debuffParams;
			SetStateOnHurt val = default(SetStateOnHurt);
			if (!((Component)healthComponent).TryGetComponent<SetStateOnHurt>(ref val) || !((Component)healthComponent).TryGetComponent<IPhysMotor>(ref motor) || !val.canBeStunned)
			{
				healthComponent.TakeDamage(deferredDamageInfo);
				Object.Destroy((Object)(object)this);
				return;
			}
			if (!started)
			{
				targetHoldPos = ((Component)healthComponent).transform.position + new Vector3(0f, debuffParams.height, 0f);
			}
			wobbleSeed = Time.fixedTime % 1f;
			if (holdStopwatch < debuffParams.duration)
			{
				holdStopwatch = debuffParams.duration;
			}
			started = true;
		}
	}
	public static class MathUtil
	{
		public static float Wrap(float x, float min, float max)
		{
			if (x < min)
			{
				return max - (min - x) % (max - min);
			}
			return min + (x - min) % (max - min);
		}

		public static float SteepSigmoid01(float x, float b)
		{
			return 0.5f - (float)Math.Tanh(2f * b * (x - 0.5f)) / (2f * (float)Math.Tanh(0f - b));
		}

		internal static Quaternion ApplyRandomSpread(Quaternion targetRotation, float coneHalfAngleDegr)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			float num = Random.Range(0f, MathF.PI * 2f);
			float num2 = Random.Range(Mathf.Cos(coneHalfAngleDegr * MathF.PI / 180f), 1f);
			float num3 = Mathf.Sqrt(1f - num2 * num2);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(num3 * Mathf.Cos(num), num3 * Mathf.Sin(num), num2);
			return targetRotation * Quaternion.LookRotation(val);
		}

		public static (Vector3 vInitial, float tFinal) CalculateVelocityForFinalPosition(Vector3 source, Vector3 target, float extraPeakHeight)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0008: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = target - source;
			float y = val.y;
			float num = Mathf.Max(new float[3]
			{
				Mathf.Max(y, 0f) + extraPeakHeight,
				y,
				0f
			});
			float num2 = 0f - Physics.gravity.y;
			float num3 = Mathf.Sqrt(2f * num2 * num);
			float num4 = Mathf.Sqrt(2f) / num2 * (Mathf.Sqrt(num2 * (num - y)) + Mathf.Sqrt(num2 * num));
			float num5 = val.x / num4;
			float num6 = val.z / num4;
			return (new Vector3(num5, num3, num6), num4);
		}

		public static bool TrajectorySphereCast(out RaycastHit hit, Vector3 source, Vector3 vInitial, float tFinal, float radius, int resolution, int layerMask = -5, QueryTriggerInteraction qTI = 0)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = source;
			for (int i = 0; i < resolution; i++)
			{
				Vector3 val2 = val;
				val = Trajectory.CalculatePositionAtTime(source, vInitial, ((float)i / (float)resolution + 1f) * tFinal);
				Vector3 val3 = val - val2;
				if (Physics.SphereCast(new Ray(val2, ((Vector3)(ref val3)).normalized), radius, ref hit, ((Vector3)(ref val3)).magnitude, layerMask, qTI))
				{
					return true;
				}
			}
			hit = default(RaycastHit);
			return false;
		}

		public static List<Vector3> CollectNearestNodeLaunchVelocities(NodeGraph graph, int desiredCount, float minRange, float maxRange, Vector3 source, float extraPeakHeight, float radius, float maxDeviation, int trajectoryResolution, int layerMask = -5, QueryTriggerInteraction qTI = 0, HullMask hullMask = 1)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			IOrderedEnumerable<Vector3> orderedEnumerable = graph.FindNodesInRange(source, minRange, maxRange, hullMask).Select(delegate(NodeIndex x)
			{
				//IL_0006: 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)
				Vector3 result = default(Vector3);
				graph.GetNodePosition(x, ref result);
				return result;
			}).OrderBy(delegate(Vector3 x)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//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)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val3 = x - source;
				return ((Vector3)(ref val3)).sqrMagnitude;
			});
			List<Vector3> list = new List<Vector3>();
			float num = maxDeviation * maxDeviation;
			foreach (Vector3 item in orderedEnumerable)
			{
				var (val, tFinal) = CalculateVelocityForFinalPosition(source, item, extraPeakHeight);
				if (TrajectorySphereCast(out var hit, source, val, tFinal, radius, trajectoryResolution, layerMask, qTI))
				{
					Vector3 val2 = ((RaycastHit)(ref hit)).point - item;
					if (((Vector3)(ref val2)).sqrMagnitude <= num)
					{
						list.Add(val);
					}
				}
				if (list.Count >= desiredCount)
				{
					break;
				}
			}
			return list;
		}
	}
	public class MiscObjectTrackerModule : Module<MiscObjectTrackerModule>
	{
		private static readonly List<GameObject> warbanners = new List<GameObject>();

		public static readonly ReadOnlyCollection<GameObject> readOnlyWarbanners = new ReadOnlyCollection<GameObject>(warbanners);

		private static readonly List<GameObject> randomDamageZones = new List<GameObject>();

		public static readonly ReadOnlyCollection<GameObject> readOnlyRandomDamageZones = new ReadOnlyCollection<GameObject>(randomDamageZones);

		private static readonly List<GameObject> crippleWards = new List<GameObject>();

		public static readonly ReadOnlyCollection<GameObject> readOnlyCrippleWards = new ReadOnlyCollection<GameObject>(crippleWards);

		internal static readonly List<GameObject> deskplants = new List<GameObject>();

		public static readonly ReadOnlyCollection<GameObject> readOnlyDeskplants = new ReadOnlyCollection<GameObject>(deskplants);

		public override bool managedEnable => false;

		public override void SetupAttributes()
		{
			base.SetupAttributes();
		}

		public override void SetupBehavior()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			base.SetupBehavior();
			BuffWard.OnEnable += new hook_OnEnable(BuffWard_OnEnable);
			BuffWard.OnDisable += new hook_OnDisable(BuffWard_OnDisable);
			HealingWard.Awake += new hook_Awake(HealingWard_Awake);
		}

		private void HealingWard_Awake(orig_Awake orig, HealingWard self)
		{
			orig.Invoke(self);
			((Component)self).gameObject.AddComponent<HealingWardInstanceTracker>();
		}

		private void BuffWard_OnEnable(orig_OnEnable orig, BuffWard self)
		{
			orig.Invoke(self);
			switch (((Object)((Component)self).gameObject).name)
			{
			case "WarbannerWard(Clone)":
				warbanners.Add(((Component)self).gameObject);
				break;
			case "DamageZoneWard(Clone)":
				randomDamageZones.Add(((Component)self).gameObject);
				break;
			case "CrippleWard(Clone)":
				crippleWards.Add(((Component)self).gameObject);
				break;
			}
		}

		private void BuffWard_OnDisable(orig_OnDisable orig, BuffWard self)
		{
			orig.Invoke(self);
			switch (((Object)((Component)self).gameObject).name)
			{
			case "WarbannerWard(Clone)":
				warbanners.Remove(((Component)self).gameObject);
				break;
			case "DamageZoneWard(Clone)":
				randomDamageZones.Remove(((Component)self).gameObject);
				break;
			case "CrippleWard(Clone)":
				crippleWards.Remove(((Component)self).gameObject);
				break;
			}
		}
	}
	public class HealingWardInstanceTracker : MonoBehaviour
	{
		private void OnEnable()
		{
			if (((Object)((Component)this).gameObject).name == "DeskplantWard(Clone)")
			{
				MiscObjectTrackerModule.deskplants.Add(((Component)this).gameObject);
			}
		}

		private void OnDisable()
		{
			if (((Object)((Component)this).gameObject).name == "DeskplantWard(Clone)")
			{
				MiscObjectTrackerModule.deskplants.Remove(((Component)this).gameObject);
			}
		}
	}
	public class AutoConfigBinding
	{
		public enum DeferType
		{
			UpdateImmediately,
			WaitForNextStage,
			WaitForRunEnd,
			NeverAutoUpdate
		}

		internal static readonly List<AutoConfigBinding> instances = new List<AutoConfigBinding>();

		internal static readonly Dictionary<AutoConfigBinding, (object, bool)> stageDirtyInstances = new Dictionary<AutoConfigBinding, (object, bool)>();

		internal static readonly Dictionary<AutoConfigBinding, object> runDirtyInstances = new Dictionary<AutoConfigBinding, object>();

		internal bool isOverridden;

		public AutoConfigContainer owner { get; internal set; }

		public object target { get; internal set; }

		public ConfigEntryBase configEntry { get; internal set; }

		public PropertyInfo boundProperty { get; internal set; }

		public string modName { get; internal set; }

		public AutoConfigUpdateActionsAttribute updateEventAttribute { get; internal set; }

		public MethodInfo propGetter { get; internal set; }

		public MethodInfo propSetter { get; internal set; }

		public Type propType { get; internal set; }

		public object boundKey { get; internal set; }

		public bool onDict { get; internal set; }

		public bool allowConCmd { get; internal set; }

		public object cachedValue { get; internal set; }

		public DeferType deferType { get; internal set; }

		public string readablePath => modName + "/" + configEntry.Definition.Section + "/" + configEntry.Definition.Key;

		internal static void CleanupDirty(bool isRunEnd)
		{
			TinkersSatchelPlugin._logger.LogDebug((object)$"Stage ended; applying {stageDirtyInstances.Count} deferred config changes...");
			foreach (AutoConfigBinding key in stageDirtyInstances.Keys)
			{
				key.DeferredUpdateProperty(stageDirtyInstances[key].Item1, stageDirtyInstances[key].Item2);
			}
			stageDirtyInstances.Clear();
			if (!isRunEnd)
			{
				return;
			}
			TinkersSatchelPlugin._logger.LogDebug((object)$"Run ended; applying {runDirtyInstances.Count} deferred config changes...");
			foreach (AutoConfigBinding key2 in runDirtyInstances.Keys)
			{
				key2.DeferredUpdateProperty(runDirtyInstances[key2], silent: true);
			}
			runDirtyInstances.Clear();
		}

		internal AutoConfigBinding()
		{
			instances.Add(this);
		}

		~AutoConfigBinding()
		{
			if (instances.Contains(this))
			{
				instances.Remove(this);
			}
		}

		internal void OverrideProperty(object newValue, bool silent = false)
		{
			if (!isOverridden)
			{
				runDirtyInstances[this] = cachedValue;
			}
			isOverridden = true;
			UpdateProperty(newValue, silent);
		}

		private void DeferredUpdateProperty(object newValue, bool silent = false)
		{
			object oldValue = propGetter.Invoke(target, (!onDict) ? new object[0] : new object[1] { boundKey });
			propSetter.Invoke(target, (!onDict) ? new object[1] { newValue } : new object[2] { boundKey, newValue });
			AutoConfigUpdateActionTypes autoConfigUpdateActionTypes = updateEventAttribute?.flags ?? AutoConfigUpdateActionTypes.None;
			AutoConfigUpdateActionsAttribute autoConfigUpdateActionsAttribute = updateEventAttribute;
			if (autoConfigUpdateActionsAttribute != null && !autoConfigUpdateActionsAttribute.ignoreDefault)
			{
				autoConfigUpdateActionTypes |= owner.defaultEnabledUpdateFlags;
			}
			cachedValue = newValue;
			owner.OnConfigChanged(new AutoConfigUpdateActionEventArgs
			{
				flags = autoConfigUpdateActionTypes,
				oldValue = oldValue,
				newValue = newValue,
				target = this,
				silent = silent
			});
		}

		internal void UpdateProperty(object newValue, bool silent = false)
		{
			if (deferType == DeferType.UpdateImmediately || (Object)(object)Run.instance == (Object)null || !((Behaviour)Run.instance).enabled)
			{
				DeferredUpdateProperty(newValue, silent);
			}
			else if (deferType == DeferType.WaitForNextStage)
			{
				stageDirtyInstances[this] = (newValue, silent);
			}
			else if (deferType == DeferType.WaitForRunEnd)
			{
				runDirtyInstances[this] = newValue;
			}
			else
			{
				TinkersSatchelPlugin._logger.LogWarning((object)("Something attempted to set the value of an AutoConfigBinding with the DeferForever flag: \"" + readablePath + "\""));
			}
		}

		public static (List<AutoConfigBinding> results, string errorMsg) FindFromPath(string path1, string path2, string path3)
		{
			string p1u = path1.ToUpper();
			string p2u = path2?.ToUpper();
			string p3u = path3?.ToUpper();
			List<AutoConfigBinding> matchesLevel1 = new List<AutoConfigBinding>();
			List<AutoConfigBinding> matchesLevel2 = new List<AutoConfigBinding>();
			List<AutoConfigBinding> matchesLevel3 = new List<AutoConfigBinding>();
			List<AutoConfigBinding> matchesLevel4 = new List<AutoConfigBinding>();
			instances.ForEach(delegate(AutoConfigBinding x)
			{
				if (x.allowConCmd)
				{
					string key = x.configEntry.Definition.Key;
					string text = key.ToUpper();
					string section = x.configEntry.Definition.Section;
					string text2 = section.ToUpper();
					string text3 = x.modName;
					string text4 = text3.ToUpper();
					if (path2 == null)
					{
						if (text.Contains(p1u) || text2.Contains(p1u) || text4.Contains(p1u))
						{
							matchesLevel1.Add(x);
							matchesLevel2.Add(x);
							if (text == p1u)
							{
								matchesLevel3.Add(x);
								if (key == path1)
								{
									matchesLevel4.Add(x);
								}
							}
						}
					}
					else if (path3 == null)
					{
						bool flag = text4.Contains(p1u);
						bool flag2 = text2.Contains(p1u);
						bool flag3 = text2.Contains(p2u);
						bool flag4 = text.Contains(p2u);
						if ((flag && flag3) || (flag2 && flag4) || (flag && flag4))
						{
							matchesLevel1.Add(x);
							if (!(flag && flag4))
							{
								matchesLevel2.Add(x);
								bool num = text3.Contains(path1);
								bool flag5 = section.Contains(path1);
								bool flag6 = section.Contains(path2);
								bool flag7 = key.Contains(path2);
								if ((num && flag6) || (flag5 && flag7))
								{
									matchesLevel3.Add(x);
									bool num2 = text3 == path1;
									bool flag8 = section == path1;
									bool flag9 = section == path2;
									bool flag10 = key == path2;
									if ((num2 && flag9) || (flag8 && flag10))
									{
										matchesLevel4.Add(x);
									}
								}
							}
						}
					}
					else if (text.Contains(p3u) && text2.Contains(p2u) && text4.Contains(p1u))
					{
						matchesLevel1.Add(x);
						matchesLevel2.Add(x);
						if (text4 == p3u && text2 == p2u && text == p1u)
						{
							matchesLevel3.Add(x);
							if (text3 == path3 && section == path2 && key == path1)
							{
								matchesLevel4.Add(x);
							}
						}
					}
				}
			});
			if (matchesLevel1.Count == 0)
			{
				return (null, "no level 1 matches");
			}
			if (matchesLevel1.Count == 1)
			{
				return (matchesLevel1, null);
			}
			if (matchesLevel2.Count == 0)
			{
				return (matchesLevel1, "multiple level 1 matches, no level 2 matches");
			}
			if (matchesLevel2.Count == 1)
			{
				return (matchesLevel2, null);
			}
			if (matchesLevel3.Count == 0)
			{
				return (matchesLevel2, "multiple level 2 matches, no level 3 matches");
			}
			if (matchesLevel3.Count == 1)
			{
				return (matchesLevel3, null);
			}
			if (matchesLevel4.Count == 0)
			{
				return (matchesLevel3, "multiple level 3 matches, no level 4 matches");
			}
			if (matchesLevel4.Count == 1)
			{
				return (matchesLevel4, null);
			}
			Debug.LogError((object)("AutoConfig: There are multiple config entries with the path \"" + matchesLevel4[0].readablePath + "\"; this should never happen! Please report this as a bug."));
			return (matchesLevel4, "multiple level 4 matches");
		}
	}
	public class AutoConfigContainer
	{
		public struct BindSubDictInfo
		{
			public object key;

			public object val;

			public Type keyType;

			public int index;
		}

		protected internal readonly List<AutoConfigBinding> bindings = new List<AutoConfigBinding>();

		protected internal virtual AutoConfigUpdateActionTypes defaultEnabledUpdateFlags => AutoConfigUpdateActionTypes.None;

		public event EventHandler<AutoConfigUpdateActionEventArgs> ConfigEntryChanged;

		public AutoConfigBinding FindConfig(string propName)
		{
			return bindings.Find((AutoConfigBinding x) => x.boundProperty.Name == propName && !x.onDict);
		}

		public AutoConfigBinding FindConfig(string propName, object dictKey)
		{
			return bindings.Find((AutoConfigBinding x) => x.boundProperty.Name == propName && x.onDict && x.boundKey == dictKey);
		}

		internal void OnConfigChanged(AutoConfigUpdateActionEventArgs e)
		{
			this.ConfigEntryChanged?.Invoke(this, e);
			Debug.Log((object)$"{e.target.readablePath}: {e.oldValue} > {e.newValue}");
			if ((Object)(object)Run.instance != (Object)null && ((Behaviour)Run.instance).isActiveAndEnabled)
			{
				if ((e.flags & AutoConfigUpdateActionTypes.InvalidateStats) == AutoConfigUpdateActionTypes.InvalidateStats)
				{
					AutoConfigModule.globalStatsDirty = true;
				}
				if ((e.flags & AutoConfigUpdateActionTypes.InvalidateDropTable) == AutoConfigUpdateActionTypes.InvalidateDropTable)
				{
					AutoConfigModule.globalDropsDirty = true;
				}
			}
		}

		private string ReplaceTags(string orig, PropertyInfo prop, string categoryName, BindSubDictInfo? subDict = null)
		{
			return Regex.Replace(orig, "<AIC.([a-zA-Z\\.]+)>", delegate(Match m)
			{
				string value = m.Groups[0].Value;
				string[] array = Regex.Split(value.Substring(1, value.Length - 1 - 1), "(?<!\\\\)\\.");
				if (array.Length < 2)
				{
					return m.Value;
				}
				string text = "AutoConfigContainer.Bind on property " + prop.Name + " in category " + categoryName + ": malformed string param \"" + m.Value + "\" ";
				switch (array[1])
				{
				case "Prop":
				{
					if (array.Length < 3)
					{
						TinkersSatchelPlugin._logger.LogWarning((object)(text + "(not enough params for Prop tag)."));
						return m.Value;
					}
					PropertyInfo property2 = prop.Declaring