Decompiled source of Heretic v1.2.9

plugins/Moffein-Heretic/Heretic.dll

Decompiled a month ago
using System;
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.Bootstrap;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.Heretic;
using HereticMod.Components;
using IL.EntityStates;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.Heretic;
using On.RoR2;
using On.RoR2.Skills;
using On.RoR2.SurvivorMannequins;
using R2API;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Achievements;
using RoR2.Skills;
using RoR2.SurvivorMannequins;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Heretic")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7d84dd2b5df2f6b9ce4198e3b70e6fea140560c4")]
[assembly: AssemblyProduct("Heretic")]
[assembly: AssemblyTitle("Heretic")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Heretic
{
	[RegisterAchievement("MoffeinHereticUnlock", "Survivors.MoffeinHeretic", null, 10u, null)]
	public class HereticUnlockAchievement : BaseEndingAchievement
	{
		public override BodyIndex LookUpRequiredBodyIndex()
		{
			//IL_0006: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			return BodyCatalog.FindBodyIndex("HereticBody");
		}

		public override bool ShouldGrant(RunReport runReport)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)runReport.gameEnding) && runReport.gameEnding.isWin && (Object)(object)runReport.gameEnding == (Object)(object)GameEndings.MainEnding && ((BaseAchievement)this).localUser.cachedBody.bodyIndex == ((BaseAchievement)this).requiredBodyIndex)
			{
				return true;
			}
			return false;
		}
	}
}
namespace HereticMod
{
	public class Assets
	{
		public static AssetBundle assetBundle;

		internal static string languageRoot => Path.Combine(assemblyDir, "language");

		internal static string assemblyDir => Path.GetDirectoryName(HereticPlugin.pluginInfo.Location);

		public static void Init()
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Heretic.hereticassetbundle");
			assetBundle = AssetBundle.LoadFromStream(stream);
		}
	}
	internal class HereticItem
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static StatHookEventHandler <>9__2_0;

			public static Func<Instruction, bool> <>9__2_3;

			public static Func<float, HealthComponent, float> <>9__2_2;

			public static Manipulator <>9__2_1;

			internal void <Init>b__2_0(CharacterBody sender, StatHookEventArgs args)
			{
				if (Object.op_Implicit((Object)(object)sender.inventory) && sender.inventory.GetItemCount(HereticStatBonusItem) > 0)
				{
					bool flag = sender.HasBuff(Buffs.AffixLunar) || sender.inventory.GetItemCount(Items.ShieldOnly) > 0;
					float num = sender.level - 1f;
					if (!flag)
					{
						args.baseRegenAdd -= sender.baseRegen + sender.levelRegen * num;
					}
					args.healthMultAdd += 3f;
					args.baseDamageAdd += 0.5f * (sender.baseDamage + sender.levelDamage * num);
				}
			}

			internal void <Init>b__2_1(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)
				ILCursor val = new ILCursor(il);
				if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(HealthComponent), "regenAccumulator")
				}))
				{
					val.Emit(OpCodes.Ldarg_0);
					val.EmitDelegate<Func<float, HealthComponent, float>>((Func<float, HealthComponent, float>)delegate(float regenAccumulator, HealthComponent self)
					{
						if (Object.op_Implicit((Object)(object)self.body.inventory) && self.body.inventory.GetItemCount(HereticStatBonusItem) > 0 && !self.body.HasBuff(Buffs.AffixLunar) && self.body.inventory.GetItemCount(Items.ShieldOnly) <= 0)
						{
							float num = Time.fixedDeltaTime * (6f + 1.2f * (self.body.level - 1f));
							num /= self.body.cursePenalty;
							regenAccumulator -= num;
						}
						return regenAccumulator;
					});
				}
				else
				{
					Debug.LogError((object)"RiskyMod: ModifyRegenAccumulator IL Hook failed");
				}
			}

			internal bool <Init>b__2_3(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdfld(x, typeof(HealthComponent), "regenAccumulator");
			}

			internal float <Init>b__2_2(float regenAccumulator, HealthComponent self)
			{
				if (Object.op_Implicit((Object)(object)self.body.inventory) && self.body.inventory.GetItemCount(HereticStatBonusItem) > 0 && !self.body.HasBuff(Buffs.AffixLunar) && self.body.inventory.GetItemCount(Items.ShieldOnly) <= 0)
				{
					float num = Time.fixedDeltaTime * (6f + 1.2f * (self.body.level - 1f));
					num /= self.body.cursePenalty;
					regenAccumulator -= num;
				}
				return regenAccumulator;
			}
		}

		public static ItemDef HereticStatBonusItem;

		private static bool initialized;

		public static void Init()
		{
			//IL_0040: 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_00c8: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			if (initialized)
			{
				return;
			}
			initialized = true;
			HereticStatBonusItem = ScriptableObject.CreateInstance<ItemDef>();
			HereticStatBonusItem.canRemove = false;
			((Object)HereticStatBonusItem).name = "MoffeinHereticStatBonusItem";
			HereticStatBonusItem.deprecatedTier = (ItemTier)5;
			HereticStatBonusItem.descriptionToken = "MOFFEINHERETIC_STATBONUSITEM_DESC";
			HereticStatBonusItem.nameToken = "MOFFEINHERETIC_STATBONUSITEM_NAME";
			HereticStatBonusItem.pickupToken = "MOFFEINHERETIC_STATBONUSITEM_PICKUP";
			HereticStatBonusItem.hidden = false;
			HereticStatBonusItem.pickupIconSprite = Assets.assetBundle.LoadAsset<Sprite>("texHeresyItemIcon");
			ItemDef hereticStatBonusItem = HereticStatBonusItem;
			ItemTag[] array = new ItemTag[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			hereticStatBonusItem.tags = (ItemTag[])(object)array;
			ItemDisplayRule[] array2 = (ItemDisplayRule[])(object)new ItemDisplayRule[0];
			ItemAPI.Add(new CustomItem(HereticStatBonusItem, array2));
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				StatHookEventHandler val = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (Object.op_Implicit((Object)(object)sender.inventory) && sender.inventory.GetItemCount(HereticStatBonusItem) > 0)
					{
						bool flag = sender.HasBuff(Buffs.AffixLunar) || sender.inventory.GetItemCount(Items.ShieldOnly) > 0;
						float num2 = sender.level - 1f;
						if (!flag)
						{
							args.baseRegenAdd -= sender.baseRegen + sender.levelRegen * num2;
						}
						args.healthMultAdd += 3f;
						args.baseDamageAdd += 0.5f * (sender.baseDamage + sender.levelDamage * num2);
					}
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
			object obj2 = <>c.<>9__2_1;
			if (obj2 == null)
			{
				Manipulator val2 = delegate(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)
					ILCursor val3 = new ILCursor(il);
					if (val3.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(HealthComponent), "regenAccumulator")
					}))
					{
						val3.Emit(OpCodes.Ldarg_0);
						val3.EmitDelegate<Func<float, HealthComponent, float>>((Func<float, HealthComponent, float>)delegate(float regenAccumulator, HealthComponent self)
						{
							if (Object.op_Implicit((Object)(object)self.body.inventory) && self.body.inventory.GetItemCount(HereticStatBonusItem) > 0 && !self.body.HasBuff(Buffs.AffixLunar) && self.body.inventory.GetItemCount(Items.ShieldOnly) <= 0)
							{
								float num = Time.fixedDeltaTime * (6f + 1.2f * (self.body.level - 1f));
								num /= self.body.cursePenalty;
								regenAccumulator -= num;
							}
							return regenAccumulator;
						});
					}
					else
					{
						Debug.LogError((object)"RiskyMod: ModifyRegenAccumulator IL Hook failed");
					}
				};
				<>c.<>9__2_1 = val2;
				obj2 = (object)val2;
			}
			HealthComponent.ServerFixedUpdate += (Manipulator)obj2;
			if (HereticPlugin.giveHereticItem)
			{
				CharacterMaster.OnInventoryChanged += new hook_OnInventoryChanged(GiveHereticItem);
			}
		}

		private static void GiveHereticItem(orig_OnInventoryChanged orig, CharacterMaster self)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			CharacterBody body = self.GetBody();
			if (Object.op_Implicit((Object)(object)body) && body.bodyIndex == HereticPlugin.HereticBodyIndex)
			{
				flag = true;
			}
			orig.Invoke(self);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)self.inventory) && self.inventory.GetItemCount(Items.LunarPrimaryReplacement.itemIndex) > 0 && self.inventory.GetItemCount(Items.LunarSecondaryReplacement.itemIndex) > 0 && self.inventory.GetItemCount(Items.LunarSpecialReplacement.itemIndex) > 0 && self.inventory.GetItemCount(Items.LunarUtilityReplacement.itemIndex) > 0 && self.inventory.GetItemCount(HereticStatBonusItem) <= 0)
			{
				self.inventory.GiveItem(HereticStatBonusItem, 1);
				if (flag)
				{
					EffectManager.SimpleEffect(SpawnState.effectPrefab, body.corePosition, Quaternion.identity, true);
				}
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Moffein.Heretic", "Heretic", "1.2.8")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class HereticPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_RebuildMannequinInstance <>9__14_0;

			internal void <ModifySurvivorDef>b__14_0(orig_RebuildMannequinInstance orig, SurvivorMannequinSlotController self)
			{
				orig.Invoke(self);
				if ((Object)(object)self.currentSurvivorDef == (Object)(object)HereticSurvivorDef)
				{
					MenuAnimComponent component = ((Component)self.mannequinInstanceTransform).gameObject.GetComponent<MenuAnimComponent>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.Play();
					}
				}
			}
		}

		public static bool fixTypos = true;

		public static bool visionsAttackSpeed = true;

		public static bool giveHereticItem = true;

		public static float sortPosition = 17f;

		public static ConfigEntry<KeyboardShortcut> squawkButton;

		public static bool forceUnlock;

		public static PluginInfo pluginInfo;

		public static BodyIndex HereticBodyIndex;

		public static GameObject HereticBodyObject;

		public static SurvivorDef HereticSurvivorDef;

		public void Awake()
		{
			//IL_0006: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			HereticBodyObject = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Heretic/HereticBody.prefab").WaitForCompletion();
			Assets.Init();
			ReadConfig();
			pluginInfo = ((BaseUnityPlugin)this).Info;
			Tokens.Init();
			Skins.InitSkins(HereticBodyObject);
			ModifyStats(HereticBodyObject.GetComponent<CharacterBody>());
			ModifySurvivorDef();
			ModifyLunarSkillDefs.Init();
			SkillSetup.Init();
			SquawkController.Init();
			HereticItem.Init();
			CameraRigController.OnEnable += new hook_OnEnable(DisableLobbyFade);
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
		}

		private void OnLoad()
		{
			//IL_0006: 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)
			HereticBodyIndex = BodyCatalog.FindBodyIndex("HereticBody");
		}

		public static void DisableLobbyFade(orig_OnEnable orig, CameraRigController self)
		{
			SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
			if (Object.op_Implicit((Object)(object)sceneDefForCurrentScene) && sceneDefForCurrentScene.baseSceneName.Equals("lobby"))
			{
				self.enableFading = false;
			}
			orig.Invoke(self);
		}

		private void ModifyStats(CharacterBody cb)
		{
			cb.baseMaxHealth = 110f;
			cb.levelMaxHealth = 33f;
			cb.baseDamage = 12f;
			cb.levelDamage = 2.4f;
			cb.baseRegen = 1f;
			cb.levelRegen = 0.2f;
		}

		private void ModifySurvivorDef()
		{
			//IL_0006: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f1: Expected O, but got Unknown
			HereticSurvivorDef = Addressables.LoadAssetAsync<SurvivorDef>((object)"RoR2/Base/Heretic/Heretic.asset").WaitForCompletion();
			HereticSurvivorDef.hidden = false;
			UnlockableDef val = ScriptableObject.CreateInstance<UnlockableDef>();
			val.cachedName = "Survivors.MoffeinHeretic";
			val.nameToken = "ACHIEVEMENT_MOFFEINHERETIC_UNLOCK_NAME";
			val.achievementIcon = Assets.assetBundle.LoadAsset<Sprite>("texHereticUnlock.png");
			ContentAddition.AddUnlockableDef(val);
			if (!forceUnlock)
			{
				HereticSurvivorDef.unlockableDef = val;
			}
			GameObject val2 = PrefabAPI.InstantiateClone(((Component)HereticBodyObject.GetComponent<ModelLocator>().modelTransform).gameObject, "MoffeinHereticDisplay", false);
			Transform transform = val2.transform;
			transform.localScale *= 0.6f;
			HereticSurvivorDef.displayPrefab = val2;
			val2.AddComponent<MenuAnimComponent>();
			HereticSurvivorDef.desiredSortPosition = sortPosition;
			object obj = <>c.<>9__14_0;
			if (obj == null)
			{
				hook_RebuildMannequinInstance val3 = delegate(orig_RebuildMannequinInstance orig, SurvivorMannequinSlotController self)
				{
					orig.Invoke(self);
					if ((Object)(object)self.currentSurvivorDef == (Object)(object)HereticSurvivorDef)
					{
						MenuAnimComponent component = ((Component)self.mannequinInstanceTransform).gameObject.GetComponent<MenuAnimComponent>();
						if (Object.op_Implicit((Object)(object)component))
						{
							component.Play();
						}
					}
				};
				<>c.<>9__14_0 = val3;
				obj = (object)val3;
			}
			SurvivorMannequinSlotController.RebuildMannequinInstance += (hook_RebuildMannequinInstance)obj;
		}

		private void ReadConfig()
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			forceUnlock = ((BaseUnityPlugin)this).Config.Bind<bool>("Unlock", "Force Unlock", false, "Unlocks Heretic by default.").Value;
			visionsAttackSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Visions of Heresy Attack Speed", true, "Reload speed of Visions of Heresy scales with Attack Speed instead of Cooldown.").Value;
			giveHereticItem = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Enable Mark of Heresy", true, "Collecting all 4 Heresy items gives you the Mark of Heresy.").Value;
			fixTypos = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Fix Skill Descriptions", true, "Fixes a typo with Hooks of Heresy and adds color-coding to Essence of Heresy.").Value;
			sortPosition = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Character Select Sort Position", 14f, "Determines which spot this survivor will take in the Character Select menu.").Value;
			squawkButton = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Squawk Button", KeyboardShortcut.Empty, "Press this button to squawk.");
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				RiskOfOptionsCompat();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void RiskOfOptionsCompat()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			ModSettingsManager.SetModIcon(Assets.assetBundle.LoadAsset<Sprite>("texHereticUnlock.png"));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(squawkButton));
		}
	}
	public class ModifyLunarSkillDefs
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_GetMaxStock <>9__2_0;

			public static hook_GetRechargeInterval <>9__4_0;

			public static Func<Instruction, bool> <>9__4_2;

			public static Func<Instruction, bool> <>9__4_3;

			public static Func<int, int> <>9__4_4;

			public static Manipulator <>9__4_1;

			public static Func<Instruction, bool> <>9__5_1;

			public static Func<Instruction, bool> <>9__5_2;

			public static Func<int, int> <>9__5_3;

			public static Manipulator <>9__5_0;

			public static hook_GetRechargeInterval <>9__6_0;

			public static hook_OnAssigned <>9__6_1;

			public static hook_OnUnassigned <>9__6_2;

			internal int <SetupPrimary>b__2_0(orig_GetMaxStock orig, LunarPrimaryReplacementSkill self, GenericSkill skillSlot)
			{
				int num = ((SkillDef)self).baseMaxStock;
				if (Object.op_Implicit((Object)(object)skillSlot) && Object.op_Implicit((Object)(object)skillSlot.characterBody) && Object.op_Implicit((Object)(object)skillSlot.characterBody.inventory))
				{
					num = Math.Max(orig.Invoke(self, skillSlot), num);
				}
				return num;
			}

			internal float <SetupSecondary>b__4_0(orig_GetRechargeInterval orig, LunarSecondaryReplacementSkill self, GenericSkill skillSlot)
			{
				float num = ((SkillDef)self).baseRechargeInterval;
				if (Object.op_Implicit((Object)(object)skillSlot) && Object.op_Implicit((Object)(object)skillSlot.characterBody) && Object.op_Implicit((Object)(object)skillSlot.characterBody.inventory))
				{
					num = Mathf.Max(orig.Invoke(self, skillSlot), num);
				}
				return num;
			}

			internal void <SetupSecondary>b__4_1(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);
				val.GotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "LunarSecondaryReplacement"),
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GetItemCount")
				});
				val.EmitDelegate<Func<int, int>>((Func<int, int>)delegate(int itemCount)
				{
					if (itemCount <= 0)
					{
						itemCount = 1;
					}
					return itemCount;
				});
			}

			internal bool <SetupSecondary>b__4_2(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "LunarSecondaryReplacement");
			}

			internal bool <SetupSecondary>b__4_3(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GetItemCount");
			}

			internal int <SetupSecondary>b__4_4(int itemCount)
			{
				if (itemCount <= 0)
				{
					itemCount = 1;
				}
				return itemCount;
			}

			internal void <SetupUtility>b__5_0(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);
				val.GotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "LunarUtilityReplacement"),
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GetItemCount")
				});
				val.EmitDelegate<Func<int, int>>((Func<int, int>)delegate(int itemCount)
				{
					if (itemCount <= 0)
					{
						itemCount = 1;
					}
					return itemCount;
				});
			}

			internal bool <SetupUtility>b__5_1(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "LunarUtilityReplacement");
			}

			internal bool <SetupUtility>b__5_2(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GetItemCount");
			}

			internal int <SetupUtility>b__5_3(int itemCount)
			{
				if (itemCount <= 0)
				{
					itemCount = 1;
				}
				return itemCount;
			}

			internal float <SetupSpecial>b__6_0(orig_GetRechargeInterval orig, LunarDetonatorSkill self, GenericSkill skillSlot)
			{
				float num = ((SkillDef)self).baseRechargeInterval;
				if (Object.op_Implicit((Object)(object)skillSlot) && Object.op_Implicit((Object)(object)skillSlot.characterBody) && Object.op_Implicit((Object)(object)skillSlot.characterBody.inventory))
				{
					num = Mathf.Max(orig.Invoke(self, skillSlot), num);
				}
				return num;
			}

			internal BaseSkillInstanceData <SetupSpecial>b__6_1(orig_OnAssigned orig, LunarDetonatorSkill self, GenericSkill skillSlot)
			{
				if (Object.op_Implicit((Object)(object)skillSlot) && Object.op_Implicit((Object)(object)skillSlot.characterBody) && Object.op_Implicit((Object)(object)skillSlot.characterBody.skillLocator) && skillSlot.characterBody.skillLocator.allSkills == null)
				{
					AssignLunarDetonator assignLunarDetonator = ((Component)skillSlot.characterBody).gameObject.GetComponent<AssignLunarDetonator>();
					if (!Object.op_Implicit((Object)(object)assignLunarDetonator))
					{
						assignLunarDetonator = ((Component)skillSlot.characterBody).gameObject.AddComponent<AssignLunarDetonator>();
					}
					assignLunarDetonator.cb = skillSlot.characterBody;
					assignLunarDetonator.skill = self;
					assignLunarDetonator.skillSlot = skillSlot;
					return null;
				}
				return orig.Invoke(self, skillSlot);
			}

			internal void <SetupSpecial>b__6_2(orig_OnUnassigned orig, LunarDetonatorSkill self, GenericSkill skillSlot)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Invalid comparison between Unknown and O
				if (Object.op_Implicit((Object)(object)skillSlot) && (object)(InstanceData)skillSlot.skillInstanceData != null)
				{
					orig.Invoke(self, skillSlot);
				}
			}
		}

		private static bool initialized;

		public static void Init()
		{
			if (!initialized)
			{
				initialized = true;
				SetupPrimary();
				SetupSecondary();
				SetupUtility();
				SetupSpecial();
			}
		}

		private static void SetupPrimary()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0010: 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_0057: 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_0062: Expected O, but got Unknown
			if (HereticPlugin.visionsAttackSpeed)
			{
				LunarPrimaryReplacementSkill val = Addressables.LoadAssetAsync<LunarPrimaryReplacementSkill>((object)"RoR2/Base/LunarSkillReplacements/LunarPrimaryReplacement.asset").WaitForCompletion();
				((SkillDef)val).attackSpeedBuffsRestockSpeed = true;
				((SkillDef)val).attackSpeedBuffsRestockSpeed_Multiplier = 1f;
			}
			LunarPrimaryReplacementSkill.GetRechargeInterval += new hook_GetRechargeInterval(LunarPrimaryReplacementSkill_GetRechargeInterval);
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				hook_GetMaxStock val2 = delegate(orig_GetMaxStock orig, LunarPrimaryReplacementSkill self, GenericSkill skillSlot)
				{
					int num = ((SkillDef)self).baseMaxStock;
					if (Object.op_Implicit((Object)(object)skillSlot) && Object.op_Implicit((Object)(object)skillSlot.characterBody) && Object.op_Implicit((Object)(object)skillSlot.characterBody.inventory))
					{
						num = Math.Max(orig.Invoke(self, skillSlot), num);
					}
					return num;
				};
				<>c.<>9__2_0 = val2;
				obj = (object)val2;
			}
			LunarPrimaryReplacementSkill.GetMaxStock += (hook_GetMaxStock)obj;
		}

		private static float LunarPrimaryReplacementSkill_GetRechargeInterval(orig_GetRechargeInterval orig, LunarPrimaryReplacementSkill self, GenericSkill skillSlot)
		{
			float num = ((SkillDef)self).baseRechargeInterval;
			if (Object.op_Implicit((Object)(object)skillSlot) && Object.op_Implicit((Object)(object)skillSlot.characterBody) && Object.op_Implicit((Object)(object)skillSlot.characterBody.inventory))
			{
				num = Mathf.Max(orig.Invoke(self, skillSlot), num);
			}
			if (((SkillDef)self).attackSpeedBuffsRestockSpeed && Object.op_Implicit((Object)(object)skillSlot))
			{
				float num2 = skillSlot.characterBody.attackSpeed - skillSlot.characterBody.baseAttackSpeed;
				num2 *= ((SkillDef)self).attackSpeedBuffsRestockSpeed_Multiplier;
				num2 += 1f;
				if (num2 < 0.5f)
				{
					num2 = 0.5f;
				}
				num /= num2;
			}
			return num;
		}

		private static void SetupSecondary()
		{
			//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_0020: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				hook_GetRechargeInterval val = delegate(orig_GetRechargeInterval orig, LunarSecondaryReplacementSkill self, GenericSkill skillSlot)
				{
					float num = ((SkillDef)self).baseRechargeInterval;
					if (Object.op_Implicit((Object)(object)skillSlot) && Object.op_Implicit((Object)(object)skillSlot.characterBody) && Object.op_Implicit((Object)(object)skillSlot.characterBody.inventory))
					{
						num = Mathf.Max(orig.Invoke(self, skillSlot), num);
					}
					return num;
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			LunarSecondaryReplacementSkill.GetRechargeInterval += (hook_GetRechargeInterval)obj;
			object obj2 = <>c.<>9__4_1;
			if (obj2 == null)
			{
				Manipulator val2 = delegate(ILContext il)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					ILCursor val3 = new ILCursor(il);
					val3.GotoNext((MoveType)2, new Func<Instruction, bool>[2]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "LunarSecondaryReplacement"),
						(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GetItemCount")
					});
					val3.EmitDelegate<Func<int, int>>((Func<int, int>)delegate(int itemCount)
					{
						if (itemCount <= 0)
						{
							itemCount = 1;
						}
						return itemCount;
					});
				};
				<>c.<>9__4_1 = val2;
				obj2 = (object)val2;
			}
			GlobalEventManager.ProcessHitEnemy += (Manipulator)obj2;
		}

		private static void SetupUtility()
		{
			//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_0020: Expected O, but got Unknown
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				Manipulator val = delegate(ILContext il)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					ILCursor val2 = new ILCursor(il);
					val2.GotoNext((MoveType)2, new Func<Instruction, bool>[2]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "LunarUtilityReplacement"),
						(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GetItemCount")
					});
					val2.EmitDelegate<Func<int, int>>((Func<int, int>)delegate(int itemCount)
					{
						if (itemCount <= 0)
						{
							itemCount = 1;
						}
						return itemCount;
					});
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			GhostUtilitySkillState.OnEnter += (Manipulator)obj;
		}

		private static void SetupSpecial()
		{
			//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_0020: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			object obj = <>c.<>9__6_0;
			if (obj == null)
			{
				hook_GetRechargeInterval val = delegate(orig_GetRechargeInterval orig, LunarDetonatorSkill self, GenericSkill skillSlot)
				{
					float num = ((SkillDef)self).baseRechargeInterval;
					if (Object.op_Implicit((Object)(object)skillSlot) && Object.op_Implicit((Object)(object)skillSlot.characterBody) && Object.op_Implicit((Object)(object)skillSlot.characterBody.inventory))
					{
						num = Mathf.Max(orig.Invoke(self, skillSlot), num);
					}
					return num;
				};
				<>c.<>9__6_0 = val;
				obj = (object)val;
			}
			LunarDetonatorSkill.GetRechargeInterval += (hook_GetRechargeInterval)obj;
			object obj2 = <>c.<>9__6_1;
			if (obj2 == null)
			{
				hook_OnAssigned val2 = delegate(orig_OnAssigned orig, LunarDetonatorSkill self, GenericSkill skillSlot)
				{
					if (Object.op_Implicit((Object)(object)skillSlot) && Object.op_Implicit((Object)(object)skillSlot.characterBody) && Object.op_Implicit((Object)(object)skillSlot.characterBody.skillLocator) && skillSlot.characterBody.skillLocator.allSkills == null)
					{
						AssignLunarDetonator assignLunarDetonator = ((Component)skillSlot.characterBody).gameObject.GetComponent<AssignLunarDetonator>();
						if (!Object.op_Implicit((Object)(object)assignLunarDetonator))
						{
							assignLunarDetonator = ((Component)skillSlot.characterBody).gameObject.AddComponent<AssignLunarDetonator>();
						}
						assignLunarDetonator.cb = skillSlot.characterBody;
						assignLunarDetonator.skill = self;
						assignLunarDetonator.skillSlot = skillSlot;
						return null;
					}
					return orig.Invoke(self, skillSlot);
				};
				<>c.<>9__6_1 = val2;
				obj2 = (object)val2;
			}
			LunarDetonatorSkill.OnAssigned += (hook_OnAssigned)obj2;
			object obj3 = <>c.<>9__6_2;
			if (obj3 == null)
			{
				hook_OnUnassigned val3 = delegate(orig_OnUnassigned orig, LunarDetonatorSkill self, GenericSkill skillSlot)
				{
					//IL_000f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0015: Invalid comparison between Unknown and O
					if (Object.op_Implicit((Object)(object)skillSlot) && (object)(InstanceData)skillSlot.skillInstanceData != null)
					{
						orig.Invoke(self, skillSlot);
					}
				};
				<>c.<>9__6_2 = val3;
				obj3 = (object)val3;
			}
			LunarDetonatorSkill.OnUnassigned += (hook_OnUnassigned)obj3;
		}
	}
	internal class SkillSetup
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_OnEnter <>9__1_1;

			public static Action <>9__1_0;

			internal void <Init>b__1_0()
			{
				//IL_0006: 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_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: 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_00ab: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Expected O, but got Unknown
				Addressables.LoadAssetAsync<SkillFamily>((object)"RoR2/Base/Heretic/HereticPrimaryFamily.asset").WaitForCompletion().variants[0].skillDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarPrimaryReplacement"));
				SkillDef skillDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarSecondaryReplacement"));
				Addressables.LoadAssetAsync<SkillFamily>((object)"RoR2/Base/Heretic/HereticSecondaryFamily.asset").WaitForCompletion().variants[0].skillDef = skillDef;
				Addressables.LoadAssetAsync<SkillFamily>((object)"RoR2/Base/Heretic/HereticUtilityFamily.asset").WaitForCompletion().variants[0].skillDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarUtilityReplacement"));
				SkillDef skillDef2 = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarDetonatorSpecialReplacement"));
				Addressables.LoadAssetAsync<SkillFamily>((object)"RoR2/Base/Heretic/HereticSpecialFamily.asset").WaitForCompletion().variants[0].skillDef = skillDef2;
				if (HereticPlugin.fixTypos)
				{
					skillDef.skillDescriptionToken = "MOFFEINHERETIC_SKILL_LUNAR_SECONDARY_REPLACEMENT_DESCRIPTION";
					skillDef2.skillDescriptionToken = "MOFFEINHERETIC_SKILL_LUNAR_SPECIAL_REPLACEMENT_DESCRIPTION";
				}
				object obj = <>9__1_1;
				if (obj == null)
				{
					hook_OnEnter val = delegate(orig_OnEnter orig, SpawnState self)
					{
						orig.Invoke(self);
						if (NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)self).characterBody))
						{
							((EntityState)self).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, SpawnState.duration + 0.5f);
						}
					};
					<>9__1_1 = val;
					obj = (object)val;
				}
				SpawnState.OnEnter += (hook_OnEnter)obj;
			}

			internal void <Init>b__1_1(orig_OnEnter orig, SpawnState self)
			{
				orig.Invoke(self);
				if (NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)self).characterBody))
				{
					((EntityState)self).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, SpawnState.duration + 0.5f);
				}
			}
		}

		private static bool initialized;

		public static void Init()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (initialized)
			{
				return;
			}
			initialized = true;
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Heretic/HereticDefaultAbility.asset").WaitForCompletion();
			SkillLocator component = HereticPlugin.HereticBodyObject.GetComponent<SkillLocator>();
			component.passiveSkill.enabled = true;
			component.passiveSkill.skillNameToken = "HERETIC_DEFAULT_SKILL_NAME";
			component.passiveSkill.skillDescriptionToken = "MOFFEINHERETIC_PASSIVE_DESCRIPTION";
			component.passiveSkill.icon = val.icon;
			FixGenericSkills(component);
			((ResourceAvailability)(ref SkillCatalog.skillsDefined)).CallWhenAvailable((Action)delegate
			{
				//IL_0006: 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_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: 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_00ab: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Expected O, but got Unknown
				Addressables.LoadAssetAsync<SkillFamily>((object)"RoR2/Base/Heretic/HereticPrimaryFamily.asset").WaitForCompletion().variants[0].skillDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarPrimaryReplacement"));
				SkillDef skillDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarSecondaryReplacement"));
				Addressables.LoadAssetAsync<SkillFamily>((object)"RoR2/Base/Heretic/HereticSecondaryFamily.asset").WaitForCompletion().variants[0].skillDef = skillDef;
				Addressables.LoadAssetAsync<SkillFamily>((object)"RoR2/Base/Heretic/HereticUtilityFamily.asset").WaitForCompletion().variants[0].skillDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarUtilityReplacement"));
				SkillDef skillDef2 = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarDetonatorSpecialReplacement"));
				Addressables.LoadAssetAsync<SkillFamily>((object)"RoR2/Base/Heretic/HereticSpecialFamily.asset").WaitForCompletion().variants[0].skillDef = skillDef2;
				if (HereticPlugin.fixTypos)
				{
					skillDef.skillDescriptionToken = "MOFFEINHERETIC_SKILL_LUNAR_SECONDARY_REPLACEMENT_DESCRIPTION";
					skillDef2.skillDescriptionToken = "MOFFEINHERETIC_SKILL_LUNAR_SPECIAL_REPLACEMENT_DESCRIPTION";
				}
				object obj = <>c.<>9__1_1;
				if (obj == null)
				{
					hook_OnEnter val2 = delegate(orig_OnEnter orig, SpawnState self)
					{
						orig.Invoke(self);
						if (NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)self).characterBody))
						{
							((EntityState)self).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, SpawnState.duration + 0.5f);
						}
					};
					<>c.<>9__1_1 = val2;
					obj = (object)val2;
				}
				SpawnState.OnEnter += (hook_OnEnter)obj;
			});
		}

		private static void FixGenericSkills(SkillLocator skillLocator)
		{
			SkillFamily skillFamily = skillLocator.utility.skillFamily;
			SkillFamily skillFamily2 = skillLocator.special.skillFamily;
			GenericSkill special = skillLocator.special;
			GenericSkill utility = skillLocator.utility;
			skillLocator.utility = special;
			skillLocator.utility._skillFamily = skillFamily;
			skillLocator.special = utility;
			skillLocator.special._skillFamily = skillFamily2;
		}
	}
	public class Skins
	{
		private static bool initialized;

		public static void InitSkins(GameObject bodyPrefab)
		{
			if (!initialized && Object.op_Implicit((Object)(object)bodyPrefab))
			{
				initialized = true;
				GameObject gameObject = ((Component)bodyPrefab.GetComponentInChildren<ModelLocator>().modelTransform).gameObject;
				CharacterModel component = gameObject.GetComponent<CharacterModel>();
				ModelSkinController val = gameObject.GetComponent<ModelSkinController>();
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = gameObject.AddComponent<ModelSkinController>();
				}
				ChildLocator component2 = gameObject.GetComponent<ChildLocator>();
				SkinnedMeshRenderer mainSkinnedMeshRenderer = component.mainSkinnedMeshRenderer;
				RendererInfo[] baseRendererInfos = component.baseRendererInfos;
				List<SkinDef> list = new List<SkinDef>();
				SkinDef val2 = CreateSkinDef("DEFAULT_SKIN", Assets.assetBundle.LoadAsset<Sprite>("texHereticSkinDefault"), baseRendererInfos, mainSkinnedMeshRenderer, gameObject);
				val2.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[0];
				list.Add(val2);
				val.skins = list.ToArray();
			}
		}

		public static SkinDef CreateSkinDef(string skinName, Sprite skinIcon, RendererInfo[] rendererInfos, SkinnedMeshRenderer mainRenderer, GameObject root)
		{
			return CreateSkinDef(skinName, skinIcon, rendererInfos, mainRenderer, root, null);
		}

		public static SkinDef CreateSkinDef(string skinName, Sprite skinIcon, RendererInfo[] rendererInfos, SkinnedMeshRenderer mainRenderer, GameObject root, UnlockableDef unlockableDef)
		{
			//IL_0003: 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_007c: 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_008e: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			SkinDefInfo val = default(SkinDefInfo);
			val.BaseSkins = Array.Empty<SkinDef>();
			val.GameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[0];
			val.Icon = skinIcon;
			val.MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[0];
			val.MinionSkinReplacements = (MinionSkinReplacement[])(object)new MinionSkinReplacement[0];
			val.Name = skinName;
			val.NameToken = skinName;
			val.ProjectileGhostReplacements = (ProjectileGhostReplacement[])(object)new ProjectileGhostReplacement[0];
			val.RendererInfos = rendererInfos;
			val.RootObject = root;
			val.UnlockableDef = unlockableDef;
			SkinDefInfo val2 = val;
			SkinDef.Awake += new hook_Awake(DoNothing);
			SkinDef val3 = ScriptableObject.CreateInstance<SkinDef>();
			val3.baseSkins = val2.BaseSkins;
			val3.icon = val2.Icon;
			val3.unlockableDef = val2.UnlockableDef;
			val3.rootObject = val2.RootObject;
			val3.rendererInfos = val2.RendererInfos;
			val3.gameObjectActivations = val2.GameObjectActivations;
			val3.meshReplacements = val2.MeshReplacements;
			val3.projectileGhostReplacements = val2.ProjectileGhostReplacements;
			val3.minionSkinReplacements = val2.MinionSkinReplacements;
			val3.nameToken = val2.NameToken;
			((Object)val3).name = val2.Name;
			SkinDef.Awake -= new hook_Awake(DoNothing);
			return val3;
		}

		private static void DoNothing(orig_Awake orig, SkinDef self)
		{
		}
	}
	internal class Tokens
	{
		private static bool initialized;

		public static void Init()
		{
			if (!initialized)
			{
				initialized = true;
				LoadLanguage();
			}
		}

		private static void LoadLanguage()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Language.SetFolders += new hook_SetFolders(fixme);
		}

		private static void fixme(orig_SetFolders orig, Language self, IEnumerable<string> newFolders)
		{
			if (Directory.Exists(Assets.languageRoot))
			{
				IEnumerable<string> second = Directory.EnumerateDirectories(Path.Combine(Assets.languageRoot), self.name);
				orig.Invoke(self, newFolders.Union(second));
			}
			else
			{
				orig.Invoke(self, newFolders);
			}
		}
	}
}
namespace HereticMod.Components
{
	public class AssignLunarDetonator : MonoBehaviour
	{
		public GenericSkill skillSlot;

		public LunarDetonatorSkill skill;

		public CharacterBody cb;

		public void FixedUpdate()
		{
			if (skillSlot.skillInstanceData == null)
			{
				if (Object.op_Implicit((Object)(object)cb) && Object.op_Implicit((Object)(object)cb.skillLocator) && cb.skillLocator.allSkills != null)
				{
					((SkillDef)skill).OnAssigned(skillSlot);
					Object.Destroy((Object)(object)this);
				}
			}
			else
			{
				Object.Destroy((Object)(object)this);
			}
		}
	}
	public class MenuAnimComponent : MonoBehaviour
	{
		public void Play()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Animator component = ((Component)this).gameObject.GetComponent<Animator>();
			EffectManager.SimpleEffect(SpawnState.effectPrefab, ((Component)this).gameObject.transform.position, Quaternion.identity, false);
			PlayAnimation("Body", "Spawn", "Spawn.playbackRate", SpawnState.duration, component);
		}

		private void PlayAnimation(string layerName, string animationStateName, string playbackRateParam, float duration, Animator animator)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			int layerIndex = animator.GetLayerIndex(layerName);
			animator.SetFloat(playbackRateParam, 1f);
			animator.PlayInFixedTime(animationStateName, layerIndex, 0f);
			animator.Update(0f);
			AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(layerIndex);
			float length = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).length;
			animator.SetFloat(playbackRateParam, length / duration);
		}
	}
	public class SquawkController : NetworkBehaviour
	{
		private static bool initialized = false;

		public static float baseCooldown = 0.3f;

		public static NetworkSoundEventDef squawk;

		private bool wasPressed = false;

		private float cooldownStopwatch = 0f;

		public static void Init()
		{
			if (!initialized)
			{
				initialized = true;
				HereticPlugin.HereticBodyObject.AddComponent<SquawkController>();
			}
		}

		private static bool GetKeyPressed(ConfigEntry<KeyboardShortcut> entry)
		{
			//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)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = entry.Value;
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
			{
				if (!Input.GetKey(modifier))
				{
					return false;
				}
			}
			value = entry.Value;
			return Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey);
		}

		public void Update()
		{
			if (!((NetworkBehaviour)this).hasAuthority)
			{
				return;
			}
			if (cooldownStopwatch <= 0f)
			{
				if (GetKeyPressed(HereticPlugin.squawkButton))
				{
					if (!wasPressed)
					{
						Util.PlaySound("Play_heretic_squawk", ((Component)this).gameObject);
						CmdSquawk();
						cooldownStopwatch = 0.15f;
					}
					wasPressed = true;
				}
				else
				{
					wasPressed = false;
				}
			}
			else
			{
				cooldownStopwatch -= Time.deltaTime;
			}
		}

		[Command]
		public void CmdSquawk()
		{
			RpcSquawk();
		}

		[ClientRpc]
		private void RpcSquawk()
		{
			if (!((NetworkBehaviour)this).hasAuthority)
			{
				Util.PlaySound("Play_heretic_squawk", ((Component)this).gameObject);
			}
		}
	}
}