Decompiled source of Seichi v1.0.5

BepInEx/plugins/seichi/LethalCompanySeichiItems.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.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanySeichiItems.Kanabo;
using LethalCompanySeichiItems.NetcodePatcher;
using LethalCompanySeichiItems.Uchiwa;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("Louis")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Lethal Company Seichi Items")]
[assembly: AssemblyFileVersion("3.2.0.0")]
[assembly: AssemblyInformationalVersion("3.2.0+c2cea823af9a531358eb978edcb6924b28dfde86")]
[assembly: AssemblyProduct("LethalCompanySeichiItems")]
[assembly: AssemblyTitle("LethalCompanySeichiItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalCompanySeichiItems
{
	[BepInPlugin("LethalCompanySeichiItems", "LethalCompanySeichiItems", "3.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SeichiItemsPlugin : BaseUnityPlugin
	{
		internal enum LogLevel
		{
			Debug,
			Info,
			Warning,
			Error
		}

		public const string ModGuid = "LCM_SeichiItems|3.2.0";

		private readonly Harmony _harmony = new Harmony("LCM_SeichiItems|3.2.0");

		private static SeichiItemsPlugin _instance;

		private static readonly ManualLogSource Mls = new ManualLogSource("LCM_SeichiItems|3.2.0");

		public static UchiwaConfig UchiwaConfigInstance { get; internal set; }

		public static KanaboConfig KanaboConfigInstance { get; internal set; }

		private void Awake()
		{
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
			_harmony.PatchAll();
			UchiwaConfigInstance = new UchiwaConfig(((BaseUnityPlugin)this).Config);
			KanaboConfigInstance = new KanaboConfig(((BaseUnityPlugin)this).Config);
			_harmony.PatchAll();
			_harmony.PatchAll(typeof(SeichiItemsPlugin));
			InitializeNetworkStuff();
		}

		internal static void Log(string msg, string prefix = "", LogLevel logLevel = LogLevel.Debug)
		{
			msg = prefix + "|" + msg;
			switch (logLevel)
			{
			case LogLevel.Debug:
				Mls.LogDebug((object)msg);
				break;
			case LogLevel.Info:
				Mls.LogInfo((object)msg);
				break;
			case LogLevel.Warning:
				Mls.LogWarning((object)msg);
				break;
			case LogLevel.Error:
				Mls.LogError((object)msg);
				break;
			default:
				throw new ArgumentOutOfRangeException("logLevel", logLevel, null);
			}
		}

		internal static void ChangeNetworkVar<T>(NetworkVariable<T> networkVariable, T newValue) where T : IEquatable<T>
		{
			if (!EqualityComparer<T>.Default.Equals(networkVariable.Value, newValue))
			{
				networkVariable.Value = newValue;
			}
		}

		private static void InitializeNetworkStuff()
		{
			IEnumerable<Type> enumerable;
			try
			{
				enumerable = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				enumerable = ex.Types.Where((Type t) => t != null);
			}
			foreach (Type item in enumerable)
			{
				MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
			IntSize = 4;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}

		private static void RequestSync()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(IntSize, (Allocator)2, -1);
			try
			{
				MessageManager.SendNamedMessage("LCM_SeichiItems|3.2.0_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		private static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0042: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!IsHost)
			{
				return;
			}
			Debug.Log((object)$"Config sync request received from client: {clientId}");
			byte[] array = SerializeToBytes(Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				MessageManager.SendNamedMessage("LCM_SeichiItems|3.2.0_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				Debug.Log((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		private static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_001f: 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)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(IntSize))
			{
				Debug.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Debug.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncInstance(data);
			Debug.Log((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_0058: 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_0063: Expected O, but got Unknown
			//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_002c: Expected O, but got Unknown
			if (IsHost)
			{
				CustomMessagingManager messageManager = MessageManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("LCM_SeichiItems|3.2.0_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				Synced = true;
				return;
			}
			Synced = false;
			CustomMessagingManager messageManager2 = MessageManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("LCM_SeichiItems|3.2.0_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			RequestSync();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			RevertSync();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalCompanySeichiItems";

		public const string PLUGIN_NAME = "LethalCompanySeichiItems";

		public const string PLUGIN_VERSION = "3.2.0";
	}
}
namespace LethalCompanySeichiItems.Uchiwa
{
	public class UchiwaConfig : SyncedInstance<UchiwaConfig>
	{
		internal readonly ConfigEntry<int> UchiwaHealAmount;

		public UchiwaConfig(ConfigFile cfg)
		{
			InitInstance(this);
			UchiwaHealAmount = cfg.Bind<int>("Uchiwa", "Player Heal Amount", 5, "The amount of health a player receives when hit with the Uchiwa.");
		}
	}
	public class UchiwaItem : GrabbableObject
	{
		private enum AudioClipTypes
		{
			Hit,
			Swing,
			HitSurface
		}

		private const string LOGPrefix = "Uchiwa";

		[Tooltip("The amount of healing the Uchiwa does per swing.")]
		[SerializeField]
		private int healAmount = 5;

		[Header("Audio")]
		[Space(5f)]
		[SerializeField]
		private AudioSource uchiwaAudio;

		public AudioClip[] hitSfx;

		public AudioClip[] swingSfx;

		private PlayerControllerB _previousPlayerHeldBy;

		private List<RaycastHit> _objectsHitByUchiwaList = new List<RaycastHit>();

		private RaycastHit[] _objectsHitByUchiwa;

		private static readonly int UseHeldItem1 = Animator.StringToHash("UseHeldItem1");

		private const int KnifeMask = 11012424;

		private float _timeAtLastDamageDealt;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			healAmount = Mathf.Clamp(SyncedInstance<UchiwaConfig>.Instance.UchiwaHealAmount.Value, 0, int.MaxValue);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				_previousPlayerHeldBy = base.playerHeldBy;
				if (((NetworkBehaviour)base.playerHeldBy).IsOwner)
				{
					base.playerHeldBy.playerBodyAnimator.SetTrigger(UseHeldItem1);
				}
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				PlayAudioClipTypeServerRpc(AudioClipTypes.Swing);
				HitUchiwa();
			}
		}

		private void HitUchiwa(bool cancel = false)
		{
			//IL_0054: 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_0073: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0142: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_01d8: 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_018c: 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_0192: 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_019b: 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_021f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_previousPlayerHeldBy == (Object)null)
			{
				SeichiItemsPlugin.Log("Variable '_previousPlayerHeldBy' is null on this client when HitUchiwa is called.", "Uchiwa", SeichiItemsPlugin.LogLevel.Error);
				return;
			}
			_previousPlayerHeldBy.activatingItem = false;
			bool flag = false;
			bool flag2 = false;
			int num = -1;
			if (!cancel)
			{
				_previousPlayerHeldBy.twoHanded = false;
				_objectsHitByUchiwa = Physics.SphereCastAll(((Component)_previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)_previousPlayerHeldBy.gameplayCamera).transform.right * 0.1f, 0.3f, ((Component)_previousPlayerHeldBy.gameplayCamera).transform.forward, 0.75f, 11012424, (QueryTriggerInteraction)2);
				_objectsHitByUchiwaList = _objectsHitByUchiwa.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
				IHittable val3 = default(IHittable);
				for (int i = 0; i < _objectsHitByUchiwaList.Count; i++)
				{
					RaycastHit val = _objectsHitByUchiwaList[i];
					RaycastHit val2 = val;
					if (((Component)((RaycastHit)(ref val2)).transform).gameObject.layer != 8 && ((Component)((RaycastHit)(ref val2)).transform).gameObject.layer != 11)
					{
						val2 = val;
						if (!((Component)((RaycastHit)(ref val2)).transform).TryGetComponent<IHittable>(ref val3))
						{
							continue;
						}
						val2 = val;
						if ((Object)(object)((RaycastHit)(ref val2)).transform == (Object)(object)((Component)_previousPlayerHeldBy).transform)
						{
							continue;
						}
						val2 = val;
						if (!(((RaycastHit)(ref val2)).point == Vector3.zero))
						{
							Vector3 position = ((Component)_previousPlayerHeldBy.gameplayCamera).transform.position;
							val2 = val;
							Vector3 point = ((RaycastHit)(ref val2)).point;
							RaycastHit val4 = default(RaycastHit);
							int collidersAndRoomMaskAndDefault = StartOfRound.Instance.collidersAndRoomMaskAndDefault;
							if (Physics.Linecast(position, point, ref val4, collidersAndRoomMaskAndDefault))
							{
								continue;
							}
						}
						flag = true;
						Vector3 forward = ((Component)_previousPlayerHeldBy.gameplayCamera).transform.forward;
						try
						{
							if ((double)Time.realtimeSinceStartup - (double)_timeAtLastDamageDealt > 0.4300000071525574)
							{
								_timeAtLastDamageDealt = Time.realtimeSinceStartup;
								flag2 = true;
								PlayerControllerB val5 = (PlayerControllerB)(object)((val3 is PlayerControllerB) ? val3 : null);
								if (val5 != null)
								{
									HealPlayerServerRpc(val5.actualClientId);
								}
								else
								{
									val3.Hit(0, forward, _previousPlayerHeldBy, true, 5);
								}
							}
						}
						catch (Exception arg)
						{
							SeichiItemsPlugin.Log($"Exception when hitting object with uchiwa from player #{_previousPlayerHeldBy.playerClientId}: {arg}", "Uchiwa", SeichiItemsPlugin.LogLevel.Error);
						}
						continue;
					}
					flag = true;
					val2 = val;
					for (int j = 0; j < StartOfRound.Instance.footstepSurfaces.Length; j++)
					{
						if (!(StartOfRound.Instance.footstepSurfaces[j].surfaceTag != ((Component)((RaycastHit)(ref val2)).collider).gameObject.tag))
						{
							num = j;
							break;
						}
					}
				}
			}
			if (flag)
			{
				PlayAudioClipTypeServerRpc(AudioClipTypes.Hit);
				if (!flag2 && num != -1)
				{
					PlayAudioClipTypeClientRpc(AudioClipTypes.HitSurface, num);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void HealPlayerServerRpc(ulong playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2944637045u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2944637045u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB val3;
				try
				{
					val3 = StartOfRound.Instance.allPlayerScripts[playerId];
				}
				catch (IndexOutOfRangeException)
				{
					SeichiItemsPlugin.Log($"Tried to heal player with ID: {playerId}, but such player does not exist.", "Uchiwa", SeichiItemsPlugin.LogLevel.Error);
					return;
				}
				if ((Object)(object)val3 == (Object)null)
				{
					SeichiItemsPlugin.Log($"Tried to heal player with ID: {playerId}, but the player object is null.", "Uchiwa", SeichiItemsPlugin.LogLevel.Error);
				}
				int playerMaxHealth = GetPlayerMaxHealth(val3);
				int playerNewHealth = ((playerMaxHealth != -1) ? Mathf.Min(val3.health + healAmount, playerMaxHealth) : Mathf.Min(val3.health + healAmount, 100));
				HealPlayerClientRpc(playerId, playerNewHealth);
			}
		}

		[ClientRpc]
		private void HealPlayerClientRpc(ulong playerId, int playerNewHealth)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3245975384u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				BytePacker.WriteValueBitPacked(val2, playerNewHealth);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3245975384u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
				val3.health = playerNewHealth;
				if ((Object)(object)HUDManager.Instance.localPlayer == (Object)(object)val3)
				{
					HUDManager.Instance.UpdateHealthUI(val3.health, false);
				}
			}
		}

		private static int GetPlayerMaxHealth(PlayerControllerB player)
		{
			if (UchiwaSharedData.Instance.PlayersMaxHealth.ContainsKey(player))
			{
				return UchiwaSharedData.Instance.PlayersMaxHealth[player];
			}
			SeichiItemsPlugin.Log("Could not get the health of player " + player.playerUsername + ". This should not happen.", "Uchiwa", SeichiItemsPlugin.LogLevel.Error);
			return -1;
		}

		[ServerRpc(RequireOwnership = false)]
		private void PlayAudioClipTypeServerRpc(AudioClipTypes audioClipType, bool interrupt = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0098: 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_00b2: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2229229963u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<AudioClipTypes>(ref audioClipType, default(ForEnums));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref interrupt, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2229229963u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				int num = audioClipType switch
				{
					AudioClipTypes.Hit => hitSfx.Length, 
					AudioClipTypes.Swing => swingSfx.Length, 
					_ => -1, 
				};
				switch (num)
				{
				case 0:
					SeichiItemsPlugin.Log($"There are no audio clips for audio clip type {audioClipType}.", "Uchiwa", SeichiItemsPlugin.LogLevel.Error);
					break;
				case -1:
					SeichiItemsPlugin.Log($"Audio Clip Type was not listed, cannot play audio clip. Number of audio clips: {num}.", "Uchiwa", SeichiItemsPlugin.LogLevel.Error);
					break;
				default:
				{
					int clipIndex = Random.Range(0, num);
					PlayAudioClipTypeClientRpc(audioClipType, clipIndex, interrupt);
					break;
				}
				}
			}
		}

		[ClientRpc]
		private void PlayAudioClipTypeClientRpc(AudioClipTypes audioClipType, int clipIndex, bool interrupt = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_008c: 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)
			//IL_00bf: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3423178400u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<AudioClipTypes>(ref audioClipType, default(ForEnums));
				BytePacker.WriteValueBitPacked(val2, clipIndex);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref interrupt, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3423178400u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			AudioClip val3 = (AudioClip)(audioClipType switch
			{
				AudioClipTypes.Hit => hitSfx[clipIndex], 
				AudioClipTypes.Swing => swingSfx[clipIndex], 
				AudioClipTypes.HitSurface => StartOfRound.Instance.footstepSurfaces[clipIndex].hitSurfaceSFX, 
				_ => null, 
			});
			if ((Object)(object)val3 == (Object)null)
			{
				SeichiItemsPlugin.Log($"Invalid audio clip with type: {audioClipType} and index: {clipIndex}", "Uchiwa", SeichiItemsPlugin.LogLevel.Error);
				return;
			}
			if (interrupt)
			{
				uchiwaAudio.Stop(true);
			}
			uchiwaAudio.PlayOneShot(val3);
			WalkieTalkie.TransmitOneShotAudio(uchiwaAudio, val3, uchiwaAudio.volume);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 8f, 0.4f, 0, false, 0);
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2944637045u, new RpcReceiveHandler(__rpc_handler_2944637045), "HealPlayerServerRpc");
			((NetworkBehaviour)this).__registerRpc(3245975384u, new RpcReceiveHandler(__rpc_handler_3245975384), "HealPlayerClientRpc");
			((NetworkBehaviour)this).__registerRpc(2229229963u, new RpcReceiveHandler(__rpc_handler_2229229963), "PlayAudioClipTypeServerRpc");
			((NetworkBehaviour)this).__registerRpc(3423178400u, new RpcReceiveHandler(__rpc_handler_3423178400), "PlayAudioClipTypeClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

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

		private static void __rpc_handler_3245975384(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				int playerNewHealth = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerNewHealth);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((UchiwaItem)(object)target).HealPlayerClientRpc(playerId, playerNewHealth);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2229229963(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_004a: 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_005f: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				AudioClipTypes audioClipType = default(AudioClipTypes);
				((FastBufferReader)(ref reader)).ReadValueSafe<AudioClipTypes>(ref audioClipType, default(ForEnums));
				bool interrupt = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref interrupt, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((UchiwaItem)(object)target).PlayAudioClipTypeServerRpc(audioClipType, interrupt);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3423178400(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_003e: 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_005d: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				AudioClipTypes audioClipType = default(AudioClipTypes);
				((FastBufferReader)(ref reader)).ReadValueSafe<AudioClipTypes>(ref audioClipType, default(ForEnums));
				int clipIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex);
				bool interrupt = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref interrupt, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((UchiwaItem)(object)target).PlayAudioClipTypeClientRpc(audioClipType, clipIndex, interrupt);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "UchiwaItem";
		}
	}
	public class UchiwaSharedData
	{
		private static UchiwaSharedData _instance;

		public static UchiwaSharedData Instance => _instance ?? (_instance = new UchiwaSharedData());

		public Dictionary<PlayerControllerB, int> PlayersMaxHealth { get; } = new Dictionary<PlayerControllerB, int>();


		public static void FlushDictionaries()
		{
			Instance.PlayersMaxHealth.Clear();
		}
	}
}
namespace LethalCompanySeichiItems.Uchiwa.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatches
	{
		[HarmonyPatch("ShipLeave")]
		[HarmonyPostfix]
		private static void ResetData(StartOfRound __instance)
		{
			UchiwaSharedData.FlushDictionaries();
		}

		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		private static void GetAllPlayersMaxHealth(StartOfRound __instance)
		{
			for (int i = 0; i < __instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = __instance.allPlayerScripts[i];
				if (UchiwaSharedData.Instance.PlayersMaxHealth.ContainsKey(val))
				{
					UchiwaSharedData.Instance.PlayersMaxHealth.Remove(val);
				}
				UchiwaSharedData.Instance.PlayersMaxHealth.Add(val, val.health);
			}
		}
	}
}
namespace LethalCompanySeichiItems.Lantern
{
	public class LanternItem : GrabbableObject
	{
		private const string LOGPrefix = "Lantern";

		[Header("Lantern Stuff")]
		[Space(15f)]
		[SerializeField]
		private Light bulbLightSource;

		[SerializeField]
		private Light bulbGlowLightSource;

		[SerializeField]
		private AudioSource audioSource;

		[SerializeField]
		private AudioClip[] turnOnAudioClips;

		[SerializeField]
		private AudioClip[] turnOffAudioClips;

		[SerializeField]
		private Material bulbLightMaterial;

		[SerializeField]
		private Material bulbDarkMaterial;

		[SerializeField]
		private MeshRenderer meshRenderer;

		[SerializeField]
		private GameObject lanternHelmetLightPrefab;

		private GameObject lanternHelmetLightInstance;

		private Light lanternHelmetLightSource;

		private readonly NetworkVariable<bool> _isMainLightOn = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

		private readonly NetworkVariable<bool> _isHelmetLightOn = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

		private readonly NetworkVariable<bool> _isOn = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);

		private bool _subscribedToNetworkEvents;

		private bool _hasInstantiated;

		private void OnEnable()
		{
			SubscribeToNetworkEvents();
		}

		private void OnDisable()
		{
			UnsubscribeFromNetworkEvents();
		}

		public override void OnDestroy()
		{
			if ((Object)(object)lanternHelmetLightInstance != (Object)null)
			{
				Object.Destroy((Object)(object)lanternHelmetLightInstance);
			}
			((NetworkBehaviour)this).OnDestroy();
		}

		public override void Start()
		{
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			SubscribeToNetworkEvents();
			if (_hasInstantiated)
			{
				return;
			}
			if ((Object)(object)meshRenderer == (Object)null)
			{
				meshRenderer = ((Component)this).GetComponent<MeshRenderer>();
			}
			if ((Object)(object)meshRenderer == (Object)null)
			{
				SeichiItemsPlugin.Log("The mesh renderer component on the lantern is null.", "Lantern", SeichiItemsPlugin.LogLevel.Error);
			}
			if ((Object)(object)bulbLightSource == (Object)null)
			{
				SeichiItemsPlugin.Log("The bulbLightSource on the lantern is null.", "Lantern", SeichiItemsPlugin.LogLevel.Error);
			}
			if ((Object)(object)bulbGlowLightSource == (Object)null)
			{
				SeichiItemsPlugin.Log("The bulbGlowLightSource on the lantern is null.", "Lantern", SeichiItemsPlugin.LogLevel.Error);
			}
			if ((Object)(object)lanternHelmetLightPrefab == (Object)null)
			{
				SeichiItemsPlugin.Log("The lanternHelmetLightPrefab gameobject on this lantern is null.", "Lantern", SeichiItemsPlugin.LogLevel.Error);
			}
			lanternHelmetLightInstance = Object.Instantiate<GameObject>(lanternHelmetLightPrefab);
			lanternHelmetLightSource = lanternHelmetLightInstance.GetComponent<Light>();
			if ((Object)(object)lanternHelmetLightSource == (Object)null)
			{
				lanternHelmetLightSource = lanternHelmetLightInstance.GetComponentInChildren<Light>();
				if ((Object)(object)lanternHelmetLightSource == (Object)null)
				{
					SeichiItemsPlugin.Log("The lanternHelmetLightSource light component on this lantern is null.", "Lantern", SeichiItemsPlugin.LogLevel.Error);
				}
			}
			((Component)lanternHelmetLightSource).gameObject.transform.position = ((Component)this).transform.position;
			((Behaviour)lanternHelmetLightSource).enabled = false;
			((Behaviour)bulbLightSource).enabled = false;
			((Behaviour)bulbGlowLightSource).enabled = false;
			_hasInstantiated = true;
			((GrabbableObject)this).Start();
		}

		public override void LateUpdate()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if ((base.isHeld || base.isPocketed) && _isOn.Value && _isHelmetLightOn.Value)
			{
				lanternHelmetLightInstance.transform.position = ((Component)base.playerHeldBy.helmetLight).transform.position;
				lanternHelmetLightInstance.transform.rotation = ((Component)base.playerHeldBy.helmetLight).transform.rotation;
			}
			((GrabbableObject)this).LateUpdate();
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			base.isBeingUsed = used;
			bool flag = false;
			if (!_isOn.Value)
			{
				if (turnOnAudioClips.Length != 0)
				{
					audioSource.PlayOneShot(turnOnAudioClips[Random.Range(0, turnOnAudioClips.Length)]);
					flag = true;
				}
			}
			else if (turnOffAudioClips.Length != 0)
			{
				audioSource.PlayOneShot(turnOffAudioClips[Random.Range(0, turnOffAudioClips.Length)]);
				flag = true;
			}
			if (flag)
			{
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 6f, 0.3f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				_isOn.Value = !_isOn.Value;
				_isMainLightOn.Value = !_isMainLightOn.Value;
				_isHelmetLightOn.Value = !_isHelmetLightOn.Value;
			}
		}

		public override void DiscardItem()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				SeichiItemsPlugin.ChangeNetworkVar(_isHelmetLightOn, newValue: false);
				SeichiItemsPlugin.ChangeNetworkVar(_isMainLightOn, _isOn.Value);
			}
			((GrabbableObject)this).DiscardItem();
		}

		public override void EquipItem()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				SeichiItemsPlugin.ChangeNetworkVar(_isHelmetLightOn, _isOn.Value);
				SeichiItemsPlugin.ChangeNetworkVar(_isMainLightOn, _isOn.Value);
			}
			((GrabbableObject)this).EquipItem();
		}

		public override void PocketItem()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				SeichiItemsPlugin.ChangeNetworkVar(_isHelmetLightOn, _isOn.Value);
				SeichiItemsPlugin.ChangeNetworkVar(_isMainLightOn, newValue: false);
			}
			((GrabbableObject)this).PocketItem();
		}

		private void OnMainLightToggled(bool oldIsTurnedOn, bool newIsTurnedOn)
		{
			SeichiItemsPlugin.Log($"Main light on?: {newIsTurnedOn}", "Lantern");
			((Behaviour)bulbLightSource).enabled = newIsTurnedOn;
			((Behaviour)bulbGlowLightSource).enabled = newIsTurnedOn;
			Material[] sharedMaterials = ((Renderer)meshRenderer).sharedMaterials;
			sharedMaterials[0] = (newIsTurnedOn ? bulbLightMaterial : bulbDarkMaterial);
			((Renderer)meshRenderer).sharedMaterials = sharedMaterials;
		}

		private void OnHelmetLightToggled(bool oldIsTurnedOn, bool newIsTurnedOn)
		{
			SeichiItemsPlugin.Log($"Helmet light on?: {newIsTurnedOn}", "Lantern");
			((Behaviour)lanternHelmetLightSource).enabled = newIsTurnedOn;
		}

		private void SubscribeToNetworkEvents()
		{
			if (!_subscribedToNetworkEvents)
			{
				NetworkVariable<bool> isMainLightOn = _isMainLightOn;
				isMainLightOn.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)isMainLightOn.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnMainLightToggled));
				NetworkVariable<bool> isHelmetLightOn = _isHelmetLightOn;
				isHelmetLightOn.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)isHelmetLightOn.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnHelmetLightToggled));
				_subscribedToNetworkEvents = true;
			}
		}

		private void UnsubscribeFromNetworkEvents()
		{
			if (_subscribedToNetworkEvents)
			{
				NetworkVariable<bool> isMainLightOn = _isMainLightOn;
				isMainLightOn.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Remove((Delegate?)(object)isMainLightOn.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnMainLightToggled));
				NetworkVariable<bool> isHelmetLightOn = _isHelmetLightOn;
				isHelmetLightOn.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Remove((Delegate?)(object)isHelmetLightOn.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnHelmetLightToggled));
				_subscribedToNetworkEvents = false;
			}
		}

		protected override void __initializeVariables()
		{
			if (_isMainLightOn == null)
			{
				throw new Exception("LanternItem._isMainLightOn cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_isMainLightOn).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_isMainLightOn, "_isMainLightOn");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_isMainLightOn);
			if (_isHelmetLightOn == null)
			{
				throw new Exception("LanternItem._isHelmetLightOn cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_isHelmetLightOn).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_isHelmetLightOn, "_isHelmetLightOn");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_isHelmetLightOn);
			if (_isOn == null)
			{
				throw new Exception("LanternItem._isOn cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_isOn).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_isOn, "_isOn");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_isOn);
			((GrabbableObject)this).__initializeVariables();
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "LanternItem";
		}
	}
}
namespace LethalCompanySeichiItems.Kanabo
{
	public class KanaboConfig : SyncedInstance<KanaboConfig>
	{
		public readonly ConfigEntry<int> KanaboDamage;

		public readonly ConfigEntry<float> KanaboReelUpTime;

		public KanaboConfig(ConfigFile cfg)
		{
			InitInstance(this);
			KanaboDamage = cfg.Bind<int>("Kanabo", "Damage", 2, "The amount of damage the Kanabo does per hit.");
			KanaboReelUpTime = cfg.Bind<float>("Kanabo", "Reel Up Time", 0.7f, "The time it takes in seconds for the player to reel up the Kanabo.");
		}
	}
	public class KanaboItem : GrabbableObject
	{
		private enum AudioClipTypes
		{
			ReelUp,
			Swing,
			Hit,
			HitSurface
		}

		private const string LOGPrefix = "Kanabo";

		[Tooltip("The amount of damage the Kanabo does on a single hit.")]
		[SerializeField]
		private int hitForce = 2;

		[Tooltip("The reel up time in seconds for the Kanabo.")]
		[SerializeField]
		private float reelUpTime = 0.7f;

		[Header("Audio")]
		[Space(5f)]
		[SerializeField]
		private AudioSource kanaboAudio;

		public AudioClip[] reelUpSfx;

		public AudioClip[] swingSfx;

		public AudioClip[] hitSfx;

		private const int ShovelMask = 11012424;

		private static readonly int ShovelHit = Animator.StringToHash("shovelHit");

		private static readonly int ReelingUp = Animator.StringToHash("reelingUp");

		private bool _reelingUp;

		private bool _isHoldingButton;

		private bool _animatorSpeedCurrentlyModified;

		private float _origionalPlayerAnimatorSpeed;

		private List<RaycastHit> _objectsHitByKanaboList = new List<RaycastHit>();

		private RaycastHit[] _objectsHitByKanabo;

		private Coroutine _reelingUpCoroutine;

		private PlayerControllerB _previousPlayerHeldBy;

		private void OnDisable()
		{
			if (_animatorSpeedCurrentlyModified)
			{
				base.playerHeldBy.playerBodyAnimator.speed = _origionalPlayerAnimatorSpeed;
			}
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			hitForce = Mathf.Clamp(SyncedInstance<KanaboConfig>.Instance.KanaboDamage.Value, 0, int.MaxValue);
			reelUpTime = Mathf.Clamp(SyncedInstance<KanaboConfig>.Instance.KanaboReelUpTime.Value, 0.05f, 2.1474836E+09f);
			_origionalPlayerAnimatorSpeed = StartOfRound.Instance.allPlayerScripts[0].playerBodyAnimator.speed;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if ((Object)(object)base.playerHeldBy == (Object)null)
			{
				return;
			}
			_isHoldingButton = buttonDown;
			if (!_reelingUp && buttonDown)
			{
				_reelingUp = true;
				_previousPlayerHeldBy = base.playerHeldBy;
				if (_reelingUpCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(_reelingUpCoroutine);
					_reelingUpCoroutine = null;
				}
				_reelingUpCoroutine = ((MonoBehaviour)this).StartCoroutine(ReelUpKanabo());
			}
		}

		private IEnumerator ReelUpKanabo()
		{
			try
			{
				if ((Object)(object)base.playerHeldBy == (Object)null)
				{
					SeichiItemsPlugin.Log("PlayerHeldBy is null at the start of ReelUpKanabo. Aborting.", "Kanabo", SeichiItemsPlugin.LogLevel.Warning);
					yield break;
				}
				ulong playerHeldByClientId = base.playerHeldBy.actualClientId;
				Animator animator = base.playerHeldBy.playerBodyAnimator;
				if ((Object)(object)animator == (Object)null)
				{
					SeichiItemsPlugin.Log("PlayerBodyAnimator is null. Aborting.", "Kanabo", SeichiItemsPlugin.LogLevel.Warning);
					yield break;
				}
				base.playerHeldBy.activatingItem = true;
				base.playerHeldBy.twoHanded = true;
				animator.ResetTrigger(ShovelHit);
				animator.SetBool(ReelingUp, true);
				yield return null;
				RuntimeAnimatorController runtimeAnimatorController = animator.runtimeAnimatorController;
				AnimationClip val = ((runtimeAnimatorController == null) ? null : runtimeAnimatorController.animationClips?.FirstOrDefault((Func<AnimationClip, bool>)((AnimationClip clip) => ((Object)clip).name == "ShovelReelUp")));
				if ((Object)(object)val != (Object)null)
				{
					_origionalPlayerAnimatorSpeed = animator.speed;
					float speed = val.length / reelUpTime;
					_animatorSpeedCurrentlyModified = true;
					animator.speed = speed;
					PlayAudioClipTypeServerRpc(AudioClipTypes.ReelUp);
					yield return (object)new WaitForSeconds(reelUpTime);
					if ((Object)(object)animator == (Object)null)
					{
						animator = StartOfRound.Instance.allPlayerScripts[playerHeldByClientId].playerBodyAnimator;
					}
					animator.speed = _origionalPlayerAnimatorSpeed;
					_animatorSpeedCurrentlyModified = false;
				}
				else
				{
					SeichiItemsPlugin.Log("No animation clips found in the runtimeAnimatorController.", "Kanabo", SeichiItemsPlugin.LogLevel.Warning);
				}
				yield return (object)new WaitUntil((Func<bool>)(() => !_isHoldingButton || !base.isHeld));
				SwingKanabo(!base.isHeld);
				yield return (object)new WaitForSeconds(0.13f);
				yield return (object)new WaitForEndOfFrame();
				HitKanabo(!base.isHeld);
				yield return (object)new WaitForSeconds(0.3f);
			}
			finally
			{
				KanaboItem kanaboItem = this;
				kanaboItem._reelingUp = false;
				kanaboItem._reelingUpCoroutine = null;
			}
		}

		public void SwingKanabo(bool cancel = false)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			_previousPlayerHeldBy.playerBodyAnimator.SetBool(ReelingUp, false);
			if (!cancel)
			{
				if (((NetworkBehaviour)this).IsServer)
				{
					PlayAudioClipTypeServerRpc(AudioClipTypes.Swing);
				}
				_previousPlayerHeldBy.UpdateSpecialAnimationValue(true, (short)((Component)_previousPlayerHeldBy).transform.localEulerAngles.y, 0.4f, false);
			}
		}

		public void HitKanabo(bool cancel = false)
		{
			//IL_0054: 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_0073: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: 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_012b: 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_0142: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_01d8: 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_018c: 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_0192: 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_019b: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_previousPlayerHeldBy == (Object)null)
			{
				SeichiItemsPlugin.Log("Variable '_previousPlayerHeldBy' is null on this client when HitKanabo is called.", "Kanabo", SeichiItemsPlugin.LogLevel.Error);
				return;
			}
			_previousPlayerHeldBy.activatingItem = false;
			bool flag = false;
			bool flag2 = false;
			int num = -1;
			if (!cancel)
			{
				_previousPlayerHeldBy.twoHanded = false;
				_objectsHitByKanabo = Physics.SphereCastAll(((Component)_previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)_previousPlayerHeldBy.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)_previousPlayerHeldBy.gameplayCamera).transform.forward, 1.5f, 11012424, (QueryTriggerInteraction)2);
				_objectsHitByKanaboList = _objectsHitByKanabo.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
				IHittable val3 = default(IHittable);
				for (int i = 0; i < _objectsHitByKanaboList.Count; i++)
				{
					RaycastHit val = _objectsHitByKanaboList[i];
					RaycastHit val2 = val;
					if (((Component)((RaycastHit)(ref val2)).transform).gameObject.layer != 8 && ((Component)((RaycastHit)(ref val2)).transform).gameObject.layer != 11)
					{
						val2 = val;
						if (!((Component)((RaycastHit)(ref val2)).transform).TryGetComponent<IHittable>(ref val3))
						{
							continue;
						}
						val2 = val;
						if ((Object)(object)((RaycastHit)(ref val2)).transform == (Object)(object)((Component)_previousPlayerHeldBy).transform)
						{
							continue;
						}
						val2 = val;
						if (!(((RaycastHit)(ref val2)).point == Vector3.zero))
						{
							Vector3 position = ((Component)_previousPlayerHeldBy.gameplayCamera).transform.position;
							val2 = val;
							Vector3 point = ((RaycastHit)(ref val2)).point;
							RaycastHit val4 = default(RaycastHit);
							int collidersAndRoomMaskAndDefault = StartOfRound.Instance.collidersAndRoomMaskAndDefault;
							if (Physics.Linecast(position, point, ref val4, collidersAndRoomMaskAndDefault))
							{
								continue;
							}
						}
						flag = true;
						Vector3 forward = ((Component)_previousPlayerHeldBy.gameplayCamera).transform.forward;
						try
						{
							val3.Hit(hitForce, forward, _previousPlayerHeldBy, true, 1);
							flag2 = true;
						}
						catch (Exception arg)
						{
							SeichiItemsPlugin.Log($"Exception caught when hitting object with Kanabo from player {_previousPlayerHeldBy.playerUsername}: {arg}", "Kanabo", SeichiItemsPlugin.LogLevel.Error);
						}
						continue;
					}
					flag = true;
					val2 = val;
					for (int j = 0; j < StartOfRound.Instance.footstepSurfaces.Length; j++)
					{
						if (!(StartOfRound.Instance.footstepSurfaces[j].surfaceTag != ((Component)((RaycastHit)(ref val2)).collider).gameObject.tag))
						{
							num = j;
							break;
						}
					}
				}
			}
			if (flag)
			{
				if (!flag2 && num != -1)
				{
					PlayAudioClipTypeClientRpc(AudioClipTypes.HitSurface, num);
				}
				base.playerHeldBy.playerBodyAnimator.SetTrigger(ShovelHit);
				PlayAudioClipTypeServerRpc(AudioClipTypes.Hit);
			}
		}

		public override void DiscardItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.activatingItem = false;
			}
			((GrabbableObject)this).DiscardItem();
		}

		[ServerRpc(RequireOwnership = false)]
		private void PlayAudioClipTypeServerRpc(AudioClipTypes audioClipType, bool interrupt = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0098: 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_00b2: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1864931625u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<AudioClipTypes>(ref audioClipType, default(ForEnums));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref interrupt, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1864931625u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				int num = audioClipType switch
				{
					AudioClipTypes.Swing => swingSfx.Length, 
					AudioClipTypes.Hit => hitSfx.Length, 
					AudioClipTypes.ReelUp => reelUpSfx.Length, 
					_ => -1, 
				};
				switch (num)
				{
				case 0:
					SeichiItemsPlugin.Log($"There are no audio clips for audio clip type {audioClipType}.", "Kanabo", SeichiItemsPlugin.LogLevel.Error);
					break;
				case -1:
					SeichiItemsPlugin.Log($"Audio Clip Type was not listed, cannot play audio clip. Number of audio clips: {num}.", "Kanabo", SeichiItemsPlugin.LogLevel.Error);
					break;
				default:
				{
					int clipIndex = Random.Range(0, num);
					PlayAudioClipTypeClientRpc(audioClipType, clipIndex, interrupt);
					break;
				}
				}
			}
		}

		[ClientRpc]
		private void PlayAudioClipTypeClientRpc(AudioClipTypes audioClipType, int clipIndex, bool interrupt = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_008c: 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)
			//IL_00bf: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(739090681u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<AudioClipTypes>(ref audioClipType, default(ForEnums));
				BytePacker.WriteValueBitPacked(val2, clipIndex);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref interrupt, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 739090681u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			AudioClip val3 = (AudioClip)(audioClipType switch
			{
				AudioClipTypes.Hit => hitSfx[clipIndex], 
				AudioClipTypes.Swing => swingSfx[clipIndex], 
				AudioClipTypes.ReelUp => reelUpSfx[clipIndex], 
				AudioClipTypes.HitSurface => StartOfRound.Instance.footstepSurfaces[clipIndex].hitSurfaceSFX, 
				_ => null, 
			});
			if ((Object)(object)val3 == (Object)null)
			{
				SeichiItemsPlugin.Log($"Invalid audio clip with type: {audioClipType} and index: {clipIndex}", "Kanabo", SeichiItemsPlugin.LogLevel.Error);
				return;
			}
			if (interrupt)
			{
				kanaboAudio.Stop(true);
			}
			kanaboAudio.PlayOneShot(val3);
			WalkieTalkie.TransmitOneShotAudio(kanaboAudio, val3, kanaboAudio.volume);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 8f, 0.4f, 0, false, 0);
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1864931625u, new RpcReceiveHandler(__rpc_handler_1864931625), "PlayAudioClipTypeServerRpc");
			((NetworkBehaviour)this).__registerRpc(739090681u, new RpcReceiveHandler(__rpc_handler_739090681), "PlayAudioClipTypeClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_1864931625(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_004a: 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_005f: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				AudioClipTypes audioClipType = default(AudioClipTypes);
				((FastBufferReader)(ref reader)).ReadValueSafe<AudioClipTypes>(ref audioClipType, default(ForEnums));
				bool interrupt = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref interrupt, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((KanaboItem)(object)target).PlayAudioClipTypeServerRpc(audioClipType, interrupt);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_739090681(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_003e: 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_005d: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				AudioClipTypes audioClipType = default(AudioClipTypes);
				((FastBufferReader)(ref reader)).ReadValueSafe<AudioClipTypes>(ref audioClipType, default(ForEnums));
				int clipIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex);
				bool interrupt = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref interrupt, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((KanaboItem)(object)target).PlayAudioClipTypeClientRpc(audioClipType, clipIndex, interrupt);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "KanaboItem";
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		}
	}
}
namespace LethalCompanySeichiItems.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

BepInEx/plugins/seichi/ScarletMansionSeichiPatch.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.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using ScarletMansion.DunGenPatch;
using UnityEngine;
using UnityEngine.Rendering;
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("ScarletMansionSeichiPatch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ScarletMansionSeichiPatch")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3fb44756-2543-4ee4-ace4-da3fdb995192")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ScarletMansionSeichiPatch;

public class Patch
{
	public static void Activate()
	{
		Plugin.Instance.harmony.PatchAll(typeof(Patch));
	}

	public static Volume GetVolume()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		GameObject[] array = null;
		for (int i = 0; i < SceneManager.sceneCount; i++)
		{
			Scene sceneAt = SceneManager.GetSceneAt(i);
			if (((Scene)(ref sceneAt)).name.ToLowerInvariant() == "seichi")
			{
				array = ((Scene)(ref sceneAt)).GetRootGameObjects();
				Plugin.logger.LogInfo((object)"Found Seichi scene");
				break;
			}
		}
		if (array == null)
		{
			return null;
		}
		GameObject[] array2 = array;
		foreach (GameObject val in array2)
		{
			if (((Object)val).name.ToLowerInvariant() == "environment")
			{
				Transform val2 = val.transform.Find("RaphtaliaVolume");
				if ((Object)(object)val2 != (Object)null)
				{
					return ((Component)val2).GetComponentInChildren<Volume>(true);
				}
			}
		}
		return null;
	}

	[HarmonyPatch(typeof(RoundManager), "SetPowerOffAtStart")]
	[HarmonyPostfix]
	public static void ShipLandedPatch(ref RoundManager __instance)
	{
		if (Patch.active)
		{
			Volume volume = GetVolume();
			if ((Object)(object)volume == (Object)null)
			{
				Plugin.logger.LogWarning((object)"Couldn't setup SDM/Seichi compatibility feature");
			}
			else
			{
				((Behaviour)volume).enabled = true;
			}
		}
	}
}
[BepInPlugin("dev.ladyalice.scarletmansion.seichipatch", "Scarlet Mansion Seichi Patch", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public const string modGUID = "dev.ladyalice.scarletmansion.seichipatch";

	private const string modName = "Scarlet Mansion Seichi Patch";

	private const string modVersion = "1.0.0";

	public const string targetModGUID = "dev.ladyalice.scarletmansion";

	public const string targetModVersion = "1.3.27";

	public readonly Harmony harmony = new Harmony("dev.ladyalice.scarletmansion.seichipatch");

	public static Plugin Instance { get; private set; }

	public static ManualLogSource logger { get; internal set; }

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		logger = Logger.CreateLogSource("dev.ladyalice.scarletmansion.seichipatch");
		if (Chainloader.PluginInfos.ContainsKey("dev.ladyalice.scarletmansion"))
		{
			PluginInfo val = Chainloader.PluginInfos["dev.ladyalice.scarletmansion"];
			Version version = val.Metadata.Version;
			bool flag;
			if (string.IsNullOrWhiteSpace("1.3.27"))
			{
				flag = true;
			}
			else
			{
				Version version2 = new Version("1.3.27");
				flag = version >= version2;
			}
			if (flag)
			{
				logger.LogInfo((object)"Plugin Scarlet Mansion Seichi Patch has been added!");
				Patch.Activate();
			}
		}
	}
}

BepInEx/plugins/seichi/SeichiAdditions.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 GameNetcodeStuff;
using HarmonyLib;
using JLL.API;
using JLL.API.LevelProperties;
using JLLItemsModule.Components;
using Microsoft.CodeAnalysis;
using SeichiAdditions.Components;
using SeichiAdditions.Managers;
using SeichiAdditions.NetcodePatcher;
using SeichiAdditions.Patches;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
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("SeichiAdditions")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SeichiAdditions")]
[assembly: AssemblyTitle("SeichiAdditions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SeichiAdditions
{
	[BepInPlugin("JacobG5.SeichiAdditions", "SeichiAdditions", "0.0.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "JacobG5.SeichiAdditions";

		private const string modName = "SeichiAdditions";

		private const string modVersion = "0.0.6";

		private Harmony harmony = new Harmony("JacobG5.SeichiAdditions");

		internal ConfigFile SecretConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "SeichiAdditions.cfg"), true);

		public static ConfigEntry<bool> deathBreaksMarriage;

		public static ManualLogSource mls { get; private set; }

		public void Awake()
		{
			mls = Logger.CreateLogSource("JacobG5.SeichiAdditions");
			deathBreaksMarriage = SecretConfig.Bind<bool>("Funny", "TillDeathDoUsPart", false, "It's funnier this way");
			harmony.PatchAll(typeof(MarriageManager));
			if (!SecretConfig.Bind<bool>("Funny", "DisableHealthPatch", false, "Removes a transpiler").Value)
			{
				harmony.PatchAll(typeof(MaxHealthTranspiler));
			}
			if (!SecretConfig.Bind<bool>("Funny", "DisableMaskPatches", false, "Removes a transpilers & patches related to masked enemies and items").Value)
			{
				harmony.PatchAll(typeof(MaskedPatches));
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				try
				{
					MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
					MethodInfo[] array = methods;
					foreach (MethodInfo methodInfo in array)
					{
						object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
						if (customAttributes.Length != 0)
						{
							methodInfo.Invoke(null, null);
						}
					}
				}
				catch
				{
					mls.LogInfo((object)"Skipping Netcode Class");
				}
			}
		}
	}
}
namespace SeichiAdditions.Patches
{
	public class MaskedPatches
	{
		private static IEnumerable<CodeInstruction> AddAfter(IEnumerable<CodeInstruction> instructions, string debug, MethodInfo original, Action<List<CodeInstruction>> action)
		{
			List<CodeInstruction> newInstructions = new List<CodeInstruction>();
			bool found = false;
			foreach (CodeInstruction instruction in instructions)
			{
				newInstructions.Add(instruction);
				if (instruction.opcode == OpCodes.Call && CodeInstructionExtensions.Calls(instruction, original))
				{
					found = true;
					action(newInstructions);
				}
			}
			Plugin.mls.LogInfo((object)$"Patched {debug}: {found}");
			foreach (CodeInstruction item in newInstructions)
			{
				yield return item;
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> MaskedKillAnim_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return AddAfter(instructions, "Masked Kill Anim", AccessTools.Method(typeof(MaskedPlayerEnemy), "CreateMimicClientRpc", (Type[])null, (Type[])null), delegate(List<CodeInstruction> newInstructions)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: 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
				newInstructions.Add(new CodeInstruction(OpCodes.Ldloc_1, (object)null));
				newInstructions.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MaskedPatches), "SpawnMaskedPartner", new Type[1] { typeof(MaskedPlayerEnemy) }, (Type[])null)));
			});
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPriority(100)]
		[HarmonyPostfix]
		private static void StartOfRoundStart_Postfix(StartOfRound __instance)
		{
			HauntedMaskItem mask = default(HauntedMaskItem);
			foreach (Item items in __instance.allItemsList.itemsList)
			{
				if (items.spawnPrefab.TryGetComponent<HauntedMaskItem>(ref mask))
				{
					MaskData maskData = items.spawnPrefab.AddComponent<MaskData>();
					maskData.mask = mask;
					Plugin.mls.LogInfo((object)("Added MaskData to " + items.itemName));
				}
			}
		}

		[HarmonyPatch(typeof(HauntedMaskItem), "EquipItem")]
		[HarmonyPostfix]
		private static void DamageOnOtherClients_Postfix(HauntedMaskItem __instance)
		{
			MaskData maskData = default(MaskData);
			if (((Component)__instance).gameObject.TryGetComponent<MaskData>(ref maskData))
			{
				maskData.previousPlayerHeldBy = ((GrabbableObject)__instance).playerHeldBy;
				maskData.previousPlayerPartner = MarriageManager.GetPartner(maskData.previousPlayerHeldBy);
			}
		}

		[HarmonyPatch(typeof(HauntedMaskItem), "CreateMimicServerRpc")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> CreateMimicServer_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			return AddAfter(instructions, "Mask Item", AccessTools.Method(typeof(HauntedMaskItem), "CreateMimicClientRpc", (Type[])null, (Type[])null), delegate(List<CodeInstruction> newInstructions)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Expected O, but got Unknown
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Expected O, but got Unknown
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Expected O, but got Unknown
				newInstructions.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null));
				newInstructions.Add(new CodeInstruction(OpCodes.Ldarg_1, (object)null));
				newInstructions.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MaskedPatches), "SpawnMaskedPartner", new Type[2]
				{
					typeof(HauntedMaskItem),
					typeof(bool)
				}, (Type[])null)));
			});
		}

		public static void SpawnMaskedPartner(MaskedPlayerEnemy masked)
		{
			//IL_0023: 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_0047: 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_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_0074: 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_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_00f8: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB partner = MarriageManager.GetPartner(((EnemyAI)masked).inSpecialAnimationWithPlayer);
			if ((Object)(object)partner == (Object)null)
			{
				return;
			}
			bool flag = ((Component)partner).transform.position.y < -80f;
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)partner).transform.position, default(NavMeshHit), 10f, -1);
			if (!RoundManager.Instance.GotNavMeshPositionResult)
			{
				return;
			}
			NetworkObjectReference val = RoundManager.Instance.SpawnEnemyGameObject(navMeshPosition, ((Component)partner).transform.eulerAngles.y, -1, ((EnemyAI)masked).enemyType);
			NetworkObject val2 = default(NetworkObject);
			if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null))
			{
				MaskedPlayerEnemy component = ((Component)val2).GetComponent<MaskedPlayerEnemy>();
				component.SetSuit(partner.currentSuitID);
				component.mimickingPlayer = partner;
				((EnemyAI)component).SetEnemyOutside(!flag);
				partner.redirectToEnemy = (EnemyAI)(object)component;
				if ((Object)(object)partner.deadBody != (Object)null)
				{
					partner.deadBody.DeactivateBody(false);
				}
			}
			masked.CreateMimicClientRpc(val, flag, (int)partner.playerClientId);
		}

		public static void SpawnMaskedPartner(HauntedMaskItem mask, bool inFactory)
		{
			//IL_004d: 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_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_0081: 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_0099: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			MaskData maskData = default(MaskData);
			if (!((Component)mask).gameObject.TryGetComponent<MaskData>(ref maskData))
			{
				return;
			}
			PlayerControllerB val = maskData.previousPlayerPartner;
			if (val == null)
			{
				val = MarriageManager.GetPartner(maskData.previousPlayerHeldBy);
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)val).transform.position, default(NavMeshHit), 10f, -1);
			if (!RoundManager.Instance.GotNavMeshPositionResult)
			{
				return;
			}
			NetworkObjectReference netObjectRef = RoundManager.Instance.SpawnEnemyGameObject(navMeshPosition, ((Component)val).transform.eulerAngles.y, -1, mask.mimicEnemy);
			NetworkObject val2 = default(NetworkObject);
			if (((NetworkObjectReference)(ref netObjectRef)).TryGet(ref val2, (NetworkManager)null))
			{
				Debug.Log((object)"Got network object for mask enemy");
				MaskedPlayerEnemy component = ((Component)val2).GetComponent<MaskedPlayerEnemy>();
				component.SetSuit(val.currentSuitID);
				component.mimickingPlayer = val;
				((EnemyAI)component).SetEnemyOutside(!inFactory);
				component.SetVisibilityOfMaskedEnemy();
				component.SetMaskType(mask.maskTypeId);
				val.redirectToEnemy = (EnemyAI)(object)component;
				if (Object.op_Implicit((Object)(object)val.deadBody))
				{
					val.deadBody.DeactivateBody(false);
				}
			}
			maskData.CreateMimicClientRpc(netObjectRef, (int)val.playerClientId, inFactory);
		}
	}
	public static class MaxHealthTranspiler
	{
		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> newInstructions = new List<CodeInstruction>();
			FieldInfo HealthField = AccessTools.Field(typeof(PlayerControllerB), "health");
			MethodInfo ReplacementMethod = AccessTools.Method(typeof(MarriageManager), "GetMaxHealth", new Type[1] { typeof(PlayerControllerB) }, (Type[])null);
			bool found = false;
			int matches = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				if (1 == 0)
				{
				}
				bool flag = matches switch
				{
					0 => instruction.opcode == OpCodes.Ldarg_0, 
					1 => instruction.opcode == OpCodes.Ldarg_0, 
					2 => instruction.opcode == OpCodes.Ldfld && CodeInstructionExtensions.LoadsField(instruction, HealthField, false), 
					3 => instruction.opcode == OpCodes.Ldarg_1, 
					4 => instruction.opcode == OpCodes.Sub, 
					5 => instruction.opcode == OpCodes.Ldc_I4_0, 
					6 => true, 
					7 => instruction.opcode == OpCodes.Call, 
					8 => instruction.opcode == OpCodes.Stfld && CodeInstructionExtensions.StoresField(instruction, HealthField), 
					_ => false, 
				};
				if (1 == 0)
				{
				}
				if (flag)
				{
					matches++;
					if (matches == 9)
					{
						found = true;
						CodeInstruction clampCall = newInstructions[newInstructions.Count - 1];
						newInstructions.RemoveAt(newInstructions.Count - 1);
						newInstructions.RemoveAt(newInstructions.Count - 1);
						newInstructions.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null));
						newInstructions.Add(new CodeInstruction(OpCodes.Call, (object)ReplacementMethod));
						newInstructions.Add(clampCall);
					}
				}
				else
				{
					matches = 0;
				}
				newInstructions.Add(instruction);
			}
			Plugin.mls.LogInfo((object)$"Patched Player Damage: {found}");
			foreach (CodeInstruction item in newInstructions)
			{
				yield return item;
			}
		}
	}
}
namespace SeichiAdditions.Managers
{
	public static class MarriageManager
	{
		private static readonly List<(PlayerControllerB, PlayerControllerB)> Partners = new List<(PlayerControllerB, PlayerControllerB)>();

		private static readonly List<PlayerControllerB> DivorceRequests = new List<PlayerControllerB>();

		public static bool Marry(PlayerControllerB playerA, PlayerControllerB playerB)
		{
			if ((Object)(object)playerA == (Object)(object)playerB || playerA.isPlayerDead || playerB.isPlayerDead || HasPartner(playerA) || HasPartner(playerB))
			{
				return false;
			}
			playerA.health = (playerB.health += playerA.health);
			if (JLLExtentions.IsLocalPlayer(playerA) || JLLExtentions.IsLocalPlayer(playerB))
			{
				HUDManager.Instance.UpdateHealthUI(playerA.health, false);
			}
			Partners.Add((playerA, playerB));
			HUDManager.Instance.AddTextToChatOnServer(playerA.playerUsername + " and " + playerB.playerUsername + " are now Married!", -1);
			return true;
		}

		public static bool Divorce(PlayerControllerB player)
		{
			for (int i = 0; i < Partners.Count; i++)
			{
				(PlayerControllerB, PlayerControllerB) tuple = Partners[i];
				PlayerControllerB val = null;
				if ((Object)(object)tuple.Item1 == (Object)(object)player)
				{
					val = tuple.Item2;
				}
				else if ((Object)(object)tuple.Item2 == (Object)(object)player)
				{
					(val, _) = tuple;
				}
				if (!((Object)(object)val != (Object)null))
				{
					continue;
				}
				if (DivorceRequests.Contains(val))
				{
					Partners.RemoveAt(i);
					DivorceRequests.Remove(val);
					if (!tuple.Item1.isPlayerDead && !tuple.Item2.isPlayerDead)
					{
						PlayerControllerB item = tuple.Item1;
						PlayerControllerB item2 = tuple.Item2;
						item.health = (item2.health /= 2);
						if (JLLExtentions.IsLocalPlayer(tuple.Item1) || JLLExtentions.IsLocalPlayer(tuple.Item2))
						{
							HUDManager.Instance.UpdateHealthUI(tuple.Item1.health, true);
							JHudHelper.QueueDisplayTip("Divorced!", "You have been divorced from " + (JLLExtentions.IsLocalPlayer(tuple.Item1) ? tuple.Item2.playerUsername : tuple.Item1.playerUsername) + "!", false, false, "LC_Tip1");
						}
					}
					return true;
				}
				HUDManager.Instance.AddTextToChatOnServer(player.playerUsername + " has filed for a divorce with " + val.playerUsername + "!", -1);
				if (JLLExtentions.IsLocalPlayer(val))
				{
					JHudHelper.QueueDisplayTip("Divorce Request", player.playerUsername + " would like to divorce you!", false, false, "LC_Tip1");
				}
				break;
			}
			DivorceRequests.Add(player);
			return false;
		}

		public static void Remove(PlayerControllerB player)
		{
			for (int i = 0; i < Partners.Count; i++)
			{
				(PlayerControllerB, PlayerControllerB) tuple = Partners[i];
				if ((Object)(object)tuple.Item1 != (Object)(object)player && (Object)(object)tuple.Item2 != (Object)(object)player)
				{
					continue;
				}
				DivorceRequests.Remove(tuple.Item1);
				DivorceRequests.Remove(tuple.Item2);
				Partners.RemoveAt(i);
				if (!tuple.Item1.isPlayerDead && !tuple.Item2.isPlayerDead)
				{
					PlayerControllerB item = tuple.Item1;
					PlayerControllerB item2 = tuple.Item2;
					item.health = (item2.health /= 2);
					if (JLLExtentions.IsLocalPlayer(tuple.Item1) || JLLExtentions.IsLocalPlayer(tuple.Item2))
					{
						HUDManager.Instance.UpdateHealthUI(tuple.Item1.health, true);
					}
				}
				break;
			}
		}

		public static bool HasPartner(PlayerControllerB partner)
		{
			foreach (var partner2 in Partners)
			{
				if ((Object)(object)partner2.Item1 == (Object)(object)partner || (Object)(object)partner2.Item2 == (Object)(object)partner)
				{
					return true;
				}
			}
			return false;
		}

		public static PlayerControllerB GetPartner(PlayerControllerB player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			foreach (var partner in Partners)
			{
				if ((Object)(object)partner.Item1 == (Object)(object)player)
				{
					return partner.Item2;
				}
				if ((Object)(object)partner.Item2 == (Object)(object)player)
				{
					return partner.Item1;
				}
			}
			return null;
		}

		public static int GetMaxHealth(PlayerControllerB player)
		{
			Plugin.mls.LogInfo((object)$"Damaged Player! Married = {HasPartner(player)}");
			return HasPartner(player) ? 200 : 100;
		}

		[HarmonyPatch(typeof(StartOfRound), "OnDestroy")]
		[HarmonyPostfix]
		private static void StartOfRoundOnDestroy_Postfix()
		{
			Partners.Clear();
			DivorceRequests.Clear();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DamageOnOtherClients")]
		[HarmonyPostfix]
		private static void DamageOnOtherClients_Postfix(int damageNumber, int newHealthAmount, PlayerControllerB __instance)
		{
			PlayerControllerB partner = GetPartner(__instance);
			if ((Object)(object)partner != (Object)null)
			{
				partner.health = newHealthAmount;
				if (JLLExtentions.IsLocalPlayer(partner))
				{
					HUDManager.Instance.UpdateHealthUI(newHealthAmount, true);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "IHittable.Hit")]
		[HarmonyPrefix]
		private static void PlayerHit_Prefix(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID, PlayerControllerB __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GetPartner(StartOfRound.Instance.localPlayerController) == (Object)(object)__instance)
			{
				((IHittable)StartOfRound.Instance.localPlayerController).Hit(force, hitDirection, playerWhoHit, playHitSFX, hitID);
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerClientRpc")]
		[HarmonyPostfix]
		private static void KillPlayerClient_Postfix(int playerId, bool spawnBody, Vector3 bodyVelocity, int causeOfDeath, int deathAnimation, Vector3 positionOffset, PlayerControllerB __instance)
		{
			//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)
			if (!StartOfRound.Instance.localPlayerController.isPlayerDead && (Object)(object)GetPartner(StartOfRound.Instance.localPlayerController) == (Object)(object)__instance)
			{
				Plugin.mls.LogInfo((object)"Married Player Has Died. Killing Self.");
				StartOfRound.Instance.localPlayerController.KillPlayer(bodyVelocity, spawnBody, (CauseOfDeath)causeOfDeath, deathAnimation, positionOffset);
				if (Plugin.deathBreaksMarriage != null && Plugin.deathBreaksMarriage.Value)
				{
					Divorce(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ReviveDeadPlayers")]
		[HarmonyPostfix]
		private static void RevivePlayers_Postfix()
		{
			foreach (var partner in Partners)
			{
				partner.Item1.health = (partner.Item2.health = 200);
				if (JLLExtentions.IsLocalPlayer(partner.Item1) || JLLExtentions.IsLocalPlayer(partner.Item2))
				{
					HUDManager.Instance.UpdateHealthUI(200, false);
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")]
		[HarmonyPrefix]
		private static void OnPlayerDC_Prefix(int playerObjectNumber, ulong clientId)
		{
			Remove(GetPartner(StartOfRound.Instance.allPlayerScripts[playerObjectNumber]));
		}
	}
}
namespace SeichiAdditions.Components
{
	public class MarriageContract : JMeleeWeapon
	{
		public bool destroyOnUse = true;

		public override bool OnWeaponHit(IHittable target, Vector3 hitDir)
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				PlayerControllerB val = (PlayerControllerB)(object)((target is PlayerControllerB) ? target : null);
				if (val != null && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)(object)val && !MarriageManager.HasPartner(((GrabbableObject)this).playerHeldBy) && !MarriageManager.HasPartner(val))
				{
					UseContractClientRpc((int)val.playerClientId, ((GrabbableObject)this).playerHeldBy.currentItemSlot);
					return true;
				}
			}
			return false;
		}

		[ClientRpc]
		public void UseContractClientRpc(int targetId, int slot)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1036822283u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, targetId);
				BytePacker.WriteValueBitPacked(val2, slot);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1036822283u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) && ((GrabbableObject)this).playerHeldBy.ItemSlots[slot] is MarriageContract)
			{
				PlayerControllerB playerB = StartOfRound.Instance.allPlayerScripts[targetId];
				if (MarriageManager.Marry(((GrabbableObject)this).playerHeldBy, playerB) && destroyOnUse)
				{
					((GrabbableObject)this).playerHeldBy.DestroyItemInSlot(slot);
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1036822283u, new RpcReceiveHandler(__rpc_handler_1036822283), "UseContractClientRpc");
			((JMeleeWeapon)this).__initializeRpcs();
		}

		private static void __rpc_handler_1036822283(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int targetId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetId);
				int slot = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref slot);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MarriageContract)(object)target).UseContractClientRpc(targetId, slot);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "MarriageContract";
		}
	}
	public class MarriageCreator : NetworkBehaviour
	{
		public string header = "Marriage Altar";

		public bool requiresRings = true;

		private bool ceramonyComplete = false;

		public InteractTrigger interactTrigger;

		private PlayerControllerB bride;

		public GameObject brideRing;

		public TMP_Text brideTxt;

		private PlayerControllerB groom;

		public GameObject groomRing;

		public TMP_Text groomTxt;

		private readonly string[] errorFeedback = new string[2] { "You are already Married!", "Ring required!" };

		public UnityEvent marriageEvent = new UnityEvent();

		private string DefaultTip => requiresRings ? "Place ring?" : "Use Altar?";

		private void Start()
		{
			Reset();
		}

		private void Reset()
		{
			interactTrigger.hoverTip = DefaultTip;
			groom = (bride = null);
			TMP_Text obj = groomTxt;
			if (obj != null)
			{
				obj.SetText(string.Empty, true);
			}
			TMP_Text obj2 = brideTxt;
			if (obj2 != null)
			{
				obj2.SetText(string.Empty, true);
			}
			GameObject obj3 = groomRing;
			if (obj3 != null)
			{
				obj3.SetActive(false);
			}
			GameObject obj4 = brideRing;
			if (obj4 != null)
			{
				obj4.SetActive(false);
			}
		}

		public void MarryPlayer(PlayerControllerB player)
		{
			if (!ceramonyComplete && JLLExtentions.IsLocalPlayer(player))
			{
				RequestMarriageServerRpc((int)player.playerClientId);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void RequestMarriageServerRpc(int playerWhoSent)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2669310054u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerWhoSent);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2669310054u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			if (ceramonyComplete || playerWhoSent < 0)
			{
				return;
			}
			int num = (((Object)(object)bride == (Object)null) ? (-1) : ((int)bride.playerClientId));
			int groomId = -1;
			if (num == playerWhoSent)
			{
				CancelWeddingClientRpc();
				return;
			}
			PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerWhoSent];
			if (MarriageManager.HasPartner(val3))
			{
				SendFeedbackClientRpc(playerWhoSent, 0);
				return;
			}
			if (requiresRings)
			{
				if (!((Object)(object)val3.currentlyHeldObjectServer != (Object)null) || !((Object)(object)val3.currentlyHeldObjectServer.itemProperties != (Object)null) || !val3.currentlyHeldObjectServer.itemProperties.itemName.Contains("ring", StringComparison.InvariantCultureIgnoreCase))
				{
					SendFeedbackClientRpc(playerWhoSent, 1);
					return;
				}
				RemoveRingItemClientRpc(playerWhoSent, val3.currentItemSlot);
			}
			if (num == -1)
			{
				num = playerWhoSent;
			}
			else
			{
				groomId = playerWhoSent;
			}
			UpdateCeramonyClientRpc(num, groomId);
		}

		[ClientRpc]
		private void UpdateCeramonyClientRpc(int brideId, int groomId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1016687170u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, brideId);
				BytePacker.WriteValueBitPacked(val2, groomId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1016687170u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			Plugin.mls.LogInfo((object)$"{brideId} {groomId}");
			if (brideId >= 0)
			{
				bride = StartOfRound.Instance.allPlayerScripts[brideId];
				GameObject obj = brideRing;
				if (obj != null)
				{
					obj.SetActive(true);
				}
				TMP_Text obj2 = brideTxt;
				if (obj2 != null)
				{
					obj2.SetText(bride.playerUsername, true);
				}
			}
			else
			{
				bride = null;
				GameObject obj3 = brideRing;
				if (obj3 != null)
				{
					obj3.SetActive(false);
				}
				TMP_Text obj4 = brideTxt;
				if (obj4 != null)
				{
					obj4.SetText(string.Empty, true);
				}
			}
			if (groomId >= 0)
			{
				groom = StartOfRound.Instance.allPlayerScripts[groomId];
				GameObject obj5 = groomRing;
				if (obj5 != null)
				{
					obj5.SetActive(true);
				}
				TMP_Text obj6 = groomTxt;
				if (obj6 != null)
				{
					obj6.SetText(groom.playerUsername, true);
				}
			}
			else
			{
				groom = null;
				GameObject obj7 = groomRing;
				if (obj7 != null)
				{
					obj7.SetActive(false);
				}
				TMP_Text obj8 = groomTxt;
				if (obj8 != null)
				{
					obj8.SetText(string.Empty, true);
				}
			}
			if ((Object)(object)bride != (Object)null && (Object)(object)groom != (Object)null)
			{
				MarriageManager.Marry(bride, groom);
				ceramonyComplete = true;
				interactTrigger.disabledHoverTip = bride.playerUsername + " & " + groom.playerUsername + " have been wed";
				interactTrigger.interactable = false;
				marriageEvent.Invoke();
			}
			else if ((Object)(object)bride != (Object)null)
			{
				interactTrigger.hoverTip = (JLLExtentions.IsLocalPlayer(bride) ? "Cancel Wedding" : ("Marry " + bride.playerUsername + "?"));
			}
			else
			{
				interactTrigger.hoverTip = DefaultTip;
			}
		}

		[ClientRpc]
		private void SendFeedbackClientRpc(int clientId, int id)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1235078690u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				BytePacker.WriteValueBitPacked(val2, id);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1235078690u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (id >= 0 && id < errorFeedback.Length && JLLExtentions.IsLocalPlayer(StartOfRound.Instance.allPlayerScripts[clientId]))
				{
					JHudHelper.QueueDisplayTip(header, errorFeedback[id], true, false, "LC_Tip1");
				}
			}
		}

		[ClientRpc]
		private void RemoveRingItemClientRpc(int clientId, int slot)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1592172660u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, clientId);
					BytePacker.WriteValueBitPacked(val2, slot);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1592172660u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					StartOfRound.Instance.allPlayerScripts[clientId].DestroyItemInSlot(slot);
				}
			}
		}

		[ClientRpc]
		private void CancelWeddingClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2284013184u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2284013184u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if ((Object)(object)bride != (Object)null)
				{
					HUDManager.Instance.AddTextToChatOnServer(bride.playerUsername + " has called off the wedding!", -1);
				}
				Reset();
			}
		}

		public void HoneyMoonTeleport(PlayerControllerB player)
		{
			if (JLLExtentions.IsLocalPlayer(player))
			{
				if (MarriageManager.HasPartner(player))
				{
					HoneyMoonTeleportServerRpc((int)player.playerClientId);
				}
				else
				{
					JHudHelper.QueueDisplayTip("Honeymoon", "You must be married to go on Honeymoon!", true, false, "LC_Tip1");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void HoneyMoonTeleportServerRpc(int playerWhoSent)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_00d7: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4002669869u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerWhoSent);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4002669869u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				bool inside;
				Vector3 val3 = FindHoneymoon(out inside);
				NavMeshHit val4 = default(NavMeshHit);
				if (NavMesh.SamplePosition(val3, ref val4, 3f, -1))
				{
					val3 = ((NavMeshHit)(ref val4)).position + Vector3.up;
				}
				HoneyMoonTeleportClientRpc(playerWhoSent, val3, inside);
			}
		}

		private Vector3 FindHoneymoon(out bool inside)
		{
			//IL_0014: 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_00cf: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			inside = true;
			Vector3 result = default(Vector3);
			if (JLevelPropertyRegistry.GetPOI("honeymoon", ref result))
			{
				return result;
			}
			LungProp[] array = Object.FindObjectsOfType<LungProp>();
			LungProp[] array2 = array;
			foreach (LungProp val in array2)
			{
				if (val.isLungDocked)
				{
					return ((Component)val).transform.position;
				}
			}
			EntranceTeleport[] array3 = (from entrance in Object.FindObjectsOfType<EntranceTeleport>()
				where !entrance.isEntranceToBuilding
				select entrance).ToArray();
			if (array3.Length != 0)
			{
				return ((Component)array3[Random.Range(0, array3.Length)]).transform.position;
			}
			inside = false;
			return new Vector3(0f, 0f, -14f);
		}

		[ClientRpc]
		private void HoneyMoonTeleportClientRpc(int playerWhoSent, Vector3 pos, bool inside)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00b1: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3171295165u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerWhoSent);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref inside, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3171295165u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerWhoSent];
				PlayerControllerB partner = MarriageManager.GetPartner(val3);
				if (!((Object)(object)partner == (Object)null))
				{
					val3.isInsideFactory = inside;
					partner.isInsideFactory = inside;
					val3.TeleportPlayer(pos, false, 0f, false, true);
					partner.TeleportPlayer(pos, false, 0f, false, true);
				}
			}
		}

		public void FileDivorce(PlayerControllerB player)
		{
			if (JLLExtentions.IsLocalPlayer(player))
			{
				if (MarriageManager.HasPartner(player))
				{
					FileDivorceServerRpc((int)player.playerClientId);
				}
				else
				{
					JHudHelper.QueueDisplayTip("Divorce", "You must be married to get divorced!", true, false, "LC_Tip1");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void FileDivorceServerRpc(int playerWhoSent)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3172716445u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerWhoSent);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3172716445u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					FileDivorceClientRpc(playerWhoSent);
				}
			}
		}

		[ClientRpc]
		private void FileDivorceClientRpc(int playerWhoSent)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2930509885u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerWhoSent);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2930509885u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					MarriageManager.Divorce(StartOfRound.Instance.allPlayerScripts[playerWhoSent]);
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2669310054u, new RpcReceiveHandler(__rpc_handler_2669310054), "RequestMarriageServerRpc");
			((NetworkBehaviour)this).__registerRpc(1016687170u, new RpcReceiveHandler(__rpc_handler_1016687170), "UpdateCeramonyClientRpc");
			((NetworkBehaviour)this).__registerRpc(1235078690u, new RpcReceiveHandler(__rpc_handler_1235078690), "SendFeedbackClientRpc");
			((NetworkBehaviour)this).__registerRpc(1592172660u, new RpcReceiveHandler(__rpc_handler_1592172660), "RemoveRingItemClientRpc");
			((NetworkBehaviour)this).__registerRpc(2284013184u, new RpcReceiveHandler(__rpc_handler_2284013184), "CancelWeddingClientRpc");
			((NetworkBehaviour)this).__registerRpc(4002669869u, new RpcReceiveHandler(__rpc_handler_4002669869), "HoneyMoonTeleportServerRpc");
			((NetworkBehaviour)this).__registerRpc(3171295165u, new RpcReceiveHandler(__rpc_handler_3171295165), "HoneyMoonTeleportClientRpc");
			((NetworkBehaviour)this).__registerRpc(3172716445u, new RpcReceiveHandler(__rpc_handler_3172716445), "FileDivorceServerRpc");
			((NetworkBehaviour)this).__registerRpc(2930509885u, new RpcReceiveHandler(__rpc_handler_2930509885), "FileDivorceClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

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

		private static void __rpc_handler_1016687170(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int brideId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref brideId);
				int groomId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref groomId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MarriageCreator)(object)target).UpdateCeramonyClientRpc(brideId, groomId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1235078690(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int clientId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				int id = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref id);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MarriageCreator)(object)target).SendFeedbackClientRpc(clientId, id);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1592172660(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int clientId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				int slot = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref slot);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MarriageCreator)(object)target).RemoveRingItemClientRpc(clientId, slot);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2284013184(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MarriageCreator)(object)target).CancelWeddingClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_3171295165(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_004f: 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_006d: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerWhoSent = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerWhoSent);
				Vector3 pos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
				bool inside = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref inside, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MarriageCreator)(object)target).HoneyMoonTeleportClientRpc(playerWhoSent, pos, inside);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		protected internal override string __getTypeName()
		{
			return "MarriageCreator";
		}
	}
	public class MaskData : NetworkBehaviour
	{
		public HauntedMaskItem mask;

		public PlayerControllerB previousPlayerHeldBy;

		public PlayerControllerB previousPlayerPartner;

		[ClientRpc]
		public void CreateMimicClientRpc(NetworkObjectReference netObjectRef, int playerId, bool inFactory)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_008c: 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)
			//IL_00bf: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2790610568u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
					BytePacker.WriteValueBitPacked(val2, playerId);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref inFactory, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2790610568u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					((MonoBehaviour)this).StartCoroutine(waitForMimicEnemySpawn(netObjectRef, StartOfRound.Instance.allPlayerScripts[playerId], inFactory));
				}
			}
		}

		public IEnumerator waitForMimicEnemySpawn(NetworkObjectReference netObjectRef, PlayerControllerB player, bool inFactory)
		{
			//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)
			NetworkObject netObject = null;
			float startTime = Time.realtimeSinceStartup;
			yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - startTime > 20f || ((NetworkObjectReference)(ref netObjectRef)).TryGet(ref netObject, (NetworkManager)null)));
			if ((Object)(object)player.deadBody == (Object)null)
			{
				startTime = Time.realtimeSinceStartup;
				yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - startTime > 20f || (Object)(object)player.deadBody != (Object)null));
			}
			if (!((Object)(object)player.deadBody == (Object)null))
			{
				player.deadBody.DeactivateBody(false);
				if ((Object)(object)netObject != (Object)null)
				{
					Debug.Log((object)"Got network object for mask enemy client");
					MaskedPlayerEnemy component = ((Component)netObject).GetComponent<MaskedPlayerEnemy>();
					component.mimickingPlayer = player;
					component.SetSuit(player.currentSuitID);
					((EnemyAI)component).SetEnemyOutside(!inFactory);
					component.SetVisibilityOfMaskedEnemy();
					component.SetMaskType(mask.maskTypeId);
					player.redirectToEnemy = (EnemyAI)(object)component;
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2790610568u, new RpcReceiveHandler(__rpc_handler_2790610568), "CreateMimicClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_2790610568(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_003e: 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_005d: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				bool inFactory = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref inFactory, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MaskData)(object)target).CreateMimicClientRpc(netObjectRef, playerId, inFactory);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "MaskData";
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace SeichiAdditions.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

BepInEx/plugins/seichi/TestAccount666.StatueThingy.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TestAccount666.StatueThingy.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TestAccount666.StatueThingy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StatueThingy")]
[assembly: AssemblyTitle("TestAccount666.StatueThingy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 StatueThingy
{
	[BepInPlugin("TestAccount666.StatueThingy", "StatueThingy", "1.0.0")]
	public class StatueThingy : BaseUnityPlugin
	{
		public static StatueThingy Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		internal static void Patch()
		{
			//IL_000d: 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_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("TestAccount666.StatueThingy");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			ExecuteNetcodePatcher();
			Logger.LogInfo((object)"TestAccount666.StatueThingy v1.0.0 has loaded!");
		}

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

		private static void ExecuteNetcodePatcher()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Type[] types = executingAssembly.GetTypes();
			foreach (Type type in types)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	[AddComponentMenu("TestAccount666/StatueThingy/StatueThingySync")]
	public class StatueThingySync : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <WaitUntilInitializationAndApply>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int index;

			public StatueThingySync <>4__this;

			private string[] <>s__1;

			private int <>s__2;

			private string <triggerName>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__1 = null;
				<triggerName>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)delegate
					{
						int result;
						if (<>4__this != null && <>4__this.animator != null)
						{
							string[] poseTriggers = <>4__this.poseTriggers;
							if (poseTriggers != null)
							{
								result = ((poseTriggers.Length > 0) ? 1 : 0);
								goto IL_0020;
							}
						}
						result = 0;
						goto IL_0020;
						IL_0020:
						return (byte)result != 0;
					});
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (<>4__this._poseTriggersHash.Count <= 0)
					{
						<>s__1 = <>4__this.poseTriggers;
						for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++)
						{
							<triggerName>5__3 = <>s__1[<>s__2];
							<>4__this._poseTriggersHash.AddLast(Animator.StringToHash(<triggerName>5__3));
							<triggerName>5__3 = null;
						}
						<>s__1 = null;
					}
					<>4__this.ApplyMeshAndMaterial(index);
					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 <WaitUntilInitializationAndSync>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public StatueThingySync <>4__this;

			private Random <seededRandom>5__1;

			private int <index>5__2;

			private string[] <>s__3;

			private int <>s__4;

			private string <triggerName>5__5;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<seededRandom>5__1 = null;
				<>s__3 = null;
				<triggerName>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)delegate
					{
						int result;
						if (<>4__this != null && <>4__this.animator != null)
						{
							string[] poseTriggers = <>4__this.poseTriggers;
							if (poseTriggers != null)
							{
								result = ((poseTriggers.Length > 0) ? 1 : 0);
								goto IL_0020;
							}
						}
						result = 0;
						goto IL_0020;
						IL_0020:
						return (byte)result != 0;
					});
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!((NetworkBehaviour)<>4__this).IsHost && !((NetworkBehaviour)<>4__this).IsServer)
					{
						return false;
					}
					if (<>4__this._poseTriggersHash.Count <= 0)
					{
						<>s__3 = <>4__this.poseTriggers;
						for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
						{
							<triggerName>5__5 = <>s__3[<>s__4];
							<>4__this._poseTriggersHash.AddLast(Animator.StringToHash(<triggerName>5__5));
							<triggerName>5__5 = null;
						}
						<>s__3 = null;
					}
					<seededRandom>5__1 = new Random(StartOfRound.Instance.randomMapSeed);
					<index>5__2 = <seededRandom>5__1.Next(0, <>4__this.poseTriggers.Length);
					<>4__this.SyncPoseClientRpc(<index>5__2);
					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 string[] poseTriggers = Array.Empty<string>();

		[SerializeField]
		private Animator? animator;

		private readonly LinkedList<int> _poseTriggersHash = new LinkedList<int>();

		[ClientRpc]
		private void SyncPoseClientRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3043677422u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, index);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3043677422u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (((Behaviour)this).isActiveAndEnabled)
				{
					((MonoBehaviour)this).StartCoroutine(WaitUntilInitializationAndApply(index));
				}
			}
		}

		private void Start()
		{
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				NetworkObject component = ((Component)this).GetComponent<NetworkObject>();
				if (!component.IsSpawned)
				{
					component.Spawn(true);
				}
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			((MonoBehaviour)this).StartCoroutine(WaitUntilInitializationAndSync());
		}

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

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

		private void ApplyMeshAndMaterial(int index)
		{
			Animator? obj = animator;
			if (obj != null)
			{
				obj.SetTrigger(_poseTriggersHash.ElementAt(index));
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3043677422u, new RpcReceiveHandler(__rpc_handler_3043677422), "SyncPoseClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "StatueThingySync";
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TestAccount666.StatueThingy";

		public const string PLUGIN_NAME = "StatueThingy";

		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)
		{
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace TestAccount666.StatueThingy.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}