Decompiled source of LinkStatue v1.2.3

LinkStatue.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FallingStaticObject;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyTemplate;
using LinkStatue;
using LinkStatue.NetcodePatcher;
using Microsoft.CodeAnalysis;
using TestingSpace;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LinkStatue")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds random Link Statue to any map.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6891e69c219e6c47cf677e569a310d562bb38a0b")]
[assembly: AssemblyProduct("LinkStatue")]
[assembly: AssemblyTitle("LinkStatue")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 LethalCompanyTemplate
{
	[BepInPlugin("LinkStatue", "LinkStatue", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony harmony = new Harmony("LinkStatue");

		public static string AppRoot = Path.Combine(Paths.PluginPath, "MadCows-LinkStatue");

		public static AssetBundle appAssets = null;

		public static GameObject LinkPrefab;

		public static GameObject TestObject;

		public static Plugin _instance;

		public static ConfigEntry<float> SpawnChances;

		public static ConfigEntry<bool> DebugMode;

		public static ConfigEntry<int> NumberOfTimesSeenToHaunt;

		public static ConfigEntry<float> RadiusOfCloseTeleport;

		public static ManualLogSource TTLogger { get; set; }

		public void Awake()
		{
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			_instance = this;
			SpawnChances = ((BaseUnityPlugin)this).Config.Bind<float>("Ganeral", "SpawnChanges", 0.5f, "The percentage chance of the statue spawning in a given round. 0.0 - 1.0");
			DebugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugMode", false, "Puts the mod into Debug mode. this mode helps find the statue and puts out more log info. Devs only foo.");
			RadiusOfCloseTeleport = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RadiusOfCloseTeleport", 20f, "Radius of how close the teleporting will be when following someone.");
			NumberOfTimesSeenToHaunt = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NumberOfTimesSeenToHaunt", 4, "The number of times the statue can be seen before He wants to haunt.");
			TTLogger = Logger.CreateLogSource("Link Statue Mod");
			loadBundle();
			TTLogger.LogInfo((object)("Plugin LinkStatue is loaded! at " + AppRoot));
			LinkPrefab = appAssets.LoadAsset<GameObject>("LinkStatue");
			LinkPrefab.AddComponent<FallingObject>();
			LinkPrefab.AddComponent<LinkStatueAI>();
			LinkPrefab.AddComponent<AudioSource>();
			((Object)LinkPrefab).name = "LINK_THE_HERO";
			LinkPrefab.transform.localScale = new Vector3(2f, 2f, 2f);
			LinkPrefab.layer = LayerMask.NameToLayer("Enemies");
			TestObject = appAssets.LoadAsset<GameObject>("TestObject");
			TestObject.AddComponent<NetworkObject>();
			TestObject.AddComponent<Testing>();
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(GameNetworkManagerPatch));
			harmony.PatchAll(typeof(ShovelPatch));
			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);
					}
				}
			}
		}

		private void loadBundle()
		{
			string path = Path.Combine(AppRoot, "linkstatuemodbundle");
			byte[] array = File.ReadAllBytes(path);
			AssetBundle val = AssetBundle.LoadFromMemory(array);
			if ((Object)(object)val != (Object)null)
			{
				TTLogger.LogInfo((object)"YES THE BUNDLE WAS LOADED!");
				appAssets = val;
			}
			else
			{
				Debug.LogError((object)"Failed to load the custom prefab.");
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	public class GameNetworkManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			NetworkManager.Singleton.AddNetworkPrefab(Plugin.LinkPrefab);
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("GeneratedFloorPostProcessing")]
		[HarmonyPrefix]
		private static void GeneratedFloorPostProcessingPatch(ref RoundManager __instance)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)__instance).IsServer && Random.value <= Plugin.SpawnChances.Value)
			{
				__instance.mapPropsContainer = GameObject.FindGameObjectWithTag("MapPropsContainer");
				GameObject linkPrefab = Plugin.LinkPrefab;
				GameObject val = Object.Instantiate<GameObject>(linkPrefab, GameObject.Find("LevelGenerationRoot").transform.position, new Quaternion(0f, 0f, 0f, 0f));
				((Object)val).name = "LINK_THE_HERO";
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPatch("UnloadSceneObjectsEarly")]
		[HarmonyPrefix]
		private static void UnloadSceneObjectsEarlyPatch(ref RoundManager __instance)
		{
			GameObject val = GameObject.Find("LINK_THE_HERO");
			if (((NetworkBehaviour)__instance).IsServer && Object.op_Implicit((Object)(object)val))
			{
				val.GetComponent<NetworkObject>().Despawn(true);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LinkStatue";

		public const string PLUGIN_NAME = "LinkStatue";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace TestingSpace
{
	internal class Testing : NetworkBehaviour
	{
		public void Start()
		{
			Debug.Log((object)"HELP HGLEP MEREJGOJREWEROGJERJO");
			Plugin.TTLogger.LogMessage((object)"Hello i am the testing script you asked for");
		}

		public void RunTheClientMessage()
		{
			if (((NetworkBehaviour)this).IsHost)
			{
				HelpMeClientRpc();
			}
		}

		[ClientRpc]
		public void HelpMeClientRpc()
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1582891226u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1582891226u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Plugin.TTLogger.LogMessage((object)"This is the Client Rpc");
				}
			}
		}

		public void Update()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				Plugin.TTLogger.LogMessage((object)"I am going to run the ClientRpc now");
				HelpMeClientRpc();
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Testing()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1582891226u, new RpcReceiveHandler(__rpc_handler_1582891226));
		}

		private static void __rpc_handler_1582891226(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)2;
				((Testing)(object)target).HelpMeClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Testing";
		}
	}
}
namespace LinkStatue
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch : MonoBehaviour
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartPatch(ref StartOfRound __instance)
		{
		}
	}
	[HarmonyPatch(typeof(Shovel))]
	internal class ShovelPatch
	{
		[HarmonyPatch("HitShovel")]
		[HarmonyPostfix]
		public static void HitShovelPatch(ref Shovel __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0086: 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)
			List<RaycastHit> list = Traverse.Create((object)__instance).Field("objectsHitByShovelList").GetValue() as List<RaycastHit>;
			for (int i = 0; i < list.Count; i++)
			{
				RaycastHit val = list[i];
				string name = ((Object)((RaycastHit)(ref val)).transform).name;
				Plugin.TTLogger.LogMessage((object)name);
				val = list[i];
				if ((Object)(object)((Component)((RaycastHit)(ref val)).transform).GetComponent<LinkStatueAI>() != (Object)null)
				{
					object value = Traverse.Create((object)__instance).Field("previousPlayerHeldBy").GetValue();
					PlayerControllerB thePlayer = (PlayerControllerB)((value is PlayerControllerB) ? value : null);
					val = list[i];
					((Component)((RaycastHit)(ref val)).transform).GetComponent<LinkStatueAI>().StartKillingPlayer(thePlayer);
					RoundManager.PlayRandomClip(__instance.shovelAudio, __instance.hitSFX, true, 1f, 0, 1000);
					__instance.HitShovelServerRpc(-1);
				}
			}
		}
	}
	internal class LinkStatueAI : NetworkBehaviour
	{
		private bool _hasBeenSeen = false;

		private PlayerControllerB _lastPersonSeen = null;

		private int _counterOfTimesSeen = 0;

		private int _numOfEyesOnMe = 0;

		private float _timeSeen = 0f;

		public float teleportDelay = 20f;

		public float teleportDelayRange = 10f;

		private float _teleTrueTime = 0f;

		private int _defaultSpawnDistance = 100;

		public float tooLonelyTimeDelay = 180f;

		private float _tooLonelyTime;

		public bool haunting = false;

		private AudioSource LinkVoice;

		private AudioClip LaughSmall;

		private AudioClip LaughLong;

		private AudioClip KillingLaugh;

		private AudioClip KillingSound;

		private AudioClip KillingMusic;

		public void Start()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			_tooLonelyTime = Time.time + tooLonelyTimeDelay;
			((MonoBehaviour)this).InvokeRepeating("CheckSitesSlow", 0f, 2f);
			LinkVoice = ((Component)this).GetComponent<AudioSource>();
			LaughSmall = Plugin.appAssets.LoadAsset<AudioClip>("Zelda-Laugh-Short");
			LaughLong = Plugin.appAssets.LoadAsset<AudioClip>("Zelda-Laugh-Long");
			KillingLaugh = Plugin.appAssets.LoadAsset<AudioClip>("Happy-Mask-Laugh");
			KillingSound = Plugin.appAssets.LoadAsset<AudioClip>("SkullKid-Scream");
			KillingMusic = Plugin.appAssets.LoadAsset<AudioClip>("SongOfHealing");
			Vector3 position = GameObject.Find("LevelGenerationRoot").transform.position;
			if (Plugin.DebugMode.Value)
			{
				_defaultSpawnDistance = 10;
				position = GameObject.Find("StartRoom(Clone)").transform.position;
			}
			((Component)this).transform.position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, (float)_defaultSpawnDistance, default(NavMeshHit));
			LinkVoice.minDistance = 10f;
			LinkVoice.maxDistance = 30f;
			LinkVoice.spatialBlend = 1f;
			LinkVoice.rolloffMode = (AudioRolloffMode)1;
		}

		public void CheckSitesSlow()
		{
			if (!((NetworkBehaviour)this).IsServer || _hasBeenSeen)
			{
				return;
			}
			PlayerControllerB[] lineOfSightOfAny = GetLineOfSightOfAny(45f, 30);
			_numOfEyesOnMe = lineOfSightOfAny.Length;
			if (_numOfEyesOnMe > 0 && !_hasBeenSeen)
			{
				_hasBeenSeen = true;
				_timeSeen = Time.time;
				_teleTrueTime = Random.Range(teleportDelay - teleportDelayRange, teleportDelay + teleportDelayRange);
				if ((Object)(object)_lastPersonSeen == (Object)(object)lineOfSightOfAny[0])
				{
					_counterOfTimesSeen++;
				}
				else
				{
					_lastPersonSeen = lineOfSightOfAny[0];
					_counterOfTimesSeen = 0;
				}
				if (_counterOfTimesSeen >= Plugin.NumberOfTimesSeenToHaunt.Value)
				{
					StartKillingPlayer(_lastPersonSeen);
				}
			}
		}

		public void Update()
		{
			if (!((NetworkBehaviour)this).IsServer || haunting)
			{
				return;
			}
			if (_hasBeenSeen && Time.time > _timeSeen + _teleTrueTime)
			{
				_numOfEyesOnMe = GetLineOfSightOfAny(45f, 30).Length;
				if (_numOfEyesOnMe > 0)
				{
					_timeSeen = Time.time;
				}
				else
				{
					_tooLonelyTime = Time.time + tooLonelyTimeDelay;
					_hasBeenSeen = false;
					MoveStatueSpot();
				}
			}
			if (Time.time > _tooLonelyTime)
			{
				_numOfEyesOnMe = GetLineOfSightOfAny(45f, 30).Length;
				if (_numOfEyesOnMe == 0)
				{
					_tooLonelyTime = Time.time + tooLonelyTimeDelay;
					_hasBeenSeen = false;
					MoveStatueSpot();
					_lastPersonSeen = null;
				}
			}
		}

		private void OnDestroy()
		{
			((MonoBehaviour)this).CancelInvoke();
		}

		public void MoveStatueSpot()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_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)
			Vector3 position = GameObject.Find("LevelGenerationRoot").transform.position;
			float num = _defaultSpawnDistance;
			if (Plugin.DebugMode.Value)
			{
				position = GameObject.Find("StartRoom(Clone)").transform.position;
			}
			if ((Object)(object)_lastPersonSeen != (Object)null)
			{
				position = _lastPersonSeen.thisPlayerBody.position;
				num = Plugin.RadiusOfCloseTeleport.Value;
			}
			position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, num, default(NavMeshHit));
			MoveStatueSpotServerRpc(position);
		}

		[ServerRpc]
		public void MoveStatueSpotServerRpc(Vector3 newSpot)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_011a: 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))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(718832639u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref newSpot);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 718832639u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ((NetworkBehaviour)this).IsServer)
			{
				MoveStatueSpotClientRpc(newSpot);
			}
		}

		[ClientRpc]
		public void MoveStatueSpotClientRpc(Vector3 newSpot)
		{
			//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_0089: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2186059455u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref newSpot);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2186059455u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(MoveStatueSpotCoroutine(newSpot));
				}
			}
		}

		public IEnumerator MoveStatueSpotCoroutine(Vector3 newSpot)
		{
			//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)
			((Component)this).transform.localScale = new Vector3(0f, 0f, 0f);
			PlaySound(Random.Range(0, 2));
			yield return (object)new WaitUntil((Func<bool>)(() => !LinkVoice.isPlaying));
			_ = ((Component)this).transform.position;
			((Component)this).transform.position = newSpot;
			((Component)this).transform.rotation = Quaternion.Euler(new Vector3(((Component)this).transform.eulerAngles.x, RoundManager.Instance.YRotationThatFacesTheFarthestFromPosition(newSpot, 25f, 6), ((Component)this).transform.eulerAngles.z));
			((Component)this).transform.localScale = new Vector3(2f, 2f, 2f);
		}

		public void InstantMoveStatue(Vector3 newPos)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.localScale = new Vector3(0f, 0f, 0f);
			Vector3 position = ((Component)this).transform.position;
			position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(newPos, 3f, default(NavMeshHit));
			((Component)this).transform.position = position;
			((Component)this).transform.localScale = new Vector3(2f, 2f, 2f);
		}

		public void StartKillingPlayer(PlayerControllerB thePlayer)
		{
			int thePlayer2 = Array.FindIndex(StartOfRound.Instance.allPlayerScripts, (PlayerControllerB player) => player.playerClientId == thePlayer.playerClientId);
			StartKillingPlayerServerRpc(thePlayer2);
		}

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

		[ClientRpc]
		public void StartKillingPlayerClientRpc(int thePlayer)
		{
			//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_00de: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3420559006u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, thePlayer);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3420559006u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((Component)this).transform.localScale = new Vector3(0f, 0f, 0f);
					((MonoBehaviour)this).StartCoroutine(StartKillingPlayerCoroutine(thePlayer));
				}
			}
		}

		public IEnumerator StartKillingPlayerCoroutine(int thePlayerIndex)
		{
			PlayerControllerB thePlayer = StartOfRound.Instance.allPlayerScripts[thePlayerIndex];
			haunting = true;
			PlaySound(Random.Range(0, 2));
			yield return (object)new WaitForSeconds(20f);
			float intervel = 6f;
			for (int j = 0; j < 5; j++)
			{
				if ((Object)(object)StartOfRound.Instance.localPlayerController == (Object)(object)thePlayer)
				{
					thePlayer.statusEffectAudio.PlayOneShot(KillingLaugh);
				}
				yield return (object)new WaitForSeconds(intervel);
				intervel -= 0.5f;
			}
			thePlayer.statusEffectAudio.PlayOneShot(KillingMusic);
			for (int i = 0; i < 5; i++)
			{
				if ((Object)(object)StartOfRound.Instance.localPlayerController == (Object)(object)thePlayer)
				{
					thePlayer.statusEffectAudio.PlayOneShot(KillingLaugh);
				}
				yield return (object)new WaitForSeconds(2f);
			}
			thePlayer.KillPlayer(Vector3.zero, true, (CauseOfDeath)5, 1, default(Vector3));
			InstantMoveStatue(((Component)thePlayer).transform.position);
			((Component)this).transform.localScale = new Vector3(2f, 2f, 2f);
			PlaySound(2);
			haunting = false;
			_hasBeenSeen = false;
			_tooLonelyTime = Time.time + tooLonelyTimeDelay;
		}

		public void PlaySound(int clipID)
		{
			switch (clipID)
			{
			case 0:
				LinkVoice.PlayOneShot(LaughSmall, 1f);
				break;
			case 1:
				LinkVoice.PlayOneShot(LaughLong, 1f);
				break;
			case 2:
				LinkVoice.PlayOneShot(KillingSound, 1f);
				break;
			}
		}

		public PlayerControllerB[] GetLineOfSightOfAny(float width = 45f, int range = 60)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerControllerB> list = new List<PlayerControllerB>(4);
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				if (StartOfRound.Instance.allPlayerScripts[i].isPlayerDead)
				{
					continue;
				}
				Vector3 position = ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position;
				Vector3 position2 = ((Component)((Component)this).transform.Find("HeadPos")).transform.position;
				Transform transform = ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform;
				if (Vector3.Distance(position2, position) < (float)range && !Physics.Linecast(position2, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					Vector3 val = position - position2;
					if (Vector3.Angle(-transform.forward, val) < width)
					{
						list.Add(StartOfRound.Instance.allPlayerScripts[i]);
					}
				}
			}
			if (list.Count > 0)
			{
				return list.ToArray();
			}
			return Array.Empty<PlayerControllerB>();
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_LinkStatueAI()
		{
			//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
			NetworkManager.__rpc_func_table.Add(718832639u, new RpcReceiveHandler(__rpc_handler_718832639));
			NetworkManager.__rpc_func_table.Add(2186059455u, new RpcReceiveHandler(__rpc_handler_2186059455));
			NetworkManager.__rpc_func_table.Add(1540599700u, new RpcReceiveHandler(__rpc_handler_1540599700));
			NetworkManager.__rpc_func_table.Add(3420559006u, new RpcReceiveHandler(__rpc_handler_3420559006));
		}

		private static void __rpc_handler_718832639(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				Vector3 newSpot = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref newSpot);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LinkStatueAI)(object)target).MoveStatueSpotServerRpc(newSpot);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2186059455(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 newSpot = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref newSpot);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LinkStatueAI)(object)target).MoveStatueSpotClientRpc(newSpot);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1540599700(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 thePlayer = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref thePlayer);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LinkStatueAI)(object)target).StartKillingPlayerServerRpc(thePlayer);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3420559006(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 thePlayer = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref thePlayer);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LinkStatueAI)(object)target).StartKillingPlayerClientRpc(thePlayer);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "LinkStatueAI";
		}
	}
}
namespace FallingStaticObject
{
	internal class FallingObject : MonoBehaviour
	{
		public Vector3 targetFloorPosition;

		private float fallTime;

		public float verticalOffset = 0f;

		private Vector3 startFallingPosition;

		public void Start()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			startFallingPosition = ((Component)this).transform.position;
			FallToGround();
		}

		public void Update()
		{
			if (fallTime < 1f)
			{
				FallWithCurve();
			}
		}

		public void FallToGround(bool randomizePosition = false)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			fallTime = 0f;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(((Component)this).transform.position, Vector3.down, ref val, 80f, 268437760, (QueryTriggerInteraction)1))
			{
				targetFloorPosition = ((RaycastHit)(ref val)).point + verticalOffset * Vector3.up;
				if ((Object)(object)((Component)this).transform.parent != (Object)null)
				{
					targetFloorPosition = ((Component)this).transform.parent.InverseTransformPoint(targetFloorPosition);
				}
			}
			else
			{
				targetFloorPosition = ((Component)this).transform.localPosition;
			}
			if (randomizePosition)
			{
				targetFloorPosition += new Vector3(Random.Range(-0.5f, 0.5f), 0f, Random.Range(-0.5f, 0.5f));
			}
		}

		public virtual void FallWithCurve()
		{
			//IL_0063: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			float num = startFallingPosition.y - targetFloorPosition.y;
			if (num > 5f)
			{
				((Component)this).transform.localPosition = Vector3.Lerp(startFallingPosition, targetFloorPosition, StartOfRound.Instance.objectFallToGroundCurveNoBounce.Evaluate(fallTime));
			}
			else
			{
				((Component)this).transform.localPosition = Vector3.Lerp(startFallingPosition, targetFloorPosition, StartOfRound.Instance.objectFallToGroundCurve.Evaluate(fallTime));
			}
			fallTime += Mathf.Abs(Time.deltaTime * 6f / num);
		}
	}
}
namespace LinkStatue.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}