Decompiled source of AssistManager v1.2.0

AssistManager.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AssistManager.VanillaTweaks;
using BepInEx;
using BepInEx.Configuration;
using EntityStates.LaserTurbine;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Items;
using RoR2.Orbs;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AssistManager")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d728f1a9a575e199d50466df546208f2a408a256")]
[assembly: AssemblyProduct("AssistManager")]
[assembly: AssemblyTitle("AssistManager")]
[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 AssistManager
{
	public class AssistManager : MonoBehaviour
	{
		public delegate void HandleAssistInventory(Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo);

		public delegate void HandleAssist(Assist assist, CharacterBody killerBody, DamageInfo damageInfo);

		public delegate void HandleAssistInventoryCompatible(CharacterBody attackerBody, CharacterBody victimBody, DamageType? assistDamageType, HashSet<ModdedDamageType> assistModdedDamageTypes, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo);

		public delegate void HandleAssistCompatible(CharacterBody attackerBody, CharacterBody victimBody, DamageType? assistDamageType, HashSet<ModdedDamageType> assistModdedDamageTypes, CharacterBody killerBody, DamageInfo damageInfo);

		public delegate void HandleDirectAssistInventory(Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo);

		public delegate void HandleDirectAssist(Assist assist, CharacterBody killerBody, DamageInfo damageInfo);

		public delegate void HandleDirectAssistInventoryCompatible(CharacterBody attackerBody, CharacterBody victimBody, DamageType? assistDamageType, HashSet<ModdedDamageType> assistModdedDamageTypes, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo);

		public delegate void HandleDirectAssistCompatible(CharacterBody attackerBody, CharacterBody victimBody, DamageType? assistDamageType, HashSet<ModdedDamageType> assistModdedDamageTypes, CharacterBody killerBody, DamageInfo damageInfo);

		public class Assist
		{
			public float timer;

			public CharacterBody attackerBody;

			public CharacterBody victimBody;

			[Tooltip("Use this if you want to save information about the hit that triggered the assist.")]
			public DamageType? damageType;

			[Tooltip("Use this if you want to save information about the hit that triggered the assist.")]
			public HashSet<ModdedDamageType> moddedDamageTypes;

			public Assist(CharacterBody attackerBody, CharacterBody victimBody, float timer)
			{
				this.attackerBody = attackerBody;
				this.victimBody = victimBody;
				this.timer = timer;
				damageType = null;
				moddedDamageTypes = new HashSet<ModdedDamageType>();
			}

			public Assist(CharacterBody attackerBody, CharacterBody victimBody, float timer, DamageType damageType)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				this.attackerBody = attackerBody;
				this.victimBody = victimBody;
				this.timer = timer;
				this.damageType = damageType;
				moddedDamageTypes = new HashSet<ModdedDamageType>();
			}
		}

		public static float assistDuration = 3f;

		public static float directKillDurationAuthority = 0.25f;

		public static float directKillDurationNetworkPlayer = 0.5f;

		public static HandleAssistInventory HandleAssistInventoryActions;

		public static HandleAssist HandleAssistActions;

		public static HandleAssistInventoryCompatible HandleAssistInventoryCompatibleActions;

		public static HandleAssistCompatible HandleAssistCompatibleActions;

		public static HandleDirectAssistInventory HandleDirectAssistInventoryActions;

		public static HandleDirectAssist HandleDirectAssistActions;

		public static HandleDirectAssistInventoryCompatible HandleDirectAssistInventoryCompatibleActions;

		public static HandleDirectAssistCompatible HandleDirectAssistCompatibleActions;

		private List<Assist> pendingAssists = new List<Assist>();

		private List<Assist> pendingDirectAssists = new List<Assist>();

		public static AssistManager instance { get; private set; }

		public static float GetDirectAssistDurationForAttacker(GameObject attacker)
		{
			return IsLocalUser(attacker) ? directKillDurationAuthority : directKillDurationNetworkPlayer;
		}

		private static bool IsLocalUser(GameObject playerObject)
		{
			foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList)
			{
				if ((Object)(object)playerObject == (Object)(object)readOnlyLocalUsers.cachedBodyObject)
				{
					return true;
				}
			}
			return false;
		}

		internal static void Init()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			Run.onRunStartGlobal += Run_onRunStartGlobal;
			GlobalEventManager.OnCharacterDeath += new hook_OnCharacterDeath(GlobalEventManager_OnCharacterDeath);
			GlobalEventManager.ProcessHitEnemy += new hook_ProcessHitEnemy(GlobalEventManager_ProcessHitEnemy);
		}

		private static void GlobalEventManager_ProcessHitEnemy(orig_ProcessHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			bool flag = NetworkServer.active && !damageInfo.rejected;
			if (Object.op_Implicit((Object)(object)instance) && flag && Object.op_Implicit((Object)(object)damageInfo.attacker) && Object.op_Implicit((Object)(object)victim))
			{
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				CharacterBody component2 = victim.GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2))
				{
					instance.AddAssist(new Assist(component, component2, assistDuration));
				}
			}
			orig.Invoke(self, damageInfo, victim);
		}

		private static void GlobalEventManager_OnCharacterDeath(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
		{
			orig.Invoke(self, damageReport);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)damageReport.attackerMaster))
			{
				CharacterBody attackerBody = damageReport.attackerBody;
				CharacterBody victimBody = damageReport.victimBody;
				if (Object.op_Implicit((Object)(object)attackerBody) && Object.op_Implicit((Object)(object)victimBody) && Object.op_Implicit((Object)(object)instance))
				{
					instance.TriggerAssists(victimBody, attackerBody, damageReport.damageInfo);
				}
			}
		}

		private static void Run_onRunStartGlobal(Run self)
		{
			if (NetworkServer.active)
			{
				instance = ((Component)self).gameObject.GetComponent<AssistManager>();
				if (!Object.op_Implicit((Object)(object)instance))
				{
					instance = ((Component)self).gameObject.AddComponent<AssistManager>();
				}
			}
		}

		private void FixedUpdate()
		{
			if (pendingAssists.Count > 0)
			{
				UpdateAssists(pendingAssists);
			}
			if (pendingDirectAssists.Count > 0)
			{
				UpdateAssists(pendingDirectAssists);
			}
		}

		private void UpdateAssists(List<Assist> assists)
		{
			List<Assist> list = new List<Assist>();
			foreach (Assist assist in assists)
			{
				assist.timer -= Time.fixedDeltaTime;
				if (assist.timer <= 0f || !Object.op_Implicit((Object)(object)assist.attackerBody) || !Object.op_Implicit((Object)(object)assist.attackerBody.healthComponent) || !assist.attackerBody.healthComponent.alive)
				{
					list.Add(assist);
				}
			}
			foreach (Assist item in list)
			{
				assists.Remove(item);
			}
		}

		public void AddAssist(Assist newAssist)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			foreach (Assist pendingAssist in pendingAssists)
			{
				if ((Object)(object)pendingAssist.attackerBody == (Object)(object)newAssist.attackerBody && (Object)(object)pendingAssist.victimBody == (Object)(object)newAssist.victimBody)
				{
					flag = true;
					if (pendingAssist.timer < newAssist.timer)
					{
						pendingAssist.timer = newAssist.timer;
					}
					pendingAssist.damageType = (DamageType?)((??)pendingAssist.damageType | (??)newAssist.damageType);
					pendingAssist.moddedDamageTypes.UnionWith(newAssist.moddedDamageTypes);
					break;
				}
			}
			if (!flag)
			{
				pendingAssists.Add(newAssist);
			}
		}

		public void AddDirectAssist(Assist newAssist)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			foreach (Assist pendingDirectAssist in pendingDirectAssists)
			{
				if ((Object)(object)pendingDirectAssist.attackerBody == (Object)(object)newAssist.attackerBody && (Object)(object)pendingDirectAssist.victimBody == (Object)(object)newAssist.victimBody && pendingDirectAssist.damageType == newAssist.damageType && pendingDirectAssist.moddedDamageTypes.SetEquals(newAssist.moddedDamageTypes))
				{
					flag = true;
					if (pendingDirectAssist.timer < newAssist.timer)
					{
						pendingDirectAssist.timer = newAssist.timer;
					}
					break;
				}
			}
			if (!flag)
			{
				pendingDirectAssists.Add(newAssist);
			}
		}

		public void TriggerAssists(CharacterBody victimBody, CharacterBody killerBody, DamageInfo damageInfo)
		{
			if (!Object.op_Implicit((Object)(object)victimBody) || pendingAssists.Count <= 0)
			{
				return;
			}
			List<Assist> list = new List<Assist>();
			List<Assist> list2 = new List<Assist>();
			foreach (Assist pendingAssist in pendingAssists)
			{
				if ((Object)(object)pendingAssist.victimBody == (Object)(object)victimBody)
				{
					list.Add(pendingAssist);
				}
			}
			foreach (Assist pendingDirectAssist in pendingDirectAssists)
			{
				if ((Object)(object)pendingDirectAssist.victimBody == (Object)(object)victimBody)
				{
					list2.Add(pendingDirectAssist);
				}
			}
			foreach (Assist item in list)
			{
				if (Object.op_Implicit((Object)(object)item.attackerBody) && Object.op_Implicit((Object)(object)item.attackerBody.healthComponent) && item.attackerBody.healthComponent.alive)
				{
					HandleAssistActions?.Invoke(item, killerBody, damageInfo);
					HandleAssistCompatibleActions?.Invoke(item.attackerBody, item.victimBody, item.damageType, item.moddedDamageTypes, killerBody, damageInfo);
					Inventory inventory = item.attackerBody.inventory;
					if (Object.op_Implicit((Object)(object)inventory))
					{
						HandleAssistInventoryActions?.Invoke(item, inventory, killerBody, damageInfo);
						HandleAssistInventoryCompatibleActions?.Invoke(item.attackerBody, item.victimBody, item.damageType, item.moddedDamageTypes, inventory, killerBody, damageInfo);
					}
				}
				pendingAssists.Remove(item);
			}
			foreach (Assist item2 in list2)
			{
				if (Object.op_Implicit((Object)(object)item2.attackerBody) && Object.op_Implicit((Object)(object)item2.attackerBody.healthComponent) && item2.attackerBody.healthComponent.alive)
				{
					HandleDirectAssistActions?.Invoke(item2, killerBody, damageInfo);
					HandleDirectAssistCompatibleActions?.Invoke(item2.attackerBody, item2.victimBody, item2.damageType, item2.moddedDamageTypes, killerBody, damageInfo);
					Inventory inventory2 = item2.attackerBody.inventory;
					if (Object.op_Implicit((Object)(object)inventory2))
					{
						HandleDirectAssistInventoryActions?.Invoke(item2, inventory2, killerBody, damageInfo);
						HandleDirectAssistInventoryCompatibleActions?.Invoke(item2.attackerBody, item2.victimBody, item2.damageType, item2.moddedDamageTypes, inventory2, killerBody, damageInfo);
					}
				}
				pendingDirectAssists.Remove(item2);
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Moffein.AssistManager", "AssistManager", "1.2.0")]
	public class AssistManagerPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			AssistManager.Init();
			AddToAssembly();
		}

		private void AddToAssembly()
		{
			IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(VanillaTweakBase))
				select type;
			foreach (Type item in enumerable)
			{
				VanillaTweakBase vanillaTweakBase = (VanillaTweakBase)Activator.CreateInstance(item);
				vanillaTweakBase.Init(((BaseUnityPlugin)this).Config);
			}
		}
	}
}
namespace AssistManager.VanillaTweaks
{
	public class BanditReset : VanillaTweakBase<BanditReset>
	{
		private GameObject resetEffect = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ImpactEffects/Bandit2ResetEffect");

		public override string ConfigOptionName => "Bandit Reset";

		public override string ConfigDescriptionString => "Add assist support for Lights Out.";

		protected override void ApplyChanges()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			base.ApplyChanges();
			GlobalEventManager.ProcessHitEnemy += new hook_ProcessHitEnemy(GlobalEventManager_ProcessHitEnemy);
			AssistManager.HandleDirectAssistActions = (AssistManager.HandleDirectAssist)Delegate.Combine(AssistManager.HandleDirectAssistActions, new AssistManager.HandleDirectAssist(HandleBanditAssists));
		}

		protected override void RemoveChanges()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			base.RemoveChanges();
			GlobalEventManager.ProcessHitEnemy -= new hook_ProcessHitEnemy(GlobalEventManager_ProcessHitEnemy);
			AssistManager.HandleDirectAssistActions = (AssistManager.HandleDirectAssist)Delegate.Remove(AssistManager.HandleDirectAssistActions, new AssistManager.HandleDirectAssist(HandleBanditAssists));
		}

		private void GlobalEventManager_ProcessHitEnemy(orig_ProcessHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && Object.op_Implicit((Object)(object)AssistManager.instance) && Object.op_Implicit((Object)(object)victim) && !damageInfo.rejected && Object.op_Implicit((Object)(object)damageInfo.attacker) && DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)4)) != 0)
			{
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				CharacterBody component2 = victim.GetComponent<CharacterBody>();
				AssistManager.instance.AddDirectAssist(new AssistManager.Assist(component, component2, AssistManager.GetDirectAssistDurationForAttacker(damageInfo.attacker), (DamageType)4));
			}
			orig.Invoke(self, damageInfo, victim);
		}

		private void HandleBanditAssists(AssistManager.Assist assist, CharacterBody killerBody, DamageInfo damageInfo)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_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_00bb: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)assist.attackerBody) && assist.damageType.HasValue && (??)((??)assist.damageType & 4) != (??)0 && assist.moddedDamageTypes.Count == 0)
			{
				bool flag = DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)4)) != 0;
				if (!flag)
				{
					EffectManager.SpawnEffect(resetEffect, new EffectData
					{
						origin = damageInfo.position
					}, true);
				}
				if ((!flag || !((Object)(object)killerBody == (Object)(object)assist.attackerBody)) && Object.op_Implicit((Object)(object)assist.attackerBody.skillLocator))
				{
					assist.attackerBody.skillLocator.ResetSkills();
				}
			}
		}
	}
	public class BanditSkull : VanillaTweakBase<BanditSkull>
	{
		private GameObject skullEffect = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ImpactEffects/Bandit2KillEffect");

		public override string ConfigOptionName => "Bandit Desperado";

		public override string ConfigDescriptionString => "Add assist support for Desperado.";

		protected override void ApplyChanges()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			base.ApplyChanges();
			GlobalEventManager.ProcessHitEnemy += new hook_ProcessHitEnemy(GlobalEventManager_ProcessHitEnemy);
			AssistManager.HandleDirectAssistActions = (AssistManager.HandleDirectAssist)Delegate.Combine(AssistManager.HandleDirectAssistActions, new AssistManager.HandleDirectAssist(HandleBanditAssists));
		}

		protected override void RemoveChanges()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			base.RemoveChanges();
			GlobalEventManager.ProcessHitEnemy -= new hook_ProcessHitEnemy(GlobalEventManager_ProcessHitEnemy);
			AssistManager.HandleDirectAssistActions = (AssistManager.HandleDirectAssist)Delegate.Remove(AssistManager.HandleDirectAssistActions, new AssistManager.HandleDirectAssist(HandleBanditAssists));
		}

		private void GlobalEventManager_ProcessHitEnemy(orig_ProcessHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && Object.op_Implicit((Object)(object)AssistManager.instance) && Object.op_Implicit((Object)(object)victim) && !damageInfo.rejected && Object.op_Implicit((Object)(object)damageInfo.attacker) && DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)268435456)) != 0)
			{
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				CharacterBody component2 = victim.GetComponent<CharacterBody>();
				AssistManager.instance.AddDirectAssist(new AssistManager.Assist(component, component2, AssistManager.GetDirectAssistDurationForAttacker(damageInfo.attacker), (DamageType)268435456));
			}
			orig.Invoke(self, damageInfo, victim);
		}

		private void HandleBanditAssists(AssistManager.Assist assist, CharacterBody killerBody, DamageInfo damageInfo)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			if (assist.damageType.HasValue && (??)((??)assist.damageType & 0x10000000) != (??)0 && assist.moddedDamageTypes.Count == 0)
			{
				bool flag = DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)268435456)) != 0;
				if (!flag)
				{
					EffectManager.SpawnEffect(skullEffect, new EffectData
					{
						origin = damageInfo.position
					}, true);
				}
				if (!flag || !((Object)(object)killerBody == (Object)(object)assist.attackerBody))
				{
					assist.attackerBody.AddBuff(Buffs.BanditSkull);
				}
			}
		}
	}
	public class Brainstalks : VanillaTweakBase<Brainstalks>
	{
		public override string ConfigOptionName => "Brainstalks";

		public override string ConfigDescriptionString => "Add assist support to this item.";

		protected override void ApplyChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Combine(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		protected override void RemoveChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Remove(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		private void OnKillEffect(AssistManager.Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo)
		{
			if (!((Object)(object)assist.attackerBody == (Object)(object)killerBody) && assist.victimBody.isElite)
			{
				int itemCount = attackerInventory.GetItemCount(Items.KillEliteFrenzy);
				if (itemCount > 0)
				{
					assist.attackerBody.AddTimedBuff(Buffs.NoCooldowns, (float)itemCount * 4f);
				}
			}
		}
	}
	public class ChronicExpansion : VanillaTweakBase<ChronicExpansion>
	{
		public override string ConfigOptionName => "Chronic Expansion";

		public override string ConfigDescriptionString => "Add assist support to this item.";

		protected override void ApplyChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Combine(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		protected override void RemoveChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Remove(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		private void OnKillEffect(AssistManager.Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo)
		{
			if (!((Object)(object)assist.attackerBody == (Object)(object)killerBody) && attackerInventory.GetItemCount(Items.IncreaseDamageOnMultiKill) > 0)
			{
				assist.attackerBody.AddIncreasedDamageMultiKillTime();
			}
		}
	}
	public class FrostRelic : VanillaTweakBase<FrostRelic>
	{
		public override string ConfigOptionName => "Frost Relic";

		public override string ConfigDescriptionString => "Add assist support to this item.";

		protected override void ApplyChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Combine(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		protected override void RemoveChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Remove(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		private void OnKillEffect(AssistManager.Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo)
		{
			if ((Object)(object)assist.attackerBody == (Object)(object)killerBody)
			{
				return;
			}
			int itemCount = attackerInventory.GetItemCount(Items.Icicle);
			if (itemCount > 0)
			{
				IcicleBodyBehavior component = ((Component)assist.attackerBody).GetComponent<IcicleBodyBehavior>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.icicleAura))
				{
					component.icicleAura.OnOwnerKillOther();
				}
			}
		}
	}
	public class Harpoon : VanillaTweakBase<Harpoon>
	{
		public override string ConfigOptionName => "Hunters Harpoon";

		public override string ConfigDescriptionString => "Add assist support to this item.";

		protected override void ApplyChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Combine(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		protected override void RemoveChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Remove(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		private void OnKillEffect(AssistManager.Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_0098: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)assist.attackerBody == (Object)(object)killerBody)
			{
				return;
			}
			int itemCount = attackerInventory.GetItemCount(Items.MoveSpeedOnKill);
			if (itemCount <= 0)
			{
				return;
			}
			CharacterBody attackerBody = assist.attackerBody;
			attackerBody.ClearTimedBuffs(Buffs.KillMoveSpeed);
			int num = itemCount - 1;
			int num2 = 5;
			float num3 = 1f + (float)num * 0.5f;
			for (int i = 0; i < num2; i++)
			{
				attackerBody.AddTimedBuff(Buffs.KillMoveSpeed, num3 * (float)(i + 1) / (float)num2);
			}
			EffectData val = new EffectData();
			val.origin = attackerBody.corePosition;
			CharacterMotor characterMotor = attackerBody.characterMotor;
			bool flag = false;
			if (Object.op_Implicit((Object)(object)characterMotor))
			{
				Vector3 moveDirection = characterMotor.moveDirection;
				if (moveDirection != Vector3.zero)
				{
					val.rotation = Util.QuaternionSafeLookRotation(moveDirection);
					flag = true;
				}
			}
			if (!flag)
			{
				val.rotation = attackerBody.transform.rotation;
			}
			EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MoveSpeedOnKillActivate"), val, true);
		}
	}
	public class Headhunter : VanillaTweakBase<Headhunter>
	{
		public override string ConfigOptionName => "Wake of Vultures";

		public override string ConfigDescriptionString => "Add assist support to this item.";

		protected override void ApplyChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Combine(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		protected override void RemoveChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Remove(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		private void OnKillEffect(AssistManager.Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo)
		{
			//IL_005c: 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)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)assist.attackerBody == (Object)(object)killerBody || !assist.victimBody.isElite)
			{
				return;
			}
			int itemCount = attackerInventory.GetItemCount(Items.HeadHunter);
			if (itemCount <= 0)
			{
				return;
			}
			float num = 3f + 5f * (float)itemCount;
			for (int i = 0; i < BuffCatalog.eliteBuffIndices.Length; i++)
			{
				BuffIndex val = BuffCatalog.eliteBuffIndices[i];
				if (assist.victimBody.HasBuff(val))
				{
					assist.attackerBody.AddTimedBuff(val, num);
				}
			}
		}
	}
	public class Infusion : VanillaTweakBase<Infusion>
	{
		public override string ConfigOptionName => "Infusion";

		public override string ConfigDescriptionString => "Add assist support for this item.";

		protected override void ApplyChanges()
		{
			base.ApplyChanges();
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Combine(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		protected override void RemoveChanges()
		{
			base.RemoveChanges();
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Remove(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		private void OnKillEffect(AssistManager.Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			if ((Object)(object)assist.attackerBody == (Object)(object)killerBody)
			{
				return;
			}
			int itemCount = attackerInventory.GetItemCount(Items.Infusion);
			if (itemCount > 0)
			{
				int num = itemCount * 100;
				if ((ulong)attackerInventory.infusionBonus < (ulong)num)
				{
					InfusionOrb val = new InfusionOrb
					{
						origin = assist.victimBody.transform.position,
						target = Util.FindBodyMainHurtBox(assist.attackerBody),
						maxHpValue = itemCount
					};
					OrbManager.instance.AddOrb((Orb)(object)val);
				}
			}
		}
	}
	public class LaserTurbine : VanillaTweakBase<LaserTurbine>
	{
		public override string ConfigOptionName => "Resonance Disk";

		public override string ConfigDescriptionString => "Add assist support for this item.";

		protected override void ApplyChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Combine(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		protected override void RemoveChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Remove(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		private void OnKillEffect(AssistManager.Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo)
		{
			if (!((Object)(object)assist.attackerBody == (Object)(object)killerBody))
			{
				int itemCount = attackerInventory.GetItemCount(Items.LaserTurbine);
				if (itemCount > 0)
				{
					assist.attackerBody.AddTimedBuff(Buffs.LaserTurbineKillCharge, (float)RechargeState.killChargeDuration, RechargeState.killChargesRequired);
				}
			}
		}
	}
	public class Multikill : VanillaTweakBase<Multikill>
	{
		public override string ConfigOptionName => "Multikill";

		public override string ConfigDescriptionString => "On-Multikill items are affected by assists.";

		protected override void ApplyChanges()
		{
			AssistManager.HandleAssistActions = (AssistManager.HandleAssist)Delegate.Combine(AssistManager.HandleAssistActions, new AssistManager.HandleAssist(AddMultikill));
		}

		protected override void RemoveChanges()
		{
			AssistManager.HandleAssistActions = (AssistManager.HandleAssist)Delegate.Remove(AssistManager.HandleAssistActions, new AssistManager.HandleAssist(AddMultikill));
		}

		private void AddMultikill(AssistManager.Assist assist, CharacterBody killerBody, DamageInfo damageInfo)
		{
			if ((Object)(object)assist.attackerBody != (Object)(object)killerBody)
			{
				assist.attackerBody.AddMultiKill(1);
			}
		}
	}
	public class Soulbound : VanillaTweakBase<Soulbound>
	{
		public override string ConfigOptionName => "Soulbound Catalyst";

		public override string ConfigDescriptionString => "Add assist support for this item.";

		protected override void ApplyChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Combine(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		protected override void RemoveChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Remove(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		private void OnKillEffect(AssistManager.Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo)
		{
			if (!((Object)(object)assist.attackerBody == (Object)(object)killerBody))
			{
				int itemCount = attackerInventory.GetItemCount(Items.Talisman);
				if (itemCount > 0)
				{
					attackerInventory.DeductActiveEquipmentCooldown(2f + (float)itemCount * 2f);
				}
			}
		}
	}
	public class TopazBrooch : VanillaTweakBase<TopazBrooch>
	{
		public override string ConfigOptionName => "Topaz Brooch";

		public override string ConfigDescriptionString => "Add assist support to this item.";

		protected override void ApplyChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Combine(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		protected override void RemoveChanges()
		{
			AssistManager.HandleAssistInventoryActions = (AssistManager.HandleAssistInventory)Delegate.Remove(AssistManager.HandleAssistInventoryActions, new AssistManager.HandleAssistInventory(OnKillEffect));
		}

		private void OnKillEffect(AssistManager.Assist assist, Inventory attackerInventory, CharacterBody killerBody, DamageInfo damageInfo)
		{
			if (!((Object)(object)assist.attackerBody == (Object)(object)killerBody))
			{
				int itemCount = attackerInventory.GetItemCount(Items.BarrierOnKill);
				if (itemCount > 0)
				{
					assist.attackerBody.healthComponent.AddBarrier(15f * (float)itemCount);
				}
			}
		}
	}
	public abstract class VanillaTweakBase<T> : VanillaTweakBase where T : VanillaTweakBase<T>
	{
		public static T Instance { get; private set; }

		public VanillaTweakBase()
		{
			if (Instance != null)
			{
				throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting VanillaTweakBase was instantiated twice");
			}
			Instance = this as T;
		}
	}
	public abstract class VanillaTweakBase
	{
		public abstract string ConfigOptionName { get; }

		public abstract string ConfigDescriptionString { get; }

		public ConfigEntry<bool> Enabled { get; private set; }

		public bool changesActive { get; private set; }

		protected virtual void ReadConfig(ConfigFile config)
		{
			Enabled = config.Bind<bool>("Vanilla Tweaks", ConfigOptionName, true, ConfigDescriptionString);
		}

		internal void Init(ConfigFile config)
		{
			changesActive = false;
			ReadConfig(config);
			SetEnabled(Enabled.Value);
		}

		public void SetEnabled(bool enabled)
		{
			if (enabled)
			{
				if (!changesActive)
				{
					ApplyChanges();
					changesActive = true;
				}
			}
			else if (changesActive)
			{
				RemoveChanges();
				changesActive = false;
			}
		}

		protected virtual void ApplyChanges()
		{
		}

		protected virtual void RemoveChanges()
		{
		}
	}
}