Decompiled source of NightOfTheLivingMimic v1.0.0

SDBBZR.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SDBBZR")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Slayer's Dead Bodies Become Zombies Randomly")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SDBBZR")]
[assembly: AssemblyTitle("SDBBZR")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 SlayerDeadBodiesBecomeZombiesRandomly
{
	internal class BodyCheck : MonoBehaviour
	{
		private float timeSinceLastCheck = 0f;

		public ulong owner = 0uL;

		public int timesRevived = 0;

		public bool hasZombied = false;

		public bool currentlyZombie = false;

		public DeadBodyInfo instance;

		public static int timerModifier;

		public static int chanceModifier;

		public void Update()
		{
			if (!currentlyZombie && !StartOfRound.Instance.shipIsLeaving && (!hasZombied || SDBBZRMain.continuous.Value))
			{
				timeSinceLastCheck += Time.deltaTime;
				if (timeSinceLastCheck >= (float)(SDBBZRMain.timer.Value + timerModifier))
				{
					becomeZombieCheck();
					timeSinceLastCheck = 0f;
				}
			}
		}

		public void becomeZombieCheck()
		{
			int num = Random.Range(0, 101);
			Debug.Log((object)num);
			num += timesRevived * SDBBZRMain.chanceDecrease.Value;
			if ((float)num < SDBBZRMain.percentChance.Value + (float)chanceModifier)
			{
				setZombie();
			}
		}

		public void setZombie()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			timeSinceLastCheck = 0f;
			hasZombied = true;
			currentlyZombie = true;
			GameObject val = Object.Instantiate<GameObject>(Misc.getEnemyByName("Masked").enemyType.enemyPrefab, ((Component)instance.grabBodyObject).transform.position, Quaternion.Euler(new Vector3(0f, 0f, 0f)));
			val.GetComponentInChildren<NetworkObject>().Spawn(true);
			RoundManager.Instance.SpawnedEnemies.Add(val.GetComponent<EnemyAI>());
			NetworkObjectReference val2 = NetworkObjectReference.op_Implicit(val.GetComponentInChildren<NetworkObject>());
			zombieBody zombieBody2 = val.AddComponent<zombieBody>();
			zombieBody2.bodyID = owner;
			Networker.Instance.fixMaskedServerRpc(instance.playerScript.playerClientId, ((NetworkObjectReference)(ref val2)).NetworkObjectId);
		}
	}
	internal class zombieBody : MonoBehaviour
	{
		public ulong bodyID = 0uL;
	}
	internal class Misc
	{
		public static SpawnableEnemyWithRarity getEnemyByName(string name)
		{
			List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				list = list.Union(val.Enemies).Union(val.OutsideEnemies).Union(val.DaytimeEnemies)
					.ToList();
			}
			list = (from x in list
				group x by x.enemyType.enemyName into g
				select g.First() into x
				orderby x.enemyType.enemyName
				select x).ToList();
			SpawnableEnemyWithRarity val2 = ((IEnumerable<SpawnableEnemyWithRarity>)list).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity x) => x.enemyType.enemyName == name));
			if (val2 == null)
			{
				SelectableLevel[] levels2 = StartOfRound.Instance.levels;
				foreach (SelectableLevel val3 in levels2)
				{
					val2 = ((IEnumerable<SpawnableEnemyWithRarity>)val3.Enemies).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.ToLower() == name.ToLower()));
					if (val2 == null)
					{
						val2 = ((IEnumerable<SpawnableEnemyWithRarity>)val3.DaytimeEnemies).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.ToLower() == name.ToLower()));
					}
					if (val2 == null)
					{
						val2 = ((IEnumerable<SpawnableEnemyWithRarity>)val3.OutsideEnemies).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.ToLower() == name.ToLower()));
					}
				}
			}
			if (val2 == null)
			{
				SDBBZRMain.CustomLogger.LogWarning((object)("Enemy '" + name + "' not found. Available enemies: " + string.Join(", ", list.Select((SpawnableEnemyWithRarity e) => e.enemyType.enemyName))));
				return null;
			}
			return val2;
		}

		public static PlayerControllerB GetPlayerByUserID(ulong userID)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.playerClientId == userID)
				{
					return val;
				}
			}
			return null;
		}

		public static int getPlayerIntFromUserID(ulong userID)
		{
			int result = -1;
			for (int i = 0; i < StartOfRound.Instance.allPlayerObjects.Count(); i++)
			{
				PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[i].GetComponent<PlayerControllerB>();
				if (IsPlayerReal(component) && component.playerClientId == userID)
				{
					result = i;
					break;
				}
			}
			return result;
		}

		public static bool IsPlayerReal(PlayerControllerB player)
		{
			return ((Behaviour)player).isActiveAndEnabled && player.isPlayerControlled;
		}
	}
	internal class Networker : NetworkBehaviour
	{
		public static Networker Instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (!((NetworkBehaviour)this).IsServer)
			{
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void addComponentToBodyServerRPC(ulong body)
		{
			//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)
			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(3051737443u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, body);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3051737443u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					addComponentToBodyClientRPC(body);
				}
			}
		}

		[ClientRpc]
		public void addComponentToBodyClientRPC(ulong body)
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3744571001u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, body);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3744571001u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkBehaviour)this).IsHost)
			{
				PlayerControllerB playerByUserID = Misc.GetPlayerByUserID(body);
				if (!((Object)(object)playerByUserID.deadBody == (Object)null))
				{
					BodyCheck bodyCheck = ((Component)playerByUserID.deadBody).gameObject.AddComponent<BodyCheck>();
					bodyCheck.owner = body;
					bodyCheck.instance = playerByUserID.deadBody;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void spawnBodyServerRPC(ulong body, Vector3 position, ulong ID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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(3143474351u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, body);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					BytePacker.WriteValueBitPacked(val2, ID);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3143474351u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					spawnBodyClientRPC(body, position, ID);
				}
			}
		}

		[ClientRpc]
		public void spawnBodyClientRPC(ulong body, Vector3 position, ulong ID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1860259407u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, body);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				BytePacker.WriteValueBitPacked(val2, ID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1860259407u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB playerByUserID = Misc.GetPlayerByUserID(body);
				((Component)playerByUserID.deadBody).gameObject.SetActive(true);
				if (((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost)
				{
					BodyCheck component = ((Component)playerByUserID.deadBody).GetComponent<BodyCheck>();
					component.currentlyZombie = false;
					component.timesRevived++;
				}
				playerByUserID.deadBody.deactivated = false;
				playerByUserID.deadBody.SetBodyPartsKinematic(false);
				playerByUserID.deadBody.attachedTo = null;
				playerByUserID.deadBody.attachedLimb = null;
				playerByUserID.deadBody.secondaryAttachedLimb = null;
				playerByUserID.deadBody.secondaryAttachedTo = null;
				playerByUserID.deadBody.SetRagdollPositionSafely(position, true);
				if (((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost && NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(ID, out var value))
				{
					GameObject gameObject = ((Component)value).gameObject;
					Object.Destroy((Object)(object)gameObject);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void fixMaskedServerRpc(ulong user, ulong masked)
		{
			//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)
			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(737332444u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, user);
					BytePacker.WriteValueBitPacked(val2, masked);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 737332444u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					fixMaskedClientRpc(user, masked);
				}
			}
		}

		[ClientRpc]
		public void fixMaskedClientRpc(ulong user, ulong masked)
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(793304271u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, user);
				BytePacker.WriteValueBitPacked(val2, masked);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 793304271u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB playerByUserID = Misc.GetPlayerByUserID(user);
				playerByUserID.deadBody.DeactivateBody(false);
				if (((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost && NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(masked, out var value))
				{
					GameObject gameObject = ((Component)value).gameObject;
					gameObject.GetComponent<MaskedPlayerEnemy>().mimickingPlayer = playerByUserID;
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Networker()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3051737443u, new RpcReceiveHandler(__rpc_handler_3051737443));
			NetworkManager.__rpc_func_table.Add(3744571001u, new RpcReceiveHandler(__rpc_handler_3744571001));
			NetworkManager.__rpc_func_table.Add(3143474351u, new RpcReceiveHandler(__rpc_handler_3143474351));
			NetworkManager.__rpc_func_table.Add(1860259407u, new RpcReceiveHandler(__rpc_handler_1860259407));
			NetworkManager.__rpc_func_table.Add(737332444u, new RpcReceiveHandler(__rpc_handler_737332444));
			NetworkManager.__rpc_func_table.Add(793304271u, new RpcReceiveHandler(__rpc_handler_793304271));
		}

		private static void __rpc_handler_3051737443(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 body = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref body);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Networker)(object)target).addComponentToBodyServerRPC(body);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3744571001(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 body = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref body);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Networker)(object)target).addComponentToBodyClientRPC(body);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3143474351(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong body = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref body);
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				ulong iD = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref iD);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Networker)(object)target).spawnBodyServerRPC(body, position, iD);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1860259407(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong body = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref body);
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				ulong iD = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref iD);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Networker)(object)target).spawnBodyClientRPC(body, position, iD);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_737332444(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 user = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref user);
				ulong masked = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref masked);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Networker)(object)target).fixMaskedServerRpc(user, masked);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_793304271(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 user = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref user);
				ulong masked = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref masked);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Networker)(object)target).fixMaskedClientRpc(user, masked);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Networker";
		}
	}
	[BepInPlugin("Slayer6409.NightOfTheLivingMimic", "NightOfTheLivingMimic", "1.0.0")]
	public class SDBBZRMain : BaseUnityPlugin
	{
		private const string modGUID = "Slayer6409.NightOfTheLivingMimic";

		private const string modName = "NightOfTheLivingMimic";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Slayer6409.NightOfTheLivingMimic");

		public static ManualLogSource CustomLogger;

		public static ConfigFile BepInExConfig;

		public static ConfigEntry<float> percentChance;

		public static ConfigEntry<int> timer;

		public static ConfigEntry<bool> continuous;

		public static ConfigEntry<int> chanceDecrease;

		public static AssetBundle LoadedAssets;

		public static GameObject NetworkerPrefab;

		public static void ModConfig()
		{
			percentChance = BepInExConfig.Bind<float>("Zombie", "Percent Chance", 7.5f, "What percent chance will it change into a zombie");
			continuous = BepInExConfig.Bind<bool>("Zombie", "Continuous", true, "If a body can become a zombie after killing the zombie again");
			timer = BepInExConfig.Bind<int>("Zombie", "Timer", 10, "How often does it try to become a zombie");
			chanceDecrease = BepInExConfig.Bind<int>("Zombie", "Chance Decrease", 1, "Decreases the chance of spawning additional zombies from the same body by this percent");
		}

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Night Of The Living Mimic is loaded!");
			BepInExConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "NightOfTheLivingMimic.cfg"), true);
			ModConfig();
			NetcodeWeaver();
			LoadedAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sdbbzr"));
			NetworkerPrefab = LoadedAssets.LoadAsset<GameObject>("Networker");
			NetworkerPrefab.AddComponent<Networker>();
			harmony.PatchAll();
		}

		private static void NetcodeWeaver()
		{
			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);
					}
				}
			}
		}
	}
}
namespace SlayerDeadBodiesBecomeZombiesRandomly.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void AddPrefab(ref GameNetworkManager __instance)
		{
			((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(SDBBZRMain.NetworkerPrefab);
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	internal class MaskedPlayerEnemyPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(MaskedPlayerEnemy), "KillEnemy")]
		public static void doKill(MaskedPlayerEnemy __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			zombieBody component = ((Component)__instance).GetComponent<zombieBody>();
			if ((Object)(object)component != (Object)null)
			{
				Networker.Instance.spawnBodyServerRPC(component.bodyID, ((Component)__instance).transform.position, ((NetworkBehaviour)__instance).NetworkObject.NetworkObjectId);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
		public static void AttachObject(PlayerControllerB __instance, int causeOfDeath, int deathAnimation, bool spawnBody, Vector3 bodyVelocity)
		{
			if ((Object)(object)Networker.Instance == (Object)null)
			{
				Debug.LogError((object)"Networker.Instance is null. Cannot add component to body.");
			}
			else
			{
				Networker.Instance.addComponentToBodyServerRPC(__instance.playerClientId);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerServerRpc")]
		public static void AttachObjectTwo(PlayerControllerB __instance, int causeOfDeath, int deathAnimation, bool spawnBody, Vector3 bodyVelocity)
		{
			if ((Object)(object)Networker.Instance == (Object)null)
			{
				Debug.LogError((object)"Networker.Instance is null. Cannot add component to body.");
			}
			else
			{
				Networker.Instance.addComponentToBodyServerRPC(__instance.playerClientId);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void InstantiateNetworker(StartOfRound __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(SDBBZRMain.NetworkerPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(true);
			}
		}
	}
}