Decompiled source of Masked Mask v1.1.2

OreoM.MaskedMask.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using MaskedMask.Network;
using MaskedMask.Patches;
using Microsoft.CodeAnalysis;
using OreoM.MaskedMask.NetcodePatcher;
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("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("OreoM.MaskedMask")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2")]
[assembly: AssemblyProduct("MaskedMask")]
[assembly: AssemblyTitle("OreoM.MaskedMask")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.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 MaskedMask
{
	[BepInPlugin("OreoM.MaskedMask", "MaskedMask", "1.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MaskedMask : BaseUnityPlugin
	{
		public const string LethalConfigGUID = "ainavt.lc.lethalconfig";

		internal MaskedMaskConfig ConfigOptions;

		public static MaskedMask Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			ConfigOptions = new MaskedMaskConfig(((BaseUnityPlugin)this).Config);
			Patch();
			NetcodePatch();
			Logger.LogInfo((object)"OreoM.MaskedMask v1.1.2 has loaded!");
		}

		private void NetcodePatch()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

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

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

		public readonly ConfigEntry<int> convertedMaskValue;

		public MaskedMaskConfig(ConfigFile cfg)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			lethalConfigLoaded = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
			cfg.SaveOnConfigSet = false;
			convertedMaskValue = cfg.Bind<int>("General", "Converted Mask Value", 40, new ConfigDescription("The value of masks spawned by a Masked converting a player", (AcceptableValueBase)(object)new AcceptableValueRange<int>(28, 51), Array.Empty<object>()));
			ClearOrphanedEntries(cfg);
			cfg.Save();
			cfg.SaveOnConfigSet = true;
			if (lethalConfigLoaded)
			{
				AddLethalConfigItems();
				ConfigLethalConfigModEntry();
			}
		}

		private void ClearOrphanedEntries(ConfigFile cfg)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
			dictionary.Clear();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void AddLethalConfigItems()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			ConfigEntry<int> obj = convertedMaskValue;
			IntSliderOptions val = new IntSliderOptions();
			((BaseRangeOptions<int>)val).Min = 28;
			((BaseRangeOptions<int>)val).Max = 51;
			((BaseOptions)val).RequiresRestart = false;
			IntSliderConfigItem val2 = new IntSliderConfigItem(obj, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void ConfigLethalConfigModEntry()
		{
			LethalConfigManager.SetModDescription("Masked Mask configs");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "OreoM.MaskedMask";

		public const string PLUGIN_NAME = "MaskedMask";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}
namespace MaskedMask.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void PostStart(GameNetworkManager __instance)
		{
			MaskedMaskNetwork.CreateAndRegisterPrefab();
		}

		[HarmonyPatch("Disconnect")]
		[HarmonyPrefix]
		private static void PreDisconnect(GameNetworkManager __instance)
		{
			MaskedMaskNetwork.DespawnNetworkHandler();
		}
	}
	[HarmonyPatch(typeof(HauntedMaskItem))]
	internal class HauntedMaskItemPatches
	{
		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void PostLateUpdate(HauntedMaskItem __instance)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((GrabbableObject)__instance).parentObject != (Object)null && ((Object)((GrabbableObject)__instance).parentObject.parent).name == "HeadMaskComedy")
			{
				((Component)__instance).transform.rotation = ((GrabbableObject)__instance).parentObject.rotation;
				((Component)__instance).transform.position = ((GrabbableObject)__instance).parentObject.position;
			}
		}

		[HarmonyPatch("CreateMimicServerRpc")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> TranspileCreateMimicServerRpc(IEnumerable<CodeInstruction> codes)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldloc_2, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HauntedMaskItemHelper), "AttachMaskWithValue", (Type[])null, (Type[])null))
			};
			return new CodeMatcher(codes, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Stloc_2, (object)null, (string)null)
			}).Advance(1).Insert(array)
				.InstructionEnumeration();
		}
	}
	internal static class HauntedMaskItemHelper
	{
		public static void AttachMaskWithValue(HauntedMaskItem maskInstance, NetworkObjectReference maskedRef)
		{
			NetworkObject val = default(NetworkObject);
			if (!((NetworkObjectReference)(ref maskedRef)).TryGet(ref val, (NetworkManager)null))
			{
				MaskedMask.Logger.LogError((object)"TryGet maskedPlayerEnemy from NetObjRef failed");
				return;
			}
			MaskedPlayerEnemy component = ((Component)val).GetComponent<MaskedPlayerEnemy>();
			if ((Object)(object)component == (Object)null)
			{
				MaskedMask.Logger.LogError((object)"Masked in GrabMask function did not have MaskedPlayerEnemy component.");
			}
			else
			{
				MaskedPlayerEnemyHelper.SpawnMaskScrap(component, (MaskedPlayerEnemyHelper.MaskIndex)component.maskTypeIndex, ((GrabbableObject)maskInstance).scrapValue);
			}
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	internal class MaskedPlayerEnemyPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void PostStart(MaskedPlayerEnemy __instance)
		{
			if (NetworkManager.Singleton.IsServer && !MaskedPlayerEnemyHelper.masks.TryGetValue((EnemyAI)(object)__instance, out var _))
			{
				MaskedPlayerEnemyHelper.SpawnMaskScrap(__instance, MaskedPlayerEnemyHelper.MaskIndex.COMEDY, MaskedMask.Instance.ConfigOptions.convertedMaskValue.Value);
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void PreUpdate(MaskedPlayerEnemy __instance)
		{
			if (!MaskedPlayerEnemyHelper.masks.TryGetValue((EnemyAI)(object)__instance, out var value))
			{
				MaskedMask.Logger.LogError((object)"Could not find mask to check grab status");
			}
			else if (((GrabbableObject)value.mask).hasBeenHeld && !((EnemyAI)__instance).isEnemyDead)
			{
				__instance.staminaTimer = 15f;
				((EnemyAI)__instance).creatureAnimator.SetBool("Running", true);
				__instance.running = true;
			}
		}

		[HarmonyPatch("SetMaskGlow")]
		[HarmonyPostfix]
		private static void PostSetMaskGlow(MaskedPlayerEnemy __instance, bool enable)
		{
			if (!MaskedPlayerEnemyHelper.masks.TryGetValue((EnemyAI)(object)__instance, out var value))
			{
				MaskedMask.Logger.LogError((object)"Could not find mask to glow");
			}
			else if (!((GrabbableObject)value.mask).hasBeenHeld)
			{
				__instance.maskTypes[__instance.maskTypeIndex].SetActive(enable);
				((GrabbableObject)value.mask).EnableItemMeshes(!enable);
			}
		}

		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void PostLateUpdate(MaskedPlayerEnemy __instance)
		{
			//IL_004f: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			if (!MaskedPlayerEnemyHelper.masks.TryGetValue((EnemyAI)(object)__instance, out var value))
			{
				MaskedMask.Logger.LogError((object)"Could not find mask to update");
				return;
			}
			HauntedMaskItem mask = value.mask;
			if (((GrabbableObject)mask).hasBeenHeld && !value.hasBeenHeld)
			{
				value.hasBeenHeld = true;
				((GrabbableObject)mask).originalScale = new Vector3(0.1646f, 0.1646f, 0.1646f);
				((Component)mask).transform.localScale = ((GrabbableObject)mask).originalScale;
			}
		}

		[HarmonyPatch("TeleportMaskedEnemyAndSync")]
		[HarmonyPostfix]
		private static void PostTeleportMaskedEnemyAndSync(MaskedPlayerEnemy __instance)
		{
			if (!MaskedPlayerEnemyHelper.masks.TryGetValue((EnemyAI)(object)__instance, out var value))
			{
				MaskedMask.Logger.LogError((object)"Could not find mask to change isInFactory property");
			}
			else if (!value.hasBeenHeld)
			{
				((GrabbableObject)value.mask).isInFactory = !((EnemyAI)__instance).isOutside;
			}
		}

		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void PostKillEnemy(MaskedPlayerEnemy __instance)
		{
			if (!MaskedPlayerEnemyHelper.masks.TryGetValue((EnemyAI)(object)__instance, out var value))
			{
				MaskedMask.Logger.LogWarning((object)"Could not find mask to drop");
				return;
			}
			HauntedMaskItem mask = value.mask;
			((GrabbableObject)mask).isHeldByEnemy = false;
			((GrabbableObject)mask).grabbableToEnemies = true;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> TranspilekillAnimation(IEnumerable<CodeInstruction> codes)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			return new CodeMatcher(codes, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Vector3), "zero"), (string)null)
			}).Advance(1).SetOpcodeAndAdvance(OpCodes.Ldc_I4_1)
				.InstructionEnumeration();
		}
	}
	internal static class MaskedPlayerEnemyHelper
	{
		public enum MaskIndex
		{
			COMEDY,
			TRAGEDY
		}

		public static GameObject comedyPrefab = null;

		public static GameObject tragedyPrefab = null;

		public static readonly Dictionary<EnemyAI, HauntedMaskItemInfo> masks = new Dictionary<EnemyAI, HauntedMaskItemInfo>();

		public static void PopulateMaskedPlayerEnemyHelperInfo()
		{
			comedyPrefab = StartOfRound.Instance.allItemsList.itemsList.Find((Item item) => ((Object)item).name == "ComedyMask").spawnPrefab;
			tragedyPrefab = StartOfRound.Instance.allItemsList.itemsList.Find((Item item) => ((Object)item).name == "TragedyMask").spawnPrefab;
		}

		public static void SpawnMaskScrap(MaskedPlayerEnemy maskedInstance, MaskIndex maskType, int value)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = null;
			switch (maskType)
			{
			case MaskIndex.COMEDY:
				val = comedyPrefab;
				break;
			case MaskIndex.TRAGEDY:
				val = tragedyPrefab;
				break;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)maskedInstance).transform.position, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
			NetworkObject component = val2.GetComponent<NetworkObject>();
			component.Spawn(false);
			NetworkObject component2 = ((Component)maskedInstance).GetComponent<NetworkObject>();
			MaskedMaskNetwork.Instance.GrabMaskEveryoneRpc(NetworkObjectReference.op_Implicit(component2), NetworkObjectReference.op_Implicit(component), value);
		}
	}
	internal struct HauntedMaskItemInfo
	{
		public HauntedMaskItem mask;

		public bool hasBeenHeld;
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatches
	{
		[HarmonyPatch("DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		private static void PostDespawnPropsAtEndOfRound(RoundManager __instance)
		{
			MaskedPlayerEnemyHelper.masks.Clear();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void PostStart(StartOfRound __instance)
		{
			MaskedMaskNetwork.SpawnNetworkHandler();
			MaskedPlayerEnemyHelper.PopulateMaskedPlayerEnemyHelperInfo();
		}
	}
}
namespace MaskedMask.Network
{
	internal class MaskedMaskNetwork : NetworkBehaviour
	{
		private static GameObject prefab;

		public static MaskedMaskNetwork Instance { get; private set; }

		public static void CreateAndRegisterPrefab()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)prefab != (Object)null))
			{
				prefab = new GameObject("OreoM.MaskedMask Prefab");
				GameObject obj = prefab;
				((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x3D);
				NetworkObject val = prefab.AddComponent<NetworkObject>();
				val.GlobalObjectIdHash = XXHash.Hash32(((Object)prefab).name);
				prefab.AddComponent<MaskedMaskNetwork>();
				NetworkManager.Singleton.AddNetworkPrefab(prefab);
				MaskedMask.Logger.LogInfo((object)"Networ prefab created and registered");
			}
		}

		public static void SpawnNetworkHandler()
		{
			if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)
			{
				Object.Instantiate<GameObject>(prefab).GetComponent<NetworkObject>().Spawn(false);
				MaskedMask.Logger.LogInfo((object)"Network handler spawned");
			}
		}

		public static void DespawnNetworkHandler()
		{
			if ((Object)(object)Instance != (Object)null && ((NetworkBehaviour)Instance).NetworkObject.IsSpawned && (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost))
			{
				((NetworkBehaviour)Instance).NetworkObject.Despawn(true);
				MaskedMask.Logger.LogInfo((object)"Network handler despawned");
			}
		}

		private void Awake()
		{
			Instance = this;
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void GrabMaskEveryoneRpc(NetworkObjectReference maskedPlayerEnemyNetObjRef, NetworkObjectReference maskItemNetObjRef, int maskValue)
		{
			//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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				RpcParams val2 = default(RpcParams);
				FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(800061607u, val2, val, (SendTo)6, (RpcDelivery)0);
				((FastBufferWriter)(ref val3)).WriteValueSafe<NetworkObjectReference>(ref maskedPlayerEnemyNetObjRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val3)).WriteValueSafe<NetworkObjectReference>(ref maskItemNetObjRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val3, maskValue);
				((NetworkBehaviour)this).__endSendRpc(ref val3, 800061607u, val2, val, (SendTo)6, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			NetworkObject val4 = default(NetworkObject);
			if (!((NetworkObjectReference)(ref maskedPlayerEnemyNetObjRef)).TryGet(ref val4, (NetworkManager)null))
			{
				MaskedMask.Logger.LogError((object)"TryGet maskedPlayerEnemy from NetObjRef failed");
				return;
			}
			NetworkObject val5 = default(NetworkObject);
			if (!((NetworkObjectReference)(ref maskItemNetObjRef)).TryGet(ref val5, (NetworkManager)null))
			{
				MaskedMask.Logger.LogError((object)"TryGet maskItem from NetObjRef failed");
				return;
			}
			HauntedMaskItem component = ((Component)val5).GetComponent<HauntedMaskItem>();
			if ((Object)(object)component == (Object)null)
			{
				MaskedMask.Logger.LogError((object)"Mask in GrabMask function did not have HauntedMaskItem component.");
				return;
			}
			MaskedPlayerEnemy component2 = ((Component)val4).GetComponent<MaskedPlayerEnemy>();
			if ((Object)(object)component2 == (Object)null)
			{
				MaskedMask.Logger.LogError((object)"Masked in GrabMask function did not have MaskedPlayerEnemy component.");
				return;
			}
			if (MaskedPlayerEnemyHelper.masks.TryGetValue((EnemyAI)(object)component2, out var value))
			{
				MaskedMask.Logger.LogWarning((object)$"Duplicate Masked entry... skipping {maskValue}");
				return;
			}
			component2.maskTypes[0].SetActive(false);
			component2.maskTypes[1].SetActive(false);
			((Component)component).transform.localScale = new Vector3(0.13f, 0.13f, 0.13f);
			((GrabbableObject)component).parentObject = ((Component)component2.maskTypes[0].transform.GetChild(2)).transform;
			((GrabbableObject)component).SetScrapValue(maskValue);
			((GrabbableObject)component).isHeldByEnemy = true;
			((GrabbableObject)component).grabbable = true;
			((GrabbableObject)component).grabbableToEnemies = false;
			value = default(HauntedMaskItemInfo);
			value.mask = component;
			value.hasBeenHeld = false;
			HauntedMaskItemInfo value2 = value;
			MaskedPlayerEnemyHelper.masks[(EnemyAI)(object)component2] = value2;
		}

		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(800061607u, new RpcReceiveHandler(__rpc_handler_800061607), "GrabMaskEveryoneRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_800061607(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_0059: 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_007b: 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 maskedPlayerEnemyNetObjRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref maskedPlayerEnemyNetObjRef, default(ForNetworkSerializable));
				NetworkObjectReference maskItemNetObjRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref maskItemNetObjRef, default(ForNetworkSerializable));
				int maskValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref maskValue);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MaskedMaskNetwork)(object)target).GrabMaskEveryoneRpc(maskedPlayerEnemyNetObjRef, maskItemNetObjRef, maskValue);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "MaskedMaskNetwork";
		}
	}
}
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 OreoM.MaskedMask.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}