Decompiled source of QueenCrest v0.1.1

QueenCrest.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.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GlobalSettings;
using HarmonyLib;
using HutongGames.PlayMaker;
using Microsoft.CodeAnalysis;
using Needleforge;
using Needleforge.Data;
using QueenCrest.Components;
using QueenCrest.Patches;
using QueenCrest.Utils;
using TeamCherry.Localization;
using TeamCherry.NestedFadeGroup;
using TeamCherry.SharedUtils;
using UnityEngine;

[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("QueenCrest")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+454188779d6d26a042968f260714cd46c7e3ec62")]
[assembly: AssemblyProduct("QueenCrest")]
[assembly: AssemblyTitle("QueenCrest")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/kaycodes13/QueenCrest")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
		}
	}
	[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;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace QueenCrest
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency("io.github.needleforge", "0.6.1")]
	[BepInPlugin("io.github.kaycodes13.queencrest", "QueenCrest", "0.1.1")]
	public class QueenCrestPlugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HudCoroutine <0>__HudCoroutine;

			public static Action<FsmInt, FsmInt, FsmFloat, PlayMakerFSM> <1>__EnableMultibinder;

			public static Action <2>__EnableReaperBindEffect;
		}

		internal const string YenId = "Yen";

		internal static readonly LocalisedString YenName = new LocalisedString("Mods.io.github.kaycodes13.queencrest", "CREST_NAME");

		internal static readonly LocalisedString YenDesc = new LocalisedString("Mods.io.github.kaycodes13.queencrest", "CREST_DESC");

		public const string Id = "io.github.kaycodes13.queencrest";

		private Harmony Harmony { get; } = new Harmony("io.github.kaycodes13.queencrest");


		internal static ManualLogSource Log { get; private set; }

		internal static CrestData YenCrest { get; private set; }

		private static Color AdminGreen { get; } = Color32.op_Implicit(new Color32((byte)89, byte.MaxValue, (byte)152, byte.MaxValue));


		internal static Color AttackColor { get; } = Color.Lerp(Color.white, AdminGreen, 0.3f);


		public static string Name => "QueenCrest";

		public static string Version => "0.1.1";

		private void Awake()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: 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_0191: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.kaycodes13.queencrest) has loaded!"));
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.44f);
			Sprite val2 = ResourceUtils.LoadEmbeddedPngAsSprite("Crest.png", val);
			Sprite val3 = ResourceUtils.LoadEmbeddedPngAsSprite("CrestSilhouette.png", val);
			Sprite val4 = ResourceUtils.LoadEmbeddedPngAsSprite("CrestGlow.png", val, 140f);
			float num = 0.5f - val.y;
			Rect rect = val2.rect;
			float num2 = num * (((Rect)(ref rect)).height / val2.pixelsPerUnit);
			YenCrest = NeedleforgePlugin.AddCrest("Yen", YenName, YenDesc, val2, val3, val4);
			YenCrest.AddSkillSlot((AttackToolBinding)1, new Vector2(-0.9f, 1.85f + num2), false);
			YenCrest.AddSkillSlot((AttackToolBinding)2, new Vector2(0.93f, 1.93f + num2), false);
			YenCrest.AddRedSlot((AttackToolBinding)0, new Vector2(2.1f, 0.13f + num2), false);
			YenCrest.AddYellowSlot(new Vector2(-2.1f, 0.13f + num2), false);
			YenCrest.AddBlueSlot(new Vector2(-1.94f, -1.67f + num2), false);
			YenCrest.AddBlueSlot(new Vector2(1.94f, -1.67f + num2), false);
			YenCrest.AddBlueSlot(new Vector2(0f, -2.95f + num2), false);
			YenCrest.ApplyAutoSlotNavigation(true, 60f, (Vector2?)new Vector2(1.25f, 0.75f));
			YenCrest.HudFrame.Preset = (VanillaCrest)2;
			HudFrameData hudFrame = YenCrest.HudFrame;
			object obj = <>O.<0>__HudCoroutine;
			if (obj == null)
			{
				HudCoroutine val5 = Bind.HudCoroutine;
				<>O.<0>__HudCoroutine = val5;
				obj = (object)val5;
			}
			hudFrame.Coroutine = (HudCoroutine)obj;
			YenCrest.BindEvent = Bind.EnableMultibinder;
			YenCrest.BindCompleteEvent = Bind.EnableReaperBindEffect;
			Harmony.PatchAll(typeof(Bind));
			Harmony.PatchAll(typeof(Moveset));
		}

		private void OnDestroy()
		{
			Harmony.UnpatchSelf();
		}
	}
}
namespace QueenCrest.Utils
{
	internal static class ResourceUtils
	{
		public static Sprite LoadEmbeddedPngAsSprite(string filename, Vector2? pivot = null, float pixelsPerUnit = 100f)
		{
			//IL_0029: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = LoadEmbeddedPngAsTexture2D(filename);
			((Object)val).name = filename;
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), (Vector2)(((??)pivot) ?? new Vector2(0.5f, 0.5f)), pixelsPerUnit);
		}

		public static Texture2D LoadEmbeddedPngAsTexture2D(string filename)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			string filename2 = filename;
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().First((string x) => x.EndsWith(filename2));
			byte[] array;
			using (Stream stream = executingAssembly.GetManifestResourceStream(name))
			{
				using BinaryReader binaryReader = new BinaryReader(stream);
				array = binaryReader.ReadBytes((int)stream.Length);
			}
			Texture2D val = new Texture2D(1, 1);
			ImageConversion.LoadImage(val, array);
			return val;
		}
	}
}
namespace QueenCrest.Patches
{
	internal static class Bind
	{
		[CompilerGenerated]
		private sealed class <HudCoroutine>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BindOrbHudFrame hudInstance;

			private HeroController <hc>5__1;

			private bool <wasInReaperMode>5__2;

			private float <effectTime>5__3;

			private NestedFadeGroupBase <effect>5__4;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<hc>5__1 = null;
				<effect>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<hc>5__1 = HeroController.instance;
					<wasInReaperMode>5__2 = false;
					<effectTime>5__3 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				case 2:
					<>1__state = -1;
					<effect>5__4 = null;
					break;
				}
				if (<hc>5__1.IsPaused())
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<effect>5__4 = hudInstance.reaperModeEffect;
				if (Object.op_Implicit((Object)(object)<effect>5__4))
				{
					if (!<wasInReaperMode>5__2 && <hc>5__1.reaperState.IsInReaperMode)
					{
						((Component)<effect>5__4).gameObject.SetActive(false);
						((Component)<effect>5__4).gameObject.SetActive(true);
						<effect>5__4.AlphaSelf = 1f;
						<effectTime>5__3 = 0f;
					}
					else if (<wasInReaperMode>5__2 && !<hc>5__1.reaperState.IsInReaperMode)
					{
						<effectTime>5__3 = <effect>5__4.FadeTo(0f, hudInstance.reaperModeEffectFadeOutTime, (AnimationCurve)null, false, (Action<bool>)null);
					}
					if (<effectTime>5__3 > 0f)
					{
						<effectTime>5__3 -= Time.deltaTime;
						if (<effectTime>5__3 <= 0f)
						{
							((Component)<effect>5__4).gameObject.SetActive(false);
						}
					}
				}
				<wasInReaperMode>5__2 = <hc>5__1.reaperState.IsInReaperMode;
				<>2__current = null;
				<>1__state = 2;
				return true;
			}

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

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

		private static readonly ProbabilityInt[] silkOrbDrops;

		private static int GetRandomOrbDrops()
		{
			return Probability.GetRandomItemByProbability<ProbabilityInt, int>(silkOrbDrops, (float[])null);
		}

		[IteratorStateMachine(typeof(<HudCoroutine>d__2))]
		internal static IEnumerator HudCoroutine(BindOrbHudFrame hudInstance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <HudCoroutine>d__2(0)
			{
				hudInstance = hudInstance
			};
		}

		internal static void EnableMultibinder(FsmInt value, FsmInt amount, FsmFloat time, PlayMakerFSM _)
		{
			ToolItem toolByName = ToolItemManager.GetToolByName("Multibind");
			if (((ToolBase)toolByName).IsEquipped)
			{
				value.Value = 2;
				amount.Value = 2;
				time.Value = 0.8f;
			}
		}

		internal static void EnableReaperBindEffect()
		{
			if (QueenCrestPlugin.YenCrest.IsEquipped)
			{
				HeroController instance = HeroController.instance;
				instance.reaperState.IsInReaperMode = true;
				instance.reaperState.ReaperModeDurationLeft = Gameplay.ReaperModeDuration;
				if (Object.op_Implicit((Object)(object)instance.reaperModeEffect))
				{
					((Component)instance.reaperModeEffect).gameObject.SetActive(false);
					((Component)instance.reaperModeEffect).gameObject.SetActive(true);
				}
			}
		}

		[HarmonyPatch(typeof(HealthManager), "TakeDamage", new Type[] { typeof(HitInstance) })]
		[HarmonyPostfix]
		private static void SpawnSilkOrbs(HealthManager __instance, ref HitInstance hitInstance)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected I4, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			if (!QueenCrestPlugin.YenCrest.IsEquipped)
			{
				return;
			}
			HeroController instance = HeroController.instance;
			if (((int)hitInstance.AttackType != 0 && ((int)hitInstance.AttackType != 16 || !hitInstance.IsNailTag)) || (int)__instance.enemyType == 3 || (int)__instance.enemyType == 6 || __instance.DoNotGiveSilk || (int)hitInstance.SilkGeneration == 2 || !instance.ReaperState.IsInReaperMode)
			{
				return;
			}
			ReaperBundleTiers reaperBundles = __instance.reaperBundles;
			if (1 == 0)
			{
			}
			int num = (int)reaperBundles switch
			{
				0 => GetRandomOrbDrops(), 
				1 => 1, 
				2 => 0, 
				_ => throw new Exception("Something has gone terribly wrong."), 
			};
			if (1 == 0)
			{
			}
			int num2 = num;
			if (num2 == 0)
			{
				return;
			}
			int cardinalDirection = DirectionUtils.GetCardinalDirection(((HitInstance)(ref hitInstance)).GetActualDirection(((Component)__instance).transform, (TargetType)0));
			float item = 0f;
			float item2 = 360f;
			float num5;
			if ((Object)(object)__instance.flingSilkOrbsAimObject != (Object)null)
			{
				Vector3 position = __instance.flingSilkOrbsAimObject.transform.position;
				Vector3 position2 = ((Component)__instance).transform.position;
				float num3 = position.x - position2.x;
				float num4 = position.y - position2.y;
				num5 = Mathf.Atan2(num4, num3) * (180f / MathF.PI);
				item = num5 - 45f;
				item2 = num5 + 45f;
			}
			else if (__instance.flingSilkOrbsDown)
			{
				item = 225f;
				item2 = 315f;
				num5 = 270f;
			}
			else
			{
				if (1 == 0)
				{
				}
				(float, float, float) tuple = cardinalDirection switch
				{
					0 => (315f, 415f, 0f), 
					1 => (45f, 135f, 90f), 
					2 => (125f, 225f, 180f), 
					3 => (225f, 315f, 270f), 
					_ => (item, item2, 0f), 
				};
				if (1 == 0)
				{
				}
				(item, item2, num5) = tuple;
			}
			Config val = default(Config);
			val.Prefab = Gameplay.ReaperBundlePrefab;
			val.AmountMin = num2;
			val.AmountMax = num2;
			val.SpeedMin = 25f;
			val.SpeedMax = 50f;
			val.AngleMin = item;
			val.AngleMax = item2;
			FlingUtils.SpawnAndFling(val, ((Component)__instance).transform, __instance.effectOrigin, (List<GameObject>)null, -1f);
			GameObject reapHitEffectPrefab = Effects.ReapHitEffectPrefab;
			if (Object.op_Implicit((Object)(object)reapHitEffectPrefab))
			{
				int cardinalDirection2 = DirectionUtils.GetCardinalDirection(num5);
				if (1 == 0)
				{
				}
				(Vector2, float) tuple3 = cardinalDirection2 switch
				{
					1 => (Vector2.one, 90f), 
					2 => (new Vector2(-1f, 1f), 0f), 
					3 => (new Vector2(1f, -1f), 90f), 
					_ => (Vector2.one, 0f), 
				};
				if (1 == 0)
				{
				}
				(Vector2, float) tuple4 = tuple3;
				Vector2 item3 = tuple4.Item1;
				float item4 = tuple4.Item2;
				GameObject val2 = ObjectPoolExtensions.Spawn(reapHitEffectPrefab, ((Component)__instance).transform.TransformPoint(__instance.effectOrigin));
				Extensions.SetRotation2D(val2.transform, item4);
				val2.transform.localScale = Extensions.ToVector3(item3, val2.transform.localScale.z);
			}
		}

		static Bind()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0020: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_003a: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0054: Expected O, but got Unknown
			ProbabilityInt[] array = new ProbabilityInt[3];
			ProbabilityInt val = new ProbabilityInt
			{
				Value = 1
			};
			((ProbabilityBase<int>)val).Probability = 0.5f;
			array[0] = val;
			ProbabilityInt val2 = new ProbabilityInt
			{
				Value = 2
			};
			((ProbabilityBase<int>)val2).Probability = 0.35f;
			array[1] = val2;
			ProbabilityInt val3 = new ProbabilityInt
			{
				Value = 3
			};
			((ProbabilityBase<int>)val3).Probability = 0.15f;
			array[2] = val3;
			silkOrbDrops = (ProbabilityInt[])(object)array;
		}
	}
	internal class Moveset
	{
		[HarmonyPatch(typeof(HeroController), "Awake")]
		[HarmonyPostfix]
		private static void AddMovesetToHornet(HeroController __instance)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			if ((Object)(object)QueenCrestPlugin.YenCrest.AttackConfig == (Object)null)
			{
				HeroControllerConfig val = BuildConfig(__instance);
				val.heroAnimOverrideLib = BuildAnimations(__instance);
				QueenCrestPlugin.YenCrest.AttackConfig = val;
				if (Object.op_Implicit((Object)(object)QueenCrestPlugin.YenCrest.ToolCrest))
				{
					QueenCrestPlugin.YenCrest.ToolCrest.heroConfig = val;
				}
			}
			GameObject val2 = BuildAttacks(__instance, QueenCrestPlugin.YenCrest.AttackConfig);
			ConfigGroup val3 = new ConfigGroup
			{
				ActiveRoot = val2,
				Config = QueenCrestPlugin.YenCrest.AttackConfig,
				NormalSlashObject = ((Component)val2.transform.Find("Slash")).gameObject,
				AlternateSlashObject = ((Component)val2.transform.Find("AltSlash")).gameObject,
				UpSlashObject = ((Component)val2.transform.Find("UpSlash")).gameObject,
				DownSlashObject = ((Component)val2.transform.Find("DownSlash")).gameObject,
				WallSlashObject = ((Component)val2.transform.Find("WallSlash")).gameObject,
				DashStab = ((Component)val2.transform.Find("Dash Stab")).gameObject,
				ChargeSlash = ((Component)val2.transform.Find("ChargeSlash")).gameObject
			};
			ConfigGroup[] configs = __instance.configs;
			int num = 0;
			ConfigGroup[] array = (ConfigGroup[])(object)new ConfigGroup[1 + configs.Length];
			ReadOnlySpan<ConfigGroup> readOnlySpan = new ReadOnlySpan<ConfigGroup>(configs);
			readOnlySpan.CopyTo(new Span<ConfigGroup>(array).Slice(num, readOnlySpan.Length));
			num += readOnlySpan.Length;
			array[num] = val3;
			__instance.configs = array;
			val3.Setup();
		}

		private static HeroControllerConfig BuildConfig(HeroController hc)
		{
			HeroControllerConfig val = Object.Instantiate<HeroControllerConfig>(hc.configs.First((ConfigGroup c) => ((Object)c.Config).name == "Default").Config);
			HeroControllerConfig config = hc.configs.First((ConfigGroup c) => ((Object)c.Config).name == "Whip").Config;
			((Object)val).name = "Yen";
			val.chargeSlashChain = config.ChargeSlashChain;
			val.chargeSlashRecoils = config.ChargeSlashRecoils;
			val.chargeSlashLungeSpeed = config.ChargeSlashLungeSpeed;
			val.chargeSlashLungeDeceleration = config.ChargeSlashLungeDeceleration;
			return val;
		}

		private static tk2dSpriteAnimation BuildAnimations(HeroController hc)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			tk2dSpriteAnimation heroAnimOverrideLib = hc.configs.First((ConfigGroup c) => ((Object)c.Config).name == "Whip").Config.heroAnimOverrideLib;
			GameObject val = new GameObject("Yen_AnimLib");
			tk2dSpriteAnimation val2 = val.AddComponent<tk2dSpriteAnimation>();
			val2.clips = heroAnimOverrideLib.clips.Where((tk2dSpriteAnimationClip c) => c.name.Contains("Charged")).ToArray();
			Object.DontDestroyOnLoad((Object)(object)val);
			return val2;
		}

		private static GameObject BuildAttacks(HeroController hc, HeroControllerConfig config)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			Transform val = hc.transform.Find("Attacks/Default");
			Transform val2 = hc.transform.Find("Attacks/Charge Slash Witch");
			GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, val.parent);
			((Object)val3).name = "Yen_Attacks";
			GameObject val4 = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)val2).transform.parent);
			((Object)val4).name = "ChargeSlash";
			val4.transform.SetParent(val3.transform);
			tk2dSpriteAnimator[] components = val4.GetComponents<tk2dSpriteAnimator>();
			foreach (tk2dSpriteAnimator val5 in components)
			{
				val5.Library = config.heroAnimOverrideLib;
			}
			TintRendererGroupConditionally tintRendererGroupConditionally = val3.AddComponent<TintRendererGroupConditionally>();
			tintRendererGroupConditionally.Condition = () => (int)HeroController.instance.NailImbuement.CurrentElement == 0;
			((TintRendererGroup)tintRendererGroupConditionally).Color = QueenCrestPlugin.AttackColor;
			return val3;
		}
	}
}
namespace QueenCrest.Components
{
	internal class TintRendererGroupConditionally : TintRendererGroup
	{
		public Func<bool> Condition { get; set; } = () => true;


		private void UpdateTint()
		{
			if (Condition())
			{
				((TintRendererGroup)this).UpdateTint();
			}
		}

		private void Update()
		{
			UpdateTint();
		}

		private void OnEnable()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			base.sprites.Clear();
			base.others.Clear();
			base.particles.Clear();
			base.meshRenderers.Clear();
			((TintRendererGroup)this).GetComponentsInChildrenRecursively(((Component)this).transform);
			if (base.meshRenderers.Count > 0)
			{
				base.block = new MaterialPropertyBlock();
			}
			UpdateTint();
		}
	}
}