Decompiled source of REPO Poggibonsese v1.0.0

BeepInEx/plugins/Ako-FunnyItems/PlaySoundBeforeDestroy.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SoundDestroy")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SoundDestroy")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f707df40-0c2b-4ba0-bfba-73eeef2369d1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public class PlaySoundBeforeDestroy : MonoBehaviour
{
	private AudioSource audioSource;

	private bool isDestroying = false;

	private void Start()
	{
		audioSource = ((Component)this).GetComponent<AudioSource>();
		if ((Object)(object)audioSource == (Object)null)
		{
			Debug.LogError((object)("No AudioSource found on " + ((Object)((Component)this).gameObject).name));
		}
	}

	private void OnDestroy()
	{
		if (!isDestroying && (Object)(object)audioSource != (Object)null)
		{
			isDestroying = true;
			PlaySoundAndDestroy();
		}
	}

	private void PlaySoundAndDestroy()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)audioSource.clip != (Object)null)
		{
			AudioSource.PlayClipAtPoint(audioSource.clip, ((Component)this).transform.position, audioSource.volume);
		}
	}
}

BeepInEx/plugins/BlueAmulet-REPONetworkTweaks/REPONetworkTweaks.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("REPONetworkTweaks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPONetworkTweaks")]
[assembly: AssemblyCopyright("Copyright © BlueAmulet 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b71c6ed6-b7be-40af-a0ab-023cbc72986c")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
namespace REPONetworkTweaks
{
	public class PhotonTransformViewTweak : MonoBehaviour
	{
		private class TransformSnapshot
		{
			internal Vector3 position;

			internal Quaternion rotation;

			internal Vector3 velocity;

			internal Vector3 angularVelocity;

			internal TransformSnapshot(Vector3 position, Quaternion rotation, Vector3 velocity, Vector3 angularVelocity)
			{
				//IL_0007: 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_000e: 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)
				//IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references)
				this.position = position;
				this.rotation = rotation;
				this.velocity = velocity;
				this.angularVelocity = angularVelocity;
			}
		}

		private Rigidbody rigidBody;

		private PhotonTransformView photonTransformView;

		private PhysGrabHinge hinge;

		private Vector3 m_StoredPosition;

		private bool teleport;

		private bool isSleeping;

		private bool isKinematic;

		private Vector3 interpVelocity;

		private Vector3 interpAngularVelocity;

		private readonly LinkedList<TransformSnapshot> snapshots = new LinkedList<TransformSnapshot>();

		private TransformSnapshot prevSnapshot;

		private float interpolationStartTime = -1f;

		private float smoothUpdateFrequency = (float)PhotonNetwork.serializationFrequency / 1000f;

		private float lastSerializationFrequency = -1f;

		private int lastSendTimestamp;

		private bool haveFirstSend;

		private float interpFactor
		{
			get
			{
				if (!(smoothUpdateFrequency <= 0f) && !(interpolationStartTime < 0f))
				{
					return (Time.timeSinceLevelLoad - interpolationStartTime) / smoothUpdateFrequency;
				}
				return 1f;
			}
		}

		public void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			rigidBody = ((Component)this).GetComponent<Rigidbody>();
			photonTransformView = ((Component)this).GetComponent<PhotonTransformView>();
			hinge = ((Component)this).GetComponent<PhysGrabHinge>();
			m_StoredPosition = ((Component)this).transform.position;
		}

		public void OnEnable()
		{
			snapshots.Clear();
			prevSnapshot = null;
		}

		internal void Teleport(Vector3 _position, Quaternion _rotation)
		{
			//IL_000d: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			teleport = true;
			((Component)this).transform.position = _position;
			((Component)this).transform.rotation = _rotation;
			rigidBody.position = _position;
			rigidBody.rotation = _rotation;
			m_StoredPosition = _position;
			isSleeping = false;
			rigidBody.WakeUp();
		}

		private Vector3 HermiteInterpolatePosition(Vector3 startPos, Vector3 startVel, Vector3 endPos, Vector3 endVel, float interpolation)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001f: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = startPos + startVel * (smoothUpdateFrequency * interpolation) / 3f;
			Vector3 val2 = endPos - endVel * (smoothUpdateFrequency * (1f - interpolation)) / 3f;
			return Vector3.Lerp(val, val2, interpolation);
		}

		private Quaternion HermiteInterpolateRotation(Quaternion startRot, Vector3 startSpin, Quaternion endRot, Vector3 endSpin, float interpolation)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = startRot * Quaternion.Euler(startSpin * (smoothUpdateFrequency * interpolation) / 3f);
			Quaternion val2 = endRot * Quaternion.Euler(endSpin * (-1f * smoothUpdateFrequency * (1f - interpolation)) / 3f);
			return Quaternion.Slerp(val, val2, interpolation);
		}

		public void Update()
		{
			//IL_0185: 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_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_011b: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)this).transform;
			if (PhotonNetwork.IsMasterClient)
			{
				return;
			}
			rigidBody.isKinematic = true;
			rigidBody.interpolation = (RigidbodyInterpolation)0;
			if (snapshots.Count < 1)
			{
				return;
			}
			while (interpFactor >= 1f && snapshots.Count > 1)
			{
				prevSnapshot = snapshots.First.Value;
				snapshots.RemoveFirst();
				interpolationStartTime += smoothUpdateFrequency;
			}
			if (snapshots.Count == 1)
			{
				TransformSnapshot value = snapshots.First.Value;
				if (prevSnapshot != null && Settings.Extrapolate.Value)
				{
					float num = 2f - Mathf.Pow(MathF.E, 0f - interpFactor);
					transform.position = value.position + Vector3.SlerpUnclamped(prevSnapshot.velocity, value.velocity, num) * ((num - 1f) * smoothUpdateFrequency);
					transform.rotation = Quaternion.SlerpUnclamped(prevSnapshot.rotation, value.rotation, num);
				}
				else
				{
					transform.position = value.position;
					transform.rotation = value.rotation;
				}
				interpVelocity = value.velocity;
				interpAngularVelocity = value.angularVelocity;
			}
			else
			{
				LinkedListNode<TransformSnapshot>? first = snapshots.First;
				TransformSnapshot value2 = first.Value;
				TransformSnapshot value3 = first.Next.Value;
				transform.position = HermiteInterpolatePosition(value2.position, value2.velocity, value3.position, value3.velocity, interpFactor);
				transform.rotation = HermiteInterpolateRotation(value2.rotation, value2.angularVelocity, value3.rotation, value3.angularVelocity, interpFactor);
				interpVelocity = Vector3.Slerp(value2.velocity, value3.velocity, interpFactor);
				interpAngularVelocity = Vector3.Lerp(value2.angularVelocity, value3.angularVelocity, interpFactor);
			}
		}

		internal void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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)
			//IL_009f: 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_00a7: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: 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_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)this).transform;
			if (stream.IsWriting)
			{
				stream.SendNext((object)rigidBody.IsSleeping());
				stream.SendNext((object)teleport);
				teleport = false;
				isKinematic = rigidBody.isKinematic;
				stream.SendNext((object)isKinematic);
				stream.SendNext((object)rigidBody.velocity);
				stream.SendNext((object)rigidBody.angularVelocity);
				Vector3 val = transform.position - m_StoredPosition;
				m_StoredPosition = transform.position;
				stream.SendNext((object)transform.position);
				stream.SendNext((object)val);
				stream.SendNext((object)transform.rotation);
				return;
			}
			if (!Object.op_Implicit((Object)(object)rigidBody))
			{
				rigidBody = ((Component)this).GetComponent<Rigidbody>();
			}
			isSleeping = (bool)stream.ReceiveNext();
			if (isSleeping)
			{
				rigidBody.Sleep();
			}
			else
			{
				rigidBody.WakeUp();
			}
			teleport = (bool)stream.ReceiveNext();
			isKinematic = (bool)stream.ReceiveNext();
			Vector3 velocity = (Vector3)stream.ReceiveNext();
			Vector3 angularVelocity = (Vector3)stream.ReceiveNext();
			Vector3 position = (Vector3)stream.ReceiveNext();
			Vector3 val2 = (Vector3)stream.ReceiveNext();
			Quaternion rotation = (Quaternion)stream.ReceiveNext();
			if ((Object)(object)hinge != (Object)null && !hinge.broken)
			{
				velocity = ((!haveFirstSend) ? (val2 / smoothUpdateFrequency) : (val2 / (float)(((PhotonMessageInfo)(ref info)).SentServerTimestamp - lastSendTimestamp) * 1000f));
			}
			if (teleport)
			{
				snapshots.Clear();
				prevSnapshot = null;
			}
			float num = Mathf.Max(Settings.Future.Value * smoothUpdateFrequency, 0f);
			TransformSnapshot transformSnapshot = new TransformSnapshot(position, rotation, velocity, angularVelocity);
			if (snapshots.Count > 0 && (float)(((PhotonMessageInfo)(ref info)).SentServerTimestamp - lastSendTimestamp) / 1000f < Settings.TimingThreshold.Value)
			{
				TransformSnapshot value = snapshots.Last.Value;
				Vector3 val3 = (transformSnapshot.velocity - value.velocity) / smoothUpdateFrequency;
				transformSnapshot.position += transformSnapshot.velocity * num + 0.5f * val3 * num * num;
				Vector3 val4 = (transformSnapshot.angularVelocity - value.angularVelocity) / smoothUpdateFrequency;
				Quaternion val5 = Quaternion.Euler((transformSnapshot.angularVelocity + val4 * num) * num);
				transformSnapshot.rotation *= val5;
			}
			else
			{
				transformSnapshot.position += transformSnapshot.velocity * num;
				transformSnapshot.rotation *= Quaternion.Euler(transformSnapshot.angularVelocity * num);
			}
			snapshots.AddLast(transformSnapshot);
			if (snapshots.Count == 2)
			{
				interpolationStartTime = Time.timeSinceLevelLoad;
			}
			else if (snapshots.Count >= 4)
			{
				snapshots.RemoveFirst();
				TransformSnapshot value2 = snapshots.First.Value;
				value2.position = transform.position;
				value2.rotation = transform.rotation;
				value2.velocity = interpVelocity;
				value2.angularVelocity = interpAngularVelocity;
				interpolationStartTime = Time.timeSinceLevelLoad;
			}
			if (haveFirstSend)
			{
				lastSerializationFrequency = (float)(((PhotonMessageInfo)(ref info)).SentServerTimestamp - lastSendTimestamp) / 1000f;
				if (lastSerializationFrequency >= Settings.TimingThreshold.Value)
				{
					lastSerializationFrequency = (float)PhotonNetwork.serializationFrequency / 1000f;
					smoothUpdateFrequency = lastSerializationFrequency;
				}
				else
				{
					smoothUpdateFrequency = Mathf.Lerp(smoothUpdateFrequency, lastSerializationFrequency, Settings.RateSmoothing.Value);
				}
			}
			else
			{
				haveFirstSend = true;
			}
			lastSendTimestamp = ((PhotonMessageInfo)(ref info)).SentServerTimestamp;
		}
	}
	[BepInPlugin("BlueAmulet.REPONetworkTweaks", "REPONetworkTweaks", "1.0.2")]
	public class REPONetworkTweaks : BaseUnityPlugin
	{
		internal const string Name = "REPONetworkTweaks";

		internal const string Author = "BlueAmulet";

		internal const string ID = "BlueAmulet.REPONetworkTweaks";

		internal const string Version = "1.0.2";

		internal static ManualLogSource Log;

		public void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Settings.InitConfig(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("BlueAmulet.REPONetworkTweaks");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Applying Harmony patches");
			val.PatchAll(Assembly.GetExecutingAssembly());
			int num = 0;
			foreach (MethodBase patchedMethod in val.GetPatchedMethods())
			{
				_ = patchedMethod;
				num++;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)(num + " patches applied"));
		}
	}
	internal static class Settings
	{
		internal static ConfigEntry<bool> DisableTimeout;

		internal static ConfigEntry<bool> PhotonLateUpdate;

		internal static ConfigEntry<bool> Extrapolate;

		internal static ConfigEntry<float> RateSmoothing;

		internal static ConfigEntry<float> Future;

		internal static ConfigEntry<float> TimingThreshold;

		public static void InitConfig(ConfigFile config)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			DisableTimeout = config.Bind<bool>("NetworkTweaks", "DisableTimeout", true, "Remove client sided Photon timeout");
			PhotonLateUpdate = config.Bind<bool>("NetworkTweaks", "PhotonLateUpdate", true, "Run Photon networking in LateUpdate instead of FixedUpdate");
			Extrapolate = config.Bind<bool>("NetworkTweaks", "Extrapolate", true, "Extrapolate position and rotations when out of data");
			RateSmoothing = config.Bind<float>("NetworkTweaks", "RateSmoothing", 0.1f, new ConfigDescription("How much to smooth the guessed sending rate", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Future = config.Bind<float>("NetworkTweaks", "Future", 1f, new ConfigDescription("How much to project data into the future", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			TimingThreshold = config.Bind<float>("NetworkTweaks", "TimingThreshold", 1f, "Threshold in seconds for when data is considered discontinuous");
		}
	}
}
namespace REPONetworkTweaks.Patches
{
	[HarmonyPatch(typeof(PhotonHandler))]
	internal static class PhotonHandlerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Awake")]
		public static void PrefixAwake()
		{
			if (Settings.PhotonLateUpdate.Value)
			{
				REPONetworkTweaks.Log.LogInfo((object)"Changing PhotonHandler to run in LateUpdate");
				PhotonNetwork.MinimalTimeScaleToDispatchInFixedUpdate = float.PositiveInfinity;
			}
		}
	}
	[HarmonyPatch(typeof(PhotonTransformView))]
	internal static class PhotonTransformViewPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void PostfixAwake(ref PhotonTransformView __instance)
		{
			if (SemiFunc.IsMultiplayer())
			{
				((Component)__instance).gameObject.AddComponent<PhotonTransformViewTweak>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnPhotonSerializeView")]
		public static bool PrefixOnPhotonSerializeView(ref PhotonTransformView __instance, PhotonStream stream, PhotonMessageInfo info)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer())
			{
				((Component)__instance).GetComponent<PhotonTransformViewTweak>().OnPhotonSerializeView(stream, info);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("Teleport")]
		public static bool PrefixTeleport(ref PhotonTransformView __instance, Vector3 _position, Quaternion _rotation)
		{
			//IL_000e: 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)
			if (SemiFunc.IsMultiplayer())
			{
				((Component)__instance).GetComponent<PhotonTransformViewTweak>().Teleport(_position, _rotation);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static bool PrefixUpdate()
		{
			return !SemiFunc.IsMultiplayer();
		}
	}
	[HarmonyPatch]
	internal static class TimeoutDisconnectPatch
	{
		private static readonly MethodInfo debugOut = AccessTools.PropertyGetter(typeof(PeerBase), "debugOut");

		private static readonly MethodInfo EnqueueStatusCallback = AccessTools.Method(typeof(PeerBase), "EnqueueStatusCallback", (Type[])null, (Type[])null);

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(EnetPeer), "SendOutgoingCommands")]
		internal static IEnumerable<CodeInstruction> TranspilerEnetPeer(IEnumerable<CodeInstruction> instructions)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			if (!Settings.DisableTimeout.Value)
			{
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			for (int i = 1; i < list.Count; i++)
			{
				CodeInstruction val = list[i];
				if (val.opcode == OpCodes.Call && (MethodInfo)val.operand == debugOut && list[i + 1].opcode == OpCodes.Ldc_I4_2 && list[i - 3].opcode == OpCodes.Brfalse)
				{
					list.Insert(i - 2, new CodeInstruction(OpCodes.Br, list[i - 3].operand));
					list[i - 3].opcode = OpCodes.Pop;
					list[i - 3].operand = null;
					flag = true;
					break;
				}
			}
			if (flag)
			{
				REPONetworkTweaks.Log.LogInfo((object)"Removed TimeoutDisconnect from EnetPeer");
			}
			else
			{
				REPONetworkTweaks.Log.LogWarning((object)"Failed to locate patch to remove EnetPeer triggering TimeoutDisconnect");
			}
			return list;
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(TPeer), "DispatchIncomingCommands")]
		internal static IEnumerable<CodeInstruction> TranspilerTPeer(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			if (!Settings.DisableTimeout.Value)
			{
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			for (int i = 1; i < list.Count; i++)
			{
				CodeInstruction val = list[i];
				if (val.opcode == OpCodes.Ldc_I4 && (int)val.operand == 1040 && list[i + 1].opcode == OpCodes.Call && (MethodInfo)list[i + 1].operand == EnqueueStatusCallback && list[i - 3].opcode == OpCodes.Brfalse)
				{
					list.Insert(i - 2, new CodeInstruction(OpCodes.Br, list[i - 3].operand));
					list[i - 3].opcode = OpCodes.Pop;
					list[i - 3].operand = null;
					flag = true;
					break;
				}
			}
			if (flag)
			{
				REPONetworkTweaks.Log.LogInfo((object)"Removed TimeoutDisconnect from TPeer");
			}
			else
			{
				REPONetworkTweaks.Log.LogWarning((object)"Failed to locate patch to remove TPeer triggering TimeoutDisconnect");
			}
			return list;
		}
	}
}

BeepInEx/plugins/BlueAmulet-REPO_HD/REPO_HD.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("REPO_HD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPO_HD")]
[assembly: AssemblyCopyright("Copyright © BlueAmulet 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a9533aec-df57-4f5d-80ac-8f782ee8883c")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
namespace REPO_HD
{
	[BepInPlugin("BlueAmulet.REPO_HD", "REPO_HD", "1.0.2")]
	public class REPO_HD : BaseUnityPlugin
	{
		internal const string Name = "REPO_HD";

		internal const string Author = "BlueAmulet";

		internal const string ID = "BlueAmulet.REPO_HD";

		internal const string Version = "1.0.2";

		internal static ManualLogSource Log;

		public void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Settings.InitConfig(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("BlueAmulet.REPO_HD");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Applying Harmony patches");
			val.PatchAll(Assembly.GetExecutingAssembly());
			int num = 0;
			foreach (MethodBase patchedMethod in val.GetPatchedMethods())
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Patched " + patchedMethod.DeclaringType.Name + "." + patchedMethod.Name));
				num++;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)(num + " patches applied"));
		}
	}
	internal static class Settings
	{
		internal static ConfigEntry<bool> AntiAliasing;

		internal static ConfigEntry<bool> FlickerFix;

		public static void InitConfig(ConfigFile config)
		{
			AntiAliasing = config.Bind<bool>("REPO_HD", "AntiAliasing", true, "Apply TAA+SMAA antialiasing to the game");
			FlickerFix = config.Bind<bool>("REPO_HD", "FlickerFix", true, "Fix flickering text on extraction points");
		}
	}
}
namespace REPO_HD.Patches
{
	[HarmonyPatch(typeof(ExtractionPoint))]
	internal static class ExtractionPointPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		public static void PrefixStart(ref ExtractionPoint __instance)
		{
			//IL_0028: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.FlickerFix.Value)
			{
				REPO_HD.Log.LogInfo((object)"Fixing extraction point text flicker");
				Transform transform = __instance.haulGoalScreen.transform;
				transform.localPosition += new Vector3(0f, 0f, -0.001f);
			}
		}
	}
	[HarmonyPatch(typeof(GraphicsManager))]
	internal static class GraphicsPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("UpdateRenderSize")]
		public static bool PrefixUpdateRenderSize()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(RenderTextureMain))]
	internal static class RenderTexturePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void PostfixStart(ref RenderTextureMain __instance)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (!Settings.AntiAliasing.Value)
			{
				return;
			}
			for (int i = 0; i < __instance.cameras.Count; i++)
			{
				Camera val = __instance.cameras[i];
				PostProcessLayer component = ((Component)val).GetComponent<PostProcessLayer>();
				if ((Object)(object)component != (Object)null)
				{
					if (i == 0)
					{
						component.antialiasingMode = (Antialiasing)3;
						REPO_HD.Log.LogInfo((object)$"Enabled TAA on {val}");
					}
					else
					{
						component.antialiasingMode = (Antialiasing)2;
						REPO_HD.Log.LogInfo((object)$"Enabled SMAA on {val}");
					}
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static void PrefixUpdate(ref RenderTextureMain __instance)
		{
			__instance.textureWidthOriginal = Screen.width;
			__instance.textureHeightOriginal = Screen.height;
		}
	}
}

BeepInEx/plugins/BULLETBOT-MoreUpgrades/MoreUpgrades.dll

Decompiled 2 weeks ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CustomColors;
using HarmonyLib;
using MoreUpgrades.Classes;
using MoreUpgrades.Properties;
using Photon.Pun;
using REPOLib.Modules;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoreUpgrades")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreUpgrades")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5e12a72d-c200-488d-940a-653d1003d96e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreUpgrades
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("bulletbot.moreupgrades", "MoreUpgrades", "1.4.4")]
	internal class Plugin : BaseUnityPlugin
	{
		internal static class CustomColors
		{
			internal const string modGUID = "x753.CustomColors";

			internal static bool IsLoaded()
			{
				return Chainloader.PluginInfos.ContainsKey("x753.CustomColors");
			}

			internal static void OnAwake()
			{
				instance.PatchAll("CustomColorsPatches");
			}
		}

		private const string modGUID = "bulletbot.moreupgrades";

		private const string modName = "MoreUpgrades";

		private const string modVer = "1.4.4";

		internal static Plugin instance;

		internal ManualLogSource logger;

		private readonly Harmony harmony = new Harmony("bulletbot.moreupgrades");

		internal AssetBundle assetBundle;

		internal List<UpgradeItem> upgradeItems;

		private void PatchAll(string name)
		{
			foreach (Type item in from t in Assembly.GetExecutingAssembly().GetTypes()
				where t.Namespace == "MoreUpgrades." + name
				select t)
			{
				harmony.PatchAll(item);
			}
		}

		private GameObject GetVisualsFromComponent(Component component)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			GameObject val = null;
			if (((object)component).GetType() == typeof(EnemyParent))
			{
				EnemyParent val2 = (EnemyParent)(object)((component is EnemyParent) ? component : null);
				Enemy val3 = (Enemy)AccessTools.Field(typeof(EnemyParent), "Enemy").GetValue(component);
				try
				{
					val = ((Component)val2.EnableObject.gameObject.GetComponentInChildren<Animator>()).gameObject;
				}
				catch
				{
				}
				if ((Object)(object)val == (Object)null)
				{
					try
					{
						val = ((Component)((Component)val3).GetComponent<EnemyVision>().VisionTransform).gameObject;
					}
					catch
					{
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)val3).gameObject;
				}
			}
			else if (((object)component).GetType() == typeof(PlayerAvatar))
			{
				PlayerAvatar val4 = (PlayerAvatar)(object)((component is PlayerAvatar) ? component : null);
				val = ((Component)val4.playerAvatarVisuals).gameObject;
			}
			return val;
		}

		internal void AddEnemyToMap(Component component, string enemyName = null)
		{
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == "Map Enemy Tracker");
			if (upgradeItem == null)
			{
				return;
			}
			EnemyParent val = (EnemyParent)(object)((component is EnemyParent) ? component : null);
			if (val != null && enemyName == null)
			{
				enemyName = val.enemyName;
			}
			if ((from x in upgradeItem.GetConfig<string>("Exclude Enemies").Split(new char[1] { ',' })
				select x.Trim() into x
				where !string.IsNullOrEmpty(x)
				select x).Contains(enemyName))
			{
				return;
			}
			GameObject visuals = GetVisualsFromComponent(component);
			List<(GameObject, Color)> variable = upgradeItem.GetVariable<List<(GameObject, Color)>>("AddToMap");
			List<GameObject> variable2 = upgradeItem.GetVariable<List<GameObject>>("RemoveFromMap");
			if (!((Object)(object)visuals == (Object)null) && !variable.Any(((GameObject, Color) x) => (Object)(object)x.Item1 == (Object)(object)visuals))
			{
				if (variable2.Contains(visuals))
				{
					variable2.Remove(visuals);
				}
				variable.Add((visuals, upgradeItem.GetConfig<Color>("Color")));
			}
		}

		internal void RemoveEnemyFromMap(Component component, string enemyName = null)
		{
			UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == "Map Enemy Tracker");
			if (upgradeItem == null)
			{
				return;
			}
			EnemyParent val = (EnemyParent)(object)((component is EnemyParent) ? component : null);
			if (val != null && enemyName == null)
			{
				enemyName = val.enemyName;
			}
			if ((from x in upgradeItem.GetConfig<string>("Exclude Enemies").Split(new char[1] { ',' })
				select x.Trim() into x
				where !string.IsNullOrEmpty(x)
				select x).Contains(enemyName))
			{
				return;
			}
			GameObject visuals = GetVisualsFromComponent(component);
			List<(GameObject, Color)> variable = upgradeItem.GetVariable<List<(GameObject, Color)>>("AddToMap");
			List<GameObject> variable2 = upgradeItem.GetVariable<List<GameObject>>("RemoveFromMap");
			if ((Object)(object)visuals == (Object)null || variable2.Contains(visuals))
			{
				return;
			}
			if (variable.Any(((GameObject, Color) x) => (Object)(object)x.Item1 == (Object)(object)visuals))
			{
				variable.RemoveAll(((GameObject, Color) x) => (Object)(object)x.Item1 == (Object)(object)visuals);
			}
			variable2.Add(visuals);
		}

		internal void AddPlayerToMap(PlayerAvatar playerAvatar)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == "Map Player Tracker");
			if (upgradeItem == null)
			{
				return;
			}
			GameObject visuals = GetVisualsFromComponent((Component)(object)playerAvatar);
			List<(GameObject, Color)> variable = upgradeItem.GetVariable<List<(GameObject, Color)>>("AddToMap");
			List<GameObject> variable2 = upgradeItem.GetVariable<List<GameObject>>("RemoveFromMap");
			if (!((Object)(object)visuals == (Object)null) && !variable.Any(((GameObject, Color) x) => (Object)(object)x.Item1 == (Object)(object)visuals))
			{
				if (variable2.Contains(visuals))
				{
					variable2.Remove(visuals);
				}
				Color item = upgradeItem.GetConfig<Color>("Color");
				if (upgradeItem.GetConfig<bool>("Player Color"))
				{
					item = (Color)AccessTools.Field(typeof(PlayerAvatarVisuals), "color").GetValue(playerAvatar.playerAvatarVisuals);
				}
				variable.Add((visuals, item));
			}
		}

		internal void RemovePlayerToMap(PlayerAvatar playerAvatar)
		{
			UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == "Map Player Tracker");
			if (upgradeItem == null)
			{
				return;
			}
			GameObject visuals = GetVisualsFromComponent((Component)(object)playerAvatar);
			List<(GameObject, Color)> variable = upgradeItem.GetVariable<List<(GameObject, Color)>>("AddToMap");
			List<GameObject> variable2 = upgradeItem.GetVariable<List<GameObject>>("RemoveFromMap");
			if ((Object)(object)visuals == (Object)null || variable2.Contains(visuals))
			{
				return;
			}
			if (variable.Any(((GameObject, Color) x) => (Object)(object)x.Item1 == (Object)(object)visuals))
			{
				variable.RemoveAll(((GameObject, Color) x) => (Object)(object)x.Item1 == (Object)(object)visuals);
			}
			variable2.Add(visuals);
		}

		internal static float ItemValueMultiplier(float itemValueMultiplier, string itemAssetName)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return itemValueMultiplier;
			}
			return (instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.fullName == itemAssetName) != null) ? 1f : itemValueMultiplier;
		}

		internal static float UpgradeValueIncrease(float upgradeValueIncrease, string itemAssetName)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return upgradeValueIncrease;
			}
			UpgradeItem upgradeItem = instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.fullName == itemAssetName);
			if (upgradeItem == null)
			{
				return upgradeValueIncrease;
			}
			float num = (upgradeItem.HasConfig("Price Increase Scaling") ? upgradeItem.GetConfig<float>("Price Increase Scaling") : upgradeItem.upgradeItemBase.priceIncreaseScaling);
			if (num < 0f)
			{
				num = upgradeValueIncrease;
			}
			return num;
		}

		private void Awake()
		{
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			logger = Logger.CreateLogSource("MoreUpgrades");
			assetBundle = AssetBundle.LoadFromMemory(Resources.moreupgrades);
			if ((Object)(object)assetBundle == (Object)null)
			{
				logger.LogError((object)"Something went wrong when loading the asset bundle.");
				return;
			}
			upgradeItems = new List<UpgradeItem>();
			UpgradeItem sprintUsage = new UpgradeItem(new UpgradeItemBase
			{
				name = "Sprint Usage",
				maxAmount = 10,
				maxAmountInShop = 2,
				minPrice = 9000f,
				maxPrice = 14000f
			});
			sprintUsage.AddConfig("Scaling Factor", 0.1f, "Formula: energySprintDrain / (1 + (upgradeAmount * scalingFactor))");
			UpgradeItem upgradeItem2 = sprintUsage;
			upgradeItem2.onFixedUpdate = (Action)Delegate.Combine(upgradeItem2.onFixedUpdate, (Action)delegate
			{
				int amount = sprintUsage.GetAmount();
				if ((Object)(object)PlayerController.instance != (Object)null && amount != 0)
				{
					if (!sprintUsage.HasVariable("OriginalEnergySprintDrain"))
					{
						sprintUsage.AddVariable("OriginalEnergySprintDrain", PlayerController.instance.EnergySprintDrain);
					}
					float variable8 = sprintUsage.GetVariable<float>("OriginalEnergySprintDrain");
					PlayerController.instance.EnergySprintDrain = variable8 / (1f + (float)amount * sprintUsage.GetConfig<float>("Scaling Factor"));
				}
			});
			upgradeItems.Add(sprintUsage);
			UpgradeItem valuableCount = new UpgradeItem(new UpgradeItemBase
			{
				name = "Valuable Count",
				minPrice = 30000f,
				maxPrice = 40000f,
				maxPurchaseAmount = 1,
				priceIncreaseScaling = 0f
			});
			valuableCount.AddConfig("Display Total Value", defaultValue: true, "Whether to display the total value next to the valuable counter.");
			UpgradeItem upgradeItem3 = valuableCount;
			upgradeItem3.onInit = (Action)Delegate.Combine(upgradeItem3.onInit, (Action)delegate
			{
				valuableCount.AddVariable("CurrentValuables", new List<ValuableObject>());
				valuableCount.AddVariable("Changed", value: false);
				valuableCount.AddVariable("PreviousCount", 0);
				valuableCount.AddVariable("PreviousValue", 0);
				valuableCount.AddVariable("TextLength", 0);
			});
			UpgradeItem upgradeItem4 = valuableCount;
			upgradeItem4.onUpdate = (Action)Delegate.Combine(upgradeItem4.onUpdate, (Action)delegate
			{
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Expected O, but got Unknown
				if (!SemiFunc.RunIsLobby() && !SemiFunc.RunIsShop() && (Object)(object)MissionUI.instance != (Object)null && valuableCount.GetAmount() != 0)
				{
					TextMeshProUGUI val5 = (TextMeshProUGUI)AccessTools.Field(typeof(MissionUI), "Text").GetValue(MissionUI.instance);
					string text = (string)AccessTools.Field(typeof(MissionUI), "messagePrev").GetValue(MissionUI.instance);
					List<ValuableObject> variable3 = valuableCount.GetVariable<List<ValuableObject>>("CurrentValuables");
					bool variable4 = valuableCount.GetVariable<bool>("Changed");
					int variable5 = valuableCount.GetVariable<int>("PreviousCount");
					int variable6 = valuableCount.GetVariable<int>("PreviousValue");
					int variable7 = valuableCount.GetVariable<int>("TextLength");
					int count = variable3.Count;
					bool config = valuableCount.GetConfig<bool>("Display Total Value");
					int num3 = (config ? variable3.Select((ValuableObject x) => (int)x.dollarValueCurrent).Sum() : 0);
					if (!Utility.IsNullOrWhiteSpace(((TMP_Text)val5).text) && (variable4 || variable5 != count || variable6 != num3))
					{
						string text2 = ((TMP_Text)val5).text;
						if (!variable4 && (variable5 != count || variable6 != num3))
						{
							text2 = text2.Substring(0, text2.Length - variable7);
						}
						string text3 = $"\nValuables: <b>{count}</b>" + (config ? (" (<color=#558B2F>$</color><b>" + SemiFunc.DollarGetString(num3) + "</b>)") : "");
						text2 += text3;
						valuableCount.SetVariable("PreviousCount", count);
						valuableCount.SetVariable("PreviousValue", num3);
						valuableCount.SetVariable("TextLength", text3.Length);
						((TMP_Text)val5).text = text2;
						AccessTools.Field(typeof(MissionUI), "messagePrev").SetValue(MissionUI.instance, text2);
						if (variable4)
						{
							valuableCount.SetVariable("Changed", value: false);
						}
					}
				}
			});
			upgradeItems.Add(valuableCount);
			UpgradeItem mapEnemyTracker = new UpgradeItem(new UpgradeItemBase
			{
				name = "Map Enemy Tracker",
				minPrice = 50000f,
				maxPrice = 60000f,
				maxPurchaseAmount = 1,
				priceIncreaseScaling = 0f
			});
			mapEnemyTracker.AddConfig("Arrow Icon", defaultValue: true, "Whether the icon should appear as an arrow showing direction instead of a dot.");
			mapEnemyTracker.AddConfig<Color>("Color", Color.red, "The color of the icon.");
			mapEnemyTracker.AddConfig("Exclude Enemies", "", "Exclude specific enemies from displaying their icon by listing their names.\nExample: 'Gnome, Clown', seperated by commas.");
			UpgradeItem upgradeItem5 = mapEnemyTracker;
			upgradeItem5.onInit = (Action)Delegate.Combine(upgradeItem5.onInit, (Action)delegate
			{
				mapEnemyTracker.AddVariable("AddToMap", new List<(GameObject, Color)>());
				mapEnemyTracker.AddVariable("RemoveFromMap", new List<GameObject>());
			});
			UpgradeItem upgradeItem6 = mapEnemyTracker;
			upgradeItem6.onUpdate = (Action)Delegate.Combine(upgradeItem6.onUpdate, (Action)delegate
			{
				if (!SemiFunc.RunIsLobby() && !SemiFunc.RunIsShop())
				{
					UpdateTracker(mapEnemyTracker);
				}
			});
			upgradeItems.Add(mapEnemyTracker);
			UpgradeItem mapPlayerTracker = new UpgradeItem(new UpgradeItemBase
			{
				name = "Map Player Tracker",
				minPrice = 30000f,
				maxPrice = 40000f,
				maxPurchaseAmount = 1,
				priceIncreaseScaling = 0f
			});
			mapPlayerTracker.AddConfig("Arrow Icon", defaultValue: true, "Whether the icon should appear as an arrow showing direction instead of a dot.");
			mapPlayerTracker.AddConfig("Player Color", defaultValue: false, "Whether the icon should be colored as the player.");
			mapPlayerTracker.AddConfig<Color>("Color", Color.blue, "The color of the icon.");
			UpgradeItem upgradeItem7 = mapPlayerTracker;
			upgradeItem7.onInit = (Action)Delegate.Combine(upgradeItem7.onInit, (Action)delegate
			{
				mapPlayerTracker.AddVariable("AddToMap", new List<(GameObject, Color)>());
				mapPlayerTracker.AddVariable("RemoveFromMap", new List<GameObject>());
			});
			UpgradeItem upgradeItem8 = mapPlayerTracker;
			upgradeItem8.onUpdate = (Action)Delegate.Combine(upgradeItem8.onUpdate, (Action)delegate
			{
				UpdateTracker(mapPlayerTracker);
			});
			upgradeItems.Add(mapPlayerTracker);
			SceneManager.activeSceneChanged += delegate
			{
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Expected O, but got Unknown
				if (!((Object)(object)RunManager.instance == (Object)null) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelMainMenu) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobbyMenu))
				{
					GameObject val3 = new GameObject("More Upgrades Manager");
					PhotonView val4 = val3.AddComponent<PhotonView>();
					val4.ViewID = 1863;
					val3.AddComponent<MoreUpgradesManager>();
				}
			};
			logger.LogMessage((object)"MoreUpgrades has started.");
			PatchAll("Patches");
			if (CustomColors.IsLoaded())
			{
				CustomColors.OnAwake();
			}
			void UpdateTracker(UpgradeItem upgradeItem)
			{
				//IL_004d: 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_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)
				if ((Object)(object)SemiFunc.PlayerAvatarLocal() != (Object)null && upgradeItem.GetAmount() != 0)
				{
					List<(GameObject, Color)> variable = upgradeItem.GetVariable<List<(GameObject, Color)>>("AddToMap");
					for (int num = variable.Count - 1; num >= 0; num--)
					{
						var (val, color) = variable[num];
						variable.RemoveAt(num);
						MapCustom component = val.GetComponent<MapCustom>();
						if (!((Object)(object)component != (Object)null))
						{
							component = val.AddComponent<MapCustom>();
							component.color = color;
							component.sprite = (upgradeItem.GetConfig<bool>("Arrow Icon") ? assetBundle.LoadAsset<Sprite>("Map Tracker") : SemiFunc.PlayerAvatarLocal().playerDeathHead.mapCustom.sprite);
						}
					}
					List<GameObject> variable2 = upgradeItem.GetVariable<List<GameObject>>("RemoveFromMap");
					for (int num2 = variable2.Count - 1; num2 >= 0; num2--)
					{
						GameObject val2 = variable2[num2];
						variable2.RemoveAt(num2);
						MapCustom component2 = val2.GetComponent<MapCustom>();
						if (!((Object)(object)component2 == (Object)null))
						{
							Object.Destroy((Object)(object)((Component)component2.mapCustomEntity).gameObject);
							Object.Destroy((Object)(object)component2);
						}
					}
				}
			}
		}
	}
}
namespace MoreUpgrades.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("MoreUpgrades.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] moreupgrades
		{
			get
			{
				object @object = ResourceManager.GetObject("moreupgrades", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace MoreUpgrades.Patches
{
	[HarmonyPatch(typeof(ItemAttributes))]
	internal class ItemAttributesPatch
	{
		[HarmonyPatch("GetValue")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> GetValueTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(ShopManager), "instance"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "itemValueMultiplier"), (string)null)
			});
			val.Advance(1);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(ItemAttributes), "itemAssetName")),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "ItemValueMultiplier", (Type[])null, (Type[])null))
			});
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(ShopManager), "instance"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "upgradeValueIncrease"), (string)null)
			});
			val.Advance(1);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(ItemAttributes), "itemAssetName")),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "UpgradeValueIncrease", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar))]
	internal class PlayerAvatarPatch
	{
		[HarmonyPatch("LateStart")]
		[HarmonyPostfix]
		private static void LateStart(PlayerAvatar __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && !((Object)(object)__instance == (Object)(object)SemiFunc.PlayerAvatarLocal()))
			{
				Plugin.instance.AddPlayerToMap(__instance);
			}
		}

		[HarmonyPatch("ReviveRPC")]
		[HarmonyPostfix]
		private static void ReviveRPC(PlayerAvatar __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && !((Object)(object)__instance == (Object)(object)SemiFunc.PlayerAvatarLocal()))
			{
				Plugin.instance.AddPlayerToMap(__instance);
			}
		}

		[HarmonyPatch("PlayerDeathRPC")]
		[HarmonyPostfix]
		private static void PlayerDeathRPC(PlayerAvatar __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && !((Object)(object)__instance == (Object)(object)SemiFunc.PlayerAvatarLocal()))
			{
				Plugin.instance.RemovePlayerToMap(__instance);
				Plugin.instance.RemoveEnemyFromMap((Component)(object)__instance);
			}
		}

		[HarmonyPatch("SetColorRPC")]
		[HarmonyPostfix]
		private static void SetColorRPC(PlayerAvatar __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && !((Object)(object)__instance == (Object)(object)SemiFunc.PlayerAvatarLocal()))
			{
				UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == "Map Player Tracker");
				if (upgradeItem != null && upgradeItem.GetConfig<bool>("Player Color"))
				{
					Plugin.instance.RemovePlayerToMap(__instance);
					Plugin.instance.AddPlayerToMap(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(EnemySlowMouth))]
	internal class EnemySlowMouthPatch
	{
		[HarmonyPatch("UpdateStateRPC")]
		[HarmonyPostfix]
		private static void UpdateStateRPC(EnemySlowMouth __instance, Enemy ___enemy)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Invalid comparison between Unknown and I4
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Invalid comparison between Unknown and I4
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null || (Object)(object)___enemy == (Object)null)
			{
				return;
			}
			PlayerAvatar val = (PlayerAvatar)AccessTools.Field(typeof(EnemySlowMouth), "playerTarget").GetValue(__instance);
			EnemyParent val2 = (EnemyParent)AccessTools.Field(typeof(Enemy), "EnemyParent").GetValue(___enemy);
			State currentState = __instance.currentState;
			if ((int)currentState == 9)
			{
				Plugin.instance.RemoveEnemyFromMap((Component)(object)val2);
				if (!((Object)(object)val == (Object)(object)SemiFunc.PlayerAvatarLocal()))
				{
					Plugin.instance.RemovePlayerToMap(val);
					Plugin.instance.AddEnemyToMap((Component)(object)val, val2.enemyName);
				}
			}
			else if ((int)currentState == 11)
			{
				Plugin.instance.AddEnemyToMap((Component)(object)val2);
				if (!((Object)(object)val == (Object)(object)SemiFunc.PlayerAvatarLocal()))
				{
					Plugin.instance.AddPlayerToMap(val);
					Plugin.instance.RemoveEnemyFromMap((Component)(object)val, val2.enemyName);
				}
			}
		}
	}
	[HarmonyPatch(typeof(EnemyParent))]
	internal class EnemyParentPatch
	{
		[HarmonyPatch("SpawnRPC")]
		[HarmonyPostfix]
		private static void SpawnRPC(EnemyParent __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.AddEnemyToMap((Component)(object)__instance);
			}
		}

		[HarmonyPatch("DespawnRPC")]
		[HarmonyPostfix]
		private static void DespawnRPC(EnemyParent __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.RemoveEnemyFromMap((Component)(object)__instance);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyHealth))]
	internal class EnemyHealthPatch
	{
		[HarmonyPatch("DeathRPC")]
		[HarmonyPostfix]
		private static void DeathRPC(EnemyHealth __instance, Enemy ___enemy)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.RemoveEnemyFromMap((Component)(EnemyParent)AccessTools.Field(typeof(Enemy), "EnemyParent").GetValue(___enemy));
			}
		}
	}
	[HarmonyPatch(typeof(MissionUIPatch))]
	internal class MissionUIPatch
	{
		[HarmonyPatch(typeof(MissionUI), "MissionText")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(MissionUI), "messagePrev"), (string)null)
			}).Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MissionUIPatch), "MissionText", (Type[])null, (Type[])null))
			})
				.InstructionEnumeration();
		}

		private static void MissionText()
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == "Valuable Count")?.SetVariable("Changed", value: true);
			}
		}
	}
	[HarmonyPatch(typeof(StatsManager))]
	internal class StatsManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void Start(StatsManager __instance)
		{
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				__instance.dictionaryOfDictionaries.Add("playerUpgradeModded" + upgradeItem.saveName, upgradeItem.playerUpgrades);
				__instance.dictionaryOfDictionaries.Add("appliedPlayerUpgradeModded" + upgradeItem.saveName, upgradeItem.appliedPlayerUpgrades);
			}
		}

		[HarmonyPatch("FetchPlayerUpgrades")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> FetchPlayerUpgradesTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(KeyValuePair<string, Dictionary<string, int>>), "get_Key", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"playerUpgrade", (string)null)
			});
			object operand = val.Operand;
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(string), "Trim", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null)
			});
			object operand2 = val.Operand;
			val.Advance(1);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[5]
			{
				new CodeInstruction(OpCodes.Ldloca_S, operand),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(KeyValuePair<string, Dictionary<string, int>>), "get_Key", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Ldloc_S, operand2),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(StatsManagerPatch), "FetchPlayerUpgrades", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stloc_S, operand2)
			});
			return val.InstructionEnumeration();
		}

		private static string FetchPlayerUpgrades(string key, string text)
		{
			string prefix = "playerUpgradeModded";
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null || !key.StartsWith(prefix))
			{
				return text;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.saveName == key.Substring(prefix.Length));
			if (upgradeItem == null)
			{
				return text;
			}
			return upgradeItem.HasConfig("Display Name") ? upgradeItem.GetConfig<string>("Display Name") : upgradeItem.name;
		}
	}
	[HarmonyPatch(typeof(ValuableObject))]
	internal class ValuableObjectPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(ValuableObject __instance)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == "Valuable Count");
			if (upgradeItem != null)
			{
				List<ValuableObject> variable = upgradeItem.GetVariable<List<ValuableObject>>("CurrentValuables");
				if (!variable.Contains(__instance))
				{
					variable.Add(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabObject))]
	internal class PhysGrabObjectPatch
	{
		[HarmonyPatch("OnDestroy")]
		[HarmonyPostfix]
		private static void OnDestroy(PhysGrabObject __instance)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return;
			}
			ValuableObject component = ((Component)__instance).gameObject.GetComponent<ValuableObject>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == "Valuable Count");
			if (upgradeItem != null)
			{
				List<ValuableObject> variable = upgradeItem.GetVariable<List<ValuableObject>>("CurrentValuables");
				if (variable.Contains(component))
				{
					variable.Remove(component);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemUpgrade))]
	internal class ItemUpgradePatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(ItemUpgrade __instance)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)__instance).gameObject;
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.fullName == gameObject.GetComponent<ItemAttributes>().item.itemAssetName);
			if (upgradeItem == null)
			{
				return;
			}
			__instance.upgradeEvent = new UnityEvent();
			__instance.upgradeEvent.AddListener((UnityAction)delegate
			{
				if (upgradeItem.HasConfig("Allow Team Upgrades") && upgradeItem.GetConfig<bool>("Allow Team Upgrades"))
				{
					foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
					{
						MoreUpgradesManager.instance.Upgrade(upgradeItem.name, SemiFunc.PlayerGetSteamID(item));
					}
					return;
				}
				MoreUpgradesManager.instance.Upgrade(upgradeItem.name, SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID((int)AccessTools.Field(typeof(ItemToggle), "playerTogglePhotonID").GetValue(gameObject.GetComponent<ItemToggle>()))));
			});
		}
	}
	[HarmonyPatch(typeof(ShopManager))]
	internal class ShopManagerPatch
	{
		[HarmonyPatch("GetAllItemsFromStatsManager")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> GetAllItemsFromStatsManagerTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Expected O, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Expected O, but got Unknown
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Dictionary<string, Item>.ValueCollection.Enumerator), "get_Current", (Type[])null, (Type[])null), (string)null)
			});
			object operand = val.Operand;
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Dictionary<string, Item>.ValueCollection.Enumerator), "get_Current", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null)
			});
			val.Advance(1);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ShopManagerPatch), "GetAllItemsFromStatsManager", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Brtrue, operand)
			});
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "itemValueMultiplier"), (string)null)
			});
			val.Advance(1);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Item), "itemAssetName")),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "ItemValueMultiplier", (Type[])null, (Type[])null))
			});
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "upgradeValueIncrease"), (string)null)
			});
			val.Advance(1);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Item), "itemAssetName")),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "UpgradeValueIncrease", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}

		private static bool GetAllItemsFromStatsManager(Item item)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return false;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.fullName == item.itemAssetName);
			return upgradeItem != null && upgradeItem.HasConfig("Enabled") && !upgradeItem.GetConfig<bool>("Enabled");
		}
	}
}
namespace MoreUpgrades.CustomColorsPatches
{
	[HarmonyPatch(typeof(ModdedColorPlayerAvatar))]
	internal class ModdedColorPlayerAvatarPatch
	{
		[HarmonyPatch("ModdedSetColorRPC")]
		[HarmonyPostfix]
		private static void ModdedSetColorRPC(ModdedColorPlayerAvatar __instance)
		{
			PlayerAvatar avatar = __instance.avatar;
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && !((Object)(object)avatar == (Object)(object)SemiFunc.PlayerAvatarLocal()))
			{
				UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == "Map Player Tracker");
				if (upgradeItem != null && upgradeItem.GetConfig<bool>("Player Color"))
				{
					Plugin.instance.RemovePlayerToMap(avatar);
					Plugin.instance.AddPlayerToMap(avatar);
				}
			}
		}
	}
}
namespace MoreUpgrades.Classes
{
	public static class MoreUpgradesLib
	{
		public static bool IsManagerActive()
		{
			return (Object)(object)MoreUpgradesManager.instance != (Object)null;
		}

		public static IReadOnlyList<UpgradeItem> GetCoreUpgradeItems()
		{
			return Plugin.instance.upgradeItems.Where((UpgradeItem x) => x.modGUID == null).ToList();
		}

		public static IReadOnlyList<UpgradeItem> GetUpgradeItemsByMod(string modGUID)
		{
			return Plugin.instance.upgradeItems.Where((UpgradeItem x) => x.modGUID == modGUID).ToList();
		}

		public static UpgradeItem Register(string modGUID, Item item, GameObject prefab, UpgradeItemBase upgradeItemBase)
		{
			if (string.IsNullOrEmpty(modGUID))
			{
				Plugin.instance.logger.LogWarning((object)"Couldn't register the upgrade item because the modGUID is not valid.");
				return null;
			}
			if ((Object)(object)Plugin.instance.assetBundle == (Object)null)
			{
				Plugin.instance.logger.LogWarning((object)(modGUID + ": Couldn't register the upgrade item because the core mod failed to start. Contact the mod creator."));
				return null;
			}
			if ((Object)(object)item == (Object)null || (Object)(object)prefab == (Object)null)
			{
				Plugin.instance.logger.LogWarning((object)(modGUID + ": Couldn't register the upgrade item because the item or prefab are not valid."));
				return null;
			}
			string name = upgradeItemBase.name;
			if (string.IsNullOrEmpty(name))
			{
				Plugin.instance.logger.LogWarning((object)(modGUID + ": Couldn't register the upgrade item because the base name is not valid."));
				return null;
			}
			if (Plugin.instance.upgradeItems.Any((UpgradeItem x) => x.name.ToLower().Trim() == name.ToLower().Trim()))
			{
				Plugin.instance.logger.LogWarning((object)(modGUID + ": An upgrade item with the name '" + name.Trim() + "' already exists. Duplicate upgrade items are not allowed."));
				return null;
			}
			UpgradeItem upgradeItem = new UpgradeItem(upgradeItemBase, modGUID, item, prefab);
			Plugin.instance.upgradeItems.Add(upgradeItem);
			return upgradeItem;
		}
	}
	internal class MoreUpgradesManager : MonoBehaviour
	{
		internal static MoreUpgradesManager instance;

		internal PhotonView photonView;

		private bool checkPlayerUpgrades;

		private void Awake()
		{
			instance = this;
			photonView = ((Component)this).GetComponent<PhotonView>();
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				upgradeItem.variables.Clear();
				upgradeItem.onInit?.Invoke();
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				((MonoBehaviour)this).StartCoroutine("WaitUntilLevel");
			}
		}

		private void LateUpdate()
		{
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				upgradeItem.onLateUpdate?.Invoke();
			}
		}

		private void FixedUpdate()
		{
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				if (checkPlayerUpgrades)
				{
					if (upgradeItem.HasConfig("Starting Amount"))
					{
						int config = upgradeItem.GetConfig<int>("Starting Amount");
						if (config >= 0)
						{
							foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
							{
								string text = SemiFunc.PlayerGetSteamID(item);
								if (!upgradeItem.appliedPlayerUpgrades.ContainsKey(text))
								{
									upgradeItem.appliedPlayerUpgrades[text] = 0;
								}
								if (upgradeItem.appliedPlayerUpgrades[text] != config)
								{
									Upgrade(upgradeItem.name, text, config - upgradeItem.appliedPlayerUpgrades[text]);
									upgradeItem.appliedPlayerUpgrades[text] = config;
								}
							}
						}
					}
					if (upgradeItem.HasConfig("Sync Host Upgrades") && upgradeItem.GetConfig<bool>("Sync Host Upgrades"))
					{
						int amount = upgradeItem.GetAmount();
						foreach (PlayerAvatar item2 in from x in SemiFunc.PlayerGetAll()
							where (Object)(object)x != (Object)(object)SemiFunc.PlayerAvatarLocal()
							select x)
						{
							string steamId = SemiFunc.PlayerGetSteamID(item2);
							int amount2 = upgradeItem.GetAmount(steamId);
							int num = amount - amount2;
							if (num != 0)
							{
								Upgrade(upgradeItem.name, steamId, num);
							}
						}
					}
				}
				upgradeItem.onFixedUpdate?.Invoke();
			}
		}

		private void Update()
		{
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				upgradeItem.onUpdate?.Invoke();
			}
		}

		private IEnumerator WaitUntilLevel()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => SemiFunc.LevelGenDone()));
			checkPlayerUpgrades = true;
			if (!SemiFunc.IsMasterClient())
			{
				yield break;
			}
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				foreach (PlayerAvatar playerAvatar in SemiFunc.PlayerGetAll())
				{
					string steamId = SemiFunc.PlayerGetSteamID(playerAvatar);
					photonView.RPC("UpgradeRPC", (RpcTarget)4, new object[3]
					{
						upgradeItem.name,
						steamId,
						upgradeItem.GetAmount(steamId)
					});
				}
			}
		}

		internal void Upgrade(string upgradeItemName, string steamId, int amount = 1)
		{
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == upgradeItemName);
			if (upgradeItem != null)
			{
				upgradeItem.playerUpgrades[steamId] += amount;
				if ((Object)(object)SemiFunc.PlayerAvatarGetFromSteamID(steamId) == (Object)(object)SemiFunc.PlayerAvatarLocal())
				{
					upgradeItem.onChanged?.Invoke();
				}
				if (GameManager.Multiplayer())
				{
					photonView.RPC("UpgradeRPC", (RpcTarget)(SemiFunc.IsMasterClient() ? 1 : 2), new object[3]
					{
						upgradeItemName,
						steamId,
						upgradeItem.playerUpgrades[steamId]
					});
				}
			}
		}

		[PunRPC]
		internal void UpgradeRPC(string upgradeItemName, string steamId, int amount)
		{
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.name == upgradeItemName);
			if (upgradeItem != null && upgradeItem.playerUpgrades[steamId] != amount)
			{
				upgradeItem.playerUpgrades[steamId] = amount;
				if ((Object)(object)SemiFunc.PlayerAvatarGetFromSteamID(steamId) == (Object)(object)SemiFunc.PlayerAvatarLocal())
				{
					upgradeItem.onChanged?.Invoke();
				}
				if (SemiFunc.IsMasterClient())
				{
					photonView.RPC("UpgradeRPC", (RpcTarget)1, new object[3] { upgradeItemName, steamId, amount });
				}
			}
		}
	}
	public class UpgradeItem
	{
		internal string saveName;

		internal string sectionName;

		internal UpgradeItemBase upgradeItemBase;

		private Dictionary<string, ConfigEntryBase> configEntries;

		internal Dictionary<string, int> playerUpgrades;

		internal Dictionary<string, int> appliedPlayerUpgrades;

		internal Dictionary<string, object> variables;

		public Action onInit;

		public Action onLateUpdate;

		public Action onFixedUpdate;

		public Action onUpdate;

		public Action onChanged;

		public string name { get; private set; }

		public string fullName { get; private set; }

		public string modGUID { get; private set; }

		public bool HasConfig(string key)
		{
			ConfigEntryBase value;
			return configEntries.TryGetValue(key, out value);
		}

		public bool AddConfig<T>(string key, T defaultValue, string description = "")
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			if (configEntries.ContainsKey(key))
			{
				Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' already exists. Duplicates are not allowed."));
				return false;
			}
			ConfigEntryBase val = null;
			val = (ConfigEntryBase)(object)((defaultValue is int) ? ((BaseUnityPlugin)Plugin.instance).Config.Bind<T>(sectionName, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())) : ((!(defaultValue is float)) ? ((BaseUnityPlugin)Plugin.instance).Config.Bind<T>(sectionName, key, defaultValue, description) : ((BaseUnityPlugin)Plugin.instance).Config.Bind<T>(sectionName, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100000f), Array.Empty<object>()))));
			configEntries.Add(key, val);
			return true;
		}

		public bool AddConfig<T>(string key, T defaultValue, ConfigDescription description = null)
		{
			if (configEntries.ContainsKey(key))
			{
				Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' already exists. Duplicates are not allowed."));
				return false;
			}
			configEntries.Add(key, (ConfigEntryBase)(object)((BaseUnityPlugin)Plugin.instance).Config.Bind<T>(sectionName, key, defaultValue, description));
			return true;
		}

		public bool AddConfig(string key, ConfigEntryBase value)
		{
			if (configEntries.ContainsKey(key))
			{
				Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' already exists. Duplicates are not allowed."));
				return false;
			}
			configEntries.Add(key, value);
			return true;
		}

		public bool SetConfig<T>(string key, T value)
		{
			if (!configEntries.TryGetValue(key, out var value2))
			{
				Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' does not exist. Returning default value."));
				return false;
			}
			if (value2 is ConfigEntry<T> val)
			{
				val.Value = value;
				return true;
			}
			Plugin.instance.logger.LogWarning((object)("Type mismatch for config entry '" + key + "'. Expected: " + value2.SettingType.FullName + ", but got: " + typeof(T).FullName + ". Returning default value."));
			return false;
		}

		public T GetConfig<T>(string key)
		{
			if (!configEntries.TryGetValue(key, out var value))
			{
				Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' does not exist. Returning default value."));
				return default(T);
			}
			if (value is ConfigEntry<T> val)
			{
				return val.Value;
			}
			Plugin.instance.logger.LogWarning((object)("Type mismatch for config entry '" + key + "'. Expected: " + value.SettingType.FullName + ", but got: " + typeof(T).FullName + ". Returning default value."));
			return default(T);
		}

		public bool HasVariable(string key)
		{
			object value;
			return variables.TryGetValue(key, out value);
		}

		public bool AddVariable<T>(string key, T value)
		{
			if (HasVariable(key))
			{
				Plugin.instance.logger.LogWarning((object)("A variable with the key '" + key + "' already exists. Duplicates are not allowed."));
				return false;
			}
			variables.Add(key, value);
			return true;
		}

		public bool SetVariable<T>(string key, T value)
		{
			if (!variables.TryGetValue(key, out var value2))
			{
				Plugin.instance.logger.LogWarning((object)("A variable with the key '" + key + "' does not exist."));
				return false;
			}
			if (value2 is T)
			{
				variables[key] = value;
				return true;
			}
			Plugin.instance.logger.LogWarning((object)("Type mismatch for variable '" + key + "'. Expected: " + value2.GetType().FullName + ", but got: " + typeof(T).FullName + "."));
			return false;
		}

		public T GetVariable<T>(string key)
		{
			if (!variables.TryGetValue(key, out var value))
			{
				Plugin.instance.logger.LogWarning((object)("A variable with the key '" + key + "' does not exist. Returning default value."));
				return default(T);
			}
			if (value is T result)
			{
				return result;
			}
			Plugin.instance.logger.LogWarning((object)("Type mismatch for variable '" + key + "'. Expected: " + value.GetType().FullName + ", but got: " + typeof(T).FullName + ". Returning default value."));
			return default(T);
		}

		public int GetAmount(string steamId = null)
		{
			if (steamId != null)
			{
				return playerUpgrades.ContainsKey(steamId) ? playerUpgrades[steamId] : 0;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
			if ((Object)(object)val != (Object)null)
			{
				steamId = SemiFunc.PlayerGetSteamID(val);
			}
			return (steamId != null && playerUpgrades.ContainsKey(steamId)) ? playerUpgrades[steamId] : 0;
		}

		internal UpgradeItem(UpgradeItemBase upgradeItemBase, string modGUID = null, Item modItem = null, GameObject modPrefab = null)
		{
			UpgradeItem upgradeItem = this;
			name = upgradeItemBase.name;
			fullName = "Modded Item Upgrade Player " + name;
			this.modGUID = modGUID;
			saveName = new string(name.Where((char x) => !char.IsWhiteSpace(x)).ToArray());
			sectionName = name + ((!Utility.IsNullOrWhiteSpace(modGUID)) ? (" (" + modGUID + ")") : "");
			this.upgradeItemBase = upgradeItemBase;
			configEntries = new Dictionary<string, ConfigEntryBase>();
			playerUpgrades = new Dictionary<string, int>();
			appliedPlayerUpgrades = new Dictionary<string, int>();
			variables = new Dictionary<string, object>();
			TryAddConfig<bool>("Enabled", defaultValue: true, "Whether the upgrade item can be spawned to the shop.");
			TryAddConfig<int>("Max Amount", upgradeItemBase.maxAmount, "The maximum number of times the upgrade item can appear in the truck.");
			TryAddConfig<int>("Max Amount In Shop", upgradeItemBase.maxAmountInShop, "The maximum number of times the upgrade item can appear in the shop.");
			TryAddConfig<float>("Minimum Price", upgradeItemBase.minPrice, "The minimum cost to purchase the upgrade item.");
			TryAddConfig<float>("Maximum Price", upgradeItemBase.maxPrice, "The maximum cost to purchase the upgrade item.");
			TryAddConfig<float>("Price Increase Scaling", upgradeItemBase.priceIncreaseScaling, "The scale of the price increase based on the total number of upgrade item purchased.\nDefault scaling is set to 0.5. (Note: This value may be modified by other mods that adjust the game's default scaling.)\nSet to -1 to use the default scaling.");
			TryAddConfig<int>("Max Purchase Amount", upgradeItemBase.maxPurchaseAmount, "The maximum number of times the upgrade item can be purchased before it is no longer available in the shop.\nSet to 0 to disable the limit.");
			TryAddConfig<bool>("Allow Team Upgrades", defaultValue: false, "Whether the upgrade item applies to the entire team instead of just one player.");
			TryAddConfig<bool>("Sync Host Upgrades", defaultValue: false, "Whether the host should sync the item upgrade for the entire team.");
			TryAddConfig<int>("Starting Amount", 0, "The number of times the upgrade item is applied at the start of the game.");
			TryAddConfig<string>("Display Name", name, "The display name of the upgrade item.");
			Item val = modItem ?? Plugin.instance.assetBundle.LoadAsset<Item>(name);
			((Object)val).name = fullName;
			val.itemAssetName = fullName;
			val.itemName = (HasConfig("Display Name") ? GetConfig<string>("Display Name") : name) + " Upgrade";
			val.maxAmount = (HasConfig("Max Amount") ? GetConfig<int>("Max Amount") : upgradeItemBase.maxAmount);
			val.maxAmountInShop = (HasConfig("Max Amount In Shop") ? GetConfig<int>("Max Amount In Shop") : upgradeItemBase.maxAmountInShop);
			val.maxPurchaseAmount = (HasConfig("Max Purchase Amount") ? GetConfig<int>("Max Purchase Amount") : upgradeItemBase.maxPurchaseAmount);
			val.maxPurchase = val.maxPurchaseAmount > 0;
			val.value = ScriptableObject.CreateInstance<Value>();
			val.value.valueMin = (HasConfig("Minimum Price") ? GetConfig<float>("Minimum Price") : upgradeItemBase.minPrice);
			val.value.valueMax = (HasConfig("Maximum Price") ? GetConfig<float>("Maximum Price") : upgradeItemBase.maxPrice);
			GameObject val2 = modPrefab ?? Plugin.instance.assetBundle.LoadAsset<GameObject>(name + " Prefab");
			((Object)val2).name = fullName;
			val2.GetComponent<ItemAttributes>().item = val;
			val.prefab = val2;
			Items.RegisterItem(val);
			void TryAddConfig<T>(string key, T defaultValue, string description = "")
			{
				if (!upgradeItemBase.excludeConfigs.Contains(key))
				{
					AddConfig(key, defaultValue, description);
				}
			}
		}
	}
	public class UpgradeItemBase
	{
		public string name = null;

		public int maxAmount = 1;

		public int maxAmountInShop = 1;

		public float minPrice = 1000f;

		public float maxPrice = 1000f;

		public int maxPurchaseAmount = 0;

		public float priceIncreaseScaling = -1f;

		public List<string> excludeConfigs = new List<string>();
	}
}

BeepInEx/plugins/Caigan-Tokucade_Valuables/TokucadeLoot.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;

[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("TokucadeLoot")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2bf427237f50cf34daf85ecc3daf4cd404f1e48b")]
[assembly: AssemblyProduct("TokucadeLoot")]
[assembly: AssemblyTitle("TokucadeLoot")]
[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;
		}
	}
}
public class ValuableEDFCabinet : MonoBehaviour
{
	private enum State
	{
		Idle,
		Active
	}

	public PhysGrabObject physGrabObject;

	private List<string> transitiveVerbs = new List<string>();

	private List<string> intransitiveVerbs = new List<string>();

	private List<string> adjectives = new List<string>();

	private List<string> intensifiers = new List<string>();

	private List<string> nouns = new List<string>();

	private List<string> adverbs = new List<string>();

	private float coolDownUntilNextSentence = 3f;

	private ParticleSystem particles;

	private bool particlesPlaying;

	public Renderer LovePotionRenderer;

	private State currentState;

	private string playerName = "[playerName]";

	private void Start()
	{
		particles = ((Component)this).GetComponentInChildren<ParticleSystem>();
		physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
		InitializeWordLists();
	}

	private void Update()
	{
		if (SemiFunc.IsMultiplayer())
		{
			switch (currentState)
			{
			case State.Idle:
				StateIdle();
				break;
			case State.Active:
				StateActive();
				break;
			}
		}
	}

	private void StateIdle()
	{
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		if (coolDownUntilNextSentence > 0f && physGrabObject.grabbed)
		{
			coolDownUntilNextSentence -= Time.deltaTime;
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)PhysGrabber.instance) || !PhysGrabber.instance.grabbed || !Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) || !((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject == (Object)(object)physGrabObject))
			{
				return;
			}
			bool flag = false;
			if (!SemiFunc.IsMultiplayer())
			{
				playerName = "this potion";
				flag = true;
			}
			else
			{
				List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)PhysGrabber.instance).transform.position, false, default(LayerMask));
				PlayerAvatar val = null;
				float num = float.MaxValue;
				foreach (PlayerAvatar item in list)
				{
					if (!((Object)(object)item == (Object)(object)PlayerAvatar.instance))
					{
						float num2 = Vector3.Distance(((Component)PhysGrabber.instance).transform.position, ((Component)item).transform.position);
						if (num2 < num)
						{
							num = num2;
							val = item;
						}
					}
				}
				flag = true;
				if ((Object)(object)val != (Object)null)
				{
					playerName = val.playerName;
				}
				else
				{
					playerName = "this potion";
				}
			}
			if (flag)
			{
				string text = GenerateAffectionateSentence();
				currentState = State.Active;
				Color val2 = default(Color);
				((Color)(ref val2))..ctor(1f, 0.3f, 0.6f, 1f);
				ChatManager.instance.PossessChatScheduleStart(10);
				ChatManager.instance.PossessChat((PossessChatID)1, text, 1f, val2, 0f, false, 0, (UnityEvent)null);
				ChatManager.instance.PossessChatScheduleEnd();
			}
		}
	}

	private void StateActive()
	{
		if (PhysGrabber.instance.grabbed && Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) && (Object)(object)PhysGrabber.instance.grabbedPhysGrabObject != (Object)(object)physGrabObject)
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 15f);
		}
		else if (!ChatManager.instance.StateIsPossessed())
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 15f);
		}
	}

	private void InitializeWordLists()
	{
		transitiveVerbs.AddRange(new string[136]
		{
			"adore", "sing oh la la with", "crush on", "fan over", "root for", "olala over", "geek out over", "vibe with", "fangirl over", "fanboy over",
			"heart", "olalalalala", "can't even", "obsess over", "trip over", "flip for", "freak over", "go nuts for", "go crazy for", "get hyped to",
			"hype up", "read a book with", "ride or die for", "show love for", "dance with", "ship", "low-key crush on", "have a thing for", "can't stop thinking about", "eyeing",
			"have robofeeling for", "catch crushie feelings for", "go heart eyes for", "get butterflies over", "have heart eyes for", "can't get over", "can't get enough of", "get in my feels over", "dream about", "imagine being happy with",
			"can't handle", "get weak for", "melt for", "have a soft spot for", "got a thing for", "obsessed with", "blushing over", "head over heels for", "feel the feels for", "admire",
			"crushing hard on", "can't even with", "totally into", "lost in", "robofeels about", "gaga for", "beeping and booping over", "extracting valuables with", "grooving to", "all about",
			"blown away by", "hyped about", "tripping over", "losing it over", "crying over", "obsessing over", "dying for", "looking at", "checking out", "having nothing but love for",
			"waiting on", "going wild for", "living for", "hooked on", "feeling", "hyped for", "showing mad love to", "sending hugs to", "sending hearts to", "0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1",
			"be friends with", "laugh hard with", "vibing with", "like", "cherish", "enjoy", "appreciate", "love", "treasure", "care for",
			"go gaga ding dong for", "long for", "think of", "miss", "want to be with", "smile at", "look at", "blush around", "get shy around", "laugh and cry with",
			"sing love songs with", "talk to", "listen to", "hold hands with", "share secrets with", "walk with", "sit with", "be near", "hang out with", "spend time with",
			"be around", "wink at", "wave to", "call", "write to", "sing to", "dance with", "cook for", "make art for", "make gifts for",
			"give gifts to", "surprise", "hug", "make taxman happy with", "ride the cart with", "robotickle", "do a stand-up routine for", "enjoy the sunset with", "share laughs with", "make smile",
			"bring joy to", "be silly with", "go on adventures with", "explore with", "go to Japan with", "grow old with"
		});
		intransitiveVerbs.AddRange(new string[140]
		{
			"vibe", "wow wow wow", "geek out", "daydream", "crush", "fangirl", "fanboy", "cheer", "freak out", "melt",
			"chill", "robostalk", "go oh la la", "robodance", "rock out", "hug", "kick it", "work", "match", "boot up",
			"meet up", "catch feels", "connect", "get along", "robohang", "check out", "look up", "catch up", "hang out", "tune in",
			"break", "tap in", "dive in", "get in", "be in", "collab", "share", "swap", "trade", "deal",
			"work", "play", "compete", "challenge", "engage", "join in", "get in on", "mix in", "add in", "help",
			"support", "follow", "track", "keep tabs", "keep up", "stay updated", "keep an eye", "buzz", "wow", "download the latest update",
			"update", "shout out", "yell", "scream", "hype", "beep boop beep boop", "vent", "express", "spill the beans", "confess love",
			"admit feelings", "declare bankruptcy", "dream", "blush", "imagine", "robodrool", "obsess", "admire", "go woop woop", "freak out",
			"lose it", "freak", "feel", "glow", "... i dunno ...", "trip", "groove", "beep boop", "crush", "flirt",
			"giggle", "smile", "laugh", "beam", "grin", "wonder", "wish", "hope", "long", "like",
			"leave a like and subscribe", "react", "lurk", "go OP", "despawn", "fart", "peep", "spy", "peek", "sigh",
			"breathe", "relate", "resonate", "go gaga ding dong", "boop", "jam", "flutter", "tingle", "twirl", "dance",
			"sing", "hum", "beep", "skip", "float", "sparkle", "bubble", "chirp", "glisten", "twinkle",
			"ponder", "admire", "breathe", "relax", "fancy", "laugh", "imagine", "melt", "smirk", "chuckle"
		});
		adjectives.AddRange(new string[137]
		{
			"epic", "awesome", "adorable", "adorbs", "fab", "cool", "dreamy", "snazzy", "rad", "stellar",
			"dope", "amazing", "breathtaking", "charming", "cute", "ah meh zin geh", "fresh", "funky", "glowing", "oh la la la",
			"incredible", "olala", "lovable", "lovely", "upgraded", "neat", "on point", "peachy", "0 1 1 0 0 0 1 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 0 0 1 1 0 0 1 0 1", "woop y woop y woo",
			"likey likey", "oooh ya ya", "slick", "smart", "smooth", "sparkling", "OMG", "stunning", "stylish", "ooooh yeaaa",
			"superb", "supreme", "sweet", "wowie", "trendy", "unreal", "vibrant", "wicked", "me likey", "beep boop",
			"oh my", "oof in a good way", "brilliant", "oh ya ya", "chic", "ah ... mazing", "clever", "comfy", "cu ... wait ... teh ... cute", "woop woop",
			"hugable", "cute", "yas queen", "sooo like ... wow", "divine", "electric", "elegant", "elite", "1337", "engaging",
			"enticing", "fancy", "fierce", "fire", "fly", "glam", "gorgeous", "hype mode", "iconic", "legendary",
			"litty", "wow wow wow", "magical", "majestic", "bootiiifoool", "poppin'", "precious", "C O O L ... cool", "C U T E ... cute", "... ... *blushes* ...",
			"slaying", "spicy", "robohandsome", "wowa wowa yas yas", "on fleek", "robocute", "wholesome", "winning", "robodorable", "powerful",
			"pretty", "beautiful", "sweet", "kind", "wow wow wow wow wow", "100%", "0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 0 1 0 0", "fun", "brave", "interesting",
			"smart in the head", "sparkling", "shiny", "warm", "heroic", "friendly", "financially stable", "oh la la oh la la la la", "romantic", "cozy",
			"wonderful", "fantastic", "super", "great", "delightful", "fabulous", "marvelous", "nice", "pleasant", "good",
			"special", "unique", "o la la la yes yes", "yeah yeah wow wow", "wooooow", "oh woooow", "oh my gawd"
		});
		intensifiers.AddRange(new string[77]
		{
			"totally", "super", "uber", "mega", "super mega", "seriously", "majorly", "legit", "absolutely", "completely",
			"for reals", "utterly", "high-key", "incredibly", "madly", "like ...", "like... seriously", "sooo", "really", "so",
			"sooooooooo", "unbelievably", "very", "like soooo much", "extra", "extremely", "really really", "fiercely", "like, for reals", "greatly",
			"hugely", "immensely", "intensely", "massively", "so so soooo", "really really really", "like totes", "like... totally", "like.. somehow sooo much", "simply",
			"supremely", "surprisingly", "super mega ultra", "ultra", "unusually", "way way", "way", "insanely", "like ... insanelyyyy", "freakishly",
			"extra extra", "overwhelmingly", "reeeaaally", "weirdly", "suuuuper", "way waaaay", "crazy", "like suuuuuper", "really sooo", "low-key",
			"high-key", "literally", "for reeeaal soo", "legit", "honestly", "kinda", "sort of", "basically", "downright", "like literally",
			"very very", "like like.. like... sooo much", "like... actually", "suuuuper suuuuper", "genuinely", "truly", "sincerely"
		});
		nouns.AddRange(new string[108]
		{
			"bae", "bro", "fam", "goals", "friendo", "buddy", "pal", "champ", "MVP", "rockstar",
			"hero", "idol", "star", "queen", "king", "baby", "beast", "boss", "bruh", "boss queen",
			"girl", "dude", "genius", "guru", "cutie", "legend", "player", "boss king", "pog", "partner",
			"prodigy", "pro", "role model", "boy", "soulmate", "superhero", "sweetie", "twin", "robot", "wizard",
			"wonder", "crushie", "angel", "viral hit", "blessing", "champion", "charmer", "crush", "darling", "dear",
			"gamer", "fave", "friend", "gem", "heartthrob", "honey", "heartbreaker", "inspiration", "love", "main",
			"other half", "crushcrush", "person", "precious", "sunshine", "treasure", "bestie", "boo", "cutie", "sister",
			"sis", "brother", "fam", "beauty", "megacrush", "best friend", "supercrush", "favfav", "main character", "robo",
			"icon", "legend", "mood", "vibe", "goat", "man", "woman", "goal", "winner", "yas queen",
			"cute robot", "robot crush", "pal", "sweetheart", "pumpkin", "sugar", "baby", "peach", "dove", "cupcake",
			"buttercup", "snugglebug", "silly goose", "teddy bear", "dream", "princess", "prince", "superstar"
		});
		adverbs.AddRange(new string[77]
		{
			"totally", "super", "uber", "mega", "super mega", "seriously", "majorly", "legit", "absolutely", "completely",
			"for reals", "utterly", "high-key", "incredibly", "madly", "like ...", "like... seriously", "sooo", "really", "so",
			"sooooooooo", "unbelievably", "very", "like soooo", "extra", "extremely", "really really", "fiercely", "like, for reals", "greatly",
			"hugely", "immensely", "intensely", "massively", "so so soooo", "really really really", "like totes", "like... totally", "like.. somehow sooo", "simply",
			"supremely", "surprisingly", "super mega ultra", "ultra", "unusually", "way way", "way", "insanely", "like ... insanelyyyy", "freakishly",
			"extra extra", "overwhelmingly", "reeeaaally", "weirdly", "suuuuper", "way waaaay", "crazy", "like suuuuuper", "really sooo", "low-key",
			"high-key", "literally", "for reeeaal soo", "legit", "honestly", "kinda", "sort of", "basically", "downright", "like literally",
			"very very", "like like.. like... sooo", "like... actually", "suuuuper suuuuper", "genuinely", "truly", "sincerely"
		});
	}

	private string GenerateAffectionateSentence()
	{
		List<string> list = new List<string>
		{
			"E D F! E D F!", "To save our mother earth from any alien attack!", "From vicious giant insects who have once again come back!", "We'll unleash all our forces!", "We won't cut them any slack!", "The E D F deploys!", "E! D! F! E! D! F!", "Our soldiers are prepared for any alien threats!", "The Navy launches ships, the Air Force sends their jets!", "And nothing can withstand our fixed bayonets!",
			"The E.D.F deploys!", "E! D! F! E! D! F!", "Our forces have now dwindled and we pull back to regroup!", "The enemy has multiplied and formed a massive troop!", "We better beat these bugs before we're all turned to soup!", "The E D F deploys!", "E! D! F! E! D! F!", "The E D F deploys!", "E! D! F! E! D! F!", "The E D F deploys!",
			"E! D! F! E! D! F!", "E! D! F! E! D! F!", "E! D! F! E! D! F!", "E! D! F! E! D! F!"
		};
		string text = list[Random.Range(0, list.Count)];
		string text2 = text.Replace("{playerName}", playerName);
		if (text.Contains("{transitiveVerb}"))
		{
			string newValue = transitiveVerbs[Random.Range(0, transitiveVerbs.Count)];
			text2 = text2.Replace("{transitiveVerb}", newValue);
		}
		if (text.Contains("{intransitiveVerb}"))
		{
			string text3 = intransitiveVerbs[Random.Range(0, intransitiveVerbs.Count)];
			if (text2.Contains("{intransitiveVerb}s"))
			{
				text3 = ((!text3.EndsWith("e")) ? (text3 + "es") : (text3 + "s"));
				text2 = text2.Replace("{intransitiveVerb}s", text3);
			}
			else
			{
				text2 = text2.Replace("{intransitiveVerb}", text3);
			}
		}
		if (text.Contains("{adjective}"))
		{
			string newValue2 = adjectives[Random.Range(0, adjectives.Count)];
			text2 = text2.Replace("{adjective}", newValue2);
		}
		if (text.Contains("{intensifier}"))
		{
			string newValue3 = intensifiers[Random.Range(0, intensifiers.Count)];
			text2 = text2.Replace("{intensifier}", newValue3);
		}
		if (text.Contains("{adverb}"))
		{
			string newValue4 = adverbs[Random.Range(0, adverbs.Count)];
			text2 = text2.Replace("{adverb}", newValue4);
		}
		if (text.Contains("{noun}"))
		{
			string newValue5 = nouns[Random.Range(0, nouns.Count)];
			text2 = text2.Replace("{noun}", newValue5);
		}
		return char.ToUpper(text2[0]) + text2.Substring(1);
	}
}
namespace TokucadeLoot
{
	[BepInPlugin("Caigan.TokucadeLoot", "Tokucade Loot", "1.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class TokucadeLoot : BaseUnityPlugin
	{
		private void Awake()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tokucade_scrap");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			GameObject val2 = val.LoadAsset<GameObject>("Assets/Resources/valuables/01 tiny/Valuable Bunny Plush.prefab");
			Valuables.RegisterValuable(val2);
			GameObject val3 = val.LoadAsset<GameObject>("Assets/Resources/valuables/01 tiny/Valuable Taiyaki.prefab");
			Valuables.RegisterValuable(val3);
			GameObject val4 = val.LoadAsset<GameObject>("Assets/Resources/valuables/01 tiny/Valuable Toast Plush.prefab");
			Valuables.RegisterValuable(val4);
			GameObject val5 = val.LoadAsset<GameObject>("Assets/Resources/valuables/01 tiny/Valuable Grape Soda.prefab");
			Valuables.RegisterValuable(val5);
			GameObject val6 = val.LoadAsset<GameObject>("Assets/Resources/valuables/01 tiny/Valuable Energy Drink.prefab");
			Valuables.RegisterValuable(val6);
			GameObject val7 = val.LoadAsset<GameObject>("Assets/Resources/valuables/02 small/Valuable Heart of a Goobold.prefab");
			Valuables.RegisterValuable(val7);
			GameObject val8 = val.LoadAsset<GameObject>("Assets/Resources/valuables/02 small/Valuable Duck Action Figure.prefab");
			Valuables.RegisterValuable(val8);
			GameObject val9 = val.LoadAsset<GameObject>("Assets/Resources/valuables/02 small/Valuable Rabbit Action Figure.prefab");
			Valuables.RegisterValuable(val9);
			GameObject val10 = val.LoadAsset<GameObject>("Assets/Resources/valuables/02 small/Valuable Mouse Plush.prefab");
			Valuables.RegisterValuable(val10);
			GameObject val11 = val.LoadAsset<GameObject>("Assets/Resources/valuables/02 small/Valuable Fluorite Octet.prefab");
			Valuables.RegisterValuable(val11);
			GameObject val12 = val.LoadAsset<GameObject>("Assets/Resources/valuables/02 small/Valuable Jelly Bean Bag.prefab");
			Valuables.RegisterValuable(val12);
			GameObject val13 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Arctic Fox.prefab");
			Valuables.RegisterValuable(val13);
			GameObject val14 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Moth Padoru.prefab");
			Valuables.RegisterValuable(val14);
			GameObject val15 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Tigermouse Plush.prefab");
			Valuables.RegisterValuable(val15);
			GameObject val16 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Cat Slime Plush.prefab");
			Valuables.RegisterValuable(val16);
			GameObject val17 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Carpet Shark Plush.prefab");
			Valuables.RegisterValuable(val17);
			GameObject val18 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Cat Snake Plush.prefab");
			Valuables.RegisterValuable(val18);
			GameObject val19 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Limo Hamster Plush.prefab");
			Valuables.RegisterValuable(val19);
			GameObject val20 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Giant Chocolate Bar.prefab");
			Valuables.RegisterValuable(val20);
			GameObject val21 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Giant Tamago.prefab");
			Valuables.RegisterValuable(val21);
			GameObject val22 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Golden Cheese.prefab");
			Valuables.RegisterValuable(val22);
			GameObject val23 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Horse Plush.prefab");
			Valuables.RegisterValuable(val23);
			GameObject val24 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Bright Pony Plush.prefab");
			Valuables.RegisterValuable(val24);
			GameObject val25 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Possum Plush.prefab");
			Valuables.RegisterValuable(val25);
			GameObject val26 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Raccoon Plush.prefab");
			Valuables.RegisterValuable(val26);
			GameObject val27 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Red Panda Plush.prefab");
			Valuables.RegisterValuable(val27);
			GameObject val28 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Squirrel Plush.prefab");
			Valuables.RegisterValuable(val28);
			GameObject val29 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Wolf Plush.prefab");
			Valuables.RegisterValuable(val29);
			GameObject val30 = val.LoadAsset<GameObject>("Assets/Resources/valuables/03 medium/Valuable Donut Plush.prefab");
			Valuables.RegisterValuable(val30);
			GameObject val31 = val.LoadAsset<GameObject>("Assets/Resources/valuables/04 big/Valuable Gachapon Machine.prefab");
			Valuables.RegisterValuable(val31);
			GameObject val32 = val.LoadAsset<GameObject>("Assets/Resources/valuables/04 big/Valuable Giant Candy Corn.prefab");
			Valuables.RegisterValuable(val32);
			GameObject val33 = val.LoadAsset<GameObject>("Assets/Resources/valuables/04 big/Valuable Giant Gummy Bear.prefab");
			Valuables.RegisterValuable(val33);
			GameObject val34 = val.LoadAsset<GameObject>("Assets/Resources/valuables/04 big/Valuable Fake Money Bag.prefab");
			Valuables.RegisterValuable(val34);
			GameObject val35 = val.LoadAsset<GameObject>("Assets/Resources/valuables/04 big/Valuable Giant Garlic.prefab");
			Valuables.RegisterValuable(val35);
			GameObject val36 = val.LoadAsset<GameObject>("Assets/Resources/valuables/05 wide/Valuable Pizza Box.prefab");
			Valuables.RegisterValuable(val36);
			GameObject val37 = val.LoadAsset<GameObject>("Assets/Resources/valuables/05 wide/Valuable Air Hockey Table.prefab");
			Valuables.RegisterValuable(val37);
			GameObject val38 = val.LoadAsset<GameObject>("Assets/Resources/valuables/06 tall/Valuable EDF Arcade Cabinet.prefab");
			Valuables.RegisterValuable(val38);
			GameObject val39 = val.LoadAsset<GameObject>("Assets/Resources/valuables/06 tall/Valuable Gumball Machine.prefab");
			Valuables.RegisterValuable(val39);
			GameObject val40 = val.LoadAsset<GameObject>("Assets/Resources/valuables/07 very tall/Valuable Claw Machine.prefab");
			Valuables.RegisterValuable(val40);
		}
	}
}

BeepInEx/plugins/CarsonJF-EnderPearlMod/EnderPearlMod.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
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: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("CarsonJF")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("EnderPearlMod Mod for REPO")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1")]
[assembly: AssemblyProduct("EnderPearlMod")]
[assembly: AssemblyTitle("EnderPearlMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.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 EnderPearlMod
{
	public class EnderPearl : MonoBehaviour
	{
		public enum States
		{
			Idle,
			Active,
			Used
		}

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

			private object <>2__current;

			public PlayerController controller;

			public Vector3 targetPos;

			public EnderPearl <>4__this;

			private bool <wasKinematic>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				//IL_0051: 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_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Expected O, but got Unknown
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: 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 WaitForFixedUpdate();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (Vector3.Distance(((Component)controller).transform.position, targetPos) > 0.1f)
					{
						((Component)controller).transform.position = targetPos;
					}
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 2;
					return true;
				case 2:
				{
					<>1__state = -1;
					if ((Object)(object)controller.rb != (Object)null)
					{
						<wasKinematic>5__1 = controller.rb.isKinematic;
						controller.rb.isKinematic = false;
						controller.rb.velocity = Vector3.zero;
						controller.rb.angularVelocity = Vector3.zero;
						controller.rb.isKinematic = <wasKinematic>5__1;
					}
					controller.OverrideSpeed(1f, 0.1f);
					controller.OverrideTimeScale(1f, 0.1f);
					PhotonView? photonView = <>4__this.photonView;
					if (photonView != null)
					{
						photonView.RPC("OnTeleportCompleteRPC", (RpcTarget)0, Array.Empty<object>());
					}
					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();
			}
		}

		[SerializeField]
		private PhysGrabObject? physGrabObject;

		[SerializeField]
		private PhotonView? photonView;

		internal States currentState;

		private bool stateStart;

		[Header("Visual Effects")]
		[SerializeField]
		private Transform? particleSystemTransform;

		[SerializeField]
		private ParticleSystem? particleSystemGlitter;

		[SerializeField]
		private ParticleSystem? teleportSuccessParticles;

		[SerializeField]
		private MeshRenderer? pearlRenderer;

		[Header("Light Settings")]
		[SerializeField]
		private Light? lightWhenHeld;

		[SerializeField]
		private float lightIntensityActive = 4f;

		[SerializeField]
		private float lightIntensityTeleport = 8f;

		[SerializeField]
		private Color lightColorActive = new Color(0.5f, 0f, 0.5f);

		[SerializeField]
		private Color lightColorIdle = new Color(0f, 1f, 0f);

		[Header("Sound Effects")]
		[SerializeField]
		private Sound? impactSound;

		[SerializeField]
		private RoomVolumeCheck? roomVolumeCheck;

		private PhysGrabber? lastHolder;

		private float lastHoldTime;

		private const float TELEPORT_MEMORY_DURATION = 5f;

		private const float RETURN_TO_IDLE_TIMEOUT = 3f;

		[SerializeField]
		private Rigidbody? rb;

		private Vector3 impactPosition;

		private float lastTeleportTime;

		private float releaseTime = -1f;

		private const float TELEPORT_COOLDOWN = 0.5f;

		private bool isTeleporting;

		private const float PLAYER_HEIGHT = 2f;

		private const float PLAYER_RADIUS = 0.5f;

		private const float CEILING_BUFFER = 0.2f;

		public static EnderPearl? Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			if (!Object.op_Implicit((Object)(object)physGrabObject))
			{
				physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
				if (!Object.op_Implicit((Object)(object)physGrabObject))
				{
					Debug.LogError((object)("EnderPearl: PhysGrabObject component is missing! GameObject: " + ((Object)((Component)this).gameObject).name + ", Path: " + GetGameObjectPath(((Component)this).gameObject)));
					((Behaviour)this).enabled = false;
					return;
				}
			}
			if (!Object.op_Implicit((Object)(object)photonView))
			{
				photonView = ((Component)this).GetComponent<PhotonView>();
				if (!Object.op_Implicit((Object)(object)photonView))
				{
					Debug.LogError((object)"EnderPearl: PhotonView component is missing!");
					((Behaviour)this).enabled = false;
					return;
				}
			}
			if (!Object.op_Implicit((Object)(object)rb))
			{
				rb = ((Component)this).GetComponent<Rigidbody>();
				if (!Object.op_Implicit((Object)(object)rb))
				{
					Debug.LogError((object)"EnderPearl: Rigidbody component is missing!");
					((Behaviour)this).enabled = false;
					return;
				}
			}
			if (!Object.op_Implicit((Object)(object)roomVolumeCheck))
			{
				roomVolumeCheck = ((Component)this).GetComponent<RoomVolumeCheck>();
				if (!Object.op_Implicit((Object)(object)roomVolumeCheck))
				{
					Debug.LogError((object)"EnderPearl: RoomVolumeCheck component is missing!");
					((Behaviour)this).enabled = false;
					return;
				}
			}
			if ((Object)(object)particleSystemTransform == (Object)null)
			{
				particleSystemTransform = ((Component)this).transform.Find("ParticleSystem");
			}
			if ((Object)(object)particleSystemGlitter == (Object)null)
			{
				particleSystemGlitter = ((Component)this).GetComponentInChildren<ParticleSystem>();
			}
			if ((Object)(object)teleportSuccessParticles == (Object)null)
			{
				Transform obj = ((Component)this).transform.Find("TeleportParticles");
				teleportSuccessParticles = ((obj != null) ? ((Component)obj).GetComponent<ParticleSystem>() : null);
			}
			if ((Object)(object)pearlRenderer == (Object)null)
			{
				pearlRenderer = ((Component)this).GetComponent<MeshRenderer>();
			}
			if ((Object)(object)lightWhenHeld == (Object)null)
			{
				lightWhenHeld = ((Component)this).GetComponentInChildren<Light>();
			}
			if (impactSound == null)
			{
				impactSound = ((Component)this).GetComponent<Sound>();
			}
			currentState = States.Idle;
			stateStart = true;
			lastHoldTime = -5f;
			StopAllParticleSystems();
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		private void StopAllParticleSystems()
		{
			if ((Object)(object)particleSystemGlitter != (Object)null)
			{
				particleSystemGlitter.Stop();
			}
			if ((Object)(object)teleportSuccessParticles != (Object)null)
			{
				teleportSuccessParticles.Stop();
			}
		}

		private void Update()
		{
			if ((Object)(object)photonView == (Object)null || (Object)(object)physGrabObject == (Object)null)
			{
				return;
			}
			if (physGrabObject.grabbed)
			{
				List<PhysGrabber> playerGrabbing = physGrabObject.playerGrabbing;
				if (playerGrabbing != null && playerGrabbing.Count > 0)
				{
					PhysGrabber val = playerGrabbing[0];
					lastHoldTime = Time.time;
					releaseTime = -1f;
					if ((Object)(object)val != (Object)(object)lastHolder)
					{
						lastHolder = val;
						UpdateLastHolder(val);
						if (!photonView.IsMine)
						{
							PlayerAvatar playerAvatar = val.playerAvatar;
							if (playerAvatar != null)
							{
								PhotonView obj = playerAvatar.photonView;
								if (((obj != null) ? new bool?(obj.IsMine) : null).GetValueOrDefault())
								{
									photonView.RequestOwnership();
								}
							}
						}
						PlayerAvatar playerAvatar2 = val.playerAvatar;
						if (playerAvatar2 != null)
						{
							PhotonView obj2 = playerAvatar2.photonView;
							if (((obj2 != null) ? new bool?(obj2.IsMine) : null).GetValueOrDefault())
							{
								SetState(States.Active);
							}
						}
					}
				}
			}
			else if (currentState == States.Active)
			{
				if (releaseTime < 0f)
				{
					releaseTime = Time.time;
				}
				if (Time.time - releaseTime >= 3f && !isTeleporting)
				{
					SetState(States.Idle);
				}
			}
			switch (currentState)
			{
			case States.Active:
				StateActive();
				break;
			case States.Idle:
				StateIdle();
				break;
			case States.Used:
				StateUsed();
				break;
			}
		}

		private bool IsPositionInBounds(Vector3 position)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: 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_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)roomVolumeCheck == (Object)null)
			{
				return true;
			}
			Vector3 position2 = ((Component)this).transform.position;
			bool enabled = ((Behaviour)roomVolumeCheck).enabled;
			((Behaviour)roomVolumeCheck).enabled = true;
			Vector3[] array = (Vector3[])(object)new Vector3[14]
			{
				position,
				position + Vector3.up * 2f,
				position + Vector3.up * 1f + Vector3.forward * 0.5f,
				position + Vector3.up * 1f - Vector3.forward * 0.5f,
				position + Vector3.up * 1f + Vector3.right * 0.5f,
				position + Vector3.up * 1f - Vector3.right * 0.5f,
				position + Vector3.forward * 0.5f + Vector3.right * 0.5f,
				position + Vector3.forward * 0.5f - Vector3.right * 0.5f,
				position - Vector3.forward * 0.5f + Vector3.right * 0.5f,
				position - Vector3.forward * 0.5f - Vector3.right * 0.5f,
				position + Vector3.up * 1.8f + Vector3.forward * 0.5f + Vector3.right * 0.5f,
				position + Vector3.up * 1.8f + Vector3.forward * 0.5f - Vector3.right * 0.5f,
				position + Vector3.up * 1.8f - Vector3.forward * 0.5f + Vector3.right * 0.5f,
				position + Vector3.up * 1.8f - Vector3.forward * 0.5f - Vector3.right * 0.5f
			};
			bool result = true;
			Vector3[] array2 = array;
			foreach (Vector3 position3 in array2)
			{
				((Component)this).transform.position = position3;
				if (!((Behaviour)roomVolumeCheck).enabled)
				{
					result = false;
					break;
				}
				((Behaviour)roomVolumeCheck).enabled = true;
			}
			((Component)this).transform.position = position2;
			((Behaviour)roomVolumeCheck).enabled = enabled;
			return result;
		}

		private void TryTeleportLastHolder()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)lastHolder == (Object)null) && !(Time.time - lastHoldTime > 5f) && IsPositionInBounds(impactPosition) && (Object)(object)lastHolder.playerAvatar != (Object)null && (Object)(object)photonView != (Object)null)
			{
				PhotonView val = lastHolder.playerAvatar.photonView;
				if ((Object)(object)val != (Object)null)
				{
					photonView.RPC("ExecuteTeleportRPC", (RpcTarget)0, new object[4] { val.ViewID, impactPosition.x, impactPosition.y, impactPosition.z });
				}
			}
		}

		[PunRPC]
		private void ExecuteTeleportRPC(int playerViewID, float x, float y, float z)
		{
			//IL_010a: 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_00d9: 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_0144: 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_016e: Unknown result type (might be due to invalid IL or missing references)
			PhotonView val = PhotonView.Find(playerViewID);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			SetTeleportingState(teleporting: true);
			if (!val.IsMine)
			{
				return;
			}
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(x, y + 0.1f, z);
			PlayerAvatar component = ((Component)val).GetComponent<PlayerAvatar>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			PlayerController instance = PlayerController.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				instance.InputDisable(0.5f);
				instance.OverrideSpeed(0f, 0.5f);
				instance.OverrideTimeScale(0f, 0.5f);
				if ((Object)(object)instance.rb != (Object)null)
				{
					bool isKinematic = instance.rb.isKinematic;
					instance.rb.isKinematic = false;
					instance.rb.velocity = Vector3.zero;
					instance.rb.angularVelocity = Vector3.zero;
					instance.rb.isKinematic = isKinematic;
				}
				((Component)instance).transform.position = val2;
				((MonoBehaviour)this).StartCoroutine(VerifyAndResetTeleport(instance, val2));
				if ((Object)(object)teleportSuccessParticles != (Object)null)
				{
					((Component)teleportSuccessParticles).transform.position = ((Component)this).transform.position;
					teleportSuccessParticles.Clear();
					teleportSuccessParticles.Play();
					ParticleSystem val3 = Object.Instantiate<ParticleSystem>(teleportSuccessParticles, val2, Quaternion.identity);
					val3.Clear();
					val3.Play();
					Object.Destroy((Object)(object)((Component)val3).gameObject, 2f);
				}
				if ((Object)(object)lightWhenHeld != (Object)null)
				{
					lightWhenHeld.intensity = lightIntensityTeleport;
					((Component)lightWhenHeld).gameObject.SetActive(true);
				}
			}
		}

		[IteratorStateMachine(typeof(<VerifyAndResetTeleport>d__40))]
		private IEnumerator VerifyAndResetTeleport(PlayerController controller, Vector3 targetPos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <VerifyAndResetTeleport>d__40(0)
			{
				<>4__this = this,
				controller = controller,
				targetPos = targetPos
			};
		}

		[PunRPC]
		private void OnTeleportCompleteRPC()
		{
			SetTeleportingState(teleporting: false);
			if (currentState == States.Used)
			{
				SetState(States.Idle);
			}
		}

		private void StateActive()
		{
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			if (stateStart)
			{
				if ((Object)(object)particleSystemGlitter != (Object)null)
				{
					particleSystemGlitter.Clear();
					particleSystemGlitter.Play();
				}
				if ((Object)(object)teleportSuccessParticles != (Object)null)
				{
					teleportSuccessParticles.Clear();
					teleportSuccessParticles.Stop();
				}
				stateStart = false;
				if ((Object)(object)lightWhenHeld != (Object)null)
				{
					((Component)lightWhenHeld).gameObject.SetActive(true);
				}
			}
			if ((Object)(object)lightWhenHeld != (Object)null && !((Component)lightWhenHeld).gameObject.activeSelf)
			{
				((Component)lightWhenHeld).gameObject.SetActive(true);
			}
			if ((Object)(object)particleSystemTransform != (Object)null && ((Component)particleSystemTransform).gameObject.activeSelf && (Object)(object)physGrabObject != (Object)null)
			{
				List<PhysGrabber> playerGrabbing = physGrabObject.playerGrabbing;
				if (playerGrabbing != null && playerGrabbing.Count > 0)
				{
					PhysGrabber val = playerGrabbing[0];
					if ((Object)(object)val != (Object)null && (Object)(object)val.playerAvatar?.playerAvatarVisuals?.headLookAtTransform != (Object)null)
					{
						particleSystemTransform.LookAt(val.playerAvatar.playerAvatarVisuals.headLookAtTransform);
					}
				}
			}
			if ((Object)(object)lightWhenHeld != (Object)null)
			{
				lightWhenHeld.intensity = Mathf.Lerp(lightWhenHeld.intensity, lightIntensityActive, Time.deltaTime * 5f);
				MeshRenderer? obj = pearlRenderer;
				Material val2 = ((obj != null) ? ((Renderer)obj).material : null);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.SetColor("_EmissionColor", lightColorActive * lightWhenHeld.intensity);
				}
			}
		}

		private void StateIdle()
		{
			//IL_00c8: 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)
			if (stateStart)
			{
				StopAllParticleSystems();
				stateStart = false;
			}
			if ((Object)(object)physGrabObject != (Object)null && physGrabObject.grabbed && (Object)(object)photonView != (Object)null && photonView.IsMine)
			{
				SetState(States.Active);
			}
			if ((Object)(object)lightWhenHeld != (Object)null)
			{
				lightWhenHeld.intensity = Mathf.Lerp(lightWhenHeld.intensity, 0f, Time.deltaTime * 10f);
				MeshRenderer? obj = pearlRenderer;
				Material val = ((obj != null) ? ((Renderer)obj).material : null);
				if ((Object)(object)val != (Object)null)
				{
					val.SetColor("_EmissionColor", lightColorIdle * lightWhenHeld.intensity);
				}
				if (lightWhenHeld.intensity < 0.01f)
				{
					((Component)lightWhenHeld).gameObject.SetActive(false);
				}
			}
		}

		private void StateUsed()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (stateStart)
			{
				StopAllParticleSystems();
				stateStart = false;
			}
			if ((Object)(object)lightWhenHeld != (Object)null)
			{
				lightWhenHeld.intensity = Mathf.Lerp(lightWhenHeld.intensity, 0f, Time.deltaTime * 10f);
				MeshRenderer? obj = pearlRenderer;
				Material val = ((obj != null) ? ((Renderer)obj).material : null);
				if ((Object)(object)val != (Object)null)
				{
					val.SetColor("_EmissionColor", lightColorIdle * lightWhenHeld.intensity);
				}
				if (lightWhenHeld.intensity < 0.01f)
				{
					((Component)lightWhenHeld).gameObject.SetActive(false);
				}
			}
		}

		[PunRPC]
		public void SetStateRPC(States state)
		{
			currentState = state;
			stateStart = true;
		}

		private void SetState(States state)
		{
			if ((Object)(object)photonView == (Object)null)
			{
				Debug.LogError((object)"Cannot set state - PhotonView is null");
			}
			else if (photonView.IsMine)
			{
				photonView.RPC("SetStateRPC", (RpcTarget)0, new object[1] { state });
			}
		}

		private void OnCollisionEnter(Collision collision)
		{
			//IL_00a1: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)photonView == (Object)null) && photonView.IsMine && !isTeleporting && (Object)(object)physGrabObject != (Object)null && !physGrabObject.grabbed && Time.time - lastHoldTime <= 5f && currentState == States.Active)
			{
				if (collision.contacts.Length != 0)
				{
					impactPosition = ((ContactPoint)(ref collision.contacts[0])).point;
				}
				else
				{
					impactPosition = collision.transform.position;
				}
				if ((Object)(object)particleSystemGlitter != (Object)null)
				{
					particleSystemGlitter.Clear();
					particleSystemGlitter.Stop();
				}
				Sound? obj = impactSound;
				if (obj != null)
				{
					obj.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				}
				TryTeleportLastHolder();
				SetTeleportingState(teleporting: true);
				lastTeleportTime = Time.time;
				SetState(States.Idle);
			}
		}

		[PunRPC]
		private void SetTeleportingStateRPC(bool isTeleporting)
		{
			this.isTeleporting = isTeleporting;
		}

		private void SetTeleportingState(bool teleporting)
		{
			if ((Object)(object)photonView != (Object)null && photonView.IsMine)
			{
				photonView.RPC("SetTeleportingStateRPC", (RpcTarget)0, new object[1] { teleporting });
			}
		}

		[PunRPC]
		private void SetLastHolderRPC(int viewID)
		{
			if (viewID == 0)
			{
				lastHolder = null;
				return;
			}
			PhotonView val = PhotonView.Find(viewID);
			if ((Object)(object)val != (Object)null)
			{
				lastHolder = ((Component)val).GetComponent<PhysGrabber>();
			}
		}

		private void UpdateLastHolder(PhysGrabber newHolder)
		{
			if ((Object)(object)photonView == (Object)null || !photonView.IsMine)
			{
				return;
			}
			int? obj;
			if (newHolder == null)
			{
				obj = null;
			}
			else
			{
				PlayerAvatar playerAvatar = newHolder.playerAvatar;
				if (playerAvatar == null)
				{
					obj = null;
				}
				else
				{
					PhotonView obj2 = playerAvatar.photonView;
					obj = ((obj2 != null) ? new int?(obj2.ViewID) : null);
				}
			}
			int? num = obj;
			int valueOrDefault = num.GetValueOrDefault();
			photonView.RPC("SetLastHolderRPC", (RpcTarget)0, new object[1] { valueOrDefault });
		}

		private string GetGameObjectPath(GameObject obj)
		{
			string text = ((Object)obj).name;
			Transform parent = obj.transform.parent;
			while ((Object)(object)parent != (Object)null)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}
	}
	[BepInPlugin("CarsonJF.EnderPearlMod", "EnderPearlMod", "2.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class EnderPearlMod : BaseUnityPlugin
	{
		private static readonly string BundleName = GetModName();

		private AssetBundle? _assetBundle;

		private bool _hasFixedAudioMixerGroups = false;

		internal static EnderPearlMod Instance { get; private set; } = null;


		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private static string GetModName()
		{
			object obj = typeof(EnderPearlMod).GetCustomAttributes(typeof(BepInPlugin), inherit: false)[0];
			BepInPlugin val = (BepInPlugin)((obj is BepInPlugin) ? obj : null);
			return ((val != null) ? val.Name : null) ?? "EnderPearlMod";
		}

		private void LoadAssetBundle()
		{
			if (!((Object)(object)_assetBundle != (Object)null))
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
				string text = Path.Combine(directoryName, BundleName + ".bundle");
				_assetBundle = AssetBundle.LoadFromFile(text);
				if ((Object)(object)_assetBundle == (Object)null)
				{
					Logger.LogError((object)("Failed to load bundle from " + text));
				}
			}
		}

		private void LoadValuablesFromResources()
		{
			if ((Object)(object)_assetBundle == (Object)null)
			{
				return;
			}
			List<GameObject> list = (from name in _assetBundle.GetAllAssetNames()
				where name.Contains("/valuables/") && name.EndsWith(".prefab")
				select _assetBundle.LoadAsset<GameObject>(name)).ToList();
			foreach (GameObject item in list)
			{
				if (((Object)item).name.Contains("enderpearl", StringComparison.OrdinalIgnoreCase))
				{
					if (!Object.op_Implicit((Object)(object)item.GetComponent<PhysGrabObject>()))
					{
						Logger.LogInfo((object)"Adding PhysGrabObject component to EnderPearl prefab");
						item.AddComponent<PhysGrabObject>();
					}
					if (!Object.op_Implicit((Object)(object)item.GetComponent<PhotonView>()))
					{
						Logger.LogInfo((object)"Adding PhotonView component to EnderPearl prefab");
						item.AddComponent<PhotonView>();
					}
					if (!Object.op_Implicit((Object)(object)item.GetComponent<EnderPearl>()))
					{
						Logger.LogInfo((object)"Adding EnderPearl component to prefab");
						item.AddComponent<EnderPearl>();
					}
				}
				Valuables.RegisterValuable(item);
			}
			if (list.Count > 0)
			{
				Logger.LogInfo((object)$"Successfully registered {list.Count} valuables through REPOLib");
			}
		}

		private void LoadItemsFromResources()
		{
			if ((Object)(object)_assetBundle == (Object)null)
			{
				return;
			}
			List<GameObject> list = (from name in _assetBundle.GetAllAssetNames()
				where name.Contains("/items/") && name.EndsWith(".prefab")
				select _assetBundle.LoadAsset<GameObject>(name)).ToList();
			foreach (GameObject item in list)
			{
				Item component = item.GetComponent<Item>();
				if ((Object)(object)component != (Object)null)
				{
					Items.RegisterItem(component);
				}
			}
			if (list.Count > 0)
			{
				Logger.LogInfo((object)$"Successfully registered {list.Count} items through REPOLib");
			}
		}

		private void LoadEnemiesFromResources()
		{
			if ((Object)(object)_assetBundle == (Object)null)
			{
				return;
			}
			List<GameObject> list = (from name in _assetBundle.GetAllAssetNames()
				where name.Contains("/enemies/") && name.EndsWith(".prefab")
				select _assetBundle.LoadAsset<GameObject>(name)).ToList();
			foreach (GameObject item in list)
			{
				EnemySetup component = item.GetComponent<EnemySetup>();
				if ((Object)(object)component != (Object)null)
				{
					Enemies.RegisterEnemy(component);
				}
				else
				{
					Logger.LogWarning((object)("Prefab " + ((Object)item).name + " does not contain an EnemySetup component"));
				}
			}
			if (list.Count > 0)
			{
				Logger.LogInfo((object)$"Successfully registered {list.Count} enemies through REPOLib");
			}
		}

		private void FixAllPrefabAudioMixerGroups()
		{
			if ((Object)(object)_assetBundle == (Object)null)
			{
				return;
			}
			List<GameObject> list = (from name in _assetBundle.GetAllAssetNames()
				where name.EndsWith(".prefab")
				select _assetBundle.LoadAsset<GameObject>(name)).ToList();
			foreach (GameObject item in list)
			{
				Utilities.FixAudioMixerGroups(item);
			}
		}

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			LoadAssetBundle();
			LoadValuablesFromResources();
			LoadItemsFromResources();
			LoadEnemiesFromResources();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//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)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
			if (!_hasFixedAudioMixerGroups)
			{
				FixAllPrefabAudioMixerGroups();
				_hasFixedAudioMixerGroups = true;
			}
		}
	}
}

BeepInEx/plugins/CarsonJF-JBLSpeaker/JBLSpeaker.dll

Decompiled 2 weeks 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;

[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: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("CarsonJF")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("JBLSpeaker Mod for REPO")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JBLSpeaker")]
[assembly: AssemblyTitle("JBLSpeaker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 JBLSpeaker
{
	public class ItemSoundHandler : MonoBehaviour
	{
		[Header("Audio")]
		public Sound[]? tracks;

		public Sound? powerOnSound;

		public Sound? powerOffSound;

		public Sound? skipSound;

		[Range(0.1f, 10f)]
		public float musicVolumeMultiplier = 1f;

		private int currentTrack = -1;

		private AudioSource? currentTrackSource;

		[Header("Effects")]
		public ParticleSystem? musicParticles;

		public ParticleSystem? impactParticles;

		public Light? speakerLight;

		public float impactParticleDuration = 2f;

		public Color lightColor = new Color(0f, 1f, 1f);

		public float lightIntensity = 2f;

		[Header("Settings")]
		public float minMessageDelay = 8f;

		public float maxMessageDelay = 16f;

		public bool skipOnImpact = true;

		private float coolDownUntilNextMessage;

		private float initialMessageDelay = 8f;

		private float musicStartDelay = 5f;

		private PhysGrabObject? physGrabObject;

		private PhysGrabObjectImpactDetector? impactDetector;

		private bool isPlaying;

		private readonly string[][] trackMessages = new string[4][]
		{
			new string[6] { "{playerName} can I hit it from behind?", "17 shots, no 38", "I got a glock in my 'Rari!", "{playerName}, rollin' with 679 vibes, let's ride!", "Stackin' paper, no delay, 679 all day!", "Keep it lit, {playerName}, no cap in the club!" },
			new string[6] { "I want {playerName} to be mine again!", "Ain't playin no games, I need {playerName}", "ayyyy yeah baby!", "Callin' you back, {playerName}, like I do again!", "Every time I see you, I'm fallin' for you again!", "Can't get enough, {playerName}, I'm all in again!" },
			new string[6] { "Hey, what's up, hello", "{playerName} is my Trap Queen!", "Talking matching lambos!!", "Slide through the trap, {playerName}, keep it fresh and mean!", "From blocks to big deals, {playerName} is my queen!", "No stoppin' the hustle, my trap queen's a dream!" },
			new string[6] { "SQUA!", "{playerName} won't you come my wayyyy!", "Two shots and I won't blink, ayy!!", "Straight out the block, {playerName}, doin' it my way!", "Keep it real, no limits, that's how we play!", "On my grind, {playerName}, my way every day!" }
		};

		private void Start()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			if ((Object)(object)impactDetector != (Object)null)
			{
				impactDetector.onImpactHeavy.AddListener(new UnityAction(OnHeavyImpact));
				impactDetector.onImpactMedium.AddListener(new UnityAction(OnMediumImpact));
				impactDetector.onImpactLight.AddListener(new UnityAction(OnLightImpact));
			}
			if ((Object)(object)musicParticles != (Object)null)
			{
				musicParticles.Stop();
				musicParticles.Clear();
			}
			if ((Object)(object)impactParticles != (Object)null)
			{
				impactParticles.Stop();
				impactParticles.Clear();
			}
			if ((Object)(object)speakerLight != (Object)null)
			{
				((Component)speakerLight).gameObject.SetActive(false);
			}
			isPlaying = false;
		}

		private void OnDestroy()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			if ((Object)(object)impactDetector != (Object)null)
			{
				impactDetector.onImpactHeavy.RemoveListener(new UnityAction(OnHeavyImpact));
				impactDetector.onImpactMedium.RemoveListener(new UnityAction(OnMediumImpact));
				impactDetector.onImpactLight.RemoveListener(new UnityAction(OnLightImpact));
			}
		}

		private void Update()
		{
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)physGrabObject == (Object)null)
			{
				return;
			}
			if (physGrabObject.grabbed && !isPlaying)
			{
				TurnOn();
			}
			if (isPlaying && (Object)(object)speakerLight != (Object)null && ((Component)speakerLight).gameObject.activeSelf)
			{
				speakerLight.intensity = Mathf.Lerp(speakerLight.intensity, lightIntensity, Time.deltaTime * 5f);
			}
			if (isPlaying && coolDownUntilNextMessage > 0f)
			{
				coolDownUntilNextMessage -= Time.deltaTime;
			}
			else
			{
				if (!isPlaying || currentTrack < 0 || tracks == null || currentTrack >= tracks.Length)
				{
					return;
				}
				bool flag = false;
				string newValue = "friend";
				if ((Object)(object)PhysGrabber.instance != (Object)null && PhysGrabber.instance.grabbed && (Object)(object)PhysGrabber.instance.grabbedPhysGrabObject == (Object)(object)physGrabObject)
				{
					if (SemiFunc.IsMultiplayer())
					{
						List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)this).transform.position, false, default(LayerMask));
						PlayerAvatar val = null;
						float num = float.MaxValue;
						foreach (PlayerAvatar item in list)
						{
							if ((Object)(object)item != (Object)(object)PlayerAvatar.instance)
							{
								float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position);
								if (num2 < num)
								{
									num = num2;
									val = item;
								}
							}
						}
						if ((Object)(object)val != (Object)null)
						{
							newValue = val.playerName;
						}
					}
					flag = true;
				}
				if (flag && (Object)(object)ChatManager.instance != (Object)null && !ChatManager.instance.StateIsPossessed())
				{
					string[] array = trackMessages[currentTrack];
					string text = array[Random.Range(0, array.Length)];
					text = text.Replace("{playerName}", newValue);
					Color val2 = default(Color);
					((Color)(ref val2))..ctor(1f, 0.9f, 0.5f, 1f);
					ChatManager.instance.PossessChatScheduleStart(10);
					ChatManager.instance.PossessChat((PossessChatID)1, text, 1f, val2, 0f, false, 0, (UnityEvent)null);
					ChatManager.instance.PossessChatScheduleEnd();
					coolDownUntilNextMessage = Random.Range(minMessageDelay, maxMessageDelay);
				}
			}
		}

		private void OnHeavyImpact()
		{
			if (!isPlaying)
			{
				return;
			}
			if ((Object)(object)physGrabObject == (Object)null || !physGrabObject.grabbed)
			{
				if ((Object)(object)impactParticles != (Object)null)
				{
					((Component)impactParticles).gameObject.SetActive(true);
					impactParticles.Clear();
					impactParticles.Play();
					((MonoBehaviour)this).Invoke("StopImpactParticles", impactParticleDuration);
				}
				TurnOff();
			}
			else
			{
				SkipTrack();
			}
		}

		private void OnMediumImpact()
		{
			if (isPlaying)
			{
				SkipTrack();
			}
		}

		private void OnLightImpact()
		{
		}

		private void StopImpactParticles()
		{
			if ((Object)(object)impactParticles != (Object)null)
			{
				impactParticles.Stop();
				((Component)impactParticles).gameObject.SetActive(false);
			}
		}

		private void TurnOn()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			isPlaying = true;
			if ((Object)(object)musicParticles != (Object)null)
			{
				((Component)musicParticles).gameObject.SetActive(true);
				musicParticles.Clear();
				musicParticles.Play();
			}
			if ((Object)(object)speakerLight != (Object)null)
			{
				speakerLight.color = lightColor;
				speakerLight.intensity = lightIntensity;
				((Component)speakerLight).gameObject.SetActive(true);
			}
			if (powerOnSound != null && (Object)(object)physGrabObject != (Object)null)
			{
				powerOnSound.Play(physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
			}
			if (tracks != null && tracks.Length != 0)
			{
				if (currentTrack == -1)
				{
					currentTrack = 0;
				}
				((MonoBehaviour)this).CancelInvoke("PlayMusic");
				((MonoBehaviour)this).Invoke("PlayMusic", musicStartDelay);
			}
			coolDownUntilNextMessage = initialMessageDelay;
		}

		private void PlayMusic()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (isPlaying && currentTrack >= 0 && tracks != null && currentTrack < tracks.Length && (Object)(object)physGrabObject != (Object)null)
			{
				if ((Object)(object)currentTrackSource != (Object)null)
				{
					currentTrackSource.Stop();
					currentTrackSource = null;
				}
				currentTrackSource = tracks[currentTrack].Play(physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
				if ((Object)(object)currentTrackSource != (Object)null)
				{
					currentTrackSource.loop = true;
					currentTrackSource.volume = musicVolumeMultiplier;
					currentTrackSource.spatialBlend = 1f;
					currentTrackSource.priority = 0;
				}
			}
		}

		private void TurnOff()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			isPlaying = false;
			if ((Object)(object)musicParticles != (Object)null)
			{
				musicParticles.Stop();
				((Component)musicParticles).gameObject.SetActive(false);
			}
			if ((Object)(object)speakerLight != (Object)null)
			{
				((Component)speakerLight).gameObject.SetActive(false);
			}
			if (powerOffSound != null && (Object)(object)physGrabObject != (Object)null)
			{
				powerOffSound.Play(physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
			}
			if ((Object)(object)currentTrackSource != (Object)null)
			{
				currentTrackSource.Stop();
				currentTrackSource = null;
			}
			currentTrack = -1;
		}

		public void SkipTrack()
		{
			//IL_004e: 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)
			if (isPlaying && tracks != null && tracks.Length > 1 && !((Object)(object)physGrabObject == (Object)null))
			{
				if (skipSound != null)
				{
					skipSound.Play(physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
				}
				if ((Object)(object)currentTrackSource != (Object)null)
				{
					currentTrackSource.Stop();
					currentTrackSource = null;
				}
				currentTrack = (currentTrack + 1) % tracks.Length;
				currentTrackSource = tracks[currentTrack].Play(physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
				if ((Object)(object)currentTrackSource != (Object)null)
				{
					currentTrackSource.loop = true;
					currentTrackSource.volume = musicVolumeMultiplier;
					currentTrackSource.spatialBlend = 1f;
					currentTrackSource.priority = 0;
				}
				else
				{
					Debug.LogError((object)"Failed to create audio source for new track");
				}
			}
		}
	}
	[BepInPlugin("CarsonJF.JBLSpeaker", "JBLSpeaker", "1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class JBLSpeaker : BaseUnityPlugin
	{
		private static readonly string BundleName = GetModName();

		private AssetBundle? _assetBundle;

		private bool _hasFixedAudioMixerGroups = false;

		internal static JBLSpeaker Instance { get; private set; } = null;


		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private static string GetModName()
		{
			object obj = typeof(JBLSpeaker).GetCustomAttributes(typeof(BepInPlugin), inherit: false)[0];
			BepInPlugin val = (BepInPlugin)((obj is BepInPlugin) ? obj : null);
			return ((val != null) ? val.Name : null) ?? "JBLSpeaker";
		}

		private void LoadAssetBundle()
		{
			if (!((Object)(object)_assetBundle != (Object)null))
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
				string text = Path.Combine(directoryName, BundleName + ".bundle");
				_assetBundle = AssetBundle.LoadFromFile(text);
				if ((Object)(object)_assetBundle == (Object)null)
				{
					Logger.LogError((object)("Failed to load bundle from " + text));
				}
			}
		}

		private void LoadValuablesFromResources()
		{
			if ((Object)(object)_assetBundle == (Object)null)
			{
				return;
			}
			List<GameObject> list = (from name in _assetBundle.GetAllAssetNames()
				where name.Contains("/valuables/") && name.EndsWith(".prefab")
				select _assetBundle.LoadAsset<GameObject>(name)).ToList();
			foreach (GameObject item in list)
			{
				Valuables.RegisterValuable(item);
			}
			if (list.Count > 0)
			{
				Logger.LogInfo((object)$"Successfully registered {list.Count} valuables through REPOLib");
			}
		}

		private void LoadItemsFromResources()
		{
			if ((Object)(object)_assetBundle == (Object)null)
			{
				return;
			}
			List<Item> list = (from name in _assetBundle.GetAllAssetNames()
				where name.Contains("/items/") && name.EndsWith(".asset")
				select _assetBundle.LoadAsset<Item>(name)).ToList();
			Logger.LogInfo((object)$"Found {list.Count} item asset");
			foreach (Item item in list)
			{
				if ((Object)(object)item == (Object)null)
				{
					Logger.LogError((object)"Failed to load item - item is null");
					continue;
				}
				try
				{
					Items.RegisterItem(item);
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Failed to register item " + ((Object)item).name + ": " + ex.Message));
				}
			}
			if (list.Count > 0)
			{
				Logger.LogInfo((object)$"Successfully registered {list.Count} items through REPOLib");
			}
		}

		private void LoadEnemiesFromResources()
		{
			if ((Object)(object)_assetBundle == (Object)null)
			{
				return;
			}
			List<GameObject> list = (from name in _assetBundle.GetAllAssetNames()
				where name.Contains("/enemies/") && name.EndsWith(".prefab")
				select _assetBundle.LoadAsset<GameObject>(name)).ToList();
			foreach (GameObject item in list)
			{
				EnemySetup component = item.GetComponent<EnemySetup>();
				if ((Object)(object)component != (Object)null)
				{
					Enemies.RegisterEnemy(component);
				}
				else
				{
					Logger.LogWarning((object)("Prefab " + ((Object)item).name + " does not contain an EnemySetup component"));
				}
			}
			if (list.Count > 0)
			{
				Logger.LogInfo((object)$"Successfully registered {list.Count} enemies through REPOLib");
			}
		}

		private void FixAllPrefabAudioMixerGroups()
		{
			if ((Object)(object)_assetBundle == (Object)null)
			{
				return;
			}
			List<GameObject> list = (from name in _assetBundle.GetAllAssetNames()
				where name.EndsWith(".prefab")
				select _assetBundle.LoadAsset<GameObject>(name)).ToList();
			foreach (GameObject item in list)
			{
				Utilities.FixAudioMixerGroups(item);
			}
		}

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			LoadAssetBundle();
			LoadValuablesFromResources();
			LoadItemsFromResources();
			LoadEnemiesFromResources();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//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)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
			if (!_hasFixedAudioMixerGroups)
			{
				FixAllPrefabAudioMixerGroups();
				_hasFixedAudioMixerGroups = true;
			}
		}
	}
}

BeepInEx/plugins/CoddingCat-ToggleMute/ToggleMute.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Voice.Unity;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ToggleMute")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod for Repo")]
[assembly: AssemblyFileVersion("0.0.5.0")]
[assembly: AssemblyInformationalVersion("0.0.5+d2d866fd73d0e86b799bd7475b8582103b6a59b8")]
[assembly: AssemblyProduct("ToggleMute")]
[assembly: AssemblyTitle("ToggleMute")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.5.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ToggleMute
{
	[HarmonyPatch(typeof(PlayerVoiceChat), "OnDestroy")]
	internal class PushToMuteCleanupPatch
	{
		[HarmonyPrefix]
		private static void Prefix(PlayerVoiceChat __instance)
		{
			if (PushToMutePatch.playerRecorders.ContainsKey(__instance))
			{
				PushToMutePatch.playerRecorders.Remove(__instance);
				PushToMutePatch.AnimateIconCoroutine = null;
			}
			else
			{
				Debug.Log((object)("PlayerVoiceChat OnDestroy: No recorder found for " + ((Component)__instance).GetComponent<PhotonView>().Owner.NickName + "."));
			}
		}
	}
	[HarmonyPatch(typeof(PlayerVoiceChat), "Awake")]
	internal class PushToMuteInitPatch
	{
		[HarmonyPostfix]
		private static void Postfix(PlayerVoiceChat __instance)
		{
			PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
			Recorder component2 = ((Component)__instance).GetComponent<Recorder>();
			if ((Object)(object)component != (Object)null && component.IsMine && (Object)(object)component2 != (Object)null)
			{
				PushToMutePatch.playerRecorders[__instance] = component2;
			}
		}
	}
	[BepInPlugin("com.coddingcat.togglemute", "ToggleMute", "1.0.0")]
	public class PushToMuteMod : BaseUnityPlugin
	{
		private Harmony harmony;

		private static GameObject hudCanvas;

		public AssetBundle muteIconBundle;

		public static PushToMuteMod Instance;

		public static ConfigEntry<KeyCode> MuteKey { get; private set; }

		public static ConfigEntry<float> SoundVolume { get; private set; }

		public static ConfigEntry<int> AnimationTime { get; private set; }

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			BindCofigs();
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			harmony = new Harmony("com.coddingcat.pushtomute");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Push-to-Mute mod loaded! Key: {MuteKey.Value}");
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void BindCofigs()
		{
			MuteKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "MuteKey", (KeyCode)109, "Key to toggle Push-to-Mute (Change in config file)");
			SoundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SoundVolume", 0.3f, "Volume of mute/unmute sound (0.0 - 1.0)");
			AnimationTime = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Animation Duration", 200, "Duration of the mute icon animation in milliseconds.");
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			PushToMutePatch.UpdateUI(PushToMutePatch.isMuted);
		}

		private void LogAssetNames(AssetBundle bundle)
		{
			if (!((Object)(object)bundle == (Object)null))
			{
				string[] allAssetNames = bundle.GetAllAssetNames();
				string[] array = allAssetNames;
				foreach (string text in array)
				{
					Debug.Log((object)("Asset in bundle: " + text));
				}
			}
		}

		public static GameObject GetHudCanvas()
		{
			if ((Object)(object)hudCanvas == (Object)null)
			{
				hudCanvas = GameObject.Find("UI/HUD/HUD Canvas");
				if ((Object)(object)hudCanvas == (Object)null)
				{
					Debug.LogError((object)"HUD Canvas not found");
				}
			}
			return hudCanvas;
		}
	}
	[HarmonyPatch(typeof(PlayerVoiceChat), "Update")]
	internal class PushToMutePatch
	{
		public static Dictionary<PlayerVoiceChat, Recorder> playerRecorders = new Dictionary<PlayerVoiceChat, Recorder>();

		private static GameObject muteIcon;

		private static GameObject cutLineIcon;

		private static Image muteIconImage;

		private static Image cutLineImage;

		private static Color muteIconColor;

		private static Color cutLineColor;

		private static AssetBundle muteIconBundle;

		private static AudioSource audioSource;

		private static AudioClip muteSound;

		private static AudioClip unmuteSound;

		public static PlayerVoiceChat instance;

		public static Coroutine AnimateIconCoroutine;

		public static bool isMuted = false;

		private static float t = 0f;

		public static void UpdateUI(bool Animation)
		{
			if ((Object)(object)muteIcon == (Object)null)
			{
				InitMuteIcon();
			}
			isMuted = Animation;
			AnimateIconCoroutine = ((MonoBehaviour)PushToMuteMod.Instance).StartCoroutine(AnimateIcon());
		}

		[HarmonyPostfix]
		private static void Postfix(PlayerVoiceChat __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			instance = __instance;
			if (!playerRecorders.TryGetValue(__instance, out var value))
			{
				return;
			}
			KeyCode value2 = PushToMuteMod.MuteKey.Value;
			if ((Object)(object)muteIcon == (Object)null)
			{
				InitMuteIcon();
			}
			if (!(bool)typeof(ChatManager).GetField("chatActive", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(ChatManager.instance))
			{
				if (Input.GetKeyDown(value2))
				{
					isMuted = !isMuted;
					audioSource.clip = (isMuted ? muteSound : unmuteSound);
					audioSource.Play();
					value.TransmitEnabled = !isMuted;
					value.RecordingEnabled = !isMuted;
				}
				bool flag = AnimateIconCoroutine != null;
				bool flag2 = (t != 1f || !isMuted) && (t != 0f || isMuted);
				if (!flag && flag2)
				{
					AnimateIconCoroutine = ((MonoBehaviour)__instance).StartCoroutine(AnimateIcon());
				}
			}
		}

		private static void InitMuteIcon()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0127: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			GameObject hudCanvas = PushToMuteMod.GetHudCanvas();
			if ((Object)(object)hudCanvas == (Object)null)
			{
				return;
			}
			GameObject val = new GameObject("MuteIconContainer");
			RectTransform val2 = val.AddComponent<RectTransform>();
			((Transform)val2).SetParent(hudCanvas.transform, false);
			Vector2 sizeDelta = default(Vector2);
			((Vector2)(ref sizeDelta))..ctor(40f, 40f);
			val2.anchorMin = new Vector2(1f, 0f);
			val2.anchorMax = new Vector2(1f, 0f);
			val2.pivot = new Vector2(1f, 0f);
			val2.anchoredPosition = new Vector2(-10f, 10f);
			val2.sizeDelta = sizeDelta;
			muteIcon = new GameObject("MuteIcon");
			RectTransform val3 = muteIcon.AddComponent<RectTransform>();
			((Transform)val3).SetParent((Transform)(object)val2);
			val3.pivot = new Vector2(0.5f, 0.5f);
			val3.anchoredPosition = Vector2.op_Implicit(Vector3.zero);
			val3.sizeDelta = sizeDelta;
			cutLineIcon = new GameObject("CutLine");
			RectTransform val4 = cutLineIcon.AddComponent<RectTransform>();
			((Transform)val4).SetParent((Transform)(object)val2, false);
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.zero;
			val4.pivot = Vector2.zero;
			val4.anchoredPosition = Vector2.op_Implicit(Vector3.zero);
			val4.sizeDelta = sizeDelta;
			muteIconImage = muteIcon.AddComponent<Image>();
			cutLineImage = cutLineIcon.AddComponent<Image>();
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			if ((Object)(object)muteIconBundle == (Object)null)
			{
				muteIconBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "togglemutebundle"));
			}
			if ((Object)(object)muteIconBundle != (Object)null)
			{
				Sprite val5 = muteIconBundle.LoadAsset<Sprite>("assets/unmuted.png");
				Sprite val6 = muteIconBundle.LoadAsset<Sprite>("assets/cutLine.png");
				muteSound = muteIconBundle.LoadAsset<AudioClip>("assets/on.ogg");
				unmuteSound = muteIconBundle.LoadAsset<AudioClip>("assets/off.ogg");
				if ((Object)(object)val5 != (Object)null && (Object)(object)val6 != (Object)null)
				{
					muteIconImage.sprite = val5;
					cutLineImage.sprite = val6;
				}
			}
			muteIconColor = ((Graphic)muteIconImage).color;
			cutLineColor = ((Graphic)cutLineImage).color;
			if ((Object)(object)audioSource == (Object)null)
			{
				audioSource = muteIcon.AddComponent<AudioSource>();
			}
			audioSource.volume = PushToMuteMod.SoundVolume.Value;
		}

		private static IEnumerator AnimateIcon()
		{
			while (true)
			{
				if ((Object)(object)muteIcon == (Object)null || (Object)(object)muteIconImage == (Object)null)
				{
					AnimateIconCoroutine = null;
					yield break;
				}
				if (t == 1f && isMuted)
				{
					muteIcon.transform.localScale = Vector3.one;
					muteIconColor.a = 1f;
					((Graphic)muteIconImage).color = muteIconColor;
					cutLineIcon.transform.localScale = Vector3.one;
					cutLineColor.a = 1f;
					((Graphic)cutLineImage).color = cutLineColor;
					AnimateIconCoroutine = null;
					yield break;
				}
				if (t == 0f && !isMuted)
				{
					break;
				}
				if (PushToMuteMod.AnimationTime.Value == 0)
				{
					t = (isMuted ? 1f : 0f);
				}
				else
				{
					float animationTimeInSeconds = (float)PushToMuteMod.AnimationTime.Value * 0.001f;
					t = Mathf.MoveTowards(t, isMuted ? 1f : 0f, Time.deltaTime / animationTimeInSeconds);
				}
				float easeT = EaseInOut(t);
				muteIcon.transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one, easeT);
				cutLineIcon.transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one, easeT);
				muteIconColor = ((Graphic)muteIconImage).color;
				muteIconColor.a = Mathf.Lerp(0f, 1f, easeT);
				cutLineColor = ((Graphic)cutLineImage).color;
				cutLineColor.a = Mathf.Lerp(0f, 1f, easeT);
				((Graphic)cutLineImage).color = cutLineColor;
				((Graphic)muteIconImage).color = muteIconColor;
				yield return null;
			}
			muteIcon.transform.localScale = Vector3.zero;
			muteIconColor.a = 0f;
			((Graphic)muteIconImage).color = muteIconColor;
			cutLineIcon.transform.localScale = Vector3.zero;
			cutLineColor.a = 0f;
			((Graphic)cutLineImage).color = cutLineColor;
			AnimateIconCoroutine = null;
		}

		private static float EaseInOut(float t)
		{
			return t * t * (3f - 2f * t);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ToggleMute";

		public const string PLUGIN_NAME = "ToggleMute";

		public const string PLUGIN_VERSION = "0.0.5";
	}
}

BeepInEx/plugins/Cronchy-DeathHeadHopper/DeathHeadHopper.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;

[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-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("Cronchy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.5.0")]
[assembly: AssemblyInformationalVersion("1.1.5+fdb6dd6bfad39fc23c04d0044cc146c4e67c9260")]
[assembly: AssemblyProduct("DeathHeadHopper")]
[assembly: AssemblyTitle("DeathHeadHopper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.5.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 DeathHeadHopper
{
	public class DeathHeadController : MonoBehaviourPun
	{
		internal PlayerDeathHead deathHead;

		internal Rigidbody rb;

		internal HeadCollisionHandler collisionHandler;

		internal PhysGrabObjectImpactDetector impactDetector;

		internal HeadHopHandler hopHandler;

		internal HeadJumpHandler jumpHandler;

		internal HeadAudioHandler audioHandler;

		internal HeadReboundHandler reboundHandler;

		internal HeadAnchorHandler anchorHandler;

		internal HeadEyeHandler eyeHandler;

		public UnityEvent m_HeadJumpEvent = new UnityEvent();

		public UnityEvent m_HeadHopEvent = new UnityEvent();

		public float maxCooldownMultiplier = 4f;

		public float startReboundTruckDistance = 3f;

		public float truckRoomRadius = 8f;

		internal float distanceToTruckRoom;

		internal bool spectated;

		internal float recentlyGrabbedTimer;

		protected void Start()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			deathHead = ((Component)this).GetComponent<PlayerDeathHead>();
			rb = ((Component)this).GetComponent<Rigidbody>();
			impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			impactDetector.playerHurtDisable = false;
			if (m_HeadJumpEvent == null)
			{
				m_HeadJumpEvent = new UnityEvent();
			}
			if (m_HeadHopEvent == null)
			{
				m_HeadHopEvent = new UnityEvent();
			}
			collisionHandler = ((Component)this).gameObject.AddComponent<HeadCollisionHandler>();
			hopHandler = ((Component)this).gameObject.AddComponent<HeadHopHandler>();
			jumpHandler = ((Component)this).gameObject.AddComponent<HeadJumpHandler>();
			audioHandler = ((Component)this).gameObject.AddComponent<HeadAudioHandler>();
			reboundHandler = ((Component)this).gameObject.AddComponent<HeadReboundHandler>();
			anchorHandler = ((Component)this).gameObject.AddComponent<HeadAnchorHandler>();
			eyeHandler = ((Component)this).gameObject.AddComponent<HeadEyeHandler>();
		}

		protected void Update()
		{
			//IL_0015: 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)
			distanceToTruckRoom = Mathf.Max(0f, Vector3.Distance(((Component)LevelGenerator.Instance.LevelPathTruck).transform.position, ((Component)this).transform.position) - truckRoomRadius);
			FixDeathHeadTpWhenOutsideRoom();
			if (anchorHandler.isAnchored)
			{
				deathHead.inTruckReviveTimer = 0.4f;
			}
		}

		protected void FixDeathHeadTpWhenOutsideRoom()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || (int)GameDirector.instance.currentState != 2)
			{
				return;
			}
			if (((Component)this).transform.position.y < -50f)
			{
				if (RoundDirector.instance.extractionPointActive)
				{
					deathHead.physGrabObject.Teleport(RoundDirector.instance.extractionPointCurrent.safetySpawn.position, RoundDirector.instance.extractionPointCurrent.safetySpawn.rotation);
				}
				else
				{
					deathHead.physGrabObject.Teleport(((Component)TruckSafetySpawnPoint.instance).transform.position, ((Component)TruckSafetySpawnPoint.instance).transform.rotation);
				}
				rb.velocity = Vector3.zero;
				if (anchorHandler.isAnchored)
				{
					anchorHandler.DestroyAnchor();
				}
			}
			if (deathHead.outsideLevelTimer > 0f)
			{
				deathHead.outsideLevelTimer = 0f;
			}
		}

		protected void LateUpdate()
		{
			UpdateSpectated();
		}

		private void UpdateSpectated()
		{
			if (!deathHead.playerAvatar.isLocal)
			{
				return;
			}
			if (!deathHead.triggered || SpectateCamera.instance?.player == null)
			{
				spectated = false;
			}
			else if ((Object)(object)SpectateCamera.instance.player == (Object)(object)PlayerAvatar.instance && !spectated)
			{
				if (GameManager.Multiplayer())
				{
					((MonoBehaviourPun)this).photonView.RPC("SetSpectated", (RpcTarget)1, new object[1] { true });
				}
				SetSpectated(value: true);
			}
			else if ((Object)(object)SpectateCamera.instance.player != (Object)(object)PlayerAvatar.instance && spectated)
			{
				if (GameManager.Multiplayer())
				{
					((MonoBehaviourPun)this).photonView.RPC("SetSpectated", (RpcTarget)1, new object[1] { false });
				}
				SetSpectated(value: false);
			}
		}

		[PunRPC]
		internal void SetSpectated(bool value)
		{
			spectated = value;
		}
	}
	[BepInPlugin("Cronchy.DeathHeadHopper", "DeathHeadHopper", "1.1.6")]
	public class DeathHeadHopper : BaseUnityPlugin
	{
		public static GameObject? DeathHeadHopperPrefab;

		private const string _mainAssetBundle = "DeathHeadHopper";

		public static ConfigEntry<bool> FlashlightFlicker;

		public static ConfigEntry<bool> AlwaysAnchor;

		internal static DeathHeadHopper Instance { get; private set; }

		internal static ManualLogSource Logger => Instance.ManualLogger;

		private ManualLogSource ManualLogger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		internal void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			BindConfig();
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//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: Expected O, but got Unknown
			//IL_0025: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void BindConfig()
		{
			string text = "General";
			string text2 = "Host Client Config";
			FlashlightFlicker = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "FlashlightFlicker", true, "The playerdeathhead flickers its flashlight to indicate when something is wrong.");
			AlwaysAnchor = ((BaseUnityPlugin)this).Config.Bind<bool>(text2, "AnchorOnAllStages", false, "Always tether playerdeathhead to an anchor on the ground, instead of only once the last extraction point is completed.");
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private static void LoadAssets()
		{
			Logger.LogInfo((object)"Loading Assets...");
			AssetBundle val = LoadAssetBundle("DeathHeadHopper");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to load asset bundle :(");
				return;
			}
			DeathHeadHopperPrefab = val.LoadAsset<GameObject>("Assets/DeathHeadHopper.prefab");
			if ((Object)(object)DeathHeadHopperPrefab == (Object)null)
			{
				Logger.LogError((object)"Failed to load prefab :(");
			}
			else
			{
				Logger.LogInfo((object)"Assets loaded!");
			}
		}

		private static AssetBundle LoadAssetBundle(string name)
		{
			Logger.LogDebug((object)("DeathHeadHopper: Loading Asset Bundle: " + name));
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
			return AssetBundle.LoadFromFile(text);
		}
	}
	public class DeathHeadHopperController : MonoBehaviour
	{
		public Vector3 spectateOffset = new Vector3(0f, 0.6f, 0f);

		private PlayerDeathHead deathHead;

		private Transform headTransform;

		private PhotonView headPhotonView;

		private HeadJumpHandler jumpHandler;

		private HeadHopHandler hopHandler;

		private Transform _tMainCamera;

		protected void Awake()
		{
			_tMainCamera = ((Component)Camera.main).transform;
			deathHead = PlayerAvatar.instance.playerDeathHead;
			headTransform = ((Component)deathHead).transform;
			headPhotonView = ((Component)deathHead).GetComponent<PhotonView>();
			DeathHeadController component = ((Component)deathHead).GetComponent<DeathHeadController>();
			jumpHandler = component.jumpHandler;
			hopHandler = component.hopHandler;
			PlayerAvatar.instance.spectatePoint = ((Component)this).transform;
		}

		protected void Update()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)headTransform) && Object.op_Implicit((Object)(object)((Component)this).transform))
			{
				Quaternion val = Quaternion.LookRotation(Vector3.ProjectOnPlane(headTransform.forward, Vector3.up));
				Quaternion rotation = ((Component)this).transform.rotation;
				float x = ((Quaternion)(ref rotation)).eulerAngles.x;
				float y = ((Quaternion)(ref val)).eulerAngles.y;
				rotation = ((Component)this).transform.rotation;
				Quaternion val2 = Quaternion.Euler(x, y, ((Quaternion)(ref rotation)).eulerAngles.z);
				((Component)this).transform.SetPositionAndRotation(headTransform.position + spectateOffset, val2);
			}
		}

		protected void LateUpdate()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)SpectateCamera.instance.player != (Object)(object)PlayerAvatar.instance)
			{
				return;
			}
			if (SemiFunc.InputDown((InputKey)1))
			{
				Jump();
			}
			if (SemiFunc.InputDown((InputKey)14))
			{
				Vector3 val = Vector3.ProjectOnPlane(((Component)_tMainCamera).transform.forward, Vector3.up);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					hopHandler.HopRealign(normalized);
					return;
				}
				headPhotonView.RPC("HopRealign", (RpcTarget)2, new object[1] { normalized });
			}
		}

		private void Jump()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0072: 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_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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_0089: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.ProjectOnPlane(((Component)_tMainCamera).transform.forward, Vector3.up);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val2 = Vector3.Cross(Vector3.up, normalized);
			float num = SemiFunc.InputMovementX();
			float num2 = SemiFunc.InputMovementY();
			Vector3 val3 = Vector3.zero;
			if (num2 > 0f)
			{
				val3 += normalized;
			}
			if (num2 < 0f)
			{
				val3 -= normalized;
			}
			if (num < 0f)
			{
				val3 -= val2;
			}
			if (num > 0f)
			{
				val3 += val2;
			}
			val3 = ((Vector3)(ref val3)).normalized;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				jumpHandler.JumpHead(val3);
				return;
			}
			headPhotonView.RPC("JumpHead", (RpcTarget)2, new object[1] { val3 });
		}
	}
	public static class DHHFunc
	{
		public static GameObject? DeathHeadHopperObj;

		public static bool IsDeathHeadSpectatable(PlayerAvatar player)
		{
			if ((Object)(object)player == (Object)(object)PlayerAvatar.instance)
			{
				if (!SemiFunc.RunIsLevel())
				{
					return SemiFunc.RunIsShop();
				}
				return true;
			}
			return false;
		}

		public static bool IsLastPointExtracting()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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
			RoundDirector instance = RoundDirector.instance;
			if (instance.extractionPointsCompleted >= instance.extractionPoints - 1 && Object.op_Implicit((Object)(object)instance.extractionPointCurrent))
			{
				if ((int)instance.extractionPointCurrent.currentState != 3 && (int)instance.extractionPointCurrent.currentState != 4)
				{
					return (int)instance.extractionPointCurrent.currentState == 6;
				}
				return true;
			}
			return false;
		}
	}
	internal class HeadAnchorHandler : MonoBehaviour
	{
		private DeathHeadController controller;

		public float anchorRadius = 8f;

		public Vector3 tetherOffset = new Vector3(0f, 0.2f, 0f);

		public float anchorReboundForce = 0.05f;

		public float lightThreshold = 0.95f;

		public float minGroundedTime = 0.5f;

		public float breakSpeed = 2f;

		public float unAnchorDelay = 0.8f;

		public Vector4 cameraShake = new Vector4(5f, 3f, 8f, 0.5f);

		public Vector4 cameraImpact = new Vector4(5f, 3f, 8f, 0.25f);

		internal bool isAnchored;

		private float distanceFromAnchor;

		private float unAnchorTimer;

		private float anchoredFor;

		private Vector3 headAnchorPoint;

		private Tether? anchorTether;

		private bool isBreaking;

		private Vector3 breakPoint = Vector3.zero;

		private float breakingLerp;

		private bool hasAnchoredAfterExtracted;

		private float reAnchorCooldown;

		protected void Awake()
		{
			controller = ((Component)this).GetComponent<DeathHeadController>();
		}

		protected void Start()
		{
			controller.reboundHandler.AddReboundForce(new HeadReboundHandler.Rebound(() => headAnchorPoint - ((Component)this).transform.position, () => isAnchored && distanceFromAnchor > anchorRadius, () => Mathf.Min(distanceFromAnchor / anchorRadius * anchorReboundForce, controller.reboundHandler.defaultReboundForce), shouldNegateProductVelocity: false));
			controller.eyeHandler.eyeNegativeConditions.Add(delegate
			{
				float num = controller.anchorHandler.anchoredFor;
				return num > 0.1f && num < 1f;
			});
			controller.eyeHandler.eyeNegativeConditions.Add(isOutsideAnchorRange);
			controller.eyeHandler.eyeFlickerConditions.Add(isOutsideAnchorRange);
			bool isOutsideAnchorRange()
			{
				return controller.anchorHandler.distanceFromAnchor / controller.anchorHandler.anchorRadius > controller.anchorHandler.lightThreshold;
			}
		}

		protected void Update()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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)
			UpdateAnchorState();
			if (isAnchored)
			{
				distanceFromAnchor = Vector3.Distance(headAnchorPoint, ((Component)this).transform.position);
				anchoredFor += Time.deltaTime;
			}
			else
			{
				distanceFromAnchor = 0f;
				anchoredFor = 0f;
			}
			if (isBreaking && anchorTether != null)
			{
				breakingLerp += Time.deltaTime * breakSpeed;
				anchorTether.point = Vector3.Lerp(breakPoint, headAnchorPoint, breakingLerp);
				if (breakingLerp >= 1f)
				{
					((Component)anchorTether).gameObject.SetActive(false);
					isBreaking = false;
				}
			}
			if (isAnchored && !isBreaking)
			{
				UpdateTetherPoint();
			}
		}

		private void UpdateAnchorState()
		{
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (!RoundDirector.instance.allExtractionPointsCompleted)
			{
				hasAnchoredAfterExtracted = false;
			}
			bool grabbed = controller.impactDetector.physGrabObject.grabbed;
			bool collidingCartWasGrabbed = controller.collisionHandler.collidingCartWasGrabbed;
			unAnchorTimer = ((grabbed || collidingCartWasGrabbed) ? (unAnchorTimer + Time.deltaTime) : 0f);
			reAnchorCooldown = ((grabbed || collidingCartWasGrabbed) ? (reAnchorCooldown - Time.deltaTime) : 0.5f);
			bool flag = !DeathHeadHopper.AlwaysAnchor.Value && !RoundDirector.instance.allExtractionPointsCompleted;
			if (unAnchorTimer > unAnchorDelay || !controller.deathHead.triggered || flag)
			{
				if (isAnchored)
				{
					DestroyAnchor();
				}
			}
			else
			{
				if (reAnchorCooldown <= 0f)
				{
					return;
				}
				bool flag2 = !hasAnchoredAfterExtracted && RoundDirector.instance.allExtractionPointsCompleted;
				if (flag2 || (controller.collisionHandler.isColliding && !controller.collisionHandler.IsCollidingCart))
				{
					if (flag2)
					{
						hasAnchoredAfterExtracted = true;
					}
					Vector3? groundPointDown = controller.collisionHandler.GetGroundPointDown();
					if (!isAnchored && groundPointDown.HasValue)
					{
						CreateAnchor(groundPointDown.Value);
					}
				}
			}
		}

		private void UpdateTetherPoint()
		{
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (anchorTether != null && ((Component)anchorTether).gameObject.activeInHierarchy)
			{
				Vector3 point = ((Component)this).transform.TransformPoint(tetherOffset);
				anchorTether.point = point;
				anchorTether.colorInterpolation = Mathf.Max(0f, (Mathf.Clamp01(distanceFromAnchor / anchorRadius) - lightThreshold) * (1f / (1f - lightThreshold)));
			}
		}

		private void EnableTether()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0013: Expected O, but got Unknown
			if (anchorTether == null)
			{
				GameObject val = new GameObject("HeadAnchorTether");
				val.transform.parent = ((Component)this).transform;
				anchorTether = val.AddComponent<Tether>();
			}
			((Component)anchorTether).gameObject.SetActive(true);
			anchorTether.origin = headAnchorPoint;
			anchorTether.curveEnabled = true;
			controller.audioHandler.PlayAnchorAttachSound();
			UpdateTetherPoint();
			anchorTether.ResetCurvePointSmooth();
			isBreaking = false;
		}

		private void DisableTether()
		{
			//IL_00ee: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			if (anchorTether == null)
			{
				return;
			}
			if (controller.deathHead.triggered)
			{
				controller.audioHandler.PlayAnchorBreakSound();
				if (controller.deathHead.playerAvatar.isLocal)
				{
					GameDirector.instance.CameraShake.ShakeDistance(cameraShake.x, cameraShake.y, cameraShake.z, ((Component)this).transform.position, cameraShake.w);
					GameDirector.instance.CameraImpact.ShakeDistance(cameraImpact.x, cameraImpact.y, cameraImpact.z, ((Component)this).transform.position, cameraImpact.w);
				}
			}
			anchorTether.curveEnabled = false;
			isBreaking = true;
			breakPoint = anchorTether.point;
			breakingLerp = 0f;
		}

		internal void CreateAnchor(Vector3 position)
		{
			//IL_002f: 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)
			isAnchored = true;
			if (!SemiFunc.IsMultiplayer())
			{
				CreateAnchorRPC(position);
				return;
			}
			((MonoBehaviourPun)controller).photonView.RPC("CreateAnchorRPC", (RpcTarget)0, new object[1] { position });
		}

		[PunRPC]
		internal void CreateAnchorRPC(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			headAnchorPoint = position;
			isAnchored = true;
			EnableTether();
		}

		internal void DestroyAnchor()
		{
			isAnchored = false;
			if (!SemiFunc.IsMultiplayer())
			{
				DestroyAnchorRPC();
			}
			else
			{
				((MonoBehaviourPun)controller).photonView.RPC("DestroyAnchorRPC", (RpcTarget)0, Array.Empty<object>());
			}
		}

		[PunRPC]
		internal void DestroyAnchorRPC()
		{
			isAnchored = false;
			DisableTether();
		}
	}
	public class HeadAudioHandler : MonoBehaviour
	{
		private DeathHeadController controller;

		public Sound? jumpSound;

		public Sound? anchorBreakSound;

		public Sound? anchorAttachSound;

		protected void Awake()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			controller = ((Component)this).GetComponent<DeathHeadController>();
			AudioSource val = ((Component)this).gameObject.GetComponent<AudioSource>();
			if ((Object)(object)val == (Object)null)
			{
				DeathHeadHopper.Logger.LogDebug((object)"No existing AudioSource. Trying to add...");
				val = ((Component)this).gameObject.AddComponent<AudioSource>();
			}
			if ((Object)(object)val == (Object)null)
			{
				DeathHeadHopper.Logger.LogError((object)"Failed to add AudioSource.");
				return;
			}
			DeathHeadHopper.Logger.LogDebug((object)"Successfully got or added AudioSource.");
			Sound val2 = new Sound();
			val2.Source = val;
			val2.Sounds = ((Component)this).gameObject.GetComponent<NotValuableObject>().audioPreset.impactMedium.Sounds.Clone() as AudioClip[];
			val2.Volume = 0.12f;
			val2.VolumeRandom = 0f;
			val2.Pitch = 0.8f;
			val2.PitchRandom = 0f;
			jumpSound = val2;
			val2 = new Sound();
			val2.Source = val;
			val2.Sounds = controller.deathHead.playerAvatar.tumbleBreakFreeSound.Sounds.Clone() as AudioClip[];
			val2.Volume = 0.2f;
			val2.VolumeRandom = 0f;
			val2.Pitch = 1f;
			val2.PitchRandom = 0f;
			anchorBreakSound = val2;
			val2 = new Sound();
			val2.Source = val;
			val2.Sounds = controller.deathHead.eyeFlashNegativeSound.Sounds.Clone() as AudioClip[];
			val2.Volume = 0.2f;
			val2.VolumeRandom = 0f;
			val2.Pitch = 1f;
			val2.PitchRandom = 0f;
			anchorAttachSound = val2;
		}

		internal void PlayJumpSound()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Sound? obj = jumpSound;
			if (obj != null)
			{
				obj.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
		}

		internal void PlayAnchorBreakSound()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Sound? obj = anchorBreakSound;
			if (obj != null)
			{
				obj.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
		}

		internal void PlayAnchorAttachSound()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Sound? obj = anchorAttachSound;
			if (obj != null)
			{
				obj.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
		}
	}
	public class HeadCollisionHandler : MonoBehaviour
	{
		public LayerMask layerMask;

		public float collisionDelay = 0.15f;

		internal bool isColliding;

		private readonly List<Collision> activeCollisions = new List<Collision>();

		private float collisionTimer;

		private float collisionDelayTimer;

		internal bool collidingCartWasGrabbed;

		private float collidingCartTimer;

		private PhysGrabCart? collidingCart;

		internal bool IsCollidingCart => collidingCartTimer > 0f;

		protected void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			layerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[4] { "Default", "PhysGrabObject", "PhysGrabObjectHinge", "PhysGrabObjectCart" }));
		}

		protected void Update()
		{
			if (collisionTimer > 0f)
			{
				collisionTimer -= Time.deltaTime;
				if (collisionDelayTimer > 0f)
				{
					collisionDelayTimer -= Time.deltaTime;
				}
				else
				{
					isColliding = true;
				}
			}
			else
			{
				isColliding = false;
				collisionDelayTimer = collisionDelay;
			}
			if (collidingCart == null)
			{
				if (collidingCartTimer > 0f)
				{
					collidingCartTimer -= Time.deltaTime;
				}
				else
				{
					collidingCartWasGrabbed = false;
				}
				return;
			}
			collidingCartTimer = 1f;
			if (!collidingCartWasGrabbed && ((Component)collidingCart).gameObject.GetComponent<PhysGrabObject>().grabbed)
			{
				collidingCartWasGrabbed = true;
			}
		}

		protected void OnCollisionEnter(Collision collision)
		{
			activeCollisions.Add(collision);
			UpdateCollidingCart();
		}

		protected void OnCollisionExit(Collision collision)
		{
			activeCollisions.Remove(collision);
			UpdateCollidingCart();
		}

		private void UpdateCollidingCart()
		{
			collidingCart = activeCollisions.Select((Collision x) => ((Component)x.collider).GetComponentInParent<PhysGrabCart>()).FirstOrDefault((Func<PhysGrabCart, bool>)((PhysGrabCart cart) => cart != null));
		}

		protected void OnCollisionStay(Collision other)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			int num = 1 << other.gameObject.layer;
			if ((num & LayerMask.op_Implicit(layerMask)) > 0)
			{
				collisionTimer = 0.1f;
			}
		}

		internal Vector3? GetGroundPointDown()
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(((Component)this).transform.position, Vector3.down, ref val, 50f, LayerMask.GetMask(new string[1] { "Default" })))
			{
				return ((RaycastHit)(ref val)).point;
			}
			return null;
		}
	}
	public class HeadEyeHandler : MonoBehaviour
	{
		private DeathHeadController controller;

		private PlayerDeathHead deathHead;

		internal List<Func<bool>> eyeFlickerConditions = new List<Func<bool>>();

		internal List<Func<bool>> eyeNegativeConditions = new List<Func<bool>>();

		[Space]
		public Color eyeColor = new Color(1f, 0.9047236f, 0.5801887f);

		public Color eyeLightColor = new Color(1f, 0.6744879f, 0.3820755f);

		private float eyeWarningLerp;

		[Space]
		public float eyeFlashIntensity = 1.2f;

		public float eyeLightRange = 8f;

		private float eyeFlashLerp;

		[Space]
		public float eyeFlickerIntensity = 0.8f;

		[Range(0f, 1f)]
		public float eyeFlickerColorMultiplier = 1f;

		public float eyeFlickerSpeed = 8f;

		public float eyeFlickerMinDelay = 0.1f;

		public float eyeFlickerMaxDelay = 1f;

		private AnimationCurve eyeFlickerCurve;

		private float eyeFlickerLerp = 1f;

		private float nextFlickerTimer;

		protected void Awake()
		{
			//IL_004c: 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)
			controller = ((Component)this).GetComponent<DeathHeadController>();
			deathHead = controller.deathHead;
			eyeFlickerCurve = AssetManager.instance.animationCurveInOut;
			((Component)deathHead.eyeFlashLight).transform.localPosition = new Vector3(0f, 0.13f, 0.008f);
			deathHead.eyeFlashLight.type = (LightType)0;
			deathHead.eyeFlashLight.spotAngle = 120f;
			deathHead.eyeFlashLight.shadows = (LightShadows)1;
			deathHead.eyeFlashLight.range = eyeLightRange;
			deathHead.eyeFlashLight.color = eyeLightColor;
			deathHead.eyeFlashLight.intensity = 0f;
		}

		protected void LateUpdate()
		{
			if (deathHead.eyeFlash && deathHead.eyeFlashLerp < 1f)
			{
				eyeFlashLerp = 0f;
				return;
			}
			deathHead.eyeFlash = false;
			EyeColor();
			if (DeathHeadHopper.FlashlightFlicker.Value && eyeFlickerConditions.Any((Func<bool> x) => x()))
			{
				EyeFlicker();
			}
			else
			{
				EyeFlash();
			}
		}

		private void EyeColor()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (eyeNegativeConditions.Any((Func<bool> x) => x()))
			{
				eyeWarningLerp = Mathf.Min(eyeWarningLerp + 2f * Time.deltaTime, 1f);
			}
			else if (eyeWarningLerp > 0f)
			{
				eyeWarningLerp = Mathf.Max(eyeWarningLerp - 2f * Time.deltaTime, 0f);
			}
			Color val = Color.Lerp(eyeColor, deathHead.eyeFlashNegativeColor, eyeWarningLerp);
			Color color = Color.Lerp(eyeLightColor, deathHead.eyeFlashNegativeColor, eyeWarningLerp);
			deathHead.eyeMaterial.SetColor(deathHead.eyeMaterialColor, val);
			deathHead.eyeFlashLight.color = color;
		}

		private void EyeFlicker()
		{
			eyeFlashLerp = 0f;
			nextFlickerTimer -= Time.deltaTime;
			if (nextFlickerTimer <= 0f)
			{
				eyeFlickerLerp = 0f;
				nextFlickerTimer = Random.Range(eyeFlickerMinDelay, eyeFlickerMaxDelay);
			}
			if (eyeFlickerLerp < 1f)
			{
				eyeFlickerLerp = Mathf.Min(eyeFlickerLerp + eyeFlickerSpeed * Time.deltaTime, 1f);
				float num = ((eyeFlickerLerp <= 0.5f) ? eyeFlickerLerp : (1f - eyeFlickerLerp)) * 2f;
				deathHead.eyeMaterial.SetFloat(deathHead.eyeMaterialAmount, eyeFlickerCurve.Evaluate(num) * eyeFlickerColorMultiplier);
				deathHead.eyeFlashLight.intensity = eyeFlickerCurve.Evaluate(num) * eyeFlickerIntensity;
			}
		}

		private void EyeFlash()
		{
			nextFlickerTimer = 0f;
			eyeFlickerLerp = 0f;
			if (controller.spectated)
			{
				if (eyeFlashLerp == 1f)
				{
					eyeFlashLerp = 0f;
				}
				if (eyeFlashLerp > 0.1f)
				{
					eyeFlashLerp = Mathf.Max(eyeFlashLerp - 2f * Time.deltaTime, 0.1f);
				}
				else if (eyeFlashLerp < 0.1f)
				{
					eyeFlashLerp = Mathf.Min(eyeFlashLerp + 2f * Time.deltaTime, 0.1f);
				}
			}
			else if (eyeFlashLerp < 1f)
			{
				eyeFlashLerp = Mathf.Min(eyeFlashLerp + 2f * Time.deltaTime, 1f);
			}
			if (((Component)deathHead.eyeFlashLight).gameObject.activeSelf ^ (eyeFlashLerp < 1f))
			{
				((Component)deathHead.eyeFlashLight).gameObject.SetActive(eyeFlashLerp < 1f);
			}
			if (((Component)deathHead.eyeFlashLight).gameObject.activeSelf)
			{
				deathHead.eyeMaterial.SetFloat(deathHead.eyeMaterialAmount, deathHead.eyeFlashCurve.Evaluate(eyeFlashLerp));
				deathHead.eyeFlashLight.intensity = deathHead.eyeFlashCurve.Evaluate(eyeFlashLerp) * eyeFlashIntensity;
			}
		}
	}
	public class HeadHopHandler : MonoBehaviour
	{
		private DeathHeadController controller;

		private Rigidbody rb;

		public float hopJumpForce = 3f;

		public float hopRotationForce = 20f;

		public float hopDamping = 12f;

		public float hopAngleThreshold = 2f;

		public float hopVelocityThreshold = 0.03f;

		public float hopCooldown = 0.6f;

		private float hopCooldownTimer;

		private bool isHopping;

		private Quaternion hopTargetRotation;

		protected void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			controller = ((Component)this).GetComponent<DeathHeadController>();
			rb = ((Component)this).GetComponent<Rigidbody>();
			controller.m_HeadJumpEvent.AddListener(new UnityAction(OnHeadJump));
		}

		protected void Update()
		{
			if (hopCooldownTimer > 0f)
			{
				hopCooldownTimer -= Time.deltaTime;
			}
		}

		protected void FixedUpdate()
		{
			//IL_001c: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (isHopping && !rb.isKinematic)
			{
				Quaternion val = hopTargetRotation * Quaternion.Inverse(rb.rotation);
				float num = default(float);
				Vector3 val2 = default(Vector3);
				((Quaternion)(ref val)).ToAngleAxis(ref num, ref val2);
				if (num > 180f)
				{
					num -= 360f;
				}
				Vector3 val3 = ((Vector3)(ref val2)).normalized * num * (MathF.PI / 180f) * hopRotationForce;
				rb.angularVelocity = Vector3.Lerp(rb.angularVelocity, val3, Time.fixedDeltaTime * hopDamping);
				Vector3 angularVelocity = rb.angularVelocity;
				if (((Vector3)(ref angularVelocity)).magnitude < hopVelocityThreshold && Quaternion.Angle(rb.rotation, hopTargetRotation) < hopAngleThreshold)
				{
					isHopping = false;
				}
			}
		}

		private void OnHeadJump()
		{
			isHopping = false;
			hopCooldownTimer = hopCooldown / 2f;
		}

		[PunRPC]
		internal void HopRealign(Vector3 forwardVector)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!(hopCooldownTimer > 0f) && !rb.isKinematic)
			{
				controller.m_HeadHopEvent.Invoke();
				rb.AddForce(new Vector3(0f, hopJumpForce, 0f), (ForceMode)1);
				hopTargetRotation = Quaternion.LookRotation(forwardVector, Vector3.up);
				isHopping = true;
				hopCooldownTimer = hopCooldown;
			}
		}
	}
	public delegate void HeadJumpedEventHandler();
	public class HeadJumpHandler : MonoBehaviourPun
	{
		private DeathHeadController controller;

		private Rigidbody rb;

		public float jumpVertical = 1f;

		public float jumpForce = 2.8f;

		public float rotationForce = 0.05f;

		public float jumpCooldown = 1f;

		private float jumpCooldownTimer;

		private float jumpBufferTimer;

		private Vector3 jumpDirection;

		protected void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			controller = ((Component)this).GetComponent<DeathHeadController>();
			rb = ((Component)this).GetComponent<Rigidbody>();
			controller.m_HeadHopEvent.AddListener(new UnityAction(OnHeadHop));
		}

		protected void Update()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0087: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			if (jumpBufferTimer > 0f)
			{
				jumpBufferTimer -= Time.deltaTime;
				if (controller.collisionHandler.isColliding && jumpCooldownTimer <= 0f)
				{
					controller.m_HeadJumpEvent.Invoke();
					jumpDirection.y = jumpVertical;
					Vector3 val = jumpDirection * jumpForce;
					rb.AddForce(val, (ForceMode)1);
					Vector3 val2 = Vector3.Cross(Vector3.up, jumpDirection);
					rb.AddTorque(val2 * rotationForce, (ForceMode)1);
					jumpCooldownTimer = jumpCooldown;
					jumpBufferTimer = 0f;
					if (!SemiFunc.IsMultiplayer())
					{
						HeadJumped(jumpForce);
					}
					else
					{
						((MonoBehaviourPun)this).photonView.RPC("HeadJumped", (RpcTarget)0, new object[1] { jumpForce });
					}
				}
			}
			if (jumpCooldownTimer > 0f)
			{
				jumpCooldownTimer -= Time.deltaTime;
			}
		}

		private void OnHeadHop()
		{
			jumpCooldownTimer = jumpCooldown / 2f;
		}

		[PunRPC]
		internal void JumpHead(Vector3 forwardVector)
		{
			//IL_000c: 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)
			jumpBufferTimer = 0.25f;
			jumpDirection = forwardVector;
		}

		[PunRPC]
		internal void HeadJumped(float jumpMultiplier)
		{
			controller.audioHandler.PlayJumpSound();
		}
	}
	internal class HeadReboundHandler : MonoBehaviour
	{
		internal class Rebound
		{
			public Func<Vector3> direction;

			public Func<bool> shouldApply;

			public Func<float>? force;

			public bool shouldNegateProductVelocity;

			public Rebound(Func<Vector3> direction, Func<bool> shouldApply, Func<float>? force = null, bool shouldNegateProductVelocity = true)
			{
				Func<Vector3> direction2 = direction;
				base..ctor();
				this.direction = 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_000e: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val = direction2();
					return ((Vector3)(ref val)).normalized;
				};
				this.shouldApply = shouldApply;
				this.force = force;
				this.shouldNegateProductVelocity = shouldNegateProductVelocity;
			}
		}

		private DeathHeadController controller;

		private Rigidbody rb;

		public float reboundDuration = 3f;

		public float defaultReboundForce = 0.1f;

		public float volicityProductMultiplier = 0.05f;

		public float reboundYVelocity = 0.08f;

		public float maxTotalReboundForce = 7f;

		private readonly List<Rebound> reboundEffects = new List<Rebound>();

		protected void Awake()
		{
			controller = ((Component)this).GetComponent<DeathHeadController>();
			rb = ((Component)this).GetComponent<Rigidbody>();
		}

		internal void FixedUpdate()
		{
			//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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00f0: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || controller.impactDetector.physGrabObject.grabbed)
			{
				return;
			}
			foreach (Rebound reboundEffect in reboundEffects)
			{
				if (reboundEffect.shouldApply())
				{
					float num = ((reboundEffect.force != null) ? reboundEffect.force() : defaultReboundForce);
					Vector3 val = -reboundEffect.direction();
					Vector3 velocity = rb.velocity;
					float num2 = Vector3.Dot(val, ((Vector3)(ref velocity)).normalized);
					velocity = rb.velocity;
					float num3 = num2 * ((Vector3)(ref velocity)).magnitude;
					if (reboundEffect.shouldNegateProductVelocity)
					{
						num += volicityProductMultiplier * Mathf.Max(0f, num3);
					}
					if (num3 < 0f)
					{
						num = Mathf.Min(num, maxTotalReboundForce + num3);
					}
					Rigidbody obj = rb;
					obj.velocity += reboundEffect.direction() * num + new Vector3(0f, reboundYVelocity, 0f);
				}
			}
		}

		public void AddReboundForce(Rebound rebound)
		{
			reboundEffects.Add(rebound);
		}
	}
	public class Tether : MonoBehaviour
	{
		public Vector3 origin;

		public Vector3 point;

		public Color tetherStartColor;

		public Color tetherEndColor;

		public float curveSpeed;

		public int curveResolution;

		public float colorInterpolation;

		public bool curveEnabled;

		[Header("Texture Scrolling")]
		public Vector2 scrollSpeed;

		private Vector3 curvePointSmooth;

		private LineRenderer lineRenderer;

		[HideInInspector]
		public Material lineMaterial;

		protected 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_005f: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			lineRenderer = ((Component)this).gameObject.AddComponent<LineRenderer>();
			LineRenderer component = ((Component)PlayerAvatar.instance).GetComponent<PhysGrabber>().physGrabBeam.gameObject.GetComponent<LineRenderer>();
			((Renderer)lineRenderer).material = ((Renderer)component).material;
			lineRenderer.textureMode = component.textureMode;
			((Renderer)lineRenderer).shadowCastingMode = (ShadowCastingMode)0;
			AnimationCurve val = new AnimationCurve();
			val.AddKey(0f, 0f);
			val.AddKey(new Keyframe(0.1f, 0.11f, 0f, 0f));
			val.AddKey(new Keyframe(0.9f, 0.07f, 0f, 0f));
			val.AddKey(1f, 0.05f);
			lineRenderer.widthCurve = val;
			lineMaterial = ((Renderer)lineRenderer).material;
		}

		protected void LateUpdate()
		{
			DrawLine();
			ScrollTexture();
		}

		internal void ResetCurvePointSmooth()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			curvePointSmooth = (origin + point) / 2f;
		}

		private void DrawLine()
		{
			//IL_0016: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			float num = curveSpeed;
			if (!curveEnabled)
			{
				num = 20f;
			}
			Vector3 val = (origin + point) / 2f;
			Vector3[] array = (Vector3[])(object)new Vector3[curveResolution];
			curvePointSmooth = Vector3.Lerp(curvePointSmooth, val, Time.deltaTime * num);
			for (int i = 0; i < curveResolution; i++)
			{
				float t = (float)i / ((float)curveResolution - 1f);
				array[i] = CalculateBezierPoint(t, origin, curvePointSmooth, point);
			}
			lineRenderer.positionCount = curveResolution;
			lineRenderer.SetPositions(array);
		}

		private Vector3 CalculateBezierPoint(float t, Vector3 p0, Vector3 p1, Vector3 p2)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Pow(1f - t, 2f) * p0 + 2f * (1f - t) * t * p1 + Mathf.Pow(t, 2f) * p2;
		}

		private void ScrollTexture()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)lineMaterial))
			{
				lineMaterial.mainTextureScale = new Vector2(1f, 1f);
				Vector2 mainTextureOffset = Time.time * scrollSpeed;
				lineMaterial.mainTextureOffset = mainTextureOffset;
				lineMaterial.color = Color.Lerp(tetherStartColor, tetherEndColor, colorInterpolation);
				lineMaterial.EnableKeyword("_EMISSION");
				lineMaterial.SetColor("_EmissionColor", lineMaterial.color);
			}
		}

		public Tether()
		{
			//IL_0016: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			Color val = default(Color);
			tetherStartColor = (Color)(ColorUtility.TryParseHtmlString("#00C4FD", ref val) ? new Color(val.r, val.g, val.b, 0.1f) : Color.red);
			Color val2 = default(Color);
			tetherEndColor = (Color)(ColorUtility.TryParseHtmlString("#E70A17", ref val2) ? new Color(val2.r, val2.g, val2.b, 0.4f) : Color.red);
			curveSpeed = 2f;
			curveResolution = 20;
			curveEnabled = true;
			scrollSpeed = new Vector2(4f, 0f);
			((MonoBehaviour)this)..ctor();
		}
	}
}
namespace DeathHeadHopper.Patches
{
	[HarmonyPatch(typeof(GameDirector))]
	public static class GameDirectorPatch
	{
		[HarmonyPatch("gameStateStart")]
		[HarmonyPostfix]
		public static void GameStateStart_Postfix()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			if ((int)GameDirector.instance.currentState != 2 || (!SemiFunc.RunIsLevel() && !SemiFunc.RunIsShop()))
			{
				return;
			}
			string name = ((Object)((Component)PlayerAvatar.instance.spectatePoint).gameObject).name;
			GameObject? deathHeadHopperPrefab = DeathHeadHopper.DeathHeadHopperPrefab;
			if (name == ((deathHeadHopperPrefab != null) ? ((Object)deathHeadHopperPrefab).name : null))
			{
				DeathHeadHopper.Logger.LogDebug((object)"Player already has DeathHeadHopper enabled");
				return;
			}
			DeathHeadHopper.Logger.LogDebug((object)"Creating DeathHeadHopper object instance...");
			DHHFunc.DeathHeadHopperObj = new GameObject("DeathHeadHopper");
			if (DHHFunc.DeathHeadHopperObj == null)
			{
				DeathHeadHopper.Logger.LogError((object)"Failed to create DeathHeadHopper object instance :(");
				return;
			}
			DHHFunc.DeathHeadHopperObj.SetActive(false);
			DHHFunc.DeathHeadHopperObj.AddComponent<DeathHeadHopperController>();
			DHHFunc.DeathHeadHopperObj.transform.SetParent(((Component)PlayerAvatar.instance).transform.parent, false);
			DeathHeadHopper.Logger.LogDebug((object)"DeathHeadHopper object instance created!");
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				ComponentHolderProtocol.AddComponent<DeathHeadController>((Object)(object)player.playerDeathHead);
			}
			DeathHeadHopper.Logger.LogDebug((object)"Added DeathHeadController to player heads!");
		}

		[HarmonyPatch("Revive")]
		[HarmonyPrefix]
		private static void Revive_Prefix()
		{
			if (DHHFunc.DeathHeadHopperObj != null && DHHFunc.DeathHeadHopperObj.activeSelf)
			{
				DeathHeadHopper.Logger.LogInfo((object)"You are revived! Disabling DeathHeadHopper");
				DHHFunc.DeathHeadHopperObj.SetActive(false);
			}
		}
	}
	[HarmonyPatch(typeof(SpectateCamera))]
	internal static class SpectateCameraPatch
	{
		private static readonly FieldInfo f_isDisabled = AccessTools.Field(typeof(PlayerAvatar), "isDisabled");

		private static readonly MethodInfo m_inputDown = AccessTools.Method(typeof(SemiFunc), "InputDown", (Type[])null, (Type[])null);

		private static readonly MethodInfo m_playerSwitch = AccessTools.Method(typeof(SpectateCamera), "PlayerSwitch", (Type[])null, (Type[])null);

		[HarmonyPatch("StateNormal")]
		[HarmonyPrefix]
		private static void StateNormal_Prefix()
		{
			if ((SemiFunc.RunIsLevel() || SemiFunc.RunIsShop()) && Object.op_Implicit((Object)(object)DHHFunc.DeathHeadHopperObj) && DHHFunc.DeathHeadHopperObj != null && !DHHFunc.DeathHeadHopperObj.activeSelf)
			{
				DeathHeadHopper.Logger.LogInfo((object)"You died! Enabling DeathHeadHopper");
				DHHFunc.DeathHeadHopperObj.SetActive(true);
			}
		}

		[HarmonyPatch("PlayerSwitch")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PlayerSwitch_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			int num = list.FindIndex((CodeInstruction ci) => CodeInstructionExtensions.LoadsField(ci, f_isDisabled, false));
			if (num <= 0 || !(list[num + 1].operand is Label item))
			{
				return instructions;
			}
			DeathHeadHopper.Logger.LogDebug((object)string.Format("{0} index: {1}", "PlayerSwitch_Transpiler", num));
			int num2 = list.FindIndex(num, (CodeInstruction ci) => ci.opcode == OpCodes.Ret);
			if (num2 <= 0)
			{
				return instructions;
			}
			DeathHeadHopper.Logger.LogDebug((object)string.Format("{0} returnIndex: {1}", "PlayerSwitch_Transpiler", num2));
			DeathHeadHopper.Logger.LogDebug((object)"Found playerAvatar.isDisabled check in PlayerSwitch, replacing code instructions");
			Label label = generator.DefineLabel();
			list[num2 + 1].labels.Add(label);
			list[num2 + 1].labels.Remove(item);
			list[num + 1].opcode = OpCodes.Brfalse_S;
			list[num + 2].labels.Add(item);
			list.InsertRange(num + 2, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldloc_3, (object)null),
				CodeInstruction.Call(typeof(DHHFunc), "IsDeathHeadSpectatable", new Type[1] { typeof(PlayerAvatar) }, (Type[])null),
				new CodeInstruction(OpCodes.Brfalse, (object)label)
			});
			return list.AsEnumerable();
		}

		[HarmonyPatch("StateNormal")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> StateNormal_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = instructions.ToList();
			int num = list.FindIndex((CodeInstruction ci) => CodeInstructionExtensions.Calls(ci, m_inputDown)) - 1;
			if (num <= 0 || list[num].opcode != OpCodes.Ldc_I4_1)
			{
				return instructions;
			}
			DeathHeadHopper.Logger.LogDebug((object)string.Format("{0} start: {1}", "StateNormal_Transpiler", num));
			int num2 = list.FindIndex(num, (CodeInstruction ci) => CodeInstructionExtensions.Calls(ci, m_playerSwitch));
			if (num2 == -1)
			{
				return instructions;
			}
			DeathHeadHopper.Logger.LogDebug((object)string.Format("{0} end: {1}", "StateNormal_Transpiler", num2));
			DeathHeadHopper.Logger.LogDebug((object)"Found jump check in StateNormal, removing code instructions");
			list[num].opcode = OpCodes.Nop;
			list.RemoveRange(num + 1, num2 - num);
			return list.AsEnumerable();
		}
	}
}

BeepInEx/plugins/Cuajitox-SharedHealthPacks/SharedHealthPacks.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using SharedHealthPacks.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SharedHealthPacks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SharedHealthPacks")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c54820f5-3229-4f30-a372-56712566cbcb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SharedHealthPacks
{
	[BepInPlugin("Cuajitox.REPO.SharedHealthPacks", "R.E.P.O SharedHealthPacks", "1.0.0")]
	public class TeamBoostersBase : BaseUnityPlugin
	{
		private const string mod_guid = "Cuajitox.REPO.SharedHealthPacks";

		private const string mod_name = "R.E.P.O SharedHealthPacks";

		private const string mod_version = "1.0.0";

		private readonly Harmony harmony = new Harmony("Cuajitox.REPO.SharedHealthPacks");

		private static TeamBoostersBase instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("Cuajitox.REPO.SharedHealthPacks");
			mls.LogInfo((object)"SharedHealthPacks mod has been activated");
			harmony.PatchAll(typeof(TeamBoostersBase));
			harmony.PatchAll(typeof(ItemHealthPackUpdatePatch));
		}
	}
}
namespace SharedHealthPacks.Patches
{
	[HarmonyPatch(typeof(ItemHealthPack), "OnDestroy")]
	public static class ItemHealthPackUpdatePatch
	{
		[HarmonyPostfix]
		public static void Postfix(ItemHealthPack __instance)
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				item.playerHealth.HealOther(__instance.healAmount, true);
			}
		}
	}
}

BeepInEx/plugins/diowo1-MoreCosmetics/rawr cosmetics/MoreHead.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using Microsoft.CodeAnalysis;
using MoreHead;
using Photon.Pun;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MoreHead")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreHead")]
[assembly: AssemblyTitle("MoreHead")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
[BepInPlugin("Mhz.REPOMoreHead", "MoreHead", "1.0.0")]
public class Morehead : BaseUnityPlugin
{
	public static ManualLogSource? Logger;

	public static Morehead? Instance { get; private set; }

	private void Awake()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		Instance = this;
		Logger = ((BaseUnityPlugin)this).Logger;
		try
		{
			Harmony val = new Harmony("Mhz.REPOMoreHead");
			val.PatchAll(typeof(PlayerAvatarVisualsPatch));
			val.PatchAll(typeof(PlayerUpdatePatch));
			val.PatchAll(typeof(PlayerAvatarAwakePatch));
			val.PatchAll(typeof(MenuPlayerVisualsPatch));
			val.PatchAll(typeof(GameDirectorUpdatePatch));
			val.PatchAll(typeof(PlayerRevivePatch));
			Logger.LogInfo((object)"MoreHead 已加载");
			HeadDecorationManager.Initialize();
			ConfigManager.Initialize();
			MoreHeadUI.Initialize();
		}
		catch (Exception ex)
		{
			Logger.LogError((object)("Harmony补丁应用失败: " + ex.Message));
		}
	}

	private void OnApplicationQuit()
	{
		ConfigManager.SaveConfig();
	}

	public static bool GetDecorationState(string? name)
	{
		return HeadDecorationManager.GetDecorationState(name);
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("Update")]
internal class PlayerUpdatePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		if (__instance.photonView.IsMine && GameManager.Multiplayer() && PhotonNetwork.LocalPlayer != null)
		{
		}
	}

	public static void UpdatePlayerDecorations(PlayerAvatar playerAvatar)
	{
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: 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_0162: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)playerAvatar?.playerAvatarVisuals == (Object)null)
			{
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = ((Component)playerAvatar.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = ((Component)playerAvatar.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = ((Component)playerAvatar.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			if (dictionary.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何装饰物父级节点");
				}
				return;
			}
			foreach (KeyValuePair<string, Transform> item in dictionary)
			{
				string key = item.Key;
				Transform value = item.Value;
				Transform val4 = value.Find("HeadDecorations");
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = new GameObject("HeadDecorations").transform;
					val4.SetParent(value, false);
					val4.localPosition = Vector3.zero;
					val4.localRotation = Quaternion.identity;
					val4.localScale = Vector3.one;
				}
			}
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (dictionary.TryGetValue(decoration.ParentTag, out var value2))
				{
					Transform val5 = value2.Find("HeadDecorations");
					if ((Object)(object)val5 != (Object)null)
					{
						UpdateDecoration(val5, decoration.Name, decoration.IsVisible);
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("找不到装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("更新装饰物状态失败: " + ex.Message));
			}
		}
	}

	private static void UpdateDecoration(Transform parent, string? decorationName, bool showDecoration)
	{
		Transform val = parent.Find(decorationName);
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(showDecoration);
		}
	}

	public static void UpdateMenuPlayerDecorations()
	{
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			PlayerAvatarVisuals val = FindMenuPlayerVisuals();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val2 = ((Component)val).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["head"] = val2;
			}
			Transform val3 = ((Component)val).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["neck"] = val3;
			}
			Transform val4 = ((Component)val).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val4 != (Object)null)
			{
				dictionary["body"] = val4;
			}
			if (dictionary.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何菜单角色装饰物父级节点");
				}
				return;
			}
			foreach (KeyValuePair<string, Transform> item in dictionary)
			{
				string key = item.Key;
				Transform value = item.Value;
				Transform val5 = value.Find("HeadDecorations");
				if ((Object)(object)val5 == (Object)null)
				{
					val5 = new GameObject("HeadDecorations").transform;
					val5.SetParent(value, false);
					val5.localPosition = Vector3.zero;
					val5.localRotation = Quaternion.identity;
					val5.localScale = Vector3.one;
				}
			}
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (dictionary.TryGetValue(decoration.ParentTag, out var value2))
				{
					Transform val6 = value2.Find("HeadDecorations");
					if ((Object)(object)val6 != (Object)null)
					{
						Transform val7 = val6.Find(decoration.Name);
						if ((Object)(object)val7 == (Object)null)
						{
							AddMenuDecoration(val6, decoration.Name);
						}
						else
						{
							((Component)val7).gameObject.SetActive(decoration.IsVisible);
						}
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("找不到菜单角色装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("更新菜单角色装饰物状态失败: " + ex.Message));
			}
		}
	}

	private static PlayerAvatarVisuals? FindMenuPlayerVisuals()
	{
		GameObject val = GameObject.Find("PlayerAvatarMenu");
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		return val.GetComponentInChildren<PlayerAvatarVisuals>();
	}

	public static void AddMenuDecoration(Transform parent, string? decorationName)
	{
		string decorationName2 = decorationName;
		try
		{
			Transform val = parent.Find(decorationName2);
			if ((Object)(object)val != (Object)null)
			{
				bool decorationState = Morehead.GetDecorationState(decorationName2);
				((Component)val).gameObject.SetActive(decorationState);
				return;
			}
			DecorationInfo decorationInfo = HeadDecorationManager.Decorations.Find((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null && (Object)(object)decorationInfo.Prefab != (Object)null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(decorationInfo.Prefab, parent);
				((Object)val2).name = decorationName2;
				val2.SetActive(decorationInfo.IsVisible);
				return;
			}
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogWarning((object)("AddMenuDecoration: 找不到装饰物 " + decorationName2 + " 或其预制体为空"));
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("为菜单角色添加装饰物时出错: " + ex.Message));
			}
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("Awake")]
internal class PlayerAvatarAwakePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		((Component)__instance).gameObject.AddComponent<HeadDecorationSync>();
	}
}
public class HeadDecorationSync : MonoBehaviourPun
{
	public void SyncAllDecorations()
	{
		try
		{
			string[] array = new string[HeadDecorationManager.Decorations.Count];
			bool[] array2 = new bool[HeadDecorationManager.Decorations.Count];
			string[] array3 = new string[HeadDecorationManager.Decorations.Count];
			for (int i = 0; i < HeadDecorationManager.Decorations.Count; i++)
			{
				DecorationInfo decorationInfo = HeadDecorationManager.Decorations[i];
				array[i] = decorationInfo.Name;
				array2[i] = decorationInfo.IsVisible;
				array3[i] = decorationInfo.ParentTag;
			}
			((MonoBehaviourPun)this).photonView.RPC("UpdateAllDecorations", (RpcTarget)1, new object[3] { array, array2, array3 });
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("同步所有装饰物状态失败: " + ex.Message));
			}
		}
	}

	[PunRPC]
	private void UpdateAllDecorations(string[] names, bool[] states, string[] parentTags)
	{
		try
		{
			PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.playerAvatarVisuals == (Object)null)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到PlayerAvatar或PlayerAvatarVisuals组件");
				}
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = ((Component)component.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = ((Component)component.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = ((Component)component.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			for (int i = 0; i < names.Length; i++)
			{
				string decorationName = names[i];
				bool showDecoration = states[i];
				string key = parentTags[i];
				if (dictionary.TryGetValue(key, out var value))
				{
					Transform val4 = value.Find("HeadDecorations");
					if ((Object)(object)val4 != (Object)null)
					{
						UpdateDecoration(val4, decorationName, showDecoration);
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("RPC更新所有装饰物状态失败: " + ex.Message));
			}
		}
	}

	private void UpdateDecoration(Transform parent, string decorationName, bool showDecoration)
	{
		Transform val = parent.Find(decorationName);
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(showDecoration);
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals))]
[HarmonyPatch("Start")]
internal class PlayerAvatarVisualsPatch
{
	private static void Postfix(PlayerAvatarVisuals __instance)
	{
		//IL_0103: 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_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			if (dictionary.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogError((object)"找不到任何装饰物父级节点");
				}
				return;
			}
			foreach (KeyValuePair<string, Transform> item in dictionary)
			{
				string key = item.Key;
				Transform value = item.Value;
				Transform val4 = value.Find("HeadDecorations");
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = new GameObject("HeadDecorations").transform;
					val4.SetParent(value, false);
					val4.localPosition = Vector3.zero;
					val4.localRotation = Quaternion.identity;
					val4.localScale = Vector3.one;
				}
			}
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (dictionary.TryGetValue(decoration.ParentTag, out var value2))
				{
					Transform val5 = value2.Find("HeadDecorations");
					if ((Object)(object)val5 != (Object)null)
					{
						AddNewDecoration(val5, decoration, __instance);
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("初始化时找不到装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
			if (!GameManager.Multiplayer() || !((Object)(object)__instance.playerAvatar != (Object)null) || !((Object)(object)__instance.playerAvatar.photonView != (Object)null) || !__instance.playerAvatar.photonView.IsMine)
			{
				return;
			}
			try
			{
				HeadDecorationSync component = ((Component)__instance.playerAvatar).GetComponent<HeadDecorationSync>();
				if ((Object)(object)component != (Object)null)
				{
					component.SyncAllDecorations();
					return;
				}
				ManualLogSource? logger3 = Morehead.Logger;
				if (logger3 != null)
				{
					logger3.LogWarning((object)"找不到HeadDecorationSync组件,无法同步初始状态");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger4 = Morehead.Logger;
				if (logger4 != null)
				{
					logger4.LogError((object)("同步初始装饰物状态失败: " + ex.Message));
				}
			}
		}
		catch (Exception ex2)
		{
			ManualLogSource? logger5 = Morehead.Logger;
			if (logger5 != null)
			{
				logger5.LogError((object)("添加装饰物失败: " + ex2.Message));
			}
		}
	}

	private static void AddNewDecoration(Transform parent, DecorationInfo decoration, PlayerAvatarVisuals __instance)
	{
		Transform val = parent.Find(decoration.Name);
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(decoration.IsVisible);
			return;
		}
		if ((Object)(object)decoration.Prefab != (Object)null)
		{
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(decoration.Prefab, parent);
				((Object)val2).name = decoration.Name;
				val2.SetActive(decoration.IsVisible);
				return;
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogError((object)("实例化预制体时出错: " + ex.Message));
				}
				return;
			}
		}
		ManualLogSource? logger2 = Morehead.Logger;
		if (logger2 != null)
		{
			logger2.LogWarning((object)("AddNewDecoration: 装饰物 " + decoration.DisplayName + " 的预制体为空"));
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals))]
[HarmonyPatch("Start")]
internal class MenuPlayerVisualsPatch
{
	private static void Postfix(PlayerAvatarVisuals __instance)
	{
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!__instance.isMenuAvatar)
			{
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			if (dictionary.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何菜单角色装饰物父级节点");
				}
				return;
			}
			foreach (KeyValuePair<string, Transform> item in dictionary)
			{
				string key = item.Key;
				Transform value = item.Value;
				Transform val4 = value.Find("HeadDecorations");
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = new GameObject("HeadDecorations").transform;
					val4.SetParent(value, false);
					val4.localPosition = Vector3.zero;
					val4.localRotation = Quaternion.identity;
					val4.localScale = Vector3.one;
				}
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					if (decoration.ParentTag == key)
					{
						PlayerUpdatePatch.AddMenuDecoration(val4, decoration.Name);
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("初始化菜单角色装饰物失败: " + ex.Message));
			}
		}
	}
}
[HarmonyPatch(typeof(GameDirector))]
[HarmonyPatch("Update")]
internal class GameDirectorUpdatePatch
{
	private static gameState previousState;

	private static void Postfix(GameDirector __instance)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Invalid comparison between Unknown and I4
		//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)
		try
		{
			if ((int)previousState != 2 && (int)__instance.currentState == 2)
			{
				SyncAllPlayersDecorations();
			}
			previousState = __instance.currentState;
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("监听游戏状态变化时出错: " + ex.Message));
			}
		}
	}

	private static void SyncAllPlayersDecorations()
	{
		try
		{
			PlayerAvatar val = FindLocalPlayer();
			if ((Object)(object)val != (Object)null)
			{
				PlayerUpdatePatch.UpdatePlayerDecorations(val);
				HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>();
				if ((Object)(object)component != (Object)null)
				{
					component.SyncAllDecorations();
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("同步所有玩家装饰物状态时出错: " + ex.Message));
			}
		}
	}

	private static PlayerAvatar? FindLocalPlayer()
	{
		try
		{
			PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
			PlayerAvatar[] array2 = array;
			foreach (PlayerAvatar val in array2)
			{
				if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine)
				{
					return val;
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("查找本地玩家时出错: " + ex.Message));
			}
		}
		return null;
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("ReviveRPC")]
internal class PlayerRevivePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		try
		{
			if (__instance.photonView.IsMine)
			{
				((MonoBehaviour)__instance).StartCoroutine(DelayedSync(__instance));
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("玩家复活时同步装饰物状态失败: " + ex.Message));
			}
		}
	}

	private static IEnumerator DelayedSync(PlayerAvatar playerAvatar)
	{
		yield return null;
		yield return (object)new WaitForSeconds(0.2f);
		try
		{
			PlayerUpdatePatch.UpdatePlayerDecorations(playerAvatar);
		}
		catch (Exception e2)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("更新玩家装饰物状态失败: " + e2.Message));
			}
		}
		yield return (object)new WaitForSeconds(0.1f);
		try
		{
			HeadDecorationSync syncComponent = ((Component)playerAvatar).GetComponent<HeadDecorationSync>();
			if ((Object)(object)syncComponent != (Object)null)
			{
				syncComponent.SyncAllDecorations();
				yield break;
			}
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogWarning((object)"玩家复活后找不到HeadDecorationSync组件");
			}
		}
		catch (Exception e)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("同步装饰物状态失败: " + e.Message));
			}
		}
	}
}
namespace MoreHead
{
	public static class ConfigManager
	{
		private static Dictionary<string?, bool> _decorationStates = new Dictionary<string, bool>();

		private static ManualLogSource? Logger => Morehead.Logger;

		private static string ConfigFilePath
		{
			get
			{
				Morehead? instance = Morehead.Instance;
				return Path.Combine(Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null) ?? string.Empty, "MoreHeadConfig.txt");
			}
		}

		public static void Initialize()
		{
			try
			{
				LoadConfig();
				ApplySavedStates();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("初始化配置管理器时出错: " + ex.Message));
				}
			}
		}

		private static void LoadConfig()
		{
			try
			{
				_decorationStates.Clear();
				if (!File.Exists(ConfigFilePath))
				{
					return;
				}
				string[] array = File.ReadAllLines(ConfigFilePath);
				string[] array2 = array;
				foreach (string text in array2)
				{
					if (!string.IsNullOrWhiteSpace(text))
					{
						string[] array3 = text.Split('=');
						if (array3.Length == 2)
						{
							string key = array3[0].Trim();
							bool value = array3[1].Trim().Equals("1", StringComparison.OrdinalIgnoreCase);
							_decorationStates[key] = value;
						}
					}
				}
				if (_decorationStates.Count > 0)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)$"已加载配置,包含 {_decorationStates.Count} 个装饰物状态");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("加载配置时出错: " + ex.Message));
				}
				_decorationStates.Clear();
			}
		}

		public static void SaveConfig()
		{
			try
			{
				UpdateConfigData();
				List<string> list = new List<string>();
				foreach (KeyValuePair<string, bool> decorationState in _decorationStates)
				{
					list.Add(decorationState.Key + "=" + (decorationState.Value ? "1" : "0"));
				}
				File.WriteAllLines(ConfigFilePath, list);
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("保存配置时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateConfigData()
		{
			_decorationStates.Clear();
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				_decorationStates[decoration.Name] = decoration.IsVisible;
			}
		}

		private static void ApplySavedStates()
		{
			try
			{
				int num = 0;
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					if (_decorationStates.TryGetValue(decoration.Name, out var value))
					{
						decoration.IsVisible = value;
						num++;
					}
				}
				if (num > 0)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)$"已应用 {num} 个已保存的装饰物状态");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("应用已保存的装饰物状态时出错: " + ex.Message));
				}
			}
		}
	}
	public class DecorationInfo
	{
		public string? Name { get; set; }

		public string? DisplayName { get; set; }

		public bool IsVisible { get; set; }

		public GameObject? Prefab { get; set; }

		public string? ParentTag { get; set; }

		public string? BundlePath { get; set; }
	}
	public static class HeadDecorationManager
	{
		private static Dictionary<string?, string> parentPathMap = new Dictionary<string, string>
		{
			{ "head", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top" },
			{ "neck", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side" },
			{ "body", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side" }
		};

		private static ManualLogSource? Logger => Morehead.Logger;

		public static List<DecorationInfo> Decorations { get; private set; } = new List<DecorationInfo>();


		public static void Initialize()
		{
			try
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"正在初始化装饰物管理器...");
				}
				Decorations.Clear();
				LoadAllDecorations();
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)$"装饰物管理器初始化完成,共加载了 {Decorations.Count} 个装饰物");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("初始化装饰物管理器时出错: " + ex.Message));
				}
			}
		}

		private static void LoadAllDecorations()
		{
			try
			{
				Morehead? instance = Morehead.Instance;
				string directoryName = Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null);
				if (string.IsNullOrEmpty(directoryName))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogError((object)"无法获取MOD所在目录");
					}
					return;
				}
				string text = Path.Combine(directoryName, "Decorations");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogInfo((object)("已创建装饰物目录: " + text));
					}
				}
				List<string> list = new List<string>();
				string[] files = Directory.GetFiles(text, "*.hhh");
				list.AddRange(files);
				try
				{
					string text2 = FindPluginsDirectory(directoryName);
					if (!string.IsNullOrEmpty(text2) && Directory.Exists(text2))
					{
						ManualLogSource? logger3 = Logger;
						if (logger3 != null)
						{
							logger3.LogInfo((object)("找到BepInEx/plugins目录: " + text2));
						}
						string[] files2 = Directory.GetFiles(text2, "*.hhh", SearchOption.AllDirectories);
						list.AddRange(files2);
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogInfo((object)$"在plugins目录中找到 {files2.Length} 个.hhh文件");
						}
					}
					else
					{
						ManualLogSource? logger5 = Logger;
						if (logger5 != null)
						{
							logger5.LogWarning((object)"无法找到BepInEx/plugins目录,将只加载本地装饰物");
						}
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger6 = Logger;
					if (logger6 != null)
					{
						logger6.LogError((object)("搜索plugins目录时出错: " + ex.Message));
					}
				}
				list = list.Distinct().ToList();
				if (list.Count == 0)
				{
					ManualLogSource? logger7 = Logger;
					if (logger7 != null)
					{
						logger7.LogWarning((object)"未找到任何装饰物包文件,请确保.hhh文件已放置");
					}
				}
				else
				{
					ManualLogSource? logger8 = Logger;
					if (logger8 != null)
					{
						logger8.LogInfo((object)$"找到 {list.Count} 个装饰物包文件");
					}
					if (files.Length != 0)
					{
						ManualLogSource? logger9 = Logger;
						if (logger9 != null)
						{
							logger9.LogInfo((object)$"- Decorations目录: {files.Length} 个文件");
						}
					}
				}
				foreach (string item in list)
				{
					LoadDecorationBundle(item);
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource? logger10 = Logger;
				if (logger10 != null)
				{
					logger10.LogError((object)("加载装饰物时出错: " + ex2.Message));
				}
			}
		}

		private static void LoadDecorationBundle(string bundlePath)
		{
			AssetBundle val = null;
			try
			{
				if (!File.Exists(bundlePath))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("文件不存在: " + bundlePath));
					}
					return;
				}
				FileInfo fileInfo = new FileInfo(bundlePath);
				if (fileInfo.Length < 1024)
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)$"文件过小,可能不是有效的AssetBundle: {bundlePath}, 大小: {fileInfo.Length} 字节");
					}
					return;
				}
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(bundlePath);
				string parentTag = "head";
				string text = fileNameWithoutExtension;
				if (fileNameWithoutExtension.Contains("_"))
				{
					string[] array = fileNameWithoutExtension.Split('_');
					if (array.Length >= 2)
					{
						string text2 = array[^1].ToLower();
						if (parentPathMap.ContainsKey(text2))
						{
							parentTag = text2;
							text = string.Join("_", array, 0, array.Length - 1);
						}
					}
				}
				string text3 = EnsureUniqueName(text);
				if (text3 != text)
				{
					ManualLogSource? logger3 = Logger;
					if (logger3 != null)
					{
						logger3.LogWarning((object)("检测到重名,将基础名称从 " + text + " 修改为 " + text3));
					}
					text = text3;
				}
				try
				{
					val = AssetBundle.LoadFromFile(bundlePath);
					if ((Object)(object)val == (Object)null)
					{
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogError((object)("无法加载AssetBundle,文件可能已损坏或不是有效的AssetBundle: " + bundlePath));
						}
						return;
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger5 = Logger;
					if (logger5 != null)
					{
						logger5.LogError((object)("加载AssetBundle时出错,文件可能不是有效的AssetBundle: " + bundlePath + ", 错误: " + ex.Message));
					}
					return;
				}
				try
				{
					string[] allAssetNames;
					try
					{
						allAssetNames = val.GetAllAssetNames();
					}
					catch (Exception ex2)
					{
						ManualLogSource? logger6 = Logger;
						if (logger6 != null)
						{
							logger6.LogError((object)("获取AssetBundle资源名称时出错: " + bundlePath + ", 错误: " + ex2.Message));
						}
						val.Unload(true);
						return;
					}
					if (allAssetNames.Length == 0)
					{
						ManualLogSource? logger7 = Logger;
						if (logger7 != null)
						{
							logger7.LogWarning((object)("AssetBundle不包含任何资源: " + bundlePath));
						}
						val.Unload(true);
						return;
					}
					bool flag = false;
					GameObject val2 = null;
					string[] array2 = allAssetNames;
					foreach (string text4 in array2)
					{
						try
						{
							val2 = val.LoadAsset<GameObject>(text4);
							if ((Object)(object)val2 != (Object)null)
							{
								flag = true;
								break;
							}
						}
						catch (Exception ex3)
						{
							ManualLogSource? logger8 = Logger;
							if (logger8 != null)
							{
								logger8.LogWarning((object)("加载资源 " + text4 + " 时出错: " + ex3.Message));
							}
						}
					}
					if (!flag || (Object)(object)val2 == (Object)null)
					{
						ManualLogSource? logger9 = Logger;
						if (logger9 != null)
						{
							logger9.LogWarning((object)("AssetBundle不包含有效的GameObject资源: " + bundlePath));
						}
						val.Unload(true);
						return;
					}
					string text5 = ((Object)val2).name;
					string text6 = EnsureUniqueDisplayName(text5);
					if (text6 != text5)
					{
						ManualLogSource? logger10 = Logger;
						if (logger10 != null)
						{
							logger10.LogWarning((object)("检测到显示名称重复,将显示名称从 " + text5 + " 修改为 " + text6));
						}
						text5 = text6;
					}
					DecorationInfo decorationInfo = new DecorationInfo
					{
						Name = text,
						DisplayName = text5,
						IsVisible = false,
						Prefab = val2,
						ParentTag = parentTag,
						BundlePath = bundlePath
					};
					Decorations.Add(decorationInfo);
					ManualLogSource? logger11 = Logger;
					if (logger11 != null)
					{
						logger11.LogInfo((object)("成功加载装饰物: " + decorationInfo.DisplayName + ", 父级: " + decorationInfo.ParentTag));
					}
					val.Unload(false);
				}
				catch (Exception ex4)
				{
					ManualLogSource? logger12 = Logger;
					if (logger12 != null)
					{
						logger12.LogError((object)("处理AssetBundle时出错: " + ex4.Message));
					}
					if ((Object)(object)val != (Object)null)
					{
						val.Unload(true);
					}
				}
			}
			catch (Exception ex5)
			{
				ManualLogSource? logger13 = Logger;
				if (logger13 != null)
				{
					logger13.LogError((object)("加载装饰物包时出错: " + ex5.Message + ", 路径: " + bundlePath));
				}
				if ((Object)(object)val != (Object)null)
				{
					val.Unload(true);
				}
			}
		}

		private static string EnsureUniqueName(string baseName)
		{
			string name = baseName;
			int num = 1;
			while (Decorations.Any((DecorationInfo d) => d.Name != null && d.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
			{
				name = $"{baseName}({num})";
				num++;
			}
			return name;
		}

		private static string EnsureUniqueDisplayName(string baseDisplayName)
		{
			string displayName = baseDisplayName;
			int num = 1;
			while (Decorations.Any((DecorationInfo d) => d.DisplayName != null && d.DisplayName.Equals(displayName, StringComparison.OrdinalIgnoreCase)))
			{
				displayName = $"{baseDisplayName}({num})";
				num++;
			}
			return displayName;
		}

		private static string? GetParentTagFromPrefab(GameObject prefab)
		{
			string text = ((Object)prefab).name.ToLower();
			foreach (string key in parentPathMap.Keys)
			{
				if (key != null && text.Contains(key))
				{
					return key;
				}
			}
			return null;
		}

		public static bool GetDecorationState(string? name)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo == null)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("GetDecorationState: 找不到装饰物 " + name2));
				}
			}
			return decorationInfo?.IsVisible ?? false;
		}

		public static void SetDecorationState(string name, bool isVisible)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null)
			{
				decorationInfo.IsVisible = isVisible;
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)$"设置装饰物 {decorationInfo.DisplayName} 显示状态为: {isVisible}");
				}
			}
			else
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogWarning((object)("SetDecorationState: 找不到装饰物 " + name2));
				}
			}
		}

		public static bool ToggleDecorationState(string? name)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null)
			{
				decorationInfo.IsVisible = !decorationInfo.IsVisible;
				return decorationInfo.IsVisible;
			}
			ManualLogSource? logger = Logger;
			if (logger != null)
			{
				logger.LogWarning((object)("ToggleDecorationState: 找不到装饰物 " + name2));
			}
			return false;
		}

		public static string GetParentPath(string parentTag)
		{
			if (parentPathMap.TryGetValue(parentTag.ToLower(), out string value))
			{
				return value;
			}
			return parentPathMap["head"];
		}

		private static string? FindPluginsDirectory(string startDirectory)
		{
			try
			{
				string text = startDirectory;
				for (int i = 0; i < 5; i++)
				{
					string fileName = Path.GetFileName(text);
					if (string.Equals(fileName, "plugins", StringComparison.OrdinalIgnoreCase))
					{
						string directoryName = Path.GetDirectoryName(text);
						if (directoryName != null)
						{
							string fileName2 = Path.GetFileName(directoryName);
							if (string.Equals(fileName2, "BepInEx", StringComparison.OrdinalIgnoreCase))
							{
								return text;
							}
						}
					}
					string text2 = Path.Combine(text, "BepInEx", "plugins");
					if (Directory.Exists(text2))
					{
						return text2;
					}
					string directoryName2 = Path.GetDirectoryName(text);
					if (string.IsNullOrEmpty(directoryName2) || directoryName2 == text)
					{
						break;
					}
					text = directoryName2;
				}
				string pathRoot = Path.GetPathRoot(startDirectory);
				if (!string.IsNullOrEmpty(pathRoot))
				{
					string text3 = Path.Combine(pathRoot, "REPO", "BepInEx", "plugins");
					if (Directory.Exists(text3))
					{
						return text3;
					}
					string[] array = new string[4]
					{
						Path.Combine(pathRoot, "Program Files (x86)", "Steam", "steamapps", "common", "REPO"),
						Path.Combine(pathRoot, "Program Files", "Steam", "steamapps", "common", "REPO"),
						Path.Combine(pathRoot, "SteamLibrary", "steamapps", "common", "REPO"),
						Path.Combine(pathRoot, "Games", "REPO")
					};
					string[] array2 = array;
					foreach (string path in array2)
					{
						string text4 = Path.Combine(path, "BepInEx", "plugins");
						if (Directory.Exists(text4))
						{
							return text4;
						}
					}
				}
				return null;
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("查找plugins目录时出错: " + ex.Message));
				}
				return null;
			}
		}
	}
	public static class MoreHeadUI
	{
		private static REPOButton? menuButton;

		private static REPOPopupPage? decorationsPage;

		private static Dictionary<string?, REPOButton> decorationButtons = new Dictionary<string, REPOButton>();

		private const string BUTTON_NAME = "<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>";

		private const string PAGE_TITLE = "Rotate robot: A/D";

		private static ManualLogSource? Logger => Morehead.Logger;

		public static void Initialize()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			try
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"正在初始化MoreHead UI...");
				}
				menuButton = new REPOButton("<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>", (Action)OnMenuButtonClick);
				MenuAPI.AddElementToEscapeMenu((REPOElement)(object)menuButton, new Vector2(0f, 0f));
				decorationsPage = new REPOPopupPage("Rotate robot: A/D", (Action<REPOPopupPage>)SetupPopupPage);
				CreatePageContent();
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)"MoreHead UI初始化完成");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("初始化UI时出错: " + ex.Message));
				}
			}
		}

		private static void SetupPopupPage(REPOPopupPage page)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				page.SetSize(new Vector2(300f, 350f));
				page.SetBackgroundDimming(true);
				page.SetMaskPadding((Padding?)new Padding(10f, 20f, 20f, 10f));
				AddAuthorCredit(page);
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"弹出页面设置完成");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("设置弹出页面属性时出错: " + ex.Message));
				}
			}
		}

		private static void AddAuthorCredit(REPOPopupPage page)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				REPOButton val = new REPOButton("<size=10><color=#FFFFA0>Masaicker</color> and <color=#FFFFA0>Yuriscat</color> co-developed.\n由<color=#FFFFA0>马赛克了</color>和<color=#FFFFA0>尤里的猫</color>共同制作。</size>", (Action)delegate
				{
				});
				((REPOSimplePage)page).AddElementToPage((REPOElement)(object)val, new Vector2(300f, 345f));
				try
				{
					MenuManager obj = Object.FindObjectOfType<MenuManager>();
					if (obj != null)
					{
						((MonoBehaviour)obj).StartCoroutine(DelayedStyleAuthorCredit(val));
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("无法修改作者标记样式: " + ex.Message));
					}
				}
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)"添加作者标记完成");
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("添加作者标记时出错: " + ex2.Message));
				}
			}
		}

		private static IEnumerator DelayedStyleAuthorCredit(REPOButton button)
		{
			yield return null;
			try
			{
				GameObject buttonObj = null;
				Button[] allButtons = Object.FindObjectsOfType<Button>();
				Button[] array = allButtons;
				foreach (Button btn in array)
				{
					if (((Object)btn).name.Contains("Masaicker") && ((Object)btn).name.Contains("Yuriscat"))
					{
						buttonObj = ((Component)btn).gameObject;
						break;
					}
				}
				if (!((Object)(object)buttonObj != (Object)null))
				{
					yield break;
				}
				Button buttonComponent = buttonObj.GetComponent<Button>();
				if (!((Object)(object)buttonComponent != (Object)null))
				{
					yield break;
				}
				((Selectable)buttonComponent).interactable = false;
				Image[] images = buttonObj.GetComponentsInChildren<Image>();
				Image[] array2 = images;
				foreach (Image image in array2)
				{
					if ((Object)(object)((Component)image).gameObject != (Object)(object)((Component)buttonComponent).gameObject)
					{
						((Behaviour)image).enabled = false;
					}
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("修改作者标记样式失败: " + e.Message));
				}
			}
		}

		private static void OnMenuButtonClick()
		{
			try
			{
				UpdateButtonStates();
				REPOPopupPage? obj = decorationsPage;
				if (obj != null)
				{
					((REPOSimplePage)obj).OpenPage(false);
				}
				SetHeaderPosition();
				MovePlayerAvatarToFront();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("打开设置页面时出错: " + ex.Message));
				}
			}
		}

		private static void SetHeaderPosition()
		{
			try
			{
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedSetHeaderPosition());
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("设置标题位置时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedSetHeaderPosition()
		{
			yield return null;
			try
			{
				FieldInfo headerTransformField = typeof(REPOPopupPage).GetField("headerTransform", BindingFlags.Instance | BindingFlags.NonPublic);
				if (headerTransformField != null)
				{
					object? value = headerTransformField.GetValue(decorationsPage);
					RectTransform headerTransform = (RectTransform)((value is RectTransform) ? value : null);
					if ((Object)(object)headerTransform != (Object)null)
					{
						((Transform)headerTransform).localPosition = new Vector3(185.5049f, 368.9677f, 0f);
						yield break;
					}
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)"headerTransform为空");
					}
				}
				else
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)"找不到headerTransform字段");
					}
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("延迟设置标题位置时出错: " + e.Message));
				}
			}
		}

		private static void AdjustBoolSettingPosition()
		{
			try
			{
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedAdjustBoolSettingPosition());
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("调整Bool Setting位置时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedAdjustBoolSettingPosition()
		{
			yield return null;
			try
			{
				object? value = AccessTools.Field(typeof(REPOPopupPage), "menuPage").GetValue(decorationsPage);
				MenuPage menuPage = (MenuPage)((value is MenuPage) ? value : null);
				if (!((Object)(object)menuPage != (Object)null))
				{
					yield break;
				}
				Transform boolSetting = null;
				foreach (Transform item in ((Component)menuPage).transform)
				{
					Transform child = item;
					if ((Object)(object)child != (Object)null && ((Object)child).name.Contains("Bool Setting"))
					{
						boolSetting = child;
						break;
					}
				}
				if ((Object)(object)boolSetting != (Object)null)
				{
					RectTransform rectTransform = ((Component)boolSetting).GetComponent<RectTransform>();
					if ((Object)(object)rectTransform != (Object)null)
					{
						((Transform)rectTransform).localPosition = new Vector3(70f, 202.5f, 0f);
					}
				}
				else
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)"找不到Bool Setting - (Clone)对象");
					}
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("延迟调整Bool Setting位置时出错: " + e.Message));
				}
			}
		}

		private static void CreatePageContent()
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				for (int i = 0; i < HeadDecorationManager.Decorations.Count; i++)
				{
					DecorationInfo decoration = HeadDecorationManager.Decorations[i];
					REPOButton val = new REPOButton(GetButtonText(decoration.DisplayName?.ToUpper(), decoration.IsVisible), (Action)delegate
					{
						OnDecorationButtonClick(decoration.Name);
					});
					int num = -(i * 20);
					REPOPopupPage? obj = decorationsPage;
					if (obj != null)
					{
						obj.AddElementToScrollView((REPOElement)(object)val, new Vector2(0f, (float)num));
					}
					decorationButtons[decoration.Name ?? string.Empty] = val;
				}
				REPOButton val2 = new REPOButton("<size=18><color=#FFFFFF>C</color><color=#E6E6E6>L</color><color=#CCCCCC>O</color><color=#B3B3B3>S</color><color=#999999>E</color></size>", (Action)OnCloseButtonClick);
				REPOPopupPage? obj2 = decorationsPage;
				if (obj2 != null)
				{
					((REPOSimplePage)obj2).AddElementToPage((REPOElement)(object)val2, new Vector2(301f, 0f));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("创建页面内容时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateButtonStates()
		{
			try
			{
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					if (decorationButtons.TryGetValue(decoration.Name ?? string.Empty, out REPOButton value))
					{
						value.SetText(GetButtonText(decoration.DisplayName?.ToUpper(), decoration.IsVisible));
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新按钮状态时出错: " + ex.Message));
				}
			}
		}

		private static void OnDecorationButtonClick(string? decorationName)
		{
			string decorationName2 = decorationName;
			try
			{
				DecorationInfo decorationInfo = HeadDecorationManager.Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase));
				if (decorationInfo == null)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("OnDecorationButtonClick: 找不到装饰物: " + decorationName2));
					}
					return;
				}
				bool isEnabled = HeadDecorationManager.ToggleDecorationState(decorationName2);
				if (decorationButtons.TryGetValue(decorationName2, out REPOButton value))
				{
					value.SetText(GetButtonText(decorationInfo.DisplayName?.ToUpper(), isEnabled));
				}
				else
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("OnDecorationButtonClick: 找不到装饰物 " + decorationName2 + " 的按钮"));
					}
				}
				UpdateDecorations();
				ConfigManager.SaveConfig();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("切换装饰物 " + decorationName2 + " 状态时出错: " + ex.Message));
				}
			}
		}

		private static void OnCloseButtonClick()
		{
			try
			{
				MenuManager.instance.PageCloseAll();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("关闭页面时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateDecorations()
		{
			try
			{
				PlayerAvatar val = FindLocalPlayer();
				if ((Object)(object)val != (Object)null)
				{
					PlayerUpdatePatch.UpdatePlayerDecorations(val);
					HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>();
					if ((Object)(object)component != (Object)null)
					{
						component.SyncAllDecorations();
					}
				}
				PlayerUpdatePatch.UpdateMenuPlayerDecorations();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新装饰物状态时出错: " + ex.Message));
				}
			}
		}

		private static PlayerAvatar? FindLocalPlayer()
		{
			try
			{
				PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
				PlayerAvatar[] array2 = array;
				foreach (PlayerAvatar val in array2)
				{
					if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine)
					{
						return val;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("查找本地玩家时出错: " + ex.Message));
				}
			}
			return null;
		}

		private static string GetButtonText(string? name, bool isEnabled)
		{
			return "<size=16>" + (isEnabled ? "<color=#00FF00>[ON]</color>" : "<color=#FF0000>[OFF]</color>") + " " + name + "</size>";
		}

		private static void MovePlayerAvatarToFront()
		{
			try
			{
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedMovePlayerAvatarToFront());
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("移动玩家模型时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedMovePlayerAvatarToFront()
		{
			yield return null;
			try
			{
				PlayerAvatarMenuHover playerAvatarHover = Object.FindObjectOfType<PlayerAvatarMenuHover>();
				if ((Object)(object)playerAvatarHover != (Object)null)
				{
					GameObject playerAvatarObj2 = ((Component)((Component)playerAvatarHover).transform.parent).gameObject;
					object? value = AccessTools.Field(typeof(REPOPopupPage), "menuPage").GetValue(decorationsPage);
					MenuPage menuPage2 = (MenuPage)((value is MenuPage) ? value : null);
					if ((Object)(object)menuPage2 != (Object)null)
					{
						playerAvatarObj2.transform.SetParent(((Component)menuPage2).transform, true);
						playerAvatarObj2.transform.SetAsLastSibling();
						playerAvatarObj2.transform.localPosition = new Vector3(-76f, -30f, 0f);
					}
					yield break;
				}
				GameObject playerAvatarObj = GameObject.Find("Menu Element Player Avatar");
				if ((Object)(object)playerAvatarObj != (Object)null)
				{
					object? value2 = AccessTools.Field(typeof(REPOPopupPage), "menuPage").GetValue(decorationsPage);
					MenuPage menuPage = (MenuPage)((value2 is MenuPage) ? value2 : null);
					if ((Object)(object)menuPage != (Object)null)
					{
						playerAvatarObj.transform.SetParent(((Component)menuPage).transform, true);
						playerAvatarObj.transform.SetAsLastSibling();
						playerAvatarObj.transform.localPosition = new Vector3(-76f, -30f, 0f);
						ManualLogSource? logger = Logger;
						if (logger != null)
						{
							logger.LogInfo((object)"已通过名称查找将玩家模型移动到前面,并设置坐标为(-76, -30, 0)");
						}
					}
				}
				else
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)"找不到玩家模型对象");
					}
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("延迟移动玩家模型时出错: " + e.Message));
				}
			}
		}
	}
}

BeepInEx/plugins/diowo1-omgitmigu/hatsune miku/MoreHead.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using Microsoft.CodeAnalysis;
using MoreHead;
using Photon.Pun;
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 = "")]
[assembly: AssemblyCompany("MoreHead")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreHead")]
[assembly: AssemblyTitle("MoreHead")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
[BepInPlugin("Mhz.REPOMoreHead", "MoreHead", "1.0.0")]
public class Morehead : BaseUnityPlugin
{
	public static ManualLogSource? Logger;

	public static Morehead? Instance { get; private set; }

	private void Awake()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		Instance = this;
		Logger = ((BaseUnityPlugin)this).Logger;
		try
		{
			Harmony val = new Harmony("Mhz.REPOMoreHead");
			val.PatchAll(typeof(PlayerAvatarVisualsPatch));
			val.PatchAll(typeof(PlayerUpdatePatch));
			val.PatchAll(typeof(PlayerAvatarAwakePatch));
			val.PatchAll(typeof(MenuPlayerVisualsPatch));
			val.PatchAll(typeof(GameDirectorUpdatePatch));
			Logger.LogInfo((object)"MoreHead 已加载");
			HeadDecorationManager.Initialize();
			ConfigManager.Initialize();
			MoreHeadUI.Initialize();
		}
		catch (Exception ex)
		{
			Logger.LogError((object)("Harmony补丁应用失败: " + ex.Message));
		}
	}

	private void OnApplicationQuit()
	{
		ConfigManager.SaveConfig();
	}

	public static bool GetDecorationState(string? name)
	{
		return HeadDecorationManager.GetDecorationState(name);
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("Update")]
internal class PlayerUpdatePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		if (__instance.photonView.IsMine && GameManager.Multiplayer() && PhotonNetwork.LocalPlayer != null)
		{
		}
	}

	public static void UpdatePlayerDecorations(PlayerAvatar playerAvatar)
	{
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: 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_0162: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)playerAvatar?.playerAvatarVisuals == (Object)null)
			{
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = ((Component)playerAvatar.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = ((Component)playerAvatar.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = ((Component)playerAvatar.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			if (dictionary.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何装饰物父级节点");
				}
				return;
			}
			foreach (KeyValuePair<string, Transform> item in dictionary)
			{
				string key = item.Key;
				Transform value = item.Value;
				Transform val4 = value.Find("HeadDecorations");
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = new GameObject("HeadDecorations").transform;
					val4.SetParent(value, false);
					val4.localPosition = Vector3.zero;
					val4.localRotation = Quaternion.identity;
					val4.localScale = Vector3.one;
				}
			}
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (dictionary.TryGetValue(decoration.ParentTag, out var value2))
				{
					Transform val5 = value2.Find("HeadDecorations");
					if ((Object)(object)val5 != (Object)null)
					{
						UpdateDecoration(val5, decoration.Name, decoration.IsVisible);
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("找不到装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("更新装饰物状态失败: " + ex.Message));
			}
		}
	}

	private static void UpdateDecoration(Transform parent, string? decorationName, bool showDecoration)
	{
		Transform val = parent.Find(decorationName);
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(showDecoration);
		}
	}

	public static void UpdateMenuPlayerDecorations()
	{
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			PlayerAvatarVisuals val = FindMenuPlayerVisuals();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val2 = ((Component)val).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["head"] = val2;
			}
			Transform val3 = ((Component)val).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["neck"] = val3;
			}
			Transform val4 = ((Component)val).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val4 != (Object)null)
			{
				dictionary["body"] = val4;
			}
			if (dictionary.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何菜单角色装饰物父级节点");
				}
				return;
			}
			foreach (KeyValuePair<string, Transform> item in dictionary)
			{
				string key = item.Key;
				Transform value = item.Value;
				Transform val5 = value.Find("HeadDecorations");
				if ((Object)(object)val5 == (Object)null)
				{
					val5 = new GameObject("HeadDecorations").transform;
					val5.SetParent(value, false);
					val5.localPosition = Vector3.zero;
					val5.localRotation = Quaternion.identity;
					val5.localScale = Vector3.one;
				}
			}
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (dictionary.TryGetValue(decoration.ParentTag, out var value2))
				{
					Transform val6 = value2.Find("HeadDecorations");
					if ((Object)(object)val6 != (Object)null)
					{
						Transform val7 = val6.Find(decoration.Name);
						if ((Object)(object)val7 == (Object)null)
						{
							AddMenuDecoration(val6, decoration.Name);
						}
						else
						{
							((Component)val7).gameObject.SetActive(decoration.IsVisible);
						}
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("找不到菜单角色装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("更新菜单角色装饰物状态失败: " + ex.Message));
			}
		}
	}

	private static PlayerAvatarVisuals? FindMenuPlayerVisuals()
	{
		GameObject val = GameObject.Find("PlayerAvatarMenu");
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		return val.GetComponentInChildren<PlayerAvatarVisuals>();
	}

	public static void AddMenuDecoration(Transform parent, string? decorationName)
	{
		string decorationName2 = decorationName;
		try
		{
			Transform val = parent.Find(decorationName2);
			if ((Object)(object)val != (Object)null)
			{
				bool decorationState = Morehead.GetDecorationState(decorationName2);
				((Component)val).gameObject.SetActive(decorationState);
				return;
			}
			DecorationInfo decorationInfo = HeadDecorationManager.Decorations.Find((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null && (Object)(object)decorationInfo.Prefab != (Object)null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(decorationInfo.Prefab, parent);
				((Object)val2).name = decorationName2;
				val2.SetActive(decorationInfo.IsVisible);
				return;
			}
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogWarning((object)("AddMenuDecoration: 找不到装饰物 " + decorationName2 + " 或其预制体为空"));
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("为菜单角色添加装饰物时出错: " + ex.Message));
			}
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("Awake")]
internal class PlayerAvatarAwakePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		((Component)__instance).gameObject.AddComponent<HeadDecorationSync>();
	}
}
public class HeadDecorationSync : MonoBehaviourPun
{
	public void SyncAllDecorations()
	{
		try
		{
			string[] array = new string[HeadDecorationManager.Decorations.Count];
			bool[] array2 = new bool[HeadDecorationManager.Decorations.Count];
			string[] array3 = new string[HeadDecorationManager.Decorations.Count];
			for (int i = 0; i < HeadDecorationManager.Decorations.Count; i++)
			{
				DecorationInfo decorationInfo = HeadDecorationManager.Decorations[i];
				array[i] = decorationInfo.Name;
				array2[i] = decorationInfo.IsVisible;
				array3[i] = decorationInfo.ParentTag;
			}
			((MonoBehaviourPun)this).photonView.RPC("UpdateAllDecorations", (RpcTarget)1, new object[3] { array, array2, array3 });
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("同步所有装饰物状态失败: " + ex.Message));
			}
		}
	}

	[PunRPC]
	private void UpdateAllDecorations(string[] names, bool[] states, string[] parentTags)
	{
		try
		{
			PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.playerAvatarVisuals == (Object)null)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到PlayerAvatar或PlayerAvatarVisuals组件");
				}
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = ((Component)component.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = ((Component)component.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = ((Component)component.playerAvatarVisuals).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			for (int i = 0; i < names.Length; i++)
			{
				string decorationName = names[i];
				bool showDecoration = states[i];
				string key = parentTags[i];
				if (dictionary.TryGetValue(key, out var value))
				{
					Transform val4 = value.Find("HeadDecorations");
					if ((Object)(object)val4 != (Object)null)
					{
						UpdateDecoration(val4, decorationName, showDecoration);
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("RPC更新所有装饰物状态失败: " + ex.Message));
			}
		}
	}

	private void UpdateDecoration(Transform parent, string decorationName, bool showDecoration)
	{
		Transform val = parent.Find(decorationName);
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(showDecoration);
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals))]
[HarmonyPatch("Start")]
internal class PlayerAvatarVisualsPatch
{
	private static void Postfix(PlayerAvatarVisuals __instance)
	{
		//IL_0103: 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_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			if (dictionary.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogError((object)"找不到任何装饰物父级节点");
				}
				return;
			}
			foreach (KeyValuePair<string, Transform> item in dictionary)
			{
				string key = item.Key;
				Transform value = item.Value;
				Transform val4 = value.Find("HeadDecorations");
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = new GameObject("HeadDecorations").transform;
					val4.SetParent(value, false);
					val4.localPosition = Vector3.zero;
					val4.localRotation = Quaternion.identity;
					val4.localScale = Vector3.one;
				}
			}
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (dictionary.TryGetValue(decoration.ParentTag, out var value2))
				{
					Transform val5 = value2.Find("HeadDecorations");
					if ((Object)(object)val5 != (Object)null)
					{
						AddNewDecoration(val5, decoration, __instance);
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("初始化时找不到装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
			if (!GameManager.Multiplayer() || !((Object)(object)__instance.playerAvatar != (Object)null) || !((Object)(object)__instance.playerAvatar.photonView != (Object)null) || !__instance.playerAvatar.photonView.IsMine)
			{
				return;
			}
			try
			{
				HeadDecorationSync component = ((Component)__instance.playerAvatar).GetComponent<HeadDecorationSync>();
				if ((Object)(object)component != (Object)null)
				{
					component.SyncAllDecorations();
					return;
				}
				ManualLogSource? logger3 = Morehead.Logger;
				if (logger3 != null)
				{
					logger3.LogWarning((object)"找不到HeadDecorationSync组件,无法同步初始状态");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger4 = Morehead.Logger;
				if (logger4 != null)
				{
					logger4.LogError((object)("同步初始装饰物状态失败: " + ex.Message));
				}
			}
		}
		catch (Exception ex2)
		{
			ManualLogSource? logger5 = Morehead.Logger;
			if (logger5 != null)
			{
				logger5.LogError((object)("添加装饰物失败: " + ex2.Message));
			}
		}
	}

	private static void AddNewDecoration(Transform parent, DecorationInfo decoration, PlayerAvatarVisuals __instance)
	{
		Transform val = parent.Find(decoration.Name);
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(decoration.IsVisible);
			return;
		}
		if ((Object)(object)decoration.Prefab != (Object)null)
		{
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(decoration.Prefab, parent);
				((Object)val2).name = decoration.Name;
				val2.SetActive(decoration.IsVisible);
				return;
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogError((object)("实例化预制体时出错: " + ex.Message));
				}
				return;
			}
		}
		ManualLogSource? logger2 = Morehead.Logger;
		if (logger2 != null)
		{
			logger2.LogWarning((object)("AddNewDecoration: 装饰物 " + decoration.DisplayName + " 的预制体为空"));
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals))]
[HarmonyPatch("Start")]
internal class MenuPlayerVisualsPatch
{
	private static void Postfix(PlayerAvatarVisuals __instance)
	{
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!__instance.isMenuAvatar)
			{
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = ((Component)__instance).transform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			if (dictionary.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何菜单角色装饰物父级节点");
				}
				return;
			}
			foreach (KeyValuePair<string, Transform> item in dictionary)
			{
				string key = item.Key;
				Transform value = item.Value;
				Transform val4 = value.Find("HeadDecorations");
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = new GameObject("HeadDecorations").transform;
					val4.SetParent(value, false);
					val4.localPosition = Vector3.zero;
					val4.localRotation = Quaternion.identity;
					val4.localScale = Vector3.one;
				}
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					if (decoration.ParentTag == key)
					{
						PlayerUpdatePatch.AddMenuDecoration(val4, decoration.Name);
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("初始化菜单角色装饰物失败: " + ex.Message));
			}
		}
	}
}
[HarmonyPatch(typeof(GameDirector))]
[HarmonyPatch("Update")]
internal class GameDirectorUpdatePatch
{
	private static gameState previousState;

	private static void Postfix(GameDirector __instance)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Invalid comparison between Unknown and I4
		//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)
		try
		{
			if ((int)previousState != 2 && (int)__instance.currentState == 2)
			{
				SyncAllPlayersDecorations();
			}
			previousState = __instance.currentState;
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("监听游戏状态变化时出错: " + ex.Message));
			}
		}
	}

	private static void SyncAllPlayersDecorations()
	{
		try
		{
			PlayerAvatar val = FindLocalPlayer();
			if ((Object)(object)val != (Object)null)
			{
				PlayerUpdatePatch.UpdatePlayerDecorations(val);
				HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>();
				if ((Object)(object)component != (Object)null)
				{
					component.SyncAllDecorations();
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("同步所有玩家装饰物状态时出错: " + ex.Message));
			}
		}
	}

	private static PlayerAvatar? FindLocalPlayer()
	{
		try
		{
			PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
			PlayerAvatar[] array2 = array;
			foreach (PlayerAvatar val in array2)
			{
				if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine)
				{
					return val;
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("查找本地玩家时出错: " + ex.Message));
			}
		}
		return null;
	}
}
namespace MoreHead
{
	public static class ConfigManager
	{
		private static Dictionary<string?, bool> _decorationStates = new Dictionary<string, bool>();

		private static ManualLogSource? Logger => Morehead.Logger;

		private static string ConfigFilePath
		{
			get
			{
				Morehead? instance = Morehead.Instance;
				return Path.Combine(Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null) ?? string.Empty, "MoreHeadConfig.txt");
			}
		}

		public static void Initialize()
		{
			try
			{
				LoadConfig();
				ApplySavedStates();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("初始化配置管理器时出错: " + ex.Message));
				}
			}
		}

		private static void LoadConfig()
		{
			try
			{
				_decorationStates.Clear();
				if (!File.Exists(ConfigFilePath))
				{
					return;
				}
				string[] array = File.ReadAllLines(ConfigFilePath);
				string[] array2 = array;
				foreach (string text in array2)
				{
					if (!string.IsNullOrWhiteSpace(text))
					{
						string[] array3 = text.Split('=');
						if (array3.Length == 2)
						{
							string key = array3[0].Trim();
							bool value = array3[1].Trim().Equals("1", StringComparison.OrdinalIgnoreCase);
							_decorationStates[key] = value;
						}
					}
				}
				if (_decorationStates.Count > 0)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)$"已加载配置,包含 {_decorationStates.Count} 个装饰物状态");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("加载配置时出错: " + ex.Message));
				}
				_decorationStates.Clear();
			}
		}

		public static void SaveConfig()
		{
			try
			{
				UpdateConfigData();
				List<string> list = new List<string>();
				foreach (KeyValuePair<string, bool> decorationState in _decorationStates)
				{
					list.Add(decorationState.Key + "=" + (decorationState.Value ? "1" : "0"));
				}
				File.WriteAllLines(ConfigFilePath, list);
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("保存配置时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateConfigData()
		{
			_decorationStates.Clear();
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				_decorationStates[decoration.Name] = decoration.IsVisible;
			}
		}

		private static void ApplySavedStates()
		{
			try
			{
				int num = 0;
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					if (_decorationStates.TryGetValue(decoration.Name, out var value))
					{
						decoration.IsVisible = value;
						num++;
					}
				}
				if (num > 0)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)$"已应用 {num} 个已保存的装饰物状态");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("应用已保存的装饰物状态时出错: " + ex.Message));
				}
			}
		}
	}
	public class DecorationInfo
	{
		public string? Name { get; set; }

		public string? DisplayName { get; set; }

		public bool IsVisible { get; set; }

		public GameObject? Prefab { get; set; }

		public string? ParentTag { get; set; }

		public string? BundlePath { get; set; }
	}
	public static class HeadDecorationManager
	{
		private static Dictionary<string?, string> parentPathMap = new Dictionary<string, string>
		{
			{ "head", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top" },
			{ "neck", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side" },
			{ "body", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side" }
		};

		private static ManualLogSource? Logger => Morehead.Logger;

		public static List<DecorationInfo> Decorations { get; private set; } = new List<DecorationInfo>();


		public static void Initialize()
		{
			try
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"正在初始化装饰物管理器...");
				}
				Decorations.Clear();
				LoadAllDecorations();
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)$"装饰物管理器初始化完成,共加载了 {Decorations.Count} 个装饰物");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("初始化装饰物管理器时出错: " + ex.Message));
				}
			}
		}

		private static void LoadAllDecorations()
		{
			try
			{
				Morehead? instance = Morehead.Instance;
				string directoryName = Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null);
				if (string.IsNullOrEmpty(directoryName))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogError((object)"无法获取MOD所在目录");
					}
					return;
				}
				string text = Path.Combine(directoryName, "Decorations");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogInfo((object)("已创建装饰物目录: " + text));
					}
				}
				List<string> list = new List<string>();
				string[] files = Directory.GetFiles(text, "*.hhh");
				list.AddRange(files);
				try
				{
					string text2 = FindPluginsDirectory(directoryName);
					if (!string.IsNullOrEmpty(text2) && Directory.Exists(text2))
					{
						ManualLogSource? logger3 = Logger;
						if (logger3 != null)
						{
							logger3.LogInfo((object)("找到BepInEx/plugins目录: " + text2));
						}
						string[] files2 = Directory.GetFiles(text2, "*.hhh", SearchOption.AllDirectories);
						list.AddRange(files2);
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogInfo((object)$"在plugins目录中找到 {files2.Length} 个.hhh文件");
						}
					}
					else
					{
						ManualLogSource? logger5 = Logger;
						if (logger5 != null)
						{
							logger5.LogWarning((object)"无法找到BepInEx/plugins目录,将只加载本地装饰物");
						}
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger6 = Logger;
					if (logger6 != null)
					{
						logger6.LogError((object)("搜索plugins目录时出错: " + ex.Message));
					}
				}
				list = list.Distinct().ToList();
				if (list.Count == 0)
				{
					ManualLogSource? logger7 = Logger;
					if (logger7 != null)
					{
						logger7.LogWarning((object)"未找到任何装饰物包文件,请确保.hhh文件已放置");
					}
				}
				else
				{
					ManualLogSource? logger8 = Logger;
					if (logger8 != null)
					{
						logger8.LogInfo((object)$"找到 {list.Count} 个装饰物包文件");
					}
					if (files.Length != 0)
					{
						ManualLogSource? logger9 = Logger;
						if (logger9 != null)
						{
							logger9.LogInfo((object)$"- Decorations目录: {files.Length} 个文件");
						}
					}
				}
				foreach (string item in list)
				{
					LoadDecorationBundle(item);
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource? logger10 = Logger;
				if (logger10 != null)
				{
					logger10.LogError((object)("加载装饰物时出错: " + ex2.Message));
				}
			}
		}

		private static void LoadDecorationBundle(string bundlePath)
		{
			AssetBundle val = null;
			try
			{
				if (!File.Exists(bundlePath))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("文件不存在: " + bundlePath));
					}
					return;
				}
				FileInfo fileInfo = new FileInfo(bundlePath);
				if (fileInfo.Length < 1024)
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)$"文件过小,可能不是有效的AssetBundle: {bundlePath}, 大小: {fileInfo.Length} 字节");
					}
					return;
				}
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(bundlePath);
				string parentTag = "head";
				string text = fileNameWithoutExtension;
				if (fileNameWithoutExtension.Contains("_"))
				{
					string[] array = fileNameWithoutExtension.Split('_');
					if (array.Length >= 2)
					{
						string text2 = array[^1].ToLower();
						if (parentPathMap.ContainsKey(text2))
						{
							parentTag = text2;
							text = string.Join("_", array, 0, array.Length - 1);
						}
					}
				}
				string text3 = EnsureUniqueName(text);
				if (text3 != text)
				{
					ManualLogSource? logger3 = Logger;
					if (logger3 != null)
					{
						logger3.LogWarning((object)("检测到重名,将基础名称从 " + text + " 修改为 " + text3));
					}
					text = text3;
				}
				try
				{
					val = AssetBundle.LoadFromFile(bundlePath);
					if ((Object)(object)val == (Object)null)
					{
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogError((object)("无法加载AssetBundle,文件可能已损坏或不是有效的AssetBundle: " + bundlePath));
						}
						return;
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger5 = Logger;
					if (logger5 != null)
					{
						logger5.LogError((object)("加载AssetBundle时出错,文件可能不是有效的AssetBundle: " + bundlePath + ", 错误: " + ex.Message));
					}
					return;
				}
				try
				{
					string[] allAssetNames;
					try
					{
						allAssetNames = val.GetAllAssetNames();
					}
					catch (Exception ex2)
					{
						ManualLogSource? logger6 = Logger;
						if (logger6 != null)
						{
							logger6.LogError((object)("获取AssetBundle资源名称时出错: " + bundlePath + ", 错误: " + ex2.Message));
						}
						val.Unload(true);
						return;
					}
					if (allAssetNames.Length == 0)
					{
						ManualLogSource? logger7 = Logger;
						if (logger7 != null)
						{
							logger7.LogWarning((object)("AssetBundle不包含任何资源: " + bundlePath));
						}
						val.Unload(true);
						return;
					}
					bool flag = false;
					GameObject val2 = null;
					string[] array2 = allAssetNames;
					foreach (string text4 in array2)
					{
						try
						{
							val2 = val.LoadAsset<GameObject>(text4);
							if ((Object)(object)val2 != (Object)null)
							{
								flag = true;
								break;
							}
						}
						catch (Exception ex3)
						{
							ManualLogSource? logger8 = Logger;
							if (logger8 != null)
							{
								logger8.LogWarning((object)("加载资源 " + text4 + " 时出错: " + ex3.Message));
							}
						}
					}
					if (!flag || (Object)(object)val2 == (Object)null)
					{
						ManualLogSource? logger9 = Logger;
						if (logger9 != null)
						{
							logger9.LogWarning((object)("AssetBundle不包含有效的GameObject资源: " + bundlePath));
						}
						val.Unload(true);
						return;
					}
					string text5 = ((Object)val2).name;
					string text6 = EnsureUniqueDisplayName(text5);
					if (text6 != text5)
					{
						ManualLogSource? logger10 = Logger;
						if (logger10 != null)
						{
							logger10.LogWarning((object)("检测到显示名称重复,将显示名称从 " + text5 + " 修改为 " + text6));
						}
						text5 = text6;
					}
					DecorationInfo decorationInfo = new DecorationInfo
					{
						Name = text,
						DisplayName = text5,
						IsVisible = false,
						Prefab = val2,
						ParentTag = parentTag,
						BundlePath = bundlePath
					};
					Decorations.Add(decorationInfo);
					ManualLogSource? logger11 = Logger;
					if (logger11 != null)
					{
						logger11.LogInfo((object)("成功加载装饰物: " + decorationInfo.DisplayName + ", 父级: " + decorationInfo.ParentTag));
					}
					val.Unload(false);
				}
				catch (Exception ex4)
				{
					ManualLogSource? logger12 = Logger;
					if (logger12 != null)
					{
						logger12.LogError((object)("处理AssetBundle时出错: " + ex4.Message));
					}
					if ((Object)(object)val != (Object)null)
					{
						val.Unload(true);
					}
				}
			}
			catch (Exception ex5)
			{
				ManualLogSource? logger13 = Logger;
				if (logger13 != null)
				{
					logger13.LogError((object)("加载装饰物包时出错: " + ex5.Message + ", 路径: " + bundlePath));
				}
				if ((Object)(object)val != (Object)null)
				{
					val.Unload(true);
				}
			}
		}

		private static string EnsureUniqueName(string baseName)
		{
			string name = baseName;
			int num = 1;
			while (Decorations.Any((DecorationInfo d) => d.Name != null && d.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
			{
				name = $"{baseName}({num})";
				num++;
			}
			return name;
		}

		private static string EnsureUniqueDisplayName(string baseDisplayName)
		{
			string displayName = baseDisplayName;
			int num = 1;
			while (Decorations.Any((DecorationInfo d) => d.DisplayName != null && d.DisplayName.Equals(displayName, StringComparison.OrdinalIgnoreCase)))
			{
				displayName = $"{baseDisplayName}({num})";
				num++;
			}
			return displayName;
		}

		private static string? GetParentTagFromPrefab(GameObject prefab)
		{
			string text = ((Object)prefab).name.ToLower();
			foreach (string key in parentPathMap.Keys)
			{
				if (key != null && text.Contains(key))
				{
					return key;
				}
			}
			return null;
		}

		public static bool GetDecorationState(string? name)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo == null)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("GetDecorationState: 找不到装饰物 " + name2));
				}
			}
			return decorationInfo?.IsVisible ?? false;
		}

		public static void SetDecorationState(string name, bool isVisible)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null)
			{
				decorationInfo.IsVisible = isVisible;
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)$"设置装饰物 {decorationInfo.DisplayName} 显示状态为: {isVisible}");
				}
			}
			else
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogWarning((object)("SetDecorationState: 找不到装饰物 " + name2));
				}
			}
		}

		public static bool ToggleDecorationState(string? name)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null)
			{
				decorationInfo.IsVisible = !decorationInfo.IsVisible;
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)$"切换装饰物 {decorationInfo.DisplayName} 显示状态为: {decorationInfo.IsVisible}");
				}
				return decorationInfo.IsVisible;
			}
			ManualLogSource? logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogWarning((object)("ToggleDecorationState: 找不到装饰物 " + name2));
			}
			return false;
		}

		public static string GetParentPath(string parentTag)
		{
			if (parentPathMap.TryGetValue(parentTag.ToLower(), out string value))
			{
				return value;
			}
			return parentPathMap["head"];
		}

		private static string? FindPluginsDirectory(string startDirectory)
		{
			try
			{
				string text = startDirectory;
				for (int i = 0; i < 5; i++)
				{
					string fileName = Path.GetFileName(text);
					if (string.Equals(fileName, "plugins", StringComparison.OrdinalIgnoreCase))
					{
						string directoryName = Path.GetDirectoryName(text);
						if (directoryName != null)
						{
							string fileName2 = Path.GetFileName(directoryName);
							if (string.Equals(fileName2, "BepInEx", StringComparison.OrdinalIgnoreCase))
							{
								return text;
							}
						}
					}
					string text2 = Path.Combine(text, "BepInEx", "plugins");
					if (Directory.Exists(text2))
					{
						return text2;
					}
					string directoryName2 = Path.GetDirectoryName(text);
					if (string.IsNullOrEmpty(directoryName2) || directoryName2 == text)
					{
						break;
					}
					text = directoryName2;
				}
				string pathRoot = Path.GetPathRoot(startDirectory);
				if (!string.IsNullOrEmpty(pathRoot))
				{
					string text3 = Path.Combine(pathRoot, "REPO", "BepInEx", "plugins");
					if (Directory.Exists(text3))
					{
						return text3;
					}
					string[] array = new string[4]
					{
						Path.Combine(pathRoot, "Program Files (x86)", "Steam", "steamapps", "common", "REPO"),
						Path.Combine(pathRoot, "Program Files", "Steam", "steamapps", "common", "REPO"),
						Path.Combine(pathRoot, "SteamLibrary", "steamapps", "common", "REPO"),
						Path.Combine(pathRoot, "Games", "REPO")
					};
					string[] array2 = array;
					foreach (string path in array2)
					{
						string text4 = Path.Combine(path, "BepInEx", "plugins");
						if (Directory.Exists(text4))
						{
							return text4;
						}
					}
				}
				return null;
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("查找plugins目录时出错: " + ex.Message));
				}
				return null;
			}
		}
	}
	public static class MoreHeadUI
	{
		private static REPOButton? menuButton;

		private static REPOPopupPage? decorationsPage;

		private static Dictionary<string?, REPOButton> decorationButtons = new Dictionary<string, REPOButton>();

		private const string BUTTON_NAME = "MOREHEAD";

		private const string PAGE_TITLE = "Rotate robot: A/D";

		private static ManualLogSource? Logger => Morehead.Logger;

		public static void Initialize()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			try
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"正在初始化MoreHead UI...");
				}
				menuButton = new REPOButton("MOREHEAD", (Action)OnMenuButtonClick);
				MenuAPI.AddElementToEscapeMenu((REPOElement)(object)menuButton, new Vector2(0f, 0f));
				decorationsPage = new REPOPopupPage("Rotate robot: A/D", (Action<REPOPopupPage>)SetupPopupPage);
				CreatePageContent();
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)"MoreHead UI初始化完成");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("初始化UI时出错: " + ex.Message));
				}
			}
		}

		private static void SetupPopupPage(REPOPopupPage page)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				page.SetSize(new Vector2(300f, 350f));
				page.SetBackgroundDimming(true);
				page.SetMaskPadding((Padding?)new Padding(10f, 20f, 20f, 10f));
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"弹出页面设置完成");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("设置弹出页面属性时出错: " + ex.Message));
				}
			}
		}

		private static void OnMenuButtonClick()
		{
			try
			{
				UpdateButtonStates();
				REPOPopupPage? obj = decorationsPage;
				if (obj != null)
				{
					((REPOSimplePage)obj).OpenPage(false);
				}
				SetHeaderPosition();
				AdjustBoolSettingPosition();
				EnableScrollBar();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("打开设置页面时出错: " + ex.Message));
				}
			}
		}

		private static void SetHeaderPosition()
		{
			try
			{
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedSetHeaderPosition());
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("设置标题位置时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedSetHeaderPosition()
		{
			yield return null;
			try
			{
				FieldInfo headerTransformField = typeof(REPOPopupPage).GetField("headerTransform", BindingFlags.Instance | BindingFlags.NonPublic);
				if (headerTransformField != null)
				{
					object? value = headerTransformField.GetValue(decorationsPage);
					RectTransform headerTransform = (RectTransform)((value is RectTransform) ? value : null);
					if ((Object)(object)headerTransform != (Object)null)
					{
						((Transform)headerTransform).localPosition = new Vector3(185.5049f, 368.9677f, 0f);
						yield break;
					}
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)"headerTransform为空");
					}
				}
				else
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)"找不到headerTransform字段");
					}
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("延迟设置标题位置时出错: " + e.Message));
				}
			}
		}

		private static void EnableScrollBar()
		{
			try
			{
				FieldInfo field = typeof(REPOPopupPage).GetField("menuScrollBox", BindingFlags.Instance | BindingFlags.NonPublic);
				if (!(field != null))
				{
					return;
				}
				object? value = field.GetValue(decorationsPage);
				MenuScrollBox val = (MenuScrollBox)((value is MenuScrollBox) ? value : null);
				if (!((Object)(object)val != (Object)null))
				{
					return;
				}
				val.heightPadding = 50f;
				FieldInfo field2 = typeof(REPOPopupPage).GetField("scrollBarTransform", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field2 != null)
				{
					object? value2 = field2.GetValue(decorationsPage);
					RectTransform val2 = (RectTransform)((value2 is RectTransform) ? value2 : null);
					if ((Object)(object)val2 != (Object)null)
					{
						((Component)val2).gameObject.SetActive(true);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("启用滚动条时出错: " + ex.Message));
				}
			}
		}

		private static void AdjustBoolSettingPosition()
		{
			try
			{
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedAdjustBoolSettingPosition());
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("调整Bool Setting位置时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedAdjustBoolSettingPosition()
		{
			yield return null;
			try
			{
				object? value = AccessTools.Field(typeof(REPOPopupPage), "menuPage").GetValue(decorationsPage);
				MenuPage menuPage = (MenuPage)((value is MenuPage) ? value : null);
				if (!((Object)(object)menuPage != (Object)null))
				{
					yield break;
				}
				Transform boolSetting = null;
				foreach (Transform item in ((Component)menuPage).transform)
				{
					Transform child = item;
					if ((Object)(object)child != (Object)null && ((Object)child).name.Contains("Bool Setting"))
					{
						boolSetting = child;
						break;
					}
				}
				if ((Object)(object)boolSetting != (Object)null)
				{
					RectTransform rectTransform = ((Component)boolSetting).GetComponent<RectTransform>();
					if ((Object)(object)rectTransform != (Object)null)
					{
						((Transform)rectTransform).localPosition = new Vector3(70f, 202.5f, 0f);
					}
				}
				else
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)"找不到Bool Setting - (Clone)对象");
					}
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("延迟调整Bool Setting位置时出错: " + e.Message));
				}
			}
		}

		private static void CreatePageContent()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				for (int i = 0; i < HeadDecorationManager.Decorations.Count; i++)
				{
					DecorationInfo decoration = HeadDecorationManager.Decorations[i];
					REPOButton val = new REPOButton(GetButtonText(decoration.DisplayName?.ToUpper(), decoration.IsVisible), (Action)delegate
					{
						OnDecorationButtonClick(decoration.Name);
					});
					int num = -(30 + i * 40);
					REPOPopupPage? obj = decorationsPage;
					if (obj != null)
					{
						obj.AddElementToScrollView((REPOElement)(object)val, new Vector2(0f, (float)num));
					}
					decorationButtons[decoration.Name ?? string.Empty] = val;
				}
				REPOButton val2 = new REPOButton("CLOSE", (Action)OnCloseButtonClick);
				REPOPopupPage? obj2 = decorationsPage;
				if (obj2 != null)
				{
					((REPOSimplePage)obj2).AddElementToPage((REPOElement)(object)val2, new Vector2(200f, 0f));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("创建页面内容时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateButtonStates()
		{
			try
			{
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					if (decorationButtons.TryGetValue(decoration.Name ?? string.Empty, out REPOButton value))
					{
						value.SetText(GetButtonText(decoration.DisplayName?.ToUpper(), decoration.IsVisible));
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新按钮状态时出错: " + ex.Message));
				}
			}
		}

		private static void OnDecorationButtonClick(string? decorationName)
		{
			string decorationName2 = decorationName;
			try
			{
				DecorationInfo decorationInfo = HeadDecorationManager.Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase));
				if (decorationInfo == null)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("OnDecorationButtonClick: 找不到装饰物: " + decorationName2));
					}
					return;
				}
				bool isEnabled = HeadDecorationManager.ToggleDecorationState(decorationName2);
				if (decorationButtons.TryGetValue(decorationName2, out REPOButton value))
				{
					value.SetText(GetButtonText(decorationInfo.DisplayName?.ToUpper(), isEnabled));
				}
				else
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("OnDecorationButtonClick: 找不到装饰物 " + decorationName2 + " 的按钮"));
					}
				}
				UpdateDecorations();
				ConfigManager.SaveConfig();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("切换装饰物 " + decorationName2 + " 状态时出错: " + ex.Message));
				}
			}
		}

		private static void OnCloseButtonClick()
		{
			try
			{
				REPOPopupPage? obj = decorationsPage;
				if (obj != null)
				{
					((REPOSimplePage)obj).ClosePage(false);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("关闭页面时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateDecorations()
		{
			try
			{
				PlayerAvatar val = FindLocalPlayer();
				if ((Object)(object)val != (Object)null)
				{
					PlayerUpdatePatch.UpdatePlayerDecorations(val);
					HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>();
					if ((Object)(object)component != (Object)null)
					{
						component.SyncAllDecorations();
					}
				}
				PlayerUpdatePatch.UpdateMenuPlayerDecorations();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新装饰物状态时出错: " + ex.Message));
				}
			}
		}

		private static PlayerAvatar? FindLocalPlayer()
		{
			try
			{
				PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
				PlayerAvatar[] array2 = array;
				foreach (PlayerAvatar val in array2)
				{
					if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine)
					{
						return val;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("查找本地玩家时出错: " + ex.Message));
				}
			}
			return null;
		}

		private static string GetButtonText(string? name, bool isEnabled)
		{
			return name + ": " + (isEnabled ? "ON" : "OFF");
		}
	}
}

BeepInEx/plugins/eth9n-Mimic/Mimics.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using Photon.Voice;
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("Mimics")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("Mimics")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Mimics
{
	public class Mimics : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <DestroyAfterDelay>d__32 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AudioSource audioSource;

			public float delay;

			public Mimics <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Object.Destroy((Object)(object)audioSource);
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public Mimics <>4__this;

			private int <clipCount>5__1;

			private float <randomDelay>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					goto IL_00e0;
				case 1:
					<>1__state = -1;
					break;
				case 2:
					{
						<>1__state = -1;
						<>4__this.StartRecording();
						goto IL_00e0;
					}
					IL_00e0:
					<clipCount>5__1 = Directory.GetFiles(<>4__this.audioFolderPath, "*.wav").Length;
					if (<clipCount>5__1 >= <>4__this.maxClipCount)
					{
						<>2__current = <>4__this.ClearAudioFolderAsync().AsCoroutine();
						<>1__state = 1;
						return true;
					}
					break;
				}
				<randomDelay>5__2 = Random.Range(Plugin.configMinDelay.Value, Plugin.configMaxDelay.Value);
				<>2__current = (object)new WaitForSeconds(<randomDelay>5__2);
				<>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();
			}
		}

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

			private object <>2__current;

			public PlayerAvatar playerAvatar;

			public Mimics <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Expected O, but got Unknown
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.playerVoiceChat = (PlayerVoiceChat)<>4__this.voiceChatField.GetValue(playerAvatar);
					break;
				case 1:
					<>1__state = -1;
					<>4__this.playerVoiceChat = (PlayerVoiceChat)<>4__this.voiceChatField.GetValue(playerAvatar);
					break;
				}
				if ((Object)(object)<>4__this.playerVoiceChat == (Object)null)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				log.LogInfo((object)"PlayerVoiceChat successfully initialized.");
				if (<>4__this.photonView.IsMine && SemiFunc.RunIsLevel())
				{
					<>4__this.audioFolderPath = Path.Combine(Application.dataPath, "AudioFiles");
					Directory.CreateDirectory(<>4__this.audioFolderPath);
					((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.RecordAtRandomIntervals());
				}
				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 static readonly ManualLogSource log = Logger.CreateLogSource("Mimics");

		public PhotonView photonView;

		private PlayerVoiceChat playerVoiceChat;

		private FieldInfo voiceChatField;

		private PlayerAvatar playerAvatar;

		private int sampleRate = 48000;

		private float[] audioBuffer;

		private int bufferPosition = 0;

		public bool isRecording = false;

		private bool capturingSpeech = false;

		private string audioFolderPath;

		private int maxClipCount = 10;

		private bool fileSaved = false;

		private HashSet<int> sentChunks = new HashSet<int>();

		private List<byte[]> receivedChunks = new List<byte[]>();

		private int expectedChunkCount = 0;

		private void Awake()
		{
			photonView = ((Component)this).GetComponent<PhotonView>();
			if ((Object)(object)photonView == (Object)null)
			{
				log.LogError((object)"PhotonView not found on Mimics.");
				return;
			}
			PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
			if ((Object)(object)component == (Object)null)
			{
				log.LogError((object)"PlayerAvatar not found on Mimics.");
				return;
			}
			voiceChatField = typeof(PlayerAvatar).GetField("voiceChat", BindingFlags.Instance | BindingFlags.NonPublic);
			if (voiceChatField == null)
			{
				log.LogError((object)"Could not find 'voiceChat' field in PlayerAvatar.");
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(WaitForVoiceChat(component));
			}
		}

		[IteratorStateMachine(typeof(<WaitForVoiceChat>d__14))]
		private IEnumerator WaitForVoiceChat(PlayerAvatar playerAvatar)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForVoiceChat>d__14(0)
			{
				<>4__this = this,
				playerAvatar = playerAvatar
			};
		}

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

		private void StartRecording()
		{
			if (!isRecording)
			{
				audioBuffer = new float[sampleRate * 3];
				bufferPosition = 0;
				isRecording = true;
				capturingSpeech = false;
				fileSaved = false;
				log.LogInfo((object)"Recording started.");
			}
		}

		public void ProcessVoiceData(short[] voiceData)
		{
			if (!isRecording || !photonView.IsMine)
			{
				return;
			}
			if ((bool)typeof(PlayerVoiceChat).GetField("isTalking", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(playerVoiceChat) && !capturingSpeech)
			{
				capturingSpeech = true;
				bufferPosition = 0;
				log.LogInfo((object)"Speech detected, capturing audio.");
			}
			if (capturingSpeech)
			{
				int num = Mathf.Min(voiceData.Length, audioBuffer.Length - bufferPosition);
				for (int i = 0; i < num; i++)
				{
					audioBuffer[bufferPosition + i] = (float)voiceData[i] / 32768f;
				}
				bufferPosition += num;
				if (bufferPosition >= audioBuffer.Length && !fileSaved)
				{
					isRecording = false;
					capturingSpeech = false;
					fileSaved = true;
					log.LogInfo((object)"Buffer full, saving audio.");
					SaveAudioToFileAsync(audioBuffer);
				}
			}
		}

		private async Task SaveAudioToFileAsync(float[] audioData)
		{
			string filePath = Path.Combine(audioFolderPath, $"audio_{Guid.NewGuid()}.wav");
			byte[] audioBytes = ConvertFloatArrayToByteArray(audioData);
			using (FileStream fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write))
			{
				using BinaryWriter writer = new BinaryWriter(fileStream);
				WriteWavHeader(writer, audioData.Length, sampleRate);
				writer.Write(audioBytes);
			}
			log.LogInfo((object)("Audio saved to: " + filePath));
			await PlayRandomAudioFile();
		}

		private void WriteWavHeader(BinaryWriter writer, int sampleCount, int sampleRate)
		{
			writer.Write("RIFF".ToCharArray());
			writer.Write(36 + sampleCount * 2);
			writer.Write("WAVE".ToCharArray());
			writer.Write("fmt ".ToCharArray());
			writer.Write(16);
			writer.Write((short)1);
			writer.Write((short)1);
			writer.Write(sampleRate);
			writer.Write(sampleRate * 2);
			writer.Write((short)2);
			writer.Write((short)16);
			writer.Write("data".ToCharArray());
			writer.Write(sampleCount * 2);
		}

		private byte[] ConvertFloatArrayToByteArray(float[] audioData)
		{
			byte[] array = new byte[audioData.Length * 2];
			for (int i = 0; i < audioData.Length; i++)
			{
				short value = (short)(audioData[i] * 32767f);
				BitConverter.GetBytes(value).CopyTo(array, i * 2);
			}
			return array;
		}

		private async Task PlayRandomAudioFile()
		{
			string[] files = Directory.GetFiles(audioFolderPath, "*.wav");
			if (files.Length != 0)
			{
				string selectedFile = files[Random.Range(0, files.Length)];
				await SendAudioInChunksAsync(await File.ReadAllBytesAsync(selectedFile));
			}
		}

		private async Task SendAudioInChunksAsync(byte[] audioData)
		{
			List<byte[]> chunks = ChunkAudioData(audioData, 8192);
			sentChunks.Clear();
			for (int i = 0; i < chunks.Count; i++)
			{
				if (!PhotonNetwork.IsConnectedAndReady)
				{
					log.LogWarning((object)"Photon disconnected, aborting send.");
					return;
				}
				photonView.RPC("ReceiveAudioChunk", (RpcTarget)0, new object[3]
				{
					chunks[i],
					i,
					chunks.Count
				});
				sentChunks.Add(i);
				await Task.Delay(125);
			}
			log.LogInfo((object)"All chunks sent.");
		}

		[PunRPC]
		public void ReceiveAudioChunk(byte[] chunk, int chunkIndex, int totalChunks)
		{
			if (chunkIndex == 0)
			{
				receivedChunks.Clear();
				expectedChunkCount = totalChunks;
				log.LogInfo((object)$"New audio transmission started, expecting {totalChunks} chunks.");
			}
			if (chunkIndex >= expectedChunkCount)
			{
				log.LogWarning((object)$"Received chunk index {chunkIndex} exceeds expected {expectedChunkCount}.");
				return;
			}
			if (chunkIndex >= receivedChunks.Count)
			{
				receivedChunks.AddRange(Enumerable.Repeat<byte[]>(null, chunkIndex - receivedChunks.Count + 1));
			}
			receivedChunks[chunkIndex] = chunk;
			if (receivedChunks.Count >= expectedChunkCount && receivedChunks.All((byte[] c) => c != null))
			{
				log.LogInfo((object)"All chunks received, playing audio.");
				byte[] audioData = CombineChunks(receivedChunks);
				PlayReceivedAudio(audioData);
				receivedChunks.Clear();
				expectedChunkCount = 0;
			}
		}

		private byte[] CombineChunks(List<byte[]> chunks)
		{
			int num = chunks.Sum((byte[] chunk) => chunk.Length);
			byte[] array = new byte[num];
			int num2 = 0;
			foreach (byte[] chunk in chunks)
			{
				Array.Copy(chunk, 0, array, num2, chunk.Length);
				num2 += chunk.Length;
			}
			return array;
		}

		private void PlayReceivedAudio(byte[] audioData)
		{
			float[] array = ConvertByteArrayToFloatArray(audioData);
			AudioClip val = AudioClip.Create("ReceivedClip", array.Length, 1, sampleRate, false);
			val.SetData(array, 0);
			foreach (GameObject item in from e in GetEnemiesList()
				where (Object)(object)e != (Object)null && !((Object)e).name.Contains("Gnome")
				select e)
			{
				Transform obj = item.transform.Find("Enable/Controller");
				GameObject val2 = ((obj != null) ? ((Component)obj).gameObject : null);
				if (!((Object)(object)val2 == (Object)null))
				{
					AudioSource val3 = val2.GetComponent<AudioSource>() ?? val2.AddComponent<AudioSource>();
					val3.clip = val;
					val3.volume = 1f;
					val3.spatialBlend = 1f;
					val3.dopplerLevel = 0.5f;
					val3.minDistance = 1f;
					val3.maxDistance = 20f;
					val3.rolloffMode = (AudioRolloffMode)1;
					val3.Play();
					((MonoBehaviour)this).StartCoroutine(DestroyAfterDelay(val3, val.length + 0.1f));
				}
			}
		}

		private List<GameObject> GetEnemiesList()
		{
			GameObject obj = GameObject.Find("Level Generator");
			Transform val = ((obj != null) ? obj.transform.Find("Enemies") : null);
			return ((Object)(object)val != (Object)null) ? (from Transform t in (IEnumerable)val
				select ((Component)t).gameObject).ToList() : new List<GameObject>();
		}

		private float[] ConvertByteArrayToFloatArray(byte[] byteArray)
		{
			float[] array = new float[byteArray.Length / 2];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = (float)BitConverter.ToInt16(byteArray, i * 2) / 32768f;
			}
			return array;
		}

		private async Task ClearAudioFolderAsync()
		{
			string[] files = Directory.GetFiles(audioFolderPath, "*.wav");
			foreach (string file in files)
			{
				await Task.Run(delegate
				{
					File.Delete(file);
				});
			}
			log.LogInfo((object)"Audio folder cleared.");
		}

		[IteratorStateMachine(typeof(<DestroyAfterDelay>d__32))]
		private IEnumerator DestroyAfterDelay(AudioSource audioSource, float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DestroyAfterDelay>d__32(0)
			{
				<>4__this = this,
				audioSource = audioSource,
				delay = delay
			};
		}

		private List<byte[]> ChunkAudioData(byte[] audioData, int chunkSize)
		{
			List<byte[]> list = new List<byte[]>();
			for (int i = 0; i < audioData.Length; i += chunkSize)
			{
				int num = Mathf.Min(chunkSize, audioData.Length - i);
				byte[] array = new byte[num];
				Array.Copy(audioData, i, array, 0, num);
				list.Add(array);
			}
			return list;
		}
	}
	public static class TaskExtensions
	{
		[CompilerGenerated]
		private sealed class <AsCoroutine>d__0 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Task task;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!task.IsCompleted)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if (task.Exception != null)
				{
					throw task.Exception;
				}
				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();
			}
		}

		[IteratorStateMachine(typeof(<AsCoroutine>d__0))]
		public static IEnumerator AsCoroutine(this Task task)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <AsCoroutine>d__0(0)
			{
				task = task
			};
		}
	}
	[BepInPlugin("Mimics", "Mimics", "1.1.2")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private static Harmony _harmony;

		public static ConfigEntry<float> configMinDelay;

		public static ConfigEntry<float> configMaxDelay;

		private void Awake()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin Mimics is loaded!");
			configMinDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinDelay", 30f, "Minimum time before an audio clip is recorded and played.");
			configMaxDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxDelay", 120f, "Maximum time before an audio clip is recorded and played.");
			_harmony = new Harmony("Mimics");
			_harmony.PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Mimics";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}
namespace Mimics.patches
{
	public class MimicsFinder : MonoBehaviour
	{
		private static MimicsFinder instance;

		private static readonly ManualLogSource log = Logger.CreateLogSource("Mimics");

		public static Mimics LocalMimics { get; set; }

		public static void EnsureInitialized()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)instance == (Object)null)
			{
				instance = new GameObject("MimicsFinder").AddComponent<MimicsFinder>();
				Object.DontDestroyOnLoad((Object)(object)((Component)instance).gameObject);
				ManualLogSource obj = log;
				Player localPlayer = PhotonNetwork.LocalPlayer;
				obj.LogInfo((object)$"MimicsFinder initialized for Player {((localPlayer != null) ? localPlayer.ActorNumber : (-1))}");
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)instance == (Object)(object)this)
			{
				LocalMimics = null;
				instance = null;
				log.LogInfo((object)"MimicsFinder destroyed, clearing cache.");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar), "Awake")]
	internal class PlayerAvatarPatch
	{
		private static readonly ManualLogSource log = Logger.CreateLogSource("Mimics");

		private static void Postfix(PlayerAvatar __instance)
		{
			if (PhotonNetwork.IsConnectedAndReady)
			{
				Mimics mimics = ((Component)__instance).GetComponent<Mimics>();
				if ((Object)(object)mimics == (Object)null)
				{
					mimics = ((Component)__instance).gameObject.AddComponent<Mimics>();
					log.LogInfo((object)("Added Mimics component to PlayerAvatar: " + ((Object)__instance).name));
				}
				PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null && component.IsMine)
				{
					MimicsFinder.LocalMimics = mimics;
					log.LogInfo((object)("Set LocalMimics for local PlayerAvatar: " + ((Object)__instance).name));
				}
			}
		}
	}
	[HarmonyPatch(typeof(LocalVoiceFramed<short>), "PushDataAsync")]
	internal class LocalVoiceFramedPatch
	{
		private static void Prefix(short[] buf)
		{
			MimicsFinder.EnsureInitialized();
			if (PhotonNetwork.IsConnectedAndReady && !((Object)(object)MimicsFinder.LocalMimics == (Object)null) && !((Object)(object)((Component)MimicsFinder.LocalMimics).gameObject == (Object)null) && MimicsFinder.LocalMimics.photonView.IsMine)
			{
				MimicsFinder.LocalMimics.ProcessVoiceData(buf);
			}
		}
	}
}

BeepInEx/plugins/flipf17-DeadTTS/REPO-DeadTTS.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using REPO_DeadTTS.Config;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("REPO-DeadTTS")]
[assembly: AssemblyDescription("Mod created by flipf17")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPO-DeadTTS")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8e05cd18-c8aa-419a-b430-33faaf371490")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace REPO_DeadTTS
{
	[BepInPlugin("flipf17.DeadTTS", "DeadTTS", "1.0.5")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static Plugin instance;

		private static ManualLogSource logger;

		private void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			instance = this;
			CreateCustomLogger();
			ConfigSettings.BindConfigSettings();
			_harmony = new Harmony("DeadTTS");
			PatchAll();
			Log("DeadTTS loaded");
		}

		private void PatchAll()
		{
			IEnumerable<Type> enumerable;
			try
			{
				enumerable = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				enumerable = ex.Types.Where((Type t) => t != null);
			}
			foreach (Type item in enumerable)
			{
				_harmony.PatchAll(item);
			}
		}

		private void CreateCustomLogger()
		{
			try
			{
				logger = Logger.CreateLogSource(string.Format("{0}-{1}", "DeadTTS", "1.0.5"));
			}
			catch
			{
				logger = ((BaseUnityPlugin)this).Logger;
			}
		}

		internal static void Log(string message)
		{
			logger.LogInfo((object)message);
		}

		internal static void LogError(string message)
		{
			logger.LogError((object)message);
		}

		internal static void LogWarning(string message)
		{
			logger.LogWarning((object)message);
		}

		internal static void LogVerbose(string message)
		{
			if (ConfigSettings.verboseLogs.Value)
			{
				logger.LogInfo((object)("[VERBOSE] " + message));
			}
		}

		internal static void LogErrorVerbose(string message)
		{
			if (ConfigSettings.verboseLogs.Value)
			{
				logger.LogError((object)("[VERBOSE] " + message));
			}
		}

		internal static void LogWarningVerbose(string message)
		{
			if (ConfigSettings.verboseLogs.Value)
			{
				logger.LogWarning((object)("[VERBOSE] " + message));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "flipf17.DeadTTS";

		public const string PLUGIN_NAME = "DeadTTS";

		public const string PLUGIN_VERSION = "1.0.5";
	}
}
namespace REPO_DeadTTS.Patches
{
	[HarmonyPatch]
	public static class UIPatcher
	{
		private static HashSet<WorldSpaceUITTS> deadTTSElements = new HashSet<WorldSpaceUITTS>();

		private static Dictionary<PlayerAvatar, bool> isDisabledStates = new Dictionary<PlayerAvatar, bool>();

		private static FieldInfo textField = typeof(WorldSpaceUITTS).GetField("text", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo playerAvatarField = typeof(WorldSpaceUITTS).GetField("playerAvatar", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo followTransformField = typeof(WorldSpaceUITTS).GetField("followTransform", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo worldPositionField = typeof(WorldSpaceUITTS).GetField("worldPosition", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo followPositionField = typeof(WorldSpaceUITTS).GetField("followPosition", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo wordTimeField = typeof(WorldSpaceUITTS).GetField("wordTime", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo ttsVoiceField = typeof(WorldSpaceUITTS).GetField("ttsVoice", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch(typeof(WorldSpaceUIParent), "TTS")]
		[HarmonyPrefix]
		public static void OnTTSUI(PlayerAvatar _player, string _text, float _time, WorldSpaceUIParent __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Invalid comparison between Unknown and I4
			//IL_0101: 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_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			if (!GameManager.Multiplayer() || (int)GameDirector.instance.currentState < 2 || (ConfigSettings.disableWhileDead.Value && Object.op_Implicit((Object)(object)PlayerPatcher.localPlayer) && (bool)PlayerPatcher.isDisabledField.GetValue(PlayerPatcher.localPlayer)) || !ConfigSettings.deadTTSSpatialAudio.Value || (int)GameDirector.instance.currentState != 2 || !Object.op_Implicit((Object)(object)_player) || !(bool)PlayerPatcher.isDisabledField.GetValue(_player) || !Object.op_Implicit((Object)(object)_player.playerDeathHead) || string.IsNullOrEmpty(_text) || (ConfigSettings.enableWhenDiscovered.Value && !PlayerPatcher.discoveredDeadPlayers.Contains(_player) && (!Object.op_Implicit((Object)(object)PlayerPatcher.localPlayer) || !(bool)PlayerPatcher.isDisabledField.GetValue(PlayerPatcher.localPlayer))))
			{
				return;
			}
			try
			{
				WorldSpaceUITTS component = Object.Instantiate<GameObject>(__instance.TTSPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation, ((Component)__instance).transform).GetComponent<WorldSpaceUITTS>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				TMP_Text val = (TMP_Text)textField.GetValue(component);
				val.text = _text;
				if (!PlayerPatcher.IsLocalPlayerDead())
				{
					string text = val.text;
					try
					{
						text = "<color=#" + ConfigSettings.deadTTSColor.Value.TrimStart(new char[1] { '#' }) + ">" + val.text + "</color>";
						val.text = text;
					}
					catch (Exception ex)
					{
						Plugin.LogError("Failed to apply dead TTS color: " + ConfigSettings.deadTTSColor.Value + "\n" + ex);
					}
				}
				playerAvatarField.SetValue(component, _player);
				Transform transform = ((Component)_player.playerDeathHead).transform;
				followTransformField.SetValue(component, transform);
				worldPositionField.SetValue(component, transform.position);
				followPositionField.SetValue(component, transform.position);
				wordTimeField.SetValue(component, _time);
				PlayerVoiceChat val2 = (PlayerVoiceChat)PlayerPatcher.voiceChatField.GetValue(_player);
				ttsVoiceField.SetValue(component, val2.ttsVoice);
				deadTTSElements.Add(component);
				try
				{
					deadTTSElements.RemoveWhere((WorldSpaceUITTS obj) => (Object)(object)obj == (Object)null);
				}
				catch
				{
				}
			}
			catch (Exception ex2)
			{
				Plugin.LogError("Error initializing dead TTS UI:\n" + ex2);
			}
		}

		[HarmonyPatch(typeof(WorldSpaceUITTS), "Update")]
		[HarmonyPrefix]
		private static void UpdateUIPositionPrefix(WorldSpaceUITTS __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			if (ConfigSettings.displayDeadTTSText.Value && deadTTSElements.Contains(__instance))
			{
				try
				{
					PlayerAvatar val = (PlayerAvatar)playerAvatarField.GetValue(__instance);
					bool value = (bool)PlayerPatcher.isDisabledField.GetValue(val);
					isDisabledStates[val] = value;
					PlayerPatcher.isDisabledField.SetValue(val, false);
				}
				catch (Exception ex)
				{
					Plugin.LogError("Error (A) updating dead TTS UI location:\n" + ex);
					deadTTSElements.Remove(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(WorldSpaceUITTS), "Update")]
		[HarmonyPostfix]
		private static void UpdateUIPositionPostfix(WorldSpaceUITTS __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if (!deadTTSElements.Contains(__instance))
			{
				return;
			}
			try
			{
				PlayerAvatar val = (PlayerAvatar)playerAvatarField.GetValue(__instance);
				if (isDisabledStates.TryGetValue(val, out var value))
				{
					PlayerPatcher.isDisabledField.SetValue(val, value);
				}
			}
			catch (Exception ex)
			{
				Plugin.LogError("Error (B) updating dead TTS UI location:\n" + ex);
				deadTTSElements.Remove(__instance);
			}
		}
	}
	[HarmonyPatch]
	public static class PlayerPatcher
	{
		internal static PlayerAvatar localPlayer;

		internal static FieldInfo voiceChatField = typeof(PlayerAvatar).GetField("voiceChat", BindingFlags.Instance | BindingFlags.NonPublic);

		internal static FieldInfo isDisabledField = typeof(PlayerAvatar).GetField("isDisabled", BindingFlags.Instance | BindingFlags.NonPublic);

		internal static Dictionary<PlayerAvatar, float> deadPlayersVoicePitch = new Dictionary<PlayerAvatar, float>();

		internal static HashSet<PlayerAvatar> discoveredDeadPlayers = new HashSet<PlayerAvatar>();

		[HarmonyPatch(typeof(PlayerAvatar), "Awake")]
		[HarmonyPostfix]
		public static void InitPlayer(ref bool ___isLocal, PlayerAvatar __instance)
		{
			if (___isLocal)
			{
				localPlayer = __instance;
			}
		}

		[HarmonyPatch(typeof(RoundDirector), "StartRoundLogic")]
		[HarmonyPrefix]
		public static void RandomizeTTSPitch(int value, RoundDirector __instance)
		{
			int num = value;
			deadPlayersVoicePitch.Clear();
			for (int i = 0; i < GameDirector.instance.PlayerList.Count; i++)
			{
				PlayerAvatar val = GameDirector.instance.PlayerList[i];
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				float num2 = 1f;
				if (GameManager.Multiplayer() && value > 0)
				{
					int num3 = -1;
					int seed = -1;
					try
					{
						num3 = val.photonView.Owner.ActorNumber;
					}
					catch (Exception ex)
					{
						Plugin.LogWarning("Failed to get player id for player: " + ((Object)val).name + " when calculating random seed. Don't worry about this.");
						Plugin.LogWarningVerbose("Error: " + ex);
					}
					if (num3 != -1)
					{
						seed = num + num3;
						Random random = new Random(seed);
						float value2 = ConfigSettings.minRandomPitch.Value;
						float value3 = ConfigSettings.maxRandomPitch.Value;
						num2 = (float)(random.NextDouble() * (double)(value3 - value2) + (double)value2);
					}
					Plugin.LogWarningVerbose("BaseSeed: " + num + " PlayerId: " + num3 + " PlayerSeed: " + seed);
					if (deadPlayersVoicePitch.TryGetValue(val, out var value4) && num2 != value4)
					{
						Plugin.Log("Setting dead TTS pitch for player with id: " + num3 + " to: " + num2);
					}
				}
				deadPlayersVoicePitch[val] = num2;
			}
		}

		[HarmonyPatch(typeof(PlayerVoiceChat), "TtsFollowVoiceSettings")]
		[HarmonyPostfix]
		public static void OnTtsFollowVoiceSettings(ref PlayerAvatar ___playerAvatar, ref AudioLowPassLogic ___lowPassLogicTTS, ref bool ___inLobbyMixerTTS, ref float ___clipLoudnessTTS, PlayerVoiceChat __instance)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Invalid comparison between Unknown and I4
			if (!Object.op_Implicit((Object)(object)___playerAvatar) || !Object.op_Implicit((Object)(object)___playerAvatar.playerDeathHead) || !Object.op_Implicit((Object)(object)__instance.ttsAudioSource) || !Object.op_Implicit((Object)(object)__instance.ttsVoice) || !Object.op_Implicit((Object)(object)__instance.mixerTTSSound) || !GameManager.Multiplayer() || (int)GameDirector.instance.currentState < 2 || !((IsPlayerDead(___playerAvatar) && ((Behaviour)___playerAvatar.playerDeathHead).isActiveAndEnabled) & ___inLobbyMixerTTS) || (ConfigSettings.enableWhenDiscovered.Value && !discoveredDeadPlayers.Contains(___playerAvatar) && !IsLocalPlayerDead()))
			{
				return;
			}
			if ((Object)(object)__instance.ttsAudioSource.outputAudioMixerGroup != (Object)(object)__instance.mixerTTSSound)
			{
				Plugin.Log("The game has toggled ON lobby chat for player: " + ((Object)___playerAvatar).name + ". Disabling TTS lobby mixer.");
				__instance.ttsVoice.setVoice(1);
				__instance.ttsAudioSource.outputAudioMixerGroup = __instance.mixerTTSSound;
				__instance.ttsVoice.StopAndClearVoice();
			}
			float pitch = (deadPlayersVoicePitch.ContainsKey(___playerAvatar) ? deadPlayersVoicePitch[___playerAvatar] : 1f);
			__instance.ttsAudioSource.pitch = pitch;
			if ((!ConfigSettings.disableWhileDead.Value || !IsLocalPlayerDead()) && (Object)(object)___playerAvatar != (Object)(object)localPlayer)
			{
				__instance.ttsAudioSource.volume = ConfigSettings.deadTTSVolume.Value;
				if (ConfigSettings.deadTTSSpatialAudio.Value)
				{
					__instance.ttsAudioSource.spatialBlend = 1f;
				}
			}
			else
			{
				__instance.ttsAudioSource.volume = 1f;
			}
		}

		[HarmonyPatch(typeof(PlayerVoiceChat), "ToggleLobby")]
		[HarmonyPostfix]
		public static void OnToggleOffLobbyChat(bool _toggle, ref PlayerAvatar ___playerAvatar, PlayerVoiceChat __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)__instance.ttsAudioSource) && Object.op_Implicit((Object)(object)__instance.mixerTTSSound) && GameManager.Multiplayer() && (int)GameDirector.instance.currentState >= 2)
			{
				discoveredDeadPlayers.Remove(___playerAvatar);
				if (!_toggle)
				{
					Plugin.Log("The game has toggled OFF lobby chat for player: " + ((Object)___playerAvatar).name);
					__instance.ttsAudioSource.volume = 1f;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerVoiceChat), "LateUpdate")]
		[HarmonyPrefix]
		public static void MoveTTSAudioTransform(ref PlayerAvatar ___playerAvatar, ref bool ___inLobbyMixerTTS, PlayerVoiceChat __instance)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (LevelGenerator.Instance.Generated && Object.op_Implicit((Object)(object)___playerAvatar) && GameManager.Multiplayer() && (int)GameDirector.instance.currentState >= 2 && ___inLobbyMixerTTS && IsPlayerDead(___playerAvatar) && Object.op_Implicit((Object)(object)___playerAvatar.playerDeathHead) && Object.op_Implicit((Object)(object)__instance.ttsVoice))
			{
				((Component)__instance).transform.position = Vector3.Lerp(((Component)__instance).transform.position, ((Component)___playerAvatar.playerDeathHead).transform.position, 30f * Time.deltaTime);
			}
		}

		[HarmonyPatch(typeof(ValuableDiscover), "New")]
		[HarmonyPrefix]
		public static void UpdateUIPositionPostfix(PhysGrabObject _target, State _state)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			if ((int)_state == 2)
			{
				PlayerDeathHead component = ((Component)_target).GetComponent<PlayerDeathHead>();
				if (Object.op_Implicit((Object)(object)component))
				{
					discoveredDeadPlayers.Add(component.playerAvatar);
				}
			}
		}

		public static bool IsLocalPlayerDead()
		{
			return IsPlayerDead(PlayerAvatar.instance);
		}

		public static bool IsPlayerDead(PlayerAvatar playerAvatar)
		{
			if (!Object.op_Implicit((Object)(object)playerAvatar))
			{
				return false;
			}
			return (bool)isDisabledField.GetValue(playerAvatar);
		}
	}
}
namespace REPO_DeadTTS.Config
{
	[Serializable]
	public static class ConfigSettings
	{
		public static ConfigEntry<float> minRandomPitch;

		public static ConfigEntry<float> maxRandomPitch;

		public static ConfigEntry<float> deadTTSVolume;

		public static ConfigEntry<bool> displayDeadTTSText;

		public static ConfigEntry<bool> deadTTSSpatialAudio;

		public static ConfigEntry<bool> enableWhenDiscovered;

		public static ConfigEntry<bool> disableWhileDead;

		public static ConfigEntry<string> deadTTSColor;

		public static ConfigEntry<bool> verboseLogs;

		public static Dictionary<string, ConfigEntryBase> currentConfigEntries = new Dictionary<string, ConfigEntryBase>();

		internal static void BindConfigSettings()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Expected O, but got Unknown
			Plugin.Log("Binding Configs");
			minRandomPitch = AddConfigEntry<float>(((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("General", "Dead TTS Random Pitch Min", 0.65f, new ConfigDescription("The lower range limit when randomizing dead players pitch.\nValues will be clamped between 0.5 and 2.0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())));
			maxRandomPitch = AddConfigEntry<float>(((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("General", "Dead TTS Random Pitch Max", 1.5f, new ConfigDescription("The upper range limit when randomizing dead players pitch.\nValues will be clamped between 0.5 and 2.0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())));
			deadTTSVolume = AddConfigEntry<float>(((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("General", "Dead TTS Volume", 0.5f, new ConfigDescription("Affects the TTS volume of all dead players.\nSet to 0 to mute the TTS of dead players. If muted, the TTS text will still appear.\nValues will be clamped between 0.0 and 1.0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())));
			displayDeadTTSText = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "Display Dead TTS Text", true, "If true, TTS Text will appear from dead players' heads."));
			deadTTSSpatialAudio = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "Use Spatial Audio", true, "If true, TTS audio from dead players should be 3D directional.\nIf false, the audio should appear as if it's in your head all the time."));
			enableWhenDiscovered = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "Enable When Discovered", false, "If true, you will only head DeadTTS from players once their head is \"discovered\"."));
			disableWhileDead = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "Disable Spatial TTS While Dead", false, "This will only disable the (directional) DeadTTS for other dead players while you (the local player) are dead. Pitch will remain synced, however."));
			deadTTSColor = AddConfigEntry<string>(((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("General", "Dead TTS Text Color Hex", "CC3333", new ConfigDescription("Hex color value for dead TTS text color. Hex string must be 6 characters long.", (AcceptableValueBase)null, Array.Empty<object>())));
			verboseLogs = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "Verbose Logs", false, new ConfigDescription("Enables verbose logs. Useful for debugging.", (AcceptableValueBase)null, Array.Empty<object>())));
			if (minRandomPitch.Value < 0.5f)
			{
				minRandomPitch.Value = (float)((ConfigEntryBase)minRandomPitch).DefaultValue;
			}
			if (maxRandomPitch.Value > 2f)
			{
				maxRandomPitch.Value = (float)((ConfigEntryBase)maxRandomPitch).DefaultValue;
			}
			minRandomPitch.Value = Mathf.Clamp(minRandomPitch.Value, 0.5f, 2f);
			maxRandomPitch.Value = Mathf.Max(maxRandomPitch.Value, minRandomPitch.Value);
			deadTTSVolume.Value = Mathf.Clamp(deadTTSVolume.Value, 0f, 2f);
		}

		internal static ConfigEntry<T> AddConfigEntry<T>(ConfigEntry<T> configEntry)
		{
			currentConfigEntries.Add(((ConfigEntryBase)configEntry).Definition.Key, (ConfigEntryBase)(object)configEntry);
			return configEntry;
		}
	}
}

BeepInEx/plugins/GalaxyMods-MoreShopItems/MoreShopItems.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreShopItems.Compatability;
using MoreShopItems.Config;
using Photon.Pun;
using REPOLib.Modules;
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("MoreShopItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.9.0")]
[assembly: AssemblyInformationalVersion("1.2.9")]
[assembly: AssemblyProduct("More Shop Items")]
[assembly: AssemblyTitle("MoreShopItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.9.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MoreShopItems
{
	[BepInPlugin("MoreShopItems", "More Shop Items", "1.2.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("MoreShopItems");

		internal Dictionary<string, ConfigEntry<int>> intConfigEntries = new Dictionary<string, ConfigEntry<int>>();

		internal Dictionary<string, ConfigEntry<bool>> boolConfigEntries = new Dictionary<string, ConfigEntry<bool>>();

		internal static GameObject CustomItemShelf;

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Instance = CheckInstance();
			Logger = ((BaseUnityPlugin)this).Logger;
			LoadConfig();
			AssetBundle bundle = LoadAssetBundle("moreshopitems_assets.file");
			CustomItemShelf = LoadAssetFromBundle(bundle, "custom_soda_shelf");
			NetworkPrefabs.RegisterNetworkPrefab(CustomItemShelf);
			_harmony.PatchAll(typeof(ShopManagerPatch));
			Logger.LogInfo((object)"\n __  __               ___ _               ___ _                \n|  \\/  |___ _ _ ___  / __| |_  ___ _ __  |_ _| |_ ___ _ __  ___\n| |\\/| / _ \\ '_/ -_) \\__ \\ ' \\/ _ \\ '_ \\  | ||  _/ -_) '  \\(_-<\n|_|  |_\\___/_| \\___| |___/_||_\\___/ .__/ |___|\\__\\___|_|_|_/__/\n                                  |_|                    v1.2.9\n");
		}

		private Plugin CheckInstance()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				return this;
			}
			return Instance;
		}

		private void LoadConfig()
		{
			string[] configDescriptions = ConfigEntries.GetConfigDescriptions();
			intConfigEntries.Add("Max Upgrades In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Upgrades", "Max Upgrades In Shop", 5, configDescriptions[0], 0, 20));
			intConfigEntries.Add("Max Upgrade Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Upgrades", "Max Upgrade Purchase Amount", 0, configDescriptions[1], 0, 1000));
			intConfigEntries.Add("Max Melee Weapons In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Weapons", "Max Melee Weapons In Shop", 5, configDescriptions[2], 0, 20));
			intConfigEntries.Add("Max Melee Weapon Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Weapons", "Max Melee Weapon Purchase Amount", 0, configDescriptions[3], 0, 1000));
			intConfigEntries.Add("Max Guns In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Weapons", "Max Guns In Shop", 5, configDescriptions[4], 0, 20));
			intConfigEntries.Add("Max Gun Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Weapons", "Max Gun Purchase Amount", 0, configDescriptions[5], 0, 1000));
			intConfigEntries.Add("Max Grenades In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Weapons", "Max Grenades In Shop", 5, configDescriptions[6], 0, 20));
			intConfigEntries.Add("Max Grenade Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Weapons", "Max Grenade Purchase Amount", 0, configDescriptions[7], 0, 1000));
			intConfigEntries.Add("Max Mines In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Weapons", "Max Mines In Shop", 5, configDescriptions[8], 0, 20));
			intConfigEntries.Add("Max Mine Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Weapons", "Max Mine Purchase Amount", 0, configDescriptions[9], 0, 1000));
			intConfigEntries.Add("Max Health-Packs In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Health-Packs", "Max Health-Packs In Shop", 15, configDescriptions[10], 0, 20));
			intConfigEntries.Add("Max Health-Pack Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Health-Packs", "Max Health-Pack Purchase Amount", 0, configDescriptions[11], 0, 1000));
			intConfigEntries.Add("Max Drones In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Utilities", "Max Drones In Shop", 5, configDescriptions[12], 0, 20));
			intConfigEntries.Add("Max Drone Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Utilities", "Max Drone Purchase Amount", 0, configDescriptions[13], 0, 1000));
			intConfigEntries.Add("Max Orbs In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Utilities", "Max Orbs In Shop", 5, configDescriptions[14], 0, 20));
			intConfigEntries.Add("Max Orb Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Utilities", "Max Orb Purchase Amount", 0, configDescriptions[15], 0, 1000));
			intConfigEntries.Add("Max Crystals In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Utilities", "Max Crystals In Shop", 5, configDescriptions[16], 0, 20));
			intConfigEntries.Add("Max Crystal Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Utilities", "Max Crystal Purchase Amount", 0, configDescriptions[17], 0, 1000));
			intConfigEntries.Add("Max Trackers In Shop", ConfigHelper.CreateConfig<ConfigEntry<int>>("Utilities", "Max Trackers In Shop", 5, configDescriptions[18], 0, 20));
			intConfigEntries.Add("Max Tracker Purchase Amount", ConfigHelper.CreateConfig<ConfigEntry<int>>("Utilities", "Max Tracker Purchase Amount", 0, configDescriptions[19], 0, 1000));
			boolConfigEntries.Add("Override Modded Items", ConfigHelper.CreateConfig<ConfigEntry<bool>>("General", "Override Modded Items", true, configDescriptions[20], -1, -1));
			boolConfigEntries.Add("Override Single-Use Upgrades", ConfigHelper.CreateConfig<ConfigEntry<bool>>("General", "Override Single-Use Upgrades", false, configDescriptions[21], -1, -1));
		}

		private AssetBundle LoadAssetBundle(string filename)
		{
			return AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), filename));
		}

		private GameObject LoadAssetFromBundle(AssetBundle bundle, string name)
		{
			return bundle.LoadAsset<GameObject>(name);
		}
	}
	[HarmonyPatch(typeof(ShopManager))]
	internal static class ShopManagerPatch
	{
		private static readonly FieldRef<ShopManager, int> itemSpawnTargetAmount_ref = AccessTools.FieldRefAccess<ShopManager, int>("itemSpawnTargetAmount");

		private static readonly FieldRef<ShopManager, int> itemConsumablesAmount_ref = AccessTools.FieldRefAccess<ShopManager, int>("itemConsumablesAmount");

		private static readonly FieldRef<ShopManager, int> itemUpgradesAmount_ref = AccessTools.FieldRefAccess<ShopManager, int>("itemUpgradesAmount");

		private static readonly FieldRef<ShopManager, int> itemHealthPacksAmount_ref = AccessTools.FieldRefAccess<ShopManager, int>("itemHealthPacksAmount");

		private static GameObject shelf;

		internal static bool isMoreUpgrades = false;

		[HarmonyPrefix]
		[HarmonyPatch("Awake")]
		private static void SetValues(ShopManager __instance)
		{
			ref int reference = ref itemSpawnTargetAmount_ref.Invoke(__instance);
			ref int reference2 = ref itemConsumablesAmount_ref.Invoke(__instance);
			ref int reference3 = ref itemUpgradesAmount_ref.Invoke(__instance);
			ref int reference4 = ref itemHealthPacksAmount_ref.Invoke(__instance);
			reference = 250;
			reference2 = 100;
			reference3 = 50;
			reference4 = 50;
		}

		[HarmonyPrefix]
		[HarmonyPatch("ShopInitialize")]
		private static void SpawnShelf()
		{
			//IL_0079: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			if (!(RunManager.instance.levelCurrent.ResourcePath == "Shop"))
			{
				return;
			}
			GameObject val = GameObject.Find("Soda Shelf");
			GameObject val2 = GameObject.Find("Module Switch BOT");
			if ((Object)(object)val != (Object)null && !val2.GetComponent<ModulePropSwitch>().ConnectedParent.activeSelf)
			{
				if (!SemiFunc.IsMultiplayer())
				{
					shelf = Object.Instantiate<GameObject>(Plugin.CustomItemShelf, val.transform.position, val.transform.rotation, val2.transform);
				}
				else
				{
					if (!SemiFunc.IsMasterClient())
					{
						val.SetActive(false);
						return;
					}
					shelf = PhotonNetwork.Instantiate(((Object)Plugin.CustomItemShelf).name, val.transform.position, val.transform.rotation, (byte)0, (object[])null);
					SetParent(val2.transform, shelf);
				}
				val.SetActive(false);
			}
			else
			{
				GameObject val3 = GameObject.Find("Shop Magazine Stand (1)");
				GameObject val4 = GameObject.Find("Shop Magazine Stand");
				GameObject val5 = GameObject.Find("Module Switch (1) top");
				if ((Object)(object)val3 != (Object)null && !val5.GetComponent<ModulePropSwitch>().ConnectedParent.activeSelf)
				{
					if (!SemiFunc.IsMultiplayer())
					{
						shelf = Object.Instantiate<GameObject>(Plugin.CustomItemShelf, val3.transform.position, val3.transform.rotation * Quaternion.Euler(0f, 90f, 0f), val5.transform.parent);
					}
					else
					{
						if (!SemiFunc.IsMasterClient())
						{
							val3.SetActive(false);
							if ((Object)(object)val4 != (Object)null)
							{
								val4.SetActive(false);
							}
							return;
						}
						shelf = PhotonNetwork.Instantiate(((Object)Plugin.CustomItemShelf).name, val3.transform.position, val3.transform.rotation * Quaternion.Euler(0f, 90f, 0f), (byte)0, (object[])null);
						SetParent(val5.transform, shelf);
					}
					val3.SetActive(false);
					if ((Object)(object)val4 != (Object)null)
					{
						val4.SetActive(false);
					}
				}
				else
				{
					GameObject val6 = GameObject.Find("Module Switch (2) left");
					GameObject val7 = GameObject.Find("Candy Shelf");
					if (!((Object)(object)val6 != (Object)null) || val6.GetComponent<ModulePropSwitch>().ConnectedParent.activeSelf)
					{
						Plugin.Logger.LogInfo((object)"Edge case found. Temporarily preventing spawn of custom shelf.");
						return;
					}
					if (!SemiFunc.IsMultiplayer())
					{
						shelf = Object.Instantiate<GameObject>(Plugin.CustomItemShelf, val6.transform.position + val6.transform.right * 0.5f - val6.transform.forward * 0.8f, val6.transform.rotation * Quaternion.Euler(0f, 180f, 0f), val5.transform.parent);
					}
					else
					{
						if (!SemiFunc.IsMasterClient())
						{
							if ((Object)(object)val7 != (Object)null)
							{
								val7.SetActive(false);
							}
							return;
						}
						shelf = PhotonNetwork.Instantiate(((Object)Plugin.CustomItemShelf).name, val6.transform.position + val6.transform.right * 0.5f - val6.transform.forward * 0.8f, val6.transform.rotation * Quaternion.Euler(0f, 180f, 0f), (byte)0, (object[])null);
						SetParent(val6.transform, shelf);
					}
					if ((Object)(object)val7 != (Object)null)
					{
						val7.SetActive(false);
					}
				}
			}
			Plugin.Logger.LogInfo((object)"Successfully spawned the shelf!");
		}

		[HarmonyPrefix]
		[HarmonyPatch("ShopInitialize")]
		private static void AdjustItems()
		{
			//IL_0094: 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)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected I4, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Invalid comparison between Unknown and I4
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Invalid comparison between Unknown and I4
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Invalid comparison between Unknown and I4
			if (!(RunManager.instance.levelCurrent.ResourcePath == "Shop") || (Object)(object)StatsManager.instance == (Object)null || (!SemiFunc.IsMasterClient() && SemiFunc.IsMultiplayer()))
			{
				return;
			}
			Dictionary<string, ConfigEntry<int>> intConfigEntries = Plugin.Instance.intConfigEntries;
			Dictionary<string, ConfigEntry<bool>> boolConfigEntries = Plugin.Instance.boolConfigEntries;
			foreach (Item value in StatsManager.instance.itemDictionary.Values)
			{
				int maxInShop = 0;
				int maxPurchaseAmount = 0;
				itemType itemType = value.itemType;
				itemType val = itemType;
				switch ((int)val)
				{
				case 0:
					maxInShop = intConfigEntries["Max Drones In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Drone Purchase Amount"].Value;
					break;
				case 1:
					maxInShop = intConfigEntries["Max Orbs In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Orb Purchase Amount"].Value;
					break;
				case 3:
					maxInShop = intConfigEntries["Max Upgrades In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Upgrade Purchase Amount"].Value;
					break;
				case 5:
					maxInShop = intConfigEntries["Max Crystals In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Crystal Purchase Amount"].Value;
					break;
				case 6:
					maxInShop = intConfigEntries["Max Grenades In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Grenade Purchase Amount"].Value;
					break;
				case 7:
					maxInShop = intConfigEntries["Max Melee Weapons In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Melee Weapon Purchase Amount"].Value;
					break;
				case 8:
					maxInShop = intConfigEntries["Max Health-Packs In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Health-Pack Purchase Amount"].Value;
					break;
				case 9:
					maxInShop = intConfigEntries["Max Guns In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Gun Purchase Amount"].Value;
					break;
				case 10:
					maxInShop = intConfigEntries["Max Trackers In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Tracker Purchase Amount"].Value;
					break;
				case 11:
					maxInShop = intConfigEntries["Max Mines In Shop"].Value;
					maxPurchaseAmount = intConfigEntries["Max Mine Purchase Amount"].Value;
					break;
				default:
					maxInShop = 5;
					maxPurchaseAmount = 0;
					continue;
				case 4:
					break;
				}
				bool flag = (int)value.itemType == 3;
				if ((int)value.itemType == 2 || (int)value.itemType == 12)
				{
					continue;
				}
				if (boolConfigEntries["Override Modded Items"].Value)
				{
					if (boolConfigEntries["Override Single-Use Upgrades"].Value && flag)
					{
						Plugin.Logger.LogInfo((object)("Result M-SU-U: " + value.itemAssetName));
						SetItemValues(value, maxInShop, maxPurchaseAmount);
					}
					else if (value.maxPurchase)
					{
						if (!flag)
						{
							Plugin.Logger.LogInfo((object)("Result M-MP-I: " + value.itemAssetName));
							SetItemValues(value, maxInShop, maxPurchaseAmount);
						}
						Plugin.Logger.LogInfo((object)("Result M-MP-U-SKIPPED: " + value.itemAssetName));
					}
					else
					{
						Plugin.Logger.LogInfo((object)("Result M-NMP: " + value.itemAssetName));
						SetItemValues(value, maxInShop, maxPurchaseAmount);
					}
				}
				else if (!MoreUpgradesMOD.isLoaded() || !value.itemAssetName.Contains("Modded Item Upgrade Player"))
				{
					if (boolConfigEntries["Override Single-Use Upgrades"].Value && flag)
					{
						Plugin.Logger.LogInfo((object)("Result NM-SU-U: " + value.itemAssetName));
						SetItemValues(value, maxInShop, maxPurchaseAmount);
					}
					else if (flag && !value.maxPurchase)
					{
						Plugin.Logger.LogInfo((object)("Result NM-NMP-U: " + value.itemAssetName));
						SetItemValues(value, maxInShop, maxPurchaseAmount);
					}
					else if (!flag)
					{
						Plugin.Logger.LogInfo((object)("Result NM-NMP-I: " + value.itemAssetName));
						SetItemValues(value, maxInShop, maxPurchaseAmount);
					}
				}
			}
		}

		private static void SetItemValues(Item item, int maxInShop, int maxPurchaseAmount)
		{
			item.maxAmountInShop = (item.maxAmount = maxInShop);
			item.maxPurchase = maxPurchaseAmount > 0;
			item.maxPurchaseAmount = maxPurchaseAmount;
		}

		[PunRPC]
		public static void SetParent(Transform parent, GameObject gameObj)
		{
			gameObj.transform.SetParent(parent);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MoreShopItems";

		public const string PLUGIN_NAME = "More Shop Items";

		public const string PLUGIN_VERSION = "1.2.9";
	}
}
namespace MoreShopItems.Compatability
{
	internal class MoreUpgradesMOD
	{
		internal const string modGUID = "bulletbot.moreupgrades";

		public static bool isLoaded()
		{
			return Chainloader.PluginInfos.ContainsKey("bulletbot.moreupgrades");
		}
	}
}
namespace MoreShopItems.Constants
{
	public static class Values
	{
		public const int TargetSpawnAmount = 250;

		public const int UpgradesAmount = 50;

		public const int HealthPacksAmount = 50;

		public const int ConsumablesAmount = 100;
	}
}
namespace MoreShopItems.Config
{
	public static class ConfigEntries
	{
		private static string[] DESCRIPTIONS = new string[22]
		{
			"How many of each upgrade to spawn in the shop.", "How many upgrades you can purchase total. Set 0 to disable", "How many of each melee weapon to spawn in the shop.", "How many melee weapons you can purchase total. Set 0 to disable", "How many of each gun to spawn in the shop.", "How many guns you can purchase total. Set 0 to disable", "How many of each grenade to spawn in the shop.", "How many grenades you can purchase total. Set 0 to disable", "How many of each mine to spawn in the shop.", "How many mines you can purchase total. Set 0 to disable",
			"How many of each health-pack to spawn in the shop.", "How many health-packs you can purchase total. Set 0 to disable", "How many of each drone to spawn in the shop.", "How many drones you can purchase total. Set 0 to disable", "How many of each orb to spawn in the shop.", "How many orbs you can purchase total. Set 0 to disable", "How many of each crystal to spawn in the shop.", "How many crystals you can purchase total. Set 0 to disable", "How many trackers to spawn in the shop.", "How many trackers you can purchase total. Set 0 to disable",
			"Overrides the values (MaxAmountInShop, MaxPurchaseAmount) set by other item/upgrade mods.", "Overrides the values (MaxAmountInShop, MaxPurchaseAmount) of single-use upgrades."
		};

		public static string[] GetConfigDescriptions()
		{
			return DESCRIPTIONS;
		}
	}
	public class ConfigHelper
	{
		public static T CreateConfig<T>(string section, string name, object value, string desc, int min, int max)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			if (value is int)
			{
				return (T)(object)((BaseUnityPlugin)Plugin.Instance).Config.Bind<int>(section, name, (int)value, new ConfigDescription(desc, (AcceptableValueBase)(object)new AcceptableValueRange<int>(min, max), Array.Empty<object>()));
			}
			return (T)(object)((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>(section, name, (bool)value, new ConfigDescription(desc, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
}

BeepInEx/plugins/ironbean-LevelNumberUI/REPO Level Number.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("REPO Level Number")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPO Level Number")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c7ba60f1-eeaf-4c76-9c08-97cfec43b265")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace REPO_Level_Number;

[BepInPlugin("ironbean.LevelNumberHUD", "Level Number HUD", "1.0.0")]
public class LevelNumberHUD : BaseUnityPlugin
{
	[HarmonyPatch(typeof(GoalUI))]
	internal class GoalPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CustomPatch(ref TextMeshProUGUI ___Text)
		{
			if (!SemiFunc.RunIsShop())
			{
				int num = StatsManager.instance.runStats["level"] + 1;
				((TMP_Text)___Text).text = "<line-height=75%>" + ((TMP_Text)___Text).text + "\n<color=#ff9600><size=28>Level " + num + "</size></color></b>";
				((TMP_Text)___Text).alignment = (TextAlignmentOptions)260;
			}
		}
	}

	[HarmonyPatch(typeof(EnergyUI))]
	internal class EnergyPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CustomPatch(ref TextMeshProUGUI ___Text)
		{
			if (SemiFunc.RunIsShop())
			{
				int num = StatsManager.instance.runStats["level"] + 1;
				((TMP_Text)___Text).text = "<line-height=75%>" + ((TMP_Text)___Text).text + "\n<color=#ff9600><size=28>Level " + num + "</size></color></b>";
			}
		}
	}

	private const string modGUID = "ironbean.LevelNumberHUD";

	private const string modName = "Level Number HUD";

	private const string modVersion = "1.0.0";

	private readonly Harmony harmony = new Harmony("ironbean.LevelNumberHUD");

	internal static LevelNumberHUD Instance;

	internal static ManualLogSource mls;

	internal bool inShop = false;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("ironbean.LevelNumberHUD");
		mls.LogInfo((object)"Level Number HUD");
		harmony.PatchAll(typeof(LevelNumberHUD));
		harmony.PatchAll(typeof(GoalPatch));
		harmony.PatchAll(typeof(EnergyPatch));
	}
}

BeepInEx/plugins/JoshA-Weeping_Angel_Enemy/WeepingAngel.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.AI;

[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("Josh Aaron")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("WeepingAngel")]
[assembly: AssemblyTitle("WeepingAngel")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.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 me.joshaaron.mods.weepingangel
{
	public class EnemyAngel : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Idle,
			Roam,
			Investigate,
			SeekPlayer,
			Attack,
			Despawn,
			TargetPlayer
		}

		private PhotonView photonView;

		public Enemy enemy;

		public State currentState;

		internal bool attackImpulse = false;

		private bool stateImpulse = true;

		private float stateTimer;

		private Vector3 agentDestination = Vector3.zero;

		private Vector3 targetPosition = Vector3.zero;

		private PlayerAvatar targetPlayer;

		private float sightingTimer = 0f;

		public AudioSource sightingSoundSource;

		public AudioClip[] sightingSounds;

		public float angelFindDistance = 400f;

		public float angelCloseThreshold = 4f;

		private void Awake()
		{
			photonView = ((Component)this).GetComponent<PhotonView>();
		}

		private void Update()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Invalid comparison between Unknown and I4
			if (sightingTimer <= 0f && enemy.OnScreen.OnScreenLocal && enemy.PlayerDistance.PlayerDistanceLocal <= 10f)
			{
				PlaySightingAudio();
			}
			if (!enemy.OnScreen.OnScreenLocal)
			{
				sightingTimer -= Time.deltaTime;
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if ((int)enemy.CurrentState == 11 && !enemy.IsStunned())
				{
					UpdateState(State.Despawn);
				}
				if (enemy.OnScreen.OnScreenAny)
				{
					UpdateState(State.Idle);
				}
				switch (currentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Idle:
					StateIdle();
					break;
				case State.Roam:
					StateRoam();
					break;
				case State.Investigate:
					StateInvestigate();
					break;
				case State.TargetPlayer:
					MoveTowardPlayer();
					StateTargetPlayer();
					break;
				case State.SeekPlayer:
					StateSeekPlayer();
					break;
				case State.Attack:
					StateAttack();
					break;
				case State.Despawn:
					break;
				}
			}
		}

		private void PlaySightingAudio()
		{
			GameDirector.instance.CameraImpact.Shake(2f, 0.1f);
			GameDirector.instance.CameraShake.Shake(2f, 1f);
			sightingSoundSource.clip = sightingSounds[Random.Range(0, sightingSounds.Length)];
			sightingSoundSource.Play();
			sightingTimer = 20f;
		}

		public void StateSpawn()
		{
			if (stateImpulse)
			{
				stateTimer = 3f;
				stateImpulse = false;
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Idle);
			}
		}

		private void StateIdle()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (stateImpulse)
			{
				stateImpulse = false;
				stateTimer = 0.5f;
				enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position);
				enemy.NavMeshAgent.ResetPath();
			}
			if (!SemiFunc.EnemySpawnIdlePause() && !enemy.OnScreen.OnScreenAny)
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Roam);
				}
			}
		}

		private void StateRoam()
		{
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			if (stateImpulse)
			{
				float num = 999f;
				PlayerAvatar val = null;
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					float num2 = Vector3.Distance(enemy.PlayerDistance.CheckTransform.position, player.PlayerVisionTarget.VisionTransform.position);
					if (!player.isDisabled && num2 < num && num2 <= angelFindDistance)
					{
						num = num2;
						val = player;
					}
				}
				enemy.NavMeshAgent.ResetPath();
				enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position);
				stateImpulse = false;
				stateTimer = 5f;
				LevelPoint val2 = ((!((Object)(object)val == (Object)null) && !val.isDisabled) ? SemiFunc.LevelPointGet(val.playerTransform.position, 5f, 15f) : SemiFunc.LevelPointGet(((Component)this).transform.position, 5f, 15f));
				if (!Object.op_Implicit((Object)(object)val2))
				{
					val2 = ((!((Object)(object)val == (Object)null) && !val.isDisabled) ? SemiFunc.LevelPointGet(val.playerTransform.position, 0f, 999f) : SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f));
				}
				NavMeshHit val3 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val2) && NavMesh.SamplePosition(((Component)val2).transform.position + Random.insideUnitSphere * 3f, ref val3, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val3)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					agentDestination = ((NavMeshHit)(ref val3)).position;
				}
			}
			enemy.NavMeshAgent.SetDestination(agentDestination);
			if (enemy.Rigidbody.notMovingTimer > 1f)
			{
				stateTimer -= Time.deltaTime;
			}
			if (stateTimer <= 0f)
			{
				UpdateState(State.Idle);
			}
			else if (Vector3.Distance(((Component)this).transform.position, agentDestination) < 2f)
			{
				UpdateState(State.Idle);
			}
		}

		private void StateInvestigate()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			if (stateImpulse)
			{
				stateTimer = 5f;
				enemy.Rigidbody.notMovingTimer = 0f;
				stateImpulse = false;
				return;
			}
			enemy.NavMeshAgent.SetDestination(agentDestination);
			if (enemy.Rigidbody.notMovingTimer > 2f)
			{
				stateTimer -= Time.deltaTime;
			}
			if (stateTimer <= 0f)
			{
				UpdateState(State.Idle);
			}
			else if (Vector3.Distance(((Component)this).transform.position, agentDestination) < 2f)
			{
				UpdateState(State.Idle);
			}
		}

		private void StateTargetPlayer()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (stateImpulse)
			{
				stateTimer = 2f;
				stateImpulse = false;
			}
			enemy.Rigidbody.OverrideFollowPosition(0.2f, 5f, 30f);
			if (Vector3.Distance(enemy.CenterTransform.position, ((Component)targetPlayer).transform.position) < 2f)
			{
				UpdateState(State.Attack);
				return;
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.SeekPlayer);
			}
			else if (enemy.Rigidbody.notMovingTimer > 3f)
			{
				enemy.Vision.DisableVision(2f);
				UpdateState(State.SeekPlayer);
			}
		}

		private void StateSeekPlayer()
		{
			//IL_00a9: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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)
			//IL_0047: 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_00ee: 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)
			if (stateImpulse)
			{
				stateTimer = 20f;
				stateImpulse = false;
				LevelPoint levelPointAhead = enemy.GetLevelPointAhead(targetPosition);
				if (Object.op_Implicit((Object)(object)levelPointAhead))
				{
					targetPosition = ((Component)levelPointAhead).transform.position;
				}
				enemy.Rigidbody.notMovingTimer = 0f;
			}
			enemy.NavMeshAgent.OverrideAgent(3f, 3f, 0.2f);
			enemy.Rigidbody.OverrideFollowPosition(0.2f, 3f, -1f);
			if (Vector3.Distance(((Component)this).transform.position, targetPosition) < 2f)
			{
				LevelPoint levelPointAhead2 = enemy.GetLevelPointAhead(targetPosition);
				if (Object.op_Implicit((Object)(object)levelPointAhead2))
				{
					targetPosition = ((Component)levelPointAhead2).transform.position;
				}
			}
			if (enemy.Rigidbody.notMovingTimer >= 3f)
			{
				UpdateState(State.Idle);
				return;
			}
			enemy.NavMeshAgent.SetDestination(targetPosition);
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f || enemy.Rigidbody.notMovingTimer > 3f)
			{
				UpdateState(State.Roam);
			}
		}

		private void MoveTowardPlayer()
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!enemy.OnScreen.OnScreenAny)
			{
				targetPosition = ((Component)targetPlayer).transform.position;
				enemy.NavMeshAgent.SetDestination(targetPosition);
			}
		}

		private void StateAttack()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (stateImpulse)
			{
				attackImpulse = true;
				if (GameManager.Multiplayer())
				{
					photonView.RPC("AttackImpulseRPC", (RpcTarget)1, Array.Empty<object>());
				}
				enemy.NavMeshAgent.ResetPath();
				enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position);
				stateTimer = 2f;
				stateImpulse = false;
			}
			else
			{
				enemy.NavMeshAgent.Stop(0.2f);
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.SeekPlayer);
				}
			}
		}

		[PunRPC]
		private void AttackImpulseRPC()
		{
			attackImpulse = true;
		}

		private void UpdateState(State _state)
		{
			if (currentState != _state)
			{
				enemy.Rigidbody.notMovingTimer = 0f;
				currentState = _state;
				stateImpulse = true;
				stateTimer = 0f;
				if (GameManager.Multiplayer())
				{
					photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
				}
				else
				{
					UpdateStateRPC(currentState);
				}
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			currentState = _state;
		}

		[PunRPC]
		private void TargetPlayerRPC(int _playerID)
		{
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (player.photonView.ViewID == _playerID)
				{
					targetPlayer = player;
				}
			}
		}

		public void OnSpawn()
		{
			Debug.Log((object)"Angel Spawned");
			if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(enemy))
			{
				UpdateState(State.Spawn);
			}
		}

		public void OnHurt()
		{
		}

		public void OnDeath()
		{
		}

		public void OnVision()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)enemy.CurrentState == 11)
			{
				return;
			}
			State state = currentState;
			if ((uint)(state - 1) <= 3u)
			{
				targetPlayer = enemy.Vision.onVisionTriggeredPlayer;
				UpdateState(State.TargetPlayer);
				if (GameManager.Multiplayer())
				{
					photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { targetPlayer.photonView.ViewID });
				}
			}
			else if (currentState == State.TargetPlayer && (Object)(object)targetPlayer == (Object)(object)enemy.Vision.onVisionTriggeredPlayer)
			{
				stateTimer = Mathf.Max(stateTimer, 1f);
			}
		}

		public void OnInvestigate()
		{
			//IL_0032: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				State state = currentState;
				if ((uint)(state - 1) <= 2u)
				{
					agentDestination = enemy.StateInvestigate.onInvestigateTriggeredPosition;
					UpdateState(State.Investigate);
				}
				else if (currentState == State.SeekPlayer)
				{
					targetPosition = enemy.StateInvestigate.onInvestigateTriggeredPosition;
				}
			}
		}

		public void OnGrabbed()
		{
		}
	}
	public class EnemyAngelAnim : MonoBehaviour
	{
		public EnemyAngel controller;

		internal Animator animator;

		private void Awake()
		{
			animator = ((Component)this).GetComponent<Animator>();
			animator.keepAnimatorStateOnDisable = true;
		}

		private void Update()
		{
			if (controller.attackImpulse)
			{
				controller.attackImpulse = false;
				animator.SetTrigger("Attack");
			}
			if (!controller.enemy.OnScreen.OnScreenAny)
			{
				animator.SetBool("IsClose", controller.enemy.PlayerDistance.PlayerDistanceClosest <= controller.angelCloseThreshold);
			}
		}
	}
	[BepInPlugin("WeepingAngel", "WeepingAngel", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
		}

		internal void Patch()
		{
			//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)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Logger.LogInfo((object)"Patching Weeping Angel Enemy...");
			LoadAssets();
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private static void LoadAssets()
		{
			AssetBundle val = LoadAssetBundle("angel");
			Logger.LogInfo((object)"Loading Weeping Angel enemy setup...");
			EnemySetup val2 = val.LoadAsset<EnemySetup>("Assets/REPO/Mods/plugins/WeepingAngel/Enemy - Angel.asset");
			Enemies.RegisterEnemy(val2);
			Logger.LogDebug((object)"Loaded Angel enemy!");
		}

		public static AssetBundle LoadAssetBundle(string name)
		{
			Logger.LogDebug((object)("Loading Asset Bundle: " + name));
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, name);
			return AssetBundle.LoadFromFile(text);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "WeepingAngel";

		public const string PLUGIN_NAME = "WeepingAngel";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}

BeepInEx/plugins/Kistras-CustomDiscoverStateLib/Kistras-CustomDiscoverStateLib.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Kistras-CustomDiscoverStateLib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomDiscoverStateLib")]
[assembly: AssemblyTitle("Kistras-CustomDiscoverStateLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CustomDiscoverStateLib
{
	[BepInPlugin("Kistras-CustomDiscoverStateLib", "CustomDiscoverStateLib", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private readonly Harmony harmony = new Harmony("Kistras-CustomDiscoverStateLib");

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll(typeof(Patches));
			Logger.LogInfo((object)"Plugin Kistras-CustomDiscoverStateLib is loaded!");
		}
	}
	public static class CustomDiscoverState
	{
		public class CustomDiscoverGraphic
		{
			public Color ColorMiddle;

			public Color ColorCorner;
		}

		internal static Dictionary<State, CustomDiscoverGraphic> customStates = new Dictionary<State, CustomDiscoverGraphic>();

		private static int lastAddedIndex = 260;

		public static State AddNewDiscoverGraphic(Color middle, Color corner)
		{
			//IL_0006: 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_001f: 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_0026: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			State val = (State)lastAddedIndex;
			lastAddedIndex++;
			customStates[val] = new CustomDiscoverGraphic
			{
				ColorMiddle = middle,
				ColorCorner = corner
			};
			return val;
		}
	}
	[HarmonyPatch]
	internal class Patches
	{
		[HarmonyPatch(typeof(ValuableDiscover), "New")]
		[HarmonyPrefix]
		public static bool ValuableDiscoverPatch(ValuableDiscover __instance, PhysGrabObject _target, State _state)
		{
			//IL_0006: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0093: 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)
			if (!CustomDiscoverState.customStates.TryGetValue(_state, out var value))
			{
				return true;
			}
			ValuableDiscoverGraphic component = Object.Instantiate<GameObject>(__instance.graphicPrefab, ((Component)__instance).transform).GetComponent<ValuableDiscoverGraphic>();
			component.target = _target;
			component.state = _state;
			((Graphic)((Component)component.middle).GetComponent<Image>()).color = value.ColorMiddle;
			((Graphic)((Component)component.topLeft).GetComponent<Image>()).color = value.ColorCorner;
			((Graphic)((Component)component.topRight).GetComponent<Image>()).color = value.ColorCorner;
			((Graphic)((Component)component.botLeft).GetComponent<Image>()).color = value.ColorCorner;
			((Graphic)((Component)component.botRight).GetComponent<Image>()).color = value.ColorCorner;
			return false;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Kistras-CustomDiscoverStateLib";

		public const string PLUGIN_NAME = "CustomDiscoverStateLib";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

BeepInEx/plugins/Kistras-Valuables_Scanner/Kistras-Scanner.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;

[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("Kistras-Scanner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+6cedc3cabbc3a5e2c6bb99e6f98d9759e86ad5eb")]
[assembly: AssemblyProduct("REPO Scanner")]
[assembly: AssemblyTitle("Kistras-Scanner")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace REPO_Scanner
{
	public static class ConfigManager
	{
		public static InputKey scanKey = (InputKey)327;

		public static ConfigEntry<KeyCode> keyBind;

		public static ConfigEntry<float> scanRadius;

		public static ConfigEntry<float> cooldown;

		public static ConfigEntry<bool> multiplayerReveal;

		public static ConfigEntry<bool> toCreateGUI;

		public static ConfigEntry<bool> shouldScanValuables;

		public static ConfigEntry<bool> shouldScanEnemies;

		public static ConfigEntry<bool> shouldScanHeads;

		public static ConfigEntry<bool> shouldScanItems;

		private static KeyCode storedKeybind;

		private static bool initialized = false;

		internal static void Initialize(Plugin plugin)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			if (!initialized)
			{
				initialized = true;
				keyBind = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("Keybinds", "Scanner Key", (KeyCode)102, new ConfigDescription("What you press to scan things", (AcceptableValueBase)null, Array.Empty<object>()));
				scanRadius = ((BaseUnityPlugin)plugin).Config.Bind<float>("Options", "Scan Radius", 10f, new ConfigDescription("Radius of the scanner", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 100f), Array.Empty<object>()));
				cooldown = ((BaseUnityPlugin)plugin).Config.Bind<float>("Options", "Cooldown", 10f, new ConfigDescription("Interval between scans", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>()));
				multiplayerReveal = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Options", "Multiplayer RPC", true, new ConfigDescription("Whether to reveal scan results on other players' minimaps in multiplayer", (AcceptableValueBase)null, Array.Empty<object>()));
				toCreateGUI = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Options", "Create GUI", true, new ConfigDescription("Whether to create cooldown GUI", (AcceptableValueBase)null, Array.Empty<object>()));
				shouldScanValuables = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Features", "Valuables", true, new ConfigDescription("Whether to scan valuables", (AcceptableValueBase)null, Array.Empty<object>()));
				shouldScanEnemies = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Features", "Enemies", true, new ConfigDescription("Whether to scan enemies", (AcceptableValueBase)null, Array.Empty<object>()));
				shouldScanHeads = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Features", "Heads", true, new ConfigDescription("Whether to scan dead player's heads", (AcceptableValueBase)null, Array.Empty<object>()));
				shouldScanItems = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Features", "Items", true, new ConfigDescription("Whether to scan equippable items", (AcceptableValueBase)null, Array.Empty<object>()));
				keyBind.SettingChanged += delegate
				{
					RebindScan();
				};
			}
		}

		internal static void RebindScan()
		{
			//IL_000d: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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)
			ConfigEntry<KeyCode> obj = keyBind;
			if (obj != null)
			{
				_ = obj.Value;
				if (0 == 0 && !((Object)(object)InputManager.instance == (Object)null) && storedKeybind != keyBind.Value)
				{
					storedKeybind = keyBind.Value;
					string text = KeyCodeToBindingPath(keyBind.Value);
					Plugin.Logger.LogInfo((object)("Keybind changed to: " + text));
					InputManager.instance.Rebind(scanKey, text);
				}
			}
		}

		internal static string KeyCodeToBindingPath(KeyCode keyCode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Invalid comparison between Unknown and I4
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_00a9: 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_00b5: Expected I4, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Invalid comparison between Unknown and I4
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Invalid comparison between Unknown and I4
			if ((int)keyCode >= 48 && (int)keyCode <= 57)
			{
				return "<keyboard>/" + ((object)(KeyCode)(ref keyCode)).ToString().Replace("Alpha", "");
			}
			if ((int)keyCode == 323)
			{
				return "<mouse>/leftButton";
			}
			if ((int)keyCode == 324)
			{
				return "<mouse>/rightButton";
			}
			if ((int)keyCode == 325)
			{
				return "<mouse>/middleButton";
			}
			if ((int)keyCode >= 326 && (int)keyCode <= 329)
			{
				return $"<mouse>/button{keyCode - 323}";
			}
			KeyCode val = keyCode;
			KeyCode val2 = val;
			if ((int)val2 != 13)
			{
				if ((int)val2 != 305)
				{
					if ((int)val2 == 306)
					{
						return "<keyboard>/leftCtrl";
					}
					string text = ((object)(KeyCode)(ref keyCode)).ToString();
					if (text.Length > 0)
					{
						string text2 = char.ToLower(text[0]).ToString();
						string text3 = text;
						text = text2 + text3.Substring(1, text3.Length - 1);
					}
					return "<keyboard>/" + text;
				}
				return "<keyboard>/rightCtrl";
			}
			return "<keyboard>/enter";
		}
	}
	[HarmonyPatch]
	public class Patches
	{
		private static float lastGuiCheckTime;

		[HarmonyPatch(typeof(InputManager), "InitializeInputs")]
		[HarmonyPostfix]
		private static void InputManagerInitializeInputsPostfix(InputManager __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Plugin.Logger.LogInfo((object)"Setting up scan input action...");
				if (!InputManager.instance.inputActions.ContainsKey(ConfigManager.scanKey))
				{
					InputAction val = new InputAction("Scan", (InputActionType)0, ConfigManager.KeyCodeToBindingPath(ConfigManager.keyBind.Value), (string)null, (string)null, (string)null);
					InputManager.instance.inputActions.Add(ConfigManager.scanKey, val);
					val.Enable();
					Plugin.Logger.LogInfo((object)"Added scan input action");
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("Error in InputManagerInitializeInputsPostfix: " + ex.Message));
			}
		}

		[HarmonyPatch(typeof(PlayerController), "Update")]
		[HarmonyPostfix]
		private static void PlayerControllerUpdatePostfix()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Scanner.Update();
			if (SemiFunc.InputDown(ConfigManager.scanKey))
			{
				Scanner.Scan();
			}
			EnsureScannerGUIExists();
		}

		[HarmonyPatch(typeof(PlayerController), "Start")]
		[HarmonyPostfix]
		private static void PlayerControllerStartPostfix()
		{
			ConfigManager.RebindScan();
		}

		private static void EnsureScannerGUIExists()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			if (!(Time.time - lastGuiCheckTime < 10f))
			{
				lastGuiCheckTime = Time.time;
				if (!((Object)(object)ScannerGUI.Instance != (Object)null) && !((Object)(object)PlayerController.instance == (Object)null))
				{
					GameObject val = new GameObject("ScannerGUI");
					val.AddComponent<ScannerGUI>();
					Object.DontDestroyOnLoad((Object)(object)val);
				}
			}
		}
	}
	[BepInPlugin("Kistras-Scanner", "REPO Scanner", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private readonly Harmony harmony = new Harmony("Kistras-Scanner");

		internal static bool isCustomDiscoverStateLibLoaded;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			ConfigManager.Initialize(this);
			harmony.PatchAll(typeof(Patches));
			Logger.LogInfo((object)$"Patched {harmony.GetPatchedMethods().Count()} methods!");
			isCustomDiscoverStateLibLoaded = Chainloader.PluginInfos.ContainsKey("Kistras-CustomDiscoverStateLib");
			if (!isCustomDiscoverStateLibLoaded)
			{
				Logger.LogInfo((object)"CustomDiscoverStateLib is not loaded. Will fallback to \"Reminder\" graphic. Consider installing all dependencies.");
			}
			Logger.LogInfo((object)"Plugin Kistras-Scanner is loaded!");
		}
	}
	public class Scanner
	{
		private const State DiscoverValuableState = 0;

		private const State DiscoverEnemyState = 2;

		private static State DiscoverHeadState = NewCustomState(new Color(1f, 0f, 0.067f, 0.059f), new Color(1f, 0.1f, 0.067f, 0.59f));

		private static State DiscoverItemState = NewCustomState(new Color(0f, 0.5f, 0.8f, 0.075f), new Color(0.1f, 0.6f, 0.9f, 0.75f));

		private static float lastScanTime;

		private static bool isInitialized = false;

		private static State NewCustomState(Color middle, Color corner)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.isCustomDiscoverStateLibLoaded)
			{
				try
				{
					Type type = AccessTools.TypeByName("CustomDiscoverStateLib.CustomDiscoverState");
					if (type != null)
					{
						MethodInfo methodInfo = AccessTools.Method(type, "AddNewDiscoverGraphic", (Type[])null, (Type[])null);
						if (methodInfo != null)
						{
							return (State)methodInfo.Invoke(null, new object[2] { middle, corner });
						}
					}
				}
				catch (Exception ex)
				{
					Plugin.Logger.LogError((object)("Error accessing CustomDiscoverState: " + ex.Message));
				}
			}
			return (State)1;
		}

		private static void Initialize()
		{
			if (!isInitialized)
			{
				lastScanTime = ConfigManager.cooldown.Value;
				isInitialized = true;
				Plugin.Logger.LogInfo((object)"Scanner initialized successfully");
			}
		}

		public static void Scan()
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: 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)
			if (Time.time - lastScanTime < ConfigManager.cooldown.Value)
			{
				return;
			}
			if ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated || SemiFunc.MenuLevel())
			{
				Plugin.Logger.LogInfo((object)"Cannot scan: No level loaded.");
				return;
			}
			if (!isInitialized)
			{
				Initialize();
			}
			PlayerController instance = PlayerController.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)Camera.main == (Object)null)
			{
				Plugin.Logger.LogError((object)"Cannot scan: Player camera not found.");
				return;
			}
			Vector3 position = ((Component)Camera.main).transform.position;
			Collider[] array = Physics.OverlapSphere(position, ConfigManager.scanRadius.Value);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).transform == (Object)null)
				{
					continue;
				}
				if (ConfigManager.shouldScanValuables.Value)
				{
					ValuableObject val2 = ((Component)val).GetComponentInParent<ValuableObject>() ?? ((Component)val).GetComponentInChildren<ValuableObject>();
					if ((Object)(object)val2 != (Object)null)
					{
						if (ConfigManager.multiplayerReveal.Value)
						{
							val2.Discover((State)0);
						}
						else
						{
							ValuableDiscover.instance.New(val2.physGrabObject, (State)0);
						}
						continue;
					}
				}
				if (ConfigManager.shouldScanEnemies.Value)
				{
					EnemyRigidbody val3 = ((Component)val).GetComponentInParent<EnemyRigidbody>() ?? ((Component)val).GetComponentInChildren<EnemyRigidbody>();
					if ((Object)(object)val3 != (Object)null)
					{
						ValuableDiscover.instance.New(val3.physGrabObject, (State)2);
						continue;
					}
				}
				if (ConfigManager.shouldScanHeads.Value)
				{
					PlayerDeathHead val4 = ((Component)val).GetComponentInParent<PlayerDeathHead>() ?? ((Component)val).GetComponentInChildren<PlayerDeathHead>();
					if ((Object)(object)val4 != (Object)null)
					{
						ValuableDiscover.instance.New(val4.physGrabObject, DiscoverHeadState);
						continue;
					}
				}
				if (ConfigManager.shouldScanItems.Value)
				{
					ItemAttributes val5 = ((Component)val).GetComponentInParent<ItemAttributes>() ?? ((Component)val).GetComponentInChildren<ItemAttributes>();
					if ((Object)(object)val5 != (Object)null)
					{
						ValuableDiscover.instance.New(val5.physGrabObject, DiscoverItemState);
					}
				}
			}
			lastScanTime = Time.time;
			if ((Object)(object)ScannerGUI.Instance != (Object)null)
			{
				ScannerGUI.Instance.NotifyScan();
			}
		}

		public static void Update()
		{
		}

		public static bool IsOnCooldown()
		{
			return Time.time - lastScanTime < ConfigManager.cooldown.Value;
		}

		public static float GetRemainingCooldown()
		{
			return Mathf.Max(0f, ConfigManager.cooldown.Value - (Time.time - lastScanTime));
		}
	}
	public class ScannerGUI : MonoBehaviour
	{
		private Texture2D barTexture;

		private Texture2D backgroundTexture;

		private readonly float barWidth = 400f;

		private readonly float barHeight = 15f;

		private float lastDisplayTime;

		private readonly float displayDuration = 3f;

		private readonly Color barColor = new Color(1f, 0.6f, 0.1f, 0.8f);

		private readonly Color readyColor = new Color(1f, 0.8f, 0.2f, 0.8f);

		public static ScannerGUI Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			Initialize();
		}

		private void Initialize()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			lastDisplayTime = ConfigManager.cooldown.Value;
			barTexture = new Texture2D(1, 1);
			barTexture.SetPixel(0, 0, Color.white);
			barTexture.Apply();
			backgroundTexture = new Texture2D(1, 1);
			backgroundTexture.SetPixel(0, 0, Color.white);
			backgroundTexture.Apply();
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			if ((Object)(object)barTexture != (Object)null)
			{
				Object.Destroy((Object)(object)barTexture);
			}
			if ((Object)(object)backgroundTexture != (Object)null)
			{
				Object.Destroy((Object)(object)backgroundTexture);
			}
		}

		private void OnGUI()
		{
			//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_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			if (!ShouldShowGUI())
			{
				return;
			}
			float remainingCooldown = Scanner.GetRemainingCooldown();
			float num = remainingCooldown / ConfigManager.cooldown.Value;
			bool flag = Scanner.IsOnCooldown();
			float num2;
			if (flag)
			{
				num2 = 1f;
				lastDisplayTime = Time.time;
			}
			else
			{
				float num3 = Time.time - lastDisplayTime;
				num2 = Mathf.Clamp01(1f - num3 / displayDuration);
			}
			if (!(num2 <= 0.01f))
			{
				float num4 = ((float)Screen.width - barWidth) / 2f;
				float num5 = 30f;
				GUI.color = new Color(0.2f, 0.2f, 0.2f, 0.6f * num2);
				GUI.DrawTexture(new Rect(num4, num5, barWidth, barHeight), (Texture)(object)backgroundTexture);
				if (flag)
				{
					GUI.color = new Color(barColor.r, barColor.g, barColor.b, barColor.a * num2);
					GUI.DrawTexture(new Rect(num4, num5, barWidth * (1f - num), barHeight), (Texture)(object)barTexture);
				}
				else
				{
					GUI.color = new Color(readyColor.r, readyColor.g, readyColor.b, readyColor.a * num2);
					GUI.DrawTexture(new Rect(num4, num5, barWidth, barHeight), (Texture)(object)barTexture);
				}
				GUI.color = Color.white;
				GUIStyle val = new GUIStyle(GUI.skin.label);
				val.font = GUI.skin.font;
				val.fontSize = 14;
				val.alignment = (TextAnchor)4;
				val.fontStyle = (FontStyle)1;
				val.normal.textColor = new Color(1f, 1f, 1f, num2);
				string text = (flag ? $"Scanner: {remainingCooldown:F1}s" : "Scanner Ready");
				GUI.Label(new Rect(num4, num5 + barHeight + 5f, barWidth, 20f), text, val);
			}
		}

		private bool ShouldShowGUI()
		{
			return ConfigManager.toCreateGUI.Value && (Object)(object)PlayerController.instance != (Object)null && (Object)(object)LevelGenerator.Instance != (Object)null && LevelGenerator.Instance.Generated && !SemiFunc.MenuLevel();
		}

		public void NotifyScan()
		{
			lastDisplayTime = Time.time;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Kistras-Scanner";

		public const string PLUGIN_NAME = "REPO Scanner";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}

BeepInEx/plugins/Lazarus-BetterTruckHeals/BetterTruckHeals.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BetterTruckHeals")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterTruckHeals")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("819aea69-b910-4066-83d4-ca334402331c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterTruckHeals;

[BepInPlugin("Lazarus.BetterTruckHeals", "Better Truck Heals", "1.0.0")]
public class BetterTruckHeals : BaseUnityPlugin
{
	[HarmonyPatch(typeof(PlayerAvatar), "FinalHealRPC")]
	public class PlayerAvatarPatch
	{
		private static readonly FieldInfo FinalHealField = typeof(PlayerAvatar).GetField("finalHeal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo IsLocalField = typeof(PlayerAvatar).GetField("isLocal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo PlayerNameField = typeof(PlayerAvatar).GetField("playerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		[HarmonyPrefix]
		private static bool Prefix(PlayerAvatar __instance)
		{
			if (FinalHealField == null || IsLocalField == null || PlayerNameField == null)
			{
				ModLogger.LogError((object)"Failed to reflect fields in PlayerAvatar. Check assembly reference.");
				return true;
			}
			if ((bool)FinalHealField.GetValue(__instance))
			{
				return true;
			}
			if ((bool)IsLocalField.GetValue(__instance))
			{
				int value = HealAmountConfig.Value;
				string text = (string)PlayerNameField.GetValue(__instance);
				ModLogger.LogInfo((object)$"Applying custom heal amount: {value} for player: {text}");
				__instance.playerHealth.EyeMaterialOverride((EyeOverrideState)2, 2f, 1);
				TruckScreenText.instance.MessageSendCustom("", text + " {arrowright}{truck}{check}\n {point}{shades}{pointright}<b><color=#00FF00>+" + value + "</color></b>{heart}", 0);
				__instance.playerHealth.Heal(value, true);
				FinalHealField.SetValue(__instance, true);
			}
			return false;
		}

		[HarmonyPostfix]
		private static void Postfix(PlayerAvatar __instance)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			TruckHealer.instance.Heal(__instance);
			__instance.truckReturn.Play(__instance.PlayerVisionTarget.VisionTransform.position, 1f, 1f, 1f, 1f);
			__instance.truckReturnGlobal.Play(__instance.PlayerVisionTarget.VisionTransform.position, 1f, 1f, 1f, 1f);
			((Component)__instance.playerAvatarVisuals.effectGetIntoTruck).gameObject.SetActive(true);
		}
	}

	private const string PluginGUID = "Lazarus.BetterTruckHeals";

	private const string PluginName = "Better Truck Heals";

	private const string PluginVersion = "1.0.0";

	public static ConfigEntry<int> HealAmountConfig;

	internal static ManualLogSource ModLogger;

	private void Awake()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Expected O, but got Unknown
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"John 11:11!");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"WAKEY WAKEY!");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"BetterTruckHeals has risen!");
		HealAmountConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General", "HealAmount", 50, new ConfigDescription("The amount of health the truck healer restores to the player.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
		ModLogger = ((BaseUnityPlugin)this).Logger;
		ModLogger.LogInfo((object)string.Format("{0} v{1} is loading with heal amount: {2}", "Better Truck Heals", "1.0.0", HealAmountConfig.Value));
		Harmony val = new Harmony("Lazarus.BetterTruckHeals");
		val.PatchAll();
		ModLogger.LogInfo((object)"Harmony patches applied successfully!");
	}
}

BeepInEx/plugins/loaforc-loaforcsSoundAPI/loaforcsSoundAPI/me.loaforc.soundapi.dll

Decompiled 2 weeks ago
using System;
using System.Buffers;
using System.Collections.Concurrent;
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 System.Text;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using loaforcsSoundAPI.Core;
using loaforcsSoundAPI.Core.Data;
using loaforcsSoundAPI.Core.JSON;
using loaforcsSoundAPI.Core.Networking;
using loaforcsSoundAPI.Core.Patches;
using loaforcsSoundAPI.Core.Util;
using loaforcsSoundAPI.Core.Util.Extensions;
using loaforcsSoundAPI.Reporting;
using loaforcsSoundAPI.Reporting.Data;
using loaforcsSoundAPI.SoundPacks;
using loaforcsSoundAPI.SoundPacks.Data;
using loaforcsSoundAPI.SoundPacks.Data.Conditions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("me.loaforc.soundapi")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.5.0")]
[assembly: AssemblyInformationalVersion("2.0.5+a71c7ab12852d0d18cae5bac2e2cc537f46f6fd8")]
[assembly: AssemblyProduct("loaforcsSoundAPI")]
[assembly: AssemblyTitle("me.loaforc.soundapi")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.5.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace loaforcsSoundAPI
{
	[BepInPlugin("me.loaforc.soundapi", "loaforcsSoundAPI", "2.0.5")]
	internal class loaforcsSoundAPI : BaseUnityPlugin
	{
		private static loaforcsSoundAPI _instance;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			_instance = this;
			Logger = Logger.CreateLogSource("me.loaforc.soundapi");
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			Logger.LogInfo((object)"Setting up config");
			Debuggers.Bind(((BaseUnityPlugin)this).Config);
			SoundReportHandler.Bind(((BaseUnityPlugin)this).Config);
			Logger.LogInfo((object)"Running patches");
			Harmony harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "me.loaforc.soundapi");
			UnityObjectPatch.Init(harmony);
			Logger.LogInfo((object)"Registering data");
			SoundAPI.RegisterAll(Assembly.GetExecutingAssembly());
			SoundAPIAudioManager.SpawnManager();
			SoundReplacementHandler.Register();
			((BaseUnityPlugin)this).Config.Save();
			Logger.LogInfo((object)"me.loaforc.soundapi by loaforc has loaded :3");
		}

		internal static ConfigFile GenerateConfigFile(string name)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			return new ConfigFile(Utility.CombinePaths(new string[2]
			{
				Paths.ConfigPath,
				name + ".cfg"
			}), false, MetadataHelper.GetMetadata((object)_instance));
		}
	}
	public static class SoundAPI
	{
		public const string PLUGIN_GUID = "me.loaforc.soundapi";

		internal static NetworkAdapter CurrentNetworkAdapter { get; private set; }

		public static async Task<AudioClip> LoadAudioFileAsync(string fullPath)
		{
			if (!File.Exists(fullPath))
			{
				throw new FileNotFoundException("'" + fullPath + "' not found.");
			}
			if (!SoundPackLoadPipeline.audioExtensions.ContainsKey(Path.GetExtension(fullPath)))
			{
				throw new NotImplementedException("Audio file extension: '" + Path.GetExtension(fullPath) + "' is not implemented.");
			}
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(fullPath, SoundPackLoadPipeline.audioExtensions[Path.GetExtension(fullPath)]);
			await (AsyncOperation)(object)request.SendWebRequest();
			AudioClip content = DownloadHandlerAudioClip.GetContent(request);
			request.Dispose();
			return content;
		}

		public static void RegisterAll(Assembly assembly)
		{
			foreach (Type loadableType in assembly.GetLoadableTypes())
			{
				if (loadableType.IsNested)
				{
					continue;
				}
				foreach (SoundAPIConditionAttribute conditionAttribute in loadableType.GetCustomAttributes<SoundAPIConditionAttribute>())
				{
					if (!typeof(Condition).IsAssignableFrom(loadableType))
					{
						loaforcsSoundAPI.Logger.LogError((object)("Condition: '" + loadableType.FullName + "' has been marked with [SoundAPICondition] but does not extend Condition!"));
						continue;
					}
					ConstructorInfo info = loadableType.GetConstructor(Array.Empty<Type>());
					if (info == null)
					{
						loaforcsSoundAPI.Logger.LogError((object)("Condition: '" + loadableType.FullName + "' has no valid constructor! It must have a constructor with no parameters! If you need extra parameters do not mark it with [SoundAPICondition] and register it manually."));
						continue;
					}
					RegisterCondition(conditionAttribute.ID, delegate
					{
						if (conditionAttribute.IsDeprecated)
						{
							if (conditionAttribute.DeprecationReason == null)
							{
								loaforcsSoundAPI.Logger.LogWarning((object)("Condition: '" + conditionAttribute.ID + "' is deprecated and may be removed in future."));
							}
							else
							{
								loaforcsSoundAPI.Logger.LogWarning((object)("Condition: '" + conditionAttribute.ID + "' is deprecated. " + conditionAttribute.DeprecationReason));
							}
						}
						return (Condition)info.Invoke(Array.Empty<object>());
					});
				}
			}
		}

		public static void RegisterCondition(string id, Func<Condition> factory)
		{
			SoundPackDataHandler.Register(id, factory);
		}

		public static void RegisterNetworkAdapter(NetworkAdapter adapter)
		{
			CurrentNetworkAdapter = adapter;
			loaforcsSoundAPI.Logger.LogInfo((object)("Registered network adapter: '" + CurrentNetworkAdapter.Name + "'"));
			CurrentNetworkAdapter.OnRegister();
		}

		public static void RegisterSoundPack(SoundPack pack)
		{
			if (SoundPackDataHandler.LoadedPacks.Contains(pack))
			{
				throw new InvalidOperationException("Already registered sound-pack: '" + pack.Name + "'!");
			}
			SoundPackDataHandler.AddLoadedPack(pack);
			foreach (SoundReplacementCollection replacementCollection in pack.ReplacementCollections)
			{
				foreach (SoundReplacementGroup replacement in replacementCollection.Replacements)
				{
					SoundPackDataHandler.AddReplacement(replacement);
				}
			}
		}
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "me.loaforc.soundapi";

		public const string PLUGIN_NAME = "loaforcsSoundAPI";

		public const string PLUGIN_VERSION = "2.0.5";
	}
}
namespace loaforcsSoundAPI.SoundPacks
{
	internal class LoadSoundOperation
	{
		public readonly UnityWebRequest WebRequest = webRequest.webRequest;

		public readonly SoundInstance Sound;

		public bool IsReady => WebRequest.isDone;

		public bool IsDone { get; set; }

		public LoadSoundOperation(SoundInstance soundInstance, UnityWebRequestAsyncOperation webRequest)
		{
			Sound = soundInstance;
			base..ctor();
		}
	}
	internal static class SoundPackDataHandler
	{
		private static List<SoundPack> _loadedPacks = new List<SoundPack>();

		internal static Dictionary<string, List<SoundReplacementGroup>> SoundReplacements = new Dictionary<string, List<SoundReplacementGroup>>();

		internal static Dictionary<string, Func<Condition>> conditionFactories = new Dictionary<string, Func<Condition>>();

		internal static List<AudioClip> allLoadedClips = new List<AudioClip>();

		internal static IReadOnlyList<SoundPack> LoadedPacks => _loadedPacks.AsReadOnly();

		internal static void Register(string id, Func<Condition> factory)
		{
			conditionFactories[id] = factory;
		}

		public static Condition CreateCondition(string id)
		{
			if (conditionFactories.TryGetValue(id, out var value))
			{
				return value();
			}
			return new InvalidCondition(id);
		}

		internal static void AddLoadedPack(SoundPack pack)
		{
			_loadedPacks.Add(pack);
		}

		internal static void AddReplacement(SoundReplacementGroup group)
		{
			foreach (string match in group.Matches)
			{
				string key = match.Split(":").Last();
				if (!SoundReplacements.TryGetValue(key, out var value))
				{
					value = new List<SoundReplacementGroup>();
				}
				if (!value.Contains(group))
				{
					value.Add(group);
					SoundReplacements[key] = value;
				}
			}
		}
	}
	internal static class SoundPackLoadPipeline
	{
		private class SkippedResults
		{
			public int Collections;

			public int Groups;

			public int Sounds;
		}

		private static volatile int _activeThreads;

		private static Dictionary<string, List<string>> mappings;

		internal static Dictionary<string, AudioType> audioExtensions;

		internal static event Action OnFinishedPipeline;

		internal static async void StartPipeline()
		{
			Stopwatch completeLoadingTimer = Stopwatch.StartNew();
			Stopwatch timer = Stopwatch.StartNew();
			List<SoundPack> list = FindAndLoadPacks();
			loaforcsSoundAPI.Logger.LogInfo((object)$"(Step 1) Loading Sound-pack definitions took {timer.ElapsedMilliseconds}ms");
			timer.Restart();
			List<LoadSoundOperation> webRequestOperations = new List<LoadSoundOperation>();
			foreach (SoundPack item2 in list)
			{
				string path = Path.Combine(item2.PackFolder, "soundapi_mappings.json");
				if (!File.Exists(path))
				{
					continue;
				}
				Dictionary<string, List<string>> dictionary = JSONDataLoader.LoadFromFile<Dictionary<string, List<string>>>(path);
				foreach (KeyValuePair<string, List<string>> item3 in dictionary)
				{
					if (mappings.ContainsKey(item3.Key))
					{
						mappings[item3.Key].AddRange(item3.Value);
					}
					else
					{
						mappings[item3.Key] = item3.Value;
					}
				}
			}
			loaforcsSoundAPI.Logger.LogInfo((object)$"(Step 2) Loading Sound-pack mappings ('{mappings.Count}') took {timer.ElapsedMilliseconds}ms");
			timer.Restart();
			SkippedResults skippedStats = new SkippedResults();
			foreach (SoundPack item4 in list)
			{
				foreach (SoundReplacementCollection item5 in LoadSoundReplacementCollections(item4, ref skippedStats))
				{
					foreach (SoundReplacementGroup replacement in item5.Replacements)
					{
						SoundPackDataHandler.AddReplacement(replacement);
						foreach (SoundInstance sound in replacement.Sounds)
						{
							if (sound.Condition is ConstantCondition constantCondition && !constantCondition.Value)
							{
								Debuggers.SoundReplacementLoader?.Log("skipping a sound in '" + LogFormats.FormatFilePath(item5.FilePath) + "' because sound is marked as constant and has a value of false.");
								skippedStats.Sounds++;
							}
							else
							{
								webRequestOperations.Add(StartWebRequestOperation(item4, sound, audioExtensions[Path.GetExtension(sound.Sound)]));
							}
						}
					}
				}
			}
			int amountOfOperations = webRequestOperations.Count;
			loaforcsSoundAPI.Logger.LogInfo((object)$"(Step 3) Skipped {skippedStats.Collections} collection(s), {skippedStats.Groups} replacement(s), {skippedStats.Sounds} sound(s)");
			loaforcsSoundAPI.Logger.LogInfo((object)$"(Step 3) Loading sound replacement collections took {timer.ElapsedMilliseconds}ms");
			if (SoundReportHandler.CurrentReport != null)
			{
				SoundReportHandler.CurrentReport.AudioClipsLoaded = amountOfOperations;
			}
			loaforcsSoundAPI.Logger.LogInfo((object)$"(Step 4) Started loading {amountOfOperations} audio file(s)");
			loaforcsSoundAPI.Logger.LogInfo((object)"Waiting for splash screens to complete to continue...");
			completeLoadingTimer.Stop();
			await Task.Delay(1);
			loaforcsSoundAPI.Logger.LogInfo((object)"Splash screens done! Continuing pipeline");
			loaforcsSoundAPI.Logger.LogWarning((object)"The game will freeze for a moment!");
			timer.Restart();
			completeLoadingTimer.Start();
			bool flag = false;
			bool threadsShouldExit = false;
			ConcurrentQueue<LoadSoundOperation> queuedOperations = new ConcurrentQueue<LoadSoundOperation>();
			ConcurrentBag<Exception> threadPoolExceptions = new ConcurrentBag<Exception>();
			for (int i = 0; i < 16; i++)
			{
				new Thread((ThreadStart)delegate
				{
					while (queuedOperations.Count == 0 && !threadsShouldExit)
					{
						Thread.Yield();
					}
					Interlocked.Increment(ref _activeThreads);
					Debuggers.SoundReplacementLoader?.Log($"active threads at {_activeThreads}");
					LoadSoundOperation result;
					while (queuedOperations.TryDequeue(out result))
					{
						try
						{
							AudioClip content = DownloadHandlerAudioClip.GetContent(result.WebRequest);
							result.Sound.Clip = content;
							result.WebRequest.Dispose();
							Debuggers.SoundReplacementLoader?.Log("clip generated");
							result.IsDone = true;
						}
						catch (Exception item)
						{
							threadPoolExceptions.Add(item);
						}
					}
					Interlocked.Decrement(ref _activeThreads);
				}).Start();
			}
			while (webRequestOperations.Count > 0)
			{
				foreach (LoadSoundOperation item6 in from operation in webRequestOperations.ToList()
					where operation.IsReady
					select operation)
				{
					queuedOperations.Enqueue(item6);
					webRequestOperations.Remove(item6);
				}
				if (!flag && webRequestOperations.Count < amountOfOperations / 2)
				{
					flag = true;
					loaforcsSoundAPI.Logger.LogInfo((object)"(Step 5) Queued half of the needed operations!");
				}
				Thread.Yield();
			}
			loaforcsSoundAPI.Logger.LogInfo((object)"(Step 5) All file reads are done, waiting for the audio clips conversions.");
			threadsShouldExit = true;
			while (_activeThreads > 0 || webRequestOperations.Any((LoadSoundOperation operation) => !operation.IsDone))
			{
				Thread.Yield();
			}
			loaforcsSoundAPI.Logger.LogInfo((object)$"(Step 6) Took {timer.ElapsedMilliseconds}ms to finish loading audio clips from files");
			if (threadPoolExceptions.Count != 0)
			{
				loaforcsSoundAPI.Logger.LogError((object)$"(Step 6) {threadPoolExceptions.Count} internal error(s) happened while loading:");
				foreach (Exception item7 in threadPoolExceptions)
				{
					loaforcsSoundAPI.Logger.LogError((object)item7.ToString());
				}
			}
			SoundPackLoadPipeline.OnFinishedPipeline();
			mappings = null;
			loaforcsSoundAPI.Logger.LogDebug((object)$"Active Threads that are left over: {_activeThreads}");
			loaforcsSoundAPI.Logger.LogInfo((object)$"Entire load process took an effective {completeLoadingTimer.ElapsedMilliseconds}ms");
		}

		private static List<SoundPack> FindAndLoadPacks(string entryPoint = "sound_pack.json")
		{
			List<SoundPack> list = new List<SoundPack>();
			string[] files = Directory.GetFiles(Paths.PluginPath, entryPoint, SearchOption.AllDirectories);
			foreach (string text in files)
			{
				Debuggers.SoundReplacementLoader?.Log("found entry point: '" + text + "'!");
				SoundPack soundPack = JSONDataLoader.LoadFromFile<SoundPack>(text);
				if (soundPack != null)
				{
					soundPack.PackFolder = Path.GetDirectoryName(text);
					Debuggers.SoundReplacementLoader?.Log("json loaded, validating");
					List<IValidatable.ValidationResult> results = soundPack.Validate();
					if (IValidatable.LogAndCheckValidationResult("loading '" + text + "'", results, soundPack.Logger))
					{
						ConfigFile val = loaforcsSoundAPI.GenerateConfigFile(soundPack.GUID);
						val.SaveOnConfigSet = false;
						soundPack.Bind(val);
						val.Save();
						list.Add(soundPack);
						SoundPackDataHandler.AddLoadedPack(soundPack);
						Debuggers.SoundReplacementLoader?.Log("pack folder: " + soundPack.PackFolder);
					}
				}
			}
			Debuggers.SoundReplacementLoader?.Log($"loaded '{list.Count}' packs.");
			return list;
		}

		private static List<SoundReplacementCollection> LoadSoundReplacementCollections(SoundPack pack, ref SkippedResults skippedStats)
		{
			List<SoundReplacementCollection> list = new List<SoundReplacementCollection>();
			if (!Directory.Exists(Path.Combine(pack.PackFolder, "replacers")))
			{
				return list;
			}
			Debuggers.SoundReplacementLoader?.Log("start loading '" + pack.Name + "'!");
			string[] files = Directory.GetFiles(Path.Combine(pack.PackFolder, "replacers"), "*.json", SearchOption.AllDirectories);
			foreach (string text in files)
			{
				Debuggers.SoundReplacementLoader?.Log("found replacer: '" + text + "'!");
				SoundReplacementCollection soundReplacementCollection = JSONDataLoader.LoadFromFile<SoundReplacementCollection>(text);
				if (soundReplacementCollection == null)
				{
					continue;
				}
				soundReplacementCollection.Pack = pack;
				if (soundReplacementCollection.Condition is ConstantCondition constantCondition && !constantCondition.Value)
				{
					Debuggers.SoundReplacementLoader?.Log("skipping '" + LogFormats.FormatFilePath(soundReplacementCollection.FilePath) + "' because collection is marked as constant and has a value of false.");
					skippedStats.Collections++;
				}
				else
				{
					if (!IValidatable.LogAndCheckValidationResult("loading '" + LogFormats.FormatFilePath(text) + "'", soundReplacementCollection.Validate(), pack.Logger))
					{
						continue;
					}
					List<IValidatable.ValidationResult> list2 = new List<IValidatable.ValidationResult>();
					foreach (SoundReplacementGroup replacement in soundReplacementCollection.Replacements)
					{
						replacement.Parent = soundReplacementCollection;
						if (replacement.Condition is ConstantCondition constantCondition2 && !constantCondition2.Value)
						{
							Debuggers.SoundReplacementLoader?.Log("skipping a replacement in '" + LogFormats.FormatFilePath(soundReplacementCollection.FilePath) + "' because group is marked as constant and has a value of false.");
							skippedStats.Groups++;
							continue;
						}
						List<IValidatable.ValidationResult> list3 = replacement.Validate();
						foreach (string item in replacement.Matches.ToList())
						{
							if (item.StartsWith("#"))
							{
								replacement.Matches.Remove(item);
								Dictionary<string, List<string>> dictionary = mappings;
								string text2 = item;
								if (dictionary.TryGetValue(text2.Substring(1, text2.Length - 1), out var value))
								{
									replacement.Matches.AddRange(value);
								}
								else
								{
									list3.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Mapping: '" + item + "' has not been found. If it's part of a soft dependency, make sure to use a 'mod_installed' condition with 'constant' enabled."));
								}
							}
						}
						if (list3.Count != 0)
						{
							list2.AddRange(list3);
							continue;
						}
						foreach (SoundInstance sound in replacement.Sounds)
						{
							sound.Parent = replacement;
							list3.AddRange(sound.Validate());
						}
						if (list3.Count != 0)
						{
							list2.AddRange(list3);
							continue;
						}
						List<string> collection = replacement.Matches.Select((string match) => (match.Split(":").Length != 2) ? match : ("*:" + match)).ToList();
						replacement.Matches.Clear();
						replacement.Matches.AddRange(collection);
					}
					if (IValidatable.LogAndCheckValidationResult("loading '" + LogFormats.FormatFilePath(text) + "'", list2, pack.Logger))
					{
						list.Add(soundReplacementCollection);
					}
				}
			}
			return list;
		}

		private static LoadSoundOperation StartWebRequestOperation(SoundPack pack, SoundInstance sound, AudioType type)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(pack.PackFolder, "sounds", sound.Sound);
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(text, type);
			return new LoadSoundOperation(sound, audioClip.SendWebRequest());
		}

		static SoundPackLoadPipeline()
		{
			SoundPackLoadPipeline.OnFinishedPipeline = delegate
			{
			};
			mappings = new Dictionary<string, List<string>>();
			audioExtensions = new Dictionary<string, AudioType>
			{
				{
					".ogg",
					(AudioType)14
				},
				{
					".wav",
					(AudioType)20
				},
				{
					".mp3",
					(AudioType)13
				}
			};
		}
	}
	internal static class SoundReplacementHandler
	{
		private const int TOKEN_PARENT_NAME = 0;

		private const int TOKEN_OBJECT_NAME = 1;

		private const int TOKEN_CLIP_NAME = 2;

		private static readonly string[] _suffixesToRemove = new string[1] { "(Clone)" };

		private static readonly Dictionary<int, string> _cachedObjectNames = new Dictionary<int, string>();

		private static readonly StringBuilder _builder = new StringBuilder();

		internal static void Register()
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode _)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				_cachedObjectNames.Clear();
				AudioSource[] array = Object.FindObjectsOfType<AudioSource>(true);
				foreach (AudioSource val in array)
				{
					if (!(((Component)val).gameObject.scene != scene) && val.playOnAwake && TryReplaceAudio(val, val.clip, out var replacement))
					{
						val.Stop();
						if (!((Object)(object)replacement == (Object)null))
						{
							val.clip = replacement;
						}
					}
				}
			};
		}

		internal static bool TryReplaceAudio(AudioSource source, AudioClip clip, out AudioClip replacement)
		{
			replacement = null;
			if ((Object)(object)((Component)source).gameObject == (Object)null)
			{
				return false;
			}
			AudioSourceAdditionalData orCreate = AudioSourceAdditionalData.GetOrCreate(source);
			if (orCreate.ReplacedWith != null && orCreate.ReplacedWith.Parent.UpdateEveryFrame)
			{
				return false;
			}
			if (orCreate.DisableReplacing)
			{
				return false;
			}
			string[] name = ArrayPool<string>.Shared.Rent(3);
			if (!TryProcessName(ref name, source, clip) || !TryGetReplacementClip(name, out var group, out var clip2, orCreate.CurrentContext ?? DefaultConditionContext.DEFAULT))
			{
				ArrayPool<string>.Shared.Return(name);
				return false;
			}
			ArrayPool<string>.Shared.Return(name);
			((Object)clip2).name = ((Object)clip).name;
			replacement = clip2;
			orCreate.ReplacedWith = group;
			if (group.Parent.UpdateEveryFrame)
			{
				Debuggers.UpdateEveryFrame?.Log("swapped to a clip that uses update_every_frame !!!");
			}
			return true;
		}

		private static string TrimObjectName(GameObject gameObject)
		{
			if (_cachedObjectNames.ContainsKey(((object)gameObject).GetHashCode()))
			{
				return _cachedObjectNames[((object)gameObject).GetHashCode()];
			}
			_builder.Clear();
			_builder.Append(((Object)gameObject).name);
			string[] suffixesToRemove = _suffixesToRemove;
			foreach (string oldValue in suffixesToRemove)
			{
				_builder.Replace(oldValue, string.Empty);
			}
			for (int j = 0; j < _builder.Length; j++)
			{
				if (_builder[j] == '(')
				{
					int num = j;
					for (j++; j < _builder.Length && char.IsDigit(_builder[j]); j++)
					{
					}
					if (j < _builder.Length && _builder[j] == ')')
					{
						_builder.Remove(num, j - num + 1);
						j = num - 1;
					}
				}
			}
			int num2 = _builder.Length;
			while (num2 > 0 && _builder[num2 - 1] == ' ')
			{
				num2--;
			}
			_builder.Remove(num2, _builder.Length - num2);
			string text = _builder.ToString();
			_cachedObjectNames[((object)gameObject).GetHashCode()] = text;
			return text;
		}

		private static bool TryProcessName(ref string[] name, AudioSource source, AudioClip clip)
		{
			if ((Object)(object)clip == (Object)null)
			{
				return false;
			}
			if ((Object)(object)((Component)source).transform.parent == (Object)null)
			{
				name[0] = "*";
			}
			else
			{
				name[0] = TrimObjectName(((Component)((Component)source).transform.parent).gameObject);
			}
			name[1] = TrimObjectName(((Component)source).gameObject);
			name[2] = ((Object)clip).name;
			if (SoundReportHandler.CurrentReport != null)
			{
				string caller;
				try
				{
					caller = new StackTrace(fNeedFileInfo: true).GetFrame(5).GetMethod().DeclaringType.Name;
				}
				catch
				{
					caller = "unknown caller";
				}
				SoundReport.PlayedSound playedSound = new SoundReport.PlayedSound(name[0] + ":" + name[1] + ":" + name[2], caller, source.playOnAwake);
				if (!SoundReportHandler.CurrentReport.PlayedSounds.Any(playedSound.Equals))
				{
					SoundReportHandler.CurrentReport.PlayedSounds.Add(playedSound);
				}
			}
			Debuggers.MatchStrings?.Log(name[0] + ":" + name[1] + ":" + name[2]);
			return true;
		}

		private static bool TryGetReplacementClip(string[] name, out SoundReplacementGroup group, out AudioClip clip, IContext context)
		{
			group = null;
			clip = null;
			if (name == null)
			{
				return false;
			}
			Debuggers.SoundReplacementHandler?.Log("beginning replacement attempt for " + name[2]);
			if (!SoundPackDataHandler.SoundReplacements.TryGetValue(name[2], out var value))
			{
				return false;
			}
			Debuggers.SoundReplacementHandler?.Log("sound dictionary hit");
			value = value.Where((SoundReplacementGroup it) => it.Parent.Evaluate(context) && it.Evaluate(context) && CheckGroupMatches(it, name)).ToList();
			if (value.Count == 0)
			{
				return false;
			}
			Debuggers.SoundReplacementHandler?.Log("sound group that matches");
			group = value[Random.Range(0, value.Count)];
			List<SoundInstance> list = group.Sounds.Where((SoundInstance it) => it.Evaluate(context)).ToList();
			if (list.Count == 0)
			{
				return false;
			}
			Debuggers.SoundReplacementHandler?.Log("has valid sounds");
			int totalWeight = 0;
			list.ForEach(delegate(SoundInstance replacement)
			{
				totalWeight += replacement.Weight;
			});
			int num = Random.Range(0, totalWeight + 1);
			SoundInstance soundInstance = null;
			foreach (SoundInstance item in list)
			{
				soundInstance = item;
				num -= soundInstance.Weight;
				if (num <= 0)
				{
					break;
				}
			}
			clip = soundInstance.Clip;
			Debuggers.SoundReplacementHandler?.Log("done, dumping stack trace!");
			Debuggers.SoundReplacementHandler?.Log(string.Join(", ", group.Matches));
			Debuggers.SoundReplacementHandler?.Log(((Object)clip).name);
			Debuggers.SoundReplacementHandler?.Log(new StackTrace(fNeedFileInfo: true).ToString().Trim());
			return true;
		}

		private static bool CheckGroupMatches(SoundReplacementGroup group, string[] a)
		{
			foreach (string match in group.Matches)
			{
				if (MatchStrings(a, match))
				{
					return true;
				}
			}
			return false;
		}

		private static bool MatchStrings(string[] a, string b)
		{
			string[] array = b.Split(":");
			if (array[0] != "*" && array[0] != a[0])
			{
				return false;
			}
			if (array[1] != "*" && array[1] != a[1])
			{
				return false;
			}
			return a[2] == array[2];
		}
	}
}
namespace loaforcsSoundAPI.SoundPacks.Data
{
	public interface IPackData
	{
		SoundPack Pack { get; internal set; }
	}
	public class SoundInstance : Conditional
	{
		[field: NonSerialized]
		public SoundReplacementGroup Parent { get; internal set; }

		public string Sound { get; private set; }

		public int Weight { get; private set; }

		[field: NonSerialized]
		public AudioClip Clip { get; internal set; }

		public override SoundPack Pack
		{
			get
			{
				return Parent.Pack;
			}
			set
			{
				if (Parent.Pack != null)
				{
					throw new InvalidOperationException("Pack has already been set.");
				}
				Parent.Pack = value;
			}
		}

		[JsonConstructor]
		internal SoundInstance()
		{
		}

		public SoundInstance(SoundReplacementGroup parent, int weight, AudioClip clip)
		{
			Parent = parent;
			Weight = weight;
			Clip = clip;
			parent.AddSoundReplacement(this);
		}

		public override List<IValidatable.ValidationResult> Validate()
		{
			List<IValidatable.ValidationResult> list = base.Validate();
			if (!File.Exists(Path.Combine(Pack.PackFolder, "sounds", Sound)))
			{
				list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Sound '" + Sound + "' couldn't be found or doesn't exist!"));
			}
			else if (!SoundPackLoadPipeline.audioExtensions.ContainsKey(Path.GetExtension(Sound)))
			{
				list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Audio type: '" + Path.GetExtension(Sound) + "' is not supported!"));
			}
			return list;
		}
	}
	public class SoundPack : IValidatable
	{
		[NonSerialized]
		private readonly Dictionary<string, object> _configData = new Dictionary<string, object>();

		private ManualLogSource _logger;

		[JsonProperty]
		private Dictionary<string, JObject> config { get; set; }

		public string Name { get; private set; }

		public string GUID => "soundpack." + Name;

		public string PackFolder { get; internal set; }

		[field: NonSerialized]
		public List<SoundReplacementCollection> ReplacementCollections { get; private set; } = new List<SoundReplacementCollection>();


		public ManualLogSource Logger
		{
			get
			{
				if (_logger == null)
				{
					_logger = Logger.CreateLogSource(GUID);
				}
				return _logger;
			}
		}

		[JsonConstructor]
		internal SoundPack()
		{
		}

		internal void Bind(ConfigFile file)
		{
			//IL_0095: 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)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Invalid comparison between Unknown and I4
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Invalid comparison between Unknown and I4
			if (config == null || config.Count == 0)
			{
				return;
			}
			loaforcsSoundAPI.Logger.LogDebug((object)"handling config");
			JToken val2 = default(JToken);
			foreach (KeyValuePair<string, JObject> item in config)
			{
				string[] array = item.Key.Split(":");
				string text = array[0];
				string text2 = array[1];
				JToken val = item.Value["default"];
				string text3 = (item.Value.TryGetValue("description", ref val2) ? ((object)val2).ToString() : "no description defined!");
				JTokenType type = val.Type;
				if ((int)type != 8)
				{
					if ((int)type != 9)
					{
						throw new NotImplementedException("WHAT");
					}
					_configData[item.Key] = file.Bind<bool>(text, text2, (bool)val, text3).Value;
				}
				else
				{
					_configData[item.Key] = file.Bind<string>(text, text2, (string)val, text3).Value;
				}
			}
		}

		public SoundPack(string name, string packFolder)
		{
			Name = name;
			PackFolder = packFolder;
		}

		internal bool TryGetConfigValue(string id, out object returnValue)
		{
			returnValue = null;
			if (!_configData.TryGetValue(id, out var value))
			{
				return false;
			}
			returnValue = value;
			return true;
		}

		public List<IValidatable.ValidationResult> Validate()
		{
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Invalid comparison between Unknown and I4
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Invalid comparison between Unknown and I4
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			List<IValidatable.ValidationResult> list = new List<IValidatable.ValidationResult>();
			if (string.IsNullOrEmpty(Name))
			{
				list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "'name' can not be missing or empty!"));
				return list;
			}
			string name = Name;
			foreach (char c in name)
			{
				if (!char.IsLetter(c) && c != '_')
				{
					list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, $"'name' can not contain special character '{c}'!"));
				}
			}
			if (config == null)
			{
				return list;
			}
			JToken val = default(JToken);
			foreach (KeyValuePair<string, JObject> item in config)
			{
				string[] array = item.Key.Split(":");
				if (array.Length != 2)
				{
					list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "'" + item.Key + "' is not a valid key for config! It must be 'section:name' with exactly one colon!"));
				}
				if (!item.Value.TryGetValue("default", ref val))
				{
					list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "'" + item.Key + "' does not have a 'default' value! This is needed to get what type the config is!"));
				}
				else if ((int)val.Type != 9 && (int)val.Type != 8)
				{
					list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, $"'{item.Key}' is of unsupported type: '{val.Type}'! Only supported types are strings/text or booleans!"));
				}
				if (!item.Value.ContainsKey("description"))
				{
					list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.WARN, "'" + item.Key + "' does not have a description."));
				}
			}
			return list;
		}
	}
	public class SoundReplacementCollection : Conditional, IFilePathAware, IPackData
	{
		[field: NonSerialized]
		public override SoundPack Pack { get; set; }

		public bool UpdateEveryFrame { get; private set; }

		public bool Synced { get; private set; }

		public List<SoundReplacementGroup> Replacements { get; private set; } = new List<SoundReplacementGroup>();


		public string FilePath { get; set; }

		[JsonConstructor]
		internal SoundReplacementCollection()
		{
		}

		public SoundReplacementCollection(SoundPack pack)
		{
			Pack = pack;
			pack.ReplacementCollections.Add(this);
		}

		internal void AddSoundReplacementGroup(SoundReplacementGroup group)
		{
			Replacements.Add(group);
		}
	}
	public class SoundReplacementGroup : Conditional
	{
		[field: NonSerialized]
		public SoundReplacementCollection Parent { get; internal set; }

		public List<string> Matches { get; private set; }

		public List<SoundInstance> Sounds { get; private set; } = new List<SoundInstance>();


		public override SoundPack Pack
		{
			get
			{
				return Parent.Pack;
			}
			set
			{
				if (Parent.Pack != null)
				{
					throw new InvalidOperationException("Pack has already been set.");
				}
				Parent.Pack = value;
			}
		}

		[JsonConstructor]
		internal SoundReplacementGroup()
		{
		}

		public SoundReplacementGroup(SoundReplacementCollection parent, List<string> matches)
		{
			Parent = parent;
			Matches = matches;
			if (SoundPackDataHandler.LoadedPacks.Contains(parent.Pack))
			{
				throw new InvalidOperationException("SoundPack has already been registered, trying to add a new SoundReplacementGroup does not work!");
			}
			parent.AddSoundReplacementGroup(this);
		}

		internal void AddSoundReplacement(SoundInstance sound)
		{
			Sounds.Add(sound);
		}

		public override List<IValidatable.ValidationResult> Validate()
		{
			List<IValidatable.ValidationResult> list = base.Validate();
			foreach (string match in Matches)
			{
				if (string.IsNullOrEmpty(match))
				{
					list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Match string can not be empty!"));
					continue;
				}
				string[] array = match.Split(":");
				if (array.Length == 1)
				{
					list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "'" + match + "' is not valid! If you mean to match to all Audio clips with this name you must explicitly do '*:" + match + "'."));
				}
				if (array.Length > 3)
				{
					list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.WARN, $"'{match}' has more than 3 parts! SoundAPI will handle this as '{match[0]}:{match[1]}:{match[2]}', discarding the rest!"));
				}
			}
			return list;
		}
	}
}
namespace loaforcsSoundAPI.SoundPacks.Data.Conditions
{
	public abstract class Condition : IValidatable
	{
		[field: NonSerialized]
		public Conditional Parent { get; internal set; }

		protected SoundPack Pack => Parent.Pack;

		public bool? Constant { get; private set; }

		protected internal virtual void OnRegistered()
		{
		}

		public abstract bool Evaluate(IContext context);

		public virtual List<IValidatable.ValidationResult> Validate()
		{
			return new List<IValidatable.ValidationResult>();
		}

		protected bool EvaluateRangeOperator(int number, string condition)
		{
			return EvaluateRangeOperator((double)number, condition);
		}

		protected bool EvaluateRangeOperator(float number, string condition)
		{
			return EvaluateRangeOperator((double)number, condition);
		}

		protected bool EvaluateRangeOperator(double value, string condition)
		{
			string[] array = condition.Split("..");
			if (array.Length == 1)
			{
				if (double.TryParse(array[0], out var result))
				{
					return value == result;
				}
				return false;
			}
			if (array.Length == 2)
			{
				double result2;
				if (array[0] == "")
				{
					result2 = double.MinValue;
				}
				else if (!double.TryParse(array[0], out result2))
				{
					return false;
				}
				double result3;
				if (array[1] == "")
				{
					result3 = double.MaxValue;
				}
				else if (!double.TryParse(array[1], out result3))
				{
					return false;
				}
				if (value >= result2)
				{
					return value <= result3;
				}
				return false;
			}
			return false;
		}

		protected bool ValidateRangeOperator(string condition, out IValidatable.ValidationResult result)
		{
			result = null;
			if (string.IsNullOrEmpty(condition))
			{
				result = new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Range operator can not be missing or empty!");
				return false;
			}
			string[] array = condition.Split("..");
			int num = array.Length;
			if (num <= 2)
			{
				switch (num)
				{
				case 1:
				{
					if (!double.TryParse(array[0], out var _))
					{
						result = new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Failed to parse: '" + array[0] + "' as a number!");
					}
					break;
				}
				case 2:
				{
					double num2;
					if (array[0] == "")
					{
						num2 = double.MinValue;
					}
					else if (!double.TryParse(array[0], out num2))
					{
						result = new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Failed to parse: '" + array[0] + "' as a number!");
					}
					double num3;
					if (array[1] == "")
					{
						num3 = double.MaxValue;
					}
					else if (!double.TryParse(array[1], out num3))
					{
						result = new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Failed to parse: '" + array[1] + "' as a number!");
					}
					break;
				}
				}
			}
			else
			{
				result = new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Range operator: '" + condition + "' uses .. more than once!");
			}
			return result == null;
		}

		protected static void LogDebug(string name, object message)
		{
			Debuggers.ConditionsInfo?.Log($"({name}) {message}");
		}
	}
	internal sealed class InvalidCondition : Condition
	{
		[CompilerGenerated]
		private string <type>P;

		public InvalidCondition(string type)
		{
			<type>P = type;
			base..ctor();
		}

		public override bool Evaluate(IContext context)
		{
			return false;
		}

		public override List<IValidatable.ValidationResult> Validate()
		{
			if (string.IsNullOrEmpty(<type>P))
			{
				return new List<IValidatable.ValidationResult>(1)
				{
					new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Condition must have a type!")
				};
			}
			return new List<IValidatable.ValidationResult>(1)
			{
				new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "'" + <type>P + "' is not a valid condition type!")
			};
		}
	}
	internal sealed class ConstantCondition : Condition
	{
		public static ConstantCondition TRUE = new ConstantCondition(constant: true);

		public static ConstantCondition FALSE = new ConstantCondition(constant: false);

		public bool Value { get; private set; }

		private ConstantCondition(bool constant)
		{
			Value = constant;
		}

		public override bool Evaluate(IContext context)
		{
			return Value;
		}
	}
	public abstract class Condition<TContext> : Condition where TContext : IContext
	{
		public override bool Evaluate(IContext context)
		{
			if (!(context is TContext context2))
			{
				return EvaluateFallback(context);
			}
			return EvaluateWithContext(context2);
		}

		protected abstract bool EvaluateWithContext(TContext context);

		protected virtual bool EvaluateFallback(IContext context)
		{
			return false;
		}
	}
	public abstract class Conditional : IValidatable, IPackData
	{
		public Condition Condition { get; set; }

		public abstract SoundPack Pack { get; set; }

		public bool Evaluate(IContext context)
		{
			if (Condition == null)
			{
				return true;
			}
			return Condition.Evaluate(context);
		}

		public virtual List<IValidatable.ValidationResult> Validate()
		{
			if (Condition == null)
			{
				return new List<IValidatable.ValidationResult>();
			}
			Condition.Parent = this;
			Condition.OnRegistered();
			return Condition.Validate();
		}
	}
	public interface IContext
	{
	}
	internal class DefaultConditionContext : IContext
	{
		internal static readonly DefaultConditionContext DEFAULT = new DefaultConditionContext();

		private DefaultConditionContext()
		{
		}
	}
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
	[MeansImplicitUse]
	public class SoundAPIConditionAttribute : Attribute
	{
		public string ID { get; private set; }

		public bool IsDeprecated { get; private set; }

		public string DeprecationReason { get; private set; }

		public SoundAPIConditionAttribute(string id, bool deprecated = false, string deprecationReason = null)
		{
			ID = id;
			IsDeprecated = deprecated;
			DeprecationReason = deprecationReason;
			base..ctor();
		}
	}
}
namespace loaforcsSoundAPI.SoundPacks.Conditions
{
	public abstract class LogicGateCondition : Condition
	{
		public Condition[] Conditions { get; private set; }

		protected abstract string ValidateWarnMessage { get; }

		protected internal override void OnRegistered()
		{
			Condition[] conditions = Conditions;
			foreach (Condition condition in conditions)
			{
				condition.Parent = base.Parent;
				condition.OnRegistered();
			}
		}

		public override List<IValidatable.ValidationResult> Validate()
		{
			if (Conditions.Length == 0)
			{
				return new List<IValidatable.ValidationResult>(1)
				{
					new IValidatable.ValidationResult(IValidatable.ResultType.WARN, ValidateWarnMessage)
				};
			}
			return new List<IValidatable.ValidationResult>();
		}

		protected static bool And(Condition[] conditions, IContext context)
		{
			foreach (Condition condition in conditions)
			{
				if (condition is InvalidCondition)
				{
					return false;
				}
				if (!condition.Evaluate(context))
				{
					return false;
				}
			}
			return true;
		}

		protected static bool Or(Condition[] conditions, IContext context)
		{
			foreach (Condition condition in conditions)
			{
				if (condition is InvalidCondition)
				{
					return false;
				}
				if (condition.Evaluate(context))
				{
					return true;
				}
			}
			return false;
		}
	}
	[SoundAPICondition("and", false, null)]
	internal class AndCondition : LogicGateCondition
	{
		protected override string ValidateWarnMessage => "'and' condition has no conditions and will always return true!";

		public override bool Evaluate(IContext context)
		{
			return LogicGateCondition.And(base.Conditions, context);
		}
	}
	[SoundAPICondition("nand", false, null)]
	internal class NandCondition : LogicGateCondition
	{
		protected override string ValidateWarnMessage => "'nand' condition has no conditions and will always return false!";

		public override bool Evaluate(IContext context)
		{
			return !LogicGateCondition.And(base.Conditions, context);
		}
	}
	[SoundAPICondition("config", false, null)]
	internal class ConfigCondition : Condition
	{
		public string Config { get; private set; }

		public object Value { get; private set; }

		public override bool Evaluate(IContext context)
		{
			if (!base.Pack.TryGetConfigValue(Config, out var returnValue))
			{
				return false;
			}
			if (Value == null)
			{
				if (returnValue is bool)
				{
					return (bool)returnValue;
				}
				if (returnValue is string value)
				{
					return string.IsNullOrEmpty(value);
				}
				return false;
			}
			if (returnValue is bool flag)
			{
				return flag == (bool)Value;
			}
			if (returnValue is string text)
			{
				return text == (string)Value;
			}
			return false;
		}

		public override List<IValidatable.ValidationResult> Validate()
		{
			if (!base.Pack.TryGetConfigValue(Config, out var returnValue))
			{
				List<IValidatable.ValidationResult> list = new List<IValidatable.ValidationResult>(1);
				list.Add(new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Config '" + Config + "' does not exist on SoundPack '" + base.Pack.Name + "'"));
				return list;
			}
			if (Value != null && returnValue.GetType() != Value.GetType())
			{
				return new List<IValidatable.ValidationResult>(1)
				{
					new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, $"Config '{Config}' has a type of: '{returnValue.GetType()}' but the Value type is '{Value.GetType()}'!")
				};
			}
			return new List<IValidatable.ValidationResult>();
		}
	}
	[SoundAPICondition("counter", false, null)]
	public class CounterCondition : Condition
	{
		private int _count;

		public string Value { get; private set; }

		public int? ResetsAt { get; private set; }

		public override bool Evaluate(IContext context)
		{
			Condition.LogDebug("counter", $"counting: {_count} -> {_count + 1}");
			_count++;
			bool flag = EvaluateRangeOperator(_count, Value);
			Condition.LogDebug("counter", $"is {_count} in range ({Value})? {flag}");
			if (_count >= ResetsAt)
			{
				_count = 0;
				Condition.LogDebug("counter", "reset count to 0.");
			}
			return flag;
		}

		public override List<IValidatable.ValidationResult> Validate()
		{
			if (!ValidateRangeOperator(Value, out var result))
			{
				return new List<IValidatable.ValidationResult>(1) { result };
			}
			return new List<IValidatable.ValidationResult>();
		}
	}
	[SoundAPICondition("mod_installed", false, null)]
	internal class ModInstalledCondition : Condition
	{
		public string Value { get; private set; }

		public override bool Evaluate(IContext context)
		{
			return Chainloader.PluginInfos.ContainsKey(Value);
		}

		public override List<IValidatable.ValidationResult> Validate()
		{
			if (string.IsNullOrEmpty(Value))
			{
				return new List<IValidatable.ValidationResult>(1)
				{
					new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "Value on 'mod_installed' must be there and must not be empty.")
				};
			}
			return new List<IValidatable.ValidationResult>();
		}
	}
	[SoundAPICondition("not", false, null)]
	internal class NotCondition : Condition
	{
		public Condition Condition { get; private set; }

		protected internal override void OnRegistered()
		{
			if (Condition != null)
			{
				Condition.Parent = base.Parent;
				Condition.OnRegistered();
			}
		}

		public override bool Evaluate(IContext context)
		{
			if (Condition is InvalidCondition)
			{
				return false;
			}
			return !Condition.Evaluate(context);
		}

		public override List<IValidatable.ValidationResult> Validate()
		{
			if (Condition == null)
			{
				return new List<IValidatable.ValidationResult>(1)
				{
					new IValidatable.ValidationResult(IValidatable.ResultType.FAIL, "'not' condition has no valid condition to invert!")
				};
			}
			return new List<IValidatable.ValidationResult>();
		}
	}
	[SoundAPICondition("or", false, null)]
	internal class OrCondition : LogicGateCondition
	{
		protected override string ValidateWarnMessage => "'or' condition has no conditions and will always return false!";

		public override bool Evaluate(IContext context)
		{
			return LogicGateCondition.Or(base.Conditions, context);
		}
	}
	[SoundAPICondition("nor", false, null)]
	internal class NorCondition : LogicGateCondition
	{
		protected override string ValidateWarnMessage => "'nor' condition has no conditions and will always return true!";

		public override bool Evaluate(IContext context)
		{
			return !LogicGateCondition.Or(base.Conditions, context);
		}
	}
}
namespace loaforcsSoundAPI.Reporting
{
	public static class SoundReportHandler
	{
		private const string _datetimeFormat = "dd_MM_yyyy-HH_mm";

		private static Action<StreamWriter, SoundReport> _reportSections = delegate
		{
		};

		public static SoundReport CurrentReport { get; private set; }

		public static void AddReportSection(string header, Action<StreamWriter, SoundReport> callback)
		{
			_reportSections = (Action<StreamWriter, SoundReport>)Delegate.Combine(_reportSections, (Action<StreamWriter, SoundReport>)delegate(StreamWriter stream, SoundReport report)
			{
				stream.WriteLine("## " + header);
				callback(stream, report);
				stream.WriteLine("");
				stream.WriteLine("");
			});
		}

		internal static void Register()
		{
			Directory.CreateDirectory(GetFolder());
			CurrentReport = new SoundReport();
			loaforcsSoundAPI.Logger.LogWarning((object)"SoundAPI is generating a report!");
			loaforcsSoundAPI.Logger.LogInfo((object)("The report will be located at '" + LogFormats.FormatFilePath(Path.Combine(GetFolder(), GetFileName(CurrentReport, ".md")))));
			Application.quitting += delegate
			{
				WriteReportToFile(CurrentReport);
			};
			SoundPackLoadPipeline.OnFinishedPipeline += delegate
			{
				foreach (SoundPack loadedPack in SoundPackDataHandler.LoadedPacks)
				{
					CurrentReport.SoundPackNames.Add(loadedPack.Name);
				}
			};
			AddReportSection("General Information", delegate(StreamWriter stream, SoundReport report)
			{
				stream.WriteLine("SoundAPI version: `2.0.5` <br/><br/>");
				stream.WriteLine($"Audio-clips loaded: `{report.AudioClipsLoaded}` <br/>");
				stream.WriteLine($"Match strings registered: `{SoundPackDataHandler.SoundReplacements.Values.Sum((List<SoundReplacementGroup> it) => it.Count)}` <br/>");
				WriteList("Loaded sound-packs", stream, report.SoundPackNames);
			});
			AddReportSection("Dynamic Data", delegate(StreamWriter stream, SoundReport _)
			{
				if (SoundAPI.CurrentNetworkAdapter != null)
				{
					stream.WriteLine("Network Adapter: `" + SoundAPI.CurrentNetworkAdapter.Name + "` <br/><br/>");
				}
				WriteList("Registered Conditions", stream, SoundPackDataHandler.conditionFactories.Keys.ToList());
			});
			AddReportSection("All Played Sounds", delegate(StreamWriter stream, SoundReport report)
			{
				WriteList(null, stream, report.PlayedSounds.Select((SoundReport.PlayedSound it) => it.FormatForReport()).ToList());
			});
		}

		internal static void Bind(ConfigFile file)
		{
			if (file.Bind<bool>("Developer", "GenerateReports", false, "While true SoundAPI will generate a json and markdown file per session that records information SoundAPI and related mods find.").Value)
			{
				Register();
			}
		}

		private static string GetFileName(SoundReport report, string extension)
		{
			return "generated_report-" + report.StartedAt.ToString("dd_MM_yyyy-HH_mm") + extension;
		}

		private static string GetFolder()
		{
			return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "reports");
		}

		private static void WriteReportToFile(SoundReport report)
		{
			using StreamWriter streamWriter = new StreamWriter(Path.Combine(GetFolder(), GetFileName(report, ".md")));
			streamWriter.WriteLine("# Generated Report");
			streamWriter.WriteLine($"At {report.StartedAt} :3");
			streamWriter.WriteLine("");
			_reportSections(streamWriter, report);
			streamWriter.Flush();
			streamWriter.Close();
			using StreamWriter streamWriter2 = new StreamWriter(Path.Combine(GetFolder(), GetFileName(report, ".json")));
			streamWriter2.WriteLine(JsonConvert.SerializeObject((object)report, (Formatting)1));
		}

		public static void WriteList(string header, StreamWriter stream, ICollection<string> list)
		{
			if (!string.IsNullOrEmpty(header))
			{
				stream.WriteLine($"### {header} (`{list.Count}`)");
			}
			stream.WriteLine(string.Join("<br/>\n", list.Select((string it) => "- " + it)));
		}

		public static void WriteEnum<T>(string header, StreamWriter stream) where T : Enum
		{
			WriteList(header, stream, (from it in Enum.GetValues(typeof(T)).OfType<T>()
				select it.ToString().ToLowerInvariant()).ToList());
		}
	}
}
namespace loaforcsSoundAPI.Reporting.Data
{
	public class SoundReport
	{
		public class PlayedSound
		{
			public string MatchString { get; private set; }

			public string Caller { get; private set; }

			public bool IsPlayOnAwake { get; private set; }

			public PlayedSound(string matchString, string caller, bool isPlayOnAwake)
			{
				MatchString = matchString;
				Caller = caller;
				IsPlayOnAwake = isPlayOnAwake;
				base..ctor();
			}

			public override bool Equals(object obj)
			{
				if (!(obj is PlayedSound other))
				{
					return false;
				}
				return Equals(other);
			}

			protected bool Equals(PlayedSound other)
			{
				if (MatchString == other.MatchString && Caller == other.Caller)
				{
					return IsPlayOnAwake == other.IsPlayOnAwake;
				}
				return false;
			}

			public override int GetHashCode()
			{
				return HashCode.Combine(MatchString, Caller, IsPlayOnAwake);
			}

			public string FormatForReport()
			{
				return $"Match String: {MatchString}, Caller: {Caller}, IsPlayOnAwake: {IsPlayOnAwake}";
			}
		}

		public DateTime StartedAt { get; private set; } = DateTime.Now;


		public List<PlayedSound> PlayedSounds { get; private set; } = new List<PlayedSound>();


		public List<string> SoundPackNames { get; private set; } = new List<string>();


		public int AudioClipsLoaded { get; set; }
	}
}
namespace loaforcsSoundAPI.Core
{
	public class AudioSourceAdditionalData
	{
		private SoundReplacementGroup _replacedWith;

		public AudioSource Source { get; private set; }

		internal SoundReplacementGroup ReplacedWith
		{
			get
			{
				return _replacedWith;
			}
			set
			{
				_replacedWith = value;
				if (RequiresUpdateFunction())
				{
					if (!SoundAPIAudioManager.liveAudioSourceData.Contains(this))
					{
						SoundAPIAudioManager.liveAudioSourceData.Add(this);
					}
				}
				else if (SoundAPIAudioManager.liveAudioSourceData.Contains(this))
				{
					SoundAPIAudioManager.liveAudioSourceData.Remove(this);
				}
			}
		}

		public bool DisableReplacing { get; private set; }

		public IContext CurrentContext { get; set; }

		internal AudioSourceAdditionalData(AudioSource source)
		{
			Source = source;
		}

		internal void Update()
		{
			if (RequiresUpdateFunction() && AudioSourceIsPlaying())
			{
				Debuggers.UpdateEveryFrame?.Log("success: updating every frame for " + ((Object)Source).name);
				IContext context = CurrentContext ?? DefaultConditionContext.DEFAULT;
				SoundInstance soundInstance = ReplacedWith.Sounds.FirstOrDefault((SoundInstance x) => x.Evaluate(context));
				if (soundInstance != null && !((Object)(object)soundInstance.Clip == (Object)(object)Source.clip))
				{
					Debuggers.UpdateEveryFrame?.Log("new clip found, swapping!!");
					float time = Source.time;
					Source.clip = soundInstance.Clip;
					Source.Play();
					Source.time = time;
					Debuggers.UpdateEveryFrame?.Log("new clip found, swapped");
				}
			}
		}

		private bool RequiresUpdateFunction()
		{
			if (ReplacedWith != null)
			{
				return ReplacedWith.Parent.UpdateEveryFrame;
			}
			return false;
		}

		private bool AudioSourceIsPlaying()
		{
			if (Object.op_Implicit((Object)(object)Source) && ((Behaviour)Source).enabled)
			{
				return Source.isPlaying;
			}
			return false;
		}

		public static AudioSourceAdditionalData GetOrCreate(AudioSource source)
		{
			if (SoundAPIAudioManager.audioSourceData.TryGetValue(source, out var value))
			{
				return value;
			}
			value = new AudioSourceAdditionalData(source);
			SoundAPIAudioManager.audioSourceData[source] = value;
			return value;
		}
	}
	internal static class Debuggers
	{
		internal static DebugLogSource AudioSourceAdditionalData;

		internal static DebugLogSource SoundReplacementLoader;

		internal static DebugLogSource SoundReplacementHandler;

		internal static DebugLogSource MatchStrings;

		internal static DebugLogSource ConditionsInfo;

		internal static DebugLogSource UpdateEveryFrame;

		internal static void Bind(ConfigFile file)
		{
			FieldInfo[] fields = typeof(Debuggers).GetFields(BindingFlags.Static | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (file.Bind<bool>("InternalDebugging", fieldInfo.Name, false, "Enable/Disable this DebugLogSource. Should only be true if you know what you are doing or have been asked to.").Value)
				{
					fieldInfo.SetValue(null, new DebugLogSource(fieldInfo.Name));
					loaforcsSoundAPI.Logger.LogDebug((object)("created a DebugLogSource for " + fieldInfo.Name + "!"));
				}
				else
				{
					fieldInfo.SetValue(null, null);
					loaforcsSoundAPI.Logger.LogDebug((object)("no DebugLogSource for " + fieldInfo.Name + "."));
				}
			}
		}
	}
	internal class DebugLogSource
	{
		[CompilerGenerated]
		private string <title>P;

		public DebugLogSource(string title)
		{
			<title>P = title;
			base..ctor();
		}

		internal void Log(object message)
		{
			loaforcsSoundAPI.Logger.LogDebug((object)$"[Debug-{<title>P}] {message}");
		}
	}
	internal class SoundAPIAudioManager : MonoBehaviour
	{
		internal static readonly Dictionary<AudioSource, AudioSourceAdditionalData> audioSourceData = new Dictionary<AudioSource, AudioSourceAdditionalData>();

		internal static readonly List<AudioSourceAdditionalData> liveAudioSourceData = new List<AudioSourceAdditionalData>();

		private static SoundAPIAudioManager Instance;

		private void Awake()
		{
			SceneManager.sceneLoaded += delegate
			{
				if (!Object.op_Implicit((Object)(object)Instance))
				{
					SpawnManager();
				}
				RunCleanup();
			};
		}

		internal static void SpawnManager()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			loaforcsSoundAPI.Logger.LogInfo((object)"Starting AudioManager.");
			GameObject val = new GameObject("SoundAPI_AudioManager");
			Object.DontDestroyOnLoad((Object)(object)val);
			Instance = val.AddComponent<SoundAPIAudioManager>();
		}

		private void Update()
		{
			Debuggers.UpdateEveryFrame?.Log("sanity check: soundapi audio manager is running!");
			foreach (AudioSourceAdditionalData liveAudioSourceDatum in liveAudioSourceData)
			{
				liveAudioSourceDatum.Update();
			}
		}

		private void OnDisable()
		{
			loaforcsSoundAPI.Logger.LogDebug((object)"manager disabled");
		}

		private void OnDestroy()
		{
			loaforcsSoundAPI.Logger.LogDebug((object)"manager destroyed");
		}

		private static void RunCleanup()
		{
			loaforcsSoundAPI.Logger.LogDebug((object)"cleaning up old audio source entries");
			AudioSource[] array = audioSourceData.Keys.ToArray();
			foreach (AudioSource val in array)
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					if (liveAudioSourceData.Contains(audioSourceData[val]))
					{
						liveAudioSourceData.Remove(audioSourceData[val]);
					}
					audioSourceData.Remove(val);
				}
			}
		}
	}
}
namespace loaforcsSoundAPI.Core.Util
{
	public class AdaptiveConfigEntry
	{
		public AdaptiveBool State { get; private set; }

		public bool DefaultValue { get; private set; }

		public bool? OverrideValue { get; set; }

		public bool Value => State switch
		{
			AdaptiveBool.Enabled => true, 
			AdaptiveBool.Disabled => false, 
			_ => OverrideValue ?? DefaultValue, 
		};

		public AdaptiveConfigEntry(AdaptiveBool state, bool defaultValue)
		{
			State = state;
			DefaultValue = defaultValue;
		}
	}
	public enum AdaptiveBool
	{
		Automatic,
		Enabled,
		Disabled
	}
	internal static class LogFormats
	{
		internal static string FormatFilePath(string path)
		{
			return $"plugins{Path.DirectorySeparatorChar}{Path.Combine(Path.GetRelativePath(Paths.PluginPath, path))}";
		}
	}
}
namespace loaforcsSoundAPI.Core.Util.Extensions
{
	internal static class AssemblyExtensions
	{
		internal static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
		{
			if (assembly == null)
			{
				throw new ArgumentNullException("assembly");
			}
			try
			{
				return assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return ex.Types.Where((Type t) => t != null);
			}
		}
	}
	public static class AsyncOperationExtensions
	{
		public static TaskAwaiter GetAwaiter(this AsyncOperation asyncOp)
		{
			TaskCompletionSource<AsyncOperation> tcs = new TaskCompletionSource<AsyncOperation>();
			asyncOp.completed += delegate(AsyncOperation operation)
			{
				tcs.SetResult(operation);
			};
			return ((Task)tcs.Task).GetAwaiter();
		}
	}
	public static class ConfigFileExtensions
	{
		public static AdaptiveConfigEntry BindAdaptive(this ConfigFile file, string section, string key, bool defaultValue, string description)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			AdaptiveBool value = file.Bind<AdaptiveBool>(section, key, AdaptiveBool.Automatic, new ConfigDescription($"{description}\nAutomatic default: {defaultValue}", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			return new AdaptiveConfigEntry(value, defaultValue);
		}
	}
	public static class ListExtensions
	{
		public static void AddUnique<T>(this List<T> list, T item)
		{
			if (!list.Contains(item))
			{
				list.Add(item);
			}
		}
	}
}
namespace loaforcsSoundAPI.Core.Patches
{
	[HarmonyPatch(typeof(AudioSource))]
	internal static class AudioSourcePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Play", new Type[] { })]
		[HarmonyPatch("Play", new Type[] { typeof(ulong) })]
		[HarmonyPatch("Play", new Type[] { typeof(double) })]
		private static bool Play(AudioSource __instance)
		{
			if (SoundReplacementHandler.TryReplaceAudio(__instance, __instance.clip, out var replacement))
			{
				if ((Object)(object)replacement == (Object)null)
				{
					return false;
				}
				__instance.clip = replacement;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("PlayOneShot", new Type[]
		{
			typeof(AudioClip),
			typeof(float)
		})]
		private static bool PlayOneShot(AudioSource __instance, ref AudioClip clip)
		{
			if (SoundReplacementHandler.TryReplaceAudio(__instance, clip, out var replacement))
			{
				if ((Object)(object)replacement == (Object)null)
				{
					return false;
				}
				clip = replacement;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GameObject))]
	internal static class GameObjectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("AddComponent", new Type[] { typeof(Type) })]
		internal static void NewAudioSource(GameObject __instance, ref Component __result)
		{
			Component obj = __result;
			AudioSource val = (AudioSource)(object)((obj is AudioSource) ? obj : null);
			if (val != null)
			{
				AudioSourceAdditionalData.GetOrCreate(val);
			}
		}
	}
	[HarmonyPatch(typeof(Logger))]
	internal static class LoggerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("LogMessage")]
		private static void ReenableAndSaveConfigs(object data)
		{
			if (data is string text && text == "Chainloader startup complete")
			{
				loaforcsSoundAPI.Logger.LogInfo((object)"Starting Sound-pack loading pipeline");
				SoundPackLoadPipeline.StartPipeline();
			}
		}
	}
	internal static class UnityObjectPatch
	{
		private static void InstantiatePatch(Object __result)
		{
			Debuggers.AudioSourceAdditionalData?.Log("aghuobr: " + __result.name);
			GameObject val = (GameObject)(object)((__result is GameObject) ? __result : null);
			if (val != null)
			{
				CheckInstantiationRecursively(val);
			}
		}

		internal static void Init(Harmony harmony)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			HarmonyMethod val = new HarmonyMethod(typeof(UnityObjectPatch).GetMethod("InstantiatePatch", BindingFlags.Static | BindingFlags.NonPublic));
			MethodInfo[] methods = typeof(Object).GetMethods();
			foreach (MethodInfo methodInfo in methods)
			{
				if (!(methodInfo.Name != "Instantiate"))
				{
					Debuggers.AudioSourceAdditionalData?.Log($"patching {methodInfo}");
					if (methodInfo.IsGenericMethod)
					{
						harmony.Patch((MethodBase)methodInfo.MakeGenericMethod(typeof(Object)), (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					}
					else
					{
						harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					}
				}
			}
		}

		private static void CheckInstantiationRecursively(GameObject gameObject)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			AudioSourceAdditionalData audioSourceAdditionalData = default(AudioSourceAdditionalData);
			if (gameObject.TryGetComponent<AudioSourceAdditionalData>(ref audioSourceAdditionalData))
			{
				return;
			}
			AudioSource[] components = gameObject.GetComponents<AudioSource>();
			foreach (AudioSource val in components)
			{
				AudioSourceAdditionalData.GetOrCreate(val);
				if (!val.playOnAwake)
				{
					continue;
				}
				AudioClip clip = val.clip;
				if (SoundReplacementHandler.TryReplaceAudio(val, clip, out var replacement))
				{
					val.Stop();
					if (!((Object)(object)replacement == (Object)null))
					{
						val.clip = replacement;
						val.Play();
					}
				}
				else
				{
					val.clip = clip;
					val.Play();
				}
			}
			foreach (Transform item in gameObject.transform)
			{
				Transform val2 = item;
				CheckInstantiationRecursively(((Component)val2).gameObject);
			}
		}
	}
}
namespace loaforcsSoundAPI.Core.Networking
{
	public abstract class NetworkAdapter
	{
		public abstract string Name { get; }

		public abstract void OnRegister();
	}
}
namespace loaforcsSoundAPI.Core.JSON
{
	public static class JSONDataLoader
	{
		private class MatchesJSONConverter : JsonConverter
		{
			public override bool CanConvert(Type objectType)
			{
				return objectType == typeof(List<string>);
			}

			public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Invalid comparison between Unknown and I4
				JToken val = JToken.Load(reader);
				if ((int)val.Type == 2)
				{
					return val.ToObject<List<string>>();
				}
				return new List<string> { ((object)val).ToString() };
			}

			public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
			{
				serializer.Serialize(writer, value);
			}
		}

		private class IncludePrivatePropertiesContractResolver : DefaultContractResolver
		{
			internal IncludePrivatePropertiesContractResolver()
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				((DefaultContractResolver)this).NamingStrategy = (NamingStrategy)new SnakeCaseNamingStrategy();
			}

			protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				JsonProperty val = ((DefaultContractResolver)this).CreateProperty(member, memberSerialization);
				if (!val.Writable && member is PropertyInfo propertyInfo)
				{
					val.Writable = propertyInfo.GetSetMethod(nonPublic: true) != null;
				}
				return val;
			}
		}

		private class ConditionConverter : JsonConverter<Condition>
		{
			public override Condition ReadJson(JsonReader reader, Type objectType, Condition existingValue, bool hasExistingValue, JsonSerializer serializer)
			{
				JObject val = JObject.Load(reader);
				string text = ((object)val["type"])?.ToString();
				if (string.IsNullOrEmpty(text))
				{
					return new InvalidCondition(null);
				}
				Condition condition = SoundPackDataHandler.CreateCondition(text);
				if (condition == null)
				{
					return null;
				}
				serializer.Populate(((JToken)val).CreateReader(), (object)condition);
				if (condition.Constant == true)
				{
					if (!condition.Evaluate(DefaultConditionContext.DEFAULT))
					{
						return ConstantCondition.FALSE;
					}
					return ConstantCondition.TRUE;
				}
				return condition;
			}

			public override void WriteJson(JsonWriter writer, Condition value, JsonSerializer serializer)
			{
				throw new NotImplementedException("no.");
			}
		}

		private static readonly JsonSerializerSettings _settings = new JsonSerializerSettings
		{
			ContractResolver = (IContractResolver)(object)new IncludePrivatePropertiesContractResolver(),
			Converters = new List<JsonConverter>(2)
			{
				(JsonConverter)(object)new MatchesJSONConverter(),
				(JsonConverter)(object)new ConditionConverter()
			}
		};

		public static T LoadFromFile<T>(string path)
		{
			//IL_0061: Expected O, but got Unknown
			string text = File.ReadAllText(path);
			try
			{
				T val = JsonConvert.DeserializeObject<T>(text, _settings);
				if ((object)val is IFilePathAware filePathAware)
				{
					filePathAware.FilePath = path;
				}
				if ((object)val is Conditional conditional && conditional.Condition != null)
				{
					conditional.Condition.Parent = conditional;
					conditional.Condition.OnRegistered();
				}
				return val;
			}
			catch (JsonReaderException val2)
			{
				JsonReaderException val3 = val2;
				loaforcsSoundAPI.Logger.LogError((object)$"Failed to read json file: 'plugins{Path.DirectorySeparatorChar}{Path.GetRelativePath(Paths.PluginPath, path)}'");
				loaforcsSoundAPI.Logger.LogError((object)((Exception)(object)val3).Message);
				string[] array = text.Split("\n");
				int num = int.MaxValue;
				for (int i = Mathf.Max(0, val3.LineNumber - 3); i < Mathf.Min(array.Length, val3.LineNumber + 3); i++)
				{
					int num2 = array[i].TakeWhile(char.IsWhiteSpace).Count();
					num = Mathf.Min(num, num2);
				}
				for (int j = Mathf.Max(0, val3.LineNumber - 3); j < Mathf.Min(array.Length, val3.LineNumber + 3); j++)
				{
					string text2 = $"{(j + 1).ToString(),-5}|  ";
					string text3 = array[j];
					int num3 = Mathf.Min(array[j].Length, num);
					string text4 = text2 + text3.Substring(num3, text3.Length - num3).TrimEnd();
					if (j + 1 == val3.LineNumber)
					{
						text4 += " // <- HERE";
					}
					loaforcsSoundAPI.Logger.LogError((object)text4);
				}
			}
			return default(T);
		}
	}
}
namespace loaforcsSoundAPI.Core.Data
{
	public interface IFilePathAware
	{
		string FilePath { get; internal set; }
	}
	public interface IValidatable
	{
		public enum ResultType
		{
			WARN,
			FAIL
		}

		public class ValidationResult
		{
			public ResultType Status { get; private set; }

			public string Reason { get; private set; }

			public ValidationResult(ResultType resultType, string reason = null)
			{
				Status = resultType;
				Reason = reason ?? string.Empty;
				base..ctor();
			}
		}

		private static readonly StringBuilder _stringBuilder = new StringBuilder();

		List<ValidationResult> Validate();

		internal static bool LogAndCheckValidationResult(string context, List<ValidationResult> results, ManualLogSource logger)
		{
			if (results.Count == 0)
			{
				return true;
			}
			int num = 0;
			int num2 = 0;
			foreach (ValidationResult result in results)
			{
				switch (result.Status)
				{
				case ResultType.WARN:
					num++;
					break;
				case ResultType.FAIL:
					num2++;
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
			}
			_stringBuilder.Clear();
			if (num2 != 0)
			{
				_stringBuilder.Append(num2);
				_stringBuilder.Append(" fail(s)");
			}
			if (num != 0)
			{
				if (num2 != 0)
				{
					_stringBuilder.Append(" and ");
				}
				_stringBuilder.Append(num);
				_stringBuilder.Append(" warning(s)");
			}
			_stringBuilder.Append(" while ");
			_stringBuilder.Append(context);
			_stringBuilder.Append(": ");
			if (num2 != 0)
			{
				logger.LogError((object)_stringBuilder);
			}
			else
			{
				logger.LogWarning((object)_stringBuilder);
			}
			foreach (ValidationResult result2 in results)
			{
				switch (result2.Status)
				{
				case ResultType.WARN:
					logger.LogWarning((object)("WARN: " + result2.Reason));
					break;
				case ResultType.FAIL:
					logger.LogError((object)("FAIL: " + result2.Reason));
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
			}
			return num2 != 0;
		}
	}
}

BeepInEx/plugins/Magic_Wesley-Wesleys_Enemies/WesleysEnemies.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.AI;

[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("Magic_Wesley")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Magic_Wesley")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WesleysEnemies")]
[assembly: AssemblyTitle("WesleysEnemies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WesleysEnemies
{
	[BepInPlugin("WesleysEnemies", "WesleysEnemies", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class WesleysEnemies : BaseUnityPlugin
	{
		private void Awake()
		{
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "wesleysenemies_enemyprefabs");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			EnemySetup val2 = val.LoadAsset<EnemySetup>("EnemySetup - Gusher");
			EnemySetup val3 = val.LoadAsset<EnemySetup>("EnemySetup - Roaster");
			Enemies.RegisterEnemy(val2);
			Enemies.RegisterEnemy(val3);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "WesleysEnemies";

		public const string PLUGIN_NAME = "WesleysEnemies";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace WesleysEnemies.AI
{
	internal class Gusher : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			StartListen,
			Listen,
			EndListen,
			Attack,
			Wander,
			Stun,
			Despawn,
			Flee
		}

		private LayerMask layermask;

		private LayerMask playerLayermask;

		private Enemy _enemy;

		private PhotonView _photonView;

		public bool Terminator = false;

		private float _speedChangeCooldown;

		internal float _animSpeed;

		private float _despawnCool;

		private bool _stateImpulse;

		internal bool _deathImpulse;

		internal bool _despawnImpulse;

		internal bool _roamImpulse;

		internal bool _attackImpulse;

		internal bool _hearImpulse;

		internal bool _isListening;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Vector3 _agentDestination;

		private Vector3 _investigatePoint;

		private int _hearCount;

		private int _hurtAmount;

		private bool _hurtImpulse;

		private float hurtLerp;

		private float _hearCooldown;

		private Material _hurtMaterial;

		[Header("State")]
		[SerializeField]
		public State currentState;

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

		[Header("Animation")]
		[SerializeField]
		private AnimationCurve hurtCurve;

		[SerializeField]
		private SkinnedMeshRenderer _skinnedMeshRenderer;

		[Header("Rotation and LookAt")]
		public SpringQuaternion horizontalRotationSpring;

		[SerializeField]
		private Transform _listenPoint;

		private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _rigidbody => _enemy.Rigidbody;

		private EnemyParent _enemyParent => _enemy.EnemyParent;

		private EnemyVision _Vision => _enemy.Vision;

		public Enemy Enemy => _enemy;

		private void Awake()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			layermask = LayerMask.op_Implicit(LayerMask.GetMask(new string[5] { "Default", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "StaticGrabObject" }));
			playerLayermask = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "Player" }));
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			if ((Object)(object)_skinnedMeshRenderer != (Object)null)
			{
				_hurtMaterial = ((Renderer)_skinnedMeshRenderer).material;
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			if ((!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) && LevelGenerator.Instance.Generated)
			{
				if (!_enemy.IsStunned())
				{
					switch (currentState)
					{
					case State.Spawn:
						StateSpawn();
						break;
					case State.Listen:
						StateListen();
						break;
					case State.StartListen:
						StateStartListen();
						break;
					case State.EndListen:
						StateEndListen();
						break;
					case State.Attack:
						StateAttack();
						break;
					case State.Wander:
						StateWander();
						break;
					case State.Flee:
						StateFlee();
						break;
					case State.Stun:
						StateStun();
						break;
					case State.Despawn:
						StateDespawn();
						break;
					default:
						throw new ArgumentOutOfRangeException();
					}
					RotationLogic();
				}
				else
				{
					UpdateState(State.Stun);
					StateStun();
				}
				HurtEffect();
			}
			if (_despawnImpulse)
			{
				if (_despawnCool < 2f)
				{
					_despawnCool += Time.deltaTime;
				}
				else
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

		private void StateSpawn()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
				_stateImpulse = false;
				stateTimer = 2f;
				_navMeshAgent.Agent.speed = 1f;
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Wander);
			}
		}

		private void StateListen()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				if (Terminator)
				{
					stateTimer = Random.Range(4f, 8f);
				}
				else
				{
					stateTimer = Random.Range(18f, 26f);
				}
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
			}
			if (!SemiFunc.EnemySpawnIdlePause())
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					_hearCount = 0;
					UpdateState(State.EndListen);
				}
				if (_hearCooldown > 0f)
				{
					_hearCooldown -= Time.deltaTime;
				}
			}
		}

		private void StateStartListen()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_hearCount = 0;
				_isListening = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
					_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 1f });
				}
				_stateImpulse = false;
				stateTimer = 1f;
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Listen);
			}
		}

		private void StateEndListen()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				stateTimer = 1f;
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				if (SemiFunc.EnemyForceLeave(_enemy))
				{
					UpdateState(State.Flee);
				}
				else
				{
					UpdateState(State.Wander);
				}
			}
		}

		private void StateWander()
		{
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_isListening = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
					_photonView.RPC("RoamImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
				if (Terminator)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 6f });
					}
					_navMeshAgent.Agent.speed = 12f;
				}
				else
				{
					_navMeshAgent.Agent.speed = 0.05f;
				}
				bool flag = false;
				LevelPoint val;
				if (Terminator)
				{
					stateTimer = Random.Range(4f, 10f);
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 5f, 15f);
				}
				else
				{
					stateTimer = Random.Range(8f, 12f);
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 25f);
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((NavMeshHit)(ref val2)).position;
					flag = true;
				}
				if (flag)
				{
					_enemy.Rigidbody.notMovingTimer = 0f;
					_stateImpulse = false;
					_navMeshAgent.SetDestination(_agentDestination);
				}
				return;
			}
			_navMeshAgent.SetDestination(_agentDestination);
			if (_navMeshAgent.Agent.speed <= 4f && !Terminator)
			{
				if (_speedChangeCooldown <= 0f)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { _navMeshAgent.Agent.speed / 1.5f + 1f });
						_speedChangeCooldown = 1f;
					}
				}
				else
				{
					_speedChangeCooldown -= Time.deltaTime;
				}
				NavMeshAgent agent = _navMeshAgent.Agent;
				agent.speed += 0.4f * Time.deltaTime;
			}
			if (_enemy.Rigidbody.notMovingTimer > 2f)
			{
				stateTimer -= Time.deltaTime;
			}
			if (stateTimer <= 0f || CheckPathCompletion())
			{
				UpdateState(State.StartListen);
			}
		}

		private void StateFlee()
		{
			//IL_00e5: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_isListening = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
					_photonView.RPC("RoamImpulseRPC", (RpcTarget)0, Array.Empty<object>());
					_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 7f });
				}
				_navMeshAgent.Agent.speed = 24f;
				stateTimer = 5f;
				stateHaltTimer = 1f;
				bool flag = false;
				LevelPoint val = ((!Terminator) ? SemiFunc.LevelPointGet(((Component)this).transform.position, 15f, 80f) : SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 30f));
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((Component)val).transform.position;
					flag = true;
				}
				if (flag)
				{
					_navMeshAgent.SetDestination(_agentDestination);
					_enemy.Rigidbody.notMovingTimer = 0f;
					_stateImpulse = false;
				}
				return;
			}
			if (_enemy.Rigidbody.notMovingTimer > 2f)
			{
				stateTimer -= Time.deltaTime;
			}
			stateHaltTimer -= Time.deltaTime;
			if (stateHaltTimer <= 0f)
			{
				SemiFunc.EnemyCartJump(_enemy);
				if (stateTimer <= 0f || CheckPathCompletion())
				{
					SemiFunc.EnemyCartJumpReset(_enemy);
					UpdateState(State.StartListen);
				}
			}
		}

		private void StateAttack()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("AttackImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
				stateTimer = 5f;
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
				return;
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Flee);
				_isListening = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
				}
			}
		}

		private void StateDespawn()
		{
		}

		private void StateStun()
		{
			if (_stateImpulse)
			{
				_stateImpulse = false;
			}
			if (!_enemy.IsStunned())
			{
				_hearCount = 0;
				_isListening = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
					_photonView.RPC("AttackImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
				UpdateState(State.Attack);
			}
		}

		private void UpdateState(State _newState)
		{
			if (currentState != _newState)
			{
				currentState = _newState;
				stateTimer = 0f;
				_stateImpulse = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
				}
				else if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			currentState = _state;
		}

		[PunRPC]
		private void RoamImpulseRPC()
		{
			_roamImpulse = true;
		}

		[PunRPC]
		private void AttackImpulseRPC()
		{
			_attackImpulse = true;
		}

		[PunRPC]
		private void HearImpulseRPC()
		{
			_hearImpulse = true;
		}

		[PunRPC]
		private void IsListeningRPC(bool value)
		{
			_isListening = value;
		}

		[PunRPC]
		private void ChangeAnimSpeedRPC(float value)
		{
			_animSpeed = value;
		}

		private bool CheckPathCompletion()
		{
			NavMeshAgent agent = _navMeshAgent.Agent;
			float remainingDistance = agent.remainingDistance;
			if (remainingDistance <= 0.07f)
			{
				return true;
			}
			return false;
		}

		private void RotationLogic()
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (currentState != State.Stun && currentState != State.StartListen && currentState != State.Listen && currentState != State.EndListen && currentState != State.Attack)
			{
				horizontalRotationSpring.speed = 8f;
				horizontalRotationSpring.damping = 0.85f;
				Vector3 normalized = ((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized;
				if (((Vector3)(ref normalized)).magnitude > 0.1f)
				{
					_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
				}
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

		private void HurtEffect()
		{
			if (!_hurtImpulse)
			{
				return;
			}
			hurtLerp += 2.5f * Time.deltaTime;
			hurtLerp = Mathf.Clamp01(hurtLerp);
			if ((Object)(object)_hurtMaterial != (Object)null)
			{
				_hurtMaterial.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
			}
			if (hurtLerp >= 1f)
			{
				hurtLerp = 0f;
				_hurtImpulse = false;
				if ((Object)(object)_hurtMaterial != (Object)null)
				{
					_hurtMaterial.SetFloat(_hurtAmount, 0f);
				}
			}
		}

		public void OnInvestigate()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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)
			if (currentState != State.Listen || !(_hearCooldown <= 0f))
			{
				return;
			}
			_investigatePoint = _enemy.StateInvestigate.onInvestigateTriggeredPosition;
			Vector3 position = _listenPoint.position;
			if (!(Vector3.Distance(_investigatePoint, position) < 14f))
			{
				return;
			}
			int num;
			float hearCooldown;
			if (Terminator)
			{
				num = 2;
				hearCooldown = 1f;
			}
			else
			{
				num = 4;
				hearCooldown = 2f;
			}
			if (_hearCount < num)
			{
				_hearCooldown = hearCooldown;
				_hearCount++;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("HearImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
			}
			else
			{
				_stateImpulse = true;
				_hearCount = 0;
				UpdateState(State.Attack);
			}
		}

		public void OnSpawn()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(_enemy))
			{
				UpdateState(State.Spawn);
			}
		}

		public void OnGrab()
		{
			if (currentState == State.Listen)
			{
				_hearCount = 0;
				UpdateState(State.Attack);
				_stateImpulse = true;
			}
		}

		public void OnHurt()
		{
			_hurtImpulse = true;
		}

		public void OnDeath()
		{
			_deathImpulse = true;
			_despawnImpulse = true;
			_enemy.Stunned = false;
			UpdateState(State.Despawn);
		}
	}
	internal class GusherAnimationController : MonoBehaviour
	{
		[Header("References")]
		public Gusher Controller;

		public Animator animator;

		[Header("Particles")]
		public ParticleSystem[] deathParticles;

		public ParticleSystem[] pukeParticles;

		public ParticleSystem[] pukeSplashParticles;

		public ParticleSystem[] pukeEndParticles;

		[Header("Sounds")]
		[SerializeField]
		private Sound roamSounds;

		[SerializeField]
		private Sound hearSounds;

		[SerializeField]
		private Sound attackSounds;

		[SerializeField]
		private Sound hurtSounds;

		[SerializeField]
		private Sound deathSounds;

		private void Update()
		{
			if (Controller.Enemy.IsStunned())
			{
				animator.SetTrigger("stun");
				EndPukePart();
				ChangeAnimSpeed(1f);
			}
			if (Controller._roamImpulse)
			{
				Controller._roamImpulse = false;
				animator.SetTrigger("roam");
			}
			if (Controller._attackImpulse)
			{
				Controller._attackImpulse = false;
				animator.SetTrigger("attack");
			}
			if (Controller._deathImpulse)
			{
				Controller._deathImpulse = false;
				animator.SetTrigger("death");
				ParticleSystem[] array = deathParticles;
				for (int i = 0; i < array.Length; i++)
				{
					array[i].Play();
				}
			}
			if (Controller._hearImpulse)
			{
				Controller._hearImpulse = false;
				animator.SetTrigger("hear");
			}
			if (Controller._isListening)
			{
				animator.SetBool("isListening", true);
			}
			else
			{
				animator.SetBool("isListening", false);
			}
			if (Controller._animSpeed != animator.speed)
			{
				animator.speed = Controller._animSpeed;
			}
		}

		public void ChangeAnimSpeed(float value)
		{
			animator.speed = value;
		}

		public void PlayRoamSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			roamSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayHurtSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			hurtSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayDeathSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			deathSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayAttackSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			attackSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayHearSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			hearSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void StartPukePart()
		{
			ParticleSystem[] array = pukeSplashParticles;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Play();
			}
			ParticleSystem[] array2 = pukeParticles;
			for (int j = 0; j < array2.Length; j++)
			{
				array2[j].Play();
			}
		}

		public void StartRandomPukePart()
		{
			ParticleSystem[] array = pukeSplashParticles;
			ParticleSystem[] array2 = pukeParticles;
			int num = Random.Range(0, array.Length);
			array[num].Play();
			array2[num].Play();
		}

		public void EndPukePart()
		{
			ParticleSystem[] array = pukeEndParticles;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Play();
			}
			ParticleSystem[] array2 = pukeParticles;
			for (int j = 0; j < array2.Length; j++)
			{
				array2[j].Stop();
			}
		}
	}
	internal class LostDroid : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Idle,
			Wander,
			Stun,
			Notice,
			Follow,
			Transform,
			RAttack,
			Despawn
		}

		private Enemy _enemy;

		private PhotonView _photonView;

		public bool Terminator = false;

		public bool Transformed = false;

		private bool _stateImpulse = false;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Vector3 _agentDestination;

		private Vector3 _targetPosition;

		private PlayerAvatar _targetPlayer;

		private Material _hurtMaterial;

		private float _overrideAgentLerp;

		private bool _hurtImpulse;

		private float hurtLerp;

		private int _hurtAmount;

		internal bool _isWalking;

		internal bool _isSprinting;

		internal bool _isTurning;

		internal bool _transformImpulse;

		private float _transformCountMax;

		private float _transformCount;

		[Header("State")]
		[SerializeField]
		public State currentState;

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

		[Header("Animation")]
		[SerializeField]
		private AnimationCurve hurtCurve;

		[SerializeField]
		private SkinnedMeshRenderer _skinnedMeshRenderer;

		[Header("Rotation and LookAt")]
		public SpringQuaternion horizontalRotationSpring;

		private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _rigidbody => _enemy.Rigidbody;

		private EnemyParent _enemyParent => _enemy.EnemyParent;

		private EnemyVision _Vision => _enemy.Vision;

		public Enemy Enemy => _enemy;

		private void Awake()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			_transformCount = 8f;
			_transformCountMax = Random.Range(8f, 18f);
			if ((Object)(object)_skinnedMeshRenderer != (Object)null)
			{
				_hurtMaterial = ((Renderer)_skinnedMeshRenderer).material;
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			if ((GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.IsStunned())
			{
				switch (currentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Wander:
					StateWander();
					break;
				case State.Stun:
					StateStun();
					break;
				case State.Notice:
					StateNotice();
					break;
				case State.Idle:
					StateIdle();
					break;
				case State.Follow:
					StateFollow();
					break;
				case State.Despawn:
					StateDespawn();
					break;
				case State.Transform:
					StateTransform();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				case State.RAttack:
					break;
				}
				RotationLogic();
			}
			else
			{
				UpdateState(State.Stun);
				StateStun();
			}
			HurtEffect();
			if (_transformCount < _transformCountMax)
			{
				_transformCount += Time.deltaTime * 0.25f;
			}
		}

		private void StateSpawn()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				stateTimer = 2f;
			}
			else
			{
				UpdateState(State.Wander);
			}
		}

		private void StateIdle()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				stateTimer = Random.Range(6f, 8f);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
			}
			else
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Wander);
				}
			}
		}

		private void StateWander()
		{
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				bool flag = false;
				LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 20f);
				stateTimer = 8f;
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 5f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 4f, ref val2, 8f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((NavMeshHit)(ref val2)).position;
					flag = true;
				}
				if (flag)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { true });
					}
					_enemy.Rigidbody.notMovingTimer = 0f;
					_stateImpulse = false;
					_navMeshAgent.Agent.speed = 1.4f;
					_navMeshAgent.SetDestination(_agentDestination);
				}
			}
			else
			{
				_navMeshAgent.SetDestination(_agentDestination);
				if (_enemy.Rigidbody.notMovingTimer > 2f)
				{
					stateTimer -= Time.deltaTime;
				}
				if (stateTimer <= 0f || CheckPathCompletion())
				{
					UpdateState(State.Idle);
				}
			}
		}

		private void StateDespawn()
		{
		}

		private void StateTransform()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				stateTimer = 4f;
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("TransformImpulseRPC", (RpcTarget)0, Array.Empty<object>());
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
			}
			else
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.RAttack);
					Transformed = true;
				}
			}
		}

		private void StateStun()
		{
			if (_stateImpulse)
			{
				_stateImpulse = false;
			}
			if (!_enemy.IsStunned())
			{
				UpdateState(State.Transform);
			}
		}

		private void StateFollow()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				stateTimer = 8f;
				_stateImpulse = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { true });
					_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { false });
				}
				return;
			}
			if (Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position) > 2f)
			{
				_overrideAgentLerp -= Time.deltaTime / 0.01f;
				_enemy.Rigidbody.OverrideFollowPosition(0.2f, 5f, 30f);
				_overrideAgentLerp = Mathf.Clamp(_overrideAgentLerp, 0f, 1f);
				float num = 25f;
				float num2 = 25f;
				float num3 = Mathf.Lerp(_enemy.NavMeshAgent.DefaultSpeed, num, _overrideAgentLerp);
				float num4 = Mathf.Lerp(_enemy.Rigidbody.positionSpeedChase, num2, _overrideAgentLerp);
				_enemy.NavMeshAgent.OverrideAgent(num3 * 2f, _enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
				_enemy.Rigidbody.OverrideFollowPosition(1f, num4 * 2f, -1f);
				_targetPosition = ((Component)_targetPlayer).transform.position;
				_enemy.NavMeshAgent.SetDestination(_targetPosition);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { true });
				}
			}
			else
			{
				_navMeshAgent.Agent.ResetPath();
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
			}
			if (_transformCount > 0f)
			{
				_transformCount -= Time.deltaTime * 0.8f;
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Idle);
				}
			}
			else
			{
				UpdateState(State.Transform);
			}
		}

		private void StateNotice()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				stateTimer = Random.Range(2f, 4f);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
			}
			else
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Follow);
				}
			}
		}

		private void UpdateState(State _newState)
		{
			if (currentState != _newState)
			{
				currentState = _newState;
				stateTimer = 0f;
				_stateImpulse = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
				}
				else if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			currentState = _state;
			Debug.Log((object)_state);
		}

		[PunRPC]
		private void IsWalkingRPC(bool value)
		{
			_isWalking = value;
			Debug.Log((object)_isWalking);
		}

		[PunRPC]
		private void IsSprintingRPC(bool value)
		{
			_isSprinting = value;
			Debug.Log((object)_isSprinting);
		}

		[PunRPC]
		private void IsTurningRPC(bool value)
		{
			_isTurning = value;
			Debug.Log((object)_isTurning);
		}

		[PunRPC]
		private void TransformImpulseRPC()
		{
			_transformImpulse = true;
		}

		[PunRPC]
		private void TargetPlayerRPC(int _playerID)
		{
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (player.photonView.ViewID == _playerID)
				{
					_targetPlayer = player;
				}
			}
		}

		public void OnSpawn()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(_enemy))
			{
				UpdateState(State.Spawn);
			}
		}

		public void OnGrab()
		{
			_targetPlayer = _enemy.Vision.onVisionTriggeredPlayer;
			if (GameManager.Multiplayer())
			{
				_photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { _targetPlayer.photonView.ViewID });
			}
			UpdateState(State.Notice);
		}

		public void OnVision()
		{
			if (Transformed)
			{
				return;
			}
			if (currentState != State.Stun && currentState != State.Despawn && currentState != State.Notice && currentState != State.Follow)
			{
				_targetPlayer = _enemy.Vision.onVisionTriggeredPlayer;
				UpdateState(State.Notice);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { _targetPlayer.photonView.ViewID });
				}
				Debug.Log((object)"Player spotted");
				Debug.Log((object)_targetPlayer);
			}
			else if ((currentState == State.Follow || currentState == State.Notice) && (Object)(object)_targetPlayer == (Object)(object)_enemy.Vision.onVisionTriggeredPlayer)
			{
				stateTimer = MathF.Max(stateTimer, 4f);
			}
		}

		private void RotationLogic()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0107: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (currentState != State.Stun && currentState != State.Idle && currentState != State.Notice)
			{
				horizontalRotationSpring.speed = 10f;
				horizontalRotationSpring.damping = 1f;
				Vector3 normalized = ((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized;
				if (((Vector3)(ref normalized)).magnitude > 0.1f)
				{
					_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
				}
			}
			if (currentState == State.Notice)
			{
				horizontalRotationSpring.speed = 10f;
				horizontalRotationSpring.damping = 1f;
				Vector3 val = ((Component)_targetPlayer).transform.position - ((Component)this).transform.position;
				_horizontalRotationTarget = Quaternion.LookRotation(val, Vector3.up);
				((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

		private void HurtEffect()
		{
			if (!_hurtImpulse)
			{
				return;
			}
			hurtLerp += 2.5f * Time.deltaTime;
			hurtLerp = Mathf.Clamp01(hurtLerp);
			if ((Object)(object)_hurtMaterial != (Object)null)
			{
				_hurtMaterial.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
			}
			if (hurtLerp >= 1f)
			{
				hurtLerp = 0f;
				_hurtImpulse = false;
				if ((Object)(object)_hurtMaterial != (Object)null)
				{
					_hurtMaterial.SetFloat(_hurtAmount, 0f);
				}
			}
		}

		private bool CheckPathCompletion()
		{
			NavMeshAgent agent = _navMeshAgent.Agent;
			float remainingDistance = agent.remainingDistance;
			if (remainingDistance <= 0.07f)
			{
				Debug.Log((object)"Path completed");
				return true;
			}
			return false;
		}
	}
	internal class LostDroidAnimationController : MonoBehaviour
	{
		[Header("References")]
		public LostDroid Controller;

		public Animator animator;

		private void Update()
		{
			animator.SetBool("isSprinting", Controller._isSprinting);
			animator.SetBool("isWalking", Controller._isWalking);
			animator.SetBool("isTurning", Controller._isTurning);
			if (Controller.Enemy.IsStunned())
			{
				animator.SetTrigger("stun");
			}
			if (Controller._transformImpulse)
			{
				Controller._transformImpulse = false;
				animator.SetTrigger("transform");
			}
		}
	}
	internal class Popper : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Idle,
			Wander,
			Stun,
			Despawn
		}

		private Enemy _enemy;

		private PhotonView _photonView;

		public bool Terminator = false;

		private bool _stateImpulse = false;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Material _hurtMaterial;

		private bool _hurtImpulse;

		private float hurtLerp;

		private int _hurtAmount;

		[Header("State")]
		[SerializeField]
		public State currentState;

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

		[Header("Animation")]
		[SerializeField]
		private AnimationCurve hurtCurve;

		[SerializeField]
		private SkinnedMeshRenderer _skinnedMeshRenderer;

		[Header("Rotation and LookAt")]
		public SpringQuaternion horizontalRotationSpring;

		private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _rigidbody => _enemy.Rigidbody;

		private EnemyParent _enemyParent => _enemy.EnemyParent;

		private EnemyVision _Vision => _enemy.Vision;

		public Enemy Enemy => _enemy;

		private void Awake()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			if ((Object)(object)_skinnedMeshRenderer != (Object)null)
			{
				_hurtMaterial = ((Renderer)_skinnedMeshRenderer).material;
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			if ((GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.IsStunned())
			{
				switch (currentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Wander:
					StateWander();
					break;
				case State.Idle:
					StateIdle();
					break;
				case State.Despawn:
					StateDespawn();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
				RotationLogic();
			}
			else
			{
				UpdateState(State.Stun);
				StateStun();
			}
			HurtEffect();
		}

		private void StateSpawn()
		{
		}

		private void StateWander()
		{
		}

		private void StateIdle()
		{
		}

		private void StateDespawn()
		{
		}

		private void StateStun()
		{
		}

		private void UpdateState(State _newState)
		{
			if (currentState != _newState)
			{
				currentState = _newState;
				stateTimer = 0f;
				_stateImpulse = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
				}
				else if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			currentState = _state;
			Debug.Log((object)_state);
		}

		private void RotationLogic()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_0051: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (currentState != State.Stun && currentState != State.Idle)
			{
				horizontalRotationSpring.speed = 8f;
				horizontalRotationSpring.damping = 0.85f;
				Vector3 normalized = ((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized;
				if (((Vector3)(ref normalized)).magnitude > 0.1f)
				{
					_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
				}
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

		private void HurtEffect()
		{
			if (!_hurtImpulse)
			{
				return;
			}
			hurtLerp += 2.5f * Time.deltaTime;
			hurtLerp = Mathf.Clamp01(hurtLerp);
			if ((Object)(object)_hurtMaterial != (Object)null)
			{
				_hurtMaterial.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
			}
			if (hurtLerp >= 1f)
			{
				hurtLerp = 0f;
				_hurtImpulse = false;
				if ((Object)(object)_hurtMaterial != (Object)null)
				{
					_hurtMaterial.SetFloat(_hurtAmount, 0f);
				}
			}
		}
	}
	internal class PopperAnimationController : MonoBehaviour
	{
		[Header("References")]
		public Popper Controller;

		public Animator animator;
	}
	internal class TheLady : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Idle,
			Wander,
			Stun,
			Despawn
		}

		private Enemy _enemy;

		private PhotonView _photonView;

		public bool Terminator = false;

		private bool _stateImpulse = false;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Material _hurtMaterial;

		private bool _hurtImpulse;

		private float hurtLerp;

		private int _hurtAmount;

		[Header("State")]
		[SerializeField]
		public State currentState;

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

		[Header("Animation")]
		[SerializeField]
		private AnimationCurve hurtCurve;

		[SerializeField]
		private SkinnedMeshRenderer _skinnedMeshRenderer;

		[Header("Rotation and LookAt")]
		public SpringQuaternion horizontalRotationSpring;

		private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _rigidbody => _enemy.Rigidbody;

		private EnemyParent _enemyParent => _enemy.EnemyParent;

		private EnemyVision _Vision => _enemy.Vision;

		public Enemy Enemy => _enemy;

		private void Awake()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			if ((Object)(object)_skinnedMeshRenderer != (Object)null)
			{
				_hurtMaterial = ((Renderer)_skinnedMeshRenderer).material;
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			if ((GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.IsStunned())
			{
				switch (currentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Wander:
					StateWander();
					break;
				case State.Idle:
					StateIdle();
					break;
				case State.Despawn:
					StateDespawn();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
				RotationLogic();
			}
			else
			{
				UpdateState(State.Stun);
				StateStun();
			}
			HurtEffect();
		}

		private void StateSpawn()
		{
		}

		private void StateWander()
		{
		}

		private void StateIdle()
		{
		}

		private void StateDespawn()
		{
		}

		private void StateStun()
		{
		}

		private void UpdateState(State _newState)
		{
			if (currentState != _newState)
			{
				currentState = _newState;
				stateTimer = 0f;
				_stateImpulse = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
				}
				else if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			currentState = _state;
			Debug.Log((object)_state);
		}

		private void RotationLogic()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_0051: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (currentState != State.Stun && currentState != State.Idle)
			{
				horizontalRotationSpring.speed = 8f;
				horizontalRotationSpring.damping = 0.85f;
				Vector3 normalized = ((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized;
				if (((Vector3)(ref normalized)).magnitude > 0.1f)
				{
					_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
				}
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

		private void HurtEffect()
		{
			if (!_hurtImpulse)
			{
				return;
			}
			hurtLerp += 2.5f * Time.deltaTime;
			hurtLerp = Mathf.Clamp01(hurtLerp);
			if ((Object)(object)_hurtMaterial != (Object)null)
			{
				_hurtMaterial.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
			}
			if (hurtLerp >= 1f)
			{
				hurtLerp = 0f;
				_hurtImpulse = false;
				if ((Object)(object)_hurtMaterial != (Object)null)
				{
					_hurtMaterial.SetFloat(_hurtAmount, 0f);
				}
			}
		}
	}
	internal class TheLadyAnimationController : MonoBehaviour
	{
		[Header("References")]
		public TheLady Controller;

		public Animator animator;
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

BeepInEx/plugins/Magic_Wesley-Wesleys_Valuables/WesleysItemProj.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using REPOLib.Modules;
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("WesleysItemProj")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WesleysItemProj")]
[assembly: AssemblyTitle("WesleysItemProj")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WesleysItemProj;

[BepInPlugin("MagicWesley.WesleysItems", "WesleysItems", "0.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class WesleysItems : BaseUnityPlugin
{
	private void Awake()
	{
		string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		string text = Path.Combine(directoryName, "wesleysitems_itemprefabs");
		AssetBundle val = AssetBundle.LoadFromFile(text);
		GameObject val2 = val.LoadAsset<GameObject>("BeholdersEye");
		GameObject val3 = val.LoadAsset<GameObject>("BiomontyDisplay");
		GameObject val4 = val.LoadAsset<GameObject>("Pickle");
		GameObject val5 = val.LoadAsset<GameObject>("PickleJar");
		GameObject val6 = val.LoadAsset<GameObject>("SpikyEye");
		GameObject val7 = val.LoadAsset<GameObject>("BananaHolder");
		GameObject val8 = val.LoadAsset<GameObject>("Webley");
		List<string> list = new List<string> { "Valuables - Arctic" };
		List<string> list2 = new List<string> { "Valuables - Wizard", "Valuables - Manor" };
		List<string> list3 = new List<string> { "Valuables - Manor" };
		List<string> list4 = new List<string> { "Valuables - Wizard", "Valuables - Manor", "Valuables - Arctic", "Valuables - Generic" };
		Valuables.RegisterValuable(val2, list2);
		Valuables.RegisterValuable(val3, list2);
		Valuables.RegisterValuable(val4, list4);
		Valuables.RegisterValuable(val5, list4);
		Valuables.RegisterValuable(val6, list2);
		Valuables.RegisterValuable(val7, list3);
		Valuables.RegisterValuable(val8, list);
	}
}

BeepInEx/plugins/nickklmao-MenuLib/MenuLib.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib.MonoBehaviors;
using MenuLib.Structs;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MenuLib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.1.3")]
[assembly: AssemblyInformationalVersion("1.0.0+1c3cccb19d32c31034b7c6293f1b024625e498de")]
[assembly: AssemblyProduct("MenuLib")]
[assembly: AssemblyTitle("MenuLib")]
[assembly: AssemblyVersion("2.1.3.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MenuLib
{
	[BepInPlugin("nickklmao.menulib", "Menu Lib", "2.1.3")]
	internal sealed class Entry : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Action<MenuPageMain>, MenuPageMain> <0>__MenuPageMain_StartHook;

			public static Action<Action<MenuPageEsc>, MenuPageEsc> <1>__MenuPageEsc_StartHook;

			public static Action<Action<MenuPageLobby>, MenuPageLobby> <2>__MenuPageLobby_StartHook;

			public static Manipulator <3>__SemiFunc_UIMouseHoverILHook;

			public static Manipulator <4>__MenuPage_StateClosingILHook;

			public static Manipulator <5>__MenuScrollBox_UpdateILHook;
		}

		private const string MOD_NAME = "Menu Lib";

		internal static readonly ManualLogSource logger = Logger.CreateLogSource("Menu Lib");

		private static void MenuPageMain_StartHook(Action<MenuPageMain> orig, MenuPageMain self)
		{
			orig(self);
			MenuAPI.mainMenuBuilderDelegates?.Invoke(((Component)self).transform);
		}

		private static void MenuPageEsc_StartHook(Action<MenuPageEsc> orig, MenuPageEsc self)
		{
			orig(self);
			MenuAPI.escapeMenuBuilderDelegates?.Invoke(((Component)self).transform);
		}

		private static void MenuPageLobby_StartHook(Action<MenuPageLobby> orig, MenuPageLobby self)
		{
			orig(self);
			MenuAPI.lobbyMenuBuilderDelegate?.Invoke(((Component)self).transform);
		}

		private static void SemiFunc_UIMouseHoverILHook(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_004e: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel val4 = default(ILLabel);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchBrfalse(instruction, ref val4) && val4.Target.OpCode == OpCodes.Ldarg_1
			});
			val.Index += 2;
			val.RemoveRange(27);
			val.Emit(OpCodes.Ldloc_0);
			val.EmitDelegate<Func<MenuScrollBox, Vector2, bool>>((Func<MenuScrollBox, Vector2, bool>)delegate(MenuScrollBox menuScrollBox, Vector2 vector)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				//IL_0012: 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)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val3 = (RectTransform)((Transform)menuScrollBox.scroller).parent;
				float y = ((Transform)val3).position.y;
				float num = y + val3.sizeDelta.y;
				return vector.y > y && vector.y < num;
			});
			ILLabel val2 = val.DefineLabel();
			val.Emit(OpCodes.Brtrue_S, (object)val2);
			val.Emit(OpCodes.Ldc_I4_0);
			val.Emit(OpCodes.Ret);
			val.MarkLabel(val2);
		}

		private static void MenuPage_StateClosingILHook(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchLdfld<MenuPage>(instruction, "stateStart")
			});
			val.Index += 2;
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Action<MenuPage>>((Action<MenuPage>)delegate(MenuPage menuPage)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				//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)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				if (MenuAPI.customMenuPages.TryGetValue(menuPage, out var value2))
				{
					RectTransform val2 = (RectTransform)((Component)menuPage).transform;
					Vector2 val3 = Vector2.op_Implicit(((Transform)val2).position);
					Rect rect = val2.rect;
					float num = 0f - ((Rect)(ref rect)).height;
					rect = value2.rectTransform.rect;
					val3.y = num - ((Rect)(ref rect)).height;
					REPOReflection.menuPage_AnimateAwayPosition.SetValue(menuPage, val3);
				}
			});
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchCall<Object>(instruction, "Destroy")
			});
			val.Index -= 5;
			val.RemoveRange(6);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Action<MenuPage>>((Action<MenuPage>)delegate(MenuPage menuPage)
			{
				if (MenuAPI.customMenuPages.TryGetValue(menuPage, out var value) && (value.isCachedPage || !value.pageWasActivatedOnce))
				{
					((Behaviour)menuPage).enabled = false;
				}
				else
				{
					MenuManager.instance.PageRemove(menuPage);
					Object.Destroy((Object)(object)((Component)menuPage).gameObject);
				}
			});
		}

		private static void MenuScrollBox_UpdateILHook(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_007d: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchLdarg(instruction, 0),
				(Instruction instruction) => ILPatternMatchingExt.MatchLdfld<MenuScrollBox>(instruction, "scrollBoxActive")
			});
			val.RemoveRange(4);
			ILLabel val2 = val.MarkLabel();
			val.Index -= 2;
			val.Remove();
			val.Emit(OpCodes.Brtrue_S, (object)val2);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchCall(instruction, typeof(SemiFunc), "InputScrollY")
			});
			int index = val.Index;
			val.Index = index - 1;
			val.Remove();
			ILLabel val3 = val.DefineLabel();
			val.Emit(OpCodes.Bne_Un_S, (object)val3);
			val.Index += 2;
			object operand = il.Instrs[val.Index].Operand;
			ILLabel val4 = (ILLabel)((operand is ILLabel) ? operand : null);
			index = val.Index;
			val.Index = index + 1;
			val.RemoveRange(24);
			val.MarkLabel(val3);
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Ldarg_0);
			val.Emit<MenuScrollBox>(OpCodes.Ldfld, "parentPage");
			val.EmitDelegate<Action<MenuScrollBox, MenuPage>>((Action<MenuScrollBox, MenuPage>)delegate(MenuScrollBox menuScrollBox, MenuPage menuPage)
			{
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				float num = SemiFunc.InputMovementY();
				float num2 = SemiFunc.InputScrollY();
				float num5;
				if (MenuAPI.customMenuPages.TryGetValue(menuPage, out var value))
				{
					float? scrollSpeed = value.scrollView.scrollSpeed;
					if (scrollSpeed.HasValue)
					{
						float valueOrDefault = scrollSpeed.GetValueOrDefault();
						valueOrDefault *= 10f;
						float num3 = Mathf.Abs((float)REPOReflection.menuScrollBox_ScrollerEndPosition.GetValue(menuScrollBox) - (float)REPOReflection.menuScrollBox_ScrollerStartPosition.GetValue(menuScrollBox));
						float num4 = (num + (float)Math.Sign(num2)) * valueOrDefault / num3;
						Rect rect = menuScrollBox.scrollBarBackground.rect;
						num5 = num4 * ((Rect)(ref rect)).height;
						goto IL_00c1;
					}
				}
				float num6 = (float)REPOReflection.menuScrollBox_ScrollHeight.GetValue(menuScrollBox);
				num5 = num * 20f / (num6 * 0.01f) + num2 / (num6 * 0.01f);
				goto IL_00c1;
				IL_00c1:
				float num7 = (float)REPOReflection.menuScrollBox_ScrollHandleTargetPosition.GetValue(menuScrollBox);
				REPOReflection.menuScrollBox_ScrollHandleTargetPosition.SetValue(menuScrollBox, num7 + num5);
			});
			val.GotoPrev(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchCall(instruction, typeof(SemiFunc), "InputMovementY")
			});
			ILLabel val5 = val.MarkLabel();
			val.Emit(OpCodes.Ldarg_0);
			val.Emit<MenuScrollBox>(OpCodes.Ldfld, "scrollBoxActive");
			val.Emit(OpCodes.Brfalse_S, (object)val4);
			val.GotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchCall<Input>(instruction, "GetMouseButton")
			});
			val.Remove();
			val.Emit(OpCodes.Brfalse, (object)val5);
			val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchCall(instruction, typeof(SemiFunc), "UIMouseHover")
			});
			val.Remove();
			val.Emit(OpCodes.Brfalse, (object)val5);
		}

		private void Awake()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Expected O, but got Unknown
			logger.LogDebug((object)"Hooking `MenuPageMain.Start`");
			new Hook((MethodBase)AccessTools.Method(typeof(MenuPageMain), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageMain>, MenuPageMain>(MenuPageMain_StartHook));
			logger.LogDebug((object)"Hooking `MenuPageEsc.Start`");
			new Hook((MethodBase)AccessTools.Method(typeof(MenuPageEsc), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageEsc>, MenuPageEsc>(MenuPageEsc_StartHook));
			logger.LogDebug((object)"Hooking `MenuPageLobby.Start`");
			new Hook((MethodBase)AccessTools.Method(typeof(MenuPageLobby), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageLobby>, MenuPageLobby>(MenuPageLobby_StartHook));
			logger.LogDebug((object)"Hooking `SemiFunc.UIMouseHover`");
			MethodInfo methodInfo = AccessTools.Method(typeof(SemiFunc), "UIMouseHover", (Type[])null, (Type[])null);
			object obj = <>O.<3>__SemiFunc_UIMouseHoverILHook;
			if (obj == null)
			{
				Manipulator val = SemiFunc_UIMouseHoverILHook;
				<>O.<3>__SemiFunc_UIMouseHoverILHook = val;
				obj = (object)val;
			}
			new ILHook((MethodBase)methodInfo, (Manipulator)obj);
			logger.LogDebug((object)"Hooking `MenuPage.StateClosing`");
			MethodInfo methodInfo2 = AccessTools.Method(typeof(MenuPage), "StateClosing", (Type[])null, (Type[])null);
			object obj2 = <>O.<4>__MenuPage_StateClosingILHook;
			if (obj2 == null)
			{
				Manipulator val2 = MenuPage_StateClosingILHook;
				<>O.<4>__MenuPage_StateClosingILHook = val2;
				obj2 = (object)val2;
			}
			new ILHook((MethodBase)methodInfo2, (Manipulator)obj2);
			logger.LogDebug((object)"Hooking `MenuScrollBox.Update`");
			MethodInfo methodInfo3 = AccessTools.Method(typeof(MenuScrollBox), "Update", (Type[])null, (Type[])null);
			object obj3 = <>O.<5>__MenuScrollBox_UpdateILHook;
			if (obj3 == null)
			{
				Manipulator val3 = MenuScrollBox_UpdateILHook;
				<>O.<5>__MenuScrollBox_UpdateILHook = val3;
				obj3 = (object)val3;
			}
			new ILHook((MethodBase)methodInfo3, (Manipulator)obj3);
		}
	}
	public static class MenuAPI
	{
		public delegate void BuilderDelegate(Transform parent);

		internal static BuilderDelegate mainMenuBuilderDelegates;

		internal static BuilderDelegate lobbyMenuBuilderDelegate;

		internal static BuilderDelegate escapeMenuBuilderDelegates;

		internal static readonly Dictionary<MenuPage, REPOPopupPage> customMenuPages = new Dictionary<MenuPage, REPOPopupPage>();

		private static MenuButtonPopUp menuButtonPopup;

		public static void AddElementToMainMenu(BuilderDelegate builderDelegate)
		{
			mainMenuBuilderDelegates = (BuilderDelegate)Delegate.Combine(mainMenuBuilderDelegates, builderDelegate);
		}

		public static void AddElementToLobbyMenu(BuilderDelegate builderDelegate)
		{
			lobbyMenuBuilderDelegate = (BuilderDelegate)Delegate.Combine(lobbyMenuBuilderDelegate, builderDelegate);
		}

		public static void AddElementToEscapeMenu(BuilderDelegate builderDelegate)
		{
			escapeMenuBuilderDelegates = (BuilderDelegate)Delegate.Combine(escapeMenuBuilderDelegates, builderDelegate);
		}

		public static void CloseAllPagesAddedOnTop()
		{
			MenuManager.instance.PageCloseAllAddedOnTop();
		}

		public static void OpenPopup(string header, Color headerColor, string content, Action onLeftClicked, Action onRightClicked = null)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)menuButtonPopup))
			{
				menuButtonPopup = ((Component)MenuManager.instance).gameObject.AddComponent<MenuButtonPopUp>();
			}
			menuButtonPopup.option1Event = new UnityEvent();
			menuButtonPopup.option2Event = new UnityEvent();
			if (onLeftClicked != null)
			{
				menuButtonPopup.option1Event.AddListener(new UnityAction(onLeftClicked.Invoke));
			}
			if (onRightClicked != null)
			{
				menuButtonPopup.option2Event.AddListener(new UnityAction(onRightClicked.Invoke));
			}
			MenuManager.instance.PagePopUpTwoOptions(menuButtonPopup, header, headerColor, content, "Yes", "No");
		}

		public static REPOButton CreateREPOButton(string text, Action onClick, Transform parent, Vector2 localPosition = default(Vector2))
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.buttonTemplate, parent);
			((Object)obj).name = "Menu Button - " + text;
			((Transform)obj).localPosition = Vector2.op_Implicit(localPosition);
			REPOButton rEPOButton = ((Component)obj).gameObject.AddComponent<REPOButton>();
			((TMP_Text)rEPOButton.labelTMP).text = text;
			rEPOButton.onClick = onClick;
			return rEPOButton;
		}

		public static REPOToggle CreateREPOToggle(string text, Action<bool> onToggle, Transform parent, Vector2 localPosition = default(Vector2), string leftButtonText = "ON", string rightButtonText = "OFF", bool defaultValue = false)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.toggleTemplate, parent);
			((Object)obj).name = "Menu Toggle - " + text;
			((Transform)obj).localPosition = Vector2.op_Implicit(localPosition);
			REPOToggle rEPOToggle = ((Component)obj).gameObject.AddComponent<REPOToggle>();
			((TMP_Text)rEPOToggle.labelTMP).text = text;
			((TMP_Text)rEPOToggle.leftButtonTMP).text = leftButtonText;
			((TMP_Text)rEPOToggle.rightButtonTMP).text = rightButtonText;
			rEPOToggle.onToggle = onToggle;
			rEPOToggle.SetState(defaultValue, invokeCallback: false);
			return rEPOToggle;
		}

		public static REPOSlider CreateREPOSlider(string text, string description, Action<float> onValueChanged, Transform parent, Vector2 localPosition = default(Vector2), float min = 0f, float max = 1f, int precision = 2, float defaultValue = 0f, string prefix = "", string postfix = "", REPOSlider.BarBehavior barBehavior = REPOSlider.BarBehavior.UpdateWithValue)
		{
			//IL_001d: 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)
			RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.sliderTemplate, parent);
			((Object)obj).name = "Float Slider - " + text;
			((Transform)obj).localPosition = Vector2.op_Implicit(localPosition);
			REPOSlider rEPOSlider = ((Component)obj).gameObject.AddComponent<REPOSlider>();
			((TMP_Text)rEPOSlider.labelTMP).text = text;
			((TMP_Text)rEPOSlider.descriptionTMP).text = description;
			rEPOSlider.onValueChanged = onValueChanged;
			rEPOSlider.min = min;
			rEPOSlider.max = max;
			rEPOSlider.precision = precision;
			rEPOSlider.prefix = prefix;
			rEPOSlider.postfix = postfix;
			rEPOSlider.barBehavior = barBehavior;
			rEPOSlider.SetValue(defaultValue, invokeCallback: false);
			return rEPOSlider;
		}

		public static REPOSlider CreateREPOSlider(string text, string description, Action<int> onValueChanged, Transform parent, Vector2 localPosition = default(Vector2), int min = 0, int max = 1, int defaultValue = 0, string prefix = "", string postfix = "", REPOSlider.BarBehavior barBehavior = REPOSlider.BarBehavior.UpdateWithValue)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.sliderTemplate, parent);
			((Object)obj).name = "Int Slider - " + text;
			((Transform)obj).localPosition = Vector2.op_Implicit(localPosition);
			REPOSlider rEPOSlider = ((Component)obj).gameObject.AddComponent<REPOSlider>();
			((TMP_Text)rEPOSlider.labelTMP).text = text;
			((TMP_Text)rEPOSlider.descriptionTMP).text = description;
			rEPOSlider.onValueChanged = delegate(float f)
			{
				onValueChanged(Convert.ToInt32(f));
			};
			rEPOSlider.min = min;
			rEPOSlider.max = max;
			rEPOSlider.precision = 0;
			rEPOSlider.prefix = prefix;
			rEPOSlider.postfix = postfix;
			rEPOSlider.barBehavior = barBehavior;
			rEPOSlider.SetValue(defaultValue, invokeCallback: false);
			return rEPOSlider;
		}

		public static REPOSlider CreateREPOSlider(string text, string description, Action<string> onOptionChanged, Transform parent, string[] stringOptions, string defaultOption, Vector2 localPosition = default(Vector2), string prefix = "", string postfix = "", REPOSlider.BarBehavior barBehavior = REPOSlider.BarBehavior.UpdateWithValue)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Object.Instantiate<RectTransform>(REPOTemplates.sliderTemplate, parent);
			((Object)val).name = "Option Slider - " + text;
			((Transform)val).localPosition = Vector2.op_Implicit(localPosition);
			REPOSlider repoSlider = ((Component)val).gameObject.AddComponent<REPOSlider>();
			((TMP_Text)repoSlider.labelTMP).text = text;
			((TMP_Text)repoSlider.descriptionTMP).text = description;
			repoSlider.onValueChanged = delegate(float f)
			{
				onOptionChanged(repoSlider.stringOptions.ElementAtOrDefault(Convert.ToInt32(f)) ?? repoSlider.stringOptions.FirstOrDefault());
			};
			repoSlider.stringOptions = stringOptions;
			repoSlider.prefix = prefix;
			repoSlider.postfix = postfix;
			repoSlider.barBehavior = barBehavior;
			int num = Array.IndexOf(stringOptions, defaultOption);
			if (num == -1)
			{
				num = 0;
			}
			repoSlider.SetValue(num, invokeCallback: false);
			return repoSlider;
		}

		public static REPOSlider CreateREPOSlider(string text, string description, Action<int> onOptionChanged, Transform parent, string[] stringOptions, string defaultOption, Vector2 localPosition = default(Vector2), string prefix = "", string postfix = "", REPOSlider.BarBehavior barBehavior = REPOSlider.BarBehavior.UpdateWithValue)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.sliderTemplate, parent);
			((Object)obj).name = "Option Slider - " + text;
			((Transform)obj).localPosition = Vector2.op_Implicit(localPosition);
			REPOSlider rEPOSlider = ((Component)obj).gameObject.AddComponent<REPOSlider>();
			((TMP_Text)rEPOSlider.labelTMP).text = text;
			((TMP_Text)rEPOSlider.descriptionTMP).text = description;
			rEPOSlider.onValueChanged = delegate(float f)
			{
				onOptionChanged(Convert.ToInt32(f));
			};
			rEPOSlider.stringOptions = stringOptions;
			rEPOSlider.prefix = prefix;
			rEPOSlider.postfix = postfix;
			rEPOSlider.barBehavior = barBehavior;
			int num = Array.IndexOf(stringOptions, defaultOption);
			if (num == -1)
			{
				num = 0;
			}
			rEPOSlider.SetValue(num, invokeCallback: false);
			return rEPOSlider;
		}

		public static REPOLabel CreateREPOLabel(string text, Transform parent, Vector2 localPosition = default(Vector2))
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.labelTemplate, parent);
			((Object)obj).name = "Label - " + text;
			((Transform)obj).localPosition = Vector2.op_Implicit(localPosition);
			REPOLabel rEPOLabel = ((Component)obj).gameObject.AddComponent<REPOLabel>();
			((TMP_Text)rEPOLabel.labelTMP).text = text;
			return rEPOLabel;
		}

		public static REPOSpacer CreateREPOSpacer(Transform parent, Vector2 localPosition = default(Vector2), Vector2 size = default(Vector2))
		{
			//IL_0018: 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)
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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)
			RectTransform val = (RectTransform)new GameObject("Spacer", new Type[1] { typeof(RectTransform) }).transform;
			((Transform)val).SetParent(parent);
			REPOSpacer result = ((Component)val).gameObject.AddComponent<REPOSpacer>();
			((Transform)val).localPosition = Vector2.op_Implicit(localPosition);
			val.sizeDelta = size;
			return result;
		}

		[Obsolete("Switch to the overload with the 'shouldCachePage' argument!")]
		public static REPOPopupPage CreateREPOPopupPage(string headerText, REPOPopupPage.PresetSide presetSide, bool pageDimmerVisibility = false, float spacing = 0f)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return CreateREPOPopupPage(headerText, pageDimmerVisibility, spacing, (presetSide == REPOPopupPage.PresetSide.Left) ? null : new Vector2?(new Vector2(40f, 0f)));
		}

		[Obsolete("Switch to the overload with the 'shouldCachePage' argument!")]
		public static REPOPopupPage CreateREPOPopupPage(string headerText, bool pageDimmerVisibility = false, float spacing = 0f, Vector2? localPosition = null)
		{
			return CreateREPOPopupPage(headerText, shouldCachePage: false, pageDimmerVisibility, spacing, localPosition);
		}

		public static REPOPopupPage CreateREPOPopupPage(string headerText, REPOPopupPage.PresetSide presetSide, bool shouldCachePage, bool pageDimmerVisibility = false, float spacing = 0f)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return CreateREPOPopupPage(headerText, shouldCachePage, pageDimmerVisibility, spacing, (presetSide == REPOPopupPage.PresetSide.Left) ? null : new Vector2?(new Vector2(40f, 0f)));
		}

		public static REPOPopupPage CreateREPOPopupPage(string headerText, bool shouldCachePage, bool pageDimmerVisibility = false, float spacing = 0f, Vector2? localPosition = null)
		{
			//IL_0055: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.popupPageTemplate, ((Component)MenuHolder.instance).transform);
			((Object)obj).name = "Menu Page " + headerText;
			REPOPopupPage rEPOPopupPage = ((Component)obj).gameObject.AddComponent<REPOPopupPage>();
			((Transform)rEPOPopupPage.rectTransform).localPosition = Vector2.op_Implicit((Vector2)(((??)localPosition) ?? new Vector2(-280f, 0f)));
			((TMP_Text)rEPOPopupPage.headerTMP).text = headerText;
			rEPOPopupPage.isCachedPage = shouldCachePage;
			rEPOPopupPage.pageDimmerVisibility = pageDimmerVisibility;
			rEPOPopupPage.scrollView.spacing = spacing;
			customMenuPages.Add(rEPOPopupPage.menuPage, rEPOPopupPage);
			return rEPOPopupPage;
		}

		public static REPOAvatarPreview CreateREPOAvatarPreview(Transform parent, Vector2 localPosition = default(Vector2), bool enableBackgroundImage = false, Color? backgroundImageColor = null)
		{
			//IL_0026: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = Object.Instantiate<Transform>(REPOTemplates.avatarPreviewTemplate, parent);
			((Object)obj).name = "Player Avatar Preview";
			REPOAvatarPreview rEPOAvatarPreview = ((Component)obj).gameObject.AddComponent<REPOAvatarPreview>();
			((Transform)rEPOAvatarPreview.rectTransform).localPosition = Vector2.op_Implicit(localPosition);
			rEPOAvatarPreview.enableBackgroundImage = enableBackgroundImage;
			rEPOAvatarPreview.backgroundImageColor = (Color)(((??)backgroundImageColor) ?? Color.white);
			return rEPOAvatarPreview;
		}

		internal static void OpenMenuPage(MenuPage menuPage, bool pageOnTop)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			object? value = REPOReflection.menuManager_CurrentMenuPage.GetValue(MenuManager.instance);
			MenuPage val = (MenuPage)((value is MenuPage) ? value : null);
			List<MenuPage> list = REPOReflection.menuManager_AddedPagesOnTop.GetValue(MenuManager.instance) as List<MenuPage>;
			if (pageOnTop && !Object.op_Implicit((Object)(object)val))
			{
				pageOnTop = false;
			}
			if (pageOnTop)
			{
				if (list == null || list.Contains(val))
				{
					return;
				}
			}
			else if (Object.op_Implicit((Object)(object)val))
			{
				REPOReflection.menuManager_PageInactiveAdd.Invoke(MenuManager.instance, new object[1] { val });
				val.PageStateSet((PageState)3);
			}
			((Component)menuPage).transform.SetAsLastSibling();
			((Behaviour)menuPage).enabled = true;
			menuPage.ResetPage();
			menuPage.PageStateSet((PageState)0);
			MenuManager.instance.PageAdd(menuPage);
			((MonoBehaviour)menuPage).StartCoroutine(REPOReflection.menuPage_LateStart.Invoke(menuPage, null) as IEnumerator);
			REPOReflection.menuPage_AddedPageOnTop.SetValue(menuPage, false);
			if (!pageOnTop)
			{
				MenuManager.instance.PageSetCurrent(menuPage.menuPageIndex, menuPage);
				REPOReflection.menuPage_PageIsOnTopOfOtherPage.SetValue(menuPage, true);
				REPOReflection.menuPage_PageUnderThisPage.SetValue(menuPage, val);
			}
			else
			{
				REPOReflection.menuPage_ParentPage.SetValue(menuPage, val);
				list.Add(menuPage);
			}
		}

		internal static void CloseMenuPage(MenuPage menuPage, bool closePagesAddedOnTop)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (closePagesAddedOnTop)
			{
				CloseAllPagesAddedOnTop();
			}
			menuPage.PageStateSet((PageState)2);
			object? value = REPOReflection.menuPage_PageUnderThisPage.GetValue(menuPage);
			MenuPage val = (MenuPage)((value is MenuPage) ? value : null);
			if (val != null)
			{
				MenuManager.instance.PageSetCurrent(val.menuPageIndex, val);
			}
		}
	}
	public static class REPOReflection
	{
		public static readonly FieldInfo menuManager_CurrentMenuPage = AccessTools.Field(typeof(MenuManager), "currentMenuPage");

		public static readonly FieldInfo menuManager_AddedPagesOnTop = AccessTools.Field(typeof(MenuManager), "addedPagesOnTop");

		public static readonly FieldInfo menuPage_AddedPageOnTop = AccessTools.Field(typeof(MenuPage), "addedPageOnTop");

		public static readonly FieldInfo menuPage_PageUnderThisPage = AccessTools.Field(typeof(MenuPage), "pageUnderThisPage");

		public static readonly FieldInfo menuPage_ParentPage = AccessTools.Field(typeof(MenuPage), "parentPage");

		public static readonly FieldInfo menuPage_PageIsOnTopOfOtherPage = AccessTools.Field(typeof(MenuPage), "pageIsOnTopOfOtherPage");

		public static readonly FieldInfo menuPage_ScrollBoxes = AccessTools.Field(typeof(MenuPage), "scrollBoxes");

		public static readonly FieldInfo menuPage_CurrentPageState = AccessTools.Field(typeof(MenuPage), "currentPageState");

		public static readonly FieldInfo menuPage_AnimateAwayPosition = AccessTools.Field(typeof(MenuPage), "animateAwayPosition");

		public static readonly FieldInfo menuButton_ParentPage = AccessTools.Field(typeof(MenuButton), "parentPage");

		public static readonly FieldInfo menuScrollBox_ScrollerEndPosition = AccessTools.Field(typeof(MenuScrollBox), "scrollerEndPosition");

		public static readonly FieldInfo menuScrollBox_ScrollerStartPosition = AccessTools.Field(typeof(MenuScrollBox), "scrollerStartPosition");

		public static readonly FieldInfo menuScrollBox_ScrollHandleTargetPosition = AccessTools.Field(typeof(MenuScrollBox), "scrollHandleTargetPosition");

		public static readonly FieldInfo menuScrollBox_ScrollHeight = AccessTools.Field(typeof(MenuScrollBox), "scrollHeight");

		public static readonly FieldInfo menuSelectableElement_MenuID = AccessTools.Field(typeof(MenuSelectableElement), "menuID");

		public static readonly MethodInfo menuManager_PageInactiveAdd = AccessTools.Method(typeof(MenuManager), "PageInactiveAdd", (Type[])null, (Type[])null);

		public static readonly MethodInfo menuPage_LateStart = AccessTools.Method(typeof(MenuPage), "LateStart", (Type[])null, (Type[])null);
	}
	internal static class REPOTemplates
	{
		internal static readonly RectTransform pageDimmerTemplate;

		internal static readonly RectTransform simplePageTemplate;

		internal static readonly RectTransform buttonTemplate;

		internal static readonly RectTransform popupPageTemplate;

		internal static readonly RectTransform toggleTemplate;

		internal static readonly RectTransform sliderTemplate;

		internal static readonly RectTransform labelTemplate;

		internal static readonly Transform avatarPreviewTemplate;

		static REPOTemplates()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected I4, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			foreach (MenuPages menuPage in MenuManager.instance.menuPages)
			{
				Transform transform = menuPage.menuPage.transform;
				MenuPageIndex menuPageIndex = menuPage.menuPageIndex;
				switch ((int)menuPageIndex)
				{
				case 0:
					simplePageTemplate = (RectTransform)transform;
					buttonTemplate = (RectTransform)((Transform)simplePageTemplate).Find("Menu Button - Quit game");
					break;
				case 2:
					pageDimmerTemplate = (RectTransform)transform.GetChild(0);
					break;
				case 4:
					popupPageTemplate = (RectTransform)transform;
					break;
				case 5:
				{
					Transform obj = transform.Find("Menu Scroll Box/Mask/Scroller");
					toggleTemplate = (RectTransform)obj.Find("Bool Setting - Push to Talk");
					sliderTemplate = (RectTransform)obj.Find("Slider - microphone");
					break;
				}
				case 6:
					labelTemplate = (RectTransform)transform.Find("Scroll Box/Mask/Scroller").Find("Header Movement");
					break;
				case 1:
					avatarPreviewTemplate = transform.Find("Menu Element Player Avatar");
					break;
				}
			}
		}
	}
}
namespace MenuLib.Structs
{
	public struct Padding
	{
		public float left;

		public float top;

		public float right;

		public float bottom;

		public Padding(float left, float top, float right, float bottom)
		{
			this.left = left;
			this.top = top;
			this.right = right;
			this.bottom = bottom;
		}
	}
}
namespace MenuLib.MonoBehaviors
{
	public sealed class REPOAvatarPreview : REPOElement
	{
		private PlayerAvatarMenu playerAvatarMenu;

		private Image backgroundImage;

		public bool enableBackgroundImage
		{
			get
			{
				return ((Behaviour)backgroundImage).enabled;
			}
			set
			{
				((Behaviour)backgroundImage).enabled = value;
			}
		}

		public Color backgroundImageColor
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return ((Graphic)backgroundImage).color;
			}
			set
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				((Graphic)backgroundImage).color = value;
			}
		}

		public PlayerAvatarVisuals playerAvatarVisuals { get; private set; }

		public Transform rigTransform => playerAvatarVisuals.meshParent.transform;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			base.rectTransform = ((Component)this).gameObject.AddComponent<RectTransform>();
			base.rectTransform.pivot = Vector2.right;
			RectTransform obj = base.rectTransform;
			Vector2 anchorMin = (base.rectTransform.anchorMax = Vector2.zero);
			obj.anchorMin = anchorMin;
			base.rectTransform.sizeDelta = new Vector2(184f, 345f);
			playerAvatarMenu = ((Component)this).GetComponentInChildren<PlayerAvatarMenuHover>().playerAvatarMenu;
			playerAvatarVisuals = ((Component)playerAvatarMenu).GetComponentInChildren<PlayerAvatarVisuals>();
			backgroundImage = ((Component)this).gameObject.AddComponent<Image>();
			((Behaviour)backgroundImage).enabled = false;
		}

		private void Start()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			((Transform)base.rectTransform).GetChild(0).localPosition = Vector3.zero;
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)playerAvatarMenu))
			{
				if (Object.op_Implicit((Object)(object)playerAvatarMenu.cameraAndStuff))
				{
					Object.Destroy((Object)(object)((Component)playerAvatarMenu.cameraAndStuff).gameObject);
				}
				Object.Destroy((Object)(object)((Component)playerAvatarMenu).gameObject);
			}
		}
	}
	public sealed class REPOButton : REPOElement
	{
		public MenuButton menuButton;

		public TextMeshProUGUI labelTMP;

		[Obsolete("Update the button clicked event using the 'onClick' field rather than through the button")]
		public Button button;

		public Action onClick;

		public Vector2? overrideButtonSize;

		private string previousText;

		private Vector2? previousOverrideButtonSize;

		public Vector2 GetLabelSize()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return ((TMP_Text)labelTMP).GetPreferredValues();
		}

		private void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			Transform transform = ((Component)this).transform;
			base.rectTransform = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			button = ((Component)this).GetComponent<Button>();
			menuButton = ((Component)this).GetComponent<MenuButton>();
			labelTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>();
			button.onClick = new ButtonClickedEvent();
			((UnityEvent)button.onClick).AddListener((UnityAction)delegate
			{
				onClick?.Invoke();
			});
			Object.Destroy((Object)(object)((Component)this).GetComponent<MenuButtonPopUp>());
		}

		private void Update()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			if (((TMP_Text)labelTMP).text == previousText)
			{
				Vector2? val = overrideButtonSize;
				Vector2? val2 = previousOverrideButtonSize;
				if (val.HasValue == val2.HasValue && (!val.HasValue || val.GetValueOrDefault() == val2.GetValueOrDefault()))
				{
					return;
				}
			}
			base.rectTransform.sizeDelta = (Vector2)(((??)overrideButtonSize) ?? GetLabelSize());
			previousText = ((TMP_Text)labelTMP).text;
			previousOverrideButtonSize = overrideButtonSize;
		}

		private void OnTransformParentChanged()
		{
			REPOReflection.menuButton_ParentPage.SetValue(menuButton, ((Component)this).GetComponentInParent<MenuPage>());
		}
	}
	public class REPOElement : MonoBehaviour
	{
		private REPOScrollViewElement _repoScrollViewElement;

		public RectTransform rectTransform { get; protected set; }

		public REPOScrollViewElement repoScrollViewElement
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_repoScrollViewElement))
				{
					return _repoScrollViewElement;
				}
				return _repoScrollViewElement = ((Component)this).GetComponent<REPOScrollViewElement>();
			}
		}
	}
	public sealed class REPOLabel : REPOElement
	{
		public TextMeshProUGUI labelTMP;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			base.rectTransform = (RectTransform)((Component)this).transform;
			labelTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>();
			Vector2 sizeDelta = (((TMP_Text)labelTMP).rectTransform.pivot = (base.rectTransform.pivot = Vector2.zero));
			RectTransform obj = ((TMP_Text)labelTMP).rectTransform;
			RectTransform obj2 = base.rectTransform;
			((Vector2)(ref sizeDelta))..ctor(200f, 30f);
			obj2.sizeDelta = sizeDelta;
			obj.sizeDelta = sizeDelta;
			((TMP_Text)labelTMP).fontSize = 30f;
			TextMeshProUGUI obj3 = labelTMP;
			bool enableWordWrapping = (((TMP_Text)labelTMP).enableAutoSizing = false);
			((TMP_Text)obj3).enableWordWrapping = enableWordWrapping;
			((TMP_Text)labelTMP).alignment = (TextAlignmentOptions)513;
			((TMP_Text)labelTMP).margin = Vector4.zero;
		}

		private void Start()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			((Transform)((TMP_Text)labelTMP).rectTransform).localPosition = Vector2.op_Implicit(Vector2.zero);
		}
	}
	public sealed class REPOPopupPage : MonoBehaviour
	{
		public enum PresetSide
		{
			Left,
			Right
		}

		public delegate RectTransform ScrollViewBuilderDelegate(Transform scrollView);

		public RectTransform rectTransform;

		public RectTransform maskRectTransform;

		public RectTransform scrollBarRectTransform;

		public MenuPage menuPage;

		public TextMeshProUGUI headerTMP;

		public MenuScrollBox menuScrollBox;

		public REPOScrollView scrollView;

		internal bool pageWasActivatedOnce;

		private GameObject pageDimmerGameObject;

		private RawImage pageDimmerRawImage;

		private RectTransform scrollBarFillRectTransform;

		private RectTransform scrollBarOutlineRectTransform;

		private Vector2 defaultMaskSizeDelta;

		private Vector2 defaultMaskPosition;

		private Padding _maskPadding;

		public bool pageDimmerVisibility
		{
			get
			{
				return pageDimmerGameObject.gameObject.activeSelf;
			}
			set
			{
				pageDimmerGameObject.gameObject.SetActive(value);
			}
		}

		public bool isCachedPage { get; internal set; }

		public float pageDimmerOpacity
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return ((Graphic)pageDimmerRawImage).color.a;
			}
			set
			{
				//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_001a: Unknown result type (might be due to invalid IL or missing references)
				RawImage obj = pageDimmerRawImage;
				Color color = ((Graphic)pageDimmerRawImage).color;
				color.a = value;
				((Graphic)obj).color = color;
			}
		}

		public Padding maskPadding
		{
			get
			{
				return _maskPadding;
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				Vector2 sizeDelta = defaultMaskSizeDelta;
				Vector2 val = defaultMaskPosition;
				sizeDelta.x -= value.left + value.right;
				sizeDelta.y -= value.top + value.bottom;
				if (value.left != 0f)
				{
					val.x += value.left;
				}
				if (value.bottom != 0f)
				{
					val.y += value.bottom;
				}
				maskRectTransform.sizeDelta = sizeDelta;
				((Transform)maskRectTransform).localPosition = Vector2.op_Implicit(val);
				_maskPadding = value;
				UpdateScrollBarPosition();
			}
		}

		public void OpenPage(bool openOnTop)
		{
			MenuAPI.OpenMenuPage(menuPage, openOnTop);
			pageWasActivatedOnce = true;
			scrollView.UpdateElements();
		}

		public void ClosePage(bool closePagesAddedOnTop)
		{
			MenuAPI.CloseMenuPage(menuPage, closePagesAddedOnTop);
		}

		public void AddElement(MenuAPI.BuilderDelegate builderDelegate)
		{
			builderDelegate?.Invoke(((Component)this).transform);
		}

		public void AddElement(RectTransform elementRectTransform, Vector2 localPosition = default(Vector2))
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			((Transform)elementRectTransform).SetParent(((Component)this).transform);
			((Transform)elementRectTransform).localPosition = Vector2.op_Implicit(localPosition);
		}

		public void AddElementToScrollView(ScrollViewBuilderDelegate scrollViewBuilderDelegate, float topPadding = 0f, float bottomPadding = 0f)
		{
			object obj;
			if (scrollViewBuilderDelegate == null)
			{
				obj = null;
			}
			else
			{
				RectTransform obj2 = scrollViewBuilderDelegate((Transform)(object)menuScrollBox.scroller);
				obj = ((obj2 != null) ? ((Component)obj2).gameObject.AddComponent<REPOScrollViewElement>() : null);
			}
			REPOScrollViewElement rEPOScrollViewElement = (REPOScrollViewElement)obj;
			if (rEPOScrollViewElement != null)
			{
				rEPOScrollViewElement.onSettingChanged = scrollView.UpdateElements;
				rEPOScrollViewElement.topPadding = topPadding;
				rEPOScrollViewElement.bottomPadding = bottomPadding;
			}
		}

		public void AddElementToScrollView(RectTransform elementRectTransform, Vector2 localPosition = default(Vector2), float topPadding = 0f, float bottomPadding = 0f)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			REPOScrollViewElement rEPOScrollViewElement = ((Component)elementRectTransform).gameObject.AddComponent<REPOScrollViewElement>();
			if (rEPOScrollViewElement != null)
			{
				rEPOScrollViewElement.onSettingChanged = scrollView.UpdateElements;
				((Transform)elementRectTransform).SetParent((Transform)(object)menuScrollBox.scroller);
				((Transform)elementRectTransform).localPosition = Vector2.op_Implicit(localPosition);
				rEPOScrollViewElement.topPadding = topPadding;
				rEPOScrollViewElement.bottomPadding = bottomPadding;
			}
		}

		private void Awake()
		{
			//IL_003d: 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_0051: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			menuPage = ((Component)this).GetComponent<MenuPage>();
			headerTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>();
			menuScrollBox = ((Component)this).GetComponentInChildren<MenuScrollBox>();
			rectTransform = (RectTransform)new GameObject("Page Content", new Type[1] { typeof(RectTransform) }).transform;
			((Transform)rectTransform).SetParent(((Component)this).transform);
			((Component)this).transform.Find("Panel").SetParent((Transform)(object)rectTransform);
			((TMP_Text)headerTMP).transform.parent.SetParent((Transform)(object)rectTransform);
			((Component)menuScrollBox).transform.SetParent((Transform)(object)rectTransform);
			pageDimmerGameObject = ((Component)Object.Instantiate<RectTransform>(REPOTemplates.pageDimmerTemplate, ((Component)this).transform)).gameObject;
			pageDimmerGameObject.transform.SetAsFirstSibling();
			pageDimmerRawImage = pageDimmerGameObject.GetComponentInChildren<RawImage>();
			menuPage.menuPageIndex = (MenuPageIndex)(-1);
			RectTransform scroller = menuScrollBox.scroller;
			for (int i = 2; i < ((Transform)scroller).childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)((Transform)scroller).GetChild(i)).gameObject);
			}
			scrollView = ((Component)scroller).gameObject.AddComponent<REPOScrollView>();
			scrollView.popupPage = this;
			maskRectTransform = (RectTransform)((Transform)scroller).parent;
			defaultMaskSizeDelta = maskRectTransform.sizeDelta;
			defaultMaskPosition = Vector2.op_Implicit(((Transform)maskRectTransform).localPosition);
			menuScrollBox.scroller.sizeDelta = maskRectTransform.sizeDelta;
			scrollBarRectTransform = (RectTransform)menuScrollBox.scrollBar.transform;
			scrollBarFillRectTransform = (RectTransform)((Transform)scrollBarRectTransform).Find("Scroll Bar Bg (2)");
			scrollBarOutlineRectTransform = (RectTransform)((Transform)scrollBarRectTransform).Find("Scroll Bar Bg (1)");
			maskPadding = new Padding(0f, 0f, 0f, 25f);
			Object.Destroy((Object)(object)((Component)this).GetComponent<MenuPageSettingsPage>());
		}

		private void Start()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			REPOReflection.menuScrollBox_ScrollerEndPosition.SetValue(menuScrollBox, 0);
			RectTransform scroller = menuScrollBox.scroller;
			Vector3 localPosition = ((Transform)menuScrollBox.scroller).localPosition;
			localPosition.y = 0f;
			((Transform)scroller).localPosition = localPosition;
			REPOReflection.menuPage_ScrollBoxes.SetValue(menuPage, 2);
			if (!pageWasActivatedOnce)
			{
				menuPage.PageStateSet((PageState)2);
			}
		}

		private void Update()
		{
			//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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			PageState val = (PageState)REPOReflection.menuPage_CurrentPageState.GetValue(menuPage);
			if (SemiFunc.InputDown((InputKey)18) && (int)val != 2)
			{
				ClosePage(closePagesAddedOnTop: false);
			}
		}

		private void UpdateScrollBarPosition()
		{
			//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)
			//IL_0028: 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_0043: 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_0051: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)scrollBarRectTransform))
			{
				RectTransform obj = scrollBarRectTransform;
				Vector3 localPosition = ((Transform)scrollBarRectTransform).localPosition;
				localPosition.y = ((Transform)maskRectTransform).localPosition.y;
				((Transform)obj).localPosition = localPosition;
				Vector2 sizeDelta = scrollBarRectTransform.sizeDelta;
				sizeDelta.y = maskRectTransform.sizeDelta.y;
				RectTransform scrollBarBackground = menuScrollBox.scrollBarBackground;
				RectTransform obj2 = scrollBarFillRectTransform;
				Vector2 val2 = (scrollBarRectTransform.sizeDelta = sizeDelta);
				Vector2 sizeDelta2 = (obj2.sizeDelta = val2);
				scrollBarBackground.sizeDelta = sizeDelta2;
				scrollBarOutlineRectTransform.sizeDelta = sizeDelta + new Vector2(4f, 4f);
			}
		}
	}
	public sealed class REPOScrollView : MonoBehaviour
	{
		public REPOPopupPage popupPage;

		public float? scrollSpeed;

		private REPOScrollViewElement[] scrollViewElements = Array.Empty<REPOScrollViewElement>();

		private float _spacing;

		public float spacing
		{
			get
			{
				return _spacing;
			}
			set
			{
				if (!(Math.Abs(_spacing - value) < float.Epsilon))
				{
					_spacing = value;
					UpdateElements();
				}
			}
		}

		public void UpdateElements()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			scrollViewElements = ((Component)this).GetComponentsInChildren<REPOScrollViewElement>(true);
			float num = 0f;
			float num2 = popupPage.maskRectTransform.sizeDelta.y;
			REPOScrollViewElement[] array = scrollViewElements;
			Rect rect;
			foreach (REPOScrollViewElement rEPOScrollViewElement in array)
			{
				if (rEPOScrollViewElement.visibility)
				{
					Vector3 localPosition = ((Transform)rEPOScrollViewElement.rectTransform).localPosition;
					num2 -= rEPOScrollViewElement.topPadding;
					float num3 = num2;
					rect = rEPOScrollViewElement.rectTransform.rect;
					num2 = num3 - ((Rect)(ref rect)).height;
					num = (localPosition.y = num2);
					num2 -= rEPOScrollViewElement.bottomPadding;
					num2 -= spacing;
					((Transform)rEPOScrollViewElement.rectTransform).localPosition = localPosition;
				}
			}
			GameObject gameObject = ((Component)popupPage.scrollBarRectTransform).gameObject;
			MenuScrollBox menuScrollBox = popupPage.menuScrollBox;
			RectTransform scroller = menuScrollBox.scroller;
			float num4 = num;
			if (!(num4 < 0f))
			{
				if (num4 >= 0f && gameObject.activeSelf)
				{
					((Component)popupPage.scrollBarRectTransform).gameObject.SetActive(false);
					Vector3 localPosition2 = ((Transform)scroller).localPosition;
					localPosition2.y = 0f;
					((Transform)scroller).localPosition = localPosition2;
				}
			}
			else if (!gameObject.activeSelf)
			{
				((Component)popupPage.scrollBarRectTransform).gameObject.SetActive(true);
			}
			FieldInfo menuScrollBox_ScrollerStartPosition = REPOReflection.menuScrollBox_ScrollerStartPosition;
			float num5 = num;
			rect = menuScrollBox.scrollHandle.rect;
			float num6 = 0.55f * ((Rect)(ref rect)).height;
			rect = menuScrollBox.scrollBarBackground.rect;
			menuScrollBox_ScrollerStartPosition.SetValue(menuScrollBox, Math.Abs(num5 / (1f - num6 / ((Rect)(ref rect)).height)));
		}

		public void SetScrollPosition(float normalizedPosition)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			normalizedPosition = Mathf.Clamp(1f - normalizedPosition, 0f, 1f);
			Rect rect = popupPage.menuScrollBox.scrollBarBackground.rect;
			float height = ((Rect)(ref rect)).height;
			float num = normalizedPosition * height;
			float num2 = popupPage.menuScrollBox.scrollHandle.sizeDelta.y / 2f;
			if (num < num2)
			{
				num = num2;
			}
			else if (num > height - num2)
			{
				num = height - num2;
			}
			REPOReflection.menuScrollBox_ScrollHandleTargetPosition.SetValue(popupPage.menuScrollBox, num);
		}

		private void OnTransformChildrenChanged()
		{
			UpdateElements();
		}

		private void Update()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			RectTransform maskRectTransform = popupPage.maskRectTransform;
			REPOScrollViewElement[] array = scrollViewElements;
			foreach (REPOScrollViewElement rEPOScrollViewElement in array)
			{
				if (!rEPOScrollViewElement.visibility)
				{
					continue;
				}
				Vector3 position = ((Component)rEPOScrollViewElement).transform.position;
				bool num = position.y <= ((Transform)maskRectTransform).position.y + maskRectTransform.sizeDelta.y + 50f && position.y >= ((Transform)maskRectTransform).position.y - 50f;
				GameObject gameObject = ((Component)rEPOScrollViewElement).gameObject;
				if (!num)
				{
					if (gameObject.activeSelf)
					{
						gameObject.SetActive(false);
					}
				}
				else if (!gameObject.activeSelf)
				{
					gameObject.SetActive(true);
				}
			}
		}
	}
	public sealed class REPOScrollViewElement : MonoBehaviour
	{
		public RectTransform rectTransform;

		internal Action onSettingChanged;

		private bool _visibility = true;

		private float _topPadding;

		private float _bottomPadding;

		public float topPadding
		{
			get
			{
				return _topPadding;
			}
			set
			{
				if (!(Math.Abs(_topPadding - value) < float.Epsilon))
				{
					_topPadding = value;
					onSettingChanged?.Invoke();
				}
			}
		}

		public float bottomPadding
		{
			get
			{
				return _bottomPadding;
			}
			set
			{
				if (!(Math.Abs(_bottomPadding - value) < float.Epsilon))
				{
					_bottomPadding = value;
					onSettingChanged?.Invoke();
				}
			}
		}

		public bool visibility
		{
			get
			{
				return _visibility;
			}
			set
			{
				if (_visibility != value)
				{
					_visibility = value;
					((Component)this).gameObject.SetActive(value);
					onSettingChanged?.Invoke();
				}
			}
		}

		private void Awake()
		{
			ref RectTransform reference = ref rectTransform;
			Transform transform = ((Component)this).transform;
			reference = (RectTransform)(object)((transform is RectTransform) ? transform : null);
		}

		private void OnRectTransformDimensionsChange()
		{
			onSettingChanged?.Invoke();
		}
	}
	public sealed class REPOSlider : REPOElement
	{
		public enum BarBehavior
		{
			UpdateWithValue,
			StaticAtMinimum,
			StaticAtMaximum
		}

		public TextMeshProUGUI labelTMP;

		public TextMeshProUGUI descriptionTMP;

		public REPOTextScroller repoTextScroller;

		public Action<float> onValueChanged;

		public BarBehavior barBehavior;

		public float value;

		public string prefix;

		public string postfix;

		private RectTransform barRectTransform;

		private RectTransform barSizeRectTransform;

		private RectTransform barPointerRectTransform;

		private RectTransform barMaskRectTransform;

		private RectTransform sliderBackgroundRectTransform;

		private RectTransform backgroundFillRectTransform;

		private RectTransform backgroundOutlineRectTransform;

		private TextMeshProUGUI valueTMP;

		private TextMeshProUGUI maskedValueTMP;

		private MenuPage menuPage;

		private MenuSelectableElement menuSelectableElement;

		private float _min;

		private float _max = 1f;

		private float previousValue;

		private float _precisionDecimal = 0.01f;

		private int _precision = 2;

		private string[] _stringOptions = Array.Empty<string>();

		private string currentDescription;

		private bool isHovering;

		public float min
		{
			get
			{
				string[] array = stringOptions;
				if (array == null || array.Length == 0)
				{
					return _min;
				}
				return 0f;
			}
			set
			{
				_min = value;
			}
		}

		public float max
		{
			get
			{
				string[] array = stringOptions;
				if (array == null || array.Length == 0)
				{
					return _max;
				}
				return stringOptions.Length - 1;
			}
			set
			{
				_max = value;
			}
		}

		public string[] stringOptions
		{
			get
			{
				return _stringOptions;
			}
			set
			{
				_stringOptions = value;
				UpdateBarText();
			}
		}

		public int precision
		{
			get
			{
				string[] array = stringOptions;
				if (array == null || array.Length == 0)
				{
					return _precision;
				}
				return 0;
			}
			set
			{
				precisionDecimal = ((value == 0) ? 1f : Mathf.Pow(10f, (float)(-value)));
				_precision = value;
			}
		}

		public float precisionDecimal
		{
			get
			{
				string[] array = stringOptions;
				if (array == null || array.Length == 0)
				{
					return _precisionDecimal;
				}
				return 1f;
			}
			set
			{
				_precisionDecimal = value;
			}
		}

		private float normalizedValue => (value - min) / (max - min);

		private bool hasValueChanged => Math.Abs(value - previousValue) > float.Epsilon;

		public void SetValue(float newValue, bool invokeCallback)
		{
			newValue = Mathf.Clamp(newValue, min, max);
			if (invokeCallback && Math.Abs(value - newValue) > float.Epsilon)
			{
				onValueChanged(newValue);
			}
			previousValue = (value = newValue);
			UpdateBarVisual();
			UpdateBarText();
		}

		public void Decrement()
		{
			float num = value - precisionDecimal;
			if (Math.Abs(value - min) < float.Epsilon)
			{
				num = max;
			}
			else if (num < min)
			{
				num = min;
			}
			SetValue(num, invokeCallback: true);
		}

		public void Increment()
		{
			float num = value + precisionDecimal;
			if (Math.Abs(max - value) < float.Epsilon)
			{
				num = min;
			}
			else if (num > max)
			{
				num = max;
			}
			SetValue(num, invokeCallback: true);
		}

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00d4: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Expected O, but got Unknown
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Expected O, but got Unknown
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Expected O, but got Unknown
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Expected O, but got Unknown
			//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_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Expected O, but got Unknown
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Expected O, but got Unknown
			base.rectTransform = (RectTransform)((Component)this).transform;
			menuPage = ((Component)this).GetComponentInParent<MenuPage>();
			menuSelectableElement = ((Component)this).GetComponent<MenuSelectableElement>();
			labelTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>();
			descriptionTMP = ((Component)((Component)this).transform.Find("Big Setting Text")).GetComponent<TextMeshProUGUI>();
			valueTMP = ((Component)((Component)this).transform.Find("Bar Text")).GetComponent<TextMeshProUGUI>();
			barMaskRectTransform = (RectTransform)((Component)this).transform.Find("MaskedText");
			maskedValueTMP = ((Component)barMaskRectTransform).GetComponentInChildren<TextMeshProUGUI>();
			barPointerRectTransform = (RectTransform)((Component)((Component)this).transform.Find("Bar Pointer")).transform;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(5.3f, 0f);
			RectTransform obj = ((TMP_Text)labelTMP).rectTransform;
			((Transform)obj).localPosition = ((Transform)obj).localPosition - val;
			((TMP_Text)descriptionTMP).alignment = (TextAlignmentOptions)514;
			TextMeshProUGUI obj2 = descriptionTMP;
			bool enableWordWrapping = (((TMP_Text)descriptionTMP).enableAutoSizing = false);
			((TMP_Text)obj2).enableWordWrapping = enableWordWrapping;
			((TMP_Text)descriptionTMP).overflowMode = (TextOverflowModes)2;
			TextMeshProUGUI obj3 = descriptionTMP;
			((TMP_Text)obj3).fontSize = ((TMP_Text)obj3).fontSize - 5f;
			repoTextScroller = ((Component)descriptionTMP).gameObject.AddComponent<REPOTextScroller>();
			repoTextScroller.textMeshPro = (TMP_Text)(object)descriptionTMP;
			RectTransform obj4 = ((TMP_Text)descriptionTMP).rectTransform;
			obj4.sizeDelta -= new Vector2(0f, 4f);
			RectTransform obj5 = ((TMP_Text)descriptionTMP).rectTransform;
			((Transform)obj5).localPosition = ((Transform)obj5).localPosition - val;
			sliderBackgroundRectTransform = (RectTransform)((Component)this).transform.Find("SliderBG");
			backgroundFillRectTransform = (RectTransform)((Transform)sliderBackgroundRectTransform).Find("RawImage (2)");
			backgroundOutlineRectTransform = (RectTransform)((Transform)sliderBackgroundRectTransform).Find("RawImage (3)");
			RectTransform obj6 = sliderBackgroundRectTransform;
			((Transform)obj6).localPosition = ((Transform)obj6).localPosition - val;
			RectTransform obj7 = ((TMP_Text)valueTMP).rectTransform;
			((Transform)obj7).localPosition = ((Transform)obj7).localPosition - val;
			Transform parent = ((Transform)((TMP_Text)maskedValueTMP).rectTransform).parent;
			parent.localPosition -= val;
			Transform val2 = ((Component)this).transform.Find("Bar");
			val2.localPosition -= val;
			barRectTransform = (RectTransform)val2.Find("RawImage");
			barRectTransform.pivot = Vector2.zero;
			((Transform)barRectTransform).localPosition = Vector2.op_Implicit(new Vector2(0f, -5f));
			barSizeRectTransform = (RectTransform)((Component)this).transform.Find("BarSize");
			RectTransform obj8 = barSizeRectTransform;
			((Transform)obj8).localPosition = ((Transform)obj8).localPosition - val;
			Vector2 sizeDelta = ((TMP_Text)labelTMP).rectTransform.sizeDelta;
			sizeDelta.y -= 10f;
			((TMP_Text)labelTMP).rectTransform.sizeDelta = sizeDelta;
			Button[] componentsInChildren = ((Component)this).GetComponentsInChildren<Button>();
			Button obj9 = componentsInChildren[0];
			Transform transform = ((Component)obj9).transform;
			transform.localPosition -= val;
			obj9.onClick = new ButtonClickedEvent();
			((UnityEvent)obj9.onClick).AddListener(new UnityAction(Decrement));
			Button obj10 = componentsInChildren[1];
			Transform transform2 = ((Component)obj10).transform;
			transform2.localPosition -= val;
			obj10.onClick = new ButtonClickedEvent();
			((UnityEvent)obj10.onClick).AddListener(new UnityAction(Increment));
			Object.Destroy((Object)(object)((Component)((Transform)sliderBackgroundRectTransform).Find("RawImage (4)")).gameObject);
			Object.Destroy((Object)(object)((Component)((Transform)sliderBackgroundRectTransform).Find("RawImage (5)")).gameObject);
			Object.Destroy((Object)(object)((Component)val2.Find("Extra Bar")).gameObject);
			Object.Destroy((Object)(object)((Component)this).GetComponent<MenuSliderMicrophone>());
			Object.Destroy((Object)(object)((Component)this).GetComponent<MenuSlider>());
		}

		private void Update()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			HandleDescription();
			if (SemiFunc.UIMouseHover(menuPage, barSizeRectTransform, REPOReflection.menuSelectableElement_MenuID.GetValue(menuSelectableElement) as string, 5f, 5f))
			{
				if (!isHovering)
				{
					MenuManager.instance.MenuEffectHover(SemiFunc.MenuGetPitchFromYPos(base.rectTransform), -1f);
				}
				isHovering = true;
				SemiFunc.MenuSelectionBoxTargetSet(menuPage, barSizeRectTransform, new Vector2(-3f, 0f), new Vector2(20f, 10f));
				if (!((Component)barPointerRectTransform).gameObject.activeSelf)
				{
					((Component)barPointerRectTransform).gameObject.SetActive(true);
				}
				HandleHovering();
			}
			else
			{
				isHovering = false;
				if (((Component)barPointerRectTransform).gameObject.activeSelf)
				{
					RectTransform obj = barPointerRectTransform;
					Vector3 localPosition = ((Transform)barPointerRectTransform).localPosition;
					localPosition.x = -1000f;
					((Transform)obj).localPosition = localPosition;
					((Component)barPointerRectTransform).gameObject.SetActive(false);
				}
			}
			if (hasValueChanged)
			{
				value = Mathf.Clamp(value, min, max);
				UpdateBarVisual();
				UpdateBarText();
				onValueChanged(previousValue = value);
			}
		}

		private void HandleDescription()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (!(((TMP_Text)descriptionTMP).text == currentDescription))
			{
				bool flag = !string.IsNullOrEmpty(((TMP_Text)descriptionTMP).text);
				backgroundFillRectTransform.sizeDelta = new Vector2(109.8f, flag ? 33f : 15f);
				backgroundOutlineRectTransform.sizeDelta = new Vector2(108f, flag ? 30.6f : 15f);
				if (Object.op_Implicit((Object)(object)base.repoScrollViewElement))
				{
					base.repoScrollViewElement.bottomPadding = (flag ? 25f : 1f);
					base.repoScrollViewElement.onSettingChanged?.Invoke();
				}
				currentDescription = ((TMP_Text)descriptionTMP).text;
			}
		}

		private void HandleHovering()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			float x = SemiFunc.UIMouseGetLocalPositionWithinRectTransform(barSizeRectTransform).x;
			float num = max - min;
			float num2 = precisionDecimal / num;
			float num3 = Mathf.Round(Mathf.Clamp01(x / barSizeRectTransform.sizeDelta.x) / num2) * num2;
			float x2 = Mathf.Clamp(((Transform)barSizeRectTransform).localPosition.x + num3 * barSizeRectTransform.sizeDelta.x, ((Transform)barSizeRectTransform).localPosition.x, ((Transform)barSizeRectTransform).localPosition.x + barSizeRectTransform.sizeDelta.x) - 2f;
			RectTransform obj = barPointerRectTransform;
			Vector3 localPosition = ((Transform)barPointerRectTransform).localPosition;
			localPosition.x = x2;
			((Transform)obj).localPosition = localPosition;
			if (Input.GetMouseButton(0))
			{
				value = min + num3 * num;
				if (hasValueChanged)
				{
					MenuManager.instance.MenuEffectClick((MenuClickEffectType)4, menuPage, -1f, -1f, false);
				}
			}
		}

		private void UpdateBarVisual()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			float num = barBehavior switch
			{
				BarBehavior.UpdateWithValue => normalizedValue, 
				BarBehavior.StaticAtMinimum => 0f, 
				BarBehavior.StaticAtMaximum => 1f, 
				_ => throw new ArgumentOutOfRangeException(), 
			};
			RectTransform obj = barRectTransform;
			RectTransform obj2 = barMaskRectTransform;
			Vector2 sizeDelta = default(Vector2);
			((Vector2)(ref sizeDelta))..ctor(num * 100f, 10f);
			obj2.sizeDelta = sizeDelta;
			obj.sizeDelta = sizeDelta;
		}

		private void UpdateBarText()
		{
			float num = value;
			if (prefix == null)
			{
				prefix = string.Empty;
			}
			if (postfix == null)
			{
				postfix = string.Empty;
			}
			string text = prefix;
			string[] array = stringOptions;
			text = ((array == null || array.Length == 0) ? (text + num.ToString($"F{precision}", CultureInfo.CurrentCulture)) : (text + (stringOptions.ElementAtOrDefault(Convert.ToInt32(num)) ?? stringOptions.First())));
			TextMeshProUGUI obj = maskedValueTMP;
			string text3 = (((TMP_Text)valueTMP).text = text + postfix);
			((TMP_Text)obj).text = text3;
		}
	}
	public sealed class REPOSpacer : REPOElement
	{
		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			base.rectTransform = (RectTransform)((Component)this).transform;
			base.rectTransform.pivot = Vector2.zero;
		}
	}
	public sealed class REPOTextScroller : MonoBehaviour
	{
		public TMP_Text textMeshPro;

		public int maxCharacters;

		public float initialWaitTime = 5f;

		public float startWaitTime = 3f;

		public float endWaitTime = 3f;

		public float scrollingSpeedInSecondsPerCharacter = 0.5f;

		private bool isInitial = true;

		public IEnumerator Animate()
		{
			while (true)
			{
				textMeshPro.firstVisibleCharacter = 0;
				textMeshPro.maxVisibleCharacters = maxCharacters;
				if (isInitial)
				{
					yield return (object)new WaitForSeconds(initialWaitTime);
					isInitial = false;
				}
				else
				{
					yield return (object)new WaitForSeconds(startWaitTime);
				}
				while (textMeshPro.maxVisibleCharacters < textMeshPro.text.Length)
				{
					TMP_Text obj = textMeshPro;
					int firstVisibleCharacter = obj.firstVisibleCharacter;
					obj.firstVisibleCharacter = firstVisibleCharacter + 1;
					TMP_Text obj2 = textMeshPro;
					firstVisibleCharacter = obj2.maxVisibleCharacters;
					obj2.maxVisibleCharacters = firstVisibleCharacter + 1;
					yield return (object)new WaitForSeconds(scrollingSpeedInSecondsPerCharacter);
				}
				yield return (object)new WaitForSeconds(endWaitTime);
			}
		}

		private void Awake()
		{
			if (!Object.op_Implicit((Object)(object)textMeshPro))
			{
				textMeshPro = (TMP_Text)(object)((Component)this).GetComponent<TextMeshProUGUI>();
			}
		}
	}
	public sealed class REPOToggle : REPOElement
	{
		public TextMeshProUGUI labelTMP;

		public TextMeshProUGUI leftButtonTMP;

		public TextMeshProUGUI rightButtonTMP;

		public Action<bool> onToggle;

		private RectTransform optionBox;

		private RectTransform optionBoxBehind;

		private Vector3 targetPosition;

		private Vector3 targetScale;

		public bool state { get; private set; }

		public void SetState(bool newState, bool invokeCallback)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_003c: 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)
			targetPosition = (newState ? new Vector3(137.8f, 12.3f) : new Vector3(212.644f, 12.3f));
			targetScale = (newState ? new Vector3(73f, 22f, 1f) : new Vector3(74f, 22f, 1f));
			if (invokeCallback && state != newState)
			{
				onToggle?.Invoke(newState);
			}
			state = newState;
		}

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_0159: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_0186: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			Transform transform = ((Component)this).transform;
			base.rectTransform = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			labelTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>();
			optionBox = (RectTransform)((Component)this).transform.Find("Option Box");
			optionBoxBehind = (RectTransform)((Component)this).transform.Find("Option Box Behind");
			Vector3 val = Vector3.right * 100f;
			Transform obj = ((Component)this).transform.Find("SliderBG");
			obj.localPosition += val;
			RectTransform obj2 = ((TMP_Text)labelTMP).rectTransform;
			obj2.sizeDelta -= new Vector2(0f, 4f);
			RectTransform obj3 = ((TMP_Text)labelTMP).rectTransform;
			((Transform)obj3).localPosition = ((Transform)obj3).localPosition + val;
			Transform obj4 = ((Component)this).transform.Find("RawImage");
			obj4.localPosition += val;
			Transform obj5 = ((Component)this).transform.Find("RawImage (1)");
			obj5.localPosition += val;
			Transform obj6 = ((Component)this).transform.Find("RawImage (2)");
			obj6.localPosition += val;
			Button[] componentsInChildren = ((Component)this).GetComponentsInChildren<Button>();
			Button val2 = componentsInChildren[0];
			Transform transform2 = ((Component)val2).transform;
			transform2.localPosition += val;
			val2.onClick = new ButtonClickedEvent();
			((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
			{
				SetState(newState: true, invokeCallback: true);
			});
			leftButtonTMP = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>();
			Button val3 = componentsInChildren[1];
			Transform transform3 = ((Component)val3).transform;
			transform3.localPosition += val;
			val3.onClick = new ButtonClickedEvent();
			((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
			{
				SetState(newState: false, invokeCallback: true);
			});
			rightButtonTMP = ((Component)val3).GetComponentInChildren<TextMeshProUGUI>();
			Object.Destroy((Object)(object)((Component)this).GetComponent<MenuTwoOptions>());
		}

		private void OnTransformParentChanged()
		{
			MenuButton[] componentsInChildren = ((Component)this).GetComponentsInChildren<MenuButton>();
			foreach (MenuButton obj in componentsInChildren)
			{
				REPOReflection.menuButton_ParentPage.SetValue(obj, ((Component)this).GetComponentInParent<MenuPage>());
			}
		}

		private void Update()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)optionBox) && Object.op_Implicit((Object)(object)optionBoxBehind))
			{
				((Transform)optionBox).localPosition = Vector3.Lerp(((Transform)optionBox).localPosition, targetPosition, 20f * Time.deltaTime);
				((Transform)optionBox).localScale = Vector3.Lerp(((Transform)optionBox).localScale, targetScale / 10f, 20f * Time.deltaTime);
				((Transform)optionBoxBehind).localPosition = Vector3.Lerp(((Transform)optionBoxBehind).localPosition, targetPosition, 20f * Time.deltaTime);
				((Transform)optionBoxBehind).localScale = Vector3.Lerp(((Transform)optionBoxBehind).localScale, new Vector3(targetScale.x + 4f, targetScale.y + 2f, 1f) / 10f, 20f * Time.deltaTime);
			}
		}
	}
}

BeepInEx/plugins/nickklmao-PlayerCount/PlayerCount.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PlayerCount")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlayerCount")]
[assembly: AssemblyTitle("PlayerCount")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PlayerCount
{
	[BepInPlugin("nickklmao.playercount", "Player Count", "1.0.0")]
	internal sealed class Entry : BaseUnityPlugin
	{
		private const string MOD_NAME = "Player Count";

		internal static readonly ManualLogSource logger = Logger.CreateLogSource("Player Count");

		private static void MenuPageLobby_AwakeHook(Action<MenuPageLobby> orig, MenuPageLobby self)
		{
			//IL_0037: 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)
			orig(self);
			Transform obj = Object.Instantiate<Transform>(((Component)self).transform.Find("Menu Button - Leave/ButtonText"), ((Component)self).transform.Find("Panel"));
			obj.localPosition = new Vector3(-154f, 10f);
			TextMeshProUGUI component = ((Component)obj).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).alignment = (TextAlignmentOptions)516;
			((TMP_Text)component).fontSize = 20f;
			((Graphic)component).color = Color.white;
			((Component)obj).gameObject.AddComponent<PlayerCountBehavior>().tmp = component;
		}

		private static void MenuPageEsc_AwakeHook(Action<MenuPageEsc> orig, MenuPageEsc self)
		{
			//IL_0037: 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)
			orig(self);
			Transform obj = Object.Instantiate<Transform>(((Component)self).transform.Find("Menu Button - Settings/ButtonText"), ((Component)self).transform.Find("Panel"));
			obj.localPosition = new Vector3(396f, -44.5f);
			TextMeshProUGUI component = ((Component)obj).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).alignment = (TextAlignmentOptions)513;
			((TMP_Text)component).fontSize = 20f;
			((Graphic)component).color = Color.white;
			((Component)obj).gameObject.AddComponent<PlayerCountBehavior>().tmp = component;
		}

		private void Awake()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)"Hooking `MenuPageLobby.Awake`");
			new Hook((MethodBase)AccessTools.Method(typeof(MenuPageLobby), "Awake", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageLobby>, MenuPageLobby>(MenuPageLobby_AwakeHook));
			logger.LogDebug((object)"Hooking `MenuPageEsc.Start`");
			new Hook((MethodBase)AccessTools.Method(typeof(MenuPageEsc), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageEsc>, MenuPageEsc>(MenuPageEsc_AwakeHook));
		}
	}
	internal sealed class PlayerCountBehavior : MonoBehaviour
	{
		internal TextMeshProUGUI tmp;

		private void Update()
		{
			if (Object.op_Implicit((Object)(object)tmp))
			{
				Room currentRoom = PhotonNetwork.CurrentRoom;
				((TMP_Text)tmp).text = $"Players: {((currentRoom != null) ? currentRoom.PlayerCount : 0)}/{((currentRoom != null) ? currentRoom.MaxPlayers : 6)}";
			}
		}
	}
}

BeepInEx/plugins/nickklmao-REPOConfig/REPOConfig.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using TMPro;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("REPOConfig")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+84c1ffb8b83bf9d0d357415bf1fb289b0a5a56fa")]
[assembly: AssemblyProduct("REPOConfig")]
[assembly: AssemblyTitle("REPOConfig")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace REPOConfig
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
	[Obsolete("This attribute will be removes soon.")]
	public class REPOConfigEntryAttribute : Attribute
	{
		public REPOConfigEntryAttribute(string displayName)
		{
		}

		public REPOConfigEntryAttribute(string displayName, int min, int max, string prefix = "", string postfix = "")
		{
		}

		public REPOConfigEntryAttribute(string displayName, float min, float max, string prefix = "", string postfix = "")
		{
		}

		public REPOConfigEntryAttribute(string displayName, float min, float max, int precision = 2, string prefix = "", string postfix = "")
		{
		}

		public REPOConfigEntryAttribute(string displayName, string prefix = "", string postfix = "")
		{
		}

		public REPOConfigEntryAttribute(string displayName, params string[] customOptions)
		{
		}
	}
	internal sealed class ConfigMenu
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static BuilderDelegate <>9__2_0;

			public static BuilderDelegate <>9__2_1;

			public static BuilderDelegate <>9__2_2;

			public static Action <>9__4_10;

			public static BuilderDelegate <>9__4_5;

			public static ScrollViewBuilderDelegate <>9__4_7;

			public static Func<ConfigEntryBase, string> <>9__5_0;

			public static ScrollViewBuilderDelegate <>9__5_2;

			public static Func<KeyValuePair<ConfigDefinition, ConfigEntryBase>, ConfigEntryBase> <>9__6_0;

			internal void <Initialize>b__2_0(Transform parent)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Mods", (Action)CreateModMenu, parent, new Vector2(48.3f, 55.5f));
			}

			internal void <Initialize>b__2_1(Transform parent)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Mods", (Action)CreateModMenu, parent, new Vector2(186f, 32f));
			}

			internal void <Initialize>b__2_2(Transform parent)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Mods", (Action)CreateModMenu, parent, new Vector2(126f, 86f));
			}

			internal void <CreateModList>b__4_5(Transform mainPageParent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Save Changes", (Action)delegate
				{
					KeyValuePair<ConfigEntryBase, object>[] array = changedEntries.ToArray();
					changedEntries.Clear();
					KeyValuePair<ConfigEntryBase, object>[] array2 = array;
					for (int i = 0; i < array2.Length; i++)
					{
						KeyValuePair<ConfigEntryBase, object> keyValuePair = array2[i];
						var (val2, boxedValue) = (KeyValuePair<ConfigEntryBase, object>)(ref keyValuePair);
						val2.BoxedValue = boxedValue;
					}
				}, mainPageParent, new Vector2(370f, 18f));
			}

			internal void <CreateModList>b__4_10()
			{
				KeyValuePair<ConfigEntryBase, object>[] array = changedEntries.ToArray();
				changedEntries.Clear();
				KeyValuePair<ConfigEntryBase, object>[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					KeyValuePair<ConfigEntryBase, object> keyValuePair = array2[i];
					var (val2, boxedValue) = (KeyValuePair<ConfigEntryBase, object>)(ref keyValuePair);
					val2.BoxedValue = boxedValue;
				}
			}

			internal RectTransform <CreateModList>b__4_7(Transform scrollView)
			{
				//IL_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0f, 10f);
				return ((REPOElement)MenuAPI.CreateREPOSpacer(scrollView, default(Vector2), val)).rectTransform;
			}

			internal string <CreateModEntries>b__5_0(ConfigEntryBase entry)
			{
				return entry.Definition.Section;
			}

			internal RectTransform <CreateModEntries>b__5_2(Transform scrollView)
			{
				//IL_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0f, 20f);
				return ((REPOElement)MenuAPI.CreateREPOSpacer(scrollView, default(Vector2), val)).rectTransform;
			}

			internal ConfigEntryBase <GetModConfigEntries>b__6_0(KeyValuePair<ConfigDefinition, ConfigEntryBase> configEntry)
			{
				return configEntry.Value;
			}
		}

		private static readonly Dictionary<ConfigEntryBase, object> changedEntries = new Dictionary<ConfigEntryBase, object>();

		internal static REPOButton lastClickedModButton;

		internal static void Initialize()
		{
			//IL_0014: 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_001f: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				BuilderDelegate val = delegate(Transform parent)
				{
					//IL_002b: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.CreateREPOButton("Mods", (Action)CreateModMenu, parent, new Vector2(48.3f, 55.5f));
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			MenuAPI.AddElementToMainMenu((BuilderDelegate)obj);
			object obj2 = <>c.<>9__2_1;
			if (obj2 == null)
			{
				BuilderDelegate val2 = delegate(Transform parent)
				{
					//IL_002b: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.CreateREPOButton("Mods", (Action)CreateModMenu, parent, new Vector2(186f, 32f));
				};
				<>c.<>9__2_1 = val2;
				obj2 = (object)val2;
			}
			MenuAPI.AddElementToLobbyMenu((BuilderDelegate)obj2);
			object obj3 = <>c.<>9__2_2;
			if (obj3 == null)
			{
				BuilderDelegate val3 = delegate(Transform parent)
				{
					//IL_002b: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.CreateREPOButton("Mods", (Action)CreateModMenu, parent, new Vector2(126f, 86f));
				};
				<>c.<>9__2_2 = val3;
				obj3 = (object)val3;
			}
			MenuAPI.AddElementToEscapeMenu((BuilderDelegate)obj3);
		}

		private static void CreateModMenu()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			changedEntries.Clear();
			lastClickedModButton = null;
			REPOPopupPage repoPopupPage = MenuAPI.CreateREPOPopupPage("Mods", (PresetSide)0, true, 0f);
			repoPopupPage.AddElement((BuilderDelegate)delegate(Transform parent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Back", (Action)delegate
				{
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					if (changedEntries.Count == 0)
					{
						repoPopupPage.ClosePage(true);
					}
					else
					{
						MenuAPI.OpenPopup("Unsaved Changes", Color.red, "You have unsaved changes, are you sure you want to exit?", (Action)delegate
						{
							repoPopupPage.ClosePage(true);
							changedEntries.Clear();
						}, (Action)null);
					}
				}, parent, new Vector2(66f, 18f));
			});
			CreateModList(repoPopupPage);
			repoPopupPage.OpenPage(false);
		}

		private static void CreateModList(REPOPopupPage mainModPage)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			foreach (KeyValuePair<string, ConfigEntryBase[]> modConfigEntry in GetModConfigEntries())
			{
				var (modName, configEntryBases) = (KeyValuePair<string, ConfigEntryBase[]>)(ref modConfigEntry);
				mainModPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform parent)
				{
					//IL_0018: 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_0040: Unknown result type (might be due to invalid IL or missing references)
					//IL_004a: Expected O, but got Unknown
					REPOButton modButton = MenuAPI.CreateREPOButton(modName, (Action)null, parent, default(Vector2));
					BuilderDelegate val = default(BuilderDelegate);
					((UnityEvent)modButton.button.onClick).AddListener((UnityAction)delegate
					{
						//IL_002b: Unknown result type (might be due to invalid IL or missing references)
						if (!((Object)(object)lastClickedModButton == (Object)(object)modButton))
						{
							if (changedEntries.Count == 0)
							{
								OpenPage();
							}
							else
							{
								MenuAPI.OpenPopup("Unsaved Changes", Color.red, "You have unsaved changes, are you sure you want to exit?", (Action)delegate
								{
									changedEntries.Clear();
									OpenPage();
								}, (Action)null);
							}
						}
					});
					return ((REPOElement)modButton).rectTransform;
					void OpenPage()
					{
						//IL_003c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0050: 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_0075: Expected O, but got Unknown
						//IL_0092: Unknown result type (might be due to invalid IL or missing references)
						//IL_0097: Unknown result type (might be due to invalid IL or missing references)
						//IL_0099: Expected O, but got Unknown
						//IL_009e: Expected O, but got Unknown
						//IL_00be: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c9: Expected O, but got Unknown
						MenuAPI.CloseAllPagesAddedOnTop();
						REPOPopupPage modPage = MenuAPI.CreateREPOPopupPage(modName, (PresetSide)1, false, 5f);
						modPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
						{
							//IL_0036: 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_0054: 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_0062: 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_007d: Unknown result type (might be due to invalid IL or missing references)
							REPOButton val9 = MenuAPI.CreateREPOButton("Reset To Default", (Action)delegate
							{
								//IL_0059: Unknown result type (might be due to invalid IL or missing references)
								MenuAPI.OpenPopup("Reset " + modName + "'" + (modName.ToLower().EndsWith('s') ? string.Empty : "s") + " settings?", Color.red, "Are you sure you want to reset all settings back to default?", (Action)ResetToDefault, (Action)null);
							}, scrollView, default(Vector2));
							RectTransform rectTransform = ((REPOElement)val9).rectTransform;
							Rect rect = modPage.maskRectTransform.rect;
							((Transform)rectTransform).localPosition = Vector2.op_Implicit(new Vector2((((Rect)(ref rect)).width - val9.GetLabelSize().x) * 0.5f, 0f));
							return ((REPOElement)val9).rectTransform;
						}, 0f, 0f);
						REPOPopupPage obj2 = modPage;
						object obj3 = <>c.<>9__4_5;
						if (obj3 == null)
						{
							BuilderDelegate val2 = delegate(Transform mainPageParent)
							{
								//IL_002f: Unknown result type (might be due to invalid IL or missing references)
								MenuAPI.CreateREPOButton("Save Changes", (Action)delegate
								{
									KeyValuePair<ConfigEntryBase, object>[] array3 = changedEntries.ToArray();
									changedEntries.Clear();
									KeyValuePair<ConfigEntryBase, object>[] array4 = array3;
									for (int j = 0; j < array4.Length; j++)
									{
										KeyValuePair<ConfigEntryBase, object> keyValuePair2 = array4[j];
										var (val8, boxedValue) = (KeyValuePair<ConfigEntryBase, object>)(ref keyValuePair2);
										val8.BoxedValue = boxedValue;
									}
								}, mainPageParent, new Vector2(370f, 18f));
							};
							<>c.<>9__4_5 = val2;
							obj3 = (object)val2;
						}
						obj2.AddElement((BuilderDelegate)obj3);
						REPOPopupPage obj4 = modPage;
						BuilderDelegate obj5 = val;
						if (obj5 == null)
						{
							BuilderDelegate val3 = delegate(Transform mainPageParent)
							{
								//IL_002f: Unknown result type (might be due to invalid IL or missing references)
								MenuAPI.CreateREPOButton("Revert", (Action)delegate
								{
									if (changedEntries.Count != 0)
									{
										changedEntries.Clear();
										lastClickedModButton = null;
										((UnityEvent)modButton.button.onClick).Invoke();
									}
								}, mainPageParent, new Vector2(585f, 18f));
							};
							BuilderDelegate val4 = val3;
							val = val3;
							obj5 = val4;
						}
						obj4.AddElement(obj5);
						REPOPopupPage obj6 = modPage;
						object obj7 = <>c.<>9__4_7;
						if (obj7 == null)
						{
							ScrollViewBuilderDelegate val5 = delegate(Transform scrollView)
							{
								//IL_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references)
								Vector2 val6 = default(Vector2);
								((Vector2)(ref val6))..ctor(0f, 10f);
								return ((REPOElement)MenuAPI.CreateREPOSpacer(scrollView, default(Vector2), val6)).rectTransform;
							};
							<>c.<>9__4_7 = val5;
							obj7 = (object)val5;
						}
						obj6.AddElementToScrollView((ScrollViewBuilderDelegate)obj7, 0f, 0f);
						CreateModEntries(modPage, configEntryBases);
						modPage.OpenPage(true);
						lastClickedModButton = modButton;
					}
					void ResetToDefault()
					{
						ConfigEntryBase[] array2 = configEntryBases;
						foreach (ConfigEntryBase obj in array2)
						{
							obj.BoxedValue = obj.DefaultValue;
						}
						changedEntries.Clear();
						lastClickedModButton = null;
						((UnityEvent)modButton.button.onClick).Invoke();
					}
				}, 0f, 0f);
			}
		}

		private static void CreateModEntries(REPOPopupPage modPage, ConfigEntryBase[] configEntryBases)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Expected O, but got Unknown
			foreach (IGrouping<string, ConfigEntryBase> group in from entry in configEntryBases
				group entry by entry.Definition.Section)
			{
				modPage.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOLabel(FixNaming(group.Key), scrollView, default(Vector2))).rectTransform), 0f, 0f);
				foreach (ConfigEntryBase entry2 in group)
				{
					string modName = FixNaming(entry2.Definition.Key);
					string description = (Entry.showDescriptions.Value ? entry2.Description.Description.Replace("\n", string.Empty) : string.Empty);
					ConfigEntryBase val = entry2;
					if (!(val is ConfigEntry<bool>))
					{
						if (!(val is ConfigEntry<float>))
						{
							if (!(val is ConfigEntry<int>))
							{
								if (!(val is ConfigEntry<string>))
								{
									if (val == null || !entry2.SettingType.IsSubclassOf(typeof(Enum)))
									{
										continue;
									}
									Type enumType = entry2.SettingType;
									string[] values = Enum.GetNames(enumType);
									modPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
									{
										//IL_0058: Unknown result type (might be due to invalid IL or missing references)
										//IL_005e: Unknown result type (might be due to invalid IL or missing references)
										REPOSlider val9 = MenuAPI.CreateREPOSlider(modName, description, (Action<int>)delegate(int i)
										{
											changedEntries[entry2] = Enum.Parse(enumType, values[i]);
										}, scrollView, values, entry2.BoxedValue.ToString(), default(Vector2), "", "", (BarBehavior)0);
										if (description.Length <= 43)
										{
											return ((REPOElement)val9).rectTransform;
										}
										((TMP_Text)val9.descriptionTMP).maxVisibleCharacters = (val9.repoTextScroller.maxCharacters = 43);
										val9.repoTextScroller.scrollingSpeedInSecondsPerCharacter = Entry.descriptionScrollSpeed.Value;
										val9.repoTextScroller.endWaitTime = (val9.repoTextScroller.initialWaitTime = 5f);
										val9.repoTextScroller.startWaitTime = 3f;
										((TMP_Text)val9.descriptionTMP).alignment = (TextAlignmentOptions)513;
										((MonoBehaviour)modPage).StartCoroutine(val9.repoTextScroller.Animate());
										return ((REPOElement)val9).rectTransform;
									}, 0f, 0f);
									continue;
								}
								AcceptableValueBase acceptableValues = entry2.Description.AcceptableValues;
								AcceptableValueList<string> acceptableValueList = acceptableValues as AcceptableValueList<string>;
								if (acceptableValueList == null)
								{
									continue;
								}
								modPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
								{
									//IL_007b: 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)
									REPOSlider val8 = MenuAPI.CreateREPOSlider(modName, description, (Action<string>)delegate(string s)
									{
										changedEntries[entry2] = s;
									}, scrollView, acceptableValueList.AcceptableValues, (string)entry2.BoxedValue, default(Vector2), "", "", (BarBehavior)0);
									if (description.Length <= 43)
									{
										return ((REPOElement)val8).rectTransform;
									}
									((TMP_Text)val8.descriptionTMP).maxVisibleCharacters = (val8.repoTextScroller.maxCharacters = 43);
									val8.repoTextScroller.scrollingSpeedInSecondsPerCharacter = Entry.descriptionScrollSpeed.Value;
									val8.repoTextScroller.endWaitTime = (val8.repoTextScroller.initialWaitTime = 5f);
									val8.repoTextScroller.startWaitTime = 3f;
									((TMP_Text)val8.descriptionTMP).alignment = (TextAlignmentOptions)513;
									((MonoBehaviour)modPage).StartCoroutine(val8.repoTextScroller.Animate());
									return ((REPOElement)val8).rectTransform;
								}, 0f, 0f);
								continue;
							}
							modPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
							{
								//IL_0090: Unknown result type (might be due to invalid IL or missing references)
								//IL_0096: Unknown result type (might be due to invalid IL or missing references)
								int num8;
								int num9;
								if (entry2.Description.AcceptableValues is AcceptableValueRange<int> val6)
								{
									num8 = val6.MinValue;
									num9 = val6.MaxValue;
								}
								else
								{
									num8 = -100;
									num9 = 100;
								}
								string text4 = modName;
								string text5 = description;
								Action<int> obj5 = delegate(int i)
								{
									changedEntries[entry2] = i;
								};
								int num10 = (int)entry2.BoxedValue;
								int num11 = num8;
								int num12 = num9;
								REPOSlider val7 = MenuAPI.CreateREPOSlider(text4, text5, obj5, scrollView, default(Vector2), num11, num12, num10, "", "", (BarBehavior)0);
								if (description.Length <= 43)
								{
									return ((REPOElement)val7).rectTransform;
								}
								((TMP_Text)val7.descriptionTMP).maxVisibleCharacters = (val7.repoTextScroller.maxCharacters = 43);
								val7.repoTextScroller.scrollingSpeedInSecondsPerCharacter = Entry.descriptionScrollSpeed.Value;
								val7.repoTextScroller.endWaitTime = (val7.repoTextScroller.initialWaitTime = 5f);
								val7.repoTextScroller.startWaitTime = 3f;
								((TMP_Text)val7.descriptionTMP).alignment = (TextAlignmentOptions)513;
								((MonoBehaviour)modPage).StartCoroutine(val7.repoTextScroller.Animate());
								return ((REPOElement)val7).rectTransform;
							}, 0f, 0f);
							continue;
						}
						modPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
						{
							//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
							//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
							int num = 2;
							float num2;
							float num3;
							if (entry2.Description.AcceptableValues is AcceptableValueRange<float> val4)
							{
								num2 = val4.MinValue;
								num3 = val4.MaxValue;
								num = Mathf.Max(new int[3]
								{
									GetDecimalPlaces(num2),
									GetDecimalPlaces(num3),
									GetDecimalPlaces((float)entry2.DefaultValue)
								});
							}
							else
							{
								num2 = -100f;
								num3 = 100f;
							}
							string text2 = modName;
							string text3 = description;
							Action<float> obj4 = delegate(float f)
							{
								changedEntries[entry2] = f;
							};
							float num4 = (float)entry2.BoxedValue;
							float num5 = num2;
							float num6 = num3;
							int num7 = num;
							REPOSlider val5 = MenuAPI.CreateREPOSlider(text2, text3, obj4, scrollView, default(Vector2), num5, num6, num7, num4, "", "", (BarBehavior)0);
							if (description.Length <= 43)
							{
								return ((REPOElement)val5).rectTransform;
							}
							((TMP_Text)val5.descriptionTMP).maxVisibleCharacters = (val5.repoTextScroller.maxCharacters = 43);
							val5.repoTextScroller.scrollingSpeedInSecondsPerCharacter = Entry.descriptionScrollSpeed.Value;
							val5.repoTextScroller.endWaitTime = (val5.repoTextScroller.initialWaitTime = 5f);
							val5.repoTextScroller.startWaitTime = 3f;
							((TMP_Text)val5.descriptionTMP).alignment = (TextAlignmentOptions)513;
							((MonoBehaviour)modPage).StartCoroutine(val5.repoTextScroller.Animate());
							return ((REPOElement)val5).rectTransform;
						}, 0f, 0f);
						continue;
					}
					modPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
					{
						//IL_004d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0053: Unknown result type (might be due to invalid IL or missing references)
						string text = modName;
						Action<bool> obj3 = delegate(bool b)
						{
							changedEntries[entry2] = b;
						};
						bool flag = (bool)entry2.BoxedValue;
						return ((REPOElement)MenuAPI.CreateREPOToggle(text, obj3, scrollView, default(Vector2), "ON", "OFF", flag)).rectTransform;
					}, 0f, 0f);
				}
				REPOPopupPage obj = modPage;
				object obj2 = <>c.<>9__5_2;
				if (obj2 == null)
				{
					ScrollViewBuilderDelegate val2 = delegate(Transform scrollView)
					{
						//IL_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references)
						Vector2 val3 = default(Vector2);
						((Vector2)(ref val3))..ctor(0f, 20f);
						return ((REPOElement)MenuAPI.CreateREPOSpacer(scrollView, default(Vector2), val3)).rectTransform;
					};
					<>c.<>9__5_2 = val2;
					obj2 = (object)val2;
				}
				obj.AddElementToScrollView((ScrollViewBuilderDelegate)obj2, 0f, 0f);
			}
		}

		private static Dictionary<string, ConfigEntryBase[]> GetModConfigEntries()
		{
			Dictionary<string, ConfigEntryBase[]> dictionary = new Dictionary<string, ConfigEntryBase[]>();
			foreach (PluginInfo value in Chainloader.PluginInfos.Values)
			{
				List<ConfigEntryBase> list = new List<ConfigEntryBase>();
				foreach (ConfigEntryBase item in ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)value.Instance.Config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> configEntry) => configEntry.Value))
				{
					ConfigDescription description = item.Description;
					object[] array = ((description != null) ? description.Tags : null);
					if (array == null || (!array.Contains("HideREPOConfig") && !array.Contains("HideFromREPOConfig")))
					{
						list.Add(item);
					}
				}
				if (list.Count > 0)
				{
					dictionary.TryAdd(FixNaming(value.Metadata.Name), list.ToArray());
				}
			}
			return dictionary;
		}

		private static string FixNaming(string input)
		{
			input = Regex.Replace(input, "([a-z])([A-Z])", "$1 $2");
			input = Regex.Replace(input, "([A-Z])([A-Z][a-z])", "$1 $2");
			input = Regex.Replace(input, "\\s+", " ");
			input = Regex.Replace(input, "([A-Z]\\.)\\s([A-Z]\\.)", "$1$2");
			return input.Trim();
		}

		private static int GetDecimalPlaces(float value)
		{
			string text = value.ToString(CultureInfo.InvariantCulture);
			int num = text.IndexOf('.');
			if (num != -1)
			{
				string text2 = text;
				int num2 = num + 1;
				return text2.Substring(num2, text2.Length - num2).Length;
			}
			return 0;
		}
	}
	[BepInPlugin("nickklmao.repoconfig", "REPO Config", "1.1.7")]
	[BepInDependency("nickklmao.menulib", "2.0.0")]
	internal sealed class Entry : BaseUnityPlugin
	{
		private const string MOD_NAME = "REPO Config";

		internal static readonly ManualLogSource logger = Logger.CreateLogSource("REPO Config");

		internal static ConfigEntry<bool> showDescriptions;

		internal static ConfigEntry<float> descriptionScrollSpeed;

		private static ConfigEntry<bool> showInGame;

		private static void MenuPageMain_StartHook(Action<MenuPageMain> orig, MenuPageMain self)
		{
			//IL_0082: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			IOrderedEnumerable<Transform> orderedEnumerable = from Transform transform in (IEnumerable)((Component)self).transform
				where ((Object)transform).name.Contains("Menu Button")
				orderby transform.localPosition.y descending
				select transform;
			float num = 224f;
			foreach (Transform item in orderedEnumerable)
			{
				if (((Object)item).name.Contains("Quit"))
				{
					num -= 34f;
				}
				Vector3 localPosition = item.localPosition;
				localPosition.y = num;
				item.localPosition = localPosition;
				num -= 34f;
			}
			orig(self);
		}

		private void Awake()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			showDescriptions = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Descriptions", true, (ConfigDescription)null);
			showDescriptions.SettingChanged += delegate
			{
				REPOButton lastClickedModButton = ConfigMenu.lastClickedModButton;
				if (Object.op_Implicit((Object)(object)lastClickedModButton))
				{
					ConfigMenu.lastClickedModButton = null;
					((UnityEvent)lastClickedModButton.button.onClick).Invoke();
				}
			};
			descriptionScrollSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Description Scroll Speed", 0.15f, new ConfigDescription("How fast descriptions scroll. (Seconds per character)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>()));
			showInGame = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show In Game", true, new ConfigDescription(string.Empty, (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" }));
			if (showInGame.Value)
			{
				logger.LogDebug((object)"Hooking `MenuPageMain.Start`");
				new Hook((MethodBase)AccessTools.Method(typeof(MenuPageMain), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageMain>, MenuPageMain>(MenuPageMain_StartHook));
				ConfigMenu.Initialize();
			}
		}
	}
}

BeepInEx/plugins/OnlyRyan-TumbleGuard/TumbleGuard.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TumbleGuard")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TumbleGuard")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e431d78a-5164-4e8b-acf6-6ed80d0de4b5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Root
{
	[BepInPlugin("Kraut-TumbleGuard-v1.1.0", "TumbleGuard", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "Kraut-TumbleGuard-v1.1.0";

		public const string modName = "TumbleGuard";

		public const string modVersion = "1.1.0";

		public static Plugin PluginInstance;

		public static ManualLogSource LoggerInstance;

		private readonly Harmony harmony = new Harmony("Kraut-TumbleGuard-v1.1.0");

		public void Awake()
		{
			if ((Object)(object)PluginInstance == (Object)null)
			{
				PluginInstance = this;
			}
			LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger;
			harmony.PatchAll();
		}
	}
}
namespace TumbleGuard
{
	[HarmonyPatch(typeof(PlayerTumble))]
	internal class PlayerTumblePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static void PreFixUpdate(PlayerTumble __instance, PhysGrabObject ___physGrabObject)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)___physGrabObject == (Object)null) && ___physGrabObject.grabbed && __instance.playerAvatar.photonView.IsMine && Input.GetKey((KeyCode)122))
			{
				___physGrabObject.playerGrabbing.ForEach(delegate(PhysGrabber physGrabber)
				{
					physGrabber.photonView.RPC("ReleaseObjectRPC", (RpcTarget)0, new object[2] { true, 0.1f });
				});
			}
		}
	}
}

BeepInEx/plugins/Pudack-KirbyBowtie/KirbyBowtie.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using KirbyBowtie.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("KirbyBowtie")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KirbyBowtie")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ee0c183f-9b5c-497e-a261-aa93f86f1541")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace KirbyBowtie
{
	[BepInPlugin("pudack.KirbyBowtie", "KirbyBowtie", "1.0.0")]
	public class KirbyBowtieBase : BaseUnityPlugin
	{
		private const string modGUID = "pudack.KirbyBowtie";

		private const string modName = "KirbyBowtie";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("pudack.KirbyBowtie");

		internal static KirbyBowtieBase instance;

		internal ManualLogSource mls;

		internal static AudioClip[] kirbysuckstart;

		internal static AudioClip[] kirbysuckloop;

		internal static AudioClip[] kirbyhi;

		public void Awake()
		{
			if (instance == null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("pudack.KirbyBowtie");
			mls.LogInfo((object)"KirbyBowtie is loading...");
			string location = ((BaseUnityPlugin)instance).Info.Location;
			location = location.TrimEnd("KirbyBowtie.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "kirbyfx");
			if (val == null)
			{
				mls.LogError((object)"Failed to load audio asset!");
				return;
			}
			kirbysuckstart = val.LoadAssetWithSubAssets<AudioClip>("Assets/kirbysuckstart.wav");
			kirbysuckloop = val.LoadAssetWithSubAssets<AudioClip>("Assets/kirbysuckloop.wav");
			kirbyhi = val.LoadAssetWithSubAssets<AudioClip>("Assets/kirbyhi.wav");
			harmony.PatchAll(typeof(KirbyBowtieBase));
			harmony.PatchAll(typeof(EnemyBowtieAnimPatch));
			mls.LogInfo((object)"KirbyBowtie has loaded");
		}
	}
}
namespace KirbyBowtie.Patches
{
	[HarmonyPatch(typeof(EnemyBowtieAnim))]
	internal class EnemyBowtieAnimPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void ReplaceAudio(EnemyBowtieAnim __instance)
		{
			__instance.yellStartSound.Sounds = KirbyBowtieBase.kirbysuckstart.ToArray();
			__instance.yellStartSoundGlobal.Sounds = KirbyBowtieBase.kirbysuckstart.ToArray();
			__instance.YellLoopSound.Sounds = KirbyBowtieBase.kirbysuckloop.ToArray();
			__instance.YellLoopSoundGlobal.Sounds = KirbyBowtieBase.kirbysuckloop.ToArray();
			__instance.noticeSound.Sounds = KirbyBowtieBase.kirbyhi.ToArray();
		}
	}
}

BeepInEx/plugins/Rebateman-LateJoin/LateJoin.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("LateJoin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+bab70bccf3337fbc8e229143cdce3eeb6a090559")]
[assembly: AssemblyProduct("LateJoin")]
[assembly: AssemblyTitle("LateJoin")]
[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 LateJoin
{
	[BepInPlugin("rebateman.latejoin", "Late Join", "0.1.2")]
	internal sealed class Entry : BaseUnityPlugin
	{
		private const string MOD_NAME = "Late Join";

		internal static readonly ManualLogSource logger = Logger.CreateLogSource("Late Join");

		private static void RunManager_ChangeLevelHook(Action<RunManager, bool, bool, ChangeLevelType> orig, RunManager self, bool _completedLevel, bool _levelFailed, ChangeLevelType _changeLevelType)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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)
			if (_levelFailed || !PhotonNetwork.IsMasterClient)
			{
				orig(self, _completedLevel, _levelFailed, _changeLevelType);
				return;
			}
			object value = AccessTools.Field(typeof(RunManager), "runManagerPUN").GetValue(self);
			object? value2 = AccessTools.Field(typeof(RunManagerPUN), "photonView").GetValue(value);
			PhotonView val = (PhotonView)((value2 is PhotonView) ? value2 : null);
			PhotonNetwork.RemoveBufferedRPCs(val.ViewID, (string)null, (int[])null);
			PhotonView[] array = Object.FindObjectsOfType<PhotonView>();
			foreach (PhotonView val2 in array)
			{
				Scene scene = ((Component)val2).gameObject.scene;
				if (((Scene)(ref scene)).buildIndex != -1)
				{
					ClearPhotonCache(val2);
				}
			}
			orig(self, _completedLevel, arg3: false, _changeLevelType);
			bool flag = SemiFunc.RunIsLobbyMenu() || SemiFunc.RunIsLobby();
			if (flag)
			{
				SteamManager.instance.UnlockLobby();
			}
			else
			{
				SteamManager.instance.LockLobby();
			}
			PhotonNetwork.CurrentRoom.IsOpen = flag;
		}

		private static void PlayerAvatar_SpawnHook(Action<PlayerAvatar, Vector3, Quaternion> orig, PlayerAvatar self, Vector3 position, Quaternion rotation)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (!(bool)AccessTools.Field(typeof(PlayerAvatar), "spawned").GetValue(self))
			{
				orig(self, position, rotation);
			}
		}

		private static void LevelGenerator_StartHook(Action<LevelGenerator> orig, LevelGenerator self)
		{
			if ((PhotonNetwork.IsMasterClient && SemiFunc.RunIsShop()) || SemiFunc.RunIsLobby())
			{
				PhotonNetwork.RemoveBufferedRPCs(self.PhotonView.ViewID, (string)null, (int[])null);
			}
			orig(self);
		}

		private static void PlayerAvatar_StartHook(Action<PlayerAvatar> orig, PlayerAvatar self)
		{
			orig(self);
			if ((PhotonNetwork.IsMasterClient || SemiFunc.RunIsLobby()) && SemiFunc.RunIsShop())
			{
				self.photonView.RPC("LoadingLevelAnimationCompletedRPC", (RpcTarget)3, Array.Empty<object>());
			}
		}

		private static void ClearPhotonCache(PhotonView photonView)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			object? value = AccessTools.Field(typeof(PhotonNetwork), "removeFilter").GetValue(null);
			Hashtable val = (Hashtable)((value is Hashtable) ? value : null);
			object value2 = AccessTools.Field(typeof(PhotonNetwork), "keyByteSeven").GetValue(null);
			object? value3 = AccessTools.Field(typeof(PhotonNetwork), "ServerCleanOptions").GetValue(null);
			RaiseEventOptions val2 = (RaiseEventOptions)((value3 is RaiseEventOptions) ? value3 : null);
			MethodInfo methodInfo = AccessTools.Method(typeof(PhotonNetwork), "RaiseEventInternal", (Type[])null, (Type[])null);
			val[value2] = photonView.InstantiationId;
			val2.CachingOption = (EventCaching)6;
			methodInfo.Invoke(null, new object[4]
			{
				(byte)202,
				val,
				val2,
				SendOptions.SendReliable
			});
		}

		private void Awake()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)"Hooking `RunManager.ChangeLevel`");
			new Hook((MethodBase)AccessTools.Method(typeof(RunManager), "ChangeLevel", (Type[])null, (Type[])null), (Delegate)new Action<Action<RunManager, bool, bool, ChangeLevelType>, RunManager, bool, bool, ChangeLevelType>(RunManager_ChangeLevelHook));
			logger.LogDebug((object)"Hooking `PlayerAvatar.Spawn`");
			new Hook((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "Spawn", (Type[])null, (Type[])null), (Delegate)new Action<Action<PlayerAvatar, Vector3, Quaternion>, PlayerAvatar, Vector3, Quaternion>(PlayerAvatar_SpawnHook));
			logger.LogDebug((object)"Hooking `LevelGenerator.Start`");
			new Hook((MethodBase)AccessTools.Method(typeof(LevelGenerator), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<LevelGenerator>, LevelGenerator>(LevelGenerator_StartHook));
			logger.LogDebug((object)"Hooking `PlayerAvatar.Start`");
			new Hook((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<PlayerAvatar>, PlayerAvatar>(PlayerAvatar_StartHook));
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LateJoin";

		public const string PLUGIN_NAME = "LateJoin";

		public const string PLUGIN_VERSION = "0.1.1";
	}
}

BeepInEx/plugins/REPOknorton-DestructionTextReplacer/oknorton.DestructTextReplacer.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;

[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("oknorton.DestructTextReplacer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DestructTextReplacer")]
[assembly: AssemblyTitle("oknorton.DestructTextReplacer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DestructTextReplacer
{
	public static class ConfigManager
	{
		private static ConfigEntry<string> customWordsConfig;

		private static ConfigEntry<string> leftBehindWordsConfig;

		private static ConfigEntry<string> cancelSelfDestructWordsConfig;

		public static void Initialize(ConfigFile config)
		{
			customWordsConfig = config.Bind<string>("SelfDestruct", "Words", "i'm out,Farewell,Adieu,sayonara,Auf Wiedersehen,adios,ciao,Au Revoir,hasta la vista,see You Later,later,peace OUT,catch you later,later gator,toodles,bye bye,bye,AAAAAAAAAAAAH!,AAAAAAAAAAAAAAAAAAAAAAAH!,bye... ... oh?,this will hurt,it's over for me,why me?,I'm sorry,i see the light,sad but necessary,HEJ DÅ!", "Comma-separated list of self-destruct words");
			leftBehindWordsConfig = config.Bind<string>("LeftBehind", "Words", "I'm sorry,Goodbye,see you later,hope this works out,good luck,peace out,I'm out of here", "Comma-separated list of words for left behind message");
			cancelSelfDestructWordsConfig = config.Bind<string>("SelfDestructCancel", "Words", "Self-destruct sequence aborted!,Phew, that was close!,Canceling self-destruct...,Stand down, crisis averted,False alarm, standing by,Guess I’ll live for now", "Comma-separated list of cancel self-destruct messages");
		}

		public static List<string> GetCancelSelfDestructWords()
		{
			((BaseUnityPlugin)Plugin.Instance).Config.Reload();
			if (cancelSelfDestructWordsConfig == null)
			{
				Debug.LogError((object)"ConfigManager not initialized!");
				return new List<string> { "Error: Config not loaded!" };
			}
			string value = cancelSelfDestructWordsConfig.Value;
			List<string> list = new List<string>(value.Split(','));
			return (list.Count > 0) ? list : new List<string> { "Default cancel message missing!" };
		}

		public static List<string> GetSelfDestructWords()
		{
			((BaseUnityPlugin)Plugin.Instance).Config.Reload();
			if (customWordsConfig == null)
			{
				Debug.LogError((object)"ConfigManager not initialized!");
				return new List<string> { "Error: Config not loaded!" };
			}
			string value = customWordsConfig.Value;
			List<string> list = new List<string>(value.Split(','));
			return (list.Count > 0) ? list : new List<string> { "Default wordlist missing!" };
		}

		public static List<string> GetLeftBehindWords()
		{
			((BaseUnityPlugin)Plugin.Instance).Config.Reload();
			if (leftBehindWordsConfig == null)
			{
				Debug.LogError((object)"ConfigManager not initialized!");
				return new List<string> { "Error: Config not loaded!" };
			}
			string value = leftBehindWordsConfig.Value;
			List<string> list = new List<string>(value.Split(','));
			return (list.Count > 0) ? list : new List<string> { "Default left behind wordlist missing!" };
		}
	}
	[BepInPlugin("oknorton.DestructTextReplacer", "DestructTextReplacer", "1.0.0")]
	[BepInProcess("REPO.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private static Harmony _harmony;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			Instance = this;
			ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin oknorton.DestructTextReplacer is loaded!");
			_harmony = new Harmony("oknorton.DestructTextReplacer");
			_harmony.PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "oknorton.DestructTextReplacer";

		public const string PLUGIN_NAME = "DestructTextReplacer";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DestructTextReplacer.Patches
{
	[HarmonyPatch(typeof(ChatManager))]
	public class ChatManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(ChatManager), "Awake")]
		private static void AwakePostFix()
		{
			Debug.Log((object)"Starting the patch: Postfix for awake");
		}

		[HarmonyPrefix]
		[HarmonyPatch("PossessSelfDestruction")]
		private static bool PossessSelfDestructionPreFix(ChatManager __instance)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(ChatManager), "playerAvatar");
				object value = fieldInfo.GetValue(__instance);
				if (value == null)
				{
					return false;
				}
				FieldInfo fieldInfo2 = AccessTools.Field(value.GetType(), "isDisabled");
				if ((bool)fieldInfo2.GetValue(value))
				{
					return false;
				}
				MethodInfo methodInfo = AccessTools.Method(typeof(ChatManager), "PossessChatScheduleStart", (Type[])null, (Type[])null);
				methodInfo.Invoke(__instance, new object[1] { -1 });
				UnityEvent val = new UnityEvent();
				MethodInfo method = AccessTools.Method(typeof(ChatManager), "SelfDestruct", (Type[])null, (Type[])null);
				UnityAction val2 = (UnityAction)Delegate.CreateDelegate(typeof(UnityAction), __instance, method);
				val.AddListener(val2);
				List<string> selfDestructWords = ConfigManager.GetSelfDestructWords();
				string text = selfDestructWords[Random.Range(0, selfDestructWords.Count)];
				MethodInfo methodInfo2 = AccessTools.Method(typeof(ChatManager), "PossessChat", (Type[])null, (Type[])null);
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)3,
					text,
					2f,
					Color.red,
					0f,
					true,
					2,
					val
				});
				MethodInfo methodInfo3 = AccessTools.Method(typeof(ChatManager), "PossessChatScheduleEnd", (Type[])null, (Type[])null);
				methodInfo3.Invoke(__instance, null);
				return false;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Error in SelfDestruct patch: " + ex.Message + "\n" + ex.StackTrace));
				return true;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("PossessLeftBehind")]
		private static bool PossessLeftBehindPreFix(ChatManager __instance)
		{
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Expected O, but got Unknown
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Expected O, but got Unknown
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(ChatManager), "playerAvatar");
				object value = fieldInfo.GetValue(__instance);
				if (value == null)
				{
					return false;
				}
				FieldInfo fieldInfo2 = AccessTools.Field(value.GetType(), "isDisabled");
				if ((bool)fieldInfo2.GetValue(value))
				{
					return false;
				}
				FieldInfo fieldInfo3 = AccessTools.Field(value.GetType(), "RoomVolumeCheck");
				object value2 = fieldInfo3.GetValue(value);
				FieldInfo fieldInfo4 = AccessTools.Field(value2.GetType(), "inTruck");
				if ((bool)fieldInfo4.GetValue(value2))
				{
					return false;
				}
				FieldInfo fieldInfo5 = AccessTools.Field(typeof(ChatManager), "betrayalActive");
				fieldInfo5.SetValue(__instance, true);
				MethodInfo methodInfo = AccessTools.Method(typeof(ChatManager), "PossessChatScheduleStart", (Type[])null, (Type[])null);
				methodInfo.Invoke(__instance, new object[1] { 2 });
				string text = SemiFunc.MessageGeneratedGetLeftBehind();
				MethodInfo methodInfo2 = AccessTools.Method(typeof(ChatManager), "PossessChat", (Type[])null, (Type[])null);
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					text,
					0.5f,
					Color.red,
					0f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"I need to get to the truck in...",
					0.4f,
					Color.red,
					0f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"10...",
					0.25f,
					Color.red,
					0f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"9...",
					0.25f,
					Color.red,
					0.3f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"8...",
					0.25f,
					Color.red,
					0.3f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"7...",
					0.25f,
					Color.red,
					0.3f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"6...",
					0.25f,
					Color.red,
					0.3f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"5...",
					0.25f,
					Color.red,
					0.3f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"4...",
					0.25f,
					Color.red,
					0.3f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"3...",
					0.25f,
					Color.red,
					0.3f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"2...",
					0.25f,
					Color.red,
					0.3f,
					true,
					2,
					null
				});
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)4,
					"1...",
					0.5f,
					Color.red,
					0.3f,
					true,
					2,
					null
				});
				UnityEvent val = new UnityEvent();
				MethodInfo method = AccessTools.Method(typeof(ChatManager), "BetrayalSelfDestruct", (Type[])null, (Type[])null);
				UnityAction val2 = (UnityAction)Delegate.CreateDelegate(typeof(UnityAction), __instance, method);
				val.AddListener(val2);
				List<string> leftBehindWords = ConfigManager.GetLeftBehindWords();
				string text2 = leftBehindWords[Random.Range(0, leftBehindWords.Count)];
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)3,
					text2,
					2f,
					Color.red,
					0f,
					true,
					2,
					val
				});
				MethodInfo methodInfo3 = AccessTools.Method(typeof(ChatManager), "PossessChatScheduleEnd", (Type[])null, (Type[])null);
				methodInfo3.Invoke(__instance, null);
				return false;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Error in LeftBehind patch: " + ex.Message + "\n" + ex.StackTrace));
				return true;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("PossessCancelSelfDestruction")]
		private static bool PossessCancelSelfDestructionPreFix(ChatManager __instance)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(ChatManager), "playerAvatar");
				object value = fieldInfo.GetValue(__instance);
				if (value == null)
				{
					return false;
				}
				FieldInfo fieldInfo2 = AccessTools.Field(value.GetType(), "isDisabled");
				if ((bool)fieldInfo2.GetValue(value))
				{
					return false;
				}
				MethodInfo methodInfo = AccessTools.Method(typeof(ChatManager), "PossessChatScheduleStart", (Type[])null, (Type[])null);
				methodInfo.Invoke(__instance, new object[1] { 1 });
				List<string> cancelSelfDestructWords = ConfigManager.GetCancelSelfDestructWords();
				string text = cancelSelfDestructWords[Random.Range(0, cancelSelfDestructWords.Count)];
				MethodInfo methodInfo2 = AccessTools.Method(typeof(ChatManager), "PossessChat", (Type[])null, (Type[])null);
				methodInfo2.Invoke(__instance, new object[8]
				{
					(object)(PossessChatID)5,
					text,
					2f,
					Color.green,
					0f,
					false,
					0,
					null
				});
				MethodInfo methodInfo3 = AccessTools.Method(typeof(ChatManager), "PossessChatScheduleEnd", (Type[])null, (Type[])null);
				methodInfo3.Invoke(__instance, null);
				return false;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Error in CancelSelfDestruct patch: " + ex.Message + "\n" + ex.StackTrace));
				return true;
			}
		}
	}
}

BeepInEx/plugins/Snowlance-NoDamageInShop/NoDamageInShop.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("NoDamageInShop")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9e23f68e87b4e00530b9caa95b9807625eb768d9")]
[assembly: AssemblyProduct("NoDamageInShop")]
[assembly: AssemblyTitle("NoDamageInShop")]
[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;
		}
	}
}
[BepInPlugin("Snowlance.NoDamageInShop", "NoDamageInShop", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
	public const string modGUID = "Snowlance.NoDamageInShop";

	public const string modName = "NoDamageInShop";

	public const string modVersion = "1.0.1";

	public static Plugin PluginInstance;

	public static ManualLogSource LoggerInstance;

	private readonly Harmony harmony = new Harmony("Snowlance.NoDamageInShop");

	public void Awake()
	{
		if ((Object)(object)PluginInstance == (Object)null)
		{
			PluginInstance = this;
		}
		LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger;
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Snowlance.NoDamageInShop v1.0.1 has loaded!");
	}
}
namespace NoDamageInShop
{
	[HarmonyPatch]
	public class PlayerHealthPatch
	{
		private static ManualLogSource logger = Plugin.LoggerInstance;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
		public static bool HurtPrefix()
		{
			if ((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelShop)
			{
				if (ChatManager.instance.betrayalActive)
				{
					return true;
				}
				return false;
			}
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

BeepInEx/plugins/soundedsquash-Enemy_And_Valuable_Spawn_Manager/SpawnManager.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using SpawnManager.Extensions;
using SpawnManager.Managers;
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: AssemblyCompany("SpawnManager")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyInformationalVersion("0.2.2+3fd126de290151b0db4d3f77bbc91049e1901874")]
[assembly: AssemblyProduct("SpawnManager")]
[assembly: AssemblyTitle("SpawnManager")]
[assembly: AssemblyVersion("0.2.2.0")]
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 SpawnManager
{
	[BepInPlugin("soundedsquash.spawnmanager", "Enemy/Valuable Spawn Manager", "0.2.2.0")]
	public class MuteToggleBase : BaseUnityPlugin
	{
		private const string PluginGuid = "soundedsquash.spawnmanager";

		private const string PluginName = "Enemy/Valuable Spawn Manager";

		private const string PluginVersion = "0.2.2.0";

		private readonly Harmony _harmony = new Harmony("soundedsquash.spawnmanager");

		private static readonly ManualLogSource ManualLogSource = Logger.CreateLogSource("soundedsquash.spawnmanager");

		public void Awake()
		{
			Settings.Initialize(((BaseUnityPlugin)this).Config, ManualLogSource);
			MenuModManager.Initialize();
			_harmony.PatchAll();
			ManualLogSource.LogInfo((object)"Enemy/Valuable Spawn Manager loaded");
		}
	}
	public static class Settings
	{
		public static ConfigEntry<string> DisabledEnemies { get; private set; }

		public static ConfigEntry<string> DisabledValuables { get; private set; }

		public static ConfigEntry<string> DisabledLevels { get; private set; }

		public static ManualLogSource Logger { get; private set; }

		internal static void Initialize(ConfigFile config, ManualLogSource logger)
		{
			Logger = logger;
			DisabledEnemies = config.Bind<string>("Enemies", "DisabledList", "", "Comma-separated list of enemy names to disable. (e.g. \"Apex Predator,Headman\")");
			DisabledValuables = config.Bind<string>("Valuables", "DisabledList", "", "Comma-separated list of valuable names to disable. (e.g. \"Valuable Television,Valuable Diamond Display\")");
			DisabledLevels = config.Bind<string>("Levels", "DisabledList", "", "Comma-separated list of level names to disable. (e.g. \"Level - Manor\")");
		}

		public static List<string> GetDisabledSettingsEntryListNames(ConfigEntry<string> settingsVariable)
		{
			return ConvertStringToList(settingsVariable.Value);
		}

		private static List<string> ConvertStringToList(string str)
		{
			if (string.IsNullOrEmpty(str))
			{
				return new List<string>();
			}
			return new List<string>(str.Split(',', StringSplitOptions.RemoveEmptyEntries));
		}

		public static void UpdateSettingsListEntry(ConfigEntry<string> settingsVariable, string entry, bool enabled)
		{
			List<string> disabledSettingsEntryListNames = GetDisabledSettingsEntryListNames(settingsVariable);
			if (enabled)
			{
				disabledSettingsEntryListNames.Remove(entry);
				if (settingsVariable == DisabledValuables)
				{
					ValuableManager.RestoreValuableObjects();
				}
				else if (settingsVariable == DisabledLevels)
				{
					LevelManager.RestoreLevels();
				}
			}
			else if (!disabledSettingsEntryListNames.Contains(entry))
			{
				disabledSettingsEntryListNames.Add(entry);
			}
			settingsVariable.Value = string.Join(",", disabledSettingsEntryListNames);
		}

		public static bool IsSettingsListEntryEnabled(ConfigEntry<string> settingsVariable, string entry)
		{
			return !GetDisabledSettingsEntryListNames(settingsVariable).Contains(entry);
		}
	}
}
namespace SpawnManager.Patches
{
	[HarmonyPatch(typeof(EnemyDirector))]
	public static class EnemyDirectorPatches
	{
		private static List<EnemySetup> _startingEnemyList = new List<EnemySetup>();

		private static bool _isListSet;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void EnemyDirectorStartPostfix()
		{
			EnemyManager.RefreshAllEnemyNames();
			if (SemiFunc.RunIsLevel())
			{
				Settings.Logger.LogDebug((object)"Not on menu level, removing enemies.");
				EnemyManager.RemoveEnemies();
			}
		}

		[HarmonyPatch("PickEnemies")]
		[HarmonyPostfix]
		private static void EnemyDirectorPickEnemiesPostfix(ref List<EnemySetup> ___enemyList)
		{
			if (___enemyList.Count != 0)
			{
				___enemyList.RemoveAll((EnemySetup e) => (Object)(object)e == (Object)null);
			}
		}

		[HarmonyPatch("GetEnemy")]
		[HarmonyPrefix]
		private static void EnemyDirectorGetEnemyPrefix(EnemyDirector __instance, ref List<EnemySetup> ___enemyList, int ___enemyListIndex)
		{
			if (!_isListSet)
			{
				_startingEnemyList = new List<EnemySetup>(___enemyList);
				_isListSet = true;
			}
			if (___enemyList.Count == 0)
			{
				EnemySetup val = ScriptableObject.CreateInstance<EnemySetup>();
				val.spawnObjects = new List<GameObject>();
				___enemyList.Add(val);
			}
			while (___enemyList.Count < ___enemyListIndex + 1)
			{
				int index = Random.Range(0, _startingEnemyList.Count);
				___enemyList.Add(___enemyList[index]);
			}
		}
	}
	[HarmonyPatch(typeof(RunManager))]
	public static class RunManagerPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		private static void RunManagerStartPrefix()
		{
			if (!SemiFunc.MenuLevel())
			{
				Settings.Logger.LogDebug((object)"Removing valuables.");
				ValuableManager.RemoveValuables();
			}
		}

		[HarmonyPatch("SetRunLevel")]
		[HarmonyPrefix]
		private static void RunManagerChangeLevelPrefix(RunManager __instance, ref Level ___previousRunLevel)
		{
			Settings.Logger.LogDebug((object)"Removing levels.");
			LevelManager.RemoveLevels();
			if (__instance.levels.Count == 1)
			{
				___previousRunLevel = null;
			}
		}
	}
	[HarmonyPatch(typeof(ValuableDirector))]
	public static class ValuableDirectorPatches
	{
		[HarmonyPatch("Spawn")]
		[HarmonyPrefix]
		private static void ValuableDirectorSpawnPrefix(GameObject _valuable, ValuableVolume _volume, ref string _path)
		{
			if (ValuableManager.AllItems.TryGetValue(((Object)_valuable).name, out ValuableMetaData value))
			{
				_path = ValuableManager.GetValuablePresetTypePath(value.PresetType);
			}
		}
	}
}
namespace SpawnManager.Managers
{
	public static class EnemyManager
	{
		public static Dictionary<string, IEnumerable<GameObject>> EnemySpawnList = new Dictionary<string, IEnumerable<GameObject>>();

		public static void RefreshAllEnemyNames()
		{
			EnemyDirector instance = EnemyDirector.instance;
			EnemySpawnList = (from so in instance.enemiesDifficulty1.Concat(instance.enemiesDifficulty2).Concat(instance.enemiesDifficulty3).SelectMany((EnemySetup ed) => ed.spawnObjects)
				group so by ((Object)so).GetInstanceID() into so
				select so.First() into so
				where (Object)(object)so.GetComponent<EnemyParent>() != (Object)null
				group so by so.GetComponent<EnemyParent>().enemyName).ToDictionary((IGrouping<string, GameObject> g) => g.Key, (IGrouping<string, GameObject> g) => g.AsEnumerable());
		}

		public static void RemoveEnemies()
		{
			List<string> disabledEnemyNames = Settings.GetDisabledSettingsEntryListNames(Settings.DisabledEnemies);
			if (disabledEnemyNames.Count == 0)
			{
				return;
			}
			if (EnemySpawnList.Count == 0)
			{
				RefreshAllEnemyNames();
			}
			EnemyDirector instance = EnemyDirector.instance;
			List<GameObject> spawnObjectsToRemove = EnemySpawnList.Where<KeyValuePair<string, IEnumerable<GameObject>>>((KeyValuePair<string, IEnumerable<GameObject>> kvp) => disabledEnemyNames.Contains(kvp.Key)).SelectMany((KeyValuePair<string, IEnumerable<GameObject>> kvp) => kvp.Value).ToList();
			Settings.Logger.LogDebug((object)string.Format("Enemies to disable: {0} | Removing {1} spawnObjects from enemy director.", string.Join(", ", disabledEnemyNames), spawnObjectsToRemove.Count));
			List<EnemySetup> list = (from s in instance.enemiesDifficulty1.Concat(instance.enemiesDifficulty2).Concat(instance.enemiesDifficulty3)
				where s.spawnObjects.Any((GameObject so) => spawnObjectsToRemove.Contains(so))
				select s).ToList();
			for (int num = list.Count - 1; num >= 0; num--)
			{
				EnemySetup val = list[num];
				Settings.Logger.LogDebug((object)("Removed enemy setup " + ((Object)val).name));
				instance.enemiesDifficulty1.Remove(val);
				instance.enemiesDifficulty2.Remove(val);
				instance.enemiesDifficulty3.Remove(val);
			}
		}
	}
	public static class LevelManager
	{
		private static List<Level> _removedList = new List<Level>();

		private static bool RunManagerLevelVariableIsAvailable
		{
			get
			{
				if ((Object)(object)RunManager.instance != (Object)null)
				{
					return RunManager.instance.levels != null;
				}
				return false;
			}
		}

		public static IEnumerable<Level> GetAllLevels()
		{
			return _removedList.Concat(RunManager.instance.levels);
		}

		public static void RemoveLevels()
		{
			if (RunManagerLevelVariableIsAvailable)
			{
				List<string> disabledLevelNames = Settings.GetDisabledSettingsEntryListNames(Settings.DisabledLevels);
				RunManager.instance.levels.Where((Level l) => disabledLevelNames.Contains(((Object)l).name)).ToList().ForEach(delegate(Level level)
				{
					Settings.Logger.LogDebug((object)("Removed level " + ((Object)level).name + "."));
					_removedList.Add(level);
					RunManager.instance.levels.Remove(level);
				});
				if (RunManager.instance.levels.Count == 0)
				{
					Settings.Logger.LogError((object)"No levels left in RunManager. Quitting to Main Menu.");
					((MonoBehaviour)RunManager.instance).StartCoroutine(RunManager.instance.LeaveToMainMenu());
				}
			}
		}

		public static void RestoreLevels()
		{
			if (RunManagerLevelVariableIsAvailable && _removedList.Count != 0)
			{
				for (int num = _removedList.Count - 1; num >= 0; num--)
				{
					Level val = _removedList[num];
					Settings.Logger.LogDebug((object)("Restored level " + ((Object)val).name + "."));
					RunManager.instance.levels.Add(val);
					_removedList.RemoveAt(num);
				}
			}
		}
	}
	public static class MenuModManager
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action <>9__1_1;

			public static BuilderDelegate <>9__1_0;

			public static Func<KeyValuePair<string, IEnumerable<GameObject>>, string> <>9__3_8;

			public static ScrollViewBuilderDelegate <>9__3_0;

			public static Func<ValuableObject, string> <>9__4_9;

			public static Func<ValuableObject, string> <>9__4_4;

			public static ScrollViewBuilderDelegate <>9__4_0;

			public static Func<Level, string> <>9__5_9;

			public static Func<Level, string> <>9__5_4;

			public static ScrollViewBuilderDelegate <>9__5_0;

			internal void <Initialize>b__1_0(Transform parent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Spawn Manager", (Action)delegate
				{
					CreatePopup().OpenPage(false);
				}, parent, new Vector2(550f, 22f));
			}

			internal void <Initialize>b__1_1()
			{
				CreatePopup().OpenPage(false);
			}

			internal RectTransform <CreateEnemyPage>b__3_0(Transform parent)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass3_0 CS$<>8__locals0 = new <>c__DisplayClass3_0();
				CS$<>8__locals0.button = MenuAPI.CreateREPOButton("Enemies", (Action)null, parent, new Vector2(0f, -80f));
				CS$<>8__locals0.button.onClick = delegate
				{
					//IL_003e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0043: Unknown result type (might be due to invalid IL or missing references)
					//IL_0045: Expected O, but got Unknown
					//IL_004a: Expected O, but got Unknown
					//IL_0063: Unknown result type (might be due to invalid IL or missing references)
					//IL_0068: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Expected O, but got Unknown
					//IL_006f: Expected O, but got Unknown
					//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d5: Expected O, but got Unknown
					if (!((Object)(object)_currentPageButton == (Object)(object)CS$<>8__locals0.button))
					{
						MenuAPI.CloseAllPagesAddedOnTop();
						REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Enemies", (PresetSide)1, false, false, 0f);
						BuilderDelegate obj = CS$<>8__locals0.<>9__2;
						if (obj == null)
						{
							BuilderDelegate val2 = delegate(Transform enemyPageParent)
							{
								//IL_002f: Unknown result type (might be due to invalid IL or missing references)
								MenuAPI.CreateREPOButton("Enable All", (Action)delegate
								{
									//IL_0005: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.OpenPopup("Enable All", Color.red, "Enable all enemies?", (Action)delegate
									{
										((ConfigEntryBase)Settings.DisabledEnemies).BoxedValue = ((ConfigEntryBase)Settings.DisabledEnemies).DefaultValue;
										_currentPageButton = null;
										CS$<>8__locals0.button.onClick();
									}, (Action)null);
								}, enemyPageParent, new Vector2(367f, 20f));
							};
							BuilderDelegate val3 = val2;
							CS$<>8__locals0.<>9__2 = val2;
							obj = val3;
						}
						val.AddElement(obj);
						BuilderDelegate obj2 = CS$<>8__locals0.<>9__3;
						if (obj2 == null)
						{
							BuilderDelegate val4 = delegate(Transform enemyPageParent)
							{
								//IL_002f: Unknown result type (might be due to invalid IL or missing references)
								MenuAPI.CreateREPOButton("Disable All", (Action)delegate
								{
									//IL_0005: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.OpenPopup("Disable All", Color.red, "Disable all enemies?", (Action)delegate
									{
										Settings.DisabledEnemies.Value = string.Join(',', EnemyManager.EnemySpawnList.Select<KeyValuePair<string, IEnumerable<GameObject>>, string>((KeyValuePair<string, IEnumerable<GameObject>> kvp) => kvp.Key));
										_currentPageButton = null;
										CS$<>8__locals0.button.onClick();
									}, (Action)null);
								}, enemyPageParent, new Vector2(536f, 20f));
							};
							BuilderDelegate val3 = val4;
							CS$<>8__locals0.<>9__3 = val4;
							obj2 = val3;
						}
						val.AddElement(obj2);
						EnemyManager.RefreshAllEnemyNames();
						Settings.Logger.LogDebug((object)"Refreshed enemy names for menu.");
						List<string> list = EnemyManager.EnemySpawnList.Keys.ToList();
						list.Sort();
						using (List<string>.Enumerator enumerator = list.GetEnumerator())
						{
							while (enumerator.MoveNext())
							{
								val.AddElementToScrollView(new ScrollViewBuilderDelegate(new <>c__DisplayClass3_1
								{
									name = enumerator.Current
								}.<CreateEnemyPage>b__9), 0f, 0f);
							}
						}
						val.OpenPage(true);
					}
				};
				return ((REPOElement)CS$<>8__locals0.button).rectTransform;
			}

			internal string <CreateEnemyPage>b__3_8(KeyValuePair<string, IEnumerable<GameObject>> kvp)
			{
				return kvp.Key;
			}

			internal RectTransform <CreateValuablePage>b__4_0(Transform parent)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass4_0 CS$<>8__locals0 = new <>c__DisplayClass4_0();
				CS$<>8__locals0.button = MenuAPI.CreateREPOButton("Valuables", (Action)null, parent, new Vector2(0f, -114f));
				CS$<>8__locals0.button.onClick = delegate
				{
					//IL_003e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0043: Unknown result type (might be due to invalid IL or missing references)
					//IL_0045: Expected O, but got Unknown
					//IL_004a: Expected O, but got Unknown
					//IL_0063: Unknown result type (might be due to invalid IL or missing references)
					//IL_0068: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Expected O, but got Unknown
					//IL_006f: Expected O, but got Unknown
					//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00fc: Expected O, but got Unknown
					if (!((Object)(object)_currentPageButton == (Object)(object)CS$<>8__locals0.button))
					{
						MenuAPI.CloseAllPagesAddedOnTop();
						REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Valuables", (PresetSide)1, false, false, 0f);
						BuilderDelegate obj = CS$<>8__locals0.<>9__2;
						if (obj == null)
						{
							BuilderDelegate val2 = delegate(Transform valuablePageParent)
							{
								//IL_002f: Unknown result type (might be due to invalid IL or missing references)
								MenuAPI.CreateREPOButton("Enable All", (Action)delegate
								{
									//IL_0005: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.OpenPopup("Enable All", Color.red, "Enable all valuables?", (Action)delegate
									{
										((ConfigEntryBase)Settings.DisabledValuables).BoxedValue = ((ConfigEntryBase)Settings.DisabledValuables).DefaultValue;
										_currentPageButton = null;
										CS$<>8__locals0.button.onClick();
									}, (Action)null);
								}, valuablePageParent, new Vector2(367f, 20f));
							};
							BuilderDelegate val3 = val2;
							CS$<>8__locals0.<>9__2 = val2;
							obj = val3;
						}
						val.AddElement(obj);
						BuilderDelegate obj2 = CS$<>8__locals0.<>9__3;
						if (obj2 == null)
						{
							BuilderDelegate val4 = delegate(Transform valuablePageParent)
							{
								//IL_002f: Unknown result type (might be due to invalid IL or missing references)
								MenuAPI.CreateREPOButton("Disable All", (Action)delegate
								{
									//IL_0005: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.OpenPopup("Disable All", Color.red, "Disable all valuables?", (Action)delegate
									{
										Settings.DisabledValuables.Value = string.Join(',', ValuableManager.ValuableList.Select((ValuableObject vo) => ((Object)vo).name));
										_currentPageButton = null;
										CS$<>8__locals0.button.onClick();
									}, (Action)null);
								}, valuablePageParent, new Vector2(536f, 20f));
							};
							BuilderDelegate val3 = val4;
							CS$<>8__locals0.<>9__3 = val4;
							obj2 = val3;
						}
						val.AddElement(obj2);
						ValuableManager.RefreshAllValuables();
						Settings.Logger.LogDebug((object)$"Refreshed {ValuableManager.ValuableList.Count} valuable names for menu.");
						using (IEnumerator<ValuableObject> enumerator = ValuableManager.ValuableList.OrderBy((ValuableObject vo) => ((Object)vo).name).GetEnumerator())
						{
							while (enumerator.MoveNext())
							{
								val.AddElementToScrollView(new ScrollViewBuilderDelegate(new <>c__DisplayClass4_1
								{
									valuableObject = enumerator.Current
								}.<CreateValuablePage>b__10), 0f, 0f);
							}
						}
						val.OpenPage(true);
					}
				};
				return ((REPOElement)CS$<>8__locals0.button).rectTransform;
			}

			internal string <CreateValuablePage>b__4_9(ValuableObject vo)
			{
				return ((Object)vo).name;
			}

			internal string <CreateValuablePage>b__4_4(ValuableObject vo)
			{
				return ((Object)vo).name;
			}

			internal RectTransform <CreateLevelPage>b__5_0(Transform parent)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass5_0 CS$<>8__locals0 = new <>c__DisplayClass5_0();
				CS$<>8__locals0.button = MenuAPI.CreateREPOButton("Levels", (Action)null, parent, new Vector2(0f, -114f));
				CS$<>8__locals0.button.onClick = delegate
				{
					//IL_003e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0043: Unknown result type (might be due to invalid IL or missing references)
					//IL_0045: Expected O, but got Unknown
					//IL_004a: Expected O, but got Unknown
					//IL_0063: Unknown result type (might be due to invalid IL or missing references)
					//IL_0068: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Expected O, but got Unknown
					//IL_006f: Expected O, but got Unknown
					//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d4: Expected O, but got Unknown
					if (!((Object)(object)_currentPageButton == (Object)(object)CS$<>8__locals0.button))
					{
						MenuAPI.CloseAllPagesAddedOnTop();
						REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Levels", (PresetSide)1, false, false, 0f);
						BuilderDelegate obj = CS$<>8__locals0.<>9__2;
						if (obj == null)
						{
							BuilderDelegate val2 = delegate(Transform levelPageParent)
							{
								//IL_002f: Unknown result type (might be due to invalid IL or missing references)
								MenuAPI.CreateREPOButton("Enable All", (Action)delegate
								{
									//IL_0005: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.OpenPopup("Enable All", Color.red, "Enable all Levels?", (Action)delegate
									{
										((ConfigEntryBase)Settings.DisabledLevels).BoxedValue = ((ConfigEntryBase)Settings.DisabledLevels).DefaultValue;
										_currentPageButton = null;
										CS$<>8__locals0.button.onClick();
									}, (Action)null);
								}, levelPageParent, new Vector2(367f, 20f));
							};
							BuilderDelegate val3 = val2;
							CS$<>8__locals0.<>9__2 = val2;
							obj = val3;
						}
						val.AddElement(obj);
						BuilderDelegate obj2 = CS$<>8__locals0.<>9__3;
						if (obj2 == null)
						{
							BuilderDelegate val4 = delegate(Transform levelPageParent)
							{
								//IL_002f: Unknown result type (might be due to invalid IL or missing references)
								MenuAPI.CreateREPOButton("Disable All", (Action)delegate
								{
									//IL_0005: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.OpenPopup("Disable All", Color.red, "Disable all Levels?", (Action)delegate
									{
										Settings.DisabledLevels.Value = string.Join(',', from l in LevelManager.GetAllLevels()
											select ((Object)l).name);
										_currentPageButton = null;
										CS$<>8__locals0.button.onClick();
									}, (Action)null);
								}, levelPageParent, new Vector2(536f, 20f));
							};
							BuilderDelegate val3 = val4;
							CS$<>8__locals0.<>9__3 = val4;
							obj2 = val3;
						}
						val.AddElement(obj2);
						using (IEnumerator<Level> enumerator = (from vo in LevelManager.GetAllLevels()
							orderby ((Object)vo).name
							select vo).GetEnumerator())
						{
							while (enumerator.MoveNext())
							{
								val.AddElementToScrollView(new ScrollViewBuilderDelegate(new <>c__DisplayClass5_1
								{
									level = enumerator.Current
								}.<CreateLevelPage>b__10), 0f, 0f);
							}
						}
						val.OpenPage(true);
					}
				};
				return ((REPOElement)CS$<>8__locals0.button).rectTransform;
			}

			internal string <CreateLevelPage>b__5_9(Level l)
			{
				return ((Object)l).name;
			}

			internal string <CreateLevelPage>b__5_4(Level vo)
			{
				return ((Object)vo).name;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass3_0
		{
			public REPOButton button;

			public Action <>9__5;

			public Action <>9__4;

			public BuilderDelegate <>9__2;

			public Action <>9__7;

			public Action <>9__6;

			public BuilderDelegate <>9__3;

			internal void <CreateEnemyPage>b__1()
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				//IL_004a: Expected O, but got Unknown
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Expected O, but got Unknown
				//IL_006f: Expected O, but got Unknown
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Expected O, but got Unknown
				if ((Object)(object)_currentPageButton == (Object)(object)button)
				{
					return;
				}
				MenuAPI.CloseAllPagesAddedOnTop();
				REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Enemies", (PresetSide)1, false, false, 0f);
				BuilderDelegate obj = <>9__2;
				if (obj == null)
				{
					BuilderDelegate val2 = delegate(Transform enemyPageParent)
					{
						//IL_002f: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("Enable All", (Action)delegate
						{
							//IL_0005: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.OpenPopup("Enable All", Color.red, "Enable all enemies?", (Action)delegate
							{
								((ConfigEntryBase)Settings.DisabledEnemies).BoxedValue = ((ConfigEntryBase)Settings.DisabledEnemies).DefaultValue;
								_currentPageButton = null;
								button.onClick();
							}, (Action)null);
						}, enemyPageParent, new Vector2(367f, 20f));
					};
					BuilderDelegate val3 = val2;
					<>9__2 = val2;
					obj = val3;
				}
				val.AddElement(obj);
				BuilderDelegate obj2 = <>9__3;
				if (obj2 == null)
				{
					BuilderDelegate val4 = delegate(Transform enemyPageParent)
					{
						//IL_002f: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("Disable All", (Action)delegate
						{
							//IL_0005: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.OpenPopup("Disable All", Color.red, "Disable all enemies?", (Action)delegate
							{
								Settings.DisabledEnemies.Value = string.Join(',', EnemyManager.EnemySpawnList.Select<KeyValuePair<string, IEnumerable<GameObject>>, string>((KeyValuePair<string, IEnumerable<GameObject>> kvp) => kvp.Key));
								_currentPageButton = null;
								button.onClick();
							}, (Action)null);
						}, enemyPageParent, new Vector2(536f, 20f));
					};
					BuilderDelegate val3 = val4;
					<>9__3 = val4;
					obj2 = val3;
				}
				val.AddElement(obj2);
				EnemyManager.RefreshAllEnemyNames();
				Settings.Logger.LogDebug((object)"Refreshed enemy names for menu.");
				List<string> list = EnemyManager.EnemySpawnList.Keys.ToList();
				list.Sort();
				using (List<string>.Enumerator enumerator = list.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						val.AddElementToScrollView(new ScrollViewBuilderDelegate(new <>c__DisplayClass3_1
						{
							name = enumerator.Current
						}.<CreateEnemyPage>b__9), 0f, 0f);
					}
				}
				val.OpenPage(true);
			}

			internal void <CreateEnemyPage>b__2(Transform enemyPageParent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Enable All", (Action)delegate
				{
					//IL_0005: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.OpenPopup("Enable All", Color.red, "Enable all enemies?", (Action)delegate
					{
						((ConfigEntryBase)Settings.DisabledEnemies).BoxedValue = ((ConfigEntryBase)Settings.DisabledEnemies).DefaultValue;
						_currentPageButton = null;
						button.onClick();
					}, (Action)null);
				}, enemyPageParent, new Vector2(367f, 20f));
			}

			internal void <CreateEnemyPage>b__4()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.OpenPopup("Enable All", Color.red, "Enable all enemies?", (Action)delegate
				{
					((ConfigEntryBase)Settings.DisabledEnemies).BoxedValue = ((ConfigEntryBase)Settings.DisabledEnemies).DefaultValue;
					_currentPageButton = null;
					button.onClick();
				}, (Action)null);
			}

			internal void <CreateEnemyPage>b__5()
			{
				((ConfigEntryBase)Settings.DisabledEnemies).BoxedValue = ((ConfigEntryBase)Settings.DisabledEnemies).DefaultValue;
				_currentPageButton = null;
				button.onClick();
			}

			internal void <CreateEnemyPage>b__3(Transform enemyPageParent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Disable All", (Action)delegate
				{
					//IL_0005: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.OpenPopup("Disable All", Color.red, "Disable all enemies?", (Action)delegate
					{
						Settings.DisabledEnemies.Value = string.Join(',', EnemyManager.EnemySpawnList.Select<KeyValuePair<string, IEnumerable<GameObject>>, string>((KeyValuePair<string, IEnumerable<GameObject>> kvp) => kvp.Key));
						_currentPageButton = null;
						button.onClick();
					}, (Action)null);
				}, enemyPageParent, new Vector2(536f, 20f));
			}

			internal void <CreateEnemyPage>b__6()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.OpenPopup("Disable All", Color.red, "Disable all enemies?", (Action)delegate
				{
					Settings.DisabledEnemies.Value = string.Join(',', EnemyManager.EnemySpawnList.Select<KeyValuePair<string, IEnumerable<GameObject>>, string>((KeyValuePair<string, IEnumerable<GameObject>> kvp) => kvp.Key));
					_currentPageButton = null;
					button.onClick();
				}, (Action)null);
			}

			internal void <CreateEnemyPage>b__7()
			{
				Settings.DisabledEnemies.Value = string.Join(',', EnemyManager.EnemySpawnList.Select<KeyValuePair<string, IEnumerable<GameObject>>, string>((KeyValuePair<string, IEnumerable<GameObject>> kvp) => kvp.Key));
				_currentPageButton = null;
				button.onClick();
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass3_1
		{
			public string name;

			public Action<bool> <>9__10;

			internal RectTransform <CreateEnemyPage>b__9(Transform enemyPageParent)
			{
				//IL_0028: 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)
				return ((REPOElement)MenuAPI.CreateREPOToggle(name, (Action<bool>)delegate(bool b)
				{
					Settings.UpdateSettingsListEntry(Settings.DisabledEnemies, name, b);
				}, enemyPageParent, default(Vector2), "ON", "OFF", Settings.IsSettingsListEntryEnabled(Settings.DisabledEnemies, name))).rectTransform;
			}

			internal void <CreateEnemyPage>b__10(bool b)
			{
				Settings.UpdateSettingsListEntry(Settings.DisabledEnemies, name, b);
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass4_0
		{
			public REPOButton button;

			public Action <>9__6;

			public Action <>9__5;

			public BuilderDelegate <>9__2;

			public Action <>9__8;

			public Action <>9__7;

			public BuilderDelegate <>9__3;

			internal void <CreateValuablePage>b__1()
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				//IL_004a: Expected O, but got Unknown
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Expected O, but got Unknown
				//IL_006f: Expected O, but got Unknown
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Expected O, but got Unknown
				if ((Object)(object)_currentPageButton == (Object)(object)button)
				{
					return;
				}
				MenuAPI.CloseAllPagesAddedOnTop();
				REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Valuables", (PresetSide)1, false, false, 0f);
				BuilderDelegate obj = <>9__2;
				if (obj == null)
				{
					BuilderDelegate val2 = delegate(Transform valuablePageParent)
					{
						//IL_002f: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("Enable All", (Action)delegate
						{
							//IL_0005: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.OpenPopup("Enable All", Color.red, "Enable all valuables?", (Action)delegate
							{
								((ConfigEntryBase)Settings.DisabledValuables).BoxedValue = ((ConfigEntryBase)Settings.DisabledValuables).DefaultValue;
								_currentPageButton = null;
								button.onClick();
							}, (Action)null);
						}, valuablePageParent, new Vector2(367f, 20f));
					};
					BuilderDelegate val3 = val2;
					<>9__2 = val2;
					obj = val3;
				}
				val.AddElement(obj);
				BuilderDelegate obj2 = <>9__3;
				if (obj2 == null)
				{
					BuilderDelegate val4 = delegate(Transform valuablePageParent)
					{
						//IL_002f: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("Disable All", (Action)delegate
						{
							//IL_0005: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.OpenPopup("Disable All", Color.red, "Disable all valuables?", (Action)delegate
							{
								Settings.DisabledValuables.Value = string.Join(',', ValuableManager.ValuableList.Select((ValuableObject vo) => ((Object)vo).name));
								_currentPageButton = null;
								button.onClick();
							}, (Action)null);
						}, valuablePageParent, new Vector2(536f, 20f));
					};
					BuilderDelegate val3 = val4;
					<>9__3 = val4;
					obj2 = val3;
				}
				val.AddElement(obj2);
				ValuableManager.RefreshAllValuables();
				Settings.Logger.LogDebug((object)$"Refreshed {ValuableManager.ValuableList.Count} valuable names for menu.");
				using (IEnumerator<ValuableObject> enumerator = ValuableManager.ValuableList.OrderBy((ValuableObject vo) => ((Object)vo).name).GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						val.AddElementToScrollView(new ScrollViewBuilderDelegate(new <>c__DisplayClass4_1
						{
							valuableObject = enumerator.Current
						}.<CreateValuablePage>b__10), 0f, 0f);
					}
				}
				val.OpenPage(true);
			}

			internal void <CreateValuablePage>b__2(Transform valuablePageParent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Enable All", (Action)delegate
				{
					//IL_0005: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.OpenPopup("Enable All", Color.red, "Enable all valuables?", (Action)delegate
					{
						((ConfigEntryBase)Settings.DisabledValuables).BoxedValue = ((ConfigEntryBase)Settings.DisabledValuables).DefaultValue;
						_currentPageButton = null;
						button.onClick();
					}, (Action)null);
				}, valuablePageParent, new Vector2(367f, 20f));
			}

			internal void <CreateValuablePage>b__5()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.OpenPopup("Enable All", Color.red, "Enable all valuables?", (Action)delegate
				{
					((ConfigEntryBase)Settings.DisabledValuables).BoxedValue = ((ConfigEntryBase)Settings.DisabledValuables).DefaultValue;
					_currentPageButton = null;
					button.onClick();
				}, (Action)null);
			}

			internal void <CreateValuablePage>b__6()
			{
				((ConfigEntryBase)Settings.DisabledValuables).BoxedValue = ((ConfigEntryBase)Settings.DisabledValuables).DefaultValue;
				_currentPageButton = null;
				button.onClick();
			}

			internal void <CreateValuablePage>b__3(Transform valuablePageParent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Disable All", (Action)delegate
				{
					//IL_0005: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.OpenPopup("Disable All", Color.red, "Disable all valuables?", (Action)delegate
					{
						Settings.DisabledValuables.Value = string.Join(',', ValuableManager.ValuableList.Select((ValuableObject vo) => ((Object)vo).name));
						_currentPageButton = null;
						button.onClick();
					}, (Action)null);
				}, valuablePageParent, new Vector2(536f, 20f));
			}

			internal void <CreateValuablePage>b__7()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.OpenPopup("Disable All", Color.red, "Disable all valuables?", (Action)delegate
				{
					Settings.DisabledValuables.Value = string.Join(',', ValuableManager.ValuableList.Select((ValuableObject vo) => ((Object)vo).name));
					_currentPageButton = null;
					button.onClick();
				}, (Action)null);
			}

			internal void <CreateValuablePage>b__8()
			{
				Settings.DisabledValuables.Value = string.Join(',', ValuableManager.ValuableList.Select((ValuableObject vo) => ((Object)vo).name));
				_currentPageButton = null;
				button.onClick();
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass4_1
		{
			public ValuableObject valuableObject;

			public Action<bool> <>9__11;

			internal RectTransform <CreateValuablePage>b__10(Transform valuablePageParent)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				return ((REPOElement)MenuAPI.CreateREPOToggle(valuableObject.FriendlyName(), (Action<bool>)delegate(bool b)
				{
					Settings.UpdateSettingsListEntry(Settings.DisabledValuables, ((Object)valuableObject).name, b);
				}, valuablePageParent, default(Vector2), "ON", "OFF", Settings.IsSettingsListEntryEnabled(Settings.DisabledValuables, ((Object)valuableObject).name))).rectTransform;
			}

			internal void <CreateValuablePage>b__11(bool b)
			{
				Settings.UpdateSettingsListEntry(Settings.DisabledValuables, ((Object)valuableObject).name, b);
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass5_0
		{
			public REPOButton button;

			public Action <>9__6;

			public Action <>9__5;

			public BuilderDelegate <>9__2;

			public Action <>9__8;

			public Action <>9__7;

			public BuilderDelegate <>9__3;

			internal void <CreateLevelPage>b__1()
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				//IL_004a: Expected O, but got Unknown
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Expected O, but got Unknown
				//IL_006f: Expected O, but got Unknown
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Expected O, but got Unknown
				if ((Object)(object)_currentPageButton == (Object)(object)button)
				{
					return;
				}
				MenuAPI.CloseAllPagesAddedOnTop();
				REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Levels", (PresetSide)1, false, false, 0f);
				BuilderDelegate obj = <>9__2;
				if (obj == null)
				{
					BuilderDelegate val2 = delegate(Transform levelPageParent)
					{
						//IL_002f: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("Enable All", (Action)delegate
						{
							//IL_0005: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.OpenPopup("Enable All", Color.red, "Enable all Levels?", (Action)delegate
							{
								((ConfigEntryBase)Settings.DisabledLevels).BoxedValue = ((ConfigEntryBase)Settings.DisabledLevels).DefaultValue;
								_currentPageButton = null;
								button.onClick();
							}, (Action)null);
						}, levelPageParent, new Vector2(367f, 20f));
					};
					BuilderDelegate val3 = val2;
					<>9__2 = val2;
					obj = val3;
				}
				val.AddElement(obj);
				BuilderDelegate obj2 = <>9__3;
				if (obj2 == null)
				{
					BuilderDelegate val4 = delegate(Transform levelPageParent)
					{
						//IL_002f: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("Disable All", (Action)delegate
						{
							//IL_0005: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.OpenPopup("Disable All", Color.red, "Disable all Levels?", (Action)delegate
							{
								Settings.DisabledLevels.Value = string.Join(',', from l in LevelManager.GetAllLevels()
									select ((Object)l).name);
								_currentPageButton = null;
								button.onClick();
							}, (Action)null);
						}, levelPageParent, new Vector2(536f, 20f));
					};
					BuilderDelegate val3 = val4;
					<>9__3 = val4;
					obj2 = val3;
				}
				val.AddElement(obj2);
				using (IEnumerator<Level> enumerator = (from vo in LevelManager.GetAllLevels()
					orderby ((Object)vo).name
					select vo).GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						val.AddElementToScrollView(new ScrollViewBuilderDelegate(new <>c__DisplayClass5_1
						{
							level = enumerator.Current
						}.<CreateLevelPage>b__10), 0f, 0f);
					}
				}
				val.OpenPage(true);
			}

			internal void <CreateLevelPage>b__2(Transform levelPageParent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Enable All", (Action)delegate
				{
					//IL_0005: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.OpenPopup("Enable All", Color.red, "Enable all Levels?", (Action)delegate
					{
						((ConfigEntryBase)Settings.DisabledLevels).BoxedValue = ((ConfigEntryBase)Settings.DisabledLevels).DefaultValue;
						_currentPageButton = null;
						button.onClick();
					}, (Action)null);
				}, levelPageParent, new Vector2(367f, 20f));
			}

			internal void <CreateLevelPage>b__5()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.OpenPopup("Enable All", Color.red, "Enable all Levels?", (Action)delegate
				{
					((ConfigEntryBase)Settings.DisabledLevels).BoxedValue = ((ConfigEntryBase)Settings.DisabledLevels).DefaultValue;
					_currentPageButton = null;
					button.onClick();
				}, (Action)null);
			}

			internal void <CreateLevelPage>b__6()
			{
				((ConfigEntryBase)Settings.DisabledLevels).BoxedValue = ((ConfigEntryBase)Settings.DisabledLevels).DefaultValue;
				_currentPageButton = null;
				button.onClick();
			}

			internal void <CreateLevelPage>b__3(Transform levelPageParent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Disable All", (Action)delegate
				{
					//IL_0005: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.OpenPopup("Disable All", Color.red, "Disable all Levels?", (Action)delegate
					{
						Settings.DisabledLevels.Value = string.Join(',', from l in LevelManager.GetAllLevels()
							select ((Object)l).name);
						_currentPageButton = null;
						button.onClick();
					}, (Action)null);
				}, levelPageParent, new Vector2(536f, 20f));
			}

			internal void <CreateLevelPage>b__7()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.OpenPopup("Disable All", Color.red, "Disable all Levels?", (Action)delegate
				{
					Settings.DisabledLevels.Value = string.Join(',', from l in LevelManager.GetAllLevels()
						select ((Object)l).name);
					_currentPageButton = null;
					button.onClick();
				}, (Action)null);
			}

			internal void <CreateLevelPage>b__8()
			{
				Settings.DisabledLevels.Value = string.Join(',', from l in LevelManager.GetAllLevels()
					select ((Object)l).name);
				_currentPageButton = null;
				button.onClick();
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass5_1
		{
			public Level level;

			public Action<bool> <>9__11;

			internal RectTransform <CreateLevelPage>b__10(Transform levelPageParent)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				return ((REPOElement)MenuAPI.CreateREPOToggle(level.FriendlyName(), (Action<bool>)delegate(bool b)
				{
					Settings.UpdateSettingsListEntry(Settings.DisabledLevels, ((Object)level).name, b);
				}, levelPageParent, default(Vector2), "ON", "OFF", Settings.IsSettingsListEntryEnabled(Settings.DisabledLevels, ((Object)level).name))).rectTransform;
			}

			internal void <CreateLevelPage>b__11(bool b)
			{
				Settings.UpdateSettingsListEntry(Settings.DisabledLevels, ((Object)level).name, b);
			}
		}

		private static REPOButton? _currentPageButton;

		public static void Initialize()
		{
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				BuilderDelegate val = delegate(Transform parent)
				{
					//IL_002f: Unknown result type (might be due to invalid IL or missing references)
					MenuAPI.CreateREPOButton("Spawn Manager", (Action)delegate
					{
						CreatePopup().OpenPage(false);
					}, parent, new Vector2(550f, 22f));
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			MenuAPI.AddElementToMainMenu((BuilderDelegate)obj);
		}

		private static REPOPopupPage CreatePopup()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			REPOPopupPage menu = MenuAPI.CreateREPOPopupPage("Spawn Manager", (PresetSide)0, false, true, 0f);
			menu.AddElement((BuilderDelegate)delegate(Transform parent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Back", (Action)delegate
				{
					menu.ClosePage(true);
				}, parent, new Vector2(77f, 34f));
			});
			CreateEnemyPage(menu);
			CreateValuablePage(menu);
			CreateLevelPage(menu);
			return menu;
		}

		private static void CreateEnemyPage(REPOPopupPage menu)
		{
			//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__3_0;
			if (obj == null)
			{
				ScrollViewBuilderDelegate val = delegate(Transform parent)
				{
					//IL_0018: Unknown result type (might be due to invalid IL or missing references)
					REPOButton button = MenuAPI.CreateREPOButton("Enemies", (Action)null, parent, new Vector2(0f, -80f));
					BuilderDelegate val2 = default(BuilderDelegate);
					BuilderDelegate val3 = default(BuilderDelegate);
					button.onClick = delegate
					{
						//IL_003e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0043: Unknown result type (might be due to invalid IL or missing references)
						//IL_0045: Expected O, but got Unknown
						//IL_004a: Expected O, but got Unknown
						//IL_0063: Unknown result type (might be due to invalid IL or missing references)
						//IL_0068: Unknown result type (might be due to invalid IL or missing references)
						//IL_006a: Expected O, but got Unknown
						//IL_006f: Expected O, but got Unknown
						//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
						//IL_00d5: Expected O, but got Unknown
						if (!((Object)(object)_currentPageButton == (Object)(object)button))
						{
							MenuAPI.CloseAllPagesAddedOnTop();
							REPOPopupPage val4 = MenuAPI.CreateREPOPopupPage("Enemies", (PresetSide)1, false, false, 0f);
							BuilderDelegate obj2 = val2;
							if (obj2 == null)
							{
								BuilderDelegate val5 = delegate(Transform enemyPageParent)
								{
									//IL_002f: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.CreateREPOButton("Enable All", (Action)delegate
									{
										//IL_0005: Unknown result type (might be due to invalid IL or missing references)
										MenuAPI.OpenPopup("Enable All", Color.red, "Enable all enemies?", (Action)delegate
										{
											((ConfigEntryBase)Settings.DisabledEnemies).BoxedValue = ((ConfigEntryBase)Settings.DisabledEnemies).DefaultValue;
											_currentPageButton = null;
											button.onClick();
										}, (Action)null);
									}, enemyPageParent, new Vector2(367f, 20f));
								};
								BuilderDelegate val6 = val5;
								val2 = val5;
								obj2 = val6;
							}
							val4.AddElement(obj2);
							BuilderDelegate obj3 = val3;
							if (obj3 == null)
							{
								BuilderDelegate val7 = delegate(Transform enemyPageParent)
								{
									//IL_002f: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.CreateREPOButton("Disable All", (Action)delegate
									{
										//IL_0005: Unknown result type (might be due to invalid IL or missing references)
										MenuAPI.OpenPopup("Disable All", Color.red, "Disable all enemies?", (Action)delegate
										{
											Settings.DisabledEnemies.Value = string.Join(',', EnemyManager.EnemySpawnList.Select<KeyValuePair<string, IEnumerable<GameObject>>, string>((KeyValuePair<string, IEnumerable<GameObject>> kvp) => kvp.Key));
											_currentPageButton = null;
											button.onClick();
										}, (Action)null);
									}, enemyPageParent, new Vector2(536f, 20f));
								};
								BuilderDelegate val6 = val7;
								val3 = val7;
								obj3 = val6;
							}
							val4.AddElement(obj3);
							EnemyManager.RefreshAllEnemyNames();
							Settings.Logger.LogDebug((object)"Refreshed enemy names for menu.");
							List<string> list = EnemyManager.EnemySpawnList.Keys.ToList();
							list.Sort();
							foreach (string name in list)
							{
								val4.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform enemyPageParent) => ((REPOElement)MenuAPI.CreateREPOToggle(name, (Action<bool>)delegate(bool b)
								{
									Settings.UpdateSettingsListEntry(Settings.DisabledEnemies, name, b);
								}, enemyPageParent, default(Vector2), "ON", "OFF", Settings.IsSettingsListEntryEnabled(Settings.DisabledEnemies, name))).rectTransform), 0f, 0f);
							}
							val4.OpenPage(true);
						}
					};
					return ((REPOElement)button).rectTransform;
				};
				<>c.<>9__3_0 = val;
				obj = (object)val;
			}
			menu.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f);
		}

		private static void CreateValuablePage(REPOPopupPage menu)
		{
			//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__4_0;
			if (obj == null)
			{
				ScrollViewBuilderDelegate val = delegate(Transform parent)
				{
					//IL_0018: Unknown result type (might be due to invalid IL or missing references)
					REPOButton button = MenuAPI.CreateREPOButton("Valuables", (Action)null, parent, new Vector2(0f, -114f));
					BuilderDelegate val2 = default(BuilderDelegate);
					BuilderDelegate val3 = default(BuilderDelegate);
					button.onClick = delegate
					{
						//IL_003e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0043: Unknown result type (might be due to invalid IL or missing references)
						//IL_0045: Expected O, but got Unknown
						//IL_004a: Expected O, but got Unknown
						//IL_0063: Unknown result type (might be due to invalid IL or missing references)
						//IL_0068: Unknown result type (might be due to invalid IL or missing references)
						//IL_006a: Expected O, but got Unknown
						//IL_006f: Expected O, but got Unknown
						//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
						//IL_00fc: Expected O, but got Unknown
						if (!((Object)(object)_currentPageButton == (Object)(object)button))
						{
							MenuAPI.CloseAllPagesAddedOnTop();
							REPOPopupPage val4 = MenuAPI.CreateREPOPopupPage("Valuables", (PresetSide)1, false, false, 0f);
							BuilderDelegate obj2 = val2;
							if (obj2 == null)
							{
								BuilderDelegate val5 = delegate(Transform valuablePageParent)
								{
									//IL_002f: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.CreateREPOButton("Enable All", (Action)delegate
									{
										//IL_0005: Unknown result type (might be due to invalid IL or missing references)
										MenuAPI.OpenPopup("Enable All", Color.red, "Enable all valuables?", (Action)delegate
										{
											((ConfigEntryBase)Settings.DisabledValuables).BoxedValue = ((ConfigEntryBase)Settings.DisabledValuables).DefaultValue;
											_currentPageButton = null;
											button.onClick();
										}, (Action)null);
									}, valuablePageParent, new Vector2(367f, 20f));
								};
								BuilderDelegate val6 = val5;
								val2 = val5;
								obj2 = val6;
							}
							val4.AddElement(obj2);
							BuilderDelegate obj3 = val3;
							if (obj3 == null)
							{
								BuilderDelegate val7 = delegate(Transform valuablePageParent)
								{
									//IL_002f: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.CreateREPOButton("Disable All", (Action)delegate
									{
										//IL_0005: Unknown result type (might be due to invalid IL or missing references)
										MenuAPI.OpenPopup("Disable All", Color.red, "Disable all valuables?", (Action)delegate
										{
											Settings.DisabledValuables.Value = string.Join(',', ValuableManager.ValuableList.Select((ValuableObject vo) => ((Object)vo).name));
											_currentPageButton = null;
											button.onClick();
										}, (Action)null);
									}, valuablePageParent, new Vector2(536f, 20f));
								};
								BuilderDelegate val6 = val7;
								val3 = val7;
								obj3 = val6;
							}
							val4.AddElement(obj3);
							ValuableManager.RefreshAllValuables();
							Settings.Logger.LogDebug((object)$"Refreshed {ValuableManager.ValuableList.Count} valuable names for menu.");
							foreach (ValuableObject valuableObject in ValuableManager.ValuableList.OrderBy((ValuableObject vo) => ((Object)vo).name))
							{
								val4.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform valuablePageParent) => ((REPOElement)MenuAPI.CreateREPOToggle(valuableObject.FriendlyName(), (Action<bool>)delegate(bool b)
								{
									Settings.UpdateSettingsListEntry(Settings.DisabledValuables, ((Object)valuableObject).name, b);
								}, valuablePageParent, default(Vector2), "ON", "OFF", Settings.IsSettingsListEntryEnabled(Settings.DisabledValuables, ((Object)valuableObject).name))).rectTransform), 0f, 0f);
							}
							val4.OpenPage(true);
						}
					};
					return ((REPOElement)button).rectTransform;
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			menu.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f);
		}

		private static void CreateLevelPage(REPOPopupPage menu)
		{
			//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)
			{
				ScrollViewBuilderDelegate val = delegate(Transform parent)
				{
					//IL_0018: Unknown result type (might be due to invalid IL or missing references)
					REPOButton button = MenuAPI.CreateREPOButton("Levels", (Action)null, parent, new Vector2(0f, -114f));
					BuilderDelegate val2 = default(BuilderDelegate);
					BuilderDelegate val3 = default(BuilderDelegate);
					button.onClick = delegate
					{
						//IL_003e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0043: Unknown result type (might be due to invalid IL or missing references)
						//IL_0045: Expected O, but got Unknown
						//IL_004a: Expected O, but got Unknown
						//IL_0063: Unknown result type (might be due to invalid IL or missing references)
						//IL_0068: Unknown result type (might be due to invalid IL or missing references)
						//IL_006a: Expected O, but got Unknown
						//IL_006f: Expected O, but got Unknown
						//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
						//IL_00d4: Expected O, but got Unknown
						if (!((Object)(object)_currentPageButton == (Object)(object)button))
						{
							MenuAPI.CloseAllPagesAddedOnTop();
							REPOPopupPage val4 = MenuAPI.CreateREPOPopupPage("Levels", (PresetSide)1, false, false, 0f);
							BuilderDelegate obj2 = val2;
							if (obj2 == null)
							{
								BuilderDelegate val5 = delegate(Transform levelPageParent)
								{
									//IL_002f: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.CreateREPOButton("Enable All", (Action)delegate
									{
										//IL_0005: Unknown result type (might be due to invalid IL or missing references)
										MenuAPI.OpenPopup("Enable All", Color.red, "Enable all Levels?", (Action)delegate
										{
											((ConfigEntryBase)Settings.DisabledLevels).BoxedValue = ((ConfigEntryBase)Settings.DisabledLevels).DefaultValue;
											_currentPageButton = null;
											button.onClick();
										}, (Action)null);
									}, levelPageParent, new Vector2(367f, 20f));
								};
								BuilderDelegate val6 = val5;
								val2 = val5;
								obj2 = val6;
							}
							val4.AddElement(obj2);
							BuilderDelegate obj3 = val3;
							if (obj3 == null)
							{
								BuilderDelegate val7 = delegate(Transform levelPageParent)
								{
									//IL_002f: Unknown result type (might be due to invalid IL or missing references)
									MenuAPI.CreateREPOButton("Disable All", (Action)delegate
									{
										//IL_0005: Unknown result type (might be due to invalid IL or missing references)
										MenuAPI.OpenPopup("Disable All", Color.red, "Disable all Levels?", (Action)delegate
										{
											Settings.DisabledLevels.Value = string.Join(',', from l in LevelManager.GetAllLevels()
												select ((Object)l).name);
											_currentPageButton = null;
											button.onClick();
										}, (Action)null);
									}, levelPageParent, new Vector2(536f, 20f));
								};
								BuilderDelegate val6 = val7;
								val3 = val7;
								obj3 = val6;
							}
							val4.AddElement(obj3);
							foreach (Level level in from vo in LevelManager.GetAllLevels()
								orderby ((Object)vo).name
								select vo)
							{
								val4.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform levelPageParent) => ((REPOElement)MenuAPI.CreateREPOToggle(level.FriendlyName(), (Action<bool>)delegate(bool b)
								{
									Settings.UpdateSettingsListEntry(Settings.DisabledLevels, ((Object)level).name, b);
								}, levelPageParent, default(Vector2), "ON", "OFF", Settings.IsSettingsListEntryEnabled(Settings.DisabledLevels, ((Object)level).name))).rectTransform), 0f, 0f);
							}
							val4.OpenPage(true);
						}
					};
					return ((REPOElement)button).rectTransform;
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			menu.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f);
		}
	}
	public static class ValuableManager
	{
		public enum ValuablePresetType
		{
			Tiny,
			Small,
			Medium,
			Big,
			Wide,
			Tall,
			VeryTall
		}

		public static List<ValuableObject> ValuableList = new List<ValuableObject>();

		public static Dictionary<string, GameObject> RemovedList = new Dictionary<string, GameObject>();

		public static Dictionary<string, LevelValuables> LevelValuablesDictionary = new Dictionary<string, LevelValuables>();

		public static Dictionary<string, ValuableMetaData> AllItems = new Dictionary<string, ValuableMetaData>();

		public static void RefreshAllValuables()
		{
			if ((Object)(object)RunManager.instance != (Object)null && RunManager.instance.levels != null)
			{
				if (AllItems.Count == 0)
				{
					foreach (Level level in RunManager.instance.levels)
					{
						foreach (LevelValuables valuablePreset in level.ValuablePresets)
						{
							AddItemsToDictionary(valuablePreset.tiny, ((Object)level).name, ValuablePresetType.Tiny);
							AddItemsToDictionary(valuablePreset.small, ((Object)level).name, ValuablePresetType.Small);
							AddItemsToDictionary(valuablePreset.medium, ((Object)level).name, ValuablePresetType.Medium);
							AddItemsToDictionary(valuablePreset.big, ((Object)level).name, ValuablePresetType.Big);
							AddItemsToDictionary(valuablePreset.wide, ((Object)level).name, ValuablePresetType.Wide);
							AddItemsToDictionary(valuablePreset.tall, ((Object)level).name, ValuablePresetType.Tall);
							AddItemsToDictionary(valuablePreset.veryTall, ((Object)level).name, ValuablePresetType.VeryTall);
						}
					}
				}
				ValuableList = (from go in RunManager.instance.levels.SelectMany(delegate(Level l)
					{
						IEnumerable<LevelValuables> valuablePresets = l.ValuablePresets;
						return valuablePresets ?? Enumerable.Empty<LevelValuables>();
					}).SelectMany(delegate(LevelValuables lv)
					{
						IEnumerable<GameObject> enumerable = lv?.tiny;
						IEnumerable<GameObject> first = enumerable ?? Enumerable.Empty<GameObject>();
						enumerable = lv?.small;
						IEnumerable<GameObject> first2 = first.Concat(enumerable ?? Enumerable.Empty<GameObject>());
						enumerable = lv?.medium;
						IEnumerable<GameObject> first3 = first2.Concat(enumerable ?? Enumerable.Empty<GameObject>());
						enumerable = lv?.big;
						IEnumerable<GameObject> first4 = first3.Concat(enumerable ?? Enumerable.Empty<GameObject>());
						enumerable = lv?.wide;
						IEnumerable<GameObject> first5 = first4.Concat(enumerable ?? Enumerable.Empty<GameObject>());
						enumerable = lv?.tall;
						IEnumerable<GameObject> first6 = first5.Concat(enumerable ?? Enumerable.Empty<GameObject>());
						enumerable = lv?.veryTall;
						return first6.Concat(enumerable ?? Enumerable.Empty<GameObject>());
					})
					select (go == null) ? null : go.GetComponent<ValuableObject>() into vo
					where (Object)(object)vo != (Object)null
					select vo).Distinct().ToList();
			}
			else
			{
				ValuableList = new List<ValuableObject>();
			}
		}

		public static void RemoveValuables()
		{
			List<string> disabledValuableNames = Settings.GetDisabledSettingsEntryListNames(Settings.DisabledValuables);
			if (disabledValuableNames.Count != 0)
			{
				RefreshAllValuables();
				List<ValuableObject> list = ValuableList.Where((ValuableObject valuableObject) => disabledValuableNames.Contains(((Object)valuableObject).name)).ToList();
				Settings.Logger.LogDebug((object)string.Format("Valuables to disable: {0} | Removing {1} valuables from levels.", string.Join(", ", disabledValuableNames), list.Count));
				RemoveValuableObjects(list);
			}
		}

		private static void RemoveValuableObjects(List<ValuableObject> valuableObjectsToRemove)
		{
			if ((Object)(object)RunManager.instance == (Object)null || RunManager.instance.levels == null)
			{
				return;
			}
			foreach (LevelValuables item in RunManager.instance.levels.SelectMany((Level level) => level.ValuablePresets))
			{
				RemoveValuableObjectsFromList(item.tiny, valuableObjectsToRemove);
				RemoveValuableObjectsFromList(item.small, valuableObjectsToRemove);
				RemoveValuableObjectsFromList(item.medium, valuableObjectsToRemove);
				RemoveValuableObjectsFromList(item.big, valuableObjectsToRemove);
				RemoveValuableObjectsFromList(item.wide, valuableObjectsToRemove);
				RemoveValuableObjectsFromList(item.tall, valuableObjectsToRemove);
				RemoveValuableObjectsFromList(item.veryTall, valuableObjectsToRemove);
				List<GameObject> list = item.tiny.Concat(item.small).Concat(item.medium).Concat(item.big)
					.Concat(item.wide)
					.Concat(item.tall)
					.Concat(item.veryTall)
					.ToList();
				if (list.Count != 0)
				{
					if (!item.tiny.Any())
					{
						item.tiny.Add(list[Random.Range(0, list.Count)]);
					}
					if (!item.small.Any())
					{
						item.small.Add(list[Random.Range(0, list.Count)]);
					}
					if (!item.medium.Any())
					{
						item.medium.Add(list[Random.Range(0, list.Count)]);
					}
					if (!item.big.Any())
					{
						item.big.Add(list[Random.Range(0, list.Count)]);
					}
					if (!item.wide.Any())
					{
						item.wide.Add(list[Random.Range(0, list.Count)]);
					}
					if (!item.tall.Any())
					{
						item.tall.Add(list[Random.Range(0, list.Count)]);
					}
					if (!item.veryTall.Any())
					{
						item.veryTall.Add(list[Random.Range(0, list.Count)]);
					}
				}
			}
		}

		private static void RemoveValuableObjectsFromList(List<GameObject> list, List<ValuableObject> valuableObjectsToRemove)
		{
			List<ValuableObject> valuableObjectsToRemove2 = valuableObjectsToRemove;
			int count = list.Count;
			foreach (GameObject item in from obj in list.ToList()
				where valuableObjectsToRemove2.Contains(obj.GetComponent<ValuableObject>())
				select obj)
			{
				Settings.Logger.LogDebug((object)("Removed valuable object " + ((Object)item).name + " from list."));
				list.Remove(item);
			}
			if (count - list.Count > 0)
			{
				Settings.Logger.LogDebug((object)$"Removed {count - list.Count} valuable objects from list.");
			}
		}

		public static void RestoreValuableObjects()
		{
			if (RemovedList.Count == 0 || AllItems.Count == 0 || (Object)(object)RunManager.instance == (Object)null || RunManager.instance.levels == null)
			{
				return;
			}
			foreach (Level level in RunManager.instance.levels)
			{
				foreach (LevelValuables valuablePreset in level.ValuablePresets)
				{
					RestoreValuableObjectsFromList(valuablePreset.tiny, ((Object)level).name, ValuablePresetType.Tiny);
					RestoreValuableObjectsFromList(valuablePreset.small, ((Object)level).name, ValuablePresetType.Small);
					RestoreValuableObjectsFromList(valuablePreset.medium, ((Object)level).name, ValuablePresetType.Medium);
					RestoreValuableObjectsFromList(valuablePreset.big, ((Object)level).name, ValuablePresetType.Big);
					RestoreValuableObjectsFromList(valuablePreset.wide, ((Object)level).name, ValuablePresetType.Wide);
					RestoreValuableObjectsFromList(valuablePreset.tall, ((Object)level).name, ValuablePresetType.Tall);
					RestoreValuableObjectsFromList(valuablePreset.veryTall, ((Object)level).name, ValuablePresetType.VeryTall);
				}
			}
		}

		private static void RestoreValuableObjectsFromList(List<GameObject> list, string levelName, ValuablePresetType type)
		{
			string levelName2 = levelName;
			List<GameObject> list2 = list;
			foreach (ValuableMetaData item in AllItems.Values.Where((ValuableMetaData meta) => meta.PresetType == type && meta.LevelName == levelName2 && !list2.Contains(meta.ValuableGameObject)))
			{
				Settings.Logger.LogDebug((object)("Restored valuable object " + ((Object)item.ValuableGameObject).name + " from list."));
				list2.Add(item.ValuableGameObject);
			}
		}

		public static string GetValuablePresetTypePath(ValuablePresetType type)
		{
			return type switch
			{
				ValuablePresetType.Tiny => "01 Tiny", 
				ValuablePresetType.Small => "02 Small", 
				ValuablePresetType.Medium => "03 Medium", 
				ValuablePresetType.Big => "04 Big", 
				ValuablePresetType.Wide => "05 Wide", 
				ValuablePresetType.Tall => "06 Tall", 
				ValuablePresetType.VeryTall => "07 Very Tall", 
				_ => "Valuable Size Not Found - Spawn Manager", 
			};
		}

		private static void AddItemsToDictionary(List<GameObject> list, string levelName, ValuablePresetType type)
		{
			foreach (GameObject item in list)
			{
				if ((Object)(object)item != (Object)null)
				{
					AllItems.TryAdd(((Object)item).name, new ValuableMetaData(item, levelName, type));
				}
			}
		}
	}
	public class ValuableMetaData
	{
		public GameObject ValuableGameObject { get; set; }

		public string LevelName { get; set; }

		public ValuableManager.ValuablePresetType PresetType { get; set; }

		public ValuableMetaData(GameObject valuable, string levelName, ValuableManager.ValuablePresetType presetType)
		{
			ValuableGameObject = valuable;
			LevelName = levelName;
			PresetType = presetType;
		}
	}
}
namespace SpawnManager.Extensions
{
	public static class Extensions
	{
		public static string FriendlyName(this ValuableObject valuableObject)
		{
			return ((Object)valuableObject).name.Replace("Valuable ", "");
		}

		public static string GetKey(this Level level)
		{
			return ((Object)level).name;
		}

		public static string FriendlyName(this Level level)
		{
			return ((Object)level).name.Replace("Level - ", "");
		}

		public static string GetKey(this LevelValuables levelValuables)
		{
			return ((Object)levelValuables).name;
		}
	}
}

BeepInEx/plugins/Spoopylocal-Lethal_Plushies/LethalPlushies.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
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("LethalPlushies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Spoopylocal")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5")]
[assembly: AssemblyProduct("LethalPlushies")]
[assembly: AssemblyTitle("LethalPlushies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[RequireComponent(typeof(PhysGrabObject), typeof(PhotonView))]
public class CarryScare : MonoBehaviourPun
{
	public float carryThreshold = 10f;

	public Vector2 playInterval = new Vector2(5f, 15f);

	public Sound[] scarySounds;

	private PhysGrabObject physGrab;

	private float carryTimer;

	private float nextPlayTime = float.PositiveInfinity;

	private void Start()
	{
		physGrab = ((Component)this).GetComponent<PhysGrabObject>();
		ResetTimers();
	}

	private void Update()
	{
		if (physGrab.grabbed)
		{
			carryTimer += Time.deltaTime;
			if (carryTimer >= carryThreshold)
			{
				if (nextPlayTime == float.PositiveInfinity)
				{
					ScheduleNextSound();
				}
				if (Time.time >= nextPlayTime)
				{
					PlayRandomScarySound();
					ScheduleNextSound();
				}
			}
		}
		else
		{
			ResetTimers();
		}
	}

	private void PlayRandomScarySound()
	{
		if (scarySounds.Length != 0)
		{
			int num = Random.Range(0, scarySounds.Length);
			Debug.Log((object)$"[CarryScare] Triggering scary sound index={num}");
			if (PhotonNetwork.IsConnected && PhotonNetwork.IsMasterClient)
			{
				((MonoBehaviourPun)this).photonView.RPC("RPC_PlaySound", (RpcTarget)0, new object[1] { num });
			}
			else
			{
				RPC_PlaySound(num);
			}
		}
	}

	private void ScheduleNextSound()
	{
		nextPlayTime = Time.time + Random.Range(playInterval.x, playInterval.y);
	}

	private void ResetTimers()
	{
		carryTimer = 0f;
		nextPlayTime = float.PositiveInfinity;
	}

	[PunRPC]
	private void RPC_PlaySound(int index)
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)$"[CarryScare] RPC_PlaySound received index={index}");
		if (index >= 0 && index < scarySounds.Length)
		{
			Sound val = scarySounds[index];
			if (val == null)
			{
				Debug.LogWarning((object)"[CarryScare] Sound at index is null!");
				return;
			}
			val.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			Debug.Log((object)"[CarryScare] Sound played!");
		}
	}
}
namespace LethalPlushies
{
	[BepInPlugin("LethalPlushies", "LethalPlushies", "1.0.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("LethalPlushies");

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Instance = this;
			Logger = Logger.CreateLogSource("LethalPlushies");
			Logger.LogInfo((object)"LethalPlushies has awoken!");
			Harmony val = new Harmony("LethalPlushies");
			val.PatchAll();
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "lethalplushieassets");
			AssetBundle val2 = AssetBundle.LoadFromFile(text);
			GameObject val3 = val2.LoadAsset<GameObject>("Valuable Hoarding Bug");
			GameObject val4 = val2.LoadAsset<GameObject>("Valuable Ghost Girl");
			GameObject val5 = val2.LoadAsset<GameObject>("Valuable Baboon Hawk");
			List<string> list = new List<string> { "Valuables - Generic" };
			Valuables.RegisterValuable(val3, list);
			Valuables.RegisterValuable(val4, list);
			Valuables.RegisterValuable(val5, list);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalPlushies";

		public const string PLUGIN_NAME = "LethalPlushies";

		public const string PLUGIN_VERSION = "1.0.5";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

BeepInEx/plugins/Spoopylocal-Removed_Items/RemovedItems.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
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("RemovedItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Spoopylocal")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RemovedItems")]
[assembly: AssemblyTitle("RemovedItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RemovedItems
{
	[BepInPlugin("RemovedItems", "RemovedItems", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("RemovedItems");

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			Instance = this;
			Harmony val = new Harmony("com.spoopylocal.removeditems");
			val.PatchAll();
			RegisterRemovedItems();
		}

		private static void RegisterRemovedItems()
		{
			string text = "Items/Removed Items";
			Item[] array = Resources.LoadAll<Item>(text);
			Item[] array2 = array;
			foreach (Item val in array2)
			{
				if ((Object)(object)val.prefab == (Object)null)
				{
					val.prefab = Resources.Load<GameObject>(Path.Combine(text, val.itemAssetName));
				}
				if (!((Object)(object)val.prefab == (Object)null))
				{
					Items.RegisterItem(val);
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "RemovedItems";

		public const string PLUGIN_NAME = "RemovedItems";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

BeepInEx/plugins/SteamBlizzard-StalkerGoku/StalkerGoku.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StalkerGoku")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StalkerGoku")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("37892a43-6bf0-4b0f-af25-0f36400bcdaa")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StalkerGoku
{
	[BepInPlugin("SteamBlizzard.StalkerGoku", "Stalker Goku", "1.0.2")]
	public class StalkerGokuBase : BaseUnityPlugin
	{
		private const string modUID = "SteamBlizzard.StalkerGoku";

		private const string modName = "Stalker Goku";

		private const string modVersion = "1.0.2";

		private readonly Harmony harmony = new Harmony("SteamBlizzard.StalkerGoku");

		internal static StalkerGokuBase instance;

		internal ManualLogSource logger;

		internal static AudioClip[] SoundNotice;

		internal static AudioClip[] SoundTeleportIn;

		internal static AudioClip[] SoundTeleportOut;

		internal static AudioClip[] SoundHey;

		internal static AudioClip[] SoundNone;

		internal static GameObject GokuModel;

		private void Awake()
		{
			logger = Logger.CreateLogSource("Stalker Goku");
			logger.LogInfo((object)"Loading Stalker Goku mod...");
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			else
			{
				Object.Destroy((Object)(object)this);
			}
			harmony.PatchAll();
			string location = ((BaseUnityPlugin)instance).Info.Location;
			location = location.TrimEnd("StalkerGoku.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "stalkergoku");
			if ((Object)(object)val == (Object)null)
			{
				logger.LogError((object)"Failed to load asset bundle!");
				return;
			}
			SoundNotice = (AudioClip[])(object)new AudioClip[2]
			{
				val.LoadAsset<AudioClip>("goku_ui"),
				val.LoadAsset<AudioClip>("prowler")
			};
			SoundTeleportIn = (AudioClip[])(object)new AudioClip[1] { val.LoadAsset<AudioClip>("teleport_in") };
			SoundTeleportOut = (AudioClip[])(object)new AudioClip[1] { val.LoadAsset<AudioClip>("teleport_out") };
			SoundNone = (AudioClip[])(object)new AudioClip[1] { val.LoadAsset<AudioClip>("no_sound") };
			SoundHey = (AudioClip[])(object)new AudioClip[1] { val.LoadAsset<AudioClip>("its_me_goku") };
			GokuModel = val.LoadAsset<GameObject>("goku");
			logger.LogInfo((object)"Successfully loaded assets and started Stalker Goku mod!");
		}
	}
}
namespace StalkerGoku.Patches
{
	[HarmonyPatch(typeof(EnemyThinMan))]
	internal class EnemyThinManPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void ReplaceAssets(EnemyThinMan __instance, ref EnemyThinManAnim ___anim)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			StalkerGokuBase.instance.logger.LogInfo((object)"Attempting to replace assets for EnemyThinMan...");
			if ((Object)(object)StalkerGokuBase.GokuModel == (Object)null)
			{
				StalkerGokuBase.instance.logger.LogError((object)"Failed to load visuals for EnemyThinMan! Aborting asset replacement...");
				return;
			}
			Transform child = ((Component)__instance).transform.parent.GetChild(2).GetChild(4).GetChild(0);
			GameObject val = Object.Instantiate<GameObject>(StalkerGokuBase.GokuModel, child);
			Transform transform = val.transform;
			transform.localPosition += new Vector3(0f, 0f - val.transform.position.y, 0f);
			val.transform.localRotation = Quaternion.identity;
			Transform transform2 = val.transform;
			transform2.localScale *= 7f;
			Renderer[] componentsInChildren = ((Component)child.GetChild(0)).gameObject.GetComponentsInChildren<Renderer>();
			Renderer[] componentsInChildren2 = ((Component)child.GetChild(1)).gameObject.GetComponentsInChildren<Renderer>();
			Renderer[] components = ((Component)child.GetChild(0).GetChild(1).GetChild(0)).gameObject.GetComponents<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val2 in array)
			{
				val2.enabled = false;
			}
			Renderer[] array2 = componentsInChildren2;
			foreach (Renderer val3 in array2)
			{
				val3.enabled = false;
			}
			Renderer[] array3 = components;
			foreach (Renderer val4 in array3)
			{
				val4.enabled = false;
			}
			___anim.notice.Sounds = StalkerGokuBase.SoundNotice;
			___anim.notice.PitchRandom = 0f;
			___anim.teleportIn.Sounds = StalkerGokuBase.SoundTeleportIn;
			___anim.teleportOut.Sounds = StalkerGokuBase.SoundTeleportOut;
			___anim.screamLocal.Sounds = StalkerGokuBase.SoundHey;
			___anim.screamLocal.PitchRandom = 0f;
			___anim.screamGlobal.Sounds = StalkerGokuBase.SoundHey;
			___anim.screamGlobal.PitchRandom = 0f;
			___anim.attack.Sounds = StalkerGokuBase.SoundNone;
			___anim.growLoop.Sounds = StalkerGokuBase.SoundNone;
			((Component)___anim).transform.parent = val.transform.parent;
			GameObject gameObject = ((Component)((Component)__instance).transform.parent.GetChild(2).GetChild(3)).gameObject;
			PropLight component = gameObject.GetComponent<PropLight>();
			component.lightRangeMultiplier = 0f;
			StalkerGokuBase.instance.logger.LogInfo((object)"Replaced assets for EnemyThinMan");
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Update(EnemyThinMan __instance, ref EnemyThinManAnim ___anim)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			((Component)__instance).transform.position = ((Component)___anim).transform.position;
		}
	}
}

BeepInEx/plugins/Sticks-Super_Mario_Cosmetics/MoreHead.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using Microsoft.CodeAnalysis;
using MoreHead;
using Newtonsoft.Json;
using Photon.Pun;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MoreHead")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreHead")]
[assembly: AssemblyTitle("MoreHead")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
[BepInPlugin("Mhz.REPOMoreHead", "MoreHead", "1.2.3")]
public class Morehead : BaseUnityPlugin
{
	private const string PluginGuid = "Mhz.REPOMoreHead";

	private const string PluginName = "MoreHead";

	private const string PluginVersion = "1.2.3";

	public static ManualLogSource? Logger;

	public static Morehead? Instance { get; private set; }

	private void Awake()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		Instance = this;
		Logger = ((BaseUnityPlugin)this).Logger;
		try
		{
			Harmony val = new Harmony("Mhz.REPOMoreHead");
			val.PatchAll(typeof(PlayerAvatarVisualsPatch));
			val.PatchAll(typeof(PlayerUpdatePatch));
			val.PatchAll(typeof(PlayerAvatarAwakePatch));
			val.PatchAll(typeof(GameDirectorUpdatePatch));
			val.PatchAll(typeof(PlayerRevivePatch));
			string text = "\n\n ███▄ ▄███▓ ▒█████   ██▀███  ▓█████  ██░ ██ ▓█████ ▄▄▄      ▓█████▄ \n▓██▒▀█▀ ██▒▒██▒  ██▒▓██ ▒ ██▒▓█   ▀ ▓██░ ██▒▓█   ▀▒████▄    ▒██▀ ██▌\n▓██    ▓██░▒██░  ██▒▓██ ░▄█ ▒▒███   ▒██▀███░▒███  ▒██  ▀█▄  ░██   █▌\n▒██    ▒██ ▒██   ██░▒███▀█▄  ▒▓█  ▄ ░▓█ ░██ ▒▓█  ▄░██▄▄▄▄██ ░▓█▄   ▌\n▒██▒   ░██▒░ ████▓▒░░██▓ ▒██▒░▒████▒░▓█▒░██▓░▒████▒▓█   ▓██▒░▒████▓   v1.2.3\n░ ▒░   ░  ░░ ▒░▒░▒░ ░ ▒▓ ░▒▓░░░ ▒░ ░ ▒ ░░▒░▒░░ ▒░ ░▒▒   ▓▒█░ ▒▒▓  ▒ \n░  ░      ░  ░ ▒ ▒░   ░▒ ░ ▒░ ░ ░  ░ ▒ ░▒░ ░ ░ ░  ░ ▒   ▒▒ ░ ░ ▒  ▒ \n░      ░   ░ ░ ░ ▒    ░░   ░    ░    ░  ░░ ░   ░    ░   ▒    ░ ░  ░ \n       ░       ░ ░     ░        ░  ░ ░  ░  ░   ░  ░     ░  ░   ░    \n";
			ManualLogSource? logger = Logger;
			if (logger != null)
			{
				logger.LogMessage((object)text);
			}
			HeadDecorationManager.Initialize();
			ConfigManager.Initialize();
			MoreHeadUI.Initialize();
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("Harmony补丁应用失败: " + ex.Message));
			}
		}
	}

	private void OnApplicationQuit()
	{
		ConfigManager.SaveConfig();
	}

	public static bool GetDecorationState(string? name)
	{
		return HeadDecorationManager.GetDecorationState(name);
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("Update")]
internal class PlayerUpdatePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		if (__instance.photonView.IsMine && GameManager.Multiplayer() && PhotonNetwork.LocalPlayer != null)
		{
		}
	}

	public static void UpdatePlayerDecorations(PlayerAvatar playerAvatar)
	{
		try
		{
			if ((Object)(object)playerAvatar?.playerAvatarVisuals == (Object)null)
			{
				return;
			}
			Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)playerAvatar.playerAvatarVisuals).transform);
			if (decorationParentNodes.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何装饰物父级节点");
				}
				return;
			}
			DecorationUtils.EnsureDecorationContainers(decorationParentNodes);
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (decorationParentNodes.TryGetValue(decoration.ParentTag ?? string.Empty, out var value))
				{
					Transform val = value.Find("HeadDecorations");
					if ((Object)(object)val != (Object)null)
					{
						DecorationUtils.UpdateDecoration(val, decoration.Name ?? string.Empty, decoration.IsVisible);
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("找不到装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("更新玩家装饰物时出错: " + ex.Message));
			}
		}
	}

	public static void UpdateMenuPlayerDecorations()
	{
		try
		{
			PlayerAvatarVisuals val = FindMenuPlayerVisuals();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)val).transform);
			if (decorationParentNodes.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何菜单角色装饰物父级节点");
				}
				return;
			}
			DecorationUtils.EnsureDecorationContainers(decorationParentNodes);
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (decorationParentNodes.TryGetValue(decoration.ParentTag ?? string.Empty, out var value))
				{
					Transform val2 = value.Find("HeadDecorations");
					if ((Object)(object)val2 != (Object)null)
					{
						Transform val3 = val2.Find(decoration.Name);
						if ((Object)(object)val3 == (Object)null)
						{
							AddMenuDecoration(val2, decoration.Name);
						}
						else
						{
							DecorationUtils.UpdateDecoration(val2, decoration.Name ?? string.Empty, decoration.IsVisible);
						}
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("找不到菜单角色装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("更新菜单角色装饰物状态失败: " + ex.Message));
			}
		}
	}

	private static PlayerAvatarVisuals? FindMenuPlayerVisuals()
	{
		if ((Object)(object)PlayerAvatarMenu.instance == (Object)null)
		{
			return null;
		}
		return ((Component)PlayerAvatarMenu.instance).GetComponentInChildren<PlayerAvatarVisuals>();
	}

	public static void AddMenuDecoration(Transform parent, string? decorationName)
	{
		string decorationName2 = decorationName;
		try
		{
			Transform val = parent.Find(decorationName2);
			if ((Object)(object)val != (Object)null)
			{
				bool decorationState = Morehead.GetDecorationState(decorationName2);
				((Component)val).gameObject.SetActive(decorationState);
				return;
			}
			DecorationInfo decorationInfo = HeadDecorationManager.Decorations.Find((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null && (Object)(object)decorationInfo.Prefab != (Object)null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(decorationInfo.Prefab, parent);
				((Object)val2).name = decorationName2;
				val2.SetActive(decorationInfo.IsVisible);
				return;
			}
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogWarning((object)("AddMenuDecoration: 找不到装饰物 " + decorationName2 + " 或其预制体为空"));
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("为菜单角色添加装饰物时出错: " + ex.Message));
			}
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("Awake")]
internal class PlayerAvatarAwakePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		((Component)__instance).gameObject.AddComponent<HeadDecorationSync>();
	}
}
public class HeadDecorationSync : MonoBehaviourPun
{
	public void SyncAllDecorations()
	{
		try
		{
			string[] array = new string[HeadDecorationManager.Decorations.Count];
			bool[] array2 = new bool[HeadDecorationManager.Decorations.Count];
			string[] array3 = new string[HeadDecorationManager.Decorations.Count];
			for (int i = 0; i < HeadDecorationManager.Decorations.Count; i++)
			{
				DecorationInfo decorationInfo = HeadDecorationManager.Decorations[i];
				array[i] = decorationInfo.Name;
				array2[i] = decorationInfo.IsVisible;
				array3[i] = decorationInfo.ParentTag;
			}
			((MonoBehaviourPun)this).photonView.RPC("UpdateAllDecorations", (RpcTarget)1, new object[3] { array, array2, array3 });
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("同步所有装饰物状态失败: " + ex.Message));
			}
		}
	}

	[PunRPC]
	private void UpdateAllDecorations(string[] names, bool[] states, string[] parentTags)
	{
		try
		{
			PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.playerAvatarVisuals == (Object)null)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到PlayerAvatar或PlayerAvatarVisuals组件");
				}
				return;
			}
			Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)component.playerAvatarVisuals).transform);
			if (decorationParentNodes.Count == 0)
			{
				ManualLogSource? logger2 = Morehead.Logger;
				if (logger2 != null)
				{
					logger2.LogWarning((object)"找不到任何装饰物父级节点");
				}
				return;
			}
			DecorationUtils.EnsureDecorationContainers(decorationParentNodes);
			for (int i = 0; i < names.Length; i++)
			{
				string decorationName = names[i];
				bool showDecoration = states[i];
				string key = parentTags[i];
				if (decorationParentNodes.TryGetValue(key, out var value))
				{
					Transform val = value.Find("HeadDecorations");
					if ((Object)(object)val != (Object)null)
					{
						DecorationUtils.UpdateDecoration(val, decorationName, showDecoration);
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("RPC更新所有装饰物状态失败: " + ex.Message));
			}
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals))]
[HarmonyPatch("Start")]
internal class PlayerAvatarVisualsPatch
{
	private static void Postfix(PlayerAvatarVisuals __instance)
	{
		try
		{
			Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)__instance).transform);
			if (decorationParentNodes.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)$"找不到任何装饰物父级节点 (isMenuAvatar: {__instance.isMenuAvatar})");
				}
				return;
			}
			DecorationUtils.EnsureDecorationContainers(decorationParentNodes);
			if (__instance.isMenuAvatar)
			{
				foreach (KeyValuePair<string, Transform> item in decorationParentNodes)
				{
					string key = item.Key;
					Transform value = item.Value;
					Transform val = value.Find("HeadDecorations");
					if ((Object)(object)val != (Object)null)
					{
						foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
						{
							if (decoration.ParentTag == key)
							{
								PlayerUpdatePatch.AddMenuDecoration(val, decoration.Name);
							}
						}
					}
				}
				return;
			}
			foreach (DecorationInfo decoration2 in HeadDecorationManager.Decorations)
			{
				if (decorationParentNodes.TryGetValue(decoration2.ParentTag ?? string.Empty, out var value2))
				{
					Transform val2 = value2.Find("HeadDecorations");
					if ((Object)(object)val2 != (Object)null)
					{
						AddNewDecoration(val2, decoration2, __instance);
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("初始化时找不到装饰物 " + decoration2.DisplayName + " 的父级节点: " + decoration2.ParentTag));
					}
				}
			}
			if (!GameManager.Multiplayer() || !((Object)(object)__instance.playerAvatar != (Object)null) || !((Object)(object)__instance.playerAvatar.photonView != (Object)null) || !__instance.playerAvatar.photonView.IsMine)
			{
				return;
			}
			try
			{
				HeadDecorationSync component = ((Component)__instance.playerAvatar).GetComponent<HeadDecorationSync>();
				if ((Object)(object)component != (Object)null)
				{
					component.SyncAllDecorations();
					return;
				}
				ManualLogSource? logger3 = Morehead.Logger;
				if (logger3 != null)
				{
					logger3.LogWarning((object)"找不到HeadDecorationSync组件,无法同步初始状态");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger4 = Morehead.Logger;
				if (logger4 != null)
				{
					logger4.LogError((object)("同步初始装饰物状态失败: " + ex.Message));
				}
			}
		}
		catch (Exception ex2)
		{
			ManualLogSource? logger5 = Morehead.Logger;
			if (logger5 != null)
			{
				logger5.LogError((object)$"添加装饰物失败: {ex2.Message} (isMenuAvatar: {__instance.isMenuAvatar})");
			}
		}
	}

	private static void AddNewDecoration(Transform parent, DecorationInfo decoration, PlayerAvatarVisuals __instance)
	{
		Transform val = parent.Find(decoration.Name);
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(decoration.IsVisible);
			return;
		}
		if ((Object)(object)decoration.Prefab != (Object)null)
		{
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(decoration.Prefab, parent);
				((Object)val2).name = decoration.Name;
				val2.SetActive(decoration.IsVisible);
				return;
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogError((object)("实例化预制体时出错: " + ex.Message));
				}
				return;
			}
		}
		ManualLogSource? logger2 = Morehead.Logger;
		if (logger2 != null)
		{
			logger2.LogWarning((object)("AddNewDecoration: 装饰物 " + decoration.DisplayName + " 的预制体为空"));
		}
	}
}
[HarmonyPatch(typeof(GameDirector))]
[HarmonyPatch("Update")]
internal class GameDirectorUpdatePatch
{
	private static gameState previousState;

	private static void Postfix(GameDirector __instance)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Invalid comparison between Unknown and I4
		//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)
		try
		{
			if ((int)previousState != 2 && (int)__instance.currentState == 2)
			{
				SyncAllPlayersDecorations();
			}
			previousState = __instance.currentState;
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("监听游戏状态变化时出错: " + ex.Message));
			}
		}
	}

	private static void SyncAllPlayersDecorations()
	{
		try
		{
			PlayerAvatar val = FindLocalPlayer();
			if ((Object)(object)val != (Object)null)
			{
				PlayerUpdatePatch.UpdatePlayerDecorations(val);
				HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>();
				if ((Object)(object)component != (Object)null)
				{
					component.SyncAllDecorations();
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("同步所有玩家装饰物状态时出错: " + ex.Message));
			}
		}
	}

	private static PlayerAvatar? FindLocalPlayer()
	{
		try
		{
			PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
			PlayerAvatar[] array2 = array;
			foreach (PlayerAvatar val in array2)
			{
				if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine)
				{
					return val;
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("查找本地玩家时出错: " + ex.Message));
			}
		}
		return null;
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("ReviveRPC")]
internal class PlayerRevivePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		try
		{
			if (__instance.photonView.IsMine)
			{
				((MonoBehaviour)__instance).StartCoroutine(DelayedSync(__instance));
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("玩家复活时同步装饰物状态失败: " + ex.Message));
			}
		}
	}

	private static IEnumerator DelayedSync(PlayerAvatar playerAvatar)
	{
		yield return null;
		yield return (object)new WaitForSeconds(0.2f);
		try
		{
			PlayerUpdatePatch.UpdatePlayerDecorations(playerAvatar);
		}
		catch (Exception e2)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("更新玩家装饰物状态失败: " + e2.Message));
			}
		}
		yield return (object)new WaitForSeconds(0.1f);
		try
		{
			HeadDecorationSync syncComponent = ((Component)playerAvatar).GetComponent<HeadDecorationSync>();
			if ((Object)(object)syncComponent != (Object)null)
			{
				syncComponent.SyncAllDecorations();
				yield break;
			}
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogWarning((object)"玩家复活后找不到HeadDecorationSync组件");
			}
		}
		catch (Exception e)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("同步装饰物状态失败: " + e.Message));
			}
		}
	}
}
namespace MoreHead
{
	public static class ConfigManager
	{
		private const string MOD_DATA_FOLDER = "REPOModData";

		private const string MOD_FOLDER = "MoreHead";

		private const string CONFIG_FILENAME = "MoreHeadConfig.json";

		private static Dictionary<string?, bool> _decorationStates = new Dictionary<string, bool>();

		private static ManualLogSource? Logger => Morehead.Logger;

		private static string NewConfigFilePath => Path.Combine(Application.persistentDataPath, "REPOModData", "MoreHead", "MoreHeadConfig.json");

		private static string BepInExConfigFilePath => Path.Combine(Paths.ConfigPath, "MoreHeadConfig.json");

		private static string OldConfigFilePath
		{
			get
			{
				Morehead? instance = Morehead.Instance;
				return Path.Combine(Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null) ?? string.Empty, "MoreHeadConfig.txt");
			}
		}

		public static void Initialize()
		{
			try
			{
				EnsureModDataDirectoryExists();
				LoadConfig();
				ApplySavedStates();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("初始化配置管理器时出错: " + ex.Message));
				}
			}
		}

		private static void EnsureModDataDirectoryExists()
		{
			try
			{
				string text = Path.Combine(Application.persistentDataPath, "REPOModData");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)("已创建MOD数据总文件夹: " + text));
					}
				}
				string text2 = Path.Combine(text, "MoreHead");
				if (!Directory.Exists(text2))
				{
					Directory.CreateDirectory(text2);
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogInfo((object)("已创建MOD特定文件夹: " + text2));
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("创建MOD数据目录时出错: " + ex.Message));
				}
			}
		}

		private static void LoadConfig()
		{
			try
			{
				_decorationStates.Clear();
				if (File.Exists(NewConfigFilePath) && LoadJsonConfig(NewConfigFilePath))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)("已从Unity存档位置加载配置: " + NewConfigFilePath));
					}
					return;
				}
				if (File.Exists(BepInExConfigFilePath) && LoadJsonConfig(BepInExConfigFilePath))
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogInfo((object)("已从BepInEx配置目录加载配置: " + BepInExConfigFilePath));
					}
					SaveConfigWithoutUpdate();
					ManualLogSource? logger3 = Logger;
					if (logger3 != null)
					{
						logger3.LogInfo((object)("已将配置从BepInEx目录迁移到Unity存档位置: " + NewConfigFilePath));
					}
					try
					{
						File.Delete(BepInExConfigFilePath);
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogInfo((object)("已删除BepInEx配置文件: " + BepInExConfigFilePath));
						}
						return;
					}
					catch (Exception ex)
					{
						ManualLogSource? logger5 = Logger;
						if (logger5 != null)
						{
							logger5.LogWarning((object)("删除BepInEx配置文件失败: " + ex.Message));
						}
						return;
					}
				}
				if (!File.Exists(OldConfigFilePath))
				{
					return;
				}
				try
				{
					string[] array = File.ReadAllLines(OldConfigFilePath);
					string[] array2 = array;
					foreach (string text in array2)
					{
						if (!string.IsNullOrWhiteSpace(text))
						{
							string[] array3 = text.Split('=');
							if (array3.Length == 2)
							{
								string key = array3[0].Trim();
								bool value = array3[1].Trim().Equals("1", StringComparison.OrdinalIgnoreCase);
								_decorationStates[key] = value;
							}
						}
					}
					if (_decorationStates.Count <= 0)
					{
						return;
					}
					ManualLogSource? logger6 = Logger;
					if (logger6 != null)
					{
						logger6.LogInfo((object)$"已从旧文本格式加载配置,包含 {_decorationStates.Count} 个装饰物状态");
					}
					SaveConfigWithoutUpdate();
					ManualLogSource? logger7 = Logger;
					if (logger7 != null)
					{
						logger7.LogInfo((object)("已将旧文本格式配置迁移到新的JSON格式: " + NewConfigFilePath));
					}
					try
					{
						File.Delete(OldConfigFilePath);
						ManualLogSource? logger8 = Logger;
						if (logger8 != null)
						{
							logger8.LogInfo((object)("已删除旧文本配置文件: " + OldConfigFilePath));
						}
					}
					catch (Exception ex2)
					{
						ManualLogSource? logger9 = Logger;
						if (logger9 != null)
						{
							logger9.LogWarning((object)("删除旧文本配置文件失败: " + ex2.Message));
						}
					}
				}
				catch (Exception ex3)
				{
					ManualLogSource? logger10 = Logger;
					if (logger10 != null)
					{
						logger10.LogError((object)("从旧文本格式加载配置时出错: " + ex3.Message));
					}
				}
			}
			catch (Exception ex4)
			{
				ManualLogSource? logger11 = Logger;
				if (logger11 != null)
				{
					logger11.LogError((object)("加载配置时出错: " + ex4.Message));
				}
				_decorationStates.Clear();
			}
		}

		private static bool LoadJsonConfig(string filePath)
		{
			//IL_0095: Expected O, but got Unknown
			try
			{
				string text = File.ReadAllText(filePath);
				Dictionary<string, bool> dictionary = JsonConvert.DeserializeObject<Dictionary<string, bool>>(text);
				if (dictionary != null)
				{
					foreach (KeyValuePair<string, bool> item in dictionary)
					{
						_decorationStates[item.Key] = item.Value;
					}
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)$"已从JSON加载配置,包含 {_decorationStates.Count} 个装饰物状态");
					}
					return true;
				}
			}
			catch (JsonException val)
			{
				JsonException val2 = val;
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("解析JSON配置文件时出错: " + ((Exception)(object)val2).Message));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("加载JSON配置文件时出错: " + ex.Message));
				}
			}
			return false;
		}

		public static void SaveConfig()
		{
			try
			{
				UpdateConfigData();
				SaveToFile();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("保存配置时出错: " + ex.Message));
				}
			}
		}

		private static void SaveConfigWithoutUpdate()
		{
			try
			{
				SaveToFile();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("保存配置时出错: " + ex.Message));
				}
			}
		}

		private static void SaveToFile()
		{
			try
			{
				EnsureModDataDirectoryExists();
				string contents = JsonConvert.SerializeObject((object)_decorationStates, (Formatting)1);
				File.WriteAllText(NewConfigFilePath, contents);
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("写入配置文件时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateConfigData()
		{
			_decorationStates.Clear();
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				_decorationStates[decoration.Name] = decoration.IsVisible;
			}
		}

		private static void ApplySavedStates()
		{
			try
			{
				int num = 0;
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					if (_decorationStates.TryGetValue(decoration.Name, out var value))
					{
						decoration.IsVisible = value;
						num++;
					}
				}
				if (num > 0)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)$"已应用 {num} 个已保存的装饰物状态");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("应用已保存的装饰物状态时出错: " + ex.Message));
				}
			}
		}
	}
	public static class DecorationUtils
	{
		private const string HEAD_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top";

		private const string NECK_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side";

		private const string BODY_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/ANIM BODY TOP SCALE";

		private const string HIP_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT";

		private const string WORLD_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT";

		public static Dictionary<string, Transform> GetDecorationParentNodes(Transform rootTransform)
		{
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/ANIM BODY TOP SCALE");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			Transform val4 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT");
			if ((Object)(object)val4 != (Object)null)
			{
				dictionary["hip"] = val4;
			}
			Transform val5 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT");
			if ((Object)(object)val5 != (Object)null)
			{
				if (!Object.op_Implicit((Object)(object)((Component)val5).GetComponent<WorldSpaceFollower>()))
				{
					((Component)val5).gameObject.AddComponent<WorldSpaceFollower>();
				}
				dictionary["world"] = val5;
			}
			return dictionary;
		}

		public static void EnsureDecorationContainers(Dictionary<string, Transform> parentNodes)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<string, Transform> parentNode in parentNodes)
			{
				Transform value = parentNode.Value;
				Transform val = value.Find("HeadDecorations");
				if ((Object)(object)val == (Object)null)
				{
					val = new GameObject("HeadDecorations").transform;
					val.SetParent(value, false);
					val.localPosition = Vector3.zero;
					val.localRotation = Quaternion.identity;
					val.localScale = Vector3.one;
				}
			}
		}

		public static void UpdateDecoration(Transform parent, string decorationName, bool showDecoration)
		{
			Transform val = parent.Find(decorationName);
			if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf != showDecoration)
			{
				((Component)val).gameObject.SetActive(showDecoration);
			}
		}
	}
	public class WorldSpaceFollower : MonoBehaviour
	{
		private Transform? _rootTransform;

		private Vector3 _initialOffset;

		private void Start()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			_rootTransform = ((Component)this).transform.parent;
			if ((Object)(object)_rootTransform != (Object)null)
			{
				_initialOffset = ((Component)this).transform.position - _rootTransform.position;
				((Component)this).transform.rotation = Quaternion.identity;
				((Component)this).transform.localScale = Vector3.one;
			}
		}

		private void LateUpdate()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_rootTransform != (Object)null)
			{
				((Component)this).transform.position = _rootTransform.position + _initialOffset;
				((Component)this).transform.rotation = Quaternion.Euler(0f, _rootTransform.eulerAngles.y, 0f);
				((Component)this).transform.localScale = Vector3.one;
			}
		}
	}
	public class DecorationInfo
	{
		public string? Name { get; set; }

		public string? DisplayName { get; set; }

		public bool IsVisible { get; set; }

		public GameObject? Prefab { get; set; }

		public string? ParentTag { get; set; }

		public string? BundlePath { get; set; }
	}
	public static class HeadDecorationManager
	{
		private static Dictionary<string?, string> parentPathMap = new Dictionary<string, string>
		{
			{ "head", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top" },
			{ "neck", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side" },
			{ "body", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/ANIM BODY TOP SCALE" },
			{ "hip", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT" },
			{ "world", "[RIG]/code_lean/code_tilt/ANIM BOT" }
		};

		private static ManualLogSource? Logger => Morehead.Logger;

		public static List<DecorationInfo> Decorations { get; private set; } = new List<DecorationInfo>();


		public static void Initialize()
		{
			try
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"正在初始化装饰物管理器...");
				}
				Decorations.Clear();
				LoadAllDecorations();
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)$"装饰物管理器初始化完成,共加载了 {Decorations.Count} 个装饰物");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("初始化装饰物管理器时出错: " + ex.Message));
				}
			}
		}

		private static void LoadAllDecorations()
		{
			try
			{
				Morehead? instance = Morehead.Instance;
				string directoryName = Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null);
				if (string.IsNullOrEmpty(directoryName))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogError((object)"无法获取MOD所在目录");
					}
					return;
				}
				string text = Path.Combine(directoryName, "Decorations");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogInfo((object)("已创建装饰物目录: " + text));
					}
				}
				List<string> list = new List<string>();
				string[] files = Directory.GetFiles(text, "*.hhh");
				list.AddRange(files);
				try
				{
					string pluginPath = Paths.PluginPath;
					if (!string.IsNullOrEmpty(pluginPath) && Directory.Exists(pluginPath))
					{
						string[] files2 = Directory.GetFiles(pluginPath, "*.hhh", SearchOption.AllDirectories);
						list.AddRange(files2);
						ManualLogSource? logger3 = Logger;
						if (logger3 != null)
						{
							logger3.LogInfo((object)$"在plugins目录中找到 {files2.Length} 个.hhh文件");
						}
					}
					else
					{
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogWarning((object)"无法找到BepInEx/plugins目录,将只加载本地装饰物");
						}
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger5 = Logger;
					if (logger5 != null)
					{
						logger5.LogError((object)("搜索plugins目录时出错: " + ex.Message));
					}
				}
				list = list.Distinct().ToList();
				if (list.Count == 0)
				{
					ManualLogSource? logger6 = Logger;
					if (logger6 != null)
					{
						logger6.LogWarning((object)"未找到任何装饰物包文件,请确保.hhh文件已放置");
					}
				}
				else
				{
					ManualLogSource? logger7 = Logger;
					if (logger7 != null)
					{
						logger7.LogInfo((object)$"找到 {list.Count} 个装饰物包文件");
					}
					if (files.Length != 0)
					{
						ManualLogSource? logger8 = Logger;
						if (logger8 != null)
						{
							logger8.LogInfo((object)$"- Decorations目录: {files.Length} 个文件");
						}
					}
				}
				foreach (string item in list)
				{
					LoadDecorationBundle(item);
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource? logger9 = Logger;
				if (logger9 != null)
				{
					logger9.LogError((object)("加载装饰物时出错: " + ex2.Message));
				}
			}
		}

		private static void LoadDecorationBundle(string bundlePath)
		{
			AssetBundle val = null;
			try
			{
				if (!File.Exists(bundlePath))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("文件不存在: " + bundlePath));
					}
					return;
				}
				FileInfo fileInfo = new FileInfo(bundlePath);
				if (fileInfo.Length < 1024)
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)$"文件过小,可能不是有效的AssetBundle: {bundlePath}, 大小: {fileInfo.Length} 字节");
					}
					return;
				}
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(bundlePath);
				string parentTag = "head";
				string text = fileNameWithoutExtension;
				if (fileNameWithoutExtension.Contains("_"))
				{
					string[] array = fileNameWithoutExtension.Split('_');
					if (array.Length >= 2)
					{
						string text2 = array[^1].ToLower();
						if (parentPathMap.ContainsKey(text2))
						{
							parentTag = text2;
							text = string.Join("_", array, 0, array.Length - 1);
						}
					}
				}
				string text3 = EnsureUniqueName(text);
				if (text3 != text)
				{
					ManualLogSource? logger3 = Logger;
					if (logger3 != null)
					{
						logger3.LogWarning((object)("检测到重名,将基础名称从 " + text + " 修改为 " + text3));
					}
					text = text3;
				}
				try
				{
					val = AssetBundle.LoadFromFile(bundlePath);
					if ((Object)(object)val == (Object)null)
					{
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogError((object)("无法加载AssetBundle,文件可能已损坏或不是有效的AssetBundle: " + bundlePath));
						}
						return;
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger5 = Logger;
					if (logger5 != null)
					{
						logger5.LogError((object)("加载AssetBundle时出错,文件可能不是有效的AssetBundle: " + bundlePath + ", 错误: " + ex.Message));
					}
					return;
				}
				try
				{
					string[] allAssetNames;
					try
					{
						allAssetNames = val.GetAllAssetNames();
					}
					catch (Exception ex2)
					{
						ManualLogSource? logger6 = Logger;
						if (logger6 != null)
						{
							logger6.LogError((object)("获取AssetBundle资源名称时出错: " + bundlePath + ", 错误: " + ex2.Message));
						}
						val.Unload(true);
						return;
					}
					if (allAssetNames.Length == 0)
					{
						ManualLogSource? logger7 = Logger;
						if (logger7 != null)
						{
							logger7.LogWarning((object)("AssetBundle不包含任何资源: " + bundlePath));
						}
						val.Unload(true);
						return;
					}
					bool flag = false;
					GameObject val2 = null;
					string[] array2 = allAssetNames;
					foreach (string text4 in array2)
					{
						try
						{
							val2 = val.LoadAsset<GameObject>(text4);
							if ((Object)(object)val2 != (Object)null)
							{
								flag = true;
								break;
							}
						}
						catch (Exception ex3)
						{
							ManualLogSource? logger8 = Logger;
							if (logger8 != null)
							{
								logger8.LogWarning((object)("加载资源 " + text4 + " 时出错: " + ex3.Message));
							}
						}
					}
					if (!flag || (Object)(object)val2 == (Object)null)
					{
						ManualLogSource? logger9 = Logger;
						if (logger9 != null)
						{
							logger9.LogWarning((object)("AssetBundle不包含有效的GameObject资源: " + bundlePath));
						}
						val.Unload(true);
						return;
					}
					string text5 = ((Object)val2).name;
					string text6 = EnsureUniqueDisplayName(text5);
					if (text6 != text5)
					{
						ManualLogSource? logger10 = Logger;
						if (logger10 != null)
						{
							logger10.LogWarning((object)("检测到显示名称重复,将显示名称从 " + text5 + " 修改为 " + text6));
						}
						text5 = text6;
					}
					DecorationInfo decorationInfo = new DecorationInfo
					{
						Name = text,
						DisplayName = text5,
						IsVisible = false,
						Prefab = val2,
						ParentTag = parentTag,
						BundlePath = bundlePath
					};
					Decorations.Add(decorationInfo);
					ManualLogSource? logger11 = Logger;
					if (logger11 != null)
					{
						logger11.LogInfo((object)("成功加载装饰物: " + decorationInfo.DisplayName + ", 标签: " + decorationInfo.ParentTag));
					}
					val.Unload(false);
				}
				catch (Exception ex4)
				{
					ManualLogSource? logger12 = Logger;
					if (logger12 != null)
					{
						logger12.LogError((object)("处理AssetBundle时出错: " + ex4.Message));
					}
					if ((Object)(object)val != (Object)null)
					{
						val.Unload(true);
					}
				}
			}
			catch (Exception ex5)
			{
				ManualLogSource? logger13 = Logger;
				if (logger13 != null)
				{
					logger13.LogError((object)("加载装饰物包时出错: " + ex5.Message + ", 路径: " + bundlePath));
				}
				if ((Object)(object)val != (Object)null)
				{
					val.Unload(true);
				}
			}
		}

		private static string EnsureUniqueName(string baseName)
		{
			string name = baseName;
			int num = 1;
			while (Decorations.Any((DecorationInfo d) => d.Name != null && d.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
			{
				name = $"{baseName}({num})";
				num++;
			}
			return name;
		}

		private static string EnsureUniqueDisplayName(string baseDisplayName)
		{
			string displayName = baseDisplayName;
			int num = 1;
			while (Decorations.Any((DecorationInfo d) => d.DisplayName != null && d.DisplayName.Equals(displayName, StringComparison.OrdinalIgnoreCase)))
			{
				displayName = $"{baseDisplayName}({num})";
				num++;
			}
			return displayName;
		}

		private static string? GetParentTagFromPrefab(GameObject prefab)
		{
			string text = ((Object)prefab).name.ToLower();
			foreach (string key in parentPathMap.Keys)
			{
				if (key != null && text.Contains(key))
				{
					return key;
				}
			}
			return null;
		}

		public static bool GetDecorationState(string? name)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo == null)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("GetDecorationState: 找不到装饰物 " + name2));
				}
			}
			return decorationInfo?.IsVisible ?? false;
		}

		public static void SetDecorationState(string name, bool isVisible)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null)
			{
				decorationInfo.IsVisible = isVisible;
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)$"设置装饰物 {decorationInfo.DisplayName} 显示状态为: {isVisible}");
				}
			}
			else
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogWarning((object)("SetDecorationState: 找不到装饰物 " + name2));
				}
			}
		}

		public static bool ToggleDecorationState(string? name)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null)
			{
				decorationInfo.IsVisible = !decorationInfo.IsVisible;
				return decorationInfo.IsVisible;
			}
			ManualLogSource? logger = Logger;
			if (logger != null)
			{
				logger.LogWarning((object)("ToggleDecorationState: 找不到装饰物 " + name2));
			}
			return false;
		}

		public static string GetParentPath(string parentTag)
		{
			if (parentPathMap.TryGetValue(parentTag.ToLower(), out string value))
			{
				return value;
			}
			return parentPathMap["head"];
		}

		public static void DisableAllDecorations()
		{
			try
			{
				int num = 0;
				foreach (DecorationInfo decoration in Decorations)
				{
					if (decoration.IsVisible)
					{
						decoration.IsVisible = false;
						num++;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("关闭所有装饰物时出错: " + ex.Message));
				}
			}
		}
	}
	public static class MoreHeadUI
	{
		private static REPOButton? menuButton;

		private static REPOPopupPage? decorationsPage;

		private static Dictionary<string?, REPOButton> decorationButtons = new Dictionary<string, REPOButton>();

		private static string currentTagFilter = "ALL";

		private static Dictionary<string, REPOButton> tagFilterButtons = new Dictionary<string, REPOButton>();

		private static Dictionary<string, REPOPopupPage?> tagPageCache = new Dictionary<string, REPOPopupPage>();

		private static Dictionary<string, Dictionary<string, REPOButton>> tagPageButtonCache = new Dictionary<string, Dictionary<string, REPOButton>>();

		private const string BUTTON_NAME = "<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>";

		private const string PAGE_TITLE = "Rotate robot: A/D";

		private static readonly string[] ALL_TAGS = new string[6] { "ALL", "HEAD", "NECK", "BODY", "HIP", "WORLD" };

		private static ManualLogSource? Logger => Morehead.Logger;

		public static void Initialize()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_002c: 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_0052: Expected O, but got Unknown
			try
			{
				menuButton = new REPOButton("<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>", (Action)OnMenuButtonClick);
				MenuAPI.AddElementToEscapeMenu((REPOElement)(object)menuButton, new Vector2(0f, 0f));
				decorationsPage = new REPOPopupPage("Rotate robot: A/D", (Action<REPOPopupPage>)SetupPopupPage);
				PreCreateTagPages();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("初始化UI时出错: " + ex.Message));
				}
			}
		}

		private static void PreCreateTagPages()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			try
			{
				tagPageCache.Clear();
				string[] aLL_TAGS = ALL_TAGS;
				foreach (string text in aLL_TAGS)
				{
					REPOPopupPage val = new REPOPopupPage("Rotate robot: A/D", (Action<REPOPopupPage>)SetupPopupPage);
					string text2 = currentTagFilter;
					currentTagFilter = text;
					CreatePageContentForTag(val, text);
					tagPageCache[text] = val;
					currentTagFilter = text2;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("预创建标签页面缓存时出错: " + ex.Message));
				}
			}
		}

		private static void SetupPopupPage(REPOPopupPage page)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				page.SetSize(new Vector2(300f, 350f));
				page.SetBackgroundDimming(true);
				page.SetMaskPadding((Padding?)new Padding(10f, 50f, 20f, 10f));
				AddAuthorCredit(page);
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("设置弹出页面属性时出错: " + ex.Message));
				}
			}
		}

		private static void AddAuthorCredit(REPOPopupPage page)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				REPOButton val = new REPOButton("<size=10><color=#FFFFA0>Masaicker</color> and <color=#FFFFA0>Yuriscat</color> co-developed.\n由<color=#FFFFA0>马赛克了</color>和<color=#FFFFA0>尤里的猫</color>共同制作。</size>", (Action)delegate
				{
				});
				((REPOSimplePage)page).AddElementToPage((REPOElement)(object)val, new Vector2(300f, 345f));
				try
				{
					MenuManager obj = Object.FindObjectOfType<MenuManager>();
					if (obj != null)
					{
						((MonoBehaviour)obj).StartCoroutine(DelayedStyleAuthorCredit(val));
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("无法修改作者标记样式: " + ex.Message));
					}
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("添加作者标记时出错: " + ex2.Message));
				}
			}
		}

		private static IEnumerator DelayedStyleAuthorCredit(REPOButton button)
		{
			yield return null;
			try
			{
				GameObject buttonObj = null;
				Button[] allButtons = Object.FindObjectsOfType<Button>();
				Button[] array = allButtons;
				foreach (Button btn in array)
				{
					if (((Object)btn).name.Contains("Masaicker") && ((Object)btn).name.Contains("Yuriscat"))
					{
						buttonObj = ((Component)btn).gameObject;
						break;
					}
				}
				if (!((Object)(object)buttonObj != (Object)null))
				{
					yield break;
				}
				Button buttonComponent = buttonObj.GetComponent<Button>();
				if (!((Object)(object)buttonComponent != (Object)null))
				{
					yield break;
				}
				((Selectable)buttonComponent).interactable = false;
				Image[] images = buttonObj.GetComponentsInChildren<Image>();
				Image[] array2 = images;
				foreach (Image image in array2)
				{
					if ((Object)(object)((Component)image).gameObject != (Object)(object)((Component)buttonComponent).gameObject)
					{
						((Behaviour)image).enabled = false;
					}
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("修改作者标记样式失败: " + e.Message));
				}
			}
		}

		private static void OnMenuButtonClick()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			try
			{
				if (tagPageCache.TryGetValue(currentTagFilter, out REPOPopupPage value))
				{
					decorationsPage = value;
				}
				else
				{
					decorationsPage = new REPOPopupPage("Rotate robot: A/D", (Action<REPOPopupPage>)SetupPopupPage);
					CreatePageContent();
				}
				REPOPopupPage? obj = decorationsPage;
				if (obj != null)
				{
					((REPOSimplePage)obj).OpenPage(false);
				}
				SetHeaderPosition();
				MovePlayerAvatarToFront();
				AdjustMenuScrollBoxPosition();
				UpdateButtonStates();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("打开设置页面时出错: " + ex.Message));
				}
			}
		}

		private static void SetHeaderPosition()
		{
			try
			{
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedSetHeaderPosition());
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("设置标题位置时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedSetHeaderPosition()
		{
			yield return null;
			try
			{
				FieldInfo headerTransformField = typeof(REPOPopupPage).GetField("headerTransform", BindingFlags.Instance | BindingFlags.NonPublic);
				if (headerTransformField != null)
				{
					object? value = headerTransformField.GetValue(decorationsPage);
					RectTransform headerTransform = (RectTransform)((value is RectTransform) ? value : null);
					if ((Object)(object)headerTransform != (Object)null)
					{
						((Transform)headerTransform).localPosition = new Vector3(185.5049f, 360f, 0f);
						yield break;
					}
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)"headerTransform为空");
					}
				}
				else
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)"找不到headerTransform字段");
					}
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("延迟设置标题位置时出错: " + e.Message));
				}
			}
		}

		private static void CreatePageContent()
		{
			CreatePageContentForTag(decorationsPage, currentTagFilter);
		}

		private static void CreatePageContentForTag(REPOPopupPage? page, string tag)
		{
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_01cd: 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)
			try
			{
				int num = 0;
				decorationButtons.Clear();
				if (!tagPageButtonCache.ContainsKey(tag))
				{
					tagPageButtonCache[tag] = new Dictionary<string, REPOButton>();
				}
				else
				{
					tagPageButtonCache[tag].Clear();
				}
				for (int i = 0; i < HeadDecorationManager.Decorations.Count; i++)
				{
					DecorationInfo decoration = HeadDecorationManager.Decorations[i];
					if (tag == "ALL" || decoration.ParentTag?.ToLower() == tag.ToLower())
					{
						REPOButton val = new REPOButton(GetButtonText(decoration, decoration.IsVisible), (Action)delegate
						{
							OnDecorationButtonClick(decoration.Name);
						});
						int num2 = -(60 + num * 20);
						if (page != null)
						{
							page.AddElementToScrollView((REPOElement)(object)val, new Vector2(0f, (float)num2));
						}
						decorationButtons[decoration.Name ?? string.Empty] = val;
						tagPageButtonCache[tag][decoration.Name ?? string.Empty] = val;
						num++;
					}
				}
				CreateTagFilterButtons(page);
				REPOButton val2 = new REPOButton("<size=18><color=#FFFFFF>C</color><color=#E6E6E6>L</color><color=#CCCCCC>O</color><color=#B3B3B3>S</color><color=#999999>E</color></size>", (Action)OnCloseButtonClick);
				if (page != null)
				{
					((REPOSimplePage)page).AddElementToPage((REPOElement)(object)val2, new Vector2(301f, 0f));
				}
				REPOButton val3 = new REPOButton("<size=18><color=#FFAA00>CLEAR ALL</color></size>", (Action)OnDisableAllButtonClick);
				if (page != null)
				{
					((REPOSimplePage)page).AddElementToPage((REPOElement)(object)val3, new Vector2(401f, 0f));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("创建页面内容时出错: " + ex.Message));
				}
			}
		}

		private static void CreateTagFilterButtons(REPOPopupPage? page)
		{
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				tagFilterButtons.Clear();
				for (int i = 0; i < ALL_TAGS.Length; i++)
				{
					string text = ALL_TAGS[i];
					string text2 = text.ToLower();
					if (1 == 0)
					{
					}
					string text3 = text2 switch
					{
						"head" => "#00AAFF", 
						"neck" => "#AA00FF", 
						"body" => "#FFAA00", 
						"hip" => "#FF00AA", 
						"world" => "#00FFAA", 
						_ => "#FFFFFF", 
					};
					if (1 == 0)
					{
					}
					string text4 = text3;
					string text5 = ((text2 == currentTagFilter.ToLower()) ? ("<size=14><b><color=" + text4 + ">" + text + "</color></b></size>") : ("<size=14><color=" + text4 + "50>" + text + "</color></size>"));
					string tagForCallback = ((text2 == "all") ? "ALL" : text);
					REPOButton val = new REPOButton(text5, (Action)delegate
					{
						OnTagFilterButtonClick(tagForCallback);
					});
					int num = 70 + i * 40;
					if (page != null)
					{
						((REPOSimplePage)page).AddElementToPage((REPOElement)(object)val, new Vector2((float)num, 20f));
					}
					tagFilterButtons[tagForCallback] = val;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("创建标签筛选按钮时出错: " + ex.Message));
				}
			}
		}

		private static void OnTagFilterButtonClick(string tag)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			try
			{
				if (!(tag == currentTagFilter))
				{
					currentTagFilter = tag;
					REPOPopupPage? obj = decorationsPage;
					if (obj != null)
					{
						((REPOSimplePage)obj).ClosePage(true);
					}
					if (tagPageCache.TryGetValue(tag, out REPOPopupPage value))
					{
						decorationsPage = value;
					}
					else
					{
						decorationsPage = new REPOPopupPage("Rotate robot: A/D", (Action<REPOPopupPage>)SetupPopupPage);
						CreatePageContent();
						tagPageCache[tag] = decorationsPage;
					}
					REPOPopupPage? obj2 = decorationsPage;
					if (obj2 != null)
					{
						((REPOSimplePage)obj2).OpenPage(false);
					}
					SetHeaderPosition();
					MovePlayerAvatarToFront();
					AdjustMenuScrollBoxPosition();
					UpdateButtonStates();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("切换标签筛选时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateButtonStates()
		{
			try
			{
				if (decorationButtons.Count == 0)
				{
					return;
				}
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					if ((currentTagFilter == "ALL" || decoration.ParentTag?.ToLower() == currentTagFilter.ToLower()) && decorationButtons.TryGetValue(decoration.Name ?? string.Empty, out REPOButton value))
					{
						value.SetText(GetButtonText(decoration, decoration.IsVisible));
					}
				}
				UpdateTagButtonHighlights();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新按钮状态时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateTagButtonHighlights()
		{
			try
			{
				string[] aLL_TAGS = ALL_TAGS;
				foreach (string text in aLL_TAGS)
				{
					string text2 = ((text == "ALL") ? "ALL" : text);
					if (tagFilterButtons.TryGetValue(text2, out REPOButton value))
					{
						string text3 = text.ToLower();
						if (1 == 0)
						{
						}
						string text4 = text3 switch
						{
							"head" => "#00AAFF", 
							"neck" => "#AA00FF", 
							"body" => "#FFAA00", 
							"hip" => "#FF00AA", 
							"world" => "#00FFAA", 
							_ => "#FFFFFF", 
						};
						if (1 == 0)
						{
						}
						string text5 = text4;
						string text6 = ((text2 == currentTagFilter) ? ("<size=14><b><color=" + text5 + ">" + text + "</color></b></size>") : ("<size=14><color=" + text5 + "50>" + text + "</color></size>"));
						value.SetText(text6);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新标签按钮高亮状态时出错: " + ex.Message));
				}
			}
		}

		private static void OnDecorationButtonClick(string? decorationName)
		{
			string decorationName2 = decorationName;
			try
			{
				DecorationInfo decorationInfo = HeadDecorationManager.Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase));
				if (decorationInfo == null)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("OnDecorationButtonClick: 找不到装饰物: " + decorationName2));
					}
					return;
				}
				bool isEnabled = HeadDecorationManager.ToggleDecorationState(decorationName2);
				foreach (KeyValuePair<string, Dictionary<string, REPOButton>> item in tagPageButtonCache)
				{
					string key = item.Key;
					Dictionary<string, REPOButton> value = item.Value;
					if ((key == "ALL" || decorationInfo.ParentTag?.ToLower() == key.ToLower()) && value.TryGetValue(decorationName2 ?? string.Empty, out var value2))
					{
						value2.SetText(GetButtonText(decorationInfo, isEnabled));
					}
				}
				UpdateDecorations();
				ConfigManager.SaveConfig();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("切换装饰物 " + decorationName2 + " 状态时出错: " + ex.Message));
				}
			}
		}

		private static string GetButtonText(DecorationInfo decoration, bool isEnabled)
		{
			string text = decoration.DisplayName?.ToUpper() ?? "UNKNOWN";
			string text2 = decoration.ParentTag ?? "unknown";
			string text3 = text2.ToLower();
			if (1 == 0)
			{
			}
			string text4 = text3 switch
			{
				"head" => "#00AAFF", 
				"neck" => "#AA00FF", 
				"body" => "#FFAA00", 
				"hip" => "#FF00AA", 
				"world" => "#00FFAA", 
				_ => "#AAAAAA", 
			};
			if (1 == 0)
			{
			}
			string text5 = text4;
			return "<size=16>" + (isEnabled ? "<color=#00FF00>[+]</color>" : "<color=#FF0000>[-]</color>") + " <color=" + text5 + "><size=12>(" + text2 + ")</size></color> " + text + "</size>";
		}

		private static void OnCloseButtonClick()
		{
			try
			{
				MenuManager.instance.PageCloseAll();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("关闭页面时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateDecorations()
		{
			try
			{
				PlayerAvatar val = FindLocalPlayer();
				if ((Object)(object)val != (Object)null)
				{
					PlayerUpdatePatch.UpdatePlayerDecorations(val);
					HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>();
					if ((Object)(object)component != (Object)null)
					{
						component.SyncAllDecorations();
					}
				}
				PlayerUpdatePatch.UpdateMenuPlayerDecorations();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新装饰物状态时出错: " + ex.Message));
				}
			}
		}

		private static PlayerAvatar? FindLocalPlayer()
		{
			try
			{
				PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
				PlayerAvatar[] array2 = array;
				foreach (PlayerAvatar val in array2)
				{
					if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine)
					{
						return val;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("查找本地玩家时出错: " + ex.Message));
				}
			}
			return null;
		}

		private static void MovePlayerAvatarToFront()
		{
			try
			{
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedMovePlayerAvatarToFront());
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("移动玩家模型时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedMovePlayerAvatarToFront()
		{
			yield return null;
			try
			{
				PlayerAvatarMenuHover playerAvatarHover = Object.FindObjectOfType<PlayerAvatarMenuHover>();
				GameObject playerAvatarObj = null;
				if ((Object)(object)playerAvatarHover != (Object)null)
				{
					playerAvatarObj = ((Component)((Component)playerAvatarHover).transform.parent).gameObject;
					if (((Object)playerAvatarObj).name != "Menu Element Player Avatar")
					{
						playerAvatarObj = null;
					}
				}
				if ((Object)(object)playerAvatarObj == (Object)null)
				{
					playerAvatarObj = GameObject.Find("Menu Element Player Avatar");
				}
				if ((Object)(object)playerAvatarObj != (Object)null)
				{
					object? value = AccessTools.Field(typeof(REPOPopupPage), "menuPage").GetValue(decorationsPage);
					MenuPage menuPage = (MenuPage)((value is MenuPage) ? value : null);
					if ((Object)(object)menuPage != (Object)null)
					{
						playerAvatarObj.transform.SetParent(((Component)menuPage).transform, true);
						playerAvatarObj.transform.SetAsLastSibling();
						playerAvatarObj.transform.localPosition = new Vector3(-76f, -30f, 0f);
					}
				}
				else
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)"找不到玩家模型对象");
					}
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("延迟移动玩家模型时出错: " + e.Message));
				}
			}
		}

		private static void AdjustMenuScrollBoxPosition()
		{
			try
			{
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedAdjustMenuScrollBoxPosition());
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("调整MenuScrollBox位置时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedAdjustMenuScrollBoxPosition()
		{
			yield return null;
			yield return null;
			try
			{
				object? value = AccessTools.Field(typeof(REPOPopupPage), "menuScrollBox").GetValue(decorationsPage);
				MenuScrollBox menuScrollBox = (MenuScrollBox)((value is MenuScrollBox) ? value : null);
				if ((Object)(object)menuScrollBox != (Object)null)
				{
					RectTransform rectTransform = ((Component)menuScrollBox).GetComponent<RectTransform>();
					if ((Object)(object)rectTransform != (Object)null)
					{
						Vector3 currentPosition2 = ((Transform)rectTransform).localPosition;
						Vector3 newPosition2 = new Vector3(currentPosition2.x, currentPosition2.y + 20f, currentPosition2.z);
						((Transform)rectTransform).localPosition = newPosition2;
						yield break;
					}
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)"无法获取MenuScrollBox的RectTransform组件");
					}
					yield break;
				}
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogWarning((object)"无法获取MenuScrollBox组件");
				}
				object? value2 = AccessTools.Field(typeof(REPOPopupPage), "menuPage").GetValue(decorationsPage);
				MenuPage menuPage = (MenuPage)((value2 is MenuPage) ? value2 : null);
				if (!((Object)(object)menuPage != (Object)null))
				{
					yield break;
				}
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogInfo((object)"成功获取MenuPage组件,尝试查找MenuScrollBox");
				}
				foreach (Transform item in ((Component)menuPage).transform)
				{
					Transform child = item;
					ManualLogSource? logger4 = Logger;
					if (logger4 != null)
					{
						logger4.LogInfo((object)("找到子对象: " + ((Object)child).name));
					}
					if (!((Object)child).name.Contains("ScrollBox") && !((Object)(object)((Component)child).GetComponent<MenuScrollBox>() != (Object)null))
					{
						continue;
					}
					RectTransform scrollBoxTransform = (RectTransform)(object)((child is RectTransform) ? child : null);
					if ((Object)(object)scrollBoxTransform != (Object)null)
					{
						Vector3 currentPosition = ((Transform)scrollBoxTransform).localPosition;
						Vector3 newPosition = (((Transform)scrollBoxTransform).localPosition = new Vector3(currentPosition.x, currentPosition.y + 20f, currentPosition.z));
						ManualLogSource? logger5 = Logger;
						if (logger5 != null)
						{
							logger5.LogInfo((object)$"通过替代方法调整MenuScrollBox位置: 从 {currentPosition} 到 {newPosition}");
						}
					}
					break;
				}
			}
			catch (Exception e)
			{
				ManualLogSource? logger6 = Logger;
				if (logger6 != null)
				{
					logger6.LogError((object)("调整MenuScrollBox位置时出错: " + e.Message + "\n" + e.StackTrace));
				}
			}
		}

		private static void OnDisableAllButtonClick()
		{
			try
			{
				HeadDecorationManager.DisableAllDecorations();
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					foreach (KeyValuePair<string, Dictionary<string, REPOButton>> item in tagPageButtonCache)
					{
						string key = item.Key;
						Dictionary<string, REPOButton> value = item.Value;
						if ((key == "ALL" || decoration.ParentTag?.ToLower() == key.ToLower()) && value.TryGetValue(decoration.Name ?? string.Empty, out var value2))
						{
							value2.SetText(GetButtonText(decoration, isEnabled: false));
						}
					}
				}
				UpdateDecorations();
				ConfigManager.SaveConfig();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("关闭所有装饰物时出错: " + ex.Message));
				}
			}
		}
	}
}

BeepInEx/plugins/Tidaleus-MoreReviveHP/More Revive HP.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using More_Revive_HP.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("More Revive HP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("More Revive HP")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("46ab4f67-24f2-4385-81cf-415d36226ff4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("Tidaleus.MoreReviveHP", "More Revive HP", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
	public const string modGUID = "Tidaleus.MoreReviveHP";

	public const string modName = "More Revive HP";

	public const string modVersion = "1.0.1";

	private readonly Harmony harmony = new Harmony("Tidaleus.MoreReviveHP");

	private static Plugin Instance;

	private ConfigEntry<int> ExtraHealth;

	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Tidaleus.MoreReviveHP has loaded");
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		ExtraHealth = ((BaseUnityPlugin)this).Config.Bind<int>("General", "ExtraHealth", 19, "Extra Health to add to the 1 you spawn with, therefore make this something 1 through 99.");
		harmony.PatchAll(typeof(Plugin));
		harmony.PatchAll(typeof(PlayerAvatarPatch));
	}

	public static int GetExtraHealth()
	{
		return Instance.ExtraHealth.Value;
	}
}
namespace More_Revive_HP.Patches;

[HarmonyPatch(typeof(PlayerAvatar), "ReviveRPC")]
internal class PlayerAvatarPatch
{
	private static void Postfix(PlayerAvatar __instance, bool _revivedByTruck)
	{
		int extraHealth = Plugin.GetExtraHealth();
		if (__instance.photonView.IsMine)
		{
			__instance.playerHealth.HealOther(extraHealth, true);
		}
	}
}

BeepInEx/plugins/TitanVortex-BigNuke/BigNuke.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;

[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("BigNuke")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BigNuke")]
[assembly: AssemblyTitle("BigNuke")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 Vortex.BigNuke
{
	[BepInPlugin("Vortex.BigNuke", "BigNuke", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BigNuke : BaseUnityPlugin
	{
		private const string modUID = "Vortex.BigNuke";

		private const string modName = "BigNuke";

		private const string modVersion = "1.0.1";

		public int explosionPlayerDamage = 100;

		public int explosionEnemyDamage = 500;

		public ConfigEntry<float> explosionRange;

		public ConfigEntry<int> maxHitCount;

		public ConfigEntry<int> minValue;

		public ConfigEntry<int> maxValue;

		internal static BigNuke instance;

		internal ManualLogSource logger = Logger.CreateLogSource("BigNuke");

		internal static GameObject NukeModel;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			if ((Object)instance == (Object)null)
			{
				instance = this;
			}
			else
			{
				Object.Destroy((Object)this);
			}
			logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version}: Instance set.");
			explosionRange = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "Range", 5f, "The range of the explosion. (For comparison: explosive grenade range is 1)");
			maxHitCount = ((BaseUnityPlugin)this).Config.Bind<int>("Explosion", "Max Hit Count", 3, "The amount of heavy hits required to trigger the explosion. (0 means only explode on destroy)");
			minValue = ((BaseUnityPlugin)this).Config.Bind<int>("Explosion", "Min Nuke Sell Value", 8000, "The minimum value of the nuke when sold.");
			maxValue = ((BaseUnityPlugin)this).Config.Bind<int>("Explosion", "Max Nuke Sell Value", 12000, "The maximum value of the nuke when sold.");
			logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version}: Config loaded.");
			string location = ((BaseUnityPlugin)instance).Info.Location;
			location = location.TrimEnd("BigNuke.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "nuke");
			if ((Object)val == (Object)null)
			{
				logger.LogError((object)"Failed to load asset bundle!");
				return;
			}
			NukeModel = val.LoadAsset<GameObject>("Valuable Nuke");
			if ((Object)NukeModel == (Object)null)
			{
				logger.LogError((object)"Failed to load model!");
				return;
			}
			NukeValuable nukeValuable = NukeModel.AddComponent<NukeValuable>();
			if ((Object)nukeValuable == (Object)null)
			{
				logger.LogError((object)"Failed to add NukeValuable component!");
				return;
			}
			Valuables.RegisterValuable(NukeModel);
			logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version}: Nuke registered.");
		}
	}
	public class NukeValuable : Trap
	{
		private ParticleScriptExplosion particleScriptExplosion;

		private int HitCount;

		public Transform Center;

		public override void Start()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			PhysGrabObjectImpactDetector component = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			if ((Object)component == (Object)null)
			{
				BigNuke.instance.logger.LogError((object)"Failed to get PhysGrabObjectImpactDetector component!");
				return;
			}
			Value val = ScriptableObject.CreateInstance<Value>();
			val.valueMin = Math.Max(0, BigNuke.instance.minValue.Value);
			val.valueMax = Math.Max(val.valueMin, BigNuke.instance.maxValue.Value);
			ValuableObject component2 = ((Component)this).GetComponent<ValuableObject>();
			if ((Object)component2 == (Object)null)
			{
				BigNuke.instance.logger.LogError((object)"Failed to get ValuableObject component!");
				return;
			}
			component2.valuePreset = val;
			component.onBreakHeavy.AddListener(new UnityAction(PotentialExplode));
			component.onDestroy.AddListener(new UnityAction(Explode));
			((Trap)this).Start();
			particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
			Center = ((Component)this).transform.Find("Object/Center");
		}

		public void Explode()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			particleScriptExplosion.Spawn(Center.position, Math.Max(1f, BigNuke.instance.explosionRange.Value), BigNuke.instance.explosionPlayerDamage, BigNuke.instance.explosionEnemyDamage, 1f, false, false, 1f);
		}

		public void PotentialExplode()
		{
			if (base.isLocal && BigNuke.instance.maxHitCount.Value > 0)
			{
				if (HitCount >= BigNuke.instance.maxHitCount.Value - 1)
				{
					Explode();
				}
				else
				{
					HitCount++;
				}
			}
		}
	}
}

BeepInEx/plugins/TopSandwich-ItemResistUpgrade/ItemResistUpgrade.dll

Decompiled 2 weeks 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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MoreUpgrades.Classes;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CarefulUpgrade")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CarefulUpgrade")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7cb998b0-02aa-4eee-92fa-7ca8822e7a50")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ItemResistUpgrade
{
	[BepInPlugin("sandwich.itemResistUpgrade", "ItemResistUpgrade", "1.0.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static Plugin instance;

		internal const string modGUID = "sandwich.itemResistUpgrade";

		private const string modName = "ItemResistUpgrade";

		private const string modVersion = "1.0.4";

		internal static ConfigEntry<float> configPower;

		private readonly Harmony harmony = new Harmony("sandwich.itemResistUpgrade");

		internal ManualLogSource mls;

		protected void Awake()
		{
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("ItemResistUpgrade");
			string text = "Item Resist";
			string value = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Upgrade Name", text, "The name to use for the upgrade.").Value;
			configPower = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Item Resist Upgrade Power", 0.8f, "The multiplier of item resist per upgrade on an item (Lower is stronger)");
			float value2 = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Minimum Price", 4000f, "The minimum base price of the upgrade.").Value;
			float value3 = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Maximum Price", 6000f, "The maximum base price of the upgrade.").Value;
			float value4 = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Price Scaling", 0.5f, "The amount the upgrade price increases by (multiplier of base value) per upgrade already purchased.").Value;
			int value5 = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Shop Amount Maximum", 2, "The maximum amount of times the upgrade can appear in the shop.").Value;
			string text2 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "itemresistbundle");
			AssetBundle val = AssetBundle.LoadFromFile(text2);
			Item val2 = val.LoadAsset<Item>(text);
			GameObject val3 = val.LoadAsset<GameObject>(text + " Prefab");
			List<string> excludeConfigs = new List<string> { "Max Amount", "Max Amount In Shop", "Minimum Price", "Maximum Price", "Price Increase Scaling", "Max Purchase Amount", "Display Name" };
			UpgradeItemBase val4 = new UpgradeItemBase
			{
				name = value,
				maxAmount = 1000,
				maxAmountInShop = value5,
				minPrice = value2,
				maxPrice = value3,
				maxPurchaseAmount = 0,
				priceIncreaseScaling = value4,
				excludeConfigs = excludeConfigs
			};
			MoreUpgradesLib.Register("sandwich.itemResistUpgrade", val2, val3, val4);
			mls.LogInfo((object)"ItemResistUpgrade is loaded");
			harmony.PatchAll();
		}
	}
}
namespace ItemResistUpgrade.Patches
{
	[HarmonyPatch(typeof(PhysGrabObjectImpactDetector))]
	internal class PhysGrabObjectImpactDetectorPatch
	{
		[HarmonyPatch("Break")]
		[HarmonyPrefix]
		private static void Break(PhysGrabObjectImpactDetector __instance, ref float valueLost)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_00f9: 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_0100: Expected O, but got Unknown
			//IL_0106: Expected O, but got Unknown
			PhysGrabObject val = (PhysGrabObject)AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "physGrabObject").GetValue(__instance);
			List<PhysGrabber> playerGrabbing = val.playerGrabbing;
			if (playerGrabbing != null && playerGrabbing.Count > 0)
			{
				List<string> list = playerGrabbing.Select((PhysGrabber player) => SemiFunc.PlayerGetSteamID(player.playerAvatar)).ToList();
				IReadOnlyList<UpgradeItem> upgradeItemsByMod = MoreUpgradesLib.GetUpgradeItemsByMod("sandwich.itemResistUpgrade");
				if (upgradeItemsByMod.Count <= 0)
				{
					return;
				}
				int num = 0;
				foreach (string item in list)
				{
					num += upgradeItemsByMod[0].GetAmount(item);
				}
				valueLost = ReduceValueLost(valueLost, num);
				return;
			}
			PlayerAvatar val2 = (PlayerAvatar)AccessTools.Field(typeof(PhysGrabObject), "lastPlayerGrabbing").GetValue(val);
			PlayerAvatar val3 = val2;
			if ((Object)val2 != (Object)null)
			{
				string text = SemiFunc.PlayerGetSteamID(val3);
				IReadOnlyList<UpgradeItem> upgradeItemsByMod2 = MoreUpgradesLib.GetUpgradeItemsByMod("sandwich.itemResistUpgrade");
				int upgradeTotal = 0;
				if (upgradeItemsByMod2.Count > 0)
				{
					upgradeTotal = upgradeItemsByMod2[0].GetAmount(text);
				}
				valueLost = ReduceValueLost(valueLost, upgradeTotal);
			}
		}

		private static float ReduceValueLost(float valueLost, int upgradeTotal)
		{
			float num = (float)Math.Pow(Plugin.configPower.Value, upgradeTotal);
			return valueLost * num;
		}
	}
}

BeepInEx/plugins/VyrusGames-Puppet/PuppetEnemy/PuppetEnemy.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.AI;

[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Vyrus Games")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+c4fea7fe65d0249f99d561d5796c7aaf6ee415fa")]
[assembly: AssemblyProduct("PuppetEnemy")]
[assembly: AssemblyTitle("PuppetEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.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 PuppetEnemy
{
	[BepInPlugin("VyrusGames.PuppetEnemy", "PuppetEnemy", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class PuppetEnemy : BaseUnityPlugin
	{
		internal static PuppetEnemy Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//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)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Logger.LogInfo((object)"Patching PuppetEnemy...");
			Logger.LogInfo((object)"Loading assets...");
			LoadAssets();
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private static void LoadAssets()
		{
			AssetBundle val = LoadAssetBundle("puppet");
			Logger.LogInfo((object)"Loading Puppet enemy setup...");
			EnemySetup val2 = val.LoadAsset<EnemySetup>("Assets/REPO/Mods/plugins/PuppetEnemy/Enemy - Puppet.asset");
			Enemies.RegisterEnemy(val2);
			Logger.LogDebug((object)"Loaded Puppet enemy!");
		}

		public static AssetBundle LoadAssetBundle(string name)
		{
			Logger.LogDebug((object)("Loading Asset Bundle: " + name));
			AssetBundle val = null;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
			return AssetBundle.LoadFromFile(text);
		}
	}
}
namespace PuppetEnemy.AI
{
	public class EnemyPuppet : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Idle,
			Roam,
			Curious,
			Investigate,
			Leave,
			Stun
		}

		private Enemy _enemy;

		private PhotonView _photonView;

		private PlayerAvatar _targetPlayer;

		private bool _stateImpulse;

		private bool _deathImpulse;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Vector3 _agentDestination;

		private Vector3 _targetPosition;

		private bool _hurtImpulse;

		private float hurtLerp;

		private int _hurtAmount;

		private Material _hurtableMaterial;

		private float _pitCheckTimer;

		private bool _pitCheck;

		private float _talkTimer;

		private bool _talkImpulse;

		[Header("State")]
		[SerializeField]
		public State currentState;

		[SerializeField]
		public float stateTimer;

		[Header("Animation")]
		[SerializeField]
		private EnemyPuppetAnimationController animator;

		[SerializeField]
		private SkinnedMeshRenderer _renderer;

		[SerializeField]
		private AnimationCurve hurtCurve;

		[Header("Rotation and LookAt")]
		public SpringQuaternion horizontalRotationSpring;

		public SpringQuaternion headLookAtSpring;

		public Transform headLookAtTarget;

		public Transform headLookAtSource;

		private EnemyNavMeshAgent _navMeshAgent => EnemyUtil.GetEnemyNavMeshAgent(_enemy);

		private EnemyRigidbody _rigidbody => EnemyUtil.GetEnemyRigidbody(_enemy);

		private EnemyParent _enemyParent => EnemyUtil.GetEnemyParent(_enemy);

		private EnemyVision _vision => EnemyUtil.GetEnemyVision(_enemy);

		private EnemyStateInvestigate _investigate => EnemyUtil.GetEnemyStateInvestigate(_enemy);

		public Enemy Enemy => _enemy;

		public bool DeathImpulse
		{
			get
			{
				return _deathImpulse;
			}
			set
			{
				_deathImpulse = value;
			}
		}

		private void Awake()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			if ((Object)(object)_renderer != (Object)null)
			{
				_hurtableMaterial = ((Renderer)_renderer).sharedMaterial;
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
			Debug.Log((object)"THE CHUD HAS ARRIVED!!");
		}

		private void Update()
		{
			if ((GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.IsStunned())
			{
				if (_enemy.IsStunned())
				{
					UpdateState(State.Stun);
				}
				switch (currentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Idle:
					StateIdle();
					break;
				case State.Roam:
					StateRoam();
					break;
				case State.Curious:
					StateCurious();
					break;
				case State.Investigate:
					StateInvestigate();
					break;
				case State.Leave:
					StateLeave();
					break;
				case State.Stun:
					StateStun();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
				RotationLogic();
				TargetingLogic();
			}
			HurtEffect();
			if (_talkTimer > 0f)
			{
				_talkTimer -= Time.deltaTime;
			}
			else
			{
				_talkImpulse = true;
			}
		}

		private void LateUpdate()
		{
			HeadLookAtLogic();
		}

		private void UpdateState(State _newState)
		{
			if (currentState != _newState)
			{
				currentState = _newState;
				stateTimer = 0f;
				_stateImpulse = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
				}
				else
				{
					UpdateStateRPC(currentState);
				}
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			currentState = _state;
		}

		[PunRPC]
		private void UpdatePlayerTargetRPC(int viewID)
		{
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (item.photonView.ViewID == viewID)
				{
					_targetPlayer = item;
					break;
				}
			}
		}

		private void TargetingLogic()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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)
			if (currentState == State.Curious && Object.op_Implicit((Object)(object)_targetPlayer))
			{
				Vector3 val = ((Component)_targetPlayer).transform.position + ((Component)_targetPlayer).transform.forward * 1.5f;
				if (_pitCheckTimer <= 0f)
				{
					_pitCheckTimer = 0.1f;
					_pitCheck = !Physics.Raycast(val + Vector3.up, Vector3.down, 4f, LayerMask.GetMask(new string[1] { "Default" }));
				}
				else
				{
					_pitCheckTimer -= Time.deltaTime;
				}
				if (_pitCheck)
				{
					val = ((Component)_targetPlayer).transform.position;
				}
				_targetPosition = Vector3.Lerp(_targetPosition, val, 20f * Time.deltaTime);
			}
		}

		private void RotationLogic()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0014: 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_0034: 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_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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = EnemyUtil.GetAgentVelocity(_navMeshAgent);
			val = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref val)).magnitude > 0.1f)
			{
				val = EnemyUtil.GetAgentVelocity(_navMeshAgent);
				_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref val)).normalized);
				((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
			}
			if (currentState == State.Spawn || currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate || currentState == State.Leave)
			{
				horizontalRotationSpring.speed = 5f;
				horizontalRotationSpring.damping = 0.7f;
			}
			else
			{
				horizontalRotationSpring.speed = 10f;
				horizontalRotationSpring.damping = 0.8f;
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

		private void HeadLookAtLogic()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			if (currentState == State.Curious && !_enemy.IsStunned() && currentState != State.Stun && Object.op_Implicit((Object)(object)_targetPlayer) && !EnemyUtil.IsPlayerDisabled(_targetPlayer))
			{
				Vector3 val = _targetPlayer.PlayerVisionTarget.VisionTransform.position - headLookAtTarget.position;
				val = SemiFunc.ClampDirection(val, headLookAtTarget.forward, 60f);
				headLookAtSource.rotation = SemiFunc.SpringQuaternionGet(headLookAtSpring, Quaternion.LookRotation(val), -1f);
			}
			else
			{
				headLookAtSource.rotation = SemiFunc.SpringQuaternionGet(headLookAtSpring, headLookAtTarget.rotation, -1f);
			}
		}

		private void HurtEffect()
		{
			if (!_hurtImpulse)
			{
				return;
			}
			hurtLerp += 2.5f * Time.deltaTime;
			hurtLerp = Mathf.Clamp01(hurtLerp);
			if ((Object)(object)_hurtableMaterial != (Object)null)
			{
				_hurtableMaterial.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
			}
			if (hurtLerp > 1f)
			{
				_hurtImpulse = false;
				if ((Object)(object)_hurtableMaterial != (Object)null)
				{
					_hurtableMaterial.SetFloat(_hurtAmount, 0f);
				}
			}
		}

		private void StateSpawn()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
				_stateImpulse = false;
				stateTimer = 2f;
			}
			if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
			}
			else
			{
				UpdateState(State.Idle);
			}
		}

		private void StateIdle()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				stateTimer = Random.Range(4f, 8f);
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
			}
			if (!SemiFunc.EnemySpawnIdlePause())
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Roam);
				}
				if (SemiFunc.EnemyForceLeave(_enemy))
				{
					UpdateState(State.Leave);
				}
			}
		}

		private void StateRoam()
		{
			//IL_012e: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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)
			if (_stateImpulse)
			{
				bool flag = false;
				_talkTimer = Random.Range(5f, 15f);
				stateTimer = Random.Range(4f, 8f);
				LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 25f);
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((NavMeshHit)(ref val2)).position;
					flag = true;
				}
				if (!flag)
				{
					return;
				}
				EnemyUtil.SetNotMovingTimer(_rigidbody, 0f);
				_stateImpulse = false;
			}
			else
			{
				_navMeshAgent.SetDestination(_agentDestination);
				if (EnemyUtil.GetNotMovingTimer(_rigidbody) > 2f)
				{
					stateTimer -= Time.deltaTime;
				}
				if (stateTimer <= 0f)
				{
					UpdateState(State.Idle);
				}
			}
			if (SemiFunc.EnemyForceLeave(_enemy))
			{
				UpdateState(State.Leave);
			}
			if (_talkImpulse)
			{
				_talkImpulse = false;
				animator.PlayRoamSound();
				_talkTimer = Random.Range(15f, 20f);
			}
		}

		private void StateCurious()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				stateTimer = Random.Range(24f, 30f);
				_talkTimer = Random.Range(5f, 15f);
			}
			_navMeshAgent.SetDestination(_targetPosition);
			stateTimer -= Time.deltaTime;
			_vision.StandOverride(0.25f);
			if (stateTimer <= 0f || !Object.op_Implicit((Object)(object)_targetPlayer) || EnemyUtil.IsPlayerDisabled(_targetPlayer))
			{
				UpdateState(State.Idle);
				return;
			}
			if (_talkImpulse)
			{
				_talkImpulse = false;
				animator.PlayCuriousSound();
				_talkTimer = Random.Range(15f, 20f);
			}
			NavMeshHit val = default(NavMeshHit);
			if (_navMeshAgent.CanReach(_targetPosition, 1f) && Vector3.Distance(((Component)_rigidbody).transform.position, _navMeshAgent.GetPoint()) < 2f && !NavMesh.SamplePosition(_targetPosition, ref val, 0.5f, -1))
			{
				UpdateState(State.Roam);
			}
		}

		private void StateInvestigate()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				stateTimer = Random.Range(24f, 30f);
				_talkTimer = Random.Range(5f, 15f);
			}
			_navMeshAgent.SetDestination(_targetPosition);
			stateTimer -= Time.deltaTime;
			_vision.StandOverride(0.25f);
			if (stateTimer <= 0f)
			{
				UpdateState(State.Idle);
				return;
			}
			if (_talkImpulse)
			{
				_talkImpulse = false;
				animator.PlayVisionSound();
				_talkTimer = Random.Range(15f, 20f);
			}
			NavMeshHit val = default(NavMeshHit);
			if (_navMeshAgent.CanReach(_targetPosition, 1f) && Vector3.Distance(((Component)_rigidbody).transform.position, _navMeshAgent.GetPoint()) < 2f && !NavMesh.SamplePosition(_targetPosition, ref val, 0.5f, -1))
			{
				UpdateState(State.Roam);
			}
		}

		private void StateLeave()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_talkTimer = Random.Range(5f, 15f);
				stateTimer = 5f;
				bool flag = false;
				LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 30f, 50f, false);
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 1f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((NavMeshHit)(ref val2)).position;
					flag = true;
				}
				if (flag)
				{
					_enemy.NavMeshAgent.SetDestination(_agentDestination);
					EnemyUtil.SetNotMovingTimer(_rigidbody, 0f);
					_stateImpulse = false;
				}
			}
			else
			{
				if (EnemyUtil.GetNotMovingTimer(_rigidbody) > 2f)
				{
					stateTimer -= Time.deltaTime;
				}
				SemiFunc.EnemyCartJump(_enemy);
				if (Vector3.Distance(((Component)this).transform.position, _agentDestination) < 1f || stateTimer <= 0f)
				{
					SemiFunc.EnemyCartJumpReset(_enemy);
					UpdateState(State.Idle);
				}
			}
			if (_talkImpulse)
			{
				_talkImpulse = false;
				animator.PlayRoamSound();
				_talkTimer = Random.Range(15f, 20f);
			}
		}

		private void StateStun()
		{
			if (_stateImpulse)
			{
				_stateImpulse = false;
			}
			if (!_enemy.IsStunned())
			{
				UpdateState(State.Idle);
			}
		}

		public void OnSpawn()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(_enemy))
			{
				UpdateState(State.Spawn);
			}
		}

		public void OnInvestigate()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer() && (currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate))
			{
				_targetPosition = EnemyUtil.GetOnInvestigateTriggeredPosition(_investigate);
				UpdateState(State.Investigate);
			}
		}

		public void OnVision()
		{
			if ((currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate) && !_enemy.IsStunned() && SemiFunc.IsMasterClientOrSingleplayer())
			{
				_targetPlayer = EnemyUtil.GetVisionTriggeredPlayer(_vision);
				if (SemiFunc.IsMultiplayer())
				{
					_photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)0, new object[1] { _photonView.ViewID });
				}
				UpdateState(State.Curious);
				animator.PlayVisionSound();
			}
		}

		public void OnHurt()
		{
			_hurtImpulse = true;
			animator.PlayHurtSound();
		}

		public void OnDeath()
		{
			_deathImpulse = true;
			animator.PlayDeathSound();
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				_enemyParent.SpawnedTimerSet(0f);
			}
		}
	}
	public class EnemyPuppetAnimationController : MonoBehaviour
	{
		[Header("References")]
		public EnemyPuppet controller;

		public Animator animator;

		[Header("Particles")]
		public ParticleSystem[] deathParticles;

		[Header("Sounds")]
		[SerializeField]
		private Sound roamSounds;

		[SerializeField]
		private Sound visionSounds;

		[SerializeField]
		private Sound curiousSounds;

		[SerializeField]
		private Sound hurtSounds;

		[SerializeField]
		private Sound deathSound;

		private void Awake()
		{
			animator = ((Component)this).GetComponent<Animator>();
		}

		private void Update()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (controller.DeathImpulse)
			{
				controller.DeathImpulse = false;
				animator.SetTrigger("Dies");
			}
			if (!controller.Enemy.IsStunned())
			{
				Animator obj = animator;
				Vector3 agentVelocity = EnemyUtil.GetAgentVelocity(EnemyUtil.GetEnemyNavMeshAgent(controller.Enemy));
				obj.SetFloat("Walking", ((Vector3)(ref agentVelocity)).magnitude);
			}
		}

		public void SetDespawn()
		{
			EnemyUtil.GetEnemyParent(controller.Enemy).Despawn();
		}

		public void DeathParticlesImpulse()
		{
			ParticleSystem[] array = deathParticles;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Play();
			}
		}

		public void PlayRoamSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			roamSounds.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayVisionSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			visionSounds.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayCuriousSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			curiousSounds.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayHurtSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			hurtSounds.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayDeathSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			deathSound.Play(controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}
	}
	public class EnemyUtil
	{
		public static EnemyNavMeshAgent GetEnemyNavMeshAgent(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("NavMeshAgent", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyNavMeshAgent)field.GetValue(enemy);
			}
			Debug.LogError((object)"NavMeshAgent field not found!");
			return null;
		}

		public static EnemyRigidbody GetEnemyRigidbody(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("Rigidbody", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyRigidbody)field.GetValue(enemy);
			}
			Debug.LogError((object)"Rigidbody field not found!");
			return null;
		}

		public static EnemyParent GetEnemyParent(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("EnemyParent", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyParent)field.GetValue(enemy);
			}
			Debug.LogError((object)"EnemyParent field not found!");
			return null;
		}

		public static EnemyVision GetEnemyVision(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("Vision", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyVision)field.GetValue(enemy);
			}
			Debug.LogError((object)"Vision field not found!");
			return null;
		}

		public static EnemyStateInvestigate GetEnemyStateInvestigate(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("StateInvestigate", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyStateInvestigate)field.GetValue(enemy);
			}
			Debug.LogError((object)"StateInvestigate field not found!");
			return null;
		}

		public static bool IsEnemyJumping(Enemy enemy)
		{
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("Jump", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				Type fieldType = field.FieldType;
				FieldInfo field2 = fieldType.GetField("jumping", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field2 != null)
				{
					return (bool)field2.GetValue(field.GetValue(enemy));
				}
				Debug.LogError((object)"Jumping field not found!");
				return false;
			}
			Debug.LogError((object)"Jump field not found!");
			return false;
		}

		public static bool IsPlayerDisabled(PlayerAvatar playerTarget)
		{
			Type type = ((object)playerTarget).GetType();
			FieldInfo field = type.GetField("isDisabled", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (bool)field.GetValue(playerTarget);
			}
			Debug.LogError((object)"isDisabled field not found!");
			return false;
		}

		public static Vector3 GetAgentVelocity(EnemyNavMeshAgent agent)
		{
			//IL_003d: 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)
			//IL_0029: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			Type type = ((object)agent).GetType();
			FieldInfo field = type.GetField("AgentVelocity", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (Vector3)field.GetValue(agent);
			}
			Debug.LogError((object)"AgentVelocity field not found!");
			return Vector3.zero;
		}

		public static Vector3 GetOnInvestigateTriggeredPosition(EnemyStateInvestigate investigate)
		{
			//IL_003d: 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)
			//IL_0029: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			Type type = ((object)investigate).GetType();
			FieldInfo field = type.GetField("onInvestigateTriggeredPosition", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (Vector3)field.GetValue(investigate);
			}
			Debug.LogError((object)"onInvestigateTriggeredPosition field not found!");
			return Vector3.zero;
		}

		public static PlayerAvatar GetVisionTriggeredPlayer(EnemyVision vision)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)vision).GetType();
			FieldInfo field = type.GetField("onVisionTriggeredPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (PlayerAvatar)field.GetValue(vision);
			}
			Debug.LogError((object)"onVisionTriggeredPlayer field not found!");
			return null;
		}

		public static float GetNotMovingTimer(EnemyRigidbody rb)
		{
			Type type = ((object)rb).GetType();
			FieldInfo field = type.GetField("notMovingTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (float)field.GetValue(rb);
			}
			Debug.LogError((object)"NotMovingTimer field not found!");
			return 0f;
		}

		public static void SetNotMovingTimer(EnemyRigidbody rb, float value)
		{
			Type type = ((object)rb).GetType();
			FieldInfo field = type.GetField("notMovingTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(rb, value);
			}
			else
			{
				Debug.LogError((object)"NotMovingTimer field not found!");
			}
		}
	}
}

BeepInEx/plugins/YMC_MHZ-MoreHead/MoreHead/MoreHead.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using MenuLib.Structs;
using Microsoft.CodeAnalysis;
using MoreHead;
using Newtonsoft.Json;
using Photon.Pun;
using TMPro;
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 = "")]
[assembly: AssemblyCompany("YMC_MHZ")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyDescription("一个简单好玩的装饰模组,提供unitypackage,供玩家自行导入模型。")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0")]
[assembly: AssemblyProduct("MoreHead")]
[assembly: AssemblyTitle("MoreHead")]
[assembly: AssemblyVersion("1.3.0.0")]
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;
		}
	}
}
[BepInPlugin("Mhz.REPOMoreHead", "MoreHead", "1.3.0")]
public class Morehead : BaseUnityPlugin
{
	private const string PluginGuid = "Mhz.REPOMoreHead";

	private const string PluginName = "MoreHead";

	private const string PluginVersion = "1.3.0";

	public static ManualLogSource? Logger;

	public static Morehead? Instance { get; private set; }

	public static string GetPluginVersion()
	{
		return "1.3.0";
	}

	private void Awake()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		Instance = this;
		Logger = ((BaseUnityPlugin)this).Logger;
		try
		{
			Harmony val = new Harmony("Mhz.REPOMoreHead");
			val.PatchAll(typeof(PlayerAvatarVisualsPatch));
			val.PatchAll(typeof(PlayerUpdatePatch));
			val.PatchAll(typeof(PlayerAvatarAwakePatch));
			val.PatchAll(typeof(GameDirectorUpdatePatch));
			val.PatchAll(typeof(PlayerRevivePatch));
			val.PatchAll(typeof(MenuManagerStartPatch));
			string text = "\n\n ███▄ ▄███▓ ▒█████   ██▀███  ▓█████  ██░ ██ ▓█████ ▄▄▄      ▓█████▄ \n▓██▒▀█▀ ██▒▒██▒  ██▒▓██ ▒ ██▒▓█   ▀ ▓██░ ██▒▓█   ▀▒████▄    ▒██▀ ██▌\n▓██    ▓██░▒██░  ██▒▓██ ░▄█ ▒▒███   ▒██▀███░▒███  ▒██  ▀█▄  ░██   █▌\n▒██    ▒██ ▒██   ██░▒███▀█▄  ▒▓█  ▄ ░▓█ ░██ ▒▓█  ▄░██▄▄▄▄██ ░▓█▄   ▌\n▒██▒   ░██▒░ ████▓▒░░██▓ ▒██▒░▒████▒░▓█▒░██▓░▒████▒▓█   ▓██▒░▒████▓   v1.3.0\n░ ▒░   ░  ░░ ▒░▒░▒░ ░ ▒▓ ░▒▓░░░ ▒░ ░ ▒ ░░▒░▒░░ ▒░ ░▒▒   ▓▒█░ ▒▒▓  ▒ \n░  ░      ░  ░ ▒ ▒░   ░▒ ░ ▒░ ░ ░  ░ ▒ ░▒░ ░ ░ ░  ░ ▒   ▒▒ ░ ░ ▒  ▒ \n░      ░   ░ ░ ░ ▒    ░░   ░    ░    ░  ░░ ░   ░    ░   ▒    ░ ░  ░ \n       ░       ░ ░     ░        ░  ░ ░  ░  ░   ░  ░     ░  ░   ░    \n";
			ManualLogSource? logger = Logger;
			if (logger != null)
			{
				logger.LogMessage((object)text);
			}
			HeadDecorationManager.Initialize();
			ConfigManager.Initialize();
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("Harmony补丁应用失败: " + ex.Message));
			}
		}
	}

	private void OnApplicationQuit()
	{
		ConfigManager.SaveConfig();
	}

	public static bool GetDecorationState(string? name)
	{
		return HeadDecorationManager.GetDecorationState(name);
	}
}
[HarmonyPatch(typeof(MenuManager))]
[HarmonyPatch("Start")]
internal class MenuManagerStartPatch
{
	[HarmonyPostfix]
	private static void Postfix()
	{
		try
		{
			if ((Object)(object)MenuManager.instance != (Object)null && MenuManager.instance.menuPages != null && MenuManager.instance.menuPages.Count > 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"MenuManager已初始化,正在初始化MoreHeadUI...");
				}
				MoreHeadUI.Initialize();
			}
			else
			{
				ManualLogSource? logger2 = Morehead.Logger;
				if (logger2 != null)
				{
					logger2.LogWarning((object)"MenuManager未准备好,无法初始化UI");
				}
			}
		}
		catch (Exception arg)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)$"在MenuManager.Start补丁中初始化UI时出错: {arg}");
			}
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("Update")]
internal class PlayerUpdatePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		if (__instance.photonView.IsMine && GameManager.Multiplayer() && PhotonNetwork.LocalPlayer != null)
		{
		}
	}

	public static void UpdatePlayerDecorations(PlayerAvatar playerAvatar)
	{
		try
		{
			if ((Object)(object)playerAvatar?.playerAvatarVisuals == (Object)null)
			{
				return;
			}
			Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)playerAvatar.playerAvatarVisuals).transform);
			if (decorationParentNodes.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何装饰物父级节点");
				}
				return;
			}
			DecorationUtils.EnsureDecorationContainers(decorationParentNodes);
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (decorationParentNodes.TryGetValue(decoration.ParentTag ?? string.Empty, out var value))
				{
					Transform val = value.Find("HeadDecorations");
					if ((Object)(object)val != (Object)null)
					{
						DecorationUtils.UpdateDecoration(val, decoration.Name ?? string.Empty, decoration.IsVisible);
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("找不到装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("更新玩家装饰物时出错: " + ex.Message));
			}
		}
	}

	public static void UpdateMenuPlayerDecorations()
	{
		try
		{
			PlayerAvatarVisuals val = FindMenuPlayerVisuals();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)val).transform);
			if (decorationParentNodes.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到任何菜单角色装饰物父级节点");
				}
				return;
			}
			DecorationUtils.EnsureDecorationContainers(decorationParentNodes);
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				if (decorationParentNodes.TryGetValue(decoration.ParentTag ?? string.Empty, out var value))
				{
					Transform val2 = value.Find("HeadDecorations");
					if ((Object)(object)val2 != (Object)null)
					{
						Transform val3 = val2.Find(decoration.Name);
						if ((Object)(object)val3 == (Object)null)
						{
							AddMenuDecoration(val2, decoration.Name);
						}
						else
						{
							DecorationUtils.UpdateDecoration(val2, decoration.Name ?? string.Empty, decoration.IsVisible);
						}
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("找不到菜单角色装饰物 " + decoration.DisplayName + " 的父级节点: " + decoration.ParentTag));
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("更新菜单角色装饰物状态失败: " + ex.Message));
			}
		}
	}

	private static PlayerAvatarVisuals? FindMenuPlayerVisuals()
	{
		if ((Object)(object)PlayerAvatarMenu.instance == (Object)null)
		{
			return null;
		}
		return ((Component)PlayerAvatarMenu.instance).GetComponentInChildren<PlayerAvatarVisuals>();
	}

	public static void AddMenuDecoration(Transform parent, string? decorationName)
	{
		string decorationName2 = decorationName;
		try
		{
			Transform val = parent.Find(decorationName2);
			if ((Object)(object)val != (Object)null)
			{
				bool decorationState = Morehead.GetDecorationState(decorationName2);
				((Component)val).gameObject.SetActive(decorationState);
				return;
			}
			DecorationInfo decorationInfo = HeadDecorationManager.Decorations.Find((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null && (Object)(object)decorationInfo.Prefab != (Object)null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(decorationInfo.Prefab, parent);
				((Object)val2).name = decorationName2;
				val2.SetActive(decorationInfo.IsVisible);
				return;
			}
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogWarning((object)("AddMenuDecoration: 找不到装饰物 " + decorationName2 + " 或其预制体为空"));
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)("为菜单角色添加装饰物时出错: " + ex.Message));
			}
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("Awake")]
internal class PlayerAvatarAwakePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		((Component)__instance).gameObject.AddComponent<HeadDecorationSync>();
	}
}
public class HeadDecorationSync : MonoBehaviourPun
{
	public void SyncAllDecorations()
	{
		try
		{
			string[] array = new string[HeadDecorationManager.Decorations.Count];
			bool[] array2 = new bool[HeadDecorationManager.Decorations.Count];
			string[] array3 = new string[HeadDecorationManager.Decorations.Count];
			for (int i = 0; i < HeadDecorationManager.Decorations.Count; i++)
			{
				DecorationInfo decorationInfo = HeadDecorationManager.Decorations[i];
				array[i] = decorationInfo.Name;
				array2[i] = decorationInfo.IsVisible;
				array3[i] = decorationInfo.ParentTag;
			}
			((MonoBehaviourPun)this).photonView.RPC("UpdateAllDecorations", (RpcTarget)1, new object[3] { array, array2, array3 });
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("同步所有装饰物状态失败: " + ex.Message));
			}
		}
	}

	[PunRPC]
	private void UpdateAllDecorations(string[] names, bool[] states, string[] parentTags)
	{
		try
		{
			PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.playerAvatarVisuals == (Object)null)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"找不到PlayerAvatar或PlayerAvatarVisuals组件");
				}
				return;
			}
			Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)component.playerAvatarVisuals).transform);
			if (decorationParentNodes.Count == 0)
			{
				ManualLogSource? logger2 = Morehead.Logger;
				if (logger2 != null)
				{
					logger2.LogWarning((object)"找不到任何装饰物父级节点");
				}
				return;
			}
			DecorationUtils.EnsureDecorationContainers(decorationParentNodes);
			for (int i = 0; i < names.Length; i++)
			{
				string decorationName = names[i];
				bool showDecoration = states[i];
				string key = parentTags[i];
				if (decorationParentNodes.TryGetValue(key, out var value))
				{
					Transform val = value.Find("HeadDecorations");
					if ((Object)(object)val != (Object)null)
					{
						DecorationUtils.UpdateDecoration(val, decorationName, showDecoration);
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("RPC更新所有装饰物状态失败: " + ex.Message));
			}
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals))]
[HarmonyPatch("Start")]
internal class PlayerAvatarVisualsPatch
{
	private static void Postfix(PlayerAvatarVisuals __instance)
	{
		try
		{
			Dictionary<string, Transform> decorationParentNodes = DecorationUtils.GetDecorationParentNodes(((Component)__instance).transform);
			if (decorationParentNodes.Count == 0)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)$"找不到任何装饰物父级节点 (isMenuAvatar: {__instance.isMenuAvatar})");
				}
				return;
			}
			DecorationUtils.EnsureDecorationContainers(decorationParentNodes);
			if (__instance.isMenuAvatar)
			{
				foreach (KeyValuePair<string, Transform> item in decorationParentNodes)
				{
					string key = item.Key;
					Transform value = item.Value;
					Transform val = value.Find("HeadDecorations");
					if ((Object)(object)val != (Object)null)
					{
						foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
						{
							if (decoration.ParentTag == key)
							{
								PlayerUpdatePatch.AddMenuDecoration(val, decoration.Name);
							}
						}
					}
				}
				return;
			}
			foreach (DecorationInfo decoration2 in HeadDecorationManager.Decorations)
			{
				if (decorationParentNodes.TryGetValue(decoration2.ParentTag ?? string.Empty, out var value2))
				{
					Transform val2 = value2.Find("HeadDecorations");
					if ((Object)(object)val2 != (Object)null)
					{
						AddNewDecoration(val2, decoration2, __instance);
					}
				}
				else
				{
					ManualLogSource? logger2 = Morehead.Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)("初始化时找不到装饰物 " + decoration2.DisplayName + " 的父级节点: " + decoration2.ParentTag));
					}
				}
			}
			if (!GameManager.Multiplayer() || !((Object)(object)__instance.playerAvatar != (Object)null) || !((Object)(object)__instance.playerAvatar.photonView != (Object)null) || !__instance.playerAvatar.photonView.IsMine)
			{
				return;
			}
			try
			{
				HeadDecorationSync component = ((Component)__instance.playerAvatar).GetComponent<HeadDecorationSync>();
				if ((Object)(object)component != (Object)null)
				{
					component.SyncAllDecorations();
					return;
				}
				ManualLogSource? logger3 = Morehead.Logger;
				if (logger3 != null)
				{
					logger3.LogWarning((object)"找不到HeadDecorationSync组件,无法同步初始状态");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger4 = Morehead.Logger;
				if (logger4 != null)
				{
					logger4.LogError((object)("同步初始装饰物状态失败: " + ex.Message));
				}
			}
		}
		catch (Exception ex2)
		{
			ManualLogSource? logger5 = Morehead.Logger;
			if (logger5 != null)
			{
				logger5.LogError((object)$"添加装饰物失败: {ex2.Message} (isMenuAvatar: {__instance.isMenuAvatar})");
			}
		}
	}

	private static void AddNewDecoration(Transform parent, DecorationInfo decoration, PlayerAvatarVisuals __instance)
	{
		Transform val = parent.Find(decoration.Name);
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(decoration.IsVisible);
			return;
		}
		if ((Object)(object)decoration.Prefab != (Object)null)
		{
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(decoration.Prefab, parent);
				((Object)val2).name = decoration.Name;
				val2.SetActive(decoration.IsVisible);
				return;
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Morehead.Logger;
				if (logger != null)
				{
					logger.LogError((object)("实例化预制体时出错: " + ex.Message));
				}
				return;
			}
		}
		ManualLogSource? logger2 = Morehead.Logger;
		if (logger2 != null)
		{
			logger2.LogWarning((object)("AddNewDecoration: 装饰物 " + decoration.DisplayName + " 的预制体为空"));
		}
	}
}
[HarmonyPatch(typeof(GameDirector))]
[HarmonyPatch("Update")]
internal class GameDirectorUpdatePatch
{
	private static gameState previousState;

	private static void Postfix(GameDirector __instance)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Invalid comparison between Unknown and I4
		//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)
		try
		{
			if ((int)previousState != 2 && (int)__instance.currentState == 2)
			{
				SyncAllPlayersDecorations();
			}
			previousState = __instance.currentState;
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("监听游戏状态变化时出错: " + ex.Message));
			}
		}
	}

	private static void SyncAllPlayersDecorations()
	{
		try
		{
			PlayerAvatar val = FindLocalPlayer();
			if ((Object)(object)val != (Object)null)
			{
				PlayerUpdatePatch.UpdatePlayerDecorations(val);
				HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>();
				if ((Object)(object)component != (Object)null)
				{
					component.SyncAllDecorations();
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("同步所有玩家装饰物状态时出错: " + ex.Message));
			}
		}
	}

	private static PlayerAvatar? FindLocalPlayer()
	{
		try
		{
			PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
			PlayerAvatar[] array2 = array;
			foreach (PlayerAvatar val in array2)
			{
				if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine)
				{
					return val;
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("查找本地玩家时出错: " + ex.Message));
			}
		}
		return null;
	}
}
[HarmonyPatch(typeof(PlayerAvatar))]
[HarmonyPatch("ReviveRPC")]
internal class PlayerRevivePatch
{
	private static void Postfix(PlayerAvatar __instance)
	{
		try
		{
			if (__instance.photonView.IsMine)
			{
				((MonoBehaviour)__instance).StartCoroutine(DelayedSync(__instance));
			}
		}
		catch (Exception ex)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("玩家复活时同步装饰物状态失败: " + ex.Message));
			}
		}
	}

	private static IEnumerator DelayedSync(PlayerAvatar playerAvatar)
	{
		yield return null;
		yield return (object)new WaitForSeconds(0.2f);
		try
		{
			PlayerUpdatePatch.UpdatePlayerDecorations(playerAvatar);
		}
		catch (Exception e2)
		{
			ManualLogSource? logger = Morehead.Logger;
			if (logger != null)
			{
				logger.LogError((object)("更新玩家装饰物状态失败: " + e2.Message));
			}
		}
		yield return (object)new WaitForSeconds(0.1f);
		try
		{
			HeadDecorationSync syncComponent = ((Component)playerAvatar).GetComponent<HeadDecorationSync>();
			if ((Object)(object)syncComponent != (Object)null)
			{
				syncComponent.SyncAllDecorations();
				yield break;
			}
			ManualLogSource? logger2 = Morehead.Logger;
			if (logger2 != null)
			{
				logger2.LogWarning((object)"玩家复活后找不到HeadDecorationSync组件");
			}
		}
		catch (Exception e)
		{
			ManualLogSource? logger3 = Morehead.Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("同步装饰物状态失败: " + e.Message));
			}
		}
	}
}
namespace MoreHead
{
	public static class ConfigManager
	{
		private const string MOD_DATA_FOLDER = "REPOModData";

		private const string MOD_FOLDER = "MoreHead";

		private const string CONFIG_FILENAME = "MoreHeadConfig.json";

		private static Dictionary<string?, bool> _decorationStates = new Dictionary<string, bool>();

		private static ManualLogSource? Logger => Morehead.Logger;

		private static string NewConfigFilePath => Path.Combine(Application.persistentDataPath, "REPOModData", "MoreHead", "MoreHeadConfig.json");

		private static string BepInExConfigFilePath => Path.Combine(Paths.ConfigPath, "MoreHeadConfig.json");

		private static string OldConfigFilePath
		{
			get
			{
				Morehead? instance = Morehead.Instance;
				return Path.Combine(Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null) ?? string.Empty, "MoreHeadConfig.txt");
			}
		}

		public static void Initialize()
		{
			try
			{
				EnsureModDataDirectoryExists();
				LoadConfig();
				ApplySavedStates();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("初始化配置管理器时出错: " + ex.Message));
				}
			}
		}

		private static void EnsureModDataDirectoryExists()
		{
			try
			{
				string text = Path.Combine(Application.persistentDataPath, "REPOModData");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)("已创建MOD数据总文件夹: " + text));
					}
				}
				string text2 = Path.Combine(text, "MoreHead");
				if (!Directory.Exists(text2))
				{
					Directory.CreateDirectory(text2);
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogInfo((object)("已创建MOD特定文件夹: " + text2));
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("创建MOD数据目录时出错: " + ex.Message));
				}
			}
		}

		private static void LoadConfig()
		{
			try
			{
				_decorationStates.Clear();
				if (File.Exists(NewConfigFilePath) && LoadJsonConfig(NewConfigFilePath))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)("已从Unity存档位置加载配置: " + NewConfigFilePath));
					}
					return;
				}
				if (File.Exists(BepInExConfigFilePath) && LoadJsonConfig(BepInExConfigFilePath))
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogInfo((object)("已从BepInEx配置目录加载配置: " + BepInExConfigFilePath));
					}
					SaveConfigWithoutUpdate();
					ManualLogSource? logger3 = Logger;
					if (logger3 != null)
					{
						logger3.LogInfo((object)("已将配置从BepInEx目录迁移到Unity存档位置: " + NewConfigFilePath));
					}
					try
					{
						File.Delete(BepInExConfigFilePath);
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogInfo((object)("已删除BepInEx配置文件: " + BepInExConfigFilePath));
						}
						return;
					}
					catch (Exception ex)
					{
						ManualLogSource? logger5 = Logger;
						if (logger5 != null)
						{
							logger5.LogWarning((object)("删除BepInEx配置文件失败: " + ex.Message));
						}
						return;
					}
				}
				if (!File.Exists(OldConfigFilePath))
				{
					return;
				}
				try
				{
					string[] array = File.ReadAllLines(OldConfigFilePath);
					string[] array2 = array;
					foreach (string text in array2)
					{
						if (!string.IsNullOrWhiteSpace(text))
						{
							string[] array3 = text.Split('=');
							if (array3.Length == 2)
							{
								string key = array3[0].Trim();
								bool value = array3[1].Trim().Equals("1", StringComparison.OrdinalIgnoreCase);
								_decorationStates[key] = value;
							}
						}
					}
					if (_decorationStates.Count <= 0)
					{
						return;
					}
					ManualLogSource? logger6 = Logger;
					if (logger6 != null)
					{
						logger6.LogInfo((object)$"已从旧文本格式加载配置,包含 {_decorationStates.Count} 个装饰物状态");
					}
					SaveConfigWithoutUpdate();
					ManualLogSource? logger7 = Logger;
					if (logger7 != null)
					{
						logger7.LogInfo((object)("已将旧文本格式配置迁移到新的JSON格式: " + NewConfigFilePath));
					}
					try
					{
						File.Delete(OldConfigFilePath);
						ManualLogSource? logger8 = Logger;
						if (logger8 != null)
						{
							logger8.LogInfo((object)("已删除旧文本配置文件: " + OldConfigFilePath));
						}
					}
					catch (Exception ex2)
					{
						ManualLogSource? logger9 = Logger;
						if (logger9 != null)
						{
							logger9.LogWarning((object)("删除旧文本配置文件失败: " + ex2.Message));
						}
					}
				}
				catch (Exception ex3)
				{
					ManualLogSource? logger10 = Logger;
					if (logger10 != null)
					{
						logger10.LogError((object)("从旧文本格式加载配置时出错: " + ex3.Message));
					}
				}
			}
			catch (Exception ex4)
			{
				ManualLogSource? logger11 = Logger;
				if (logger11 != null)
				{
					logger11.LogError((object)("加载配置时出错: " + ex4.Message));
				}
				_decorationStates.Clear();
			}
		}

		private static bool LoadJsonConfig(string filePath)
		{
			//IL_0095: Expected O, but got Unknown
			try
			{
				string text = File.ReadAllText(filePath);
				Dictionary<string, bool> dictionary = JsonConvert.DeserializeObject<Dictionary<string, bool>>(text);
				if (dictionary != null)
				{
					foreach (KeyValuePair<string, bool> item in dictionary)
					{
						_decorationStates[item.Key] = item.Value;
					}
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)$"已从JSON加载配置,包含 {_decorationStates.Count} 个装饰物状态");
					}
					return true;
				}
			}
			catch (JsonException val)
			{
				JsonException val2 = val;
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("解析JSON配置文件时出错: " + ((Exception)(object)val2).Message));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("加载JSON配置文件时出错: " + ex.Message));
				}
			}
			return false;
		}

		public static void SaveConfig()
		{
			try
			{
				UpdateConfigData();
				SaveToFile();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("保存配置时出错: " + ex.Message));
				}
			}
		}

		private static void SaveConfigWithoutUpdate()
		{
			try
			{
				SaveToFile();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("保存配置时出错: " + ex.Message));
				}
			}
		}

		private static void SaveToFile()
		{
			try
			{
				EnsureModDataDirectoryExists();
				string contents = JsonConvert.SerializeObject((object)_decorationStates, (Formatting)1);
				File.WriteAllText(NewConfigFilePath, contents);
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("写入配置文件时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateConfigData()
		{
			_decorationStates.Clear();
			foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
			{
				_decorationStates[decoration.Name] = decoration.IsVisible;
			}
		}

		public static void ApplySavedStates()
		{
			try
			{
				int num = 0;
				foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
				{
					if (_decorationStates.TryGetValue(decoration.Name, out var value))
					{
						decoration.IsVisible = value;
						num++;
					}
				}
				if (num > 0)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogInfo((object)$"已应用 {num} 个已保存的装饰物状态");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("应用已保存的装饰物状态时出错: " + ex.Message));
				}
			}
		}
	}
	public static class DecorationUtils
	{
		private const string HEAD_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top";

		private const string NECK_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side";

		private const string BODY_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/ANIM BODY TOP SCALE";

		private const string HIP_NODE_PATH = "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT";

		public static Dictionary<string, Transform> GetDecorationParentNodes(Transform rootTransform)
		{
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform val = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top");
			if ((Object)(object)val != (Object)null)
			{
				dictionary["head"] = val;
			}
			Transform val2 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side");
			if ((Object)(object)val2 != (Object)null)
			{
				dictionary["neck"] = val2;
			}
			Transform val3 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/ANIM BODY TOP SCALE");
			if ((Object)(object)val3 != (Object)null)
			{
				dictionary["body"] = val3;
			}
			Transform val4 = rootTransform.Find("[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT");
			if ((Object)(object)val4 != (Object)null)
			{
				dictionary["hip"] = val4;
			}
			if ((Object)(object)rootTransform != (Object)null)
			{
				bool flag = false;
				PlayerAvatar componentInChildren = ((Component)rootTransform.parent).GetComponentInChildren<PlayerAvatar>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					flag = !SemiFunc.IsMultiplayer() || ((Object)(object)componentInChildren.photonView != (Object)null && componentInChildren.photonView.IsMine);
				}
				Transform val5 = rootTransform.Find("WorldDecorationFollower");
				if ((Object)(object)val5 != (Object)null)
				{
					if (flag)
					{
						((Component)val5).gameObject.SetActive(false);
					}
					else
					{
						((Component)val5).gameObject.SetActive(true);
					}
					dictionary["world"] = val5;
				}
				else
				{
					GameObject val6 = new GameObject("WorldDecorationFollower");
					val6.transform.SetParent(rootTransform, false);
					val6.transform.localPosition = Vector3.zero;
					val6.transform.localRotation = Quaternion.identity;
					val6.transform.localScale = Vector3.one;
					val6.AddComponent<WorldSpaceFollower>();
					if (flag)
					{
						val6.SetActive(false);
					}
					else
					{
						val6.SetActive(true);
					}
					dictionary["world"] = val6.transform;
				}
			}
			return dictionary;
		}

		public static void EnsureDecorationContainers(Dictionary<string, Transform> parentNodes)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<string, Transform> parentNode in parentNodes)
			{
				Transform value = parentNode.Value;
				Transform val = value.Find("HeadDecorations");
				if ((Object)(object)val == (Object)null)
				{
					val = new GameObject("HeadDecorations").transform;
					val.SetParent(value, false);
					val.localPosition = Vector3.zero;
					val.localRotation = Quaternion.identity;
					val.localScale = Vector3.one;
				}
			}
		}

		public static void UpdateDecoration(Transform parent, string decorationName, bool showDecoration)
		{
			Transform val = parent.Find(decorationName);
			if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf != showDecoration)
			{
				((Component)val).gameObject.SetActive(showDecoration);
			}
		}
	}
	public class WorldSpaceFollower : MonoBehaviour
	{
		private Transform? _rootTransform;

		private Vector3 _initialOffset;

		private void Start()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			_rootTransform = ((Component)this).transform.parent;
			if ((Object)(object)_rootTransform != (Object)null)
			{
				_initialOffset = ((Component)this).transform.position - _rootTransform.position;
				((Component)this).transform.rotation = Quaternion.identity;
				((Component)this).transform.localScale = Vector3.one;
			}
		}

		private void LateUpdate()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_rootTransform != (Object)null)
			{
				((Component)this).transform.position = _rootTransform.position + _initialOffset;
				((Component)this).transform.rotation = Quaternion.Euler(0f, _rootTransform.eulerAngles.y, 0f);
				((Component)this).transform.localScale = Vector3.one;
			}
		}
	}
	public class DecorationInfo
	{
		public string? Name { get; set; }

		public string? DisplayName { get; set; }

		public bool IsVisible { get; set; }

		public GameObject? Prefab { get; set; }

		public string? ParentTag { get; set; }

		public string? BundlePath { get; set; }
	}
	public static class HeadDecorationManager
	{
		private static Dictionary<string?, string> parentPathMap = new Dictionary<string, string>
		{
			{ "head", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side/_____________________________________/ANIM HEAD TOP/code_head_top" },
			{ "neck", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/_____________________________________/ANIM HEAD BOT/code_head_bot_up/code_head_bot_side" },
			{ "body", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT/_____________________________________/ANIM BODY TOP/code_body_top_up/code_body_top_side/ANIM BODY TOP SCALE" },
			{ "hip", "[RIG]/code_lean/code_tilt/ANIM BOT/_____________________________________/ANIM BODY BOT" },
			{ "world", "" }
		};

		private static Dictionary<string, List<DecorationInfo>> externalDecorations = new Dictionary<string, List<DecorationInfo>>();

		private static ManualLogSource? Logger => Morehead.Logger;

		public static List<DecorationInfo> Decorations { get; private set; } = new List<DecorationInfo>();


		public static void Initialize()
		{
			try
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"正在初始化装饰物管理器...");
				}
				Decorations.Clear();
				LoadAllDecorations();
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)$"装饰物管理器初始化完成,共加载了 {Decorations.Count} 个装饰物");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogError((object)("初始化装饰物管理器时出错: " + ex.Message));
				}
			}
		}

		private static void LoadAllDecorations()
		{
			try
			{
				Morehead? instance = Morehead.Instance;
				string directoryName = Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null);
				if (string.IsNullOrEmpty(directoryName))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogError((object)"无法获取MOD所在目录");
					}
					return;
				}
				string text = Path.Combine(directoryName, "Decorations");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogInfo((object)("已创建装饰物目录: " + text));
					}
				}
				List<string> list = new List<string>();
				string[] files = Directory.GetFiles(text, "*.hhh");
				list.AddRange(files);
				try
				{
					string pluginPath = Paths.PluginPath;
					if (!string.IsNullOrEmpty(pluginPath) && Directory.Exists(pluginPath))
					{
						string[] files2 = Directory.GetFiles(pluginPath, "*.hhh", SearchOption.AllDirectories);
						list.AddRange(files2);
						ManualLogSource? logger3 = Logger;
						if (logger3 != null)
						{
							logger3.LogInfo((object)$"在plugins目录中找到 {files2.Length} 个.hhh文件");
						}
					}
					else
					{
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogWarning((object)"无法找到BepInEx/plugins目录,将只加载本地装饰物");
						}
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger5 = Logger;
					if (logger5 != null)
					{
						logger5.LogError((object)("搜索plugins目录时出错: " + ex.Message));
					}
				}
				list = list.Distinct().ToList();
				if (list.Count == 0)
				{
					ManualLogSource? logger6 = Logger;
					if (logger6 != null)
					{
						logger6.LogWarning((object)"未找到任何装饰物包文件,请确保.hhh文件已放置");
					}
				}
				else
				{
					ManualLogSource? logger7 = Logger;
					if (logger7 != null)
					{
						logger7.LogInfo((object)$"找到 {list.Count} 个装饰物包文件");
					}
					if (files.Length != 0)
					{
						ManualLogSource? logger8 = Logger;
						if (logger8 != null)
						{
							logger8.LogInfo((object)$"- Decorations目录: {files.Length} 个文件");
						}
					}
				}
				foreach (string item in list)
				{
					LoadDecorationBundle(item);
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource? logger9 = Logger;
				if (logger9 != null)
				{
					logger9.LogError((object)("加载装饰物时出错: " + ex2.Message));
				}
			}
		}

		private static void LoadDecorationBundle(string bundlePath)
		{
			AssetBundle val = null;
			try
			{
				if (!File.Exists(bundlePath))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("文件不存在: " + bundlePath));
					}
					return;
				}
				FileInfo fileInfo = new FileInfo(bundlePath);
				if (fileInfo.Length < 1024)
				{
					ManualLogSource? logger2 = Logger;
					if (logger2 != null)
					{
						logger2.LogWarning((object)$"文件过小,可能不是有效的AssetBundle: {bundlePath}, 大小: {fileInfo.Length} 字节");
					}
					return;
				}
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(bundlePath);
				string parentTag = "head";
				string text = fileNameWithoutExtension;
				if (fileNameWithoutExtension.Contains("_"))
				{
					string[] array = fileNameWithoutExtension.Split('_');
					if (array.Length >= 2)
					{
						string text2 = array[^1].ToLower();
						if (parentPathMap.ContainsKey(text2))
						{
							parentTag = text2;
							text = string.Join("_", array, 0, array.Length - 1);
						}
					}
				}
				string text3 = EnsureUniqueName(text);
				if (text3 != text)
				{
					ManualLogSource? logger3 = Logger;
					if (logger3 != null)
					{
						logger3.LogWarning((object)("检测到重名,将基础名称从 " + text + " 修改为 " + text3));
					}
					text = text3;
				}
				try
				{
					val = AssetBundle.LoadFromFile(bundlePath);
					if ((Object)(object)val == (Object)null)
					{
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogError((object)("无法加载AssetBundle,文件可能已损坏或不是有效的AssetBundle: " + bundlePath));
						}
						return;
					}
				}
				catch (Exception ex)
				{
					ManualLogSource? logger5 = Logger;
					if (logger5 != null)
					{
						logger5.LogError((object)("加载AssetBundle时出错,文件可能不是有效的AssetBundle: " + bundlePath + ", 错误: " + ex.Message));
					}
					return;
				}
				try
				{
					string[] allAssetNames;
					try
					{
						allAssetNames = val.GetAllAssetNames();
					}
					catch (Exception ex2)
					{
						ManualLogSource? logger6 = Logger;
						if (logger6 != null)
						{
							logger6.LogError((object)("获取AssetBundle资源名称时出错: " + bundlePath + ", 错误: " + ex2.Message));
						}
						val.Unload(true);
						return;
					}
					if (allAssetNames.Length == 0)
					{
						ManualLogSource? logger7 = Logger;
						if (logger7 != null)
						{
							logger7.LogWarning((object)("AssetBundle不包含任何资源: " + bundlePath));
						}
						val.Unload(true);
						return;
					}
					bool flag = false;
					GameObject val2 = null;
					string[] array2 = allAssetNames;
					foreach (string text4 in array2)
					{
						try
						{
							val2 = val.LoadAsset<GameObject>(text4);
							if ((Object)(object)val2 != (Object)null)
							{
								flag = true;
								break;
							}
						}
						catch (Exception ex3)
						{
							ManualLogSource? logger8 = Logger;
							if (logger8 != null)
							{
								logger8.LogWarning((object)("加载资源 " + text4 + " 时出错: " + ex3.Message));
							}
						}
					}
					if (!flag || (Object)(object)val2 == (Object)null)
					{
						ManualLogSource? logger9 = Logger;
						if (logger9 != null)
						{
							logger9.LogWarning((object)("AssetBundle不包含有效的GameObject资源: " + bundlePath));
						}
						val.Unload(true);
						return;
					}
					string text5 = ((Object)val2).name;
					string text6 = EnsureUniqueDisplayName(text5);
					if (text6 != text5)
					{
						ManualLogSource? logger10 = Logger;
						if (logger10 != null)
						{
							logger10.LogWarning((object)("检测到显示名称重复,将显示名称从 " + text5 + " 修改为 " + text6));
						}
						text5 = text6;
					}
					DecorationInfo decorationInfo = new DecorationInfo
					{
						Name = text,
						DisplayName = text5,
						IsVisible = false,
						Prefab = val2,
						ParentTag = parentTag,
						BundlePath = bundlePath
					};
					Decorations.Add(decorationInfo);
					ManualLogSource? logger11 = Logger;
					if (logger11 != null)
					{
						logger11.LogInfo((object)("成功加载装饰物: " + decorationInfo.DisplayName + ", 标签: " + decorationInfo.ParentTag));
					}
					val.Unload(false);
				}
				catch (Exception ex4)
				{
					ManualLogSource? logger12 = Logger;
					if (logger12 != null)
					{
						logger12.LogError((object)("处理AssetBundle时出错: " + ex4.Message));
					}
					if ((Object)(object)val != (Object)null)
					{
						val.Unload(true);
					}
				}
			}
			catch (Exception ex5)
			{
				ManualLogSource? logger13 = Logger;
				if (logger13 != null)
				{
					logger13.LogError((object)("加载装饰物包时出错: " + ex5.Message + ", 路径: " + bundlePath));
				}
				if ((Object)(object)val != (Object)null)
				{
					val.Unload(true);
				}
			}
		}

		private static string EnsureUniqueName(string baseName)
		{
			string name = baseName;
			int num = 1;
			while (Decorations.Any((DecorationInfo d) => d.Name != null && d.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
			{
				name = $"{baseName}({num})";
				num++;
			}
			return name;
		}

		private static string EnsureUniqueDisplayName(string baseDisplayName)
		{
			string displayName = baseDisplayName;
			int num = 1;
			while (Decorations.Any((DecorationInfo d) => d.DisplayName != null && d.DisplayName.Equals(displayName, StringComparison.OrdinalIgnoreCase)))
			{
				displayName = $"{baseDisplayName}({num})";
				num++;
			}
			return displayName;
		}

		private static string? GetParentTagFromPrefab(GameObject prefab)
		{
			string text = ((Object)prefab).name.ToLower();
			foreach (string key in parentPathMap.Keys)
			{
				if (key != null && text.Contains(key))
				{
					return key;
				}
			}
			return null;
		}

		public static bool GetDecorationState(string? name)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo == null)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("GetDecorationState: 找不到装饰物 " + name2));
				}
			}
			return decorationInfo?.IsVisible ?? false;
		}

		public static void SetDecorationState(string name, bool isVisible)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null)
			{
				decorationInfo.IsVisible = isVisible;
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)$"设置装饰物 {decorationInfo.DisplayName} 显示状态为: {isVisible}");
				}
			}
			else
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogWarning((object)("SetDecorationState: 找不到装饰物 " + name2));
				}
			}
		}

		public static bool ToggleDecorationState(string? name)
		{
			string name2 = name;
			DecorationInfo decorationInfo = Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(name2, StringComparison.OrdinalIgnoreCase));
			if (decorationInfo != null)
			{
				decorationInfo.IsVisible = !decorationInfo.IsVisible;
				return decorationInfo.IsVisible;
			}
			ManualLogSource? logger = Logger;
			if (logger != null)
			{
				logger.LogWarning((object)("ToggleDecorationState: 找不到装饰物 " + name2));
			}
			return false;
		}

		public static string GetParentPath(string parentTag)
		{
			if (parentPathMap.TryGetValue(parentTag.ToLower(), out string value))
			{
				return value;
			}
			return parentPathMap["head"];
		}

		public static void DisableAllDecorations()
		{
			try
			{
				int num = 0;
				foreach (DecorationInfo decoration in Decorations)
				{
					if (decoration.IsVisible)
					{
						decoration.IsVisible = false;
						num++;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("关闭所有装饰物时出错: " + ex.Message));
				}
			}
		}

		public static bool LoadExternalAssetBundle(byte[] bundleData, string resourceName)
		{
			try
			{
				string text = Path.Combine(Path.GetTempPath(), resourceName);
				File.WriteAllBytes(text, bundleData);
				LoadDecorationBundle(text);
				try
				{
					File.Delete(text);
				}
				catch (Exception ex)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("清理临时文件失败: " + ex.Message));
					}
				}
				return true;
			}
			catch (Exception ex2)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("加载外部AB包失败: " + ex2.Message));
				}
				return false;
			}
		}

		public static void LoadExternalAssetBundlesFromAssembly(Assembly assembly)
		{
			try
			{
				int num = 0;
				string name2 = assembly.GetName().Name;
				if (!externalDecorations.ContainsKey(name2))
				{
					externalDecorations[name2] = new List<DecorationInfo>();
				}
				else
				{
					externalDecorations[name2].Clear();
				}
				int count = Decorations.Count;
				string[] manifestResourceNames = assembly.GetManifestResourceNames();
				IEnumerable<string> enumerable = manifestResourceNames.Where((string name) => name.EndsWith(".hhh", StringComparison.OrdinalIgnoreCase));
				if (!enumerable.Any())
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("在DLL " + name2 + " 中未找到.hhh资源"));
					}
					return;
				}
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)$"在DLL {name2} 中找到 {enumerable.Count()} 个.hhh资源");
				}
				foreach (string item in enumerable)
				{
					try
					{
						string text = item.Substring(0, item.Length - 4);
						string text2 = ((!text.Contains(".")) ? text : text.Split('.').Last());
						ManualLogSource? logger3 = Logger;
						if (logger3 != null)
						{
							logger3.LogInfo((object)("处理资源: " + item + ", 提取文件名: " + text2));
						}
						byte[] array;
						using (Stream stream = assembly.GetManifestResourceStream(item))
						{
							if (stream == null)
							{
								continue;
							}
							array = new byte[stream.Length];
							stream.Read(array, 0, array.Length);
							goto IL_01ab;
						}
						IL_01ab:
						if (LoadExternalAssetBundle(array, text2 + ".hhh"))
						{
							num++;
						}
					}
					catch (Exception ex)
					{
						ManualLogSource? logger4 = Logger;
						if (logger4 != null)
						{
							logger4.LogError((object)("加载资源 " + item + " 失败: " + ex.Message));
						}
					}
				}
				if (num > 0)
				{
					for (int i = count; i < Decorations.Count; i++)
					{
						externalDecorations[name2].Add(Decorations[i]);
					}
					ManualLogSource? logger5 = Logger;
					if (logger5 != null)
					{
						logger5.LogInfo((object)$"成功从DLL {name2} 加载了 {num} 个资源,已保存到外部装饰物记录中");
					}
					ConfigManager.ApplySavedStates();
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource? logger6 = Logger;
				if (logger6 != null)
				{
					logger6.LogError((object)("从DLL加载资源失败: " + ex2.Message));
				}
			}
		}

		public static List<DecorationInfo> GetDecorationsFromAssembly(Assembly assembly)
		{
			string name = assembly.GetName().Name;
			if (externalDecorations.TryGetValue(name, out List<DecorationInfo> value))
			{
				return value;
			}
			return new List<DecorationInfo>();
		}

		public static List<GameObject> GetDecorationGameObjectsFromAssembly(Assembly assembly)
		{
			List<GameObject> list = new List<GameObject>();
			foreach (DecorationInfo item in GetDecorationsFromAssembly(assembly))
			{
				if ((Object)(object)item.Prefab != (Object)null)
				{
					list.Add(item.Prefab);
				}
			}
			return list;
		}

		public static DecorationInfo GetDecorationByName(Assembly assembly, string decorationName)
		{
			string decorationName2 = decorationName;
			List<DecorationInfo> decorationsFromAssembly = GetDecorationsFromAssembly(assembly);
			return decorationsFromAssembly.FirstOrDefault((DecorationInfo d) => (d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase)) || (d.DisplayName != null && d.DisplayName.Equals(decorationName2, StringComparison.OrdinalIgnoreCase)));
		}

		public static List<DecorationInfo> FindDecorationsByPartialName(Assembly assembly, string partialName)
		{
			string partialName2 = partialName;
			if (string.IsNullOrEmpty(partialName2))
			{
				return new List<DecorationInfo>();
			}
			List<DecorationInfo> decorationsFromAssembly = GetDecorationsFromAssembly(assembly);
			return decorationsFromAssembly.Where((DecorationInfo d) => (d.Name != null && d.Name.IndexOf(partialName2, StringComparison.OrdinalIgnoreCase) >= 0) || (d.DisplayName != null && d.DisplayName.IndexOf(partialName2, StringComparison.OrdinalIgnoreCase) >= 0)).ToList();
		}

		public static void RecreateUI()
		{
			try
			{
				MoreHeadUI.RecreateUI();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("重新创建UI时出错: " + ex.Message));
				}
			}
		}
	}
	public static class MoreHeadUI
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static BuilderDelegate <>9__13_0;

			public static Action <>9__18_1;

			public static BuilderDelegate <>9__18_0;

			public static BuilderDelegate <>9__30_0;

			public static Func<DecorationInfo, bool> <>9__34_0;

			public static Func<DecorationInfo, string> <>9__34_1;

			public static Func<DecorationInfo, bool> <>9__34_2;

			public static Func<DecorationInfo, string> <>9__34_3;

			public static BuilderDelegate <>9__36_0;

			public static BuilderDelegate <>9__36_1;

			internal void <Initialize>b__13_0(Transform parent)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>", (Action)OnMenuButtonClick, parent, Vector2.zero);
			}

			internal void <AddAuthorCredit>b__18_0(Transform parent)
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("<size=10><color=#FFFFA0>Masaicker</color> and <color=#FFFFA0>Yuriscat</color> co-developed.\n由<color=#FFFFA0>马赛克了</color>和<color=#FFFFA0>尤里的猫</color>共同制作。</size>", (Action)delegate
				{
				}, parent, new Vector2(300f, 329f));
			}

			internal void <AddAuthorCredit>b__18_1()
			{
			}

			internal void <CreateAvatarPreview>b__30_0(Transform parent)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				avatarPreview = MenuAPI.CreateREPOAvatarPreview(parent, new Vector2(420f, 10f), false, (Color?)null);
			}

			internal bool <CreateAllDecorationButtons>b__34_0(DecorationInfo decoration)
			{
				return IsBuiltInDecoration(decoration);
			}

			internal string <CreateAllDecorationButtons>b__34_1(DecorationInfo decoration)
			{
				return decoration.DisplayName;
			}

			internal bool <CreateAllDecorationButtons>b__34_2(DecorationInfo decoration)
			{
				return !IsBuiltInDecoration(decoration);
			}

			internal string <CreateAllDecorationButtons>b__34_3(DecorationInfo decoration)
			{
				return decoration.DisplayName;
			}

			internal void <AddActionButtons>b__36_0(Transform parent)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("<size=18><color=#FFFFFF>C</color><color=#E6E6E6>L</color><color=#CCCCCC>O</color><color=#B3B3B3>S</color><color=#999999>E</color></size>", (Action)OnCloseButtonClick, parent, new Vector2(301f, 0f));
			}

			internal void <AddActionButtons>b__36_1(Transform parent)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("<size=18><color=#FFAA00>CLEAR ALL</color></size>", (Action)OnDisableAllButtonClick, parent, new Vector2(401f, 0f));
			}
		}

		private static REPOPopupPage? decorationsPage;

		private static Dictionary<string?, REPOButton> decorationButtons = new Dictionary<string, REPOButton>();

		private static Dictionary<string, List<REPOScrollViewElement>> tagScrollViewElements = new Dictionary<string, List<REPOScrollViewElement>>();

		private static string currentTagFilter = "ALL";

		private static Dictionary<string, REPOButton> tagFilterButtons = new Dictionary<string, REPOButton>();

		private static Dictionary<string, List<DecorationInfo>> decorationDataCache = new Dictionary<string, List<DecorationInfo>>();

		private static Dictionary<string, Dictionary<string, string>> buttonTextCache = new Dictionary<string, Dictionary<string, string>>();

		private static REPOAvatarPreview? avatarPreview;

		private const string BUTTON_NAME = "<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>";

		private static readonly string PAGE_TITLE = "Rotate robot: A/D <size=12><color=#AAAAAA>v" + Morehead.GetPluginVersion() + "</color></size>";

		private static readonly string[] ALL_TAGS = new string[6] { "ALL", "HEAD", "NECK", "BODY", "HIP", "WORLD" };

		private static ManualLogSource? Logger => Morehead.Logger;

		public static void Initialize()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			try
			{
				object obj = <>c.<>9__13_0;
				if (obj == null)
				{
					BuilderDelegate val = delegate(Transform parent)
					{
						//IL_0013: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("<color=#FF0000>M</color><color=#FF3300>O</color><color=#FF6600>R</color><color=#FF9900>E</color><color=#FFCC00>H</color><color=#FFDD00>E</color><color=#FFEE00>A</color><color=#FFFF00>D</color>", (Action)OnMenuButtonClick, parent, Vector2.zero);
					};
					<>c.<>9__13_0 = val;
					obj = (object)val;
				}
				MenuAPI.AddElementToEscapeMenu((BuilderDelegate)obj);
				InitializeDataCache();
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"MoreHead UI已初始化");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("初始化UI时出错: " + ex.Message));
				}
			}
		}

		private static void InitializeDataCache()
		{
			try
			{
				decorationDataCache.Clear();
				buttonTextCache.Clear();
				string[] aLL_TAGS = ALL_TAGS;
				foreach (string tag in aLL_TAGS)
				{
					List<DecorationInfo> list = HeadDecorationManager.Decorations.Where((DecorationInfo decoration) => tag == "ALL" || decoration.ParentTag?.ToLower() == tag.ToLower()).ToList();
					decorationDataCache[tag] = list;
					buttonTextCache[tag] = new Dictionary<string, string>();
					foreach (DecorationInfo item in list)
					{
						string buttonText = GetButtonText(item, item.IsVisible);
						buttonTextCache[tag][item.Name ?? string.Empty] = buttonText;
					}
				}
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"数据缓存初始化完成");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("初始化数据缓存时出错: " + ex.Message));
				}
			}
		}

		private static void OnMenuButtonClick()
		{
			try
			{
				MenuManager.instance.PageCloseAll();
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedOpenMoreHeadUI());
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("打开设置页面时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedOpenMoreHeadUI()
		{
			yield return null;
			try
			{
				if ((Object)(object)decorationsPage == (Object)null)
				{
					decorationsPage = MenuAPI.CreateREPOPopupPage(PAGE_TITLE, true, true, 0f, (Vector2?)new Vector2(-299f, 10f));
					SetupPopupPage(decorationsPage);
					CreateAllDecorationButtons(decorationsPage);
					CreateTagFilterButtons(decorationsPage);
					AddAuthorCredit(decorationsPage);
					AddActionButtons(decorationsPage);
				}
				decorationsPage.OpenPage(false);
				MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>();
				if (obj != null)
				{
					obj.StartCoroutine(DelayedShowTagDecorations(currentTagFilter));
				}
				UpdateAvatarPreview();
				UpdateButtonStates();
			}
			catch (Exception e)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("延迟打开设置页面时出错: " + e.Message));
				}
			}
		}

		private static void SetupPopupPage(REPOPopupPage page)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)((Component)page).gameObject != (Object)null)
				{
					((Object)((Component)page).gameObject).name = "MoreHead_Page";
				}
				page.pageDimmerVisibility = true;
				page.maskPadding = new Padding(10f, 10f, 20f, 10f);
				((Transform)((TMP_Text)page.headerTMP).rectTransform).position = new Vector3(170f, 344f, 0f);
				page.pageDimmerOpacity = 0.85f;
				page.scrollView.scrollSpeed = 4f;
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("设置弹出页面属性时出错: " + ex.Message));
				}
			}
		}

		private static void AddAuthorCredit(REPOPopupPage page)
		{
			//IL_0017: 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_0022: Expected O, but got Unknown
			try
			{
				object obj = <>c.<>9__18_0;
				if (obj == null)
				{
					BuilderDelegate val = delegate(Transform parent)
					{
						//IL_0030: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("<size=10><color=#FFFFA0>Masaicker</color> and <color=#FFFFA0>Yuriscat</color> co-developed.\n由<color=#FFFFA0>马赛克了</color>和<color=#FFFFA0>尤里的猫</color>共同制作。</size>", (Action)delegate
						{
						}, parent, new Vector2(300f, 329f));
					};
					<>c.<>9__18_0 = val;
					obj = (object)val;
				}
				page.AddElement((BuilderDelegate)obj);
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("添加作者标记时出错: " + ex.Message));
				}
			}
		}

		private static bool IsBuiltInDecoration(DecorationInfo decoration)
		{
			string bundlePath = decoration.BundlePath;
			if (string.IsNullOrEmpty(bundlePath))
			{
				return false;
			}
			Morehead? instance = Morehead.Instance;
			string directoryName = Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null);
			if (string.IsNullOrEmpty(directoryName))
			{
				return false;
			}
			string value = Path.Combine(directoryName, "Decorations");
			return bundlePath.StartsWith(value);
		}

		private static void CreateTagFilterButtons(REPOPopupPage? page)
		{
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			try
			{
				tagFilterButtons.Clear();
				for (int i = 0; i < ALL_TAGS.Length; i++)
				{
					string text = ALL_TAGS[i];
					string text2 = text.ToLower();
					int num = i;
					if (1 == 0)
					{
					}
					string text3 = text2 switch
					{
						"head" => "#00AAFF", 
						"neck" => "#AA00FF", 
						"body" => "#FFAA00", 
						"hip" => "#FF00AA", 
						"world" => "#00FFAA", 
						_ => "#FFFFFF", 
					};
					if (1 == 0)
					{
					}
					string text4 = text3;
					string buttonText = ((text2 == currentTagFilter.ToLower()) ? ("<size=14><b><color=" + text4 + ">" + text + "</color></b></size>") : ("<size=14><color=" + text4 + "50>" + text + "</color></size>"));
					string tagForCallback = ((text2 == "all") ? "ALL" : text);
					int xPosition = 70 + i * 40;
					if (page == null)
					{
						continue;
					}
					page.AddElement((BuilderDelegate)delegate(Transform parent)
					{
						//IL_0033: Unknown result type (might be due to invalid IL or missing references)
						REPOButton value = MenuAPI.CreateREPOButton(buttonText, (Action)delegate
						{
							OnTagFilterButtonClick(tagForCallback);
						}, parent, new Vector2((float)xPosition, 20f));
						tagFilterButtons[tagForCallback] = value;
					});
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("创建标签筛选按钮时出错: " + ex.Message));
				}
			}
		}

		private static void OnTagFilterButtonClick(string tag)
		{
			try
			{
				if (tag == currentTagFilter)
				{
					REPOPopupPage? obj = decorationsPage;
					if (obj != null)
					{
						obj.scrollView.SetScrollPosition(0f);
					}
				}
				else
				{
					ShowTagDecorations(tag);
					UpdateTagButtonHighlights();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("切换标签筛选时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateButtonStates()
		{
			try
			{
				if (decorationButtons.Count == 0)
				{
					return;
				}
				if (decorationDataCache.TryGetValue(currentTagFilter, out List<DecorationInfo> value))
				{
					foreach (DecorationInfo item in value)
					{
						if (!decorationButtons.TryGetValue(item.Name ?? string.Empty, out REPOButton value2))
						{
							continue;
						}
						if (!buttonTextCache.TryGetValue(currentTagFilter, out Dictionary<string, string> value3) || !value3.TryGetValue(item.Name ?? string.Empty, out var value4))
						{
							value4 = GetButtonText(item, item.IsVisible);
							if (buttonTextCache.TryGetValue(currentTagFilter, out value3))
							{
								value3[item.Name ?? string.Empty] = value4;
							}
						}
						((TMP_Text)value2.labelTMP).text = value4;
					}
				}
				UpdateTagButtonHighlights();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新按钮状态时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateTagButtonHighlights()
		{
			try
			{
				string[] aLL_TAGS = ALL_TAGS;
				foreach (string text in aLL_TAGS)
				{
					string text2 = ((text == "ALL") ? "ALL" : text);
					if (tagFilterButtons.TryGetValue(text2, out REPOButton value))
					{
						string text3 = text.ToLower();
						if (1 == 0)
						{
						}
						string text4 = text3 switch
						{
							"head" => "#00AAFF", 
							"neck" => "#AA00FF", 
							"body" => "#FFAA00", 
							"hip" => "#FF00AA", 
							"world" => "#00FFAA", 
							_ => "#FFFFFF", 
						};
						if (1 == 0)
						{
						}
						string text5 = text4;
						string text6 = ((text2 == currentTagFilter) ? ("<size=14><b><color=" + text5 + ">" + text + "</color></b></size>") : ("<size=14><color=" + text5 + "50>" + text + "</color></size>"));
						((TMP_Text)value.labelTMP).text = text6;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新标签按钮高亮状态时出错: " + ex.Message));
				}
			}
		}

		private static void OnDecorationButtonClick(string? decorationName)
		{
			string decorationName2 = decorationName;
			try
			{
				DecorationInfo decorationInfo = HeadDecorationManager.Decorations.FirstOrDefault((DecorationInfo d) => d.Name != null && d.Name.Equals(decorationName2, StringComparison.OrdinalIgnoreCase));
				if (decorationInfo == null)
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)("OnDecorationButtonClick: 找不到装饰物: " + decorationName2));
					}
					return;
				}
				bool isEnabled = HeadDecorationManager.ToggleDecorationState(decorationName2);
				string buttonText = GetButtonText(decorationInfo, isEnabled);
				string[] aLL_TAGS = ALL_TAGS;
				foreach (string text in aLL_TAGS)
				{
					if ((text == "ALL" || decorationInfo.ParentTag?.ToLower() == text.ToLower()) && buttonTextCache.TryGetValue(text, out Dictionary<string, string> value))
					{
						value[decorationName2 ?? string.Empty] = buttonText;
					}
				}
				if (decorationButtons.TryGetValue(decorationName2 ?? string.Empty, out REPOButton value2))
				{
					((TMP_Text)value2.labelTMP).text = buttonText;
				}
				UpdateDecorations();
				ConfigManager.SaveConfig();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("切换装饰物 " + decorationName2 + " 状态时出错: " + ex.Message));
				}
			}
		}

		private static string GetButtonText(DecorationInfo decoration, bool isEnabled)
		{
			string text = decoration.DisplayName?.ToUpper() ?? "UNKNOWN";
			string text2 = decoration.ParentTag ?? "unknown";
			string text3 = text2.ToLower();
			if (1 == 0)
			{
			}
			string text4 = text3 switch
			{
				"head" => "#00AAFF", 
				"neck" => "#AA00FF", 
				"body" => "#FFAA00", 
				"hip" => "#FF00AA", 
				"world" => "#00FFAA", 
				_ => "#AAAAAA", 
			};
			if (1 == 0)
			{
			}
			string text5 = text4;
			return "<size=16>" + (isEnabled ? "<color=#00FF00>[+]</color>" : "<color=#FF0000>[-]</color>") + " <color=" + text5 + "><size=12>(" + text2 + ")</size></color> " + text + "</size>";
		}

		private static void OnCloseButtonClick()
		{
			try
			{
				MenuManager.instance.PageCloseAll();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("关闭页面时出错: " + ex.Message));
				}
			}
		}

		private static void UpdateDecorations()
		{
			try
			{
				PlayerAvatar val = FindLocalPlayer();
				if ((Object)(object)val != (Object)null)
				{
					PlayerUpdatePatch.UpdatePlayerDecorations(val);
					HeadDecorationSync component = ((Component)val).GetComponent<HeadDecorationSync>();
					if ((Object)(object)component != (Object)null)
					{
						component.SyncAllDecorations();
					}
				}
				PlayerUpdatePatch.UpdateMenuPlayerDecorations();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新装饰物状态时出错: " + ex.Message));
				}
			}
		}

		private static PlayerAvatar? FindLocalPlayer()
		{
			try
			{
				PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
				PlayerAvatar[] array2 = array;
				foreach (PlayerAvatar val in array2)
				{
					if ((Object)(object)val?.photonView != (Object)null && val.photonView.IsMine)
					{
						return val;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("查找本地玩家时出错: " + ex.Message));
				}
			}
			return null;
		}

		private static void UpdateAvatarPreview()
		{
			try
			{
				if (!((Object)(object)decorationsPage == (Object)null))
				{
					if ((Object)(object)avatarPreview != (Object)null)
					{
						SafeDestroyAvatar();
					}
					CreateAvatarPreview(decorationsPage);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("更新头像预览时出错: " + ex.Message));
				}
			}
		}

		private static void CreateAvatarPreview(REPOPopupPage page)
		{
			//IL_0017: 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_0022: Expected O, but got Unknown
			try
			{
				object obj = <>c.<>9__30_0;
				if (obj == null)
				{
					BuilderDelegate val = delegate(Transform parent)
					{
						//IL_000c: Unknown result type (might be due to invalid IL or missing references)
						avatarPreview = MenuAPI.CreateREPOAvatarPreview(parent, new Vector2(420f, 10f), false, (Color?)null);
					};
					<>c.<>9__30_0 = val;
					obj = (object)val;
				}
				page.AddElement((BuilderDelegate)obj);
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("创建头像预览时出错: " + ex.Message));
				}
			}
		}

		private static void SafeDestroyAvatar()
		{
			try
			{
				if ((Object)(object)avatarPreview != (Object)null)
				{
					if ((Object)(object)((Component)avatarPreview).transform != (Object)null && (Object)(object)((Component)avatarPreview).transform.parent != (Object)null)
					{
						((Component)avatarPreview).transform.SetParent((Transform)null, false);
					}
					PlayerAvatarVisuals playerAvatarVisuals = avatarPreview.playerAvatarVisuals;
					if ((Object)(object)playerAvatarVisuals != (Object)null)
					{
					}
					if ((Object)(object)((Component)avatarPreview).gameObject != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)avatarPreview).gameObject);
					}
					avatarPreview = null;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("安全销毁头像预览时出错,但这不影响功能: " + ex.Message));
				}
				avatarPreview = null;
			}
		}

		private static void OnDisableAllButtonClick()
		{
			try
			{
				HeadDecorationManager.DisableAllDecorations();
				string[] aLL_TAGS = ALL_TAGS;
				foreach (string text in aLL_TAGS)
				{
					if (!buttonTextCache.TryGetValue(text, out Dictionary<string, string> value))
					{
						continue;
					}
					foreach (DecorationInfo decoration in HeadDecorationManager.Decorations)
					{
						if (text == "ALL" || decoration.ParentTag?.ToLower() == text.ToLower())
						{
							string buttonText = GetButtonText(decoration, isEnabled: false);
							value[decoration.Name ?? string.Empty] = buttonText;
						}
					}
				}
				foreach (DecorationInfo decoration2 in HeadDecorationManager.Decorations)
				{
					if (decorationButtons.TryGetValue(decoration2.Name ?? string.Empty, out REPOButton value2))
					{
						((TMP_Text)value2.labelTMP).text = GetButtonText(decoration2, isEnabled: false);
					}
				}
				UpdateDecorations();
				ConfigManager.SaveConfig();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("关闭所有装饰物时出错: " + ex.Message));
				}
			}
		}

		public static void RecreateUI()
		{
			try
			{
				decorationDataCache.Clear();
				buttonTextCache.Clear();
				decorationButtons.Clear();
				tagScrollViewElements.Clear();
				if ((Object)(object)decorationsPage != (Object)null && (Object)(object)((Component)decorationsPage).gameObject != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)decorationsPage).gameObject);
					decorationsPage = null;
				}
				SafeDestroyAvatar();
				InitializeDataCache();
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"UI已重新初始化,缓存已重置");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("重新创建UI时出错: " + ex.Message));
				}
			}
		}

		private static void CreateAllDecorationButtons(REPOPopupPage page)
		{
			try
			{
				decorationButtons.Clear();
				tagScrollViewElements.Clear();
				string[] aLL_TAGS = ALL_TAGS;
				foreach (string key in aLL_TAGS)
				{
					tagScrollViewElements[key] = new List<REPOScrollViewElement>();
				}
				List<DecorationInfo> source = HeadDecorationManager.Decorations.ToList();
				List<DecorationInfo> list = (from decoration in source
					where IsBuiltInDecoration(decoration)
					orderby decoration.DisplayName
					select decoration).ToList();
				List<DecorationInfo> list2 = (from decoration in source
					where !IsBuiltInDecoration(decoration)
					orderby decoration.DisplayName
					select decoration).ToList();
				foreach (DecorationInfo item in list)
				{
					CreateDecorationButton(page, item);
				}
				foreach (DecorationInfo item2 in list2)
				{
					CreateDecorationButton(page, item2);
				}
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)$"创建了所有装饰物按钮,总共 {decorationButtons.Count} 个");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("创建装饰物按钮时出错: " + ex.Message));
				}
			}
		}

		private static void CreateDecorationButton(REPOPopupPage page, DecorationInfo decoration)
		{
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			try
			{
				string decorationName = decoration.Name;
				string parentTag = decoration.ParentTag;
				if (string.IsNullOrEmpty(decorationName) || string.IsNullOrEmpty(parentTag))
				{
					ManualLogSource? logger = Logger;
					if (logger != null)
					{
						logger.LogWarning((object)"跳过创建按钮:装饰物名称或标签为空");
					}
					return;
				}
				string buttonText = GetButtonText(decoration, decoration.IsVisible);
				string[] aLL_TAGS = ALL_TAGS;
				foreach (string text in aLL_TAGS)
				{
					if (text == "ALL" || parentTag.ToLower() == text.ToLower())
					{
						if (!buttonTextCache.TryGetValue(text, out Dictionary<string, string> value))
						{
							buttonTextCache[text] = new Dictionary<string, string>();
							value = buttonTextCache[text];
						}
						value[decorationName] = buttonText;
					}
				}
				REPOButton repoButton = null;
				page.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
				{
					//IL_002a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					repoButton = MenuAPI.CreateREPOButton(buttonText, (Action)delegate
					{
						OnDecorationButtonClick(decorationName);
					}, scrollView, default(Vector2));
					return ((REPOElement)repoButton).rectTransform;
				}, 0f, 0f);
				if ((Object)(object)repoButton != (Object)null)
				{
					decorationButtons[decorationName] = repoButton;
					((REPOElement)repoButton).repoScrollViewElement.visibility = false;
					tagScrollViewElements["ALL"].Add(((REPOElement)repoButton).repoScrollViewElement);
					if (tagScrollViewElements.TryGetValue(parentTag.ToUpper(), out List<REPOScrollViewElement> value2))
					{
						value2.Add(((REPOElement)repoButton).repoScrollViewElement);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogError((object)("创建装饰物按钮时出错: " + ex.Message));
				}
			}
		}

		private static void AddActionButtons(REPOPopupPage page)
		{
			//IL_0017: 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_0022: Expected O, but got Unknown
			//IL_003d: 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)
			//IL_0048: Expected O, but got Unknown
			try
			{
				object obj = <>c.<>9__36_0;
				if (obj == null)
				{
					BuilderDelegate val = delegate(Transform parent)
					{
						//IL_001d: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("<size=18><color=#FFFFFF>C</color><color=#E6E6E6>L</color><color=#CCCCCC>O</color><color=#B3B3B3>S</color><color=#999999>E</color></size>", (Action)OnCloseButtonClick, parent, new Vector2(301f, 0f));
					};
					<>c.<>9__36_0 = val;
					obj = (object)val;
				}
				page.AddElement((BuilderDelegate)obj);
				object obj2 = <>c.<>9__36_1;
				if (obj2 == null)
				{
					BuilderDelegate val2 = delegate(Transform parent)
					{
						//IL_001d: Unknown result type (might be due to invalid IL or missing references)
						MenuAPI.CreateREPOButton("<size=18><color=#FFAA00>CLEAR ALL</color></size>", (Action)OnDisableAllButtonClick, parent, new Vector2(401f, 0f));
					};
					<>c.<>9__36_1 = val2;
					obj2 = (object)val2;
				}
				page.AddElement((BuilderDelegate)obj2);
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("添加操作按钮时出错: " + ex.Message));
				}
			}
		}

		private static void ShowTagDecorations(string tag)
		{
			try
			{
				if ((Object)(object)decorationsPage == (Object)null)
				{
					return;
				}
				if (!string.IsNullOrEmpty(currentTagFilter) && tagScrollViewElements.TryGetValue(currentTagFilter, out List<REPOScrollViewElement> value))
				{
					foreach (REPOScrollViewElement item in value)
					{
						if ((Object)(object)item != (Object)null)
						{
							item.visibility = false;
						}
					}
				}
				if (!string.IsNullOrEmpty(tag) && tagScrollViewElements.TryGetValue(tag, out List<REPOScrollViewElement> value2))
				{
					foreach (REPOScrollViewElement item2 in value2)
					{
						if ((Object)(object)item2 != (Object)null)
						{
							item2.visibility = true;
						}
					}
				}
				currentTagFilter = tag;
				decorationsPage.scrollView.SetScrollPosition(0f);
				decorationsPage.scrollView.UpdateElements();
			}
			catch (Exception ex)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("显示标签 " + tag + " 的装饰物时出错: " + ex.Message));
				}
			}
		}

		private static IEnumerator DelayedShowTagDecorations(string tag)
		{
			yield return null;
			try
			{
				ShowTagDecorations(tag);
			}
			catch (Exception e)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)("延迟显示标签装饰物时出错: " + e.Message));
				}
			}
		}
	}
}

BeepInEx/plugins/Zehs-ExtractionPointConfirmButton/com.github.zehsteam.ExtractionPointConfirmButton.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using com.github.zehsteam.ExtractionPointConfirmButton.MonoBehaviours;
using com.github.zehsteam.ExtractionPointConfirmButton.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Zehs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2025 Zehs")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+7c041e9f7e7907f331a7f407a227a8738137bf57")]
[assembly: AssemblyProduct("ExtractionPointConfirmButton")]
[assembly: AssemblyTitle("com.github.zehsteam.ExtractionPointConfirmButton")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace com.github.zehsteam.ExtractionPointConfirmButton
{
	internal static class Assets
	{
		public static GameObject ConfirmButtonObjectPrefab { get; private set; }

		public static void Load()
		{
			LoadAssetsFromAssetBundle();
		}

		private static void LoadAssetsFromAssetBundle()
		{
			AssetBundle val = LoadAssetBundle("extractionpointconfirmbutton_assets");
			if (!((Object)(object)val == (Object)null))
			{
				ConfirmButtonObjectPrefab = LoadAssetFromAssetBundle<GameObject>("ConfirmButtonObject", val);
				Plugin.Logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
		}

		private static AssetBundle LoadAssetBundle(string fileName)
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, fileName);
				return AssetBundle.LoadFromFile(text);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Failed to load AssetBundle \"{fileName}\". {arg}");
			}
			return null;
		}

		private static T LoadAssetFromAssetBundle<T>(string name, AssetBundle assetBundle) where T : Object
		{
			if (string.IsNullOrWhiteSpace(name))
			{
				Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."));
				return default(T);
			}
			if ((Object)(object)assetBundle == (Object)null)
			{
				Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."));
				return default(T);
			}
			T val = assetBundle.LoadAsset<T>(name);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."));
				return default(T);
			}
			return val;
		}
	}
	[BepInPlugin("com.github.zehsteam.ExtractionPointConfirmButton", "ExtractionPointConfirmButton", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.zehsteam.ExtractionPointConfirmButton");

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = Logger.CreateLogSource("com.github.zehsteam.ExtractionPointConfirmButton");
			Logger.LogInfo((object)"ExtractionPointConfirmButton has awoken!");
			_harmony.PatchAll(typeof(RunManagerPatch));
			_harmony.PatchAll(typeof(ExtractionPointPatch));
			Assets.Load();
			NetworkPrefabs.RegisterNetworkPrefab(Assets.ConfirmButtonObjectPrefab);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.ExtractionPointConfirmButton";

		public const string PLUGIN_NAME = "ExtractionPointConfirmButton";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace com.github.zehsteam.ExtractionPointConfirmButton.Patches
{
	[HarmonyPatch(typeof(ExtractionPoint))]
	internal static class ExtractionPointPatch
	{
		private static readonly Dictionary<ExtractionPoint, float> _timeSinceConfirms = new Dictionary<ExtractionPoint, float>();

		public static Dictionary<ExtractionPoint, ConfirmButton> ConfirmButtons { get; private set; } = new Dictionary<ExtractionPoint, ConfirmButton>();


		public static void Reset()
		{
			ConfirmButtons.Clear();
			_timeSinceConfirms.Clear();
		}

		public static void ConfirmExtractionPoint(ExtractionPoint extractionPoint)
		{
			if ((Object)(object)extractionPoint == (Object)null || extractionPoint.isShop)
			{
				return;
			}
			if (extractionPoint.haulGoal - extractionPoint.haulCurrent > 0)
			{
				if (extractionPoint.StateIs((State)2))
				{
					extractionPoint.StateSet((State)5);
				}
			}
			else
			{
				_timeSinceConfirms[extractionPoint] = Time.realtimeSinceStartup;
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(ref ExtractionPoint __instance)
		{
			SpawnConfirmButtonObject(__instance);
			UpdateConfirmButtonVisibility(__instance);
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(ref ExtractionPoint __instance)
		{
			UpdateSuccessDelay(__instance);
		}

		[HarmonyPatch("StateSetRPC")]
		[HarmonyPostfix]
		private static void StateSetRPCPatch(ref ExtractionPoint __instance)
		{
			UpdateConfirmButtonVisibility(__instance);
		}

		private static void SpawnConfirmButtonObject(ExtractionPoint extractionPoint)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)extractionPoint == (Object)null || extractionPoint.isShop || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			Transform val = ((Component)extractionPoint).transform.Find("Scale");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to spawn confirm button object. Target transform is null.");
				return;
			}
			GameObject confirmButtonObjectPrefab = Assets.ConfirmButtonObjectPrefab;
			Vector3 position = val.position;
			Quaternion rotation = val.rotation;
			GameObject val2 = ((!SemiFunc.IsMultiplayer()) ? Object.Instantiate<GameObject>(confirmButtonObjectPrefab, position, rotation) : PhotonNetwork.InstantiateRoomObject(((Object)confirmButtonObjectPrefab).name, position, rotation, (byte)0, (object[])null));
			ConfirmButton component = val2.GetComponent<ConfirmButton>();
			if (SemiFunc.IsMultiplayer())
			{
				component.SetExtractionPointRPC(extractionPoint.photonView.ViewID);
			}
			else
			{
				component.SetExtractionPoint(extractionPoint);
			}
			ConfirmButtons.Add(extractionPoint, component);
		}

		private static void UpdateSuccessDelay(ExtractionPoint extractionPoint)
		{
			if (!((Object)(object)extractionPoint == (Object)null) && !extractionPoint.isShop && HasConfirmButton(extractionPoint))
			{
				bool flag = true;
				if (_timeSinceConfirms.TryGetValue(extractionPoint, out var value) && Time.realtimeSinceStartup - value <= 2f)
				{
					flag = false;
				}
				if (flag)
				{
					extractionPoint.successDelay = 1.5f;
				}
				else
				{
					extractionPoint.successDelay = 0f;
				}
			}
		}

		private static bool HasConfirmButton(ExtractionPoint extractionPoint)
		{
			if ((Object)(object)extractionPoint == (Object)null || extractionPoint.isShop)
			{
				return false;
			}
			if (ConfirmButtons.TryGetValue(extractionPoint, out var value))
			{
				if ((Object)(object)value == (Object)null)
				{
					return false;
				}
				return ((Component)value).gameObject.activeSelf;
			}
			return false;
		}

		private static void UpdateConfirmButtonVisibility(ExtractionPoint extractionPoint)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)extractionPoint == (Object)null) && !extractionPoint.isShop && ConfirmButtons.TryGetValue(extractionPoint, out var value) && !((Object)(object)value == (Object)null))
			{
				((Component)value).gameObject.SetActive(ShowConfirmButton(extractionPoint.stateSetTo));
			}
		}

		private static bool ShowConfirmButton(State state)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			if ((int)state == 1)
			{
				return false;
			}
			if ((int)state == 6)
			{
				return false;
			}
			if ((int)state == 9)
			{
				return false;
			}
			if ((int)state == 7)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(RunManager))]
	internal static class RunManagerPatch
	{
		[HarmonyPatch("UpdateLevel")]
		[HarmonyPostfix]
		private static void UpdateLevelPatch()
		{
			ExtractionPointPatch.Reset();
		}
	}
}
namespace com.github.zehsteam.ExtractionPointConfirmButton.MonoBehaviours
{
	public class ConfirmButton : MonoBehaviour
	{
		public Transform ButtonVisualTransform;

		private bool _buttonAnimation;

		private float _buttonAnimationEval;

		private ExtractionPoint _extractionPoint;

		private void Update()
		{
			ButtonAnimation();
		}

		public void OnClick()
		{
			OnClickRPC();
		}

		[PunRPC]
		public void SetExtractionPointRPC(int viewID)
		{
			PhotonView photonView = PhotonNetwork.GetPhotonView(viewID);
			if ((Object)(object)photonView == (Object)null)
			{
				Plugin.Logger.LogError((object)"ConfirmButton: failed to set extraction point. PhotonView is null.");
				return;
			}
			ExtractionPoint extractionPoint = default(ExtractionPoint);
			if (!((Component)photonView).TryGetComponent<ExtractionPoint>(ref extractionPoint))
			{
				Plugin.Logger.LogError((object)"ConfirmButton: failed to set extraction point. ExtractionPoint is null.");
				return;
			}
			_extractionPoint = extractionPoint;
			Plugin.Logger.LogInfo((object)$"ConfirmButton: set extraction point. (ViewID: {viewID})");
		}

		public void SetExtractionPoint(ExtractionPoint extractionPoint)
		{
			_extractionPoint = extractionPoint;
			Plugin.Logger.LogInfo((object)"ConfirmButton: set extraction point.");
		}

		[PunRPC]
		private void OnClickRPC()
		{
			ButtonPushVisualsStart();
			ExtractionPointPatch.ConfirmExtractionPoint(_extractionPoint);
		}

		private void ButtonPushVisualsStart()
		{
			//IL_002c: 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)
			if (!((Object)(object)_extractionPoint == (Object)null) && !_buttonAnimation)
			{
				ButtonVisualTransform.localScale = new Vector3(1f, 0.1f, 1f);
				_extractionPoint.soundButton.Play(ButtonVisualTransform.position, 1f, 1f, 1f, 1f);
				_buttonAnimationEval = 0f;
				_buttonAnimation = true;
			}
		}

		private void ButtonAnimation()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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)
			if (!((Object)(object)_extractionPoint == (Object)null) && _buttonAnimation)
			{
				_buttonAnimationEval += Time.deltaTime * 2f;
				_buttonAnimationEval = Mathf.Clamp01(_buttonAnimationEval);
				float num = _extractionPoint.buttonPressAnimationCurve.Evaluate(_buttonAnimationEval);
				Color val = default(Color);
				((Color)(ref val))..ctor(1f, 0.5f, 0f, 1f);
				((Renderer)((Component)ButtonVisualTransform).GetComponent<MeshRenderer>()).material.SetColor("_EmissionColor", Color.Lerp(val, Color.white, num));
				num = Mathf.Clamp(num, 0.5f, 1f);
				ButtonVisualTransform.localScale = new Vector3(1f, num, 1f);
				if (_buttonAnimationEval >= 1f)
				{
					_buttonAnimation = false;
					_buttonAnimationEval = 0f;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

BeepInEx/plugins/Zehs-LethalCompanyValuables/com.github.zehsteam.LethalCompanyValuables.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using com.github.zehsteam.LethalCompanyValuables.Objects;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Zehs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2025 Zehs")]
[assembly: AssemblyDescription("Adds 30 scrap items from Lethal Company as valuables.")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+b251022efc99bc65e7c524ea22dab616684e7a96")]
[assembly: AssemblyProduct("LethalCompanyValuables")]
[assembly: AssemblyTitle("com.github.zehsteam.LethalCompanyValuables")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace com.github.zehsteam.LethalCompanyValuables
{
	internal static class Assets
	{
		public static ValuableList ValuableList { get; private set; }

		public static void Load()
		{
			LoadAssetsFromAssetBundle();
		}

		private static void LoadAssetsFromAssetBundle()
		{
			AssetBundle val = LoadAssetBundle("lethalcompanyvaluables_assets");
			if (!((Object)(object)val == (Object)null))
			{
				ValuableList = LoadAssetFromAssetBundle<ValuableList>("ValuableList", val);
				Plugin.Logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
		}

		private static AssetBundle LoadAssetBundle(string fileName)
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, fileName);
				return AssetBundle.LoadFromFile(text);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Failed to load AssetBundle \"{fileName}\". {arg}");
			}
			return null;
		}

		private static T LoadAssetFromAssetBundle<T>(string name, AssetBundle assetBundle) where T : Object
		{
			if (string.IsNullOrWhiteSpace(name))
			{
				Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."));
				return default(T);
			}
			if ((Object)(object)assetBundle == (Object)null)
			{
				Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."));
				return default(T);
			}
			T val = assetBundle.LoadAsset<T>(name);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."));
				return default(T);
			}
			return val;
		}
	}
	[BepInPlugin("com.github.zehsteam.LethalCompanyValuables", "LethalCompanyValuables", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Instance = this;
			Logger = Logger.CreateLogSource("com.github.zehsteam.LethalCompanyValuables");
			Logger.LogInfo((object)"LethalCompanyValuables has awoken!");
			Assets.Load();
			RegisterValuables();
		}

		private void RegisterValuables()
		{
			GameObject[] valuables = Assets.ValuableList.Valuables;
			foreach (GameObject val in valuables)
			{
				Valuables.RegisterValuable(val);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.LethalCompanyValuables";

		public const string PLUGIN_NAME = "LethalCompanyValuables";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace com.github.zehsteam.LethalCompanyValuables.Objects
{
	[CreateAssetMenu(fileName = "ValuableList", menuName = "LethalCompanyValuables/ValuableList")]
	public class ValuableList : ScriptableObject
	{
		public GameObject[] Valuables = Array.Empty<GameObject>();
	}
}
namespace com.github.zehsteam.LethalCompanyValuables.MonoBehaviours
{
	public class GiftBox : MonoBehaviour
	{
		[SerializeField]
		private Transform _spawnTransform;

		public void OnBreak()
		{
			SpawnRandomValuable();
		}

		private void SpawnRandomValuable()
		{
			//IL_0071: 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_0051: 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)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)_spawnTransform == (Object)null)
			{
				return;
			}
			List<GameObject> valuablePrefabsForCurrentLevel = GetValuablePrefabsForCurrentLevel();
			if (valuablePrefabsForCurrentLevel.Count != 0)
			{
				int index = Random.Range(0, valuablePrefabsForCurrentLevel.Count);
				GameObject val = valuablePrefabsForCurrentLevel[index];
				if (SemiFunc.IsMultiplayer())
				{
					string valuablePrefabPath = ResourcesHelper.GetValuablePrefabPath(val);
					PhotonNetwork.InstantiateRoomObject(valuablePrefabPath, _spawnTransform.position, _spawnTransform.rotation, (byte)0, (object[])null);
				}
				else
				{
					Object.Instantiate<GameObject>(val, _spawnTransform.position, _spawnTransform.rotation);
				}
			}
		}

		private List<GameObject> GetValuablePrefabsForCurrentLevel()
		{
			if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent == (Object)null)
			{
				return new List<GameObject>();
			}
			Level levelCurrent = RunManager.instance.levelCurrent;
			List<GameObject> list = new List<GameObject>();
			foreach (LevelValuables valuablePreset in levelCurrent.ValuablePresets)
			{
				List<GameObject> tiny = valuablePreset.tiny;
				List<GameObject> small = valuablePreset.small;
				List<GameObject> medium = valuablePreset.medium;
				int num = 0;
				GameObject[] array = (GameObject[])(object)new GameObject[tiny.Count + small.Count + medium.Count];
				foreach (GameObject item2 in tiny)
				{
					array[num] = item2;
					num++;
				}
				foreach (GameObject item3 in small)
				{
					array[num] = item3;
					num++;
				}
				foreach (GameObject item4 in medium)
				{
					array[num] = item4;
					num++;
				}
				GameObject[] array2 = array;
				GameObject[] array3 = array2;
				foreach (GameObject item in array3)
				{
					if (!list.Contains(item))
					{
						list.Add(item);
					}
				}
			}
			return list;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

BeepInEx/plugins/Zehs-REPOLib/REPOLib.dll

Decompiled 2 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.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Commands;
using REPOLib.Extensions;
using REPOLib.Modules;
using REPOLib.Objects;
using REPOLib.Objects.Sdk;
using REPOLib.Patches;
using UnityEngine;
using UnityEngine.Audio;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Zehs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2025 Zehs")]
[assembly: AssemblyDescription("Library for adding content to R.E.P.O.")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyInformationalVersion("1.5.0+50992e22330735a42648859858c536480d3930e4")]
[assembly: AssemblyProduct("REPOLib")]
[assembly: AssemblyTitle("REPOLib")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ZehsTeam/REPOLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace REPOLib
{
	public static class BundleLoader
	{
		public static void LoadAllBundles(string root, string withExtension)
		{
			string[] files = Directory.GetFiles(root, "*" + withExtension, SearchOption.AllDirectories);
			string[] array = files;
			foreach (string text in array)
			{
				string text2 = text.Replace(root, "");
				try
				{
					LoadBundle(text, text2);
				}
				catch (Exception arg)
				{
					Logger.LogError($"Failed to load bundle at {text2}: {arg}");
				}
			}
		}

		public static void LoadBundle(string path, string relativePath)
		{
			AssetBundle val = AssetBundle.LoadFromFile(path);
			Mod[] array = val.LoadAllAssets<Mod>();
			int num = array.Length;
			if (num <= 1)
			{
				if (num == 0)
				{
					throw new Exception("Bundle contains no mods.");
				}
				Mod mod = array[0];
				Logger.LogInfo("Loading content from bundle at " + relativePath + " (" + mod.Identifier + ")");
				Content[] array2 = val.LoadAllAssets<Content>();
				Content[] array3 = array2;
				foreach (Content content in array3)
				{
					try
					{
						content.Initialize(mod);
					}
					catch (Exception arg)
					{
						throw new Exception($"Failed to load {content.Name} ({((object)content).GetType().Name}): {arg}");
					}
				}
				return;
			}
			throw new Exception("Bundle contains more than one mod.");
		}
	}
	internal static class ConfigManager
	{
		public static ConfigFile ConfigFile { get; private set; }

		public static ConfigEntry<bool> ExtendedLogging { get; private set; }

		public static ConfigEntry<bool> DeveloperMode { get; private set; }

		public static void Initialize(ConfigFile configFile)
		{
			ConfigFile = configFile;
			BindConfigs();
		}

		private static void BindConfigs()
		{
			ExtendedLogging = ConfigFile.Bind<bool>("General", "ExtendedLogging", false, "Enable extended logging.");
			DeveloperMode = ConfigFile.Bind<bool>("General", "DeveloperMode", false, "Enable developer mode cheats for testing.");
			DeveloperMode.SettingChanged += delegate
			{
				SteamManagerPatch.UpdateDeveloperMode();
			};
		}
	}
	internal static class Logger
	{
		public static ManualLogSource ManualLogSource { get; private set; }

		public static void Initialize(ManualLogSource manualLogSource)
		{
			ManualLogSource = manualLogSource;
		}

		public static void LogInfo(object data, bool extended = false)
		{
			Log((LogLevel)16, data, extended);
		}

		public static void LogWarning(object data, bool extended = false)
		{
			Log((LogLevel)4, data, extended);
		}

		public static void LogError(object data, bool extended = false)
		{
			Log((LogLevel)2, data, extended);
		}

		public static void Log(LogLevel logLevel, object data, bool extended = false)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!extended || IsExtendedLoggingEnabled())
			{
				ManualLogSource manualLogSource = ManualLogSource;
				if (manualLogSource != null)
				{
					manualLogSource.Log(logLevel, data);
				}
			}
		}

		public static bool IsExtendedLoggingEnabled()
		{
			if (ConfigManager.ExtendedLogging == null)
			{
				return false;
			}
			return ConfigManager.ExtendedLogging.Value;
		}
	}
	[BepInPlugin("REPOLib", "REPOLib", "1.5.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("REPOLib");

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			Logger.Initialize(Logger.CreateLogSource("REPOLib"));
			Logger.LogInfo("REPOLib has awoken!");
			_harmony.PatchAll(typeof(RunManagerPatch));
			_harmony.PatchAll(typeof(EnemyDirectorPatch));
			_harmony.PatchAll(typeof(StatsManagerPatch));
			_harmony.PatchAll(typeof(SemiFuncPatch));
			_harmony.PatchAll(typeof(AudioManagerPatch));
			_harmony.PatchAll(typeof(SteamManagerPatch));
			_harmony.PatchAll(typeof(EnemyGnomeDirectorPatch));
			_harmony.PatchAll(typeof(EnemyBangDirectorPatch));
			ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
			BundleLoader.LoadAllBundles(Paths.PluginPath, ".repobundle");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "REPOLib";

		public const string PLUGIN_NAME = "REPOLib";

		public const string PLUGIN_VERSION = "1.5.0";
	}
}
namespace REPOLib.Patches
{
	[HarmonyPatch(typeof(AudioManager))]
	internal static class AudioManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			Utilities.FixAudioMixerGroupsOnPrefabs();
		}
	}
	[HarmonyPatch(typeof(EnemyBangDirector))]
	internal static class EnemyBangDirectorPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> AwakeTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(typeof(EnemyBangDirector), "Setup", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(EnemyBangDirectorPatch), "PreSetup", (Type[])null, (Type[])null);
			if (methodInfo == null || methodInfo2 == null)
			{
				Logger.LogError("EnemyBangDirectorPatch: failed to find required methods for AwakeTranspiler.");
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>();
			foreach (CodeInstruction instruction in instructions)
			{
				if ((instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt) && instruction.operand is MethodInfo methodInfo3 && methodInfo3 == methodInfo)
				{
					list.Add(new CodeInstruction(OpCodes.Call, (object)methodInfo2));
					Logger.LogInfo("EnemyBangDirectorPatch: AwakeTranspiler replaced " + methodInfo.Name + " call with " + methodInfo2.Name + ".", extended: true);
				}
				else
				{
					list.Add(instruction);
				}
			}
			return list.AsEnumerable();
		}

		private static IEnumerator PreSetup(EnemyBangDirector instance)
		{
			if (LevelGenerator.Instance.Generated)
			{
				yield return (object)new WaitForSeconds(0.1f);
			}
			yield return instance.Setup();
		}
	}
	[HarmonyPatch(typeof(EnemyDirector))]
	internal static class EnemyDirectorPatch
	{
		private static bool _alreadyRegistered;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch()
		{
			if (_alreadyRegistered)
			{
				foreach (EnemySetup registeredEnemy in Enemies.RegisteredEnemies)
				{
					EnemyDirector.instance.AddEnemy(registeredEnemy);
				}
				return;
			}
			Enemies.RegisterEnemies();
			_alreadyRegistered = true;
		}
	}
	[HarmonyPatch(typeof(EnemyGnomeDirector))]
	internal static class EnemyGnomeDirectorPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> AwakeTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(typeof(EnemyGnomeDirector), "Setup", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(EnemyGnomeDirectorPatch), "PreSetup", (Type[])null, (Type[])null);
			if (methodInfo == null || methodInfo2 == null)
			{
				Logger.LogError("EnemyGnomeDirectorPatch: failed to find required methods for AwakeTranspiler.");
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>();
			foreach (CodeInstruction instruction in instructions)
			{
				if ((instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt) && instruction.operand is MethodInfo methodInfo3 && methodInfo3 == methodInfo)
				{
					list.Add(new CodeInstruction(OpCodes.Call, (object)methodInfo2));
					Logger.LogInfo("EnemyGnomeDirectorPatch: AwakeTranspiler replaced " + methodInfo.Name + " call with " + methodInfo2.Name + ".", extended: true);
				}
				else
				{
					list.Add(instruction);
				}
			}
			return list.AsEnumerable();
		}

		private static IEnumerator PreSetup(EnemyGnomeDirector instance)
		{
			if (LevelGenerator.Instance.Generated)
			{
				yield return (object)new WaitForSeconds(0.1f);
			}
			yield return instance.Setup();
		}
	}
	[HarmonyPatch(typeof(RunManager))]
	internal static class RunManagerPatch
	{
		private static bool _patchedAwake;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void AwakePatch()
		{
			if (!_patchedAwake)
			{
				_patchedAwake = true;
				NetworkPrefabs.Initialize();
				NetworkingEvents.Initialize();
				Valuables.RegisterValuables();
				CommandManager.Initialize();
			}
		}
	}
	[HarmonyPatch(typeof(SemiFunc))]
	internal static class SemiFuncPatch
	{
		[HarmonyPatch("Command")]
		[HarmonyPrefix]
		private static bool CommandPatch(string _command)
		{
			if (_command.StartsWith("/"))
			{
				return Command(_command);
			}
			return true;
		}

		private static bool Command(string message)
		{
			string text = message.ToLower();
			string text2 = text.Split(' ')[0].Substring(1);
			string text3 = "";
			if (text.Length > text2.Length)
			{
				text3 = text.Substring(text2.Length + 1).Trim();
			}
			CommandManager.CommandExecutionMethods.TryGetValue(text2, out var value);
			if (value != null)
			{
				CommandExecutionAttribute customAttribute = value.GetCustomAttribute<CommandExecutionAttribute>();
				if (CommandManager.CommandsEnabled.TryGetValue(customAttribute.Name, out var value2) && !value2)
				{
					return false;
				}
				if (customAttribute != null && customAttribute.RequiresDeveloperMode && !SteamManager.instance.developerMode)
				{
					Logger.LogWarning("Command " + text2 + " requires developer mode to be enabled. Enable it in REPOLib.cfg");
					return false;
				}
				try
				{
					ParameterInfo[] parameters = value.GetParameters();
					if (parameters.Length == 0)
					{
						value.Invoke(null, null);
					}
					else
					{
						value.Invoke(null, new object[1] { text3 });
					}
				}
				catch (Exception arg)
				{
					Logger.LogError($"Error executing command: {arg}");
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch("EnemySpawn")]
		[HarmonyPrefix]
		private static bool EnemySpawnPatch(ref bool __result)
		{
			if (Enemies.SpawnNextEnemiesNotDespawned > 0)
			{
				Enemies.SpawnNextEnemiesNotDespawned--;
				__result = true;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StatsManager))]
	internal static class StatsManagerPatch
	{
		[HarmonyPatch("RunStartStats")]
		[HarmonyPostfix]
		private static void RunStartStatsPatch()
		{
			Items.RegisterItems();
		}
	}
	[HarmonyPatch(typeof(SteamManager))]
	internal static class SteamManagerPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void AwakePatch(SteamManager __instance)
		{
			UpdateDeveloperMode();
		}

		public static void UpdateDeveloperMode()
		{
			if (ConfigManager.DeveloperMode == null || (Object)(object)SteamManager.instance == (Object)null)
			{
				return;
			}
			bool value = ConfigManager.DeveloperMode.Value;
			if (SteamManager.instance.developerMode != value)
			{
				if (value)
				{
					Logger.LogInfo("Enabling developer mode in SteamManager.");
				}
				else
				{
					Logger.LogInfo("Disabling developer mode in SteamManager.");
				}
			}
			SteamManager.instance.developerMode = value;
		}
	}
}
namespace REPOLib.Objects
{
	public class CustomPrefabPool : IPunPrefabPool
	{
		public readonly Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>();

		private DefaultPool _defaultPool;

		private IPunPrefabPool _otherPool;

		public DefaultPool DefaultPool
		{
			get
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Expected O, but got Unknown
				if (_defaultPool == null)
				{
					_defaultPool = new DefaultPool();
				}
				return _defaultPool;
			}
			set
			{
				if (value != null)
				{
					_defaultPool = value;
				}
			}
		}

		public IPunPrefabPool OtherPool
		{
			get
			{
				return _otherPool;
			}
			set
			{
				if (!(value is DefaultPool) && !(value is CustomPrefabPool))
				{
					_otherPool = value;
				}
			}
		}

		public bool RegisterPrefab(string prefabId, GameObject prefab)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab == (Object)null)
			{
				throw new ArgumentException("CustomPrefabPool: failed to register network prefab. Prefab is null.");
			}
			if (string.IsNullOrWhiteSpace(prefabId))
			{
				throw new ArgumentException("CustomPrefabPool: failed to register network prefab. PrefabId is invalid.");
			}
			if (ResourcesHelper.HasPrefab(prefabId))
			{
				Logger.LogError("CustomPrefabPool: failed to register network prefab \"" + prefabId + "\". Prefab already exists in Resources with the same prefab id.");
				return false;
			}
			if (Prefabs.TryGetValue(prefabId, out var value, ignoreKeyCase: true))
			{
				LogLevel logLevel = (LogLevel)(((Object)(object)value == (Object)(object)prefab) ? 4 : 2);
				Logger.Log(logLevel, "CustomPrefabPool: failed to register network prefab \"" + prefabId + "\". There is already a prefab registered with the same prefab id.");
				return false;
			}
			Prefabs[prefabId] = prefab;
			Logger.LogInfo("CustomPrefabPool: registered network prefab \"" + prefabId + "\"", extended: true);
			return true;
		}

		public bool HasPrefab(GameObject prefab)
		{
			if (Prefabs.ContainsValue(prefab))
			{
				return true;
			}
			if (ResourcesHelper.HasPrefab(prefab))
			{
				return true;
			}
			return false;
		}

		public bool HasPrefab(string prefabId)
		{
			if (Prefabs.ContainsKey(prefabId, ignoreKeyCase: true))
			{
				return true;
			}
			if (ResourcesHelper.HasPrefab(prefabId))
			{
				return true;
			}
			return false;
		}

		public string GetPrefabId(GameObject prefab)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				Logger.LogError("Failed to get prefab id. GameObject is null.");
				return string.Empty;
			}
			return Prefabs.GetKeyOrDefault(prefab);
		}

		public GameObject GetPrefab(string prefabId)
		{
			return Prefabs.GetValueOrDefault(prefabId, ignoreKeyCase: true);
		}

		public GameObject Instantiate(string prefabId, Vector3 position, Quaternion rotation)
		{
			//IL_0018: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			GameObject val;
			if (!Prefabs.TryGetValue(prefabId, out var value, ignoreKeyCase: true))
			{
				val = DefaultPool.Instantiate(prefabId, position, rotation);
				if ((Object)(object)val == (Object)null && OtherPool != null)
				{
					val = OtherPool.Instantiate(prefabId, position, rotation);
				}
				return val;
			}
			bool activeSelf = value.activeSelf;
			if (activeSelf)
			{
				value.SetActive(false);
			}
			val = Object.Instantiate<GameObject>(value, position, rotation);
			if (activeSelf)
			{
				value.SetActive(true);
			}
			Logger.LogInfo($"CustomPrefabPool: spawned network prefab \"{prefabId}\" at position {position}, rotation {((Quaternion)(ref rotation)).eulerAngles}", extended: true);
			return val;
		}

		public void Destroy(GameObject gameObject)
		{
			Object.Destroy((Object)(object)gameObject);
		}
	}
	public class UnityObjectNameComparer<T> : IEqualityComparer<T> where T : Object
	{
		public StringComparison ComparisonType { get; private set; }

		public UnityObjectNameComparer(StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
		{
			ComparisonType = comparisonType;
		}

		public bool Equals(T x, T y)
		{
			if ((Object)(object)x == (Object)(object)y)
			{
				return true;
			}
			if ((Object)(object)x == (Object)null || (Object)(object)y == (Object)null)
			{
				return false;
			}
			return ((Object)x).name.Equals(((Object)y).name, ComparisonType);
		}

		public int GetHashCode(T obj)
		{
			if (!((Object)(object)obj != (Object)null))
			{
				return 0;
			}
			return ((Object)obj).name.GetHashCode();
		}
	}
}
namespace REPOLib.Objects.Sdk
{
	public abstract class Content : ScriptableObject
	{
		public abstract string Name { get; }

		public abstract void Initialize(Mod mod);
	}
	[CreateAssetMenu(menuName = "REPOLib/Enemy", order = 3, fileName = "New Enemy")]
	public class EnemyContent : Content
	{
		[SerializeField]
		private EnemySetup _setup;

		public EnemySetup Setup => _setup;

		public override string Name => ((Object)Setup).name;

		public override void Initialize(Mod mod)
		{
			Enemies.RegisterEnemy(Setup);
		}
	}
	[CreateAssetMenu(menuName = "REPOLib/Item", order = 2, fileName = "New Item")]
	public class ItemContent : Content
	{
		[SerializeField]
		private ItemAttributes _prefab;

		public ItemAttributes Prefab => _prefab;

		public override string Name => ((Object)Prefab).name;

		public override void Initialize(Mod mod)
		{
			_prefab.item.prefab = ((Component)_prefab).gameObject;
			Items.RegisterItem(Prefab.item);
		}
	}
	[CreateAssetMenu(menuName = "REPOLib/Mod", order = 0, fileName = "New Mod")]
	public class Mod : ScriptableObject
	{
		[SerializeField]
		private string _name;

		[SerializeField]
		private string _author;

		[SerializeField]
		private string _version = "1.0.0";

		[SerializeField]
		private string _description;

		[SerializeField]
		private string _websiteUrl;

		[SerializeField]
		private string[] _dependencies = new string[1] { "Zehs-REPOLib-1.5.0" };

		[SerializeField]
		private Sprite _icon;

		[SerializeField]
		private TextAsset _readme;

		public string Name => _name;

		public string Author => _author;

		public string Version => _version;

		public string Description => _description;

		public string WebsiteUrl => _websiteUrl;

		public IReadOnlyList<string> Dependencies => _dependencies;

		public Sprite Icon => _icon;

		public TextAsset Readme => _readme;

		public string FullName => Author + "-" + Name;

		public string Identifier => Author + "-" + Name + "-" + Version;
	}
	[CreateAssetMenu(menuName = "REPOLib/Valuable", order = 1, fileName = "New Valuable")]
	public class ValuableContent : Content
	{
		[SerializeField]
		private ValuableObject _prefab;

		[SerializeField]
		private string[] _valuablePresets = new string[1] { Valuables.GenericValuablePresetName };

		public ValuableObject Prefab => _prefab;

		public IReadOnlyList<string> ValuablePresets => _valuablePresets;

		public override string Name => ((Object)Prefab).name;

		public override void Initialize(Mod mod)
		{
			Valuables.RegisterValuable(((Component)Prefab).gameObject, ValuablePresets.ToList());
		}
	}
}
namespace REPOLib.Modules
{
	public static class Enemies
	{
		internal static int SpawnNextEnemiesNotDespawned = 0;

		private static readonly List<EnemySetup> _enemiesToRegister = new List<EnemySetup>();

		private static readonly List<EnemySetup> _enemiesRegistered = new List<EnemySetup>();

		private static bool _canRegisterEnemies = true;

		public static IReadOnlyList<EnemySetup> AllEnemies => GetEnemies();

		public static IReadOnlyList<EnemySetup> RegisteredEnemies => _enemiesRegistered;

		internal static void RegisterEnemies()
		{
			if (!_canRegisterEnemies)
			{
				return;
			}
			EnemyParent val = default(EnemyParent);
			foreach (EnemySetup item in _enemiesToRegister)
			{
				if (!_enemiesRegistered.Contains(item) && item.spawnObjects[0].TryGetComponent<EnemyParent>(ref val))
				{
					if (EnemyDirector.instance.AddEnemy(item))
					{
						_enemiesRegistered.Add(item);
						Logger.LogInfo("Added enemy \"" + ((Object)item.spawnObjects[0]).name + "\" to difficulty " + ((object)(Difficulty)(ref val.difficulty)).ToString(), extended: true);
					}
					else
					{
						Logger.LogWarning("Failed to add enemy \"" + ((Object)item.spawnObjects[0]).name + "\" to difficulty " + ((object)(Difficulty)(ref val.difficulty)).ToString(), extended: true);
					}
				}
			}
			_enemiesToRegister.Clear();
			_canRegisterEnemies = false;
		}

		public static void RegisterEnemy(EnemySetup enemySetup)
		{
			if ((Object)(object)enemySetup == (Object)null || enemySetup.spawnObjects == null || enemySetup.spawnObjects.Count == 0)
			{
				throw new ArgumentException("Failed to register enemy. EnemySetup or spawnObjects list is empty.");
			}
			EnemyParent enemyParent = enemySetup.GetEnemyParent();
			if ((Object)(object)enemyParent == (Object)null)
			{
				Logger.LogError("Failed to register enemy \"" + ((Object)enemySetup).name + "\". No enemy prefab found in spawnObjects list.");
				return;
			}
			if (!_canRegisterEnemies)
			{
				Logger.LogError("Failed to register enemy \"" + enemyParent.enemyName + "\". You can only register enemies in awake!");
			}
			if (ResourcesHelper.HasEnemyPrefab(enemySetup))
			{
				Logger.LogError("Failed to register enemy \"" + enemyParent.enemyName + "\". Enemy prefab already exists in Resources with the same name.");
				return;
			}
			if (_enemiesToRegister.Contains(enemySetup))
			{
				Logger.LogError("Failed to register enemy \"" + enemyParent.enemyName + "\". Enemy is already registered!");
				return;
			}
			foreach (GameObject distinctSpawnObject in enemySetup.GetDistinctSpawnObjects())
			{
				foreach (EnemySetup item in _enemiesToRegister)
				{
					if (item.AnySpawnObjectsNameEqualsThatIsNotTheSameObject(distinctSpawnObject))
					{
						Logger.LogError("Failed to register enemy \"" + enemyParent.enemyName + "\". Enemy \"" + ((Object)item).name + "\" already has a spawn object called \"" + ((Object)distinctSpawnObject).name + "\"");
						return;
					}
				}
			}
			foreach (GameObject distinctSpawnObject2 in enemySetup.GetDistinctSpawnObjects())
			{
				string enemyPrefabPath = ResourcesHelper.GetEnemyPrefabPath(distinctSpawnObject2);
				if (!NetworkPrefabs.HasNetworkPrefab(enemyPrefabPath))
				{
					NetworkPrefabs.RegisterNetworkPrefab(enemyPrefabPath, distinctSpawnObject2);
				}
				Utilities.FixAudioMixerGroups(distinctSpawnObject2);
			}
			_enemiesToRegister.Add(enemySetup);
		}

		public static List<EnemyParent> SpawnEnemy(EnemySetup enemySetup, Vector3 position, Quaternion rotation, bool spawnDespawned = true)
		{
			//IL_00fd: 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_023e: 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)
			if ((Object)(object)enemySetup == (Object)null)
			{
				Logger.LogError("Failed to spawn enemy. EnemySetup is null.");
				return null;
			}
			if (!enemySetup.TryGetEnemyParent(out var enemyParent))
			{
				Logger.LogError("Failed to spawn enemy. EnemyParent is null.");
				return null;
			}
			if ((Object)(object)LevelGenerator.Instance == (Object)null)
			{
				Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\". EnemySetup instance is null.");
				return null;
			}
			if ((Object)(object)RunManager.instance == (Object)null)
			{
				Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\". RunManager instance is null.");
				return null;
			}
			if ((Object)(object)EnemyDirector.instance == (Object)null)
			{
				Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\". EnemyDirector instance is null.");
				return null;
			}
			List<EnemyParent> list = new List<EnemyParent>();
			EnemyParent val2 = default(EnemyParent);
			foreach (GameObject sortedSpawnObject in enemySetup.GetSortedSpawnObjects())
			{
				if ((Object)(object)sortedSpawnObject == (Object)null)
				{
					Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\" spawn object. GameObject is null.");
					continue;
				}
				string enemyPrefabPath = ResourcesHelper.GetEnemyPrefabPath(sortedSpawnObject);
				GameObject val = NetworkPrefabs.SpawnNetworkPrefab(enemyPrefabPath, position, rotation, 0);
				if ((Object)(object)val == (Object)null)
				{
					Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\" spawn object \"" + ((Object)sortedSpawnObject).name + "\"");
				}
				else if (val.TryGetComponent<EnemyParent>(ref val2))
				{
					list.Add(val2);
					SpawnNextEnemiesNotDespawned++;
					val2.SetupDone = true;
					Enemy componentInChildren = val.GetComponentInChildren<Enemy>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.EnemyTeleported(position);
					}
					else
					{
						Logger.LogError("Enemy \"" + enemyParent.enemyName + "\" spawn object \"" + ((Object)sortedSpawnObject).name + "\" does not have an enemy component.");
					}
					LevelGenerator instance = LevelGenerator.Instance;
					instance.EnemiesSpawnTarget++;
					EnemyDirector.instance.FirstSpawnPointAdd(val2);
				}
			}
			if (list.Count == 0)
			{
				Logger.LogInfo("Failed to spawn enemy \"" + enemyParent.enemyName + "\". No spawn objects where spawned.", extended: true);
				return list;
			}
			Logger.LogInfo($"Spawned enemy \"{enemyParent.enemyName}\" at position {position}", extended: true);
			RunManager.instance.EnemiesSpawnedRemoveEnd();
			return list;
		}

		public static IReadOnlyList<EnemySetup> GetEnemies()
		{
			if ((Object)(object)EnemyDirector.instance == (Object)null)
			{
				return Array.Empty<EnemySetup>();
			}
			return EnemyDirector.instance.GetEnemies();
		}

		public static bool TryGetEnemyByName(string name, out EnemySetup enemySetup)
		{
			enemySetup = GetEnemyByName(name);
			return (Object)(object)enemySetup != (Object)null;
		}

		public static EnemySetup GetEnemyByName(string name)
		{
			return EnemyDirector.instance?.GetEnemyByName(name);
		}

		public static bool TryGetEnemyThatContainsName(string name, out EnemySetup enemySetup)
		{
			enemySetup = GetEnemyThatContainsName(name);
			return (Object)(object)enemySetup != (Object)null;
		}

		public static EnemySetup GetEnemyThatContainsName(string name)
		{
			return EnemyDirector.instance?.GetEnemyThatContainsName(name);
		}
	}
	public static class Items
	{
		private static readonly List<Item> _itemsToRegister = new List<Item>();

		private static readonly List<Item> _itemsRegistered = new List<Item>();

		private static bool _canRegisterItems = true;

		public static IReadOnlyList<Item> AllItems => GetItems();

		public static IReadOnlyList<Item> RegisteredItems => _itemsRegistered;

		internal static void RegisterItems()
		{
			if ((Object)(object)StatsManager.instance == (Object)null)
			{
				Logger.LogError("Failed to register items. StatsManager instance is null.");
				return;
			}
			Logger.LogInfo("Adding items.");
			foreach (Item item in _itemsToRegister)
			{
				if (StatsManager.instance.AddItem(item))
				{
					if (!_itemsRegistered.Contains(item))
					{
						_itemsRegistered.Add(item);
					}
					Logger.LogInfo("Added item \"" + item.itemName + "\"", extended: true);
				}
				else
				{
					Logger.LogWarning("Failed to add item \"" + item.itemName + "\"", extended: true);
				}
			}
			_canRegisterItems = false;
		}

		public static void RegisterItem(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				throw new ArgumentException("Failed to register item. Item is null.");
			}
			if ((Object)(object)item.prefab == (Object)null)
			{
				Logger.LogError("Failed to register item \"" + item.itemName + "\". Item prefab is null.");
				return;
			}
			if (item.itemAssetName != ((Object)item.prefab).name)
			{
				Logger.LogError("Failed to register item \"" + item.itemName + "\". Item itemAssetName does not match the prefab name.");
				return;
			}
			if (!_canRegisterItems)
			{
				Logger.LogError("Failed to register item \"" + item.itemName + "\". You can only register items from your plugins awake!");
				return;
			}
			if (ResourcesHelper.HasItemPrefab(item))
			{
				Logger.LogError("Failed to register item \"" + item.itemName + "\". Item prefab already exists in Resources with the same name.");
				return;
			}
			if (_itemsToRegister.Any((Item x) => x.itemAssetName == item.itemAssetName))
			{
				Logger.LogError("Failed to register item \"" + item.itemName + "\". Item prefab already exists with the same name.");
				return;
			}
			if (_itemsToRegister.Contains(item))
			{
				Logger.LogError("Failed to register item \"" + item.itemName + "\". Item is already registered!");
				return;
			}
			string itemPrefabPath = ResourcesHelper.GetItemPrefabPath(item);
			NetworkPrefabs.RegisterNetworkPrefab(itemPrefabPath, item.prefab);
			Utilities.FixAudioMixerGroups(item.prefab);
			_itemsToRegister.Add(item);
		}

		public static GameObject SpawnItem(Item item, Vector3 position, Quaternion rotation)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null)
			{
				Logger.LogError("Failed to spawn item. Item is null.");
				return null;
			}
			if ((Object)(object)item.prefab == (Object)null)
			{
				Logger.LogError("Failed to spawn item. Prefab is null.");
				return null;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				Logger.LogError("Failed to spawn item \"" + item.itemName + "\". You are not the host.");
				return null;
			}
			string itemPrefabPath = ResourcesHelper.GetItemPrefabPath(item);
			GameObject val = NetworkPrefabs.SpawnNetworkPrefab(itemPrefabPath, position, rotation, 0);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError("Failed to spawn item \"" + item.itemName + "\"");
				return null;
			}
			Logger.LogInfo($"Spawned item \"{item.itemName}\" at position {position}, rotation: {((Quaternion)(ref rotation)).eulerAngles}", extended: true);
			return val;
		}

		public static IReadOnlyList<Item> GetItems()
		{
			if ((Object)(object)StatsManager.instance == (Object)null)
			{
				return Array.Empty<Item>();
			}
			return StatsManager.instance.GetItems();
		}

		public static bool TryGetItemByName(string name, out Item item)
		{
			item = GetItemByName(name);
			return (Object)(object)item != (Object)null;
		}

		public static Item GetItemByName(string name)
		{
			return StatsManager.instance?.GetItemByName(name);
		}

		public static bool TryGetItemThatContainsName(string name, out Item item)
		{
			item = GetItemThatContainsName(name);
			return (Object)(object)item != (Object)null;
		}

		public static Item GetItemThatContainsName(string name)
		{
			return StatsManager.instance?.GetItemThatContainsName(name);
		}
	}
	public static class NetworkingEvents
	{
		public static readonly byte[] ReservedEventCodes = new byte[3] { 0, 1, 2 };

		private static readonly List<NetworkedEvent> _customEvents = new List<NetworkedEvent>();

		public static readonly RaiseEventOptions RaiseAll = new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)1
		};

		public static readonly RaiseEventOptions RaiseOthers = new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)0
		};

		public static readonly RaiseEventOptions RaiseMasterClient = new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)2
		};

		public static IReadOnlyList<NetworkedEvent> CustomEvents => _customEvents;

		internal static void Initialize()
		{
			PhotonNetwork.NetworkingClient.EventReceived += OnEvent;
			Application.quitting += delegate
			{
				PhotonNetwork.NetworkingClient.EventReceived -= OnEvent;
			};
		}

		internal static void AddCustomEvent(NetworkedEvent networkedEvent)
		{
			if (!_customEvents.Contains(networkedEvent))
			{
				_customEvents.Add(networkedEvent);
			}
		}

		private static void OnEvent(EventData photonEvent)
		{
			_customEvents.FirstOrDefault((NetworkedEvent e) => e.EventCode == photonEvent.Code)?.EventAction?.Invoke(photonEvent);
		}

		internal static bool TryGetUniqueEventCode(out byte eventCode)
		{
			eventCode = 0;
			while (IsEventCodeTaken(eventCode) && eventCode < 200)
			{
				eventCode++;
			}
			if (eventCode > 200 || (eventCode == 200 && IsEventCodeTaken(eventCode)))
			{
				eventCode = 0;
				return false;
			}
			return true;
		}

		public static bool IsEventCodeTaken(byte eventCode)
		{
			if (ReservedEventCodes.Any((byte x) => x == eventCode))
			{
				return true;
			}
			if (_customEvents.Any((NetworkedEvent x) => x.EventCode == eventCode))
			{
				return true;
			}
			return false;
		}
	}
	public class NetworkedEvent
	{
		public string Name { get; private set; }

		public byte EventCode { get; private set; }

		public Action<EventData> EventAction { get; private set; }

		public NetworkedEvent(string name, Action<EventData> eventAction)
		{
			Name = name;
			EventAction = eventAction;
			if (NetworkingEvents.TryGetUniqueEventCode(out var eventCode))
			{
				EventCode = eventCode;
				NetworkingEvents.AddCustomEvent(this);
				Logger.LogInfo($"Registered NetworkedEvent \"{Name}\" with event code: {EventCode}", extended: true);
			}
			else
			{
				Logger.LogError("Failed to register NetworkedEvent \"" + Name + "\". Could not get unique event code.");
			}
		}

		public void RaiseEvent(object eventContent, RaiseEventOptions raiseEventOptions, SendOptions sendOptions)
		{
			//IL_0018: 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)
			if (SemiFunc.IsMultiplayer())
			{
				PhotonNetwork.RaiseEvent(EventCode, eventContent, raiseEventOptions, sendOptions);
			}
			else if ((int)raiseEventOptions.Receivers != 0)
			{
				RaiseEventSingleplayer(eventContent);
			}
		}

		private void RaiseEventSingleplayer(object eventContent)
		{
			//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_001a: Expected O, but got Unknown
			if (!SemiFunc.IsMultiplayer())
			{
				EventData val = new EventData
				{
					Code = EventCode
				};
				val.Parameters[val.CustomDataKey] = eventContent;
				val.Parameters[val.SenderKey] = 1;
				EventAction?.Invoke(val);
			}
		}
	}
	public static class NetworkPrefabs
	{
		private static CustomPrefabPool _customPrefabPool;

		internal static CustomPrefabPool CustomPrefabPool
		{
			get
			{
				if (_customPrefabPool == null)
				{
					_customPrefabPool = new CustomPrefabPool();
				}
				return _customPrefabPool;
			}
			private set
			{
				_customPrefabPool = value;
			}
		}

		internal static void Initialize()
		{
			if (PhotonNetwork.PrefabPool is CustomPrefabPool)
			{
				Logger.LogWarning("NetworkPrefabs failed to initialize. PhotonNetwork.PrefabPool is already a CustomPrefabPool.");
				return;
			}
			Logger.LogInfo("Initializing NetworkPrefabs.");
			Logger.LogInfo($"PhotonNetwork.PrefabPool = {((object)PhotonNetwork.PrefabPool).GetType()}", extended: true);
			IPunPrefabPool prefabPool = PhotonNetwork.PrefabPool;
			DefaultPool val = (DefaultPool)(object)((prefabPool is DefaultPool) ? prefabPool : null);
			if (val != null)
			{
				CustomPrefabPool.DefaultPool = val;
			}
			else
			{
				CustomPrefabPool.OtherPool = PhotonNetwork.PrefabPool;
			}
			PhotonNetwork.PrefabPool = (IPunPrefabPool)(object)CustomPrefabPool;
			Logger.LogInfo("Replaced PhotonNetwork.PrefabPool with CustomPrefabPool.");
			Logger.LogInfo($"PhotonNetwork.PrefabPool = {((object)PhotonNetwork.PrefabPool).GetType()}", extended: true);
			Logger.LogInfo("Finished initializing NetworkPrefabs.");
		}

		public static void RegisterNetworkPrefab(GameObject prefab)
		{
			RegisterNetworkPrefab((prefab != null) ? ((Object)prefab).name : null, prefab);
		}

		public static void RegisterNetworkPrefab(string prefabId, GameObject prefab)
		{
			CustomPrefabPool.RegisterPrefab(prefabId, prefab);
		}

		public static bool HasNetworkPrefab(string prefabId)
		{
			return CustomPrefabPool.HasPrefab(prefabId);
		}

		public static GameObject SpawnNetworkPrefab(string prefabId, Vector3 position, Quaternion rotation, byte group = 0, object[] data = null)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(prefabId))
			{
				Logger.LogError("Failed to spawn network prefab. PrefabId is null.");
				return null;
			}
			if (!HasNetworkPrefab(prefabId))
			{
				Logger.LogError("Failed to spawn network prefab \"" + prefabId + "\". PrefabId is not registered as a network prefab.");
				return null;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				Logger.LogError("Failed to spawn network prefab \"" + prefabId + "\". You are not the host.");
				return null;
			}
			if (SemiFunc.IsMultiplayer())
			{
				return PhotonNetwork.InstantiateRoomObject(prefabId, position, rotation, group, data);
			}
			return Object.Instantiate<GameObject>(CustomPrefabPool.GetPrefab(prefabId), position, rotation);
		}
	}
	public static class ResourcesHelper
	{
		public static string GetValuablesFolderPath(Type volumeType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			return Path.Combine("Valuables/", (int)volumeType switch
			{
				0 => "01 Tiny/", 
				1 => "02 Small/", 
				2 => "03 Medium/", 
				3 => "04 Big/", 
				4 => "05 Wide/", 
				5 => "06 Tall/", 
				6 => "07 Very Tall/", 
				_ => string.Empty, 
			});
		}

		public static string GetItemsFolderPath()
		{
			return "Items/";
		}

		public static string GetEnemiesFolderPath()
		{
			return "Enemies/";
		}

		public static string GetValuablePrefabPath(ValuableObject valuableObject)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)valuableObject == (Object)null)
			{
				return string.Empty;
			}
			string valuablesFolderPath = GetValuablesFolderPath(valuableObject.volumeType);
			return Path.Combine(valuablesFolderPath, ((Object)((Component)valuableObject).gameObject).name);
		}

		public static string GetValuablePrefabPath(GameObject prefab)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				return string.Empty;
			}
			ValuableObject valuableObject = default(ValuableObject);
			if (prefab.TryGetComponent<ValuableObject>(ref valuableObject))
			{
				return GetValuablePrefabPath(valuableObject);
			}
			return string.Empty;
		}

		public static string GetItemPrefabPath(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return string.Empty;
			}
			return GetItemPrefabPath(item.prefab);
		}

		public static string GetItemPrefabPath(GameObject prefab)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				return string.Empty;
			}
			string itemsFolderPath = GetItemsFolderPath();
			return Path.Combine(itemsFolderPath, ((Object)prefab).name);
		}

		public static string GetEnemyPrefabPath(EnemySetup enemySetup)
		{
			if ((Object)(object)enemySetup == (Object)null || enemySetup.spawnObjects == null)
			{
				return string.Empty;
			}
			GameObject mainSpawnObject = enemySetup.GetMainSpawnObject();
			if ((Object)(object)mainSpawnObject == (Object)null)
			{
				return string.Empty;
			}
			string enemiesFolderPath = GetEnemiesFolderPath();
			return Path.Combine(enemiesFolderPath, ((Object)mainSpawnObject).name);
		}

		public static string GetEnemyPrefabPath(GameObject prefab)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				return string.Empty;
			}
			string enemiesFolderPath = GetEnemiesFolderPath();
			return Path.Combine(enemiesFolderPath, ((Object)prefab).name);
		}

		public static bool HasValuablePrefab(ValuableObject valuableObject)
		{
			if ((Object)(object)valuableObject == (Object)null)
			{
				return false;
			}
			string valuablePrefabPath = GetValuablePrefabPath(valuableObject);
			return (Object)(object)Resources.Load<GameObject>(valuablePrefabPath) != (Object)null;
		}

		public static bool HasItemPrefab(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			string itemPrefabPath = GetItemPrefabPath(item);
			return (Object)(object)Resources.Load<GameObject>(itemPrefabPath) != (Object)null;
		}

		public static bool HasEnemyPrefab(EnemySetup enemySetup)
		{
			if ((Object)(object)enemySetup == (Object)null)
			{
				return false;
			}
			foreach (GameObject distinctSpawnObject in enemySetup.GetDistinctSpawnObjects())
			{
				string enemyPrefabPath = GetEnemyPrefabPath(distinctSpawnObject);
				if ((Object)(object)Resources.Load<GameObject>(enemyPrefabPath) != (Object)null)
				{
					return true;
				}
			}
			return false;
		}

		public static bool HasPrefab(GameObject prefab)
		{
			return (Object)(object)Resources.Load<GameObject>((prefab != null) ? ((Object)prefab).name : null) != (Object)null;
		}

		public static bool HasPrefab(string prefabId)
		{
			return (Object)(object)Resources.Load<GameObject>(prefabId) != (Object)null;
		}
	}
	public static class Utilities
	{
		private static readonly List<GameObject> _prefabsToFix = new List<GameObject>();

		private static readonly List<GameObject> _fixedPrefabs = new List<GameObject>();

		internal static void FixAudioMixerGroupsOnPrefabs()
		{
			foreach (GameObject item in _prefabsToFix)
			{
				item.FixAudioMixerGroups();
				_fixedPrefabs.Add(item);
			}
			_prefabsToFix.Clear();
		}

		public static void FixAudioMixerGroups(GameObject prefab)
		{
			if (!((Object)(object)prefab == (Object)null) && !_prefabsToFix.Contains(prefab) && !_fixedPrefabs.Contains(prefab))
			{
				if ((Object)(object)AudioManager.instance == (Object)null)
				{
					_prefabsToFix.Add(prefab);
					return;
				}
				prefab.FixAudioMixerGroups();
				_fixedPrefabs.Add(prefab);
			}
		}
	}
	public static class Valuables
	{
		private static readonly Dictionary<string, LevelValuables> _valuablePresets = new Dictionary<string, LevelValuables>();

		private static readonly Dictionary<GameObject, List<string>> _valuablesToRegister = new Dictionary<GameObject, List<string>>();

		private static readonly List<GameObject> _valuablesRegistered = new List<GameObject>();

		private static bool _canRegisterValuables = true;

		public static IReadOnlyList<GameObject> AllValuables => GetValuables();

		public static IReadOnlyList<GameObject> RegisteredValuables => _valuablesRegistered;

		public static IReadOnlyList<LevelValuables> ValuablePresets => _valuablePresets.Values.ToList();

		public static string GenericValuablePresetName => "Valuables - Generic";

		private static void CacheValuablePresets()
		{
			if ((Object)(object)RunManager.instance == (Object)null)
			{
				Logger.LogError("Failed to cache LevelValuables. RunManager instance is null.");
				return;
			}
			foreach (Level level in RunManager.instance.levels)
			{
				foreach (LevelValuables valuablePreset in level.ValuablePresets)
				{
					_valuablePresets.TryAdd(((Object)valuablePreset).name, valuablePreset);
				}
			}
		}

		internal static void RegisterValuables()
		{
			if (!_canRegisterValuables)
			{
				return;
			}
			CacheValuablePresets();
			if (_valuablePresets.Count == 0)
			{
				Logger.LogError("Failed to register valuables. LevelValuables list is empty!");
				return;
			}
			Logger.LogInfo("Adding valuables to valuable presets.");
			foreach (GameObject key in _valuablesToRegister.Keys)
			{
				if (_valuablesRegistered.Contains(key))
				{
					continue;
				}
				List<string> list = _valuablesToRegister[key];
				if (!list.Any((string x) => _valuablePresets.Keys.Any((string y) => x == y)))
				{
					Logger.LogError("Valuable \"" + ((Object)key).name + "\" does not have any valid valuable preset names set. Adding generic valuable preset name.");
					list.Add(GenericValuablePresetName);
				}
				foreach (string item in list)
				{
					if (item == null || !_valuablePresets.ContainsKey(item))
					{
						Logger.LogError("Failed to add valuable \"" + ((Object)key).name + "\" to valuable preset \"" + item + "\". The valuable preset does not exist.");
					}
					else if (_valuablePresets[item].AddValuable(key))
					{
						_valuablesRegistered.Add(key);
						Logger.LogInfo("Added valuable \"" + ((Object)key).name + "\" to valuable preset \"" + item + "\"", extended: true);
					}
					else
					{
						Logger.LogWarning("Failed to add valuable \"" + ((Object)key).name + "\" to valuable preset \"" + item + "\"", extended: true);
					}
				}
			}
			_valuablesToRegister.Clear();
			_canRegisterValuables = false;
		}

		public static void RegisterValuable(GameObject prefab)
		{
			RegisterValuable(prefab, new List<string>());
		}

		public static void RegisterValuable(GameObject prefab, List<LevelValuables> presets)
		{
			RegisterValuable(prefab, presets.Select((LevelValuables preset) => ((Object)preset).name).ToList());
		}

		public static void RegisterValuable(GameObject prefab, List<string> presetNames)
		{
			ValuableObject valuableObject = default(ValuableObject);
			if ((Object)(object)prefab == (Object)null)
			{
				Logger.LogError("Failed to register valuable. Prefab is null.");
			}
			else if (!prefab.TryGetComponent<ValuableObject>(ref valuableObject))
			{
				Logger.LogError("Failed to register valuable. Prefab does not have a ValuableObject component.");
			}
			else
			{
				RegisterValuable(valuableObject, presetNames);
			}
		}

		public static void RegisterValuable(ValuableObject valuableObject)
		{
			RegisterValuable(valuableObject, new List<string>());
		}

		public static void RegisterValuable(ValuableObject valuableObject, List<LevelValuables> presets)
		{
			RegisterValuable(valuableObject, presets.Select((LevelValuables preset) => ((Object)preset).name).ToList());
		}

		public static void RegisterValuable(ValuableObject valuableObject, List<string> presetNames)
		{
			if ((Object)(object)valuableObject == (Object)null)
			{
				Logger.LogError("Failed to register valuable. ValuableObject is null.");
				return;
			}
			GameObject prefab = ((Component)valuableObject).gameObject;
			if (presetNames == null || presetNames.Count == 0)
			{
				presetNames = new List<string>(1) { GenericValuablePresetName };
			}
			if (!_canRegisterValuables)
			{
				Logger.LogError("Failed to register valuable \"" + ((Object)prefab).name + "\". You can only register valuables from your plugins awake!");
				return;
			}
			if (ResourcesHelper.HasValuablePrefab(valuableObject))
			{
				Logger.LogError("Failed to register valuable \"" + ((Object)prefab).name + "\". Valuable prefab already exists in Resources with the same name.");
				return;
			}
			if (_valuablesToRegister.Keys.Any((GameObject x) => ((Object)x).name.Equals(((Object)prefab).name, StringComparison.OrdinalIgnoreCase)))
			{
				Logger.LogError("Failed to register valuable \"" + ((Object)prefab).name + "\". Valuable prefab already exists with the same name.");
				return;
			}
			if (_valuablesToRegister.ContainsKey(prefab))
			{
				Logger.LogWarning("Failed to register valuable \"" + ((Object)prefab).name + "\". Valuable is already registered!");
				return;
			}
			string valuablePrefabPath = ResourcesHelper.GetValuablePrefabPath(valuableObject);
			NetworkPrefabs.RegisterNetworkPrefab(valuablePrefabPath, prefab);
			Utilities.FixAudioMixerGroups(prefab);
			_valuablesToRegister.Add(prefab, presetNames);
		}

		public static GameObject SpawnValuable(ValuableObject valuableObject, Vector3 position, Quaternion rotation)
		{
			//IL_0047: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)valuableObject == (Object)null)
			{
				Logger.LogError("Failed to spawn valuable. ValuableObject is null.");
				return null;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				Logger.LogError("Failed to spawn valuable \"" + ((Object)((Component)valuableObject).gameObject).name + "\". You are not the host.");
				return null;
			}
			string valuablePrefabPath = ResourcesHelper.GetValuablePrefabPath(valuableObject);
			GameObject val = NetworkPrefabs.SpawnNetworkPrefab(valuablePrefabPath, position, rotation, 0);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError("Failed to spawn valuable \"" + ((Object)((Component)valuableObject).gameObject).name + "\"");
				return null;
			}
			Logger.LogInfo($"Spawned valuable \"{((Object)val).name}\" at position {position}, rotation: {((Quaternion)(ref rotation)).eulerAngles}", extended: true);
			return val;
		}

		public static IReadOnlyList<GameObject> GetValuables()
		{
			if ((Object)(object)RunManager.instance == (Object)null)
			{
				return Array.Empty<GameObject>();
			}
			if (_valuablePresets.Count == 0)
			{
				CacheValuablePresets();
			}
			return _valuablePresets.Values.Select((LevelValuables levelValuables) => levelValuables.GetCombinedList()).SelectMany((List<GameObject> list) => list).Distinct()
				.ToList();
		}

		public static bool TryGetValuableByName(string name, out ValuableObject valuableObject)
		{
			valuableObject = GetValuableByName(name);
			return (Object)(object)valuableObject != (Object)null;
		}

		public static ValuableObject GetValuableByName(string name)
		{
			ValuableObject result = default(ValuableObject);
			foreach (GameObject valuable in GetValuables())
			{
				if (valuable.TryGetComponent<ValuableObject>(ref result) && ((Object)valuable).name.EqualsAny(new <>z__ReadOnlyArray<string>(new string[2]
				{
					name,
					"Valuable " + name
				}), StringComparison.OrdinalIgnoreCase))
				{
					return result;
				}
			}
			return null;
		}

		public static bool TryGetValuableThatContainsName(string name, out ValuableObject valuableObject)
		{
			valuableObject = GetValuableThatContainsName(name);
			return (Object)(object)valuableObject != (Object)null;
		}

		public static ValuableObject GetValuableThatContainsName(string name)
		{
			ValuableObject result = default(ValuableObject);
			foreach (GameObject valuable in GetValuables())
			{
				if (valuable.TryGetComponent<ValuableObject>(ref result) && ((Object)valuable).name.Contains(name, StringComparison.OrdinalIgnoreCase))
				{
					return result;
				}
			}
			return null;
		}

		[Obsolete("prefabId is no longer supported", true)]
		public static void RegisterValuable(string prefabId, GameObject prefab)
		{
			RegisterValuable(prefab);
		}

		[Obsolete("prefabId is no longer supported", true)]
		public static void RegisterValuable(string prefabId, GameObject prefab, List<LevelValuables> presets)
		{
			RegisterValuable(prefab, presets);
		}

		[Obsolete("prefabId is no longer supported", true)]
		public static void RegisterValuable(string prefabId, GameObject prefab, List<string> presetNames)
		{
			RegisterValuable(prefab, presetNames);
		}
	}
}
namespace REPOLib.Extensions
{
	public static class AudioSourceExtensions
	{
		public static void FixAudioMixerGroup(this AudioSource audioSource)
		{
			audioSource.FixAudioMixerGroup(((Component)audioSource).gameObject);
		}

		public static void FixAudioMixerGroup(this AudioSource audioSource, GameObject parentObject)
		{
			if ((Object)(object)audioSource == (Object)null)
			{
				return;
			}
			string text = ((!((Object)(object)parentObject == (Object)(object)((Component)audioSource).gameObject)) ? (((Object)parentObject).name + "/" + ((Object)((Component)audioSource).gameObject).name) : ((Object)((Component)audioSource).gameObject).name);
			if ((Object)(object)AudioManager.instance == (Object)null)
			{
				Logger.LogWarning("Failed to fix AudioMixerGroup on GameObject \"" + text + "\". AudioManager instance is null.");
				return;
			}
			if ((Object)(object)audioSource.outputAudioMixerGroup == (Object)null)
			{
				Logger.LogWarning("Failed to fix AudioMixerGroup on GameObject \"" + text + "\". No AudioMixerGroup is assigned.");
				return;
			}
			AudioMixer val = (AudioMixer)(((Object)audioSource.outputAudioMixerGroup.audioMixer).name switch
			{
				"Master" => AudioManager.instance.MasterMixer, 
				"Music" => AudioManager.instance.MusicMasterGroup.audioMixer, 
				"Sound" => AudioManager.instance.SoundMasterGroup.audioMixer, 
				"Spectate" => AudioManager.instance.MicrophoneSpectateGroup.audioMixer, 
				_ => AudioManager.instance.SoundMasterGroup.audioMixer, 
			});
			AudioMixerGroup[] array = val.FindMatchingGroups(((Object)audioSource.outputAudioMixerGroup).name);
			AudioMixerGroup val2;
			if (array.Length >= 1)
			{
				val2 = array[0];
			}
			else
			{
				val = AudioManager.instance.SoundMasterGroup.audioMixer;
				val2 = val.FindMatchingGroups("Sound Effects")[0];
				Logger.LogWarning("Could not find matching AudioMixerGroup for GameObject \"" + text + "\". Using default AudioMixerGroup \"" + ((Object)val).name + "/" + ((Object)val2).name + "\"", extended: true);
			}
			audioSource.outputAudioMixerGroup = val2;
			Logger.LogInfo("Fixed AudioMixerGroup on GameObject \"" + text + "\". AudioMixerGroup \"" + ((Object)val).name + "/" + ((Object)val2).name + "\"", extended: true);
		}
	}
	public static class DictionaryExtensions
	{
		public static bool TryGetKey<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TValue value, out TKey key)
		{
			foreach (KeyValuePair<TKey, TValue> item in dictionary)
			{
				if (object.Equals(item.Value, value))
				{
					key = item.Key;
					return true;
				}
			}
			key = default(TKey);
			return false;
		}

		public static TKey GetKeyOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TValue value)
		{
			if (dictionary.TryGetKey(value, out var key))
			{
				return key;
			}
			return default(TKey);
		}

		public static TKey GetKeyOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TValue value, TKey defaultKey)
		{
			if (dictionary.TryGetKey(value, out var key))
			{
				return key;
			}
			return defaultKey;
		}

		public static bool ContainsKey<T>(this Dictionary<string, T> dictionary, string key, bool ignoreKeyCase)
		{
			if (!ignoreKeyCase)
			{
				return dictionary.ContainsKey(key);
			}
			foreach (KeyValuePair<string, T> item in dictionary)
			{
				if (string.Equals(item.Key, key, StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		public static bool TryGetValue<T>(this Dictionary<string, T> dictionary, string key, out T value, bool ignoreKeyCase)
		{
			if (!ignoreKeyCase)
			{
				return dictionary.TryGetValue(key, out value);
			}
			foreach (KeyValuePair<string, T> item in dictionary)
			{
				if (string.Equals(item.Key, key, StringComparison.OrdinalIgnoreCase))
				{
					value = item.Value;
					return true;
				}
			}
			value = default(T);
			return false;
		}

		public static T GetValueOrDefault<T>(this Dictionary<string, T> dictionary, string key, bool ignoreKeyCase)
		{
			if (dictionary.TryGetValue(key, out var value, ignoreKeyCase))
			{
				return value;
			}
			return default(T);
		}

		public static T GetValueOrDefault<T>(this Dictionary<string, T> dictionary, string key, T defaultValue, bool ignoreKeyCase)
		{
			if (dictionary.TryGetValue(key, out var value, ignoreKeyCase))
			{
				return value;
			}
			return defaultValue;
		}
	}
	public static class EnemyDirectorExtensions
	{
		public static bool HasEnemy(this EnemyDirector enemyDirector, EnemySetup enemySetup)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)enemySetup == (Object)null || enemySetup.spawnObjects.Count == 0)
			{
				return false;
			}
			EnemyParent val = default(EnemyParent);
			foreach (GameObject spawnObject in enemySetup.spawnObjects)
			{
				if (spawnObject.TryGetComponent<EnemyParent>(ref val) && enemyDirector.TryGetList(val.difficulty, out var list))
				{
					return list.Contains(enemySetup);
				}
			}
			return false;
		}

		internal static bool AddEnemy(this EnemyDirector enemyDirector, EnemySetup enemySetup)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)enemySetup == (Object)null)
			{
				return false;
			}
			EnemyParent val = default(EnemyParent);
			foreach (GameObject spawnObject in enemySetup.spawnObjects)
			{
				if (spawnObject.TryGetComponent<EnemyParent>(ref val) && enemyDirector.TryGetList(val.difficulty, out var list) && !list.Contains(enemySetup))
				{
					list.Add(enemySetup);
					return true;
				}
			}
			return false;
		}

		public static bool TryGetList(this EnemyDirector enemyDirector, Difficulty difficultyType, out List<EnemySetup> list)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected I4, but got Unknown
			list = (int)difficultyType switch
			{
				0 => enemyDirector.enemiesDifficulty1, 
				1 => enemyDirector.enemiesDifficulty2, 
				2 => enemyDirector.enemiesDifficulty3, 
				_ => null, 
			};
			return list != null;
		}

		public static List<EnemySetup> GetEnemies(this EnemyDirector enemyDirector)
		{
			List<EnemySetup> enemiesDifficulty = enemyDirector.enemiesDifficulty1;
			List<EnemySetup> enemiesDifficulty2 = enemyDirector.enemiesDifficulty2;
			List<EnemySetup> enemiesDifficulty3 = enemyDirector.enemiesDifficulty3;
			List<EnemySetup> list = new List<EnemySetup>(enemiesDifficulty.Count + enemiesDifficulty2.Count + enemiesDifficulty3.Count);
			list.AddRange(enemiesDifficulty);
			list.AddRange(enemiesDifficulty2);
			list.AddRange(enemiesDifficulty3);
			return list;
		}

		public static bool TryGetEnemyByName(this EnemyDirector enemyDirector, string name, out EnemySetup enemySetup)
		{
			enemySetup = enemyDirector.GetEnemyByName(name);
			return (Object)(object)enemySetup != (Object)null;
		}

		public static EnemySetup GetEnemyByName(this EnemyDirector enemyDirector, string name)
		{
			return ((IEnumerable<EnemySetup>)enemyDirector.GetEnemies()).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup x) => x.NameEquals(name)));
		}

		public static bool TryGetEnemyThatContainsName(this EnemyDirector enemyDirector, string name, out EnemySetup enemySetup)
		{
			enemySetup = enemyDirector.GetEnemyThatContainsName(name);
			return (Object)(object)enemySetup != (Object)null;
		}

		public static EnemySetup GetEnemyThatContainsName(this EnemyDirector enemyDirector, string name)
		{
			return ((IEnumerable<EnemySetup>)enemyDirector.GetEnemies()).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup x) => x.NameContains(name)));
		}
	}
	public static class EnemySetupExtensions
	{
		public static List<GameObject> GetDistinctSpawnObjects(this EnemySetup enemySetup)
		{
			if ((Object)(object)enemySetup == (Object)null || enemySetup.spawnObjects == null)
			{
				return new List<GameObject>();
			}
			return enemySetup.spawnObjects.Where((GameObject x) => (Object)(object)x != (Object)null).Distinct(new UnityObjectNameComparer<GameObject>()).ToList();
		}

		public static List<GameObject> GetSortedSpawnObjects(this EnemySetup enemySetup)
		{
			if ((Object)(object)enemySetup == (Object)null || enemySetup.spawnObjects == null)
			{
				return new List<GameObject>();
			}
			EnemyParent val = default(EnemyParent);
			return (from x in enemySetup.spawnObjects
				where (Object)(object)x != (Object)null
				orderby x.TryGetComponent<EnemyParent>(ref val) descending
				select x).ToList();
		}

		public static GameObject GetMainSpawnObject(this EnemySetup enemySetup)
		{
			EnemyParent enemyParent = enemySetup.GetEnemyParent();
			if (enemyParent == null)
			{
				return null;
			}
			return ((Component)enemyParent).gameObject;
		}

		public static EnemyParent GetEnemyParent(this EnemySetup enemySetup)
		{
			EnemyParent result = default(EnemyParent);
			foreach (GameObject distinctSpawnObject in enemySetup.GetDistinctSpawnObjects())
			{
				if (distinctSpawnObject.TryGetComponent<EnemyParent>(ref result))
				{
					return result;
				}
			}
			return null;
		}

		public static bool TryGetEnemyParent(this EnemySetup enemySetup, out EnemyParent enemyParent)
		{
			enemyParent = enemySetup.GetEnemyParent();
			return (Object)(object)enemyParent != (Object)null;
		}

		public static bool AnySpawnObjectsNameEquals(this EnemySetup enemySetup, string name)
		{
			if ((Object)(object)enemySetup == (Object)null)
			{
				return false;
			}
			return enemySetup.GetDistinctSpawnObjects().Any((GameObject x) => ((Object)x).name.Equals(name, StringComparison.OrdinalIgnoreCase));
		}

		public static bool AnySpawnObjectsNameEqualsThatIsNotTheSameObject(this EnemySetup enemySetup, GameObject gameObject)
		{
			if ((Object)(object)enemySetup == (Object)null || (Object)(object)gameObject == (Object)null)
			{
				return false;
			}
			return enemySetup.GetDistinctSpawnObjects().Any((GameObject x) => ((Object)x).name.Equals(((Object)gameObject).name, StringComparison.OrdinalIgnoreCase) && (Object)(object)x != (Object)(object)gameObject);
		}

		public static bool NameEquals(this EnemySetup enemySetup, string name)
		{
			if ((Object)(object)enemySetup == (Object)null)
			{
				return false;
			}
			if (((Object)enemySetup).name.EqualsAny(new <>z__ReadOnlyArray<string>(new string[2]
			{
				name,
				"Enemy - " + name
			}), StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (enemySetup.TryGetEnemyParent(out var enemyParent) && enemyParent.enemyName.Equals(name, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (((Object)((Component)enemyParent).gameObject).name.EqualsAny(new <>z__ReadOnlyArray<string>(new string[2]
			{
				name,
				"Enemy - " + name
			}), StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			return false;
		}

		public static bool NameContains(this EnemySetup enemySetup, string name)
		{
			if ((Object)(object)enemySetup == (Object)null)
			{
				return false;
			}
			if (((Object)enemySetup).name.Contains(name, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (enemySetup.TryGetEnemyParent(out var enemyParent) && enemyParent.enemyName.Contains(name, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (((Object)((Component)enemyParent).gameObject).name.Contains(name, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			return false;
		}
	}
	public static class GameObjectExtensions
	{
		public static void FixAudioMixerGroups(this GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			if ((Object)(object)AudioManager.instance == (Object)null)
			{
				Logger.LogWarning("Failed to fix audio mixer groups on GameObject \"" + ((Object)gameObject).name + "\". AudioManager instance is null.");
				return;
			}
			AudioSource[] componentsInChildren = gameObject.GetComponentsInChildren<AudioSource>();
			foreach (AudioSource audioSource in componentsInChildren)
			{
				audioSource.FixAudioMixerGroup(gameObject);
			}
		}
	}
	internal static class ItemExtensions
	{
		public static bool NameEquals(this Item item, string name)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			if (((Object)item).name.EqualsAny(new <>z__ReadOnlyArray<string>(new string[2]
			{
				name,
				"Item " + name
			}), StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (item.itemAssetName.EqualsAny(new <>z__ReadOnlyArray<string>(new string[2]
			{
				name,
				"Item " + name
			}), StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (item.itemName.Equals(name, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			return false;
		}

		public static bool NameContains(this Item item, string name)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			if (((Object)item).name.Contains(name, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (item.itemAssetName.Contains(name, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (item.itemName.Contains(name, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			return false;
		}
	}
	public static class LevelValuablesExtensions
	{
		public static bool HasValuable(this LevelValuables levelValuables, GameObject prefab)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			ValuableObject val = default(ValuableObject);
			if (!prefab.TryGetComponent<ValuableObject>(ref val))
			{
				return false;
			}
			if (!levelValuables.TryGetList(val.volumeType, out var list))
			{
				return false;
			}
			return list.Contains(prefab);
		}

		internal static bool AddValuable(this LevelValuables levelValuables, GameObject prefab)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			ValuableObject val = default(ValuableObject);
			if (!prefab.TryGetComponent<ValuableObject>(ref val))
			{
				return false;
			}
			if (!levelValuables.TryGetList(val.volumeType, out var list))
			{
				return false;
			}
			if (list.Contains(prefab))
			{
				return false;
			}
			list.Add(prefab);
			return true;
		}

		public static bool TryGetList(this LevelValuables levelValuables, Type volumeType, out List<GameObject> list)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			list = (int)volumeType switch
			{
				0 => levelValuables.tiny, 
				1 => levelValuables.small, 
				2 => levelValuables.medium, 
				3 => levelValuables.big, 
				4 => levelValuables.wide, 
				5 => levelValuables.tall, 
				6 => levelValuables.veryTall, 
				_ => null, 
			};
			return list != null;
		}

		public static bool TryGetCombinedList(this LevelValuables levelValuables, out List<GameObject> list)
		{
			List<List<GameObject>> source = new List<List<GameObject>> { levelValuables.tiny, levelValuables.small, levelValuables.medium, levelValuables.big, levelValuables.wide, levelValuables.tall, levelValuables.veryTall };
			list = (from x in source.SelectMany((List<GameObject> valuables) => valuables)
				where (Object)(object)x != (Object)null
				select x).Distinct().ToList();
			return list != null;
		}

		public static List<GameObject> GetCombinedList(this LevelValuables levelValuables)
		{
			if (levelValuables.TryGetCombinedList(out var list))
			{
				return list;
			}
			return new List<GameObject>();
		}
	}
	public static class StatsManagerExtensions
	{
		public static bool HasItem(this StatsManager statsManager, Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			return statsManager.itemDictionary.ContainsKey(item.itemAssetName);
		}

		internal static bool AddItem(this StatsManager statsManager, Item item)
		{
			if (!statsManager.itemDictionary.ContainsKey(item.itemAssetName))
			{
				statsManager.itemDictionary.Add(item.itemAssetName, item);
			}
			foreach (Dictionary<string, int> item2 in statsManager.AllDictionariesWithPrefix("item"))
			{
				item2[item.itemAssetName] = 0;
			}
			return true;
		}

		public static List<Item> GetItems(this StatsManager statsManager)
		{
			return statsManager.itemDictionary.Values.ToList();
		}

		public static bool TryGetItemByName(this StatsManager statsManager, string name, out Item item)
		{
			item = statsManager.GetItemByName(name);
			return (Object)(object)item != (Object)null;
		}

		public static Item GetItemByName(this StatsManager statsManager, string name)
		{
			return ((IEnumerable<Item>)statsManager.GetItems()).FirstOrDefault((Func<Item, bool>)((Item x) => x.NameEquals(name)));
		}

		public static bool TryGetItemThatContainsName(this StatsManager statsManager, string name, out Item item)
		{
			item = statsManager.GetItemThatContainsName(name);
			return (Object)(object)item != (Object)null;
		}

		public static Item GetItemThatContainsName(this StatsManager statsManager, string name)
		{
			return ((IEnumerable<Item>)statsManager.GetItems()).FirstOrDefault((Func<Item, bool>)((Item x) => x.NameContains(name)));
		}
	}
	public static class StringExtensions
	{
		public static bool EqualsAny(this string value, IReadOnlyCollection<string> inputs, StringComparison comparisonType = StringComparison.Ordinal)
		{
			if (value == null || inputs == null)
			{
				return false;
			}
			return inputs.Contains<string>(value, StringComparer.FromComparison(comparisonType));
		}
	}
}
namespace REPOLib.Commands
{
	[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
	public class CommandExecutionAttribute : Attribute
	{
		public bool RequiresDeveloperMode { get; private set; }

		public bool EnabledByDefault { get; private set; }

		public string Name { get; private set; }

		public string Description { get; private set; }

		public CommandExecutionAttribute(string name = null, string description = null, bool enabledByDefault = true, bool requiresDeveloperMode = false)
		{
			RequiresDeveloperMode = requiresDeveloperMode;
			EnabledByDefault = enabledByDefault;
			Name = name ?? "";
			Description = description ?? "";
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
	public class CommandInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)]
	public class CommandAliasAttribute : Attribute
	{
		public string Alias { get; private set; }

		public CommandAliasAttribute(string alias)
		{
			Alias = alias;
		}
	}
	internal static class CommandManager
	{
		private static List<MethodInfo> _commandExecutionMethodCache = new List<MethodInfo>();

		public static Dictionary<string, MethodInfo> CommandExecutionMethods { get; private set; } = new Dictionary<string, MethodInfo>();


		public static List<MethodInfo> CommandInitializerMethods { get; private set; } = new List<MethodInfo>();


		public static Dictionary<string, bool> CommandsEnabled { get; private set; } = new Dictionary<string, bool>();


		public static void Initialize()
		{
			Logger.LogInfo("CommandManager initializing.", extended: true);
			CommandInitializerMethods = (from method in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly assembly) => assembly.GetTypes()).SelectMany((Type type) => type.GetMethods())
				where method.GetCustomAttribute<CommandInitializerAttribute>() != null
				select method).ToList();
			foreach (MethodInfo commandInitializerMethod in CommandInitializerMethods)
			{
				try
				{
					Logger.LogInfo($"Initializing command initializer on method {commandInitializerMethod.DeclaringType}.{commandInitializerMethod.Name}", extended: true);
					if (!commandInitializerMethod.IsStatic)
					{
						Logger.LogWarning($"Command initializer {commandInitializerMethod.DeclaringType}.{commandInitializerMethod.Name} is not static!");
					}
					commandInitializerMethod.Invoke(null, null);
				}
				catch (Exception arg)
				{
					Logger.LogError($"Failed to initialize command: {arg}");
				}
			}
			FindAllCommandMethods();
			foreach (KeyValuePair<string, MethodInfo> commandExecutionMethod in CommandExecutionMethods)
			{
				if (!commandExecutionMethod.Value.IsStatic)
				{
					Logger.LogWarning("Command execution method for command \"" + commandExecutionMethod.Key + "\" is not static!");
				}
			}
			BindConfigs();
			Logger.LogInfo("Finished initializing custom commands.");
		}

		public static void FindAllCommandMethods()
		{
			_commandExecutionMethodCache = (from method in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly assembly) => assembly.GetTypes()).SelectMany((Type type) => type.GetMethods())
				where method.GetCustomAttribute<CommandExecutionAttribute>() != null
				select method).ToList();
			foreach (MethodInfo item in _commandExecutionMethodCache)
			{
				ParameterInfo[] parameters = item.GetParameters();
				if (parameters.Length > 1)
				{
					Logger.LogError("Command \"" + item.GetCustomAttribute<CommandExecutionAttribute>().Name + "\" execution method \"" + item.Name + "\" has too many parameters! Should only have 1 string parameter or none.");
					break;
				}
				if (parameters.Length == 1 && parameters[0].ParameterType != typeof(string))
				{
					Logger.LogError("Command \"" + item.GetCustomAttribute<CommandExecutionAttribute>().Name + "\" execution method \"" + item.Name + "\" has parameter of the wrong type! Should be string.");
					break;
				}
				IEnumerable<CommandAliasAttribute> customAttributes = item.GetCustomAttributes<CommandAliasAttribute>();
				bool flag = false;
				if (customAttributes == null || customAttributes.Count() == 0)
				{
					Logger.LogWarning("Command " + item.Name + " has no alias attributes!");
					continue;
				}
				foreach (CommandAliasAttribute item2 in customAttributes)
				{
					if (CommandExecutionMethods.TryAdd(item2.Alias, item))
					{
						Logger.LogInfo($"Registered command alias \"{item2.Alias}\" for method \"{item.DeclaringType}.{item.Name}\".", extended: true);
						flag = true;
					}
				}
				if (!flag)
				{
					Logger.LogWarning("Failed to add any command aliases for method \"" + item.Name + "\".");
				}
			}
		}

		public static void BindConfigs()
		{
			foreach (MethodInfo item in _commandExecutionMethodCache)
			{
				CommandExecutionAttribute customAttribute = item.GetCustomAttribute<CommandExecutionAttribute>();
				BepInPlugin customAttribute2 = ((MemberInfo)(from type in item.Module.Assembly.GetTypes()
					where ((MemberInfo)type).GetCustomAttribute<BepInPlugin>() != null
					select type).ToList()[0]).GetCustomAttribute<BepInPlugin>();
				string text = ((customAttribute2 != null) ? customAttribute2.GUID : null) ?? "Unknown";
				string text2 = item.DeclaringType.ToString() ?? "Unknown";
				List<string> list = new List<string>();
				foreach (CommandAliasAttribute customAttribute3 in item.GetCustomAttributes<CommandAliasAttribute>())
				{
					list.Add(customAttribute3.Alias);
				}
				string text3 = customAttribute.Name ?? "Unknown";
				string text4 = "(Alias(es): [" + string.Join(", ", list) + "])\n\n" + (customAttribute.Description ?? "Unknown");
				bool enabledByDefault = customAttribute.EnabledByDefault;
				CommandsEnabled[text3] = ConfigManager.ConfigFile.Bind<bool>("Commands." + text, text3, enabledByDefault, text4).Value;
			}
		}
	}
	internal static class SpawnEnemyCommand
	{
		[CommandExecution("Spawn Enemy", "Spawn an instance of an enemy with the specified (case-insensitive) name. You can optionally leave out \"Enemy - \" from the prefab name.", true, true)]
		[CommandAlias("spawnenemy")]
		[CommandAlias("se")]
		public static void Execute(string args)
		{
			//IL_00d3: 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_00df: 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)
			Logger.LogInfo("Running spawn command with args \"" + args + "\"", extended: true);
			if (string.IsNullOrWhiteSpace(args))
			{
				Logger.LogWarning("No args provided to spawn command.");
				return;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				Logger.LogError("Only the host can spawn enemies!");
				return;
			}
			if ((Object)(object)EnemyDirector.instance == (Object)null)
			{
				Logger.LogError("Failed spawn enemy command, EnemyDirector is not initialized.");
				return;
			}
			if ((Object)(object)LevelGenerator.Instance == (Object)null)
			{
				Logger.LogError("Failed spawn enemy command, LevelGenerator is not initialized.");
				return;
			}
			if ((Object)(object)RunManager.instance == (Object)null)
			{
				Logger.LogError("Failed spawn enemy command, RunManager is not initialized.");
				return;
			}
			if ((Object)(object)PlayerAvatar.instance == (Object)null)
			{
				Logger.LogWarning("Can't spawn anything, player avatar is not initialized.");
				return;
			}
			if (!EnemyDirector.instance.TryGetEnemyThatContainsName(args, out var enemySetup))
			{
				Logger.LogWarning("Spawn command failed. Unknown enemy with name \"" + args + "\"");
				return;
			}
			Vector3 position = ((Component)PlayerAvatar.instance).transform.position;
			Logger.LogInfo($"Trying to spawn enemy \"{args}\" at {position}...", extended: true);
			((MonoBehaviour)EnemyDirector.instance).StartCoroutine(SpawnEnemyAfterTime(enemySetup, position, TimeSpan.FromSeconds(3.0)));
		}

		private static IEnumerator SpawnEnemyAfterTime(EnemySetup enemySetup, Vector3 position, TimeSpan timeSpan)
		{
			//IL_000e: 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)
			yield return (object)new WaitForSeconds((float)timeSpan.TotalSeconds);
			Enemies.SpawnEnemy(enemySetup, position, Quaternion.identity, spawnDespawned: false);
		}
	}
	internal static class SpawnItemCommand
	{
		[CommandExecution("Spawn Item", "Spawn an instance of an item with the specified (case-insensitive) name. You can optionally leave out \"Item \" from the prefab name.", true, true)]
		[CommandAlias("spawnitem")]
		[CommandAlias("si")]
		public static void Execute(string args)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogInfo("Running spawn command with args \"" + args + "\"", extended: true);
			if (string.IsNullOrWhiteSpace(args))
			{
				Logger.LogWarning("No args provided to spawn command.");
				return;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				Logger.LogError("Only the host can spawn items!");
				return;
			}
			if ((Object)(object)StatsManager.instance == (Object)null)
			{
				Logger.LogError("Failed spawn item command, StatsManager is not initialized.");
				return;
			}
			if ((Object)(object)PlayerAvatar.instance == (Object)null)
			{
				Logger.LogWarning("Can't spawn anything, player avatar is not initialized.");
				return;
			}
			Vector3 val = ((Component)PlayerAvatar.instance).transform.position + new Vector3(0f, 1f, 0f) + ((Component)PlayerAvatar.instance).transform.forward * 1f;
			Logger.LogInfo($"Trying to spawn item \"{args}\" at {val}...", extended: true);
			if (!Items.TryGetItemThatContainsName(args, out var item))
			{
				Logger.LogWarning("Spawn command failed. Unknown item with name \"" + args + "\"");
			}
			else
			{
				Items.SpawnItem(item, val, Quaternion.identity);
			}
		}
	}
	internal static class SpawnValuableCommand
	{
		[CommandExecution("Spawn Valuable", "Spawn an instance of a valuable with the specified (case-insensitive) name. You can optionally leave out \"Valuable \" from the prefab name.", true, true)]
		[CommandAlias("spawnvaluable")]
		[CommandAlias("spawnval")]
		[CommandAlias("sv")]
		public static void Execute(string args)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogInfo("Running spawn command with args \"" + args + "\"", extended: true);
			if (string.IsNullOrWhiteSpace(args))
			{
				Logger.LogWarning("No args provided to spawn command.");
				return;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				Logger.LogError("Only the host can spawn valuables!");
				return;
			}
			if ((Object)(object)PlayerAvatar.instance == (Object)null)
			{
				Logger.LogWarning("Can't spawn anything, player avatar is not initialized.");
				return;
			}
			if ((Object)(object)ValuableDirector.instance == (Object)null)
			{
				Logger.LogError("ValuableDirector not initialized.");
				return;
			}
			Vector3 val = ((Component)PlayerAvatar.instance).transform.position + new Vector3(0f, 1f, 0f) + ((Component)PlayerAvatar.instance).transform.forward * 1f;
			Logger.LogInfo($"Trying to spawn valuable \"{args}\" at {val}...", extended: true);
			if (!Valuables.TryGetValuableThatContainsName(args, out var valuableObject))
			{
				Logger.LogWarning("Spawn command failed. Unknown valuable with name \"" + args + "\"");
			}
			else
			{
				Valuables.SpawnValuable(valuableObject, val, Quaternion.identity);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}

BeepInEx/plugins/zelofi-MorePlayers/MorePlayers/MovePlayers.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using Steamworks.Data;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AdjustMaxPlayers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AdjustMaxPlayers")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("332fb87a-6417-4a3c-b614-543d93450b34")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MorePlayers;

[BepInPlugin("zelofi.MorePlayers", "MorePlayers", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(NetworkConnect), "TryJoiningRoom")]
	public class TryJoiningRoomPatch
	{
		private static bool Prefix(ref string ___RoomName)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			if (string.IsNullOrEmpty(___RoomName))
			{
				mls.LogError((object)"RoomName is null or empty, using previous method!");
				return true;
			}
			if (configMaxPlayers.Value == 0)
			{
				mls.LogError((object)"The MaxPlayers config is null or empty, using previous method!");
				return true;
			}
			if ((Object)(object)NetworkConnect.instance != (Object)null)
			{
				PhotonNetwork.JoinOrCreateRoom(___RoomName, new RoomOptions
				{
					MaxPlayers = configMaxPlayers.Value
				}, TypedLobby.Default, (string[])null);
				return false;
			}
			mls.LogError((object)"NetworkConnect instance is null, using previous method!");
			return true;
		}
	}

	[HarmonyPatch(typeof(SteamManager), "HostLobby")]
	public class HostLobbyPatch
	{
		private static bool Prefix()
		{
			HostLobbyAsync();
			return false;
		}

		private static async void HostLobbyAsync()
		{
			Debug.Log((object)"Steam: Hosting lobby...");
			Lobby? lobby = await SteamMatchmaking.CreateLobbyAsync(configMaxPlayers.Value);
			if (!lobby.HasValue)
			{
				Debug.LogError((object)"Lobby created but not correctly instantiated.");
				return;
			}
			Lobby value = lobby.Value;
			((Lobby)(ref value)).SetPublic();
			value = lobby.Value;
			((Lobby)(ref value)).SetJoinable(false);
		}
	}

	public const string modGUID = "zelofi.MorePlayers";

	public const string modName = "MorePlayers";

	public const string modVersion = "1.0.1";

	private readonly Harmony harmony = new Harmony("zelofi.MorePlayers");

	public static ConfigEntry<int> configMaxPlayers;

	public static ManualLogSource mls;

	private void Awake()
	{
		mls = Logger.CreateLogSource("zelofi.MorePlayers");
		mls.LogInfo((object)"zelofi.MorePlayers is now awake!");
		configMaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxPlayers", 10, "The max amount of players allowed in a server");
		harmony.PatchAll(typeof(TryJoiningRoomPatch));
		harmony.PatchAll(typeof(HostLobbyPatch));
	}
}

BeepInEx/plugins/zombieseatflesh7-True_Tumble_Cam/TumbleCam.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
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("TumbleCam")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TumbleCam")]
[assembly: AssemblyTitle("TumbleCam")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 TumbleCam
{
	[BepInPlugin("zombieseatflesh7.TumbleCam", "Tumble Cam", "1.0.0")]
	public class TumbleCam : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "zombieseatflesh7.TumbleCam";

		public const string PLUGIN_NAME = "Tumble Cam";

		public const string PLUGIN_VERSION = "1.0.0";

		internal static readonly ManualLogSource logger = Logger.CreateLogSource("Tumble Cam");

		private static bool hasControl = true;

		private static void PlayerTumble_UpdateHook(Action<PlayerTumble> orig, PlayerTumble self)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			orig(self);
			if (self.isTumbling && (!SemiFunc.IsMultiplayer() || self.playerAvatar.photonView.IsMine))
			{
				hasControl = false;
				Quaternion rotation = ((Component)self).transform.rotation;
				PlayerController.instance.cameraAim.playerAim = rotation;
			}
		}

		private static void CameraAim_UpdateHook(Action<CameraAim> orig, CameraAim self)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (hasControl)
			{
				orig(self);
				return;
			}
			hasControl = true;
			((Component)self).transform.localRotation = Quaternion.Lerp(((Component)self).transform.localRotation, self.playerAim, 30f * Time.deltaTime);
		}

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			new Hook((MethodBase)AccessTools.Method(typeof(PlayerTumble), "Update", (Type[])null, (Type[])null), (Delegate)new Action<Action<PlayerTumble>, PlayerTumble>(PlayerTumble_UpdateHook));
			new Hook((MethodBase)AccessTools.Method(typeof(CameraAim), "Update", (Type[])null, (Type[])null), (Delegate)new Action<Action<CameraAim>, CameraAim>(CameraAim_UpdateHook));
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TumbleCam";

		public const string PLUGIN_NAME = "TumbleCam";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}