Decompiled source of JollyLethal v1.1.2

mishelin.JollyLethal.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LobbyCompatibility.Attributes;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("mishelin.JollyLethal")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+e58725708fe1823bccfb266e529b37cb4a90e6d5")]
[assembly: AssemblyProduct("JollyLethal")]
[assembly: AssemblyTitle("mishelin.JollyLethal")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.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 JollyLethal
{
	internal static class AssetLoader
	{
		private const string ASSET_BUNDLE_NAME = "lethal-mod-asset";

		public static AssetBundle? AssetsAwake(string assemblyPath)
		{
			if (string.IsNullOrEmpty(assemblyPath))
			{
				JollyLethal.PluginLogErrorWithPrefix("Invalid assebmly path!!!");
				return null;
			}
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(assemblyPath, "lethal-mod-asset"));
			if (val == null)
			{
				JollyLethal.PluginLogErrorWithPrefix("Failed to load custom assets !!!");
				return null;
			}
			JollyLethal.PluginLogInfoWithPrefix("Successfully loaded custom assets.");
			return val;
		}

		public static GameObject LoadSantaHat(AssetBundle customAssets)
		{
			GameObject result = customAssets.LoadAsset<GameObject>("assets/hatparent.prefab");
			JollyLethal.PluginLogInfoWithPrefix("Successfully loaded in santa hat");
			return result;
		}
	}
	internal class EnemyHatConfigs
	{
		internal static (string?, Vector3, Vector3, float) GetBrackenSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("FlowermanModel/AnimContainer/metarig/Torso1/Torso2/Torso3/Neck1/Neck2/Head1/Head2", new Vector3(0f, 0f, 0f), new Vector3(0f, 115f, 0f), 2f);
		}

		internal static (string?, Vector3, Vector3, float) GetHoardingBugSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("HoarderBugModel/AnimContainer/Armature/Abdomen/Chest/Head", new Vector3(0.25f, 2.2f, 0.1f), new Vector3(15f, 20f, 330f), 3f);
		}

		internal static (string?, Vector3, Vector3, float) GetSnareFleaSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("CentipedeModel/AnimContainer/Armature/Head", new Vector3(0f, 0.4f, 0.25f), new Vector3(0f, 90f, 90f), 1.5f);
		}

		internal static (string?, Vector3, Vector3, float) GetThumperSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("CrawlerModel/AnimContainer/metarig/spine/spine.003/spine.004", new Vector3(0f, 0.2635f, -0.02f), new Vector3(64f, 168f, 341f), 0.3f);
		}

		internal static (string?, Vector3, Vector3, float) GetBunkerSpiderSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("MeshContainer/AnimContainer/Armature/Head", new Vector3(0f, 0.9101f, 0.5545f), new Vector3(19f, 274f, 252f), 1.7525f);
		}

		internal static (string?, Vector3, Vector3, float) GetJesterSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("MeshContainer/AnimContainer/metarig/BoxContainer/spine.004/spine.005", new Vector3(-2.32f, -8.6f, 2.75f), new Vector3(344f, 292f, 181f), 18f);
		}

		internal static (string?, Vector3, Vector3, float) GetJesterPoppedSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("MeshContainer/AnimContainer/metarig/BoxContainer/spine.004/spine.005/spine.006/UpperJaw", new Vector3(0f, 0.1f, 1.2f), new Vector3(0f, 115f, 0f), 3f);
		}

		internal static (string?, Vector3, Vector3, float) GetNutcrackerSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("MeshContainer/AnimContainer/metarig/spinecontainer/spine/spine.001/head", new Vector3(0f, 0.5f, 0f), new Vector3(0f, 115f, 0f), 0.668f);
		}

		internal static (string?, Vector3, Vector3, float) GetSpringSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("SpringManModel/AnimContainer/metarig/spine/spine.001/spine.002/spine.003/springBone/springBone.001/springBone.002", new Vector3(0f, 0.3f, 0f), new Vector3(0f, 115f, 0f), 0.25f);
		}

		internal static (string?, Vector3, Vector3, float) GetMaskedSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004", new Vector3(0f, 0.27f, 0.05f), new Vector3(0f, 115f, 0f), 0.55f);
		}

		internal static (string?, Vector3, Vector3, float) GetButlerSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("MeshContainer/metarig/spine/spine.001/NeckContainer/spine.004/face", new Vector3(0f, 0.3f, 0f), new Vector3(0f, 115f, 0f), 0.8f);
		}

		internal static (string?, Vector3, Vector3, float) GetManeaterSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("BabyMeshContainer/BabyAnimContainer/Spine1/Spine3", new Vector3(-0.0067f, 0.4368f, 0.0076f), new Vector3(302f, 358f, 1f), 2f);
		}

		internal static (string?, Vector3, Vector3, float) GetManeaterBigSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("MeshContainer/AnimContainer/Spine/Spine1/Spine2/Bone.003", new Vector3(0f, 0f, -0.5f), new Vector3(280f, 180f, 180f), 3f);
		}

		internal static (string?, Vector3, Vector3, float) GetSporeLizardSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("PufferModel/AnimContainer/Armature/Base/Chest/Neck", new Vector3(0.5f, 0.5f, 0f), new Vector3(30f, 10f, 290f), 1f);
		}

		internal static (string?, Vector3, Vector3, float) GetMouthDogSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("MouthDogModel/AnimContainer/Armature/Neck1Container/Neck1/Neck2/JawUpper/", new Vector3(0f, 0.233f, -0.5545f), new Vector3(20f, 80f, 240f), 2.5f);
		}

		internal static (string?, Vector3, Vector3, float) GetBaboonHawkSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("BaboonBirdModel/AnimContainer/metarig/spine/spine.001/spine.003/spine.004/HeadBoneContainer", new Vector3(0f, 0.3f, 0.25f), new Vector3(0f, 90f, 0f), 0.7f);
		}

		internal static (string?, Vector3, Vector3, float) GetForestGiantSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("FGiantModelContainer/AnimContainer/metarig/spine/spine.003", new Vector3(0f, 0.5f, 0.05f), new Vector3(0f, 115f, 0f), 0.6f);
		}

		internal static (string?, Vector3, Vector3, float) GetOldBirdSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("MeshContainer/AnimContainer/metarig/TorsoContainer/Torso", new Vector3(0f, 4.4f, 0f), new Vector3(0f, 25f, 0f), 2.5f);
		}

		internal static (string?, Vector3, Vector3, float) GetTulipSnakeSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("FlowerLizardModel/AnimContainer/Armature/Belly/LowerChest/Chest/Chest.001/JawUpper/", new Vector3(0f, 0.6f, 0.4f), new Vector3(48f, 270f, 270f), 2f);
		}

		internal static (string?, Vector3, Vector3, float) GetGirlSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("DressGirlModel/AnimContainer/metarig/spine/spine.002/spine.003/spine.004", new Vector3(0f, 0.27f, -0.035f), new Vector3(10f, 115f, 340f), 0.4f);
		}

		internal static (string?, Vector3, Vector3, float) GetBlobSantaHatConfig()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ("Armature/Center", new Vector3(0f, 1.6f, 0f), new Vector3(0f, 170f, 0f), 3f);
		}

		internal static (string?, Vector3, Vector3, float) GetKidnapperFoxSantaHatConfig()
		{
			return GetIncompatibleSantaHatConfig();
		}

		internal static (string?, Vector3, Vector3, float) GetBarberSantaHatConfig()
		{
			return GetIncompatibleSantaHatConfig();
		}

		internal static (string?, Vector3, Vector3, float) GetIncompatibleSantaHatConfig()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return (null, Vector3.zero, Vector3.zero, 0f);
		}

		internal static (string?, Vector3, Vector3, float) GetDefaultSantaHatConfig()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return (null, Vector3.zero, Vector3.zero, 0f);
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class FixHatPositionOnEnemyStateChange
	{
		[CompilerGenerated]
		private sealed class <HandleManeaterStateChange>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int state;

			public Transform enemy;

			public Transform hat;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: 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_010a: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: 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_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: 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_00ad: 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)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					JollyLethal.PluginLogInfoWithPrefix("Handling Maneaters change of state");
					if (state != 2 && IsManeaterInBabyState(enemy))
					{
						JollyLethal.PluginLogInfoWithPrefix("Changing hat position due to change of maneater appearance to smol");
						(string?, Vector3, Vector3, float) maneaterSantaHatConfig = EnemyHatConfigs.GetManeaterSantaHatConfig();
						string item = maneaterSantaHatConfig.Item1;
						Vector3 item2 = maneaterSantaHatConfig.Item2;
						Vector3 item3 = maneaterSantaHatConfig.Item3;
						float item4 = maneaterSantaHatConfig.Item4;
						Transform val = enemy.Find(item);
						hat.SetParent(val, false);
						JollyHatActions.ApplyOffsetsToHat(hat, item2, item3, item4);
					}
					else
					{
						JollyLethal.PluginLogInfoWithPrefix("Changing hat position due to change of maneater appearance to big");
						(string?, Vector3, Vector3, float) maneaterBigSantaHatConfig = EnemyHatConfigs.GetManeaterBigSantaHatConfig();
						string item5 = maneaterBigSantaHatConfig.Item1;
						Vector3 item6 = maneaterBigSantaHatConfig.Item2;
						Vector3 item7 = maneaterBigSantaHatConfig.Item3;
						float item8 = maneaterBigSantaHatConfig.Item4;
						Transform val2 = enemy.Find(item5);
						hat.SetParent(val2, false);
						JollyHatActions.ApplyOffsetsToHat(hat, item6, item7, item8);
					}
					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();
			}
		}

		[HarmonyPatch("SwitchToBehaviourStateOnLocalClient")]
		[HarmonyPostfix]
		private static void FixEnemyHatPosition(EnemyAI __instance, int stateIndex)
		{
			Transform val = RecursiveFindChild(((Component)__instance).transform, "mishelin.JollyLethal.JollyHatParent");
			if (val == null)
			{
				return;
			}
			string enemyName = __instance.enemyType.enemyName;
			if (!(enemyName == "Jester"))
			{
				if (enemyName == "Maneater")
				{
					((MonoBehaviour)__instance).StartCoroutine(HandleManeaterStateChange(((Component)__instance).transform, val, stateIndex));
				}
			}
			else
			{
				HandleJesterStateChange(((Component)__instance).transform, val, stateIndex);
			}
		}

		private static void HandleJesterStateChange(Transform enemy, Transform hat, int state)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0080: 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)
			JollyLethal.PluginLogInfoWithPrefix("Handling Jesters change of state");
			switch (state)
			{
			case 0:
			case 1:
			{
				JollyLethal.PluginLogInfoWithPrefix("Changing hat position due to change of jester state to winding/chilling");
				(string?, Vector3, Vector3, float) jesterSantaHatConfig = EnemyHatConfigs.GetJesterSantaHatConfig();
				Vector3 item5 = jesterSantaHatConfig.Item2;
				Vector3 item6 = jesterSantaHatConfig.Item3;
				float item7 = jesterSantaHatConfig.Item4;
				JollyHatActions.ApplyOffsetsToHat(hat, item5, item6, item7);
				break;
			}
			case 2:
			{
				JollyLethal.PluginLogInfoWithPrefix("Changing hat position due to change of jester state to popped");
				(string?, Vector3, Vector3, float) jesterPoppedSantaHatConfig = EnemyHatConfigs.GetJesterPoppedSantaHatConfig();
				string item = jesterPoppedSantaHatConfig.Item1;
				Vector3 item2 = jesterPoppedSantaHatConfig.Item2;
				Vector3 item3 = jesterPoppedSantaHatConfig.Item3;
				float item4 = jesterPoppedSantaHatConfig.Item4;
				Transform val = enemy.Find(item);
				hat.SetParent(val, false);
				JollyHatActions.ApplyOffsetsToHat(hat, item2, item3, item4);
				break;
			}
			}
		}

		[IteratorStateMachine(typeof(<HandleManeaterStateChange>d__2))]
		private static IEnumerator HandleManeaterStateChange(Transform enemy, Transform hat, int state)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <HandleManeaterStateChange>d__2(0)
			{
				enemy = enemy,
				hat = hat,
				state = state
			};
		}

		internal static bool IsManeaterInBabyState(Transform maneater)
		{
			if (((Component)maneater.Find("BabyMeshContainer")).gameObject.activeSelf)
			{
				return !((Component)maneater.Find("MeshContainer")).gameObject.activeSelf;
			}
			return false;
		}

		internal static Transform? RecursiveFindChild(Transform parent, string childName)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name == childName)
				{
					return val;
				}
				Transform val2 = RecursiveFindChild(val, childName);
				if (val2 != null)
				{
					return val2;
				}
			}
			return null;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class EnemyDumper
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void DumpEveryEnemy()
		{
			JollyLethal.PluginLogInfoWithPrefix("=== STARTING ENEMY NAME DUMP ===");
			EnemyType[] source = Resources.FindObjectsOfTypeAll<EnemyType>();
			IOrderedEnumerable<string> orderedEnumerable = from n in source.Select((EnemyType e) => e.enemyName).Distinct()
				orderby n
				select n;
			foreach (string item in orderedEnumerable)
			{
				JollyLethal.PluginLogInfoWithPrefix("Found Enemy Name: \"" + item + "\"");
			}
			JollyLethal.PluginLogInfoWithPrefix("=== DUMP FINISHED ===");
		}
	}
	internal class JollyHatActions
	{
		internal static bool DoesTransformAlreadyContainJollyHat(Transform parent, string pathToObject)
		{
			return parent.Find(pathToObject + "/mishelin.JollyLethal.JollyHatParent") != null;
		}

		internal static void FixHatParentChildPosScale(Transform parent)
		{
			//IL_0009: 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)
			Transform child = parent.GetChild(0);
			ApplyOffsetsToHat(child, Vector3.zero, Vector3.zero, 1f);
		}

		internal static void ApplyOffsetsToHat(Transform obj, Vector3 pos, Vector3 rot, float scale)
		{
			//IL_0001: 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_000f: 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)
			obj.localPosition = pos;
			obj.localEulerAngles = rot;
			obj.localScale = Vector3.one * scale;
		}

		internal static void ChangeRotOfHatParentChild(Transform hatParent, Vector3 newRot)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Transform child = hatParent.GetChild(0);
			child.localEulerAngles = newRot;
		}
	}
	[BepInPlugin("mishelin.JollyLethal", "JollyLethal", "1.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
	public class JollyLethal : BaseUnityPlugin
	{
		internal static AssetBundle? myCustomAssets;

		internal static GameObject mySantaHat;

		internal const string JollyHatSpawnedObjName = "mishelin.JollyLethal.JollyHatParent";

		public static JollyLethal Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			LoadAssets();
			Patch();
			Logger.LogInfo((object)"mishelin.JollyLethal v1.1.2 has loaded!");
		}

		internal void LoadAssets()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			myCustomAssets = AssetLoader.AssetsAwake(directoryName);
			if (myCustomAssets != null)
			{
				mySantaHat = AssetLoader.LoadSantaHat(myCustomAssets);
			}
		}

		internal static void Patch()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("mishelin.JollyLethal");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}

		internal static void PluginLogInfoWithPrefix(string content)
		{
			Logger.LogInfo((object)("[EVIL] " + content));
		}

		internal static void PluginLogErrorWithPrefix(string content)
		{
			Logger.LogError((object)("[EVIL] " + content));
		}
	}
	internal class ObjectHatConfigs
	{
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	internal class PlaceHatOnMaskedPatch
	{
		[CompilerGenerated]
		private sealed class <GiveHatToMaskedCoroutine>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MaskedPlayerEnemy enemy;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				//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_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: 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(1.5f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					JollyLethal.PluginLogInfoWithPrefix("Placing santa hat on masked");
					if (enemy == null || ((EnemyAI)enemy).isEnemyDead)
					{
						return false;
					}
					var (text, posOffset, rotOffset, scale) = PlaceHatsOnEnemiesPatch.GetEnemyHatConfig("Masked");
					if (text == null)
					{
						return false;
					}
					Transform hatPlaceTransform = PlaceHatsOnEnemiesPatch.GetHatPlaceTransform(((Component)enemy).transform, text);
					PlaceHatsOnEnemiesPatch.SpawnSantaHatOnEnemy(hatPlaceTransform, posOffset, rotOffset, scale);
					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();
			}
		}

		private const float myWaitForSeconds = 1.5f;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void GiveHatToMasked(MaskedPlayerEnemy __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(GiveHatToMaskedCoroutine(__instance));
		}

		[IteratorStateMachine(typeof(<GiveHatToMaskedCoroutine>d__2))]
		private static IEnumerator GiveHatToMaskedCoroutine(MaskedPlayerEnemy enemy)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GiveHatToMaskedCoroutine>d__2(0)
			{
				enemy = enemy
			};
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class PlaceHatsOnItemsPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void GiveEnemySantaHat(GrabbableObject __instance)
		{
			if (JollyLethal.myCustomAssets == null)
			{
				JollyLethal.PluginLogErrorWithPrefix("AssetBundle not loaded!!!");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlaceHatOnPlayerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void GiveHatToPlayer(PlayerControllerB __instance)
		{
		}

		private static bool ShouldPlaceHatOnPlayersHat(PlayerControllerB __instance)
		{
			string item = PlaceHatsOnEnemiesPatch.GetEnemyHatConfig("Masked").Item1;
			if (!((NetworkBehaviour)__instance).IsOwner && !__instance.isPlayerDead && __instance.isPlayerControlled)
			{
				return !JollyHatActions.DoesTransformAlreadyContainJollyHat(((Component)__instance).transform, item);
			}
			return false;
		}

		private static void SetLayerRecursively(GameObject obj, int newLayer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			obj.layer = newLayer;
			foreach (Transform item in obj.transform)
			{
				Transform val = item;
				SetLayerRecursively(((Component)val).gameObject, newLayer);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class PlaceHatsOnEnemiesPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void GiveEnemySantaHat(EnemyAI __instance)
		{
			if (JollyLethal.myCustomAssets == null)
			{
				JollyLethal.PluginLogErrorWithPrefix("AssetBundle not loaded!!!");
			}
			else
			{
				PlaceHatOnEnemyTransform(((Component)__instance).transform, __instance.enemyType);
			}
		}

		internal static void PlaceHatOnEnemyTransform(Transform enemyTransform, EnemyType enemyType)
		{
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			string enemyName = enemyType.enemyName;
			var (text, posOffset, rotOffset, scale) = GetEnemyHatConfig(enemyName);
			if (text != null && !JollyHatActions.DoesTransformAlreadyContainJollyHat(enemyTransform, text))
			{
				Transform hatPlaceTransform = GetHatPlaceTransform(enemyTransform, text);
				Transform hatParent = SpawnSantaHatOnEnemy(hatPlaceTransform, posOffset, rotOffset, scale);
				FixAdditionalChildrenPositions(enemyName, hatParent);
			}
		}

		private static void FixAdditionalChildrenPositions(string enemyName, Transform hatParent)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (!(enemyName == "Crawler"))
			{
				if (enemyName == "Maneater")
				{
					JollyHatActions.ChangeRotOfHatParentChild(hatParent, new Vector3(0f, 115f, 0f));
				}
			}
			else
			{
				JollyHatActions.ChangeRotOfHatParentChild(hatParent, new Vector3(0f, 285f, 0f));
			}
		}

		internal static Transform SpawnSantaHatOnEnemy(Transform targetBone, Vector3 posOffset, Vector3 rotOffset, float scale)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(JollyLethal.mySantaHat, targetBone);
			((Object)val).name = "mishelin.JollyLethal.JollyHatParent";
			Transform transform = val.transform;
			JollyHatActions.FixHatParentChildPosScale(transform);
			JollyHatActions.ApplyOffsetsToHat(transform, posOffset, rotOffset, scale);
			return transform;
		}

		internal static Transform GetHatPlaceTransform(Transform enemyTransform, string? bonePath)
		{
			Transform val = ((Component)enemyTransform).transform.Find(bonePath);
			if (val != null)
			{
				return val;
			}
			return ((Component)enemyTransform).transform;
		}

		internal static (string?, Vector3, Vector3, float) GetEnemyHatConfig(string enemyName)
		{
			JollyLethal.PluginLogInfoWithPrefix("Placing hat on: " + enemyName);
			switch (enemyName)
			{
			case "Flowerman":
				return EnemyHatConfigs.GetBrackenSantaHatConfig();
			case "Hoarding bug":
				return EnemyHatConfigs.GetHoardingBugSantaHatConfig();
			case "Centipede":
				return EnemyHatConfigs.GetSnareFleaSantaHatConfig();
			case "Crawler":
				return EnemyHatConfigs.GetThumperSantaHatConfig();
			case "Bunker Spider":
				return EnemyHatConfigs.GetBunkerSpiderSantaHatConfig();
			case "Jester":
				return EnemyHatConfigs.GetJesterSantaHatConfig();
			case "Nutcracker":
				return EnemyHatConfigs.GetNutcrackerSantaHatConfig();
			case "Spring":
				return EnemyHatConfigs.GetSpringSantaHatConfig();
			case "Masked":
				return EnemyHatConfigs.GetMaskedSantaHatConfig();
			case "Butler":
				return EnemyHatConfigs.GetButlerSantaHatConfig();
			case "Maneater":
				return EnemyHatConfigs.GetManeaterSantaHatConfig();
			case "Puffer":
				return EnemyHatConfigs.GetSporeLizardSantaHatConfig();
			case "Blob":
				return EnemyHatConfigs.GetBlobSantaHatConfig();
			case "Girl":
				return EnemyHatConfigs.GetGirlSantaHatConfig();
			case "MouthDog":
				return EnemyHatConfigs.GetMouthDogSantaHatConfig();
			case "Baboon hawk":
				return EnemyHatConfigs.GetBaboonHawkSantaHatConfig();
			case "ForestGiant":
				return EnemyHatConfigs.GetForestGiantSantaHatConfig();
			case "RadMech":
				return EnemyHatConfigs.GetOldBirdSantaHatConfig();
			case "Tulip Snake":
				return EnemyHatConfigs.GetTulipSnakeSantaHatConfig();
			case "Bush Wolf":
				return EnemyHatConfigs.GetKidnapperFoxSantaHatConfig();
			case "Clay Surgeon":
				JollyLethal.PluginLogInfoWithPrefix("Skipping hat for incompatible enemy: " + enemyName);
				return EnemyHatConfigs.GetBarberSantaHatConfig();
			case "Manticoil":
			case "GiantKiwi":
			case "Red pill":
			case "Butler Bees":
			case "Earth Leviathan":
			case "Red Locust Bees":
			case "Docile Locust Bees":
			case "Lasso":
				JollyLethal.PluginLogInfoWithPrefix("Skipping hat for incompatible enemy: " + enemyName);
				return EnemyHatConfigs.GetIncompatibleSantaHatConfig();
			default:
				JollyLethal.PluginLogErrorWithPrefix("Enemy '" + enemyName + "' not in config. Defaulting to 'Head'.");
				return EnemyHatConfigs.GetDefaultSantaHatConfig();
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class PutHatOnDormantOldBird
	{
		[HarmonyPatch("SpawnNestObjectForOutsideEnemy")]
		[HarmonyPostfix]
		private static void AddHatToDormantOldBird(RoundManager __instance)
		{
			foreach (EnemyAINestSpawnObject enemyNestSpawnObject in __instance.enemyNestSpawnObjects)
			{
				string enemyName = enemyNestSpawnObject.enemyType.enemyName;
				JollyLethal.PluginLogInfoWithPrefix("NestSpawn: " + enemyName);
				if (enemyName == "RadMech")
				{
					PlaceHatOnDormantOldBird(enemyNestSpawnObject);
				}
			}
		}

		private static void PlaceHatOnDormantOldBird(EnemyAINestSpawnObject enemy)
		{
			JollyLethal.PluginLogInfoWithPrefix("Dormant birdo");
			PlaceHatsOnEnemiesPatch.PlaceHatOnEnemyTransform(((Component)enemy).transform, enemy.enemyType);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "mishelin.JollyLethal";

		public const string PLUGIN_NAME = "JollyLethal";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}
namespace JollyLethal.Patches
{
	[HarmonyPatch(typeof(TVScript))]
	public class ExampleTVPatch
	{
		[HarmonyPatch("SwitchTVLocalClient")]
		[HarmonyPrefix]
		private static void SwitchTVPrefix(TVScript __instance)
		{
			StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(__instance.tvOn);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}