Decompiled source of Groove Salad vs the Game v0.0.0

JohnHopooReturns.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HG;
using HG.GeneralSerializer;
using HG.Reflection;
using IL.RoR2;
using IL.RoR2.Items;
using KinematicCharacterController;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using On.RoR2.Items;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.Audio;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Items;
using RoR2.Navigation;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("JohnHopooReturns")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JohnHopooReturns")]
[assembly: AssemblyTitle("JohnHopooReturns")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace JohnHopooReturns;

public class Aegis : JohnHopooReturns.Behaviour<Aegis>
{
	private const string SECTION = "Aegis Buff";

	public float conversionRate = JohnHopooReturns.Behaviour.Config.Value("Aegis Buff", "Healing To Barrier Ratio", 1f);

	public void Awake()
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("Aegis Buff", string.Format("Enabled", "Aegis Buff"), defaultValue: true))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		LanguageAPI.Add("ITEM_BARRIERONOVERHEAL_DESC", $"Healing past full grants you a <style=cIsHealing>temporary barrier</style> for <style=cIsHealing>{conversionRate:0%} <style=cStack>(+{conversionRate:0%} per stack)</style></style> of the amount you <style=cIsHealing>healed</style>.");
		HealthComponent.Heal += new Manipulator(HealthComponent_Heal);
	}

	private void HealthComponent_Heal(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		float num = default(float);
		if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdfld<ItemCounts>(x, "barrierOnOverHeal"),
			(Instruction x) => ILPatternMatchingExt.MatchConvR4(x),
			(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num),
			(Instruction x) => ILPatternMatchingExt.MatchMul(x)
		}))
		{
			val.Index += 2;
			val.Next.Operand = conversionRate;
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"Aegis.HealthComponent_Heal IL hook failed!");
		}
	}
}
public class Beetles : JohnHopooReturns.Behaviour<Beetles>, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	public class EnterBurrow : BaseState
	{
		private Animator modelAnimator;

		private float duration;

		private bool didCrossfade;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			duration = JohnHopooReturns.Behaviour<Beetles>.Instance.crossfadeDelay + JohnHopooReturns.Behaviour<Beetles>.Instance.crossfadeDuration;
			((EntityState)this).PlayCrossfade("Body", "EmoteSurprise", 0.1f);
			modelAnimator = ((EntityState)this).GetModelAnimator();
			if (Object.op_Implicit((Object)(object)modelAnimator))
			{
				modelAnimator.speed = JohnHopooReturns.Behaviour<Beetles>.Instance.animSpeed;
			}
			Util.PlaySound(JohnHopooReturns.Behaviour<Beetles>.Instance.startSoundString, ((EntityState)this).gameObject);
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).fixedAge >= JohnHopooReturns.Behaviour<Beetles>.Instance.crossfadeDelay)
			{
				TryCrossfade();
			}
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextState((EntityState)(object)new BeetleBurrow());
			}
		}

		public override void OnExit()
		{
			TryCrossfade();
			if (NetworkServer.active)
			{
				Util.CleanseBody(((EntityState)this).characterBody, true, false, false, true, false, false);
			}
			((EntityState)this).OnExit();
		}

		public void TryCrossfade()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (!didCrossfade && Object.op_Implicit((Object)(object)modelAnimator))
			{
				modelAnimator.speed = 1f;
				modelAnimator.Update(0f);
				modelAnimator.SetFloat("Spawn1.playbackRate", 0f);
				modelAnimator.CrossFadeInFixedTime("Spawn1", JohnHopooReturns.Behaviour<Beetles>.Instance.crossfadeDuration, modelAnimator.GetLayerIndex("Body"));
				EffectManager.SimpleEffect(BeetleBurrowEffect, ((EntityState)this).characterBody.footPosition, Quaternion.identity, false);
				Util.PlaySound(JohnHopooReturns.Behaviour<Beetles>.Instance.burrowSoundString, ((EntityState)this).gameObject);
				didCrossfade = true;
			}
		}
	}

	public class BeetleBurrow : BaseState
	{
		private const float ARBITRARY_RADIUS = 10f;

		private HurtBox target;

		private Vector3 predictedDestination;

		public float duration;

		private CharacterModel characterModel;

		private HurtBoxGroup hurtboxGroup;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			duration = JohnHopooReturns.Behaviour<Beetles>.Instance.baseBurrowDuration;
			Transform modelTransform = ((EntityState)this).GetModelTransform();
			if (Object.op_Implicit((Object)(object)modelTransform))
			{
				characterModel = ((Component)modelTransform).GetComponent<CharacterModel>();
				hurtboxGroup = ((Component)modelTransform).GetComponent<HurtBoxGroup>();
			}
			if (Object.op_Implicit((Object)(object)characterModel))
			{
				CharacterModel obj = characterModel;
				obj.invisibilityCount++;
			}
			if (Object.op_Implicit((Object)(object)hurtboxGroup))
			{
				HurtBoxGroup obj2 = hurtboxGroup;
				int hurtBoxesDeactivatorCounter = obj2.hurtBoxesDeactivatorCounter;
				obj2.hurtBoxesDeactivatorCounter = hurtBoxesDeactivatorCounter + 1;
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
			{
				((Behaviour)((EntityState)this).characterMotor).enabled = false;
			}
			((EntityState)this).gameObject.layer = LayerIndex.fakeActor.intVal;
			((BaseCharacterController)((EntityState)this).characterMotor).Motor.RebuildCollidableLayers();
			CalculatePredictedDestination();
			Util.PlaySound("Play_magmaWorm_burrowed_loop", ((EntityState)this).gameObject);
		}

		private void CalculatePredictedDestination()
		{
			//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_0008: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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)
			//IL_0043: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.zero;
			Ray aimRay = ((BaseState)this).GetAimRay();
			BullseyeSearch val2 = new BullseyeSearch
			{
				searchOrigin = ((Ray)(ref aimRay)).origin,
				searchDirection = ((Ray)(ref aimRay)).direction,
				maxDistanceFilter = 100f,
				teamMaskFilter = TeamMask.allButNeutral,
				filterByLoS = false,
				sortMode = (SortMode)2
			};
			((TeamMask)(ref val2.teamMaskFilter)).RemoveTeam(TeamComponent.GetObjectTeam(((EntityState)this).gameObject));
			val2.RefreshCandidates();
			target = val2.GetResults().FirstOrDefault();
			if (Object.op_Implicit((Object)(object)target))
			{
				val = ((Component)target).transform.position - ((EntityState)this).transform.position;
				HealthComponent healthComponent = target.healthComponent;
				object obj;
				if (healthComponent == null)
				{
					obj = null;
				}
				else
				{
					CharacterBody body = healthComponent.body;
					obj = ((body != null) ? body.characterMotor : null);
				}
				CharacterMotor val3 = (CharacterMotor)obj;
				if (Object.op_Implicit((Object)(object)val3))
				{
					Vector3 moveDirection = val3.moveDirection;
					Vector3 normalized = ((Vector3)(ref moveDirection)).normalized;
					float num = target.healthComponent.body.moveSpeed * duration;
					Vector3 val4 = val + (num + 10f) * normalized;
					if (((Vector3)(ref val4)).sqrMagnitude <= 100f)
					{
						val4 = val - (num - 10f) * normalized;
					}
					val = val4;
				}
			}
			predictedDestination = ((EntityState)this).transform.position + val;
			((EntityState)this).characterDirection.forward = val;
		}

		private Vector3 GetFinalPosition()
		{
			//IL_0017: 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_0036: 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)
			//IL_003b: 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_004f: 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_0060: 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_0070: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (Object.op_Implicit((Object)(object)target) ? Vector3.Lerp(predictedDestination, ((Component)target).transform.position, JohnHopooReturns.Behaviour<Beetles>.Instance.burrowAccuracyCoefficient) : predictedDestination);
			NodeGraph groundNodes = SceneInfo.instance.groundNodes;
			NodeIndex val2 = groundNodes.FindClosestNode(val, ((EntityState)this).characterBody.hullClassification, float.PositiveInfinity);
			groundNodes.GetNodePosition(val2, ref val);
			return val + (((EntityState)this).transform.position - ((EntityState)this).characterBody.footPosition);
		}

		private void SetPosition(Vector3 newPosition)
		{
			//IL_0012: 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)
			CharacterMotor characterMotor = ((EntityState)this).characterMotor;
			if (characterMotor != null)
			{
				((BaseCharacterController)characterMotor).Motor.SetPositionAndRotation(newPosition, Quaternion.identity, true);
			}
		}

		public override void FixedUpdate()
		{
			//IL_001e: 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)
			((EntityState)this).FixedUpdate();
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
			{
				((EntityState)this).characterMotor.velocity = Vector3.zero;
			}
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextState((EntityState)(object)new ExitBurrow());
			}
		}

		public override void OnExit()
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Vector3 finalPosition = GetFinalPosition();
			((EntityState)this).characterDirection.forward = finalPosition - ((EntityState)this).transform.position;
			SetPosition(finalPosition);
			((EntityState)this).gameObject.layer = LayerIndex.defaultLayer.intVal;
			CharacterMotor characterMotor = ((EntityState)this).characterMotor;
			if (characterMotor != null)
			{
				((BaseCharacterController)characterMotor).Motor.RebuildCollidableLayers();
			}
			if (Object.op_Implicit((Object)(object)characterModel))
			{
				CharacterModel obj = characterModel;
				obj.invisibilityCount--;
			}
			if (Object.op_Implicit((Object)(object)hurtboxGroup))
			{
				HurtBoxGroup obj2 = hurtboxGroup;
				int hurtBoxesDeactivatorCounter = obj2.hurtBoxesDeactivatorCounter;
				obj2.hurtBoxesDeactivatorCounter = hurtBoxesDeactivatorCounter - 1;
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
			{
				((Behaviour)((EntityState)this).characterMotor).enabled = true;
			}
			Util.PlaySound("Stop_magmaWorm_burrowed_loop", ((EntityState)this).gameObject);
			((EntityState)this).OnExit();
		}
	}

	public class ExitBurrow : BaseState
	{
		private const float ANIM_DURATION_COEF = 0.7f;

		private const float ANIM_JUMP_MARKER = 0.6f;

		private float duration;

		private bool didJump;

		private bool didCancelAnimation;

		private bool movementHitAuthority;

		public override void OnEnter()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			((BaseState)this).OnEnter();
			duration = JohnHopooReturns.Behaviour<Beetles>.Instance.baseBurrowExitDuration / base.attackSpeedStat;
			((EntityState)this).PlayAnimation("Body", "Spawn1", "Spawn1.playbackRate", duration / 0.7f);
			if (((EntityState)this).isAuthority)
			{
				((EntityState)this).characterMotor.onMovementHit += new MovementHitDelegate(OnMovementHit);
			}
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).fixedAge >= duration * JohnHopooReturns.Behaviour<Beetles>.Instance.exitJumpMarker / 0.7f)
			{
				TryJump();
			}
			if (!(((EntityState)this).fixedAge < duration))
			{
				TryCancelAnimation();
				if (((EntityState)this).isAuthority && (movementHitAuthority || (((BaseCharacterController)((EntityState)this).characterMotor).Motor.GroundingStatus.IsStableOnGround && !((BaseCharacterController)((EntityState)this).characterMotor).Motor.LastGroundingStatus.IsStableOnGround)))
				{
					((EntityState)this).outer.SetNextStateToMain();
				}
			}
		}

		public override void OnExit()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			TryJump();
			TryCancelAnimation();
			if (((EntityState)this).isAuthority)
			{
				((EntityState)this).characterMotor.onMovementHit -= new MovementHitDelegate(OnMovementHit);
			}
			((EntityState)this).OnExit();
		}

		public void TryJump()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0093: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			if (!didJump && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
			{
				EffectManager.SimpleEffect(BeetleBurrowEffect, ((EntityState)this).characterBody.footPosition, Quaternion.identity, false);
				Util.PlaySound(JohnHopooReturns.Behaviour<Beetles>.Instance.burrowSoundString, ((EntityState)this).gameObject);
				Util.PlaySound(JohnHopooReturns.Behaviour<Beetles>.Instance.endSoundString, ((EntityState)this).gameObject);
				((BaseCharacterController)((EntityState)this).characterMotor).Motor.ForceUnground();
				CharacterMotor characterMotor = ((EntityState)this).characterMotor;
				characterMotor.velocity += Vector3.up * JohnHopooReturns.Behaviour<Beetles>.Instance.exitVelocityBonus;
				didJump = true;
			}
		}

		public void TryCancelAnimation()
		{
			if (!didCancelAnimation)
			{
				((EntityState)this).PlayCrossfade("Body", ((BaseState)this).isGrounded ? "Idle" : "Jump", 1f);
				didCancelAnimation = true;
			}
		}

		private void OnMovementHit(ref MovementHitInfo movementHitInfo)
		{
			movementHitAuthority = true;
		}
	}

	private const string SECTION = "Beetle Buff";

	public float baseBurrowDuration = 1f;

	public float baseBurrowExitDuration = 1.3f;

	public float exitJumpMarker = 0.4f;

	public float exitVelocityBonus = 0f;

	public float crossfadeDelay = 1.1f;

	public float crossfadeDuration = 0.2f;

	public float animSpeed = 1.3f;

	public string burrowSoundString = "Play_treeBot_sprint_end";

	public string startSoundString = "Play_beetle_worker_idle";

	public string endSoundString = "Play_hermitCrab_unburrow";

	public float burrowAccuracyCoefficient = 0.3f;

	public static SkillDef BeetleBodyBurrow { get; private set; }

	public static GameObject BeetleBurrowEffect { get; private set; }

	public void Awake()
	{
		if (!JohnHopooReturns.Behaviour.Config.Value("Beetle Buff", string.Format("Enabled", "Beetle Buff"), defaultValue: true, "Beetles move faster, spawn faster, and gain a new burrow skill."))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		Util.Add(JohnHopooReturns.Behaviour.Content.entityStateTypes, typeof(EnterBurrow));
		Util.Add(JohnHopooReturns.Behaviour.Content.entityStateTypes, typeof(BeetleBurrow));
		Util.Add(JohnHopooReturns.Behaviour.Content.entityStateTypes, typeof(ExitBurrow));
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		BeetleBodyBurrow = ScriptableObject.CreateInstance<SkillDef>();
		BeetleBodyBurrow.skillName = "GS_BeetleBodyBurrow";
		BeetleBodyBurrow.activationStateMachineName = "Body";
		BeetleBodyBurrow.activationState = new SerializableEntityStateType(typeof(EnterBurrow));
		BeetleBodyBurrow.baseRechargeInterval = 8f;
		BeetleBodyBurrow.cancelSprintingOnActivation = false;
		BeetleBodyBurrow.isCombatSkill = false;
		JohnHopooReturns.Behaviour.Content.skillDefs.Add<SkillDef>(BeetleBodyBurrow);
		if (!JohnHopooReturns.Behaviour.LoadAddressable<SkillFamily>("RoR2/Base/Beetle/BeetleBodySecondaryFamily.asset", out var BeetleBodySecondaryFamily))
		{
			yield return BeetleBodySecondaryFamily;
		}
		BeetleBodySecondaryFamily.Result.variants[0].skillDef = BeetleBodyBurrow;
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/Base/Beetle/BeetleMaster.prefab", out var BeetleMaster))
		{
			yield return BeetleMaster;
		}
		AISkillDriver[] skillDrivers = BeetleMaster.Result.GetComponents<AISkillDriver>();
		AISkillDriver followNodeGraphToTarget = ((IEnumerable<AISkillDriver>)skillDrivers).FirstOrDefault((Func<AISkillDriver, bool>)((AISkillDriver x) => x.customName == "FollowNodeGraphToTarget"));
		if (Object.op_Implicit((Object)(object)followNodeGraphToTarget))
		{
			Object.DestroyImmediate((Object)(object)followNodeGraphToTarget);
		}
		AISkillDriver jumpAtTarget = BeetleMaster.Result.AddComponent<AISkillDriver>();
		jumpAtTarget.customName = "BurrowTowardsTarget";
		jumpAtTarget.skillSlot = (SkillSlot)1;
		jumpAtTarget.requireSkillReady = true;
		jumpAtTarget.minDistance = 20f;
		jumpAtTarget.maxDistance = 60f;
		jumpAtTarget.selectionRequiresTargetLoS = true;
		jumpAtTarget.selectionRequiresOnGround = true;
		jumpAtTarget.moveTargetType = (TargetType)0;
		jumpAtTarget.movementType = (MovementType)1;
		jumpAtTarget.aimType = (AimType)2;
		AISkillDriver newFollowNodeGraphToTarget = BeetleMaster.Result.AddComponent<AISkillDriver>();
		newFollowNodeGraphToTarget.customName = "FollowNodeGraphToTarget";
		newFollowNodeGraphToTarget.skillSlot = (SkillSlot)(-1);
		newFollowNodeGraphToTarget.moveTargetType = (TargetType)0;
		newFollowNodeGraphToTarget.movementType = (MovementType)1;
		newFollowNodeGraphToTarget.aimType = (AimType)4;
		if (!JohnHopooReturns.Behaviour.LoadAddressable<EntityStateConfiguration>("RoR2/Base/Beetle/EntityStates.BeetleMonster.SpawnState.asset", out var spawnStateConfiguration))
		{
			yield return spawnStateConfiguration;
		}
		spawnStateConfiguration.Result.TryModifyFieldValue("duration", 3.5f);
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/Base/Beetle/BeetleBody.prefab", out var beetleBodyPrefab))
		{
			yield return beetleBodyPrefab;
		}
		beetleBodyPrefab.Result.GetComponent<CharacterBody>().baseMoveSpeed = 7f;
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/Base/Beetle/BeetleGuardSunderPop.prefab", out var BeetleGuardSunderPop))
		{
			yield return BeetleGuardSunderPop;
		}
		BeetleBurrowEffect = PrefabAPI.InstantiateClone(BeetleGuardSunderPop.Result, "BeetleBurrowEffect", false);
		BeetleBurrowEffect.GetComponent<VFXAttributes>().vfxPriority = (VFXPriority)2;
		ParticleSystemRenderer dustRenderer = default(ParticleSystemRenderer);
		if (BeetleBurrowEffect.transform.TryFind("Particles/ParticleInitial/Dust", out var dust) && ((Component)dust).TryGetComponent<ParticleSystemRenderer>(ref dustRenderer))
		{
			((Renderer)dustRenderer).sharedMaterial = new Material(((Renderer)dustRenderer).sharedMaterial);
			((Renderer)dustRenderer).sharedMaterial.SetColor("_TintColor", Color32.op_Implicit(new Color32((byte)201, (byte)126, (byte)44, byte.MaxValue)));
		}
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/Base/Beetle/BeetleGuardGroundSlam.prefab", out var BeetleGuardGroundSlam))
		{
			yield return BeetleGuardGroundSlam;
		}
		if (BeetleGuardGroundSlam.Result.transform.TryFind("ParticleInitial/Decal", out var decal))
		{
			GameObject burrowDecal = Object.Instantiate<GameObject>(((Component)decal).gameObject, BeetleBurrowEffect.transform);
			burrowDecal.transform.localScale = Vector3.one * 5f;
		}
		JohnHopooReturns.Behaviour.Content.effectDefs.Add<EffectDef>(new EffectDef(BeetleBurrowEffect));
	}
}
public class Bungus : JohnHopooReturns.Behaviour, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	private const string SECTION = "Bustling Fungus Returns";

	public void Awake()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("Bustling Fungus Returns", string.Format("Enabled", "Bustling Fungus Returns"), defaultValue: true, "Bungus has better stacking but cannot be used while attacking. Also includes a notable damage buff for Engineer's stationary turrets."))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		LanguageAPI.Add("ITEM_MUSHROOM_DESC", "After standing still for <style=cIsHealing>1</style> second, create a zone that <style=cIsHealing>heals</style> for <style=cIsHealing>4.5%</style> <style=cStack>(+4.5% per stack)</style> of your <style=cIsHealing>health</style> every second to all allies within <style=cIsHealing>3m</style> <style=cStack>(+1.5m per stack)</style>.");
		MushroomBodyBehavior.FixedUpdate += new Manipulator(MushroomBodyBehavior_FixedUpdate);
	}

	private void MushroomBodyBehavior_FixedUpdate(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "GetNotMoving")
		}))
		{
			val.Emit(OpCodes.Ldarg, 0);
			val.EmitDelegate<Func<bool, MushroomBodyBehavior, bool>>((Func<bool, MushroomBodyBehavior, bool>)((bool active, MushroomBodyBehavior behaviour) => active && ((BaseItemBodyBehavior)behaviour).body.outOfCombatStopwatch >= 1f));
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"Bungus.MushroomBodyBehavior_FixedUpdate IL hook 1 failed!");
		}
		if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchStfld<HealingWard>(x, "interval")
		}))
		{
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldc_R4, 0.5f);
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"Bungus.MushroomBodyBehavior_FixedUpdate IL hook 2 failed!");
		}
		if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchStfld<HealingWard>(x, "healFraction")
		}))
		{
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldarg, 0);
			val.EmitDelegate<Func<MushroomBodyBehavior, float>>((Func<MushroomBodyBehavior, float>)((MushroomBodyBehavior behaviour) => (float)((BaseItemBodyBehavior)behaviour).stack * 0.045f * 0.5f));
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"Bungus.MushroomBodyBehavior_FixedUpdate IL hook 3 failed!");
		}
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!JohnHopooReturns.Behaviour.LoadAddressable<EntityStateConfiguration>("RoR2/Base/Engi/EntityStates.EngiTurret.EngiTurretWeapon.FireGauss.asset", out var fireGaussConfiguration))
		{
			yield return fireGaussConfiguration;
		}
		fireGaussConfiguration.Result.TryModifyFieldValue("damageCoefficient", 1f);
	}
}
public class Elixir : JohnHopooReturns.Behaviour<Elixir>, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	public class ElixirBehaviour : BaseItemBodyBehavior, IOnTakeDamageServerReceiver
	{
		[ItemDefAssociation(useOnServer = true, useOnClient = false)]
		public static ItemDef GetItemDef()
		{
			return JohnHopooReturns.Behaviour<Elixir>.Exists ? Items.HealingPotion : null;
		}

		public void OnEnable()
		{
			((BaseItemBodyBehavior)this).body.healthComponent.AddTakeDamageReceiver((IOnTakeDamageServerReceiver)(object)this);
		}

		public void OnDisable()
		{
			((BaseItemBodyBehavior)this).body.healthComponent.RemoveTakeDamageReceiver((IOnTakeDamageServerReceiver)(object)this);
		}

		public void OnTakeDamageServer(DamageReport damageReport)
		{
			//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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			if (base.stack > 0 && !((BaseItemBodyBehavior)this).body.healthComponent.alive)
			{
				((BaseItemBodyBehavior)this).body.healthComponent.Networkhealth = 1f;
				Util.CleanseBody(((BaseItemBodyBehavior)this).body, true, false, false, true, false, true);
				((BaseItemBodyBehavior)this).body.inventory.RemoveItem(Items.HealingPotion, 1);
				((BaseItemBodyBehavior)this).body.inventory.GiveItem(Items.HealingPotionConsumed, 1);
				CharacterMasterNotificationQueue.SendTransformNotification(((BaseItemBodyBehavior)this).body.master, Items.HealingPotion.itemIndex, Items.HealingPotionConsumed.itemIndex, (TransformationType)0);
				EffectData val = new EffectData
				{
					origin = ((BaseItemBodyBehavior)this).body.corePosition
				};
				val.SetNetworkedObjectReference(((Component)this).gameObject);
				EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/HealingPotionEffect"), val, true);
			}
		}
	}

	private const string SECTION = "Power Elixir Rework";

	public void Awake()
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("Power Elixir Rework", string.Format("Enabled", "Power Elixir Rework"), defaultValue: true, "Power Elixir becomes Elixir and saves you from lethal damage once."))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		LanguageAPI.Add("ITEM_HEALINGPOTION_NAME", "Elixir", "en");
		LanguageAPI.Add("ITEM_HEALINGPOTION_PICKUP", "Survive one lethal attack. Consumed on use.");
		LanguageAPI.Add("ITEM_HEALINGPOTION_DESC", "If you would recieve <style=cIsHealth>lethal damage</style>, <style=cIsUtility>consume</style> this item to <style=cIsHealing>survive</style> with <style=cIsHealing>1 hp</style>.");
		ItemCounts.ctor += new Manipulator(ItemCounts_ctor);
	}

	private void ItemCounts_ctor(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
			(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1),
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "HealingPotion"),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCount"),
			(Instruction x) => ILPatternMatchingExt.MatchStfld<ItemCounts>(x, "healingPotion")
		}))
		{
			val.RemoveRange(5);
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"Elixir.ItemCounts_ctor IL hook failed!");
		}
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!JohnHopooReturns.Behaviour.LoadAddressable<ItemDef>("RoR2/DLC1/HealingPotion/HealingPotion.asset", out var HealingPotion))
		{
			yield return HealingPotion;
		}
		HealingPotion.Result.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)2 };
	}
}
public class HappiestMask : JohnHopooReturns.Behaviour<HappiestMask>
{
	private const string SECTION = "Happiest Mask Always Procs";

	public CharacterMaster[] aiMastersByBody;

	public void Awake()
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("Happiest Mask Always Procs", string.Format("Enabled", "Happiest Mask Always Procs"), defaultValue: true, "Happiest Mask chance increased to 100% with reduced duration and damage."))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		LanguageAPI.Add("ITEM_GHOSTONKILL_PICKUP", "Summon a ghost on killing an enemy.");
		LanguageAPI.Add("ITEM_GHOSTONKILL_DESC", "Kills <style=cIsDamage>spawn a ghost</style> of the killed enemy with <style=cIsDamage>300%</style> damage that lasts <style=cIsDamage>15s</style> <style=cStack>(+15s per stack)</style>.");
		GlobalEventManager.OnCharacterDeath += new Manipulator(GlobalEventManager_OnCharacterDeath);
		Util.TryToCreateGhost += new Manipulator(Util_TryToCreateGhost);
	}

	private void GlobalEventManager_OnCharacterDeath(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		float num4 = default(float);
		int num3 = default(int);
		ILLabel val2 = default(ILLabel);
		if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "GhostOnKill"),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCount")
		}) && val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num4),
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num3),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Util), "CheckRoll"),
			(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val2)
		}))
		{
			val.RemoveRange(4);
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"HappiestMask.GlobalEventManager_OnCharacterDeath IL hook 1 failed!");
		}
		int num2 = default(int);
		int num = default(int);
		if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2),
			(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num),
			(Instruction x) => ILPatternMatchingExt.MatchMul(x),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Util), "TryToCreateGhost")
		}))
		{
			int index = val.Index;
			val.Index = index + 1;
			val.Next.Operand = (sbyte)15;
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"HappiestMask.GlobalEventManager_OnCharacterDeath IL hook 2 failed!");
		}
	}

	private void Util_TryToCreateGhost(ILContext il)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: 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)
		ILCursor val = new ILCursor(il);
		int locDisplayClassIndex = -1;
		FieldReference bodyPrefabField = null;
		ILLabel val3 = default(ILLabel);
		int num = default(int);
		MethodReference val2 = default(MethodReference);
		if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[15]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locDisplayClassIndex),
			(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(BodyCatalog), "FindBodyPrefab"),
			(Instruction x) => ILPatternMatchingExt.MatchStfld(x, ref bodyPrefabField),
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, locDisplayClassIndex),
			(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, bodyPrefabField),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Object>(x, "op_Implicit"),
			(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val3),
			(Instruction x) => ILPatternMatchingExt.MatchLdnull(x),
			(Instruction x) => ILPatternMatchingExt.MatchRet(x),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(MasterCatalog), "get_allAiMasters"),
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num),
			(Instruction x) => ILPatternMatchingExt.MatchLdftn(x, ref val2),
			(Instruction x) => ILPatternMatchingExt.MatchNewobj<Func<CharacterMaster, bool>>(x),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Enumerable), "FirstOrDefault")
		}))
		{
			int index = val.Index;
			val.Index = index + 1;
			val.RemoveRange(14);
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldarg, 0);
			val.EmitDelegate<Func<CharacterBody, CharacterMaster>>((Func<CharacterBody, CharacterMaster>)((CharacterBody targetBody) => ArrayUtils.GetSafe<CharacterMaster>(aiMastersByBody, (int)targetBody.bodyIndex)));
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"HappiestMask.Util_TryToCreateGhost IL hook 1 failed!");
		}
		if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchStfld<MasterSummon>(x, "preSpawnSetupCallback")
		}) && val.TryGotoPrev((MoveType)0, new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Delegate>(x, "Combine")
		}))
		{
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldarg, 2);
			val.EmitDelegate<Func<int, Action<CharacterMaster>>>((Func<int, Action<CharacterMaster>>)((int duration) => delegate(CharacterMaster newMaster)
			{
				newMaster.inventory.GiveItem(Items.Ghost, 1);
				newMaster.inventory.GiveItem(Items.HealthDecay, duration);
				newMaster.inventory.GiveItem(Items.BoostDamage, 20);
			}));
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"HappiestMask.Util_TryToCreateGhost IL hook 2 failed!");
		}
	}

	[SystemInitializer(new Type[]
	{
		typeof(BodyCatalog),
		typeof(MasterCatalog)
	})]
	public static void TryInit()
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Invalid comparison between Unknown and I4
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Invalid comparison between Unknown and I4
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		if (!JohnHopooReturns.Behaviour<HappiestMask>.Exists)
		{
			return;
		}
		JohnHopooReturns.Behaviour<HappiestMask>.Instance.aiMastersByBody = (CharacterMaster[])(object)new CharacterMaster[BodyCatalog.bodyCount];
		foreach (CharacterMaster allAiMaster in MasterCatalog.allAiMasters)
		{
			BodyIndex val = BodyCatalog.FindBodyIndex(allAiMaster.bodyPrefab);
			if ((int)val > -1 && (int)val < BodyCatalog.bodyCount && (Object)(object)JohnHopooReturns.Behaviour<HappiestMask>.Instance.aiMastersByBody[val] == (Object)null)
			{
				JohnHopooReturns.Behaviour<HappiestMask>.Instance.aiMastersByBody[val] = allAiMaster;
			}
		}
	}
}
public class HideOSPBar : JohnHopooReturns.Behaviour, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	private const string SECTION = "Hide One Shot Protection Indicator";

	public void Awake()
	{
		if (!JohnHopooReturns.Behaviour.Config.Value("Hide One Shot Protection Indicator", string.Format("Enabled", "Hide One Shot Protection Indicator"), defaultValue: true))
		{
			Object.Destroy((Object)(object)this);
		}
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!JohnHopooReturns.Behaviour.LoadAddressable<HealthBarStyle>("RoR2/Base/Common/HUDHealthBar.asset", out var HUDHealthBar))
		{
			yield return HUDHealthBar;
		}
		HUDHealthBar.Result.ospStyle.enabled = false;
	}
}
[BepInPlugin("com.groovesalad.vs.theGame", "Groove_Salad_vs_the_Game", "0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class JohnHopooReturns : BaseUnityPlugin, IContentPackProvider
{
	public interface IOnLoadStaticContentAsyncProvider
	{
		IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args);
	}

	public class Behaviour : MonoBehaviour
	{
		public const string BEHAVIOUR_ENABLED = "Enabled";

		public static ContentPack Content => instance.contentPack;

		public static ConfigFile Config => ((BaseUnityPlugin)instance).Config;

		public static ManualLogSource Logger => ((BaseUnityPlugin)instance).Logger;

		public static AssetBundle Assets => instance.johnhopoogamesassets.assetBundle;

		public static bool LoadAddressable<TObject>(object key, out AsyncOperationHandle<TObject> op)
		{
			//IL_0003: 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)
			op = Addressables.LoadAssetAsync<TObject>(key);
			return op.IsDone;
		}
	}

	public class Behaviour<TBehaviour> : Behaviour where TBehaviour : Behaviour<TBehaviour>
	{
		public static TBehaviour Instance { get; private set; }

		public static bool Exists => (Object)(object)Instance != (Object)null;

		public Behaviour()
		{
			Instance = this as TBehaviour;
		}
	}

	public ContentPack contentPack;

	public AssetBundleCreateRequest johnhopoogamesassets;

	public static JohnHopooReturns instance;

	public string identifier => "groovesalad.JohnHopooReturns";

	public void Awake()
	{
		//IL_0008: 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_001f: Expected O, but got Unknown
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Expected O, but got Unknown
		instance = this;
		contentPack = new ContentPack
		{
			identifier = identifier
		};
		johnhopoogamesassets = AssetBundle.LoadFromFileAsync(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "johnhopoogamesassets"));
		((Component)this).gameObject.AddComponent<SurvivorSpeed>();
		((Component)this).gameObject.AddComponent<PostProcessing>();
		((Component)this).gameObject.AddComponent<Beetles>();
		((Component)this).gameObject.AddComponent<MonsterStats>();
		((Component)this).gameObject.AddComponent<Scythe>();
		((Component)this).gameObject.AddComponent<LeechingSeed>();
		((Component)this).gameObject.AddComponent<WarHorn>();
		((Component)this).gameObject.AddComponent<Bungus>();
		((Component)this).gameObject.AddComponent<HappiestMask>();
		((Component)this).gameObject.AddComponent<Opal>();
		((Component)this).gameObject.AddComponent<RoseBuckler>();
		((Component)this).gameObject.AddComponent<Soulbound>();
		((Component)this).gameObject.AddComponent<Elixir>();
		((Component)this).gameObject.AddComponent<HideOSPBar>();
		((Component)this).gameObject.AddComponent<Polyp>();
		((Component)this).gameObject.AddComponent<RejuvRack>();
		((Component)this).gameObject.AddComponent<NoMeteors>();
		((Component)this).gameObject.AddComponent<Tesla>();
		((Component)this).gameObject.AddComponent<StunGrenade>();
		((Component)this).gameObject.AddComponent<Aegis>();
		((Component)this).gameObject.AddComponent<SpareDroneParts>();
		((Component)this).gameObject.AddComponent<Watch>();
		ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)delegate(AddContentPackProviderDelegate add)
		{
			add.Invoke((IContentPackProvider)(object)this);
		};
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!((AsyncOperation)johnhopoogamesassets).isDone)
		{
			yield return johnhopoogamesassets;
		}
		IOnLoadStaticContentAsyncProvider[] providers = ((Component)this).GetComponents<IOnLoadStaticContentAsyncProvider>();
		for (int i = 0; i < providers.Length; i++)
		{
			yield return providers[i].LoadStaticContentAsync(args);
			args.ReportProgress((float)i / (float)providers.Length);
		}
	}

	public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
	{
		ContentPack.Copy(contentPack, args.output);
		yield break;
	}

	public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
	{
		AssetBundle assetBundle = johnhopoogamesassets.assetBundle;
		if (assetBundle != null)
		{
			assetBundle.Unload(false);
		}
		yield break;
	}
}
public class LeechingSeed : JohnHopooReturns.Behaviour<LeechingSeed>
{
	public class HealOnHitBehaviour : BaseItemBodyBehavior, IOnDamageDealtServerReceiver
	{
		[ItemDefAssociation(useOnServer = true, useOnClient = false)]
		public static ItemDef GetItemDef()
		{
			return JohnHopooReturns.Behaviour<LeechingSeed>.Exists ? Items.Seed : null;
		}

		public void OnDamageDealtServer(DamageReport damageReport)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)((BaseItemBodyBehavior)this).body.healthComponent) && !((ProcChainMask)(ref damageReport.damageInfo.procChainMask)).HasProc((ProcType)6))
			{
				ProcChainMask procChainMask = damageReport.damageInfo.procChainMask;
				((ProcChainMask)(ref procChainMask)).AddProc((ProcType)6);
				((BaseItemBodyBehavior)this).body.healthComponent.Heal((float)base.stack, procChainMask, true);
			}
		}
	}

	private const string SECTION = "Leeching Seed Ignores Proc Coefficient";

	public void Awake()
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("Leeching Seed Ignores Proc Coefficient", string.Format("Enabled", "Leeching Seed Ignores Proc Coefficient"), defaultValue: true, "Leeching Seed heals 1 from all damage, including damage over times."))
		{
			Object.Destroy((Object)(object)this);
		}
		else
		{
			GlobalEventManager.OnHitEnemy += new Manipulator(GlobalEventManager_OnHitEnemy);
		}
	}

	private void GlobalEventManager_OnHitEnemy(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_005f: 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)
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "Seed"),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCount")
		}))
		{
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldc_I4_0);
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"LeechingSeed.GlobalEventManager_OnHitEnemy IL hook failed!");
		}
	}
}
public class MonsterStats : JohnHopooReturns.Behaviour<MonsterStats>, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	private const string SECTION = "Monster Stat Tweaks";

	public void Awake()
	{
		if (!JohnHopooReturns.Behaviour.Config.Value("Monster Stat Tweaks", string.Format("Enabled", "Monster Stat Tweaks"), defaultValue: true, "A collection of enemy balance changes focused on the first few stages. Increases the health of weaker monsters like Beetles and Lemurians. Elites are cheaper to spawn but have reduced health. Greater Wisps cost less credits to spawn."))
		{
			Object.Destroy((Object)(object)this);
		}
	}

	[SystemInitializer(new Type[] { typeof(CombatDirector) })]
	public static void TryInit()
	{
		if (!JohnHopooReturns.Behaviour<MonsterStats>.Exists)
		{
			return;
		}
		EliteTierDef val = ((IEnumerable<EliteTierDef>)CombatDirector.eliteTiers).FirstOrDefault((Func<EliteTierDef, bool>)((EliteTierDef x) => Array.IndexOf(x.eliteTypes, Elites.Fire) >= 0));
		if (val != null)
		{
			val.costMultiplier = 4f;
			EliteDef[] eliteTypes = val.eliteTypes;
			foreach (EliteDef val2 in eliteTypes)
			{
				val2.healthBoostCoefficient = Mathf.Max(1f, val2.healthBoostCoefficient - 1f);
			}
		}
		EliteTierDef val3 = ((IEnumerable<EliteTierDef>)CombatDirector.eliteTiers).FirstOrDefault((Func<EliteTierDef, bool>)((EliteTierDef x) => Array.IndexOf(x.eliteTypes, Elites.FireHonor) >= 0));
		if (val3 != null)
		{
			val3.costMultiplier = 2.5f;
			EliteDef[] eliteTypes2 = val3.eliteTypes;
			foreach (EliteDef val4 in eliteTypes2)
			{
				val4.healthBoostCoefficient = Mathf.Max(1f, val4.healthBoostCoefficient - 1f);
			}
		}
		EliteTierDef val5 = ((IEnumerable<EliteTierDef>)CombatDirector.eliteTiers).FirstOrDefault((Func<EliteTierDef, bool>)((EliteTierDef x) => Array.IndexOf(x.eliteTypes, Elites.Poison) >= 0));
		if (val5 != null)
		{
			val5.costMultiplier = 24f;
			EliteDef[] eliteTypes3 = val5.eliteTypes;
			foreach (EliteDef val6 in eliteTypes3)
			{
				val6.healthBoostCoefficient = Mathf.Max(1f, val6.healthBoostCoefficient * 0.75f);
			}
		}
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/Base/Wisp/WispBody.prefab", out var wispBodyPrefab))
		{
			yield return wispBodyPrefab;
		}
		CharacterBody wispBody = default(CharacterBody);
		if (wispBodyPrefab.Result.TryGetComponent<CharacterBody>(ref wispBody))
		{
			wispBody.baseMaxHealth = 60f;
			wispBody.levelMaxHealth = 18f;
		}
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/Base/Jellyfish/JellyfishBody.prefab", out var jellyfishBodyPrefab))
		{
			yield return jellyfishBodyPrefab;
		}
		CharacterBody jellyfishBody = default(CharacterBody);
		if (jellyfishBodyPrefab.Result.TryGetComponent<CharacterBody>(ref jellyfishBody))
		{
			jellyfishBody.baseMaxHealth = 80f;
			jellyfishBody.levelMaxHealth = 24f;
		}
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/Base/Beetle/BeetleBody.prefab", out var beetleBodyPrefab))
		{
			yield return beetleBodyPrefab;
		}
		CharacterBody beetleBody = default(CharacterBody);
		if (beetleBodyPrefab.Result.TryGetComponent<CharacterBody>(ref beetleBody))
		{
			beetleBody.baseMaxHealth = 144f;
			beetleBody.levelMaxHealth = 43f;
		}
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/Base/Lemurian/LemurianBody.prefab", out var lemurianBodyPrefab))
		{
			yield return lemurianBodyPrefab;
		}
		CharacterBody lemurianBody = default(CharacterBody);
		if (lemurianBodyPrefab.Result.TryGetComponent<CharacterBody>(ref lemurianBody))
		{
			lemurianBody.baseMaxHealth = 144f;
			lemurianBody.levelMaxHealth = 43f;
		}
		if (!JohnHopooReturns.Behaviour.LoadAddressable<CharacterSpawnCard>("RoR2/Base/GreaterWisp/cscGreaterWisp.asset", out var cscGreaterWisp))
		{
			yield return cscGreaterWisp;
		}
		((SpawnCard)cscGreaterWisp.Result).directorCreditCost = 100;
	}
}
public class NoMeteors : JohnHopooReturns.Behaviour
{
	private const string SECTION = "Hide Skybox Meteors";

	public void Awake()
	{
		if (!JohnHopooReturns.Behaviour.Config.Value("Hide Skybox Meteors", string.Format("Enabled", "Hide Skybox Meteors"), defaultValue: true))
		{
			Object.Destroy((Object)(object)this);
		}
		else
		{
			SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
		}
	}

	private void SceneManager_activeSceneChanged(Scene oldScene, Scene newScene)
	{
		GameObject obj = GameObject.Find("HOLDER: Meteors");
		if (obj != null)
		{
			obj.SetActive(false);
		}
	}
}
public class Opal : JohnHopooReturns.Behaviour, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	private const string SECTION = "Uncommon Oddly-shaped Opal";

	public void Awake()
	{
		if (!JohnHopooReturns.Behaviour.Config.Value("Uncommon Oddly-shaped Opal", string.Format("Enabled", "Uncommon Oddly-shaped Opal"), defaultValue: true))
		{
			Object.Destroy((Object)(object)this);
		}
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!JohnHopooReturns.Behaviour.LoadAddressable<ItemDef>("RoR2/DLC1/OutOfCombatArmor/OutOfCombatArmor.asset", out var OutOfCombatArmor))
		{
			yield return OutOfCombatArmor;
		}
		OutOfCombatArmor.Result.deprecatedTier = (ItemTier)1;
		AssetBundleRequest texOddlyShapedOpalIcon = JohnHopooReturns.Behaviour.Assets.LoadAssetAsync<Sprite>("texOddlyShapedOpalIcon");
		yield return texOddlyShapedOpalIcon;
		OutOfCombatArmor.Result.pickupIconSprite = (Sprite)texOddlyShapedOpalIcon.asset;
	}
}
public class Polyp : JohnHopooReturns.Behaviour, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	private const string SECTION = "Reduced Squid Polyp Knockback";

	public void Awake()
	{
		if (!JohnHopooReturns.Behaviour.Config.Value("Reduced Squid Polyp Knockback", string.Format("Enabled", "Reduced Squid Polyp Knockback"), defaultValue: true, "Reduces Squid Polyp knockback force and increases firerate to compensate."))
		{
			Object.Destroy((Object)(object)this);
		}
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!JohnHopooReturns.Behaviour.LoadAddressable<EntityStateConfiguration>("RoR2/Base/Squid/EntityStates.Squid.SquidWeapon.FireSpine.asset", out var fireSpineConfiguration))
		{
			yield return fireSpineConfiguration;
		}
		fireSpineConfiguration.Result.TryModifyFieldValue("forceScalar", 400f);
		fireSpineConfiguration.Result.TryModifyFieldValue("baseDuration", 0.5f);
	}
}
public class PostProcessing : JohnHopooReturns.Behaviour
{
	private const string SECTION = "Updated Post Processing";

	public float temperature = JohnHopooReturns.Behaviour.Config.Value("Updated Post Processing", "Temperature", 2f);

	public bool enableToneMapping = JohnHopooReturns.Behaviour.Config.Value("Updated Post Processing", "Enable Custom Tone Mapping", defaultValue: true);

	public void Awake()
	{
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("Updated Post Processing", string.Format("Enabled", "Updated Post Processing"), defaultValue: true))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		PostProcessProfile val = ScriptableObject.CreateInstance<PostProcessProfile>();
		((Object)val).name = "ppJohnHopooGames";
		ColorGrading val2 = val.AddSettings<ColorGrading>();
		((ParameterOverride<float>)(object)val2.temperature).Override(temperature);
		if (enableToneMapping)
		{
			((ParameterOverride<Tonemapper>)(object)val2.tonemapper).Override((Tonemapper)3);
			((ParameterOverride<float>)(object)val2.toneCurveToeStrength).Override(0.35f);
			((ParameterOverride<float>)(object)val2.toneCurveToeLength).Override(0.6f);
			((ParameterOverride<float>)(object)val2.toneCurveShoulderStrength).Override(1f);
			((ParameterOverride<float>)(object)val2.toneCurveShoulderLength).Override(2f);
		}
		GameObject val3 = new GameObject("JohnHopooGamesPostProcessing");
		val3.layer = LayerIndex.postProcess.intVal;
		Object.DontDestroyOnLoad((Object)(object)val3);
		PostProcessVolume val4 = val3.AddComponent<PostProcessVolume>();
		val4.sharedProfile = val;
		val4.isGlobal = true;
		val4.weight = 1f;
		val4.priority = 1f;
	}
}
public class RejuvRack : JohnHopooReturns.Behaviour<RejuvRack>, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	public class SummonSpiritsBehaviour : BaseItemBodyBehavior
	{
		public class SummonSpiritMessage : INetMessage, ISerializableObject
		{
			private float regenValue;

			private Vector3 offset;

			private NetworkInstanceId networkInstanceId;

			public SummonSpiritMessage()
			{
			}

			public SummonSpiritMessage(float regenValue, Vector3 offset, NetworkInstanceId networkInstanceId)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				this.regenValue = regenValue;
				this.offset = offset;
				this.networkInstanceId = networkInstanceId;
			}

			public void Serialize(NetworkWriter writer)
			{
				//IL_0010: 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)
				writer.Write(regenValue);
				writer.Write(offset);
				writer.Write(networkInstanceId);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//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)
				regenValue = reader.ReadSingle();
				offset = reader.ReadVector3();
				networkInstanceId = reader.ReadNetworkId();
			}

			public void OnReceived()
			{
				//IL_000e: 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)
				if (!NetworkServer.active)
				{
					GameObject val = Util.FindNetworkObject(networkInstanceId);
					SummonSpiritsBehaviour summonSpiritsBehaviour = default(SummonSpiritsBehaviour);
					if (Object.op_Implicit((Object)(object)val) && val.TryGetComponent<SummonSpiritsBehaviour>(ref summonSpiritsBehaviour))
					{
						summonSpiritsBehaviour.InstantiateSpirit(regenValue, offset);
					}
				}
			}
		}

		public class SpiritController : MonoBehaviour
		{
			public ParticleSystem particles;

			public TrailRenderer trail;

			public float lifespan;

			public float regenValue;

			public Transform targetTransform;

			public float updateOffsetTimer;

			public Vector3 currentOffset;

			public Vector3 targetOffset;

			private Vector3 _currentOffsetVelocity;

			private Vector3 _currentVelocity;

			public void Start()
			{
				Util.PlaySound(JohnHopooReturns.Behaviour<RejuvRack>.Instance.spawnSoundEffect, ((Component)this).gameObject);
			}

			public void FixedUpdate()
			{
				lifespan -= Time.fixedDeltaTime;
			}

			public void Update()
			{
				//IL_00a1: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: 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)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: 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_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: 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_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_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: 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)
				//IL_0062: 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_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)targetTransform))
				{
					updateOffsetTimer -= Time.deltaTime;
					if (updateOffsetTimer <= 0f)
					{
						Vector3 insideUnitSphere = Random.insideUnitSphere;
						Vector3 insideUnitSphere2 = Random.insideUnitSphere;
						Vector3 val = ((((Vector3)(ref insideUnitSphere)).sqrMagnitude < ((Vector3)(ref insideUnitSphere2)).sqrMagnitude) ? insideUnitSphere : insideUnitSphere2);
						targetOffset = JohnHopooReturns.Behaviour<RejuvRack>.Instance.offsetRadius * val;
						updateOffsetTimer += Mathf.Lerp(4f, 1f, ((Vector3)(ref val)).sqrMagnitude);
					}
					currentOffset = Vector3.SmoothDamp(currentOffset, targetOffset, ref _currentOffsetVelocity, JohnHopooReturns.Behaviour<RejuvRack>.Instance.offsetSmoothTime, JohnHopooReturns.Behaviour<RejuvRack>.Instance.offsetMaxSpeed, Time.deltaTime);
					Vector3 val2 = ((Component)this).transform.position - currentOffset;
					val2 = Vector3.SmoothDamp(val2, targetTransform.position, ref _currentVelocity, JohnHopooReturns.Behaviour<RejuvRack>.Instance.smoothTime, JohnHopooReturns.Behaviour<RejuvRack>.Instance.maxSpeed, Time.deltaTime);
					((Component)this).transform.position = val2 + currentOffset;
				}
			}

			public void BeginDestroy()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				((Behaviour)((Component)this).GetComponent<ObjectScaleCurve>()).enabled = true;
				((Behaviour)((Component)this).GetComponent<DestroyOnTimer>()).enabled = true;
				if (Object.op_Implicit((Object)(object)particles))
				{
					EmissionModule emission = particles.emission;
					((EmissionModule)(ref emission)).enabled = false;
					particles.Stop();
				}
				if (Object.op_Implicit((Object)(object)trail))
				{
					trail.emitting = false;
				}
			}
		}

		[SerializeField]
		private Transform headTransform;

		private NetworkIdentity networkIdentity;

		[SerializeField]
		private float healingPoolServer;

		[SerializeField]
		private float summonSpiritTimerServer;

		public Queue<SpiritController> activeSpirits = new Queue<SpiritController>();

		private TemporaryVisualEffect vfxInstance;

		public float vfxRadius => Mathf.Min((float)activeSpirits.Count * 0.1f, 1f) * JohnHopooReturns.Behaviour<RejuvRack>.Instance.maxVfxRadiusCoefficient * ((BaseItemBodyBehavior)this).body.bestFitRadius;

		[ItemDefAssociation(useOnServer = true, useOnClient = true)]
		public static ItemDef GetItemDef()
		{
			return JohnHopooReturns.Behaviour<RejuvRack>.Exists ? Items.IncreaseHealing : null;
		}

		public void OnEnable()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			CharacterBody body = ((BaseItemBodyBehavior)this).body;
			object obj;
			if (body == null)
			{
				obj = null;
			}
			else
			{
				ModelLocator modelLocator = body.modelLocator;
				if (modelLocator == null)
				{
					obj = null;
				}
				else
				{
					Transform modelTransform = modelLocator.modelTransform;
					obj = ((modelTransform != null) ? ((Component)modelTransform).GetComponent<ChildLocator>() : null);
				}
			}
			ChildLocator val = (ChildLocator)obj;
			if (Object.op_Implicit((Object)(object)val))
			{
				headTransform = val.FindChild("Head");
			}
			networkIdentity = ((Component)this).GetComponent<NetworkIdentity>();
			HealthComponent.onCharacterHealServer += HealthComponent_onCharacterHealServer;
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
		}

		public void OnDisable()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			HealthComponent.onCharacterHealServer -= HealthComponent_onCharacterHealServer;
			RecalculateStatsAPI.GetStatCoefficients -= new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
		}

		private void HealthComponent_onCharacterHealServer(HealthComponent healthComponent, float amount, ProcChainMask procChainMask)
		{
			if (Object.op_Implicit((Object)(object)healthComponent) && (Object)(object)healthComponent == (Object)(object)((BaseItemBodyBehavior)this).body.healthComponent)
			{
				healingPoolServer = Mathf.Min(healingPoolServer + amount * (float)base.stack, ((BaseItemBodyBehavior)this).body.healthComponent.fullCombinedHealth);
			}
		}

		private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
		{
			if (!Object.op_Implicit((Object)(object)sender) || !((Object)(object)sender == (Object)(object)((BaseItemBodyBehavior)this).body))
			{
				return;
			}
			foreach (SpiritController activeSpirit in activeSpirits)
			{
				args.baseRegenAdd += activeSpirit.regenValue;
			}
		}

		public void FixedUpdate()
		{
			if (NetworkServer.active)
			{
				FixedUpdateServer();
			}
			if (activeSpirits.Count > 0)
			{
				SpiritController spiritController = activeSpirits.Peek();
				if ((Object)(object)spiritController == (Object)null || spiritController.lifespan <= 0f)
				{
					RemoveNextSpirit();
				}
			}
		}

		public void FixedUpdateServer()
		{
			if (!(healingPoolServer <= 0f))
			{
				summonSpiritTimerServer -= Time.fixedDeltaTime;
				if (summonSpiritTimerServer <= 0f)
				{
					summonSpiritTimerServer += 0.1f;
					float num = ((BaseItemBodyBehavior)this).body.healthComponent.fullCombinedHealth / 10f;
					healingPoolServer -= num;
					SummonSpiritServer(num);
				}
			}
		}

		public void OnDestroy()
		{
			while (activeSpirits.Count > 0)
			{
				RemoveNextSpirit();
			}
		}

		public void SummonSpiritServer(float energy)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0032: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Random.onUnitSphere * 20f;
			val.y = Mathf.Abs(val.y);
			float regenValue = energy / JohnHopooReturns.Behaviour<RejuvRack>.Instance.spiritDuration;
			InstantiateSpirit(regenValue, val);
			if (Object.op_Implicit((Object)(object)networkIdentity))
			{
				NetMessageExtensions.Send((INetMessage)(object)new SummonSpiritMessage(regenValue, val, networkIdentity.netId), (NetworkDestination)1);
			}
		}

		public void InstantiateSpirit(float regenValue, Vector3 offset)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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)
			Transform val = headTransform ?? ((Component)this).transform;
			SpiritController component = Object.Instantiate<GameObject>(SpiritPrefab, val.position + offset, Quaternion.identity).GetComponent<SpiritController>();
			component.lifespan = JohnHopooReturns.Behaviour<RejuvRack>.Instance.spiritDuration;
			component.regenValue = regenValue;
			component.targetTransform = val;
			component.currentOffset = offset;
			activeSpirits.Enqueue(component);
			OnSpiritsUpdated();
		}

		public void RemoveNextSpirit()
		{
			SpiritController spiritController = activeSpirits.Dequeue();
			if (Object.op_Implicit((Object)(object)spiritController))
			{
				spiritController.BeginDestroy();
			}
			OnSpiritsUpdated();
		}

		public void OnSpiritsUpdated()
		{
			//IL_00ef: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			((BaseItemBodyBehavior)this).body.MarkAllStatsDirty();
			if (activeSpirits.Count > 0)
			{
				if ((Object)(object)vfxInstance == (Object)null)
				{
					vfxInstance = Object.Instantiate<GameObject>(SummonSpiritsEffect, ((BaseItemBodyBehavior)this).body.corePosition, Quaternion.identity).GetComponent<TemporaryVisualEffect>();
					vfxInstance.parentTransform = ((BaseItemBodyBehavior)this).body.coreTransform;
					vfxInstance.visualState = (VisualState)0;
					vfxInstance.healthComponent = ((BaseItemBodyBehavior)this).body.healthComponent;
				}
				vfxInstance.radius = vfxRadius;
				Light val = default(Light);
				if (((Component)vfxInstance).TryGetComponent<Light>(ref val))
				{
					val.range = vfxInstance.radius * JohnHopooReturns.Behaviour<RejuvRack>.Instance.lightRadiusMultiplier;
				}
			}
			else if (Object.op_Implicit((Object)(object)vfxInstance))
			{
				vfxInstance.visualState = (VisualState)1;
			}
		}
	}

	public class DitherModelFast : MonoBehaviour
	{
		public float fade;

		public Renderer[] renderers;

		private MaterialPropertyBlock propertyStorage = new MaterialPropertyBlock();

		private static List<DitherModelFast> instancesList;

		public void OnEnable()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if (instancesList == null)
			{
				instancesList = new List<DitherModelFast>();
				SceneCamera.onSceneCameraPreRender += new SceneCameraDelegate(OnSceneCameraPreRender);
			}
			instancesList.Add(this);
		}

		public void OnDisable()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			if (instancesList.Remove(this) && instancesList.Count <= 0)
			{
				instancesList = null;
				SceneCamera.onSceneCameraPreRender -= new SceneCameraDelegate(OnSceneCameraPreRender);
			}
		}

		private static void OnSceneCameraPreRender(SceneCamera sceneCamera)
		{
			//IL_0021: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			CameraRigController cameraRigController = sceneCamera.cameraRigController;
			if (!Object.op_Implicit((Object)(object)cameraRigController))
			{
				return;
			}
			Vector3 position = ((Component)cameraRigController).transform.position;
			for (int i = 0; i < instancesList.Count; i++)
			{
				DitherModelFast ditherModelFast = instancesList[i];
				if (cameraRigController.enableFading)
				{
					ditherModelFast.fade = Mathf.Clamp01(Util.Remap(Vector3.Distance(((Component)ditherModelFast).transform.position, position), cameraRigController.fadeStartDistance, cameraRigController.fadeEndDistance, 0f, 1f));
				}
				else
				{
					ditherModelFast.fade = 1f;
				}
				ditherModelFast.UpdateDither();
			}
		}

		private void UpdateDither()
		{
			for (int num = renderers.Length - 1; num >= 0; num--)
			{
				Renderer val = renderers[num];
				val.GetPropertyBlock(propertyStorage);
				propertyStorage.SetFloat("_Fade", fade);
				val.SetPropertyBlock(propertyStorage);
			}
		}
	}

	private const string SECTION = "Rejuvenation Rack Rework";

	public float spiritDuration = 10f;

	public float offsetSmoothTime = 1f;

	public float offsetMaxSpeed = 5f;

	public float smoothTime = 0.2f;

	public float maxSpeed = 200f;

	public float offsetRadius = 2f;

	public float maxVfxRadiusCoefficient = 2f;

	public float lightRadiusMultiplier = 5f;

	public string spawnSoundEffect = "Play_item_proc_regenOnKill";

	public static GameObject SpiritPrefab { get; private set; }

	public static GameObject SummonSpiritsEffect { get; private set; }

	public void Awake()
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("Rejuvenation Rack Rework", string.Format("Enabled", "Rejuvenation Rack Rework"), defaultValue: true, "Rejuv Rack becomes a counterpart to N'kuhana's Opinion with a similar but more visual effect."))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		NetworkingAPI.RegisterMessageType<SummonSpiritsBehaviour.SummonSpiritMessage>();
		LanguageAPI.Add("ITEM_INCREASEHEALING_PICKUP", "Invite friendly spirits when healed.");
		LanguageAPI.Add("ITEM_INCREASEHEALING_DESC", $"Store <style=cIsHealing>100%</style> <style=cStack>(+100% per stack)</style> of healing as <style=cIsHealing>Soul Energy</style>. After your <style=cIsHealing>Soul Energy</style> reaches 10% of your maximum health, <style=cIsHealing>invite a spirit</style> to heal for <style=cIsHealing>100%</style> of your <style=cIsHealing>Soul Energy</style> over <style=cIsHealing>{spiritDuration}s</style>.");
		ItemCounts.ctor += new Manipulator(ItemCounts_ctor);
	}

	private void ItemCounts_ctor(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
			(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1),
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "IncreaseHealing"),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCount"),
			(Instruction x) => ILPatternMatchingExt.MatchStfld<ItemCounts>(x, "increaseHealing")
		}))
		{
			val.RemoveRange(5);
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"RejuvRack.ItemCounts_ctor IL hook failed!");
		}
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/DLC1/LunarSun/LunarSunProjectileGhost.prefab", out var LunarSunProjectileGhost))
		{
			yield return LunarSunProjectileGhost;
		}
		SpiritPrefab = PrefabAPI.InstantiateClone(LunarSunProjectileGhost.Result, "HealingSpirit", false);
		ProjectileGhostController projectileGhostController = default(ProjectileGhostController);
		if (SpiritPrefab.TryGetComponent<ProjectileGhostController>(ref projectileGhostController))
		{
			Object.DestroyImmediate((Object)(object)projectileGhostController);
		}
		VFXAttributes vFXAttributes = default(VFXAttributes);
		if (SpiritPrefab.TryGetComponent<VFXAttributes>(ref vFXAttributes))
		{
			Object.DestroyImmediate((Object)(object)vFXAttributes);
		}
		SummonSpiritsBehaviour.SpiritController spiritController = SpiritPrefab.AddComponent<SummonSpiritsBehaviour.SpiritController>();
		if (!JohnHopooReturns.Behaviour.LoadAddressable<Texture>("RoR2/Base/Common/ColorRamps/texRampAntler.png", out var texRampAntler))
		{
			yield return texRampAntler;
		}
		if (!JohnHopooReturns.Behaviour.LoadAddressable<Texture>("RoR2/Base/Common/texCloudSkulls.png", out var texCloudSkulls))
		{
			yield return texCloudSkulls;
		}
		if (!JohnHopooReturns.Behaviour.LoadAddressable<Material>("RoR2/Base/ExplodeOnDeath/matWilloWispCore.mat", out var matWilloWispCore))
		{
			yield return matWilloWispCore;
		}
		if (!JohnHopooReturns.Behaviour.LoadAddressable<Texture>("RoR2/Base/Common/ColorRamps/texRampHealing.png", out var texRampHealing))
		{
			yield return texRampHealing;
		}
		ParticleSystemRenderer backdropRenderer = default(ParticleSystemRenderer);
		if (SpiritPrefab.transform.TryFind("mdlSunProjectile/Backdrop", out var backdrop) && ((Component)backdrop).TryGetComponent<ParticleSystemRenderer>(ref backdropRenderer))
		{
			((Renderer)backdropRenderer).sharedMaterial = new Material(((Renderer)backdropRenderer).sharedMaterial);
			((Renderer)backdropRenderer).sharedMaterial.SetTexture("_RemapTex", texRampAntler.Result);
			((Renderer)backdropRenderer).sharedMaterial.SetFloat("_AlphaBoost", 1.3f);
			((Renderer)backdropRenderer).sharedMaterial.SetFloat("_AlphaBias", 0.075f);
			((Renderer)backdropRenderer).sharedMaterial.SetTexture("_Cloud1Tex", texCloudSkulls.Result);
			backdrop.localScale = Vector3.one * 2f;
		}
		MeshRenderer billboardRenderer = default(MeshRenderer);
		if (SpiritPrefab.transform.TryFind("mdlSunProjectile/Quad", out var billboard) && ((Component)billboard).TryGetComponent<MeshRenderer>(ref billboardRenderer))
		{
			((Renderer)billboardRenderer).sharedMaterial = new Material(matWilloWispCore.Result);
			((Renderer)billboardRenderer).sharedMaterial.SetTexture("_RemapTex", texRampHealing.Result);
			((Renderer)billboardRenderer).sharedMaterial.SetFloat("_Boost", 3f);
			SetRandomScale setRandomScale = default(SetRandomScale);
			if (((Component)billboard).TryGetComponent<SetRandomScale>(ref setRandomScale))
			{
				setRandomScale.minimumScale = 0.5f;
				setRandomScale.maximumScale = 1f;
			}
		}
		ParticleSystem closeParticlesSystem = default(ParticleSystem);
		if (SpiritPrefab.transform.TryFind("Particles/CloseParticles", out var closeParticles) && ((Component)closeParticles).TryGetComponent<ParticleSystem>(ref closeParticlesSystem))
		{
			MainModule main2 = closeParticlesSystem.main;
			((MainModule)(ref main2)).startColor = new MinMaxGradient(Color.yellow, Color.green);
			spiritController.particles = closeParticlesSystem;
			main2 = default(MainModule);
		}
		ParticleSystem onSpawnPopParticleSystem = default(ParticleSystem);
		if (SpiritPrefab.transform.TryFind("Particles/OnSpawnPopParticle", out var onSpawnPopParticle) && ((Component)onSpawnPopParticle).TryGetComponent<ParticleSystem>(ref onSpawnPopParticleSystem))
		{
			MainModule main3 = onSpawnPopParticleSystem.main;
			((MainModule)(ref main3)).startColor = new MinMaxGradient(Color.yellow, Color.green);
			main3 = default(MainModule);
		}
		TrailRenderer trailRenderer = default(TrailRenderer);
		if (SpiritPrefab.transform.TryFind("Particles/Trail", out var trail) && ((Component)trail).TryGetComponent<TrailRenderer>(ref trailRenderer))
		{
			((Renderer)trailRenderer).sharedMaterial = new Material(((Renderer)trailRenderer).sharedMaterial);
			((Renderer)trailRenderer).sharedMaterial.SetTexture("_RemapTex", texRampAntler.Result);
			trailRenderer.time = 0.3f;
			spiritController.trail = trailRenderer;
		}
		ObjectScaleCurve objectScaleCurve = SpiritPrefab.AddComponent<ObjectScaleCurve>();
		objectScaleCurve.useOverallCurveOnly = true;
		objectScaleCurve.overallCurve = AnimationCurve.Linear(0f, 1f, 1f, 0f);
		objectScaleCurve.timeMax = 0.2f;
		((Behaviour)objectScaleCurve).enabled = false;
		DestroyOnTimer destroyOnTimer = SpiritPrefab.AddComponent<DestroyOnTimer>();
		destroyOnTimer.duration = 0.5f;
		((Behaviour)destroyOnTimer).enabled = false;
		SpiritPrefab.AddComponent<DitherModelFast>().renderers = SpiritPrefab.GetComponentsInChildren<Renderer>(false);
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/Base/ShockNearby/TeslaFieldBuffEffect.prefab", out var TeslaFieldBuffEffect))
		{
			yield return TeslaFieldBuffEffect;
		}
		SummonSpiritsEffect = PrefabAPI.InstantiateClone(TeslaFieldBuffEffect.Result, "SummonSpiritsEffect", false);
		Transform obj = SummonSpiritsEffect.transform.Find("VisualTransform/Rings");
		if (obj != null)
		{
			((Component)obj).gameObject.SetActive(false);
		}
		ParticleSystem randomParticlesSystem = default(ParticleSystem);
		if (SummonSpiritsEffect.transform.TryFind("VisualTransform/Random Particles", out var randomParticles) && ((Component)randomParticles).TryGetComponent<ParticleSystem>(ref randomParticlesSystem))
		{
			MainModule main4 = randomParticlesSystem.main;
			((MainModule)(ref main4)).startColor = new MinMaxGradient(Color.yellow, Color.green);
			main4 = default(MainModule);
		}
		ParticleSystem softGlowSystem = default(ParticleSystem);
		if (SummonSpiritsEffect.transform.TryFind("VisualTransform/SoftGlow", out var softGlow) && ((Component)softGlow).TryGetComponent<ParticleSystem>(ref softGlowSystem))
		{
			MainModule main = softGlowSystem.main;
			((MainModule)(ref main)).startColor = new MinMaxGradient(Color32.op_Implicit(new Color32((byte)110, byte.MaxValue, (byte)0, (byte)64)), Color32.op_Implicit(new Color32((byte)0, byte.MaxValue, (byte)0, (byte)60)));
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f, 1f);
			ParticleSystemRenderer softGlowRenderer = default(ParticleSystemRenderer);
			if (((Component)softGlow).TryGetComponent<ParticleSystemRenderer>(ref softGlowRenderer))
			{
				softGlowRenderer.maxParticleSize = 1f;
			}
			main = default(MainModule);
		}
		Light light = SummonSpiritsEffect.AddComponent<Light>();
		light.type = (LightType)2;
		light.color = Color32.op_Implicit(new Color32((byte)216, byte.MaxValue, (byte)0, byte.MaxValue));
		light.intensity = 1f;
		light.shadows = (LightShadows)0;
		if (!JohnHopooReturns.Behaviour.LoadAddressable<GameObject>("RoR2/DLC1/MushroomVoid/MushroomVoidEffect.prefab", out var MushroomVoidEffect))
		{
			yield return MushroomVoidEffect;
		}
		if (MushroomVoidEffect.Result.transform.TryFind("Visual/Crosses", out var crosses))
		{
			GameObject crossesInstance = Object.Instantiate<GameObject>(((Component)crosses).gameObject, SummonSpiritsEffect.transform.Find("VisualTransform"));
			SummonSpiritsEffect.AddComponent<DetachParticleOnDestroyAndEndEmission>().particleSystem = crossesInstance.GetComponent<ParticleSystem>();
		}
	}
}
public class RoseBuckler : JohnHopooReturns.Behaviour, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	private const string SECTION = "Common Rose Buckler";

	public sbyte armorBonus = JohnHopooReturns.Behaviour.Config.Value("Common Rose Buckler", "Armor Bonus Per Stack", (sbyte)10, (ConfigDescription)null);

	public void Awake()
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("Common Rose Buckler", string.Format("Enabled", "Common Rose Buckler"), defaultValue: true))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		LanguageAPI.Add("ITEM_SPRINTARMOR_DESC", $"<style=cIsHealing>Increase armor</style> by <style=cIsHealing>{armorBonus}</style> <style=cStack>(+{armorBonus} per stack)</style> <style=cIsUtility>while sprinting</style>.");
		CharacterBody.RecalculateStats += new Manipulator(CharacterBody_RecalculateStats);
	}

	private void CharacterBody_RecalculateStats(ILContext il)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		int locCountIndex = -1;
		int num = default(int);
		if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "SprintArmor"),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCount"),
			(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref locCountIndex)
		}) && val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[7]
		{
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_armor"),
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, locCountIndex),
			(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num),
			(Instruction x) => ILPatternMatchingExt.MatchMul(x),
			(Instruction x) => ILPatternMatchingExt.MatchConvR4(x),
			(Instruction x) => ILPatternMatchingExt.MatchAdd(x),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "set_armor")
		}))
		{
			val.Index += 2;
			val.Next.Operand = armorBonus;
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"RoseBuckler.CharacterBody_RecalculateStats IL hook failed!");
		}
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!JohnHopooReturns.Behaviour.LoadAddressable<ItemDef>("RoR2/Base/SprintArmor/SprintArmor.asset", out var SprintArmor))
		{
			yield return SprintArmor;
		}
		SprintArmor.Result.deprecatedTier = (ItemTier)0;
		AssetBundleRequest texBucklerIcon = JohnHopooReturns.Behaviour.Assets.LoadAssetAsync<Sprite>("texBucklerIcon");
		yield return texBucklerIcon;
		SprintArmor.Result.pickupIconSprite = (Sprite)texBucklerIcon.asset;
	}
}
public class Scythe : JohnHopooReturns.Behaviour
{
	public class HealOnCritOrb : Orb
	{
		public float healValue;

		public ProcChainMask procChainMask;

		public override void Begin()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0081: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)base.target))
			{
				((Orb)this).duration = 0.3f;
				float scale = (Object.op_Implicit((Object)(object)base.target.healthComponent) ? Mathf.Min(healValue / base.target.healthComponent.fullHealth, 1f) : 1f);
				EffectData val = new EffectData
				{
					scale = scale,
					origin = base.origin,
					genericFloat = ((Orb)this).duration
				};
				val.SetHurtBoxReference(base.target);
				EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/OrbEffects/HealthOrbEffect"), val, true);
			}
		}

		public override void OnArrival()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			HurtBox target = base.target;
			if (target != null)
			{
				HealthComponent healthComponent = target.healthComponent;
				if (healthComponent != null)
				{
					healthComponent.Heal(healValue, procChainMask, true);
				}
			}
		}
	}

	private const string SECTION = "New Harvesters Scythe Visuals";

	public void Awake()
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("New Harvesters Scythe Visuals", string.Format("Enabled", "New Harvesters Scythe Visuals"), defaultValue: true))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		GlobalEventManager.OnCrit += new Manipulator(GlobalEventManager_OnCrit);
		GlobalEventManager.OnHitEnemy += new hook_OnHitEnemy(GlobalEventManager_OnHitEnemy);
	}

	private void GlobalEventManager_OnCrit(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_005f: 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)
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "HealOnCrit"),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCount")
		}))
		{
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldc_I4_0);
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"Scythe.GlobalEventManager_OnCrit IL hook failed!");
		}
	}

	private void GlobalEventManager_OnHitEnemy(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
	{
		//IL_00cd: 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_00e3: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody val = default(CharacterBody);
		if (NetworkServer.active && !damageInfo.rejected && Object.op_Implicit((Object)(object)damageInfo.attacker) && damageInfo.crit && damageInfo.procCoefficient > 0f && !((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)8) && damageInfo.attacker.TryGetComponent<CharacterBody>(ref val) && Object.op_Implicit((Object)(object)val.inventory) && Object.op_Implicit((Object)(object)val.healthComponent))
		{
			int itemCount = val.inventory.GetItemCount(Items.HealOnCrit);
			if (itemCount > 0)
			{
				Util.PlaySound("Play_item_proc_crit_heal", damageInfo.attacker);
				HealOnCritOrb healOnCritOrb = new HealOnCritOrb();
				Vector3? obj;
				if (victim == null)
				{
					obj = null;
				}
				else
				{
					CharacterBody component = victim.GetComponent<CharacterBody>();
					obj = ((component != null) ? new Vector3?(component.corePosition) : null);
				}
				((Orb)healOnCritOrb).origin = (Vector3)(((??)obj) ?? val.corePosition);
				((Orb)healOnCritOrb).target = val.mainHurtBox;
				healOnCritOrb.healValue = (4f + 4f * (float)itemCount) * damageInfo.procCoefficient;
				healOnCritOrb.procChainMask = damageInfo.procChainMask;
				HealOnCritOrb healOnCritOrb2 = healOnCritOrb;
				((ProcChainMask)(ref healOnCritOrb2.procChainMask)).AddProc((ProcType)8);
				OrbManager.instance.AddOrb((Orb)(object)healOnCritOrb2);
			}
		}
		orig.Invoke(self, damageInfo, victim);
	}
}
public class Soulbound : JohnHopooReturns.Behaviour<Soulbound>, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	public class CatalystBehaviour : BaseItemBodyBehavior, IOnIncomingDamageServerReceiver, IOnTakeDamageServerReceiver
	{
		private float _health;

		private float _cooldownTimer;

		[ItemDefAssociation(useOnServer = true, useOnClient = true)]
		public static ItemDef GetItemDef()
		{
			return JohnHopooReturns.Behaviour<Soulbound>.Exists ? Items.Talisman : null;
		}

		public void Start()
		{
			_cooldownTimer = ((BaseItemBodyBehavior)this).body.equipmentSlot.cooldownTimer;
		}

		public void OnEnable()
		{
			((BaseItemBodyBehavior)this).body.healthComponent.AddIncomingDamageReceiver((IOnIncomingDamageServerReceiver)(object)this);
			((BaseItemBodyBehavior)this).body.healthComponent.AddTakeDamageReceiver((IOnTakeDamageServerReceiver)(object)this);
		}

		public void OnDisable()
		{
			((BaseItemBodyBehavior)this).body.healthComponent.RemoveIncomingDamageReceiver((IOnIncomingDamageServerReceiver)(object)this);
			((BaseItemBodyBehavior)this).body.healthComponent.RemoveTakeDamageReceiver((IOnTakeDamageServerReceiver)(object)this);
		}

		public void FixedUpdate()
		{
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)((BaseItemBodyBehavior)this).body.equipmentSlot))
			{
				return;
			}
			if (_cooldownTimer - ((BaseItemBodyBehavior)this).body.equipmentSlot.cooldownTimer >= 0.5f)
			{
				Util.PlaySound(JohnHopooReturns.Behaviour<Soulbound>.Instance.sound, ((Component)this).gameObject);
				if (((BaseItemBodyBehavior)this).body.equipmentSlot.stock <= 0)
				{
					HUD val = ((IEnumerable<HUD>)HUD.readOnlyInstanceList).FirstOrDefault((Func<HUD, bool>)((HUD x) => (Object)(object)x.targetBodyObject == (Object)(object)((Component)this).gameObject));
					EquipmentIcon[] equipmentIcons = val.equipmentIcons;
					Image val4 = default(Image);
					AnimateUIAlpha val5 = default(AnimateUIAlpha);
					foreach (EquipmentIcon val2 in equipmentIcons)
					{
						if (!val2.displayAlternateEquipment && Object.op_Implicit((Object)(object)val2.reminderFlashPanelObject) && !((DisplayData)(ref val2.currentDisplayData)).isReady)
						{
							GameObject val3 = Object.Instantiate<GameObject>(val2.reminderFlashPanelObject, val2.reminderFlashPanelObject.transform.parent);
							if (val3.TryGetComponent<Image>(ref val4))
							{
								((Graphic)val4).color = JohnHopooReturns.Behaviour<Soulbound>.Instance.flashColor;
							}
							if (val3.TryGetComponent<AnimateUIAlpha>(ref val5))
							{
								val5.time = 0f;
								val5.destroyOnEnd = true;
							}
							val3.SetActive(true);
						}
					}
				}
			}
			_cooldownTimer = ((BaseItemBodyBehavior)this).body.equipmentSlot.cooldownTimer;
		}

		public void OnIncomingDamageServer(DamageInfo damageInfo)
		{
			_health = ((BaseItemBodyBehavior)this).body.healthComponent.health;
		}

		public void OnTakeDamageServer(DamageReport damageReport)
		{
			//IL_003e: 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)
			float num = _health - ((BaseItemBodyBehavior)this).body.healthComponent.health;
			if (num > 0f && Object.op_Implicit((Object)(object)((BaseItemBodyBehavior)this).body.inventory) && Object.op_Implicit((Object)(object)((BaseItemBodyBehavior)this).body.inventory.currentEquipmentState.equipmentDef))
			{
				float num2 = ((BaseItemBodyBehavior)this).body.inventory.currentEquipmentState.equipmentDef.cooldown * ((BaseItemBodyBehavior)this).body.inventory.CalculateEquipmentCooldownScale();
				float num3 = Util.StackScaling(JohnHopooReturns.Behaviour<Soulbound>.Instance.baseConversionRate, JohnHopooReturns.Behaviour<Soulbound>.Instance.stackConversionRate, base.stack);
				((BaseItemBodyBehavior)this).body.inventory.DeductActiveEquipmentCooldown(num3 * num2 * num / ((BaseItemBodyBehavior)this).body.healthComponent.fullHealth);
			}
		}
	}

	private const string SECTION = "Soulbound Catalyst Rework";

	public float baseConversionRate = JohnHopooReturns.Behaviour.Config.Value("Soulbound Catalyst Rework", "Base Conversion Rate", 1f);

	public float stackConversionRate = JohnHopooReturns.Behaviour.Config.Value("Soulbound Catalyst Rework", "Conversion Rate Per Stack", 0.2f);

	public string sound = JohnHopooReturns.Behaviour.Config.Value("Soulbound Catalyst Rework", "Proc Sound", "Play_item_proc_ghostOnKill");

	public Color flashColor = JohnHopooReturns.Behaviour.Config.Value<Color>("Soulbound Catalyst Rework", "Equipment Icon Flash Color", Color32.op_Implicit(new Color32((byte)170, byte.MaxValue, (byte)235, byte.MaxValue)));

	public void Awake()
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Expected O, but got Unknown
		if (!JohnHopooReturns.Behaviour.Config.Value("Soulbound Catalyst Rework", string.Format("Enabled", "Soulbound Catalyst Rework"), defaultValue: true, "Soulbound Catalyst converts damage taken into equipment charge. Also reduces Forgive Me Please cooldown to 30s."))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		LanguageAPI.Add("ITEM_TALISMAN_PICKUP", "Losing health reduces equipment cooldown.");
		LanguageAPI.Add("ITEM_TALISMAN_DESC", $"<style=cIsUtility>Reduce equipment cooldown</style> on taking damage by <style=cIsUtility>{baseConversionRate:0%}</style> <style=cStack>(+{stackConversionRate:0%} per stack)</style> of the <style=cIsHealth>maximum health percentage you lost</style>.");
		GlobalEventManager.OnCharacterDeath += new Manipulator(GlobalEventManager_OnCharacterDeath);
	}

	private void GlobalEventManager_OnCharacterDeath(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_005f: 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)
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "Talisman"),
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCount")
		}))
		{
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldc_I4_0);
		}
		else
		{
			JohnHopooReturns.Behaviour.Logger.LogError((object)"Soulbound.GlobalEventManager_OnCharacterDeath IL hook failed!");
		}
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		if (!JohnHopooReturns.Behaviour.LoadAddressable<ItemDef>("RoR2/Base/Talisman/Talisman.asset", out var Talisman))
		{
			yield return Talisman;
		}
		Talisman.Result.tags = (ItemTag[])(object)new ItemTag[2]
		{
			(ItemTag)3,
			(ItemTag)7
		};
		if (!JohnHopooReturns.Behaviour.LoadAddressable<EquipmentDef>("RoR2/Base/DeathProjectile/DeathProjectile.asset", out var DeathProjectile))
		{
			yield return DeathProjectile;
		}
		DeathProjectile.Result.cooldown = 30f;
	}
}
public class SpareDroneParts : JohnHopooReturns.Behaviour<SpareDroneParts>, JohnHopooReturns.IOnLoadStaticContentAsyncProvider
{
	public delegate void ModifyIdrCallback(ref ItemDisplayRule idr);

	private const string SECTION = "Spare Drone Parts";

	public int chainGunBounces = JohnHopooReturns.Behaviour.Config.Value("Spare Drone Parts", "Chain Gun Bounces", 0);

	public float chainGunDuration = JohnHopooReturns.Behaviour.Config.Value("Spare Drone Parts", "Chain Gun Base Duration", 0.15f);

	public bool updatedItemDisplays = JohnHopooReturns.Behaviour.Config.Value("Spare Drone Parts", "Updated Item Displays", defaultValue: true);

	public void Awake()
	{
		if (!JohnHopooReturns.Behaviour.Config.Value("Spare Drone Parts", string.Format("Enabled", "Spare Drone Parts"), defaultValue: true))
		{
			Object.Destroy((Object)(object)this);
		}
		else
		{
			LanguageAPI.Add("ITEM_DRONEWEAPONS_DESC", "Gain <style=cIsDamage>Col. Droneman</style>. \nDrones gain <style=cIsDamage>+50%</style> <style=cStack>(+50% per stack)</style> attack speed and cooldown reduction. \nDrones gain <style=cIsDamage>10%</style> chance to fire a <style=cIsDamage>missile</style> on hit, dealing <style=cIsDamage>300%</style> TOTAL damage. \nDrones gain an <style=cIsDamage>a