Decompiled source of Crimson Moons Semblance v1.0.6

BepInEx/plugins/Crimson_Moons_Semblance/CrimsonMoonsSemblance.dll

Decompiled 3 weeks 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 CrimsonMoonsSemblance;
using CrimsonMoonsSemblance.NetcodePatcher;
using CrimsonMoonsSemblance.Scripts;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.VFX;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CrimsonMoonsSemblance")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CrimsonMoonsSemblance")]
[assembly: AssemblyTitle("CrimsonMoonsSemblance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[HarmonyPatch(typeof(HUDManager))]
internal class HudManagerPatch
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(HUDManager), "Update")]
	public static void Update()
	{
		try
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (localPlayerController.currentItemSlot < 0 || localPlayerController.currentItemSlot >= localPlayerController.ItemSlots.Length)
			{
				Plugin.meterContainer.SetActive(false);
			}
			else if ((Object)(object)localPlayerController.ItemSlots[localPlayerController.currentItemSlot] != (Object)null)
			{
				if (localPlayerController.ItemSlots[localPlayerController.currentItemSlot].itemProperties.itemName == "Crimson Moon's Semblance")
				{
					float num = ((Component)localPlayerController).GetComponent<CMS_PlayerScript>().BondOfLife;
					Plugin.meterContainer.SetActive(true);
					Plugin.meter.GetComponent<Image>().fillMethod = (FillMethod)0;
					Plugin.meter.GetComponent<Image>().fillAmount = num / 100f;
				}
				else
				{
					Plugin.meterContainer.SetActive(false);
				}
			}
			else
			{
				Plugin.meterContainer.SetActive(false);
			}
		}
		catch
		{
		}
	}
}
namespace CrimsonMoonsSemblance
{
	public class CSMInput : LcInputActions
	{
		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction SkillKey { get; set; }

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction BurstKey { get; set; }
	}
	[BepInPlugin("Entity378.CrimsonMoonsSemblance", "CrimsonMoonsSemblance", "1.0.6")]
	[BepInDependency("evaisa.lethallib", "0.14.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony harmony = new Harmony("Entity378.CrimsonMoonsSemblance");

		private const string GUID = "Entity378.CrimsonMoonsSemblance";

		private const string NAME = "CrimsonMoonsSemblance";

		private const string VERSION = "1.0.6";

		public static string assetsDir;

		public static AssetBundle bundle;

		public static GameObject CrimsonMoonsSemblanceMarkPrefab;

		public static Item CrimsonMoonsSemblanceItem;

		public static GameObject meterContainer;

		public static GameObject meter;

		public static GameObject frame;

		public static GameObject warningL;

		public static GameObject warningR;

		public static CSMInput InputActionsInstance = new CSMInput();

		private void Awake()
		{
			assetsDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "crimsonmoonssemblance");
			bundle = AssetBundle.LoadFromFile(assetsDir);
			AudioClip crimsonMoonsSemblanceSwingSFX = bundle.LoadAsset<AudioClip>("Assets/LethalCompany/CMS/ShovelSwing.ogg");
			AudioClip crimsonMoonsSemblanceReelUpSFX = bundle.LoadAsset<AudioClip>("Assets/LethalCompany/CMS/ShovelReelUp.ogg");
			AudioClip[] crimsonMoonsSemblanceHitSFX = (AudioClip[])(object)new AudioClip[2]
			{
				bundle.LoadAsset<AudioClip>("Assets/LethalCompany/CMS/ShovelHitDefault.ogg"),
				bundle.LoadAsset<AudioClip>("Assets/LethalCompany/CMS/ShovelHitDefault2.ogg")
			};
			CrimsonMoonsSemblanceItem = bundle.LoadAsset<Item>("Assets/LethalCompany/CMS/CrimsonMoonsSemblanceItem.asset");
			CrimsonMoonsSemblanceMarkPrefab = bundle.LoadAsset<GameObject>("Assets/LethalCompany/CMS/CrimsonMoonsSemblanceMark.prefab");
			CMS_WeaponScript cMS_WeaponScript = CrimsonMoonsSemblanceItem.spawnPrefab.AddComponent<CMS_WeaponScript>();
			CrimsonMoonsSemblanceMarkPrefab.AddComponent<CMS_EnemyMarkScript>();
			((GrabbableObject)cMS_WeaponScript).itemProperties = CrimsonMoonsSemblanceItem;
			cMS_WeaponScript.crimsonMoonsSemblanceSwingSFX = crimsonMoonsSemblanceSwingSFX;
			cMS_WeaponScript.crimsonMoonsSemblanceReelUpSFX = crimsonMoonsSemblanceReelUpSFX;
			cMS_WeaponScript.crimsonMoonsSemblanceHitSFX = crimsonMoonsSemblanceHitSFX;
			NetworkPrefabs.RegisterNetworkPrefab(CrimsonMoonsSemblanceItem.spawnPrefab);
			Utilities.FixMixerGroups(CrimsonMoonsSemblanceItem.spawnPrefab);
			Items.RegisterScrap(CrimsonMoonsSemblanceItem, 10, (LevelTypes)(-1));
			Items.RegisterShopItem(CrimsonMoonsSemblanceItem, 378);
			harmony.PatchAll();
			SceneManager.sceneLoaded += OnSceneRelayLoaded;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CMS: Loaded!");
		}

		private void OnSceneRelayLoaded(Scene scene, LoadSceneMode loadMode)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			if (((Scene)(ref scene)).name == "SampleSceneRelay")
			{
				GameObject val = GameObject.Find("IngamePlayerHUD");
				meterContainer = new GameObject("BondOfLifeMeterContainer");
				meterContainer.AddComponent<CanvasGroup>();
				RectTransform val2 = meterContainer.AddComponent<RectTransform>();
				((Transform)val2).parent = val.transform;
				((Transform)val2).localScale = Vector3.one;
				val2.anchoredPosition = Vector2.zero;
				((Transform)val2).localPosition = Vector2.op_Implicit(new Vector2(0f, -235f));
				val2.sizeDelta = Vector2.one;
				meter = AddImageToHUD("BoL-MeterFull", scene);
				frame = AddImageToHUD("BoL-MeterEmpty", scene);
				warningL = AddImageToHUD("BoL-Icon", scene);
				warningR = AddImageToHUD("BoL-Icon", scene);
				GameObject[] array = (GameObject[])(object)new GameObject[4] { meter, frame, warningL, warningR };
				GameObject[] array2 = array;
				foreach (GameObject val3 in array2)
				{
					val3.transform.parent = meterContainer.transform;
					val3.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
				}
				meter.GetComponent<Image>().type = (Type)3;
				meter.GetComponent<Image>().fillMethod = (FillMethod)1;
				Transform transform = warningL.transform;
				transform.localPosition += new Vector3(-115f, 0f);
				Transform transform2 = warningR.transform;
				transform2.localPosition += new Vector3(115f, 0f);
			}
		}

		private GameObject AddImageToHUD(string imageName, Scene scene)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			Sprite val = bundle.LoadAsset<Sprite>("Assets/LethalCompany/CMS/" + imageName + ".png");
			GameObject val2 = new GameObject(imageName);
			SceneManager.MoveGameObjectToScene(val2, scene);
			GameObject val3 = GameObject.Find("IngamePlayerHUD");
			RectTransform val4 = val2.AddComponent<RectTransform>();
			((Transform)val4).parent = val3.transform;
			((Transform)val4).localScale = Vector2.op_Implicit(Vector2.one);
			val4.anchoredPosition = Vector2.zero;
			((Transform)val4).localPosition = Vector2.op_Implicit(Vector2.zero);
			Rect rect = val.rect;
			float num = ((Rect)(ref rect)).width / 2.5f;
			rect = val.rect;
			val4.sizeDelta = new Vector2(num, ((Rect)(ref rect)).height / 2.5f);
			Image val5 = val2.AddComponent<Image>();
			val5.sprite = val;
			CanvasRenderer val6 = val2.AddComponent<CanvasRenderer>();
			return val2;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CrimsonMoonsSemblance";

		public const string PLUGIN_NAME = "CrimsonMoonsSemblance";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace CrimsonMoonsSemblance.Scripts
{
	internal class CMS_EnemyDeathScript : MonoBehaviour
	{
		public bool hasToDie = true;
	}
	internal class CMS_EnemyMarkScript : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <MarkDuration>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject gameObject;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(30f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					try
					{
						Object.Destroy((Object)(object)gameObject);
					}
					catch
					{
						Debug.Log((object)"CMS: The mark has already been removed");
					}
					return false;
				}
			}

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

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

		public bool AlreadyStarted = true;

		public bool RemoveMark = false;

		private Transform iconTransform;

		private void Start()
		{
			iconTransform = ((Component)this).transform.Find("CrimsonMoonsSemblanceMarkIcon");
			((MonoBehaviour)this).StartCoroutine(MarkDuration(((Component)this).gameObject));
		}

		private void Update()
		{
			if (RemoveMark)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void LateUpdate()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)iconTransform != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				iconTransform.LookAt(((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.position);
			}
		}

		[IteratorStateMachine(typeof(<MarkDuration>d__6))]
		private static IEnumerator MarkDuration(GameObject gameObject)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <MarkDuration>d__6(0)
			{
				gameObject = gameObject
			};
		}
	}
	internal class CMS_PlayerScript : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <ActivateEmeberfireGrace>d__37 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CMS_PlayerScript <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (!<>4__this.EmberfireGraceUsed)
					{
						Debug.Log((object)"CMS: Emberfire immortality effect has been activated");
						<>4__this.EmberfireGraceUsed = true;
						<>4__this.BondOfLife = 40;
						<>4__this.Player.health = 60;
						HUDManager.Instance.selfRedCanvasGroup.alpha = (float)(100 - <>4__this.Player.health) / 100f;
						if (((NetworkBehaviour)<>4__this.Player).IsServer)
						{
							<>4__this.Player.DamagePlayerClientRpc(0, <>4__this.Player.health);
						}
						else
						{
							<>4__this.Player.DamagePlayerServerRpc(0, <>4__this.Player.health);
						}
						<>2__current = (object)new WaitForSeconds(3f);
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					<>4__this.EmberfireGraceUsed = false;
					Debug.Log((object)"CMS: Emberfire immortality effect has been disabled");
					<>4__this.EmebrefireCheck();
					<>4__this.UpdateDMG();
					break;
				}
				return false;
			}

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

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

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

			private object <>2__current;

			public CMS_PlayerScript <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					<>4__this.AddUltProgress(<>4__this.BurstPassiveEnergyGainValue);
					break;
				}
				if (<>4__this.BurstPassiveEnergyGainStatus)
				{
					<>2__current = (object)new WaitForSeconds((float)<>4__this.BurstPassiveEnergyGainIntervall);
					<>1__state = 1;
					return true;
				}
				return false;
			}

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

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

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

			private object <>2__current;

			public CMS_PlayerScript <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Expected O, but got Unknown
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					<>4__this.CurrentBurstCooldown--;
				}
				else
				{
					<>1__state = -1;
					if (!((NetworkBehaviour)<>4__this.Player).IsOwner)
					{
						goto IL_00e8;
					}
					<>4__this.BurstOffCooldown = false;
					<>4__this.ResetSkillCooldown = true;
					<>4__this.CanMark = true;
					<>4__this.BurstEnergy = 0;
					<>4__this.CurrentBurstCooldown = <>4__this.BurstCooldown;
				}
				if (<>4__this.CurrentBurstCooldown > 0)
				{
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				}
				<>4__this.BurstOffCooldown = true;
				<>4__this.ResetSkillCooldown = false;
				goto IL_00e8;
				IL_00e8:
				return false;
			}

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

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

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

			private object <>2__current;

			public CMS_PlayerScript <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Expected O, but got Unknown
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					<>4__this.CurrentSkillCooldown--;
				}
				else
				{
					<>1__state = -1;
					if (!((NetworkBehaviour)<>4__this.Player).IsOwner)
					{
						goto IL_00c6;
					}
					<>4__this.CanMark = false;
					<>4__this.CurrentSkillCooldown = <>4__this.SkillCooldown;
				}
				if (<>4__this.CurrentSkillCooldown > 0 && !<>4__this.ResetSkillCooldown)
				{
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				}
				<>4__this.CanMark = true;
				goto IL_00c6;
				IL_00c6:
				return false;
			}

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

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

		public int BondOfLife = 0;

		public int BurstEnergy = 0;

		public bool CanMark = true;

		public bool BurstOffCooldown = true;

		public bool ResetSkillCooldown = false;

		public bool EmberfireGrace = false;

		public bool EmberfireGraceUsed = false;

		public int CurrentSkillCooldown = 0;

		public int CurrentBurstCooldown = 0;

		public float SkillRange = 7.5f;

		public float BurstRange = 10f;

		public int BondOfLifeIncrease = 20;

		public int BondOfLifeDecrease = 10;

		public int SkillCooldown = 30;

		public int BurstCooldown = 15;

		public int BurstHitEnergyGain = 12;

		public bool BurstPassiveEnergyGainStatus = false;

		public int BurstPassiveEnergyGainValue = 1;

		public int BurstPassiveEnergyGainIntervall = 21;

		public string SkillKey;

		public string BurstKey;

		private PlayerControllerB Player;

		private void Start()
		{
			Player = ((Component)this).GetComponent<PlayerControllerB>();
			SetInputString();
		}

		private void Update()
		{
			UpdateHUD();
		}

		public void AddBondOfLife(int bondOfLifeIncrease)
		{
			BondOfLife = Mathf.Clamp(BondOfLife + bondOfLifeIncrease, 0, 100);
			Debug.Log((object)("CMS: Applying Bond Of Life, Current Bond Of Life = " + BondOfLife));
			BondDamage(bondOfLifeIncrease);
			UpdateDMG();
		}

		public void RemoveBondOfLife(int bondOfLifeDecrease)
		{
			BondOfLife = Mathf.Clamp(BondOfLife - bondOfLifeDecrease, 0, 100);
			Debug.Log((object)("CMS: Removing Bond Of Life, Current Bond Of Life = " + BondOfLife));
			BondHeal(bondOfLifeDecrease);
			UpdateDMG();
		}

		public void BondDamage(int dmg)
		{
			Player.health = Mathf.Clamp(Player.health - dmg, 1, 100);
			Debug.Log((object)("CMS: Player Health = " + Player.health));
			HUDManager.Instance.selfRedCanvasGroup.alpha = (float)(100 - Player.health) / 100f;
			if (((NetworkBehaviour)Player).IsServer)
			{
				Player.DamagePlayerClientRpc(0, Player.health);
			}
			else
			{
				Player.DamagePlayerServerRpc(0, Player.health);
			}
		}

		public void BondHeal(int heal)
		{
			Player.health = Mathf.Clamp(Player.health + heal, 1, 100);
			Debug.Log((object)("CMS: Player Health = " + Player.health));
			HUDManager.Instance.selfRedCanvasGroup.alpha = (float)(100 - Player.health) / 100f;
			if (((NetworkBehaviour)Player).IsServer)
			{
				Player.DamagePlayerClientRpc(0, Player.health);
			}
			else
			{
				Player.DamagePlayerServerRpc(0, Player.health);
			}
		}

		public void AddUltProgress(int ultGain)
		{
			BurstEnergy = Mathf.Clamp(BurstEnergy + ultGain, 0, 100);
			if (BurstEnergy == 100)
			{
				BurstOffCooldown = true;
			}
			Debug.Log((object)("CMS: Balemoon Rising Energy = " + BurstEnergy));
		}

		public void UltHeal()
		{
			Player.health = (int)Mathf.Clamp((float)Player.health + (float)BondOfLife * 1.5f, 1f, 100f);
			BondOfLife = 0;
			Debug.Log((object)("CMS: Removing Bond Of Life, Current Bond Of Life = " + BondOfLife));
			Debug.Log((object)("CMS: Player Health = " + Player.health));
			HUDManager.Instance.selfRedCanvasGroup.alpha = (float)(100 - Player.health) / 100f;
			if (((NetworkBehaviour)this).IsServer)
			{
				Player.DamagePlayerClientRpc(0, Player.health);
				BondOfLifeResetClientRpc(Player.playerClientId, BondOfLife);
			}
			else
			{
				Player.DamagePlayerServerRpc(0, Player.health);
				BondOfLifeResetServerRpc();
			}
			UpdateDMG();
		}

		[ServerRpc]
		private void BondOfLifeResetServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1295584646u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1295584646u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				BondOfLifeResetClientRpc(Player.playerClientId, BondOfLife);
			}
		}

		[ClientRpc]
		private void BondOfLifeResetClientRpc(ulong playerClientId, int bondValue)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(267510483u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerClientId);
				BytePacker.WriteValueBitPacked(val2, bondValue);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 267510483u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects;
			foreach (GameObject val3 in allPlayerObjects)
			{
				PlayerControllerB component = val3.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && component.playerClientId == playerClientId && (Object)(object)val3.GetComponent<CMS_PlayerScript>() != (Object)null)
				{
					val3.GetComponent<CMS_PlayerScript>().BondOfLife = bondValue;
				}
			}
		}

		public void EmebrefireCheck()
		{
			if (EmberfireGraceUsed)
			{
				Debug.Log((object)"CMS: Emberfire immortality effect is active");
			}
			else if (BondOfLife == 100)
			{
				EmberfireGrace = true;
				Debug.Log((object)"CMS: Emberfire is active");
			}
			else
			{
				EmberfireGrace = false;
				Debug.Log((object)"CMS: Emberfire is not active");
			}
		}

		public void UpdateDMG()
		{
			if (Player.currentItemSlot >= 0 && Player.currentItemSlot < Player.ItemSlots.Length && (Object)(object)Player.ItemSlots[Player.currentItemSlot] != (Object)null)
			{
				Item itemProperties = Player.ItemSlots[Player.currentItemSlot].itemProperties;
				if (itemProperties.itemName == "Crimson Moon's Semblance")
				{
					Shovel component = ((Component)Player.ItemSlots[Player.currentItemSlot]).GetComponent<Shovel>();
					component.shovelHitForce = BondOfLife / 10 + 1;
					Debug.Log((object)("CMS: Weapon DMG = " + component.shovelHitForce));
					EmebrefireCheck();
				}
			}
		}

		public void UpdateHUD()
		{
			if (Player.currentItemSlot < 0 || Player.currentItemSlot >= Player.ItemSlots.Length || !((NetworkBehaviour)Player).IsOwner || !((Object)(object)Player.ItemSlots[Player.currentItemSlot] != (Object)null))
			{
				return;
			}
			Item itemProperties = Player.ItemSlots[Player.currentItemSlot].itemProperties;
			if (itemProperties.itemName == "Crimson Moon's Semblance")
			{
				SetInputString();
				itemProperties.toolTips[0] = "All Is Ash: [" + SkillKey + "]";
				if (CurrentSkillCooldown != 0)
				{
					itemProperties.toolTips[1] = "[" + SkillKey + "] Cooldown : " + CurrentSkillCooldown;
					HUDManager.Instance.ChangeControlTipMultiple(itemProperties.toolTips, false, itemProperties);
				}
				else
				{
					itemProperties.toolTips[1] = "[" + SkillKey + "] Cooldown : Ready";
					HUDManager.Instance.ChangeControlTipMultiple(itemProperties.toolTips, false, itemProperties);
				}
				itemProperties.toolTips[2] = "Balemoon Rising: [" + BurstKey + "]";
				if (CurrentBurstCooldown != 0)
				{
					itemProperties.toolTips[3] = "[" + BurstKey + "] Cooldown : " + CurrentBurstCooldown;
					HUDManager.Instance.ChangeControlTipMultiple(itemProperties.toolTips, false, itemProperties);
				}
				else if (BurstEnergy != 100)
				{
					itemProperties.toolTips[3] = "[" + BurstKey + "] Energy : " + BurstEnergy + "% (Not Ready)";
					HUDManager.Instance.ChangeControlTipMultiple(itemProperties.toolTips, false, itemProperties);
				}
				else
				{
					itemProperties.toolTips[3] = "[" + BurstKey + "] Energy : " + BurstEnergy + "% (Ready)";
					HUDManager.Instance.ChangeControlTipMultiple(itemProperties.toolTips, false, itemProperties);
				}
			}
		}

		public void SetInputString()
		{
			SkillKey = InputActionRebindingExtensions.GetBindingDisplayString(Plugin.InputActionsInstance.SkillKey, (DisplayStringOptions)0, (string)null);
			BurstKey = InputActionRebindingExtensions.GetBindingDisplayString(Plugin.InputActionsInstance.BurstKey, (DisplayStringOptions)0, (string)null);
			SkillKey = SkillKey.Substring(0, SkillKey.IndexOf(" |"));
			BurstKey = BurstKey.Substring(0, BurstKey.IndexOf(" |"));
		}

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

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

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

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

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1295584646u, new RpcReceiveHandler(__rpc_handler_1295584646), "BondOfLifeResetServerRpc");
			((NetworkBehaviour)this).__registerRpc(267510483u, new RpcReceiveHandler(__rpc_handler_267510483), "BondOfLifeResetClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1295584646(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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)
			//IL_008c: 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_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CMS_PlayerScript)(object)target).BondOfLifeResetServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_267510483(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerClientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId);
				int bondValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref bondValue);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CMS_PlayerScript)(object)target).BondOfLifeResetClientRpc(playerClientId, bondValue);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "CMS_PlayerScript";
		}
	}
	internal class CMS_WeaponScript : Shovel
	{
		public List<EnemyAI> enemyList = new List<EnemyAI>();

		public AudioClip[] crimsonMoonsSemblanceHitSFX;

		public AudioClip crimsonMoonsSemblanceSwingSFX;

		public AudioClip crimsonMoonsSemblanceReelUpSFX;

		public VisualEffect vfx;

		public override void Start()
		{
			((GrabbableObject)this).isInFactory = true;
			((GrabbableObject)this).grabbable = true;
			((GrabbableObject)this).grabbableToEnemies = false;
			((GrabbableObject)this).mainObjectRenderer = ((Component)this).GetComponent<MeshRenderer>();
			base.shovelAudio = ((Component)this).GetComponent<AudioSource>();
			base.shovelHitForce = 1;
			base.reelUp = crimsonMoonsSemblanceReelUpSFX;
			base.swing = crimsonMoonsSemblanceSwingSFX;
			base.hitSFX = crimsonMoonsSemblanceHitSFX;
			vfx = ((Component)this).GetComponentInChildren<VisualEffect>();
			((GrabbableObject)this).Start();
		}

		public override void SetControlTipsForItem()
		{
			HUDManager.Instance.ChangeControlTipMultiple(((GrabbableObject)this).itemProperties.toolTips, false, ((GrabbableObject)this).itemProperties);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((Shovel)this).ItemActivate(used, buttonDown);
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			SetVFXEnabled(enabled: true);
		}

		public override void PocketItem()
		{
			SetVFXEnabled(enabled: false);
			((GrabbableObject)this).PocketItem();
		}

		private void SetVFXEnabled(bool enabled)
		{
			VisualEffect[] componentsInChildren = ((Component)this).GetComponentsInChildren<VisualEffect>();
			foreach (VisualEffect val in componentsInChildren)
			{
				GameObject gameObject = ((Component)val).gameObject;
				if (!gameObject.CompareTag("DoNotSet") && !gameObject.CompareTag("InteractTrigger"))
				{
					((Behaviour)val).enabled = enabled;
				}
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			CMS_PlayerScript component = ((Component)((GrabbableObject)this).playerHeldBy).GetComponent<CMS_PlayerScript>();
			component.BondDamage(component.BondOfLife);
			base.shovelHitForce = component.BondOfLife / 10 + 1;
			component.EmebrefireCheck();
			component.BurstPassiveEnergyGainStatus = true;
			((MonoBehaviour)this).StartCoroutine(component.PassiveUltGain());
		}

		public override void DiscardItem()
		{
			CMS_PlayerScript component = ((Component)((GrabbableObject)this).playerHeldBy).GetComponent<CMS_PlayerScript>();
			component.BondHeal(component.BondOfLife);
			component.BurstPassiveEnergyGainStatus = false;
			base.shovelHitForce = 1;
			component.EmebrefireCheck();
			((Shovel)this).DiscardItem();
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && !((GrabbableObject)this).isPocketed)
			{
				CMS_PlayerScript component = ((Component)((GrabbableObject)this).playerHeldBy).GetComponent<CMS_PlayerScript>();
				vfx.SetFloat("BondValue", (float)component.BondOfLife / 10f);
				if (component.EmberfireGrace)
				{
					vfx.SetBool("EmberFire", true);
				}
				else
				{
					vfx.SetBool("EmberFire", false);
				}
				if (!((GrabbableObject)this).playerHeldBy.isGrabbingObjectAnimation && !((GrabbableObject)this).playerHeldBy.isTypingChat && !((GrabbableObject)this).playerHeldBy.inTerminalMenu && !((GrabbableObject)this).playerHeldBy.inSpecialInteractAnimation && (Object)(object)((GrabbableObject)this).playerHeldBy.hoveringOverTrigger == (Object)null)
				{
					SetupKeyCallbacks();
					return;
				}
			}
			else
			{
				vfx.SetFloat("BondValue", 0f);
				vfx.SetBool("EmberFire", false);
			}
			StopKeyCallbacks();
		}

		public void SetupKeyCallbacks()
		{
			Plugin.InputActionsInstance.SkillKey.performed += UseSkill;
			Plugin.InputActionsInstance.BurstKey.performed += UseBurst;
		}

		public void StopKeyCallbacks()
		{
			Plugin.InputActionsInstance.SkillKey.performed -= UseSkill;
			Plugin.InputActionsInstance.BurstKey.performed -= UseBurst;
		}

		public void UseSkill(CallbackContext SkillContext)
		{
			if (((CallbackContext)(ref SkillContext)).performed && !((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null))
			{
				CMS_PlayerScript component = ((Component)((GrabbableObject)this).playerHeldBy).GetComponent<CMS_PlayerScript>();
				if (component.CanMark)
				{
					HandleAOEAttack(component.SkillRange, 0, -2, "All Is Ash");
					((MonoBehaviour)this).StartCoroutine(component.StartCooldownSkill());
				}
			}
		}

		public void UseBurst(CallbackContext BurstContext)
		{
			if (((CallbackContext)(ref BurstContext)).performed && !((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null))
			{
				CMS_PlayerScript component = ((Component)((GrabbableObject)this).playerHeldBy).GetComponent<CMS_PlayerScript>();
				if (component.BurstOffCooldown && component.BurstEnergy == 100)
				{
					HandleAOEAttack(component.BurstRange, 1, -3, "Balemoon Rising");
					component.UltHeal();
					((MonoBehaviour)this).StartCoroutine(component.StartCooldownBurst());
				}
			}
		}

		private void HandleAOEAttack(float range, int hitForce, int hitID, string attackName)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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)
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, range);
			foreach (Collider val in array)
			{
				EnemyAI componentInParent = ((Component)val).gameObject.GetComponentInParent<EnemyAI>();
				if ((Object)(object)componentInParent != (Object)null && !componentInParent.isEnemyDead && !enemyList.Contains(componentInParent))
				{
					enemyList.Add(componentInParent);
					Debug.Log((object)("CMS: Enemy " + ((Object)componentInParent).name + " has been hit with " + attackName + "!"));
					componentInParent.HitEnemyOnLocalClient(hitForce, default(Vector3), ((GrabbableObject)this).playerHeldBy, true, hitID);
				}
			}
			enemyList.Clear();
		}

		protected override void __initializeVariables()
		{
			((Shovel)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			((Shovel)this).__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "CMS_WeaponScript";
		}
	}
}
namespace CrimsonMoonsSemblance.Patch
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		[CompilerGenerated]
		private sealed class <MoveBody>d__9 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EnemyAI enemy;

			public float delay;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Component)enemy).transform.position = new Vector3(-10000f, -10000f, -10000f);
					enemy.SyncPositionToClients();
					if (enemy.enemyType.enemyName == "Blob" && ((NetworkBehaviour)enemy).IsServer)
					{
						((Component)enemy).GetComponent<NetworkObject>().Despawn(true);
					}
					return false;
				}
			}

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

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

		[HarmonyPrefix]
		[HarmonyPatch("HitEnemy")]
		private static bool HitEnemyPatch(ref EnemyAI __instance, PlayerControllerB playerWhoHit, int hitID)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)playerWhoHit == (Object)null)
			{
				return true;
			}
			if (playerWhoHit.currentItemSlot < 0 || playerWhoHit.currentItemSlot >= playerWhoHit.ItemSlots.Length)
			{
				return true;
			}
			GrabbableObject val = playerWhoHit.ItemSlots[playerWhoHit.currentItemSlot];
			if ((Object)(object)val == (Object)null || val.itemProperties.itemName != "Crimson Moon's Semblance")
			{
				return true;
			}
			CMS_PlayerScript component = ((Component)playerWhoHit).GetComponent<CMS_PlayerScript>();
			if ((Object)(object)component == (Object)null)
			{
				return true;
			}
			if (component.EmberfireGrace)
			{
				HandleEmberfire(__instance, component, hitID, playerWhoHit);
				return false;
			}
			switch (hitID)
			{
			case -2:
				HandleAllIsAshMark(__instance);
				break;
			default:
				HandleNormalAttack(__instance, component);
				component.AddUltProgress(component.BurstHitEnergyGain);
				break;
			case -3:
				break;
			}
			return true;
		}

		private static void HandleEmberfire(EnemyAI enemy, CMS_PlayerScript player, int hitID, PlayerControllerB owner)
		{
			bool flag = (Object)(object)((Component)enemy).transform.Find("CrimsonMoonsSemblanceMark(Clone)") != (Object)null;
			if (hitID == -2 || flag)
			{
				Debug.Log((object)"CMS: Emberfire used on marked or All Is Ash enemy");
				player.AddBondOfLife(player.BondOfLifeIncrease);
			}
			else if (player.BondOfLife >= 0)
			{
				Debug.Log((object)"CMS: Emberfire used on unmarked enemy");
				player.RemoveBondOfLife(player.BondOfLifeDecrease);
			}
			((MonoBehaviour)enemy).StartCoroutine(player.ActivateEmeberfireGrace());
			((Component)enemy).gameObject.AddComponent<CMS_EnemyDeathScript>();
			if ((Object)(object)owner == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				enemy.KillEnemyOnOwnerClient(false);
			}
		}

		private static void HandleAllIsAshMark(EnemyAI enemy)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			Transform val = ((Component)enemy).transform.Find("CrimsonMoonsSemblanceMark(Clone)");
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)"CMS: Mark found on enemy after All Is Ash");
				((Component)val).GetComponent<CMS_EnemyMarkScript>().RemoveMark = true;
			}
			else
			{
				Debug.Log((object)"CMS: Mark not found on enemy after All Is Ash");
			}
			Vector3 visibleMeshCenter = GetVisibleMeshCenter(enemy);
			Object.Instantiate<GameObject>(Plugin.CrimsonMoonsSemblanceMarkPrefab, visibleMeshCenter, Quaternion.identity, ((Component)enemy).transform);
		}

		private static void HandleNormalAttack(EnemyAI enemy, CMS_PlayerScript player)
		{
			Transform val = ((Component)enemy).transform.Find("CrimsonMoonsSemblanceMark(Clone)");
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)"CMS: Mark found on enemy after normal attack");
				((Component)val).GetComponent<CMS_EnemyMarkScript>().RemoveMark = true;
				player.AddBondOfLife(player.BondOfLifeIncrease);
			}
			else if (player.BondOfLife > 0)
			{
				Debug.Log((object)"CMS: Mark not found on enemy after normal attack");
				player.RemoveBondOfLife(player.BondOfLifeDecrease);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("KillEnemyOnOwnerClient")]
		private static bool KillEnemyOnOwnerClientPatch(EnemyAI __instance, bool overrideDestroy)
		{
			CMS_EnemyDeathScript component = ((Component)__instance).GetComponent<CMS_EnemyDeathScript>();
			if ((Object)(object)component == (Object)null)
			{
				return true;
			}
			if (!((NetworkBehaviour)__instance).IsOwner || __instance.isEnemyDead)
			{
				return false;
			}
			bool flag = overrideDestroy || __instance.enemyType.destroyOnDeath;
			Debug.Log((object)$"CMS: Kill enemy called! destroy: {flag}");
			if (((NetworkBehaviour)__instance).IsServer)
			{
				__instance.KillEnemy(flag);
			}
			else
			{
				__instance.KillEnemyServerRpc(flag);
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch("KillEnemy")]
		private static void KillEnemyPatch(EnemyAI __instance)
		{
			try
			{
				((Component)((Component)__instance).transform.Find("CrimsonMoonsSemblanceMark(Clone)")).GetComponent<CMS_EnemyMarkScript>().RemoveMark = true;
			}
			catch
			{
				Debug.Log((object)"CMS: Mark not found on the killed enemy");
			}
			CMS_EnemyDeathScript component = ((Component)__instance).GetComponent<CMS_EnemyDeathScript>();
			if (!((Object)(object)component == (Object)null) && !__instance.isEnemyDead)
			{
				Debug.Log((object)"CMS: Forced InstaKill");
				DisableColliderIfExists(__instance);
				__instance.isEnemyDead = true;
				AudioSource creatureVoice = __instance.creatureVoice;
				if (creatureVoice != null)
				{
					creatureVoice.PlayOneShot(__instance.dieSFX);
				}
				TriggerKillAnimation(__instance);
				__instance.CancelSpecialAnimationWithPlayer();
				UpdateRoundManagerEnemyPower(__instance);
				((Behaviour)__instance.agent).enabled = false;
				((MonoBehaviour)__instance).StartCoroutine(MoveBody(__instance, 5f));
				Object.Destroy((Object)(object)component);
			}
		}

		private static void DisableColliderIfExists(EnemyAI enemy)
		{
			ScanNodeProperties componentInChildren = ((Component)enemy).GetComponentInChildren<ScanNodeProperties>();
			if ((Object)(object)((componentInChildren != null) ? ((Component)componentInChildren).gameObject.GetComponent<Collider>() : null) != (Object)null)
			{
				((Component)componentInChildren).gameObject.GetComponent<Collider>().enabled = false;
			}
		}

		private static void TriggerKillAnimation(EnemyAI enemy)
		{
			Animator creatureAnimator = enemy.creatureAnimator;
			if (!((Object)(object)creatureAnimator == (Object)null))
			{
				creatureAnimator.SetBool("Stunned", false);
				creatureAnimator.SetBool("stunned", false);
				creatureAnimator.SetBool("stun", false);
				creatureAnimator.SetTrigger("KillEnemy");
				creatureAnimator.SetBool("Dead", true);
			}
		}

		private static void UpdateRoundManagerEnemyPower(EnemyAI enemy)
		{
			EnemyType enemyType = enemy.enemyType;
			if (enemyType.isDaytimeEnemy)
			{
				RoundManager.Instance.currentDaytimeEnemyPower = Mathf.Max(RoundManager.Instance.currentDaytimeEnemyPower - enemyType.PowerLevel, 0f);
				return;
			}
			if (enemyType.isOutsideEnemy)
			{
				RoundManager.Instance.currentOutsideEnemyPower = Mathf.Max(RoundManager.Instance.currentOutsideEnemyPower - enemyType.PowerLevel, 0f);
				return;
			}
			RoundManager.Instance.currentEnemyPower = Mathf.Max(RoundManager.Instance.currentEnemyPower - enemyType.PowerLevel, 0f);
			RoundManager.Instance.cannotSpawnMoreInsideEnemies = false;
		}

		[IteratorStateMachine(typeof(<MoveBody>d__9))]
		private static IEnumerator MoveBody(EnemyAI enemy, float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <MoveBody>d__9(0)
			{
				enemy = enemy,
				delay = delay
			};
		}

		private static Vector3 GetVisibleMeshCenter(EnemyAI enemy)
		{
			//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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)enemy == (Object)null)
			{
				return Vector3.zero;
			}
			int num = (Object.op_Implicit((Object)(object)Camera.main) ? Camera.main.cullingMask : 591075327);
			Renderer[] componentsInChildren = ((Component)enemy).GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren.Length == 0)
			{
				return ((Component)enemy).transform.position;
			}
			Bounds val = default(Bounds);
			bool flag = false;
			Renderer[] array = componentsInChildren;
			foreach (Renderer val2 in array)
			{
				if ((Object)(object)val2 == (Object)null || !val2.enabled || !val2.isVisible || ((1 << ((Component)val2).gameObject.layer) & num) == 0)
				{
					continue;
				}
				Bounds bounds = val2.bounds;
				Vector3 size = ((Bounds)(ref bounds)).size;
				Bounds val7;
				if (((Vector3)(ref size)).sqrMagnitude < 1E-06f)
				{
					SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null);
					if (val3 != null)
					{
						try
						{
							Mesh val4 = new Mesh();
							val3.BakeMesh(val4);
							if (val4.vertexCount == 0)
							{
								continue;
							}
							Bounds bounds2 = val4.bounds;
							Vector3 val5 = ((Component)val3).transform.TransformPoint(((Bounds)(ref bounds2)).center);
							Vector3 val6 = Vector3.Scale(((Bounds)(ref bounds2)).size, ((Component)val3).transform.lossyScale);
							float num2 = ((Component)enemy).transform.position.y + val6.y * 0.5f;
							if (val5.y > num2)
							{
								val5.y = num2;
							}
							val7 = new Bounds(val5, val6);
							goto IL_01af;
						}
						catch
						{
						}
						continue;
					}
				}
				val7 = val2.bounds;
				goto IL_01af;
				IL_01af:
				if (!flag)
				{
					val = val7;
					flag = true;
				}
				else
				{
					((Bounds)(ref val)).Encapsulate(val7);
				}
			}
			if (!flag)
			{
				return ((Component)enemy).transform.position;
			}
			Vector3 center = ((Bounds)(ref val)).center;
			if (center.y > ((Component)enemy).transform.position.y + ((Bounds)(ref val)).size.y * 0.5f)
			{
				center.y = ((Component)enemy).transform.position.y + ((Bounds)(ref val)).size.y * 0.5f;
			}
			return center;
		}
	}
	[HarmonyPatch(typeof(IngamePlayerSettings))]
	internal class IngamePlayerSettingsPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("SaveChangedSettings")]
		private static void SaveChangedSettingsPatch()
		{
			try
			{
				((Component)StartOfRound.Instance.localPlayerController).GetComponent<CMS_PlayerScript>().UpdateHUD();
			}
			catch
			{
				Debug.Log((object)"CMS: Saving changed settings in the Main Menu");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("AllowPlayerDeath")]
		private static bool AllowPlayerDeathPatch(ref PlayerControllerB __instance)
		{
			CMS_PlayerScript component = ((Component)__instance).GetComponent<CMS_PlayerScript>();
			if (component.EmberfireGrace && !component.EmberfireGraceUsed)
			{
				((MonoBehaviour)__instance).StartCoroutine(component.ActivateEmeberfireGrace());
				return false;
			}
			if (component.EmberfireGraceUsed)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void StartPatch()
		{
			List<PlayerControllerB> list = (from PlayerControllerB e in Resources.FindObjectsOfTypeAll(typeof(PlayerControllerB))
				where (Object)(object)e != (Object)null
				select e).ToList();
			foreach (PlayerControllerB item in list)
			{
				if ((Object)(object)((Component)item).GetComponent<CMS_PlayerScript>() == (Object)null)
				{
					((Component)item).gameObject.AddComponent<CMS_PlayerScript>();
				}
			}
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace CrimsonMoonsSemblance.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}