Decompiled source of Haunt Pack v1.0.8

backrooms/Backrooms.dll

Decompiled 8 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.AI.Navigation;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
[RequireComponent(typeof(SphereCollider))]
public class KillBox : MonoBehaviour
{
	private void OnTriggerEnter(Collider other)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
		if ((Object)(object)component != (Object)null)
		{
			component.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 0);
		}
	}
}
public class LightFlickerEffect : MonoBehaviour
{
	[Tooltip("External light to flicker; you can leave this null if you attach script to a light")]
	public Light light;

	[Tooltip("Minimum random light intensity")]
	public float minIntensity;

	[Tooltip("Maximum random light intensity")]
	public float maxIntensity = 1f;

	[Tooltip("How much to smooth out the randomness; lower values = sparks, higher = lantern")]
	[Range(1f, 50f)]
	public int smoothing = 5;

	private Queue<float> smoothQueue;

	private float lastSum;

	public void Reset()
	{
		smoothQueue.Clear();
		lastSum = 0f;
	}

	private void Start()
	{
		smoothQueue = new Queue<float>(smoothing);
		if ((Object)(object)light == (Object)null)
		{
			light = ((Component)this).GetComponent<Light>();
		}
	}

	private void Update()
	{
		if (!((Object)(object)light == (Object)null))
		{
			while (smoothQueue.Count >= smoothing)
			{
				lastSum -= smoothQueue.Dequeue();
			}
			float num = Random.Range(minIntensity, maxIntensity);
			smoothQueue.Enqueue(num);
			lastSum += num;
			light.intensity = lastSum / (float)smoothQueue.Count;
		}
	}
}
public class LookAtPlayer : MonoBehaviour
{
	private void Update()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).gameObject.transform.LookAt(((Component)GameNetworkManager.Instance.localPlayerController).transform.position + Vector3.up);
	}
}
public class SpawnPosition : MonoBehaviour
{
	private void Start()
	{
	}

	private void Update()
	{
	}
}
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
	private struct MonoScriptData
	{
		public byte[] FilePathsData;

		public byte[] TypesData;

		public int TotalTypes;

		public int TotalFiles;

		public bool IsEditorOnly;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static MonoScriptData Get()
	{
		MonoScriptData result = default(MonoScriptData);
		result.FilePathsData = new byte[506]
		{
			0, 0, 0, 1, 0, 0, 0, 42, 92, 65,
			115, 115, 101, 116, 115, 92, 66, 97, 99, 107,
			114, 111, 111, 109, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 65, 114, 101, 89, 111, 117,
			87, 97, 116, 99, 104, 101, 100, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 38, 92, 65,
			115, 115, 101, 116, 115, 92, 66, 97, 99, 107,
			114, 111, 111, 109, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 66, 97, 99, 107, 114, 111,
			111, 109, 115, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 33, 92, 65, 115, 115, 101, 116,
			115, 92, 66, 97, 99, 107, 114, 111, 111, 109,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			69, 120, 105, 116, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 33, 92, 65, 115, 115, 101,
			116, 115, 92, 66, 97, 99, 107, 114, 111, 111,
			109, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 72, 111, 111, 107, 46, 99, 115, 0, 0,
			0, 1, 0, 0, 0, 36, 92, 65, 115, 115,
			101, 116, 115, 92, 66, 97, 99, 107, 114, 111,
			111, 109, 115, 92, 83, 99, 114, 105, 112, 116,
			115, 92, 75, 105, 108, 108, 66, 111, 120, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 47,
			92, 65, 115, 115, 101, 116, 115, 92, 66, 97,
			99, 107, 114, 111, 111, 109, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 76, 105, 103, 104,
			116, 70, 108, 105, 99, 107, 101, 114, 69, 102,
			102, 101, 99, 116, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 35, 92, 65, 115, 115, 101,
			116, 115, 92, 66, 97, 99, 107, 114, 111, 111,
			109, 115, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 76, 111, 97, 100, 101, 114, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 41, 92, 65,
			115, 115, 101, 116, 115, 92, 66, 97, 99, 107,
			114, 111, 111, 109, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 76, 111, 111, 107, 65, 116,
			80, 108, 97, 121, 101, 114, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 36, 92, 65, 115,
			115, 101, 116, 115, 92, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 83, 107, 105, 98, 105, 100, 105,
			46, 99, 115, 0, 0, 0, 1, 0, 0, 0,
			35, 92, 65, 115, 115, 101, 116, 115, 92, 66,
			97, 99, 107, 114, 111, 111, 109, 115, 92, 83,
			99, 114, 105, 112, 116, 115, 92, 83, 109, 105,
			108, 101, 114, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 42, 92, 65, 115, 115, 101, 116,
			115, 92, 66, 97, 99, 107, 114, 111, 111, 109,
			115, 92, 83, 99, 114, 105, 112, 116, 115, 92,
			83, 112, 97, 119, 110, 80, 111, 115, 105, 116,
			105, 111, 110, 46, 99, 115
		};
		result.TypesData = new byte[233]
		{
			0, 0, 0, 0, 25, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 124, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 72, 101, 108, 112, 101, 114,
			0, 0, 0, 0, 19, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 124, 66, 97, 99, 107, 114,
			111, 111, 109, 115, 0, 0, 0, 0, 14, 66,
			97, 99, 107, 114, 111, 111, 109, 115, 124, 69,
			120, 105, 116, 0, 0, 0, 0, 14, 66, 97,
			99, 107, 114, 111, 111, 109, 115, 124, 72, 111,
			111, 107, 0, 0, 0, 0, 8, 124, 75, 105,
			108, 108, 66, 111, 120, 0, 0, 0, 0, 19,
			124, 76, 105, 103, 104, 116, 70, 108, 105, 99,
			107, 101, 114, 69, 102, 102, 101, 99, 116, 0,
			0, 0, 0, 16, 66, 97, 99, 107, 114, 111,
			111, 109, 115, 124, 76, 111, 97, 100, 101, 114,
			0, 0, 0, 0, 13, 124, 76, 111, 111, 107,
			65, 116, 80, 108, 97, 121, 101, 114, 0, 0,
			0, 0, 20, 66, 97, 99, 107, 114, 111, 111,
			109, 115, 124, 83, 111, 117, 110, 100, 80, 97,
			116, 99, 104, 0, 0, 0, 0, 16, 66, 97,
			99, 107, 114, 111, 111, 109, 115, 124, 83, 109,
			105, 108, 101, 114, 0, 0, 0, 0, 14, 124,
			83, 112, 97, 119, 110, 80, 111, 115, 105, 116,
			105, 111, 110
		};
		result.TotalFiles = 11;
		result.TotalTypes = 11;
		result.IsEditorOnly = false;
		return result;
	}
}
namespace Backrooms;

public class BackroomsHelper : MonoBehaviour
{
	public bool HasBeenInTheBackrooms;

	private void Start()
	{
	}

	private void Update()
	{
	}
}
public class Backrooms : NetworkBehaviour
{
	public static Backrooms Instance;

	public GameObject Floor;

	public GameObject Wall;

	public GameObject Ceiling;

	public GameObject LightlessCeiling;

	public GameObject Pillar;

	public GameObject Room;

	public static float Offset = -500f;

	private int Width = 30;

	private int Height = 30;

	public List<Vector2> PossibleSpawnPoint;

	public List<PlayerControllerB> playerInBackrooms;

	public NetworkVariable<float> SharedOdds = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	private float initialValue;

	public DungeonFlow Flow;

	public GameObject Child;

	public override void OnNetworkSpawn()
	{
		if (((NetworkBehaviour)this).IsServer)
		{
			initialValue = Loader.TeleportationOdds.Value;
			SharedOdds.Value = initialValue;
			((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback += NetworkManager_OnClientConnectedCallback;
			return;
		}
		if (SharedOdds.Value != initialValue)
		{
			Debug.LogWarning((object)($"NetworkVariable was {SharedOdds.Value} upon being spawned" + $" when it should have been {initialValue}"));
		}
		else
		{
			Debug.Log((object)$"NetworkVariable is {SharedOdds.Value} when spawned.");
		}
		NetworkVariable<float> sharedOdds = SharedOdds;
		sharedOdds.OnValueChanged = (OnValueChangedDelegate<float>)(object)Delegate.Combine((Delegate?)(object)sharedOdds.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<float>(OnSomeValueChanged));
	}

	private void NetworkManager_OnClientConnectedCallback(ulong obj)
	{
		StartChangingNetworkVariable();
	}

	private void OnSomeValueChanged(float previous, float current)
	{
		Debug.Log((object)$"Detected NetworkVariable Change: Previous: {previous} | Current: {current}");
	}

	private void StartChangingNetworkVariable()
	{
		((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback -= NetworkManager_OnClientConnectedCallback;
	}

	private void Awake()
	{
		PossibleSpawnPoint = new List<Vector2>();
		playerInBackrooms = new List<PlayerControllerB>();
	}

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

	private IEnumerator Teleport()
	{
		yield return (object)new WaitForSeconds(10f);
		for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
		{
			if (StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled)
			{
				TeleportToBackroomsClientRpc(i);
			}
		}
	}

	public void ServerGenerate()
	{
		int seed = Random.Range(0, 1000000);
		GenerateClientRpc(seed);
	}

	public void ServerClean()
	{
		Smiler[] array = Object.FindObjectsOfType<Smiler>();
		for (int i = 0; i < array.Length; i++)
		{
			((Component)array[i]).GetComponent<NetworkObject>().Despawn(true);
		}
		playerInBackrooms.Clear();
		CleanBackroomsClientRpc();
	}

	[ClientRpc]
	public void CleanBackroomsClientRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: 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(2180494496u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2180494496u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		foreach (Transform item in ((Component)this).transform)
		{
			Object.Destroy((Object)(object)((Component)item).gameObject);
		}
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		for (int i = 0; i < allPlayerScripts.Length; i++)
		{
			((Component)allPlayerScripts[i]).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms = false;
		}
	}

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

	[ClientRpc]
	public void TeleportToBackroomsClientRpc(int client)
	{
		//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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: 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(3078584200u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, client);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3078584200u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[client];
			Random.InitState(client);
			Vector2 val4 = PossibleSpawnPoint[Random.Range(0, PossibleSpawnPoint.Count)];
			val3.TeleportPlayer(new Vector3(val4.x, Offset, val4.y), false, 0f, false, true);
			val3.isInsideFactory = true;
			val3.ResetFallGravity();
			((Component)val3).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms = true;
			if (((NetworkBehaviour)this).IsServer)
			{
				playerInBackrooms.Add(val3);
			}
		}
	}

	[ClientRpc]
	public void TeleportOutOfBackroomsClientRpc(int client)
	{
		//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_00e1: 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(1623403188u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, client);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1623403188u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB obj = StartOfRound.Instance.allPlayerScripts[client];
				obj.TeleportPlayer(StartOfRound.Instance.playerSpawnPositions[0].position, false, 0f, false, true);
				obj.isInsideFactory = false;
			}
		}
	}

	[ClientRpc]
	public void GenerateClientRpc(int seed)
	{
		//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_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_0545: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Unknown result type (might be due to invalid IL or missing references)
		//IL_054d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0559: Unknown result type (might be due to invalid IL or missing references)
		//IL_0560: Unknown result type (might be due to invalid IL or missing references)
		//IL_0565: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0458: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: 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(890432861u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, seed);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 890432861u, val, (RpcDelivery)0);
		}
		if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		PossibleSpawnPoint.Clear();
		playerInBackrooms.Clear();
		Random random = new Random(seed);
		Debug.Log((object)"Generate floor and ceiling");
		for (int i = -Width / 2; i < Width / 2; i++)
		{
			for (int j = -Height / 2; j < Height / 2; j++)
			{
				Object.Instantiate<GameObject>(Floor, new Vector3((float)(i * 6), Offset, (float)(j * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				if (random.Next(100) < 85)
				{
					Object.Instantiate<GameObject>(LightlessCeiling, new Vector3((float)(i * 6), Offset + 5f, (float)(j * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				}
				else
				{
					Object.Instantiate<GameObject>(Ceiling, new Vector3((float)(i * 6), Offset + 5f, (float)(j * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				}
			}
		}
		Debug.Log((object)"Generate walls");
		for (int k = -Width / 2; k < Width / 2; k++)
		{
			Object.Instantiate<GameObject>(Wall, new Vector3((float)(-Width / 2 * 6 - 3), Offset, (float)(k * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
			if (k != 0)
			{
				Object.Instantiate<GameObject>(Wall, new Vector3((float)(Width / 2 * 6 - 3), Offset, (float)(k * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				continue;
			}
			Debug.Log((object)"Generate room");
			Object.Instantiate<GameObject>(Room, new Vector3((float)(Width / 2 * 6 - 3), Offset, (float)(k * 6)), Quaternion.Euler(0f, 90f, 0f), ((Component)this).transform);
		}
		Debug.Log((object)"Generate walls 2");
		for (int l = -Width / 2; l < Width / 2; l++)
		{
			Object.Instantiate<GameObject>(Wall, new Vector3((float)(l * 6), Offset, (float)(-Height / 2 * 6 - 3)), Quaternion.Euler(-90f, 90f, 0f), ((Component)this).transform);
			Object.Instantiate<GameObject>(Wall, new Vector3((float)(l * 6), Offset, (float)(Height / 2 * 6 - 3)), Quaternion.Euler(-90f, 90f, 0f), ((Component)this).transform);
		}
		Debug.Log((object)"Generate inside 2");
		for (int m = -Width / 2; m < Width / 2; m++)
		{
			for (int n = -Height / 2; n < Height / 2; n++)
			{
				if (m == 0 && n == 0)
				{
					continue;
				}
				int num = random.Next(20);
				if (num < 15)
				{
					if (random.Next(10) < 5)
					{
						Object.Instantiate<GameObject>(Wall, new Vector3((float)(m * 6 - 3), Offset, (float)(n * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
					}
					else
					{
						Object.Instantiate<GameObject>(Wall, new Vector3((float)(m * 6), Offset, (float)(n * 6 - 3)), Quaternion.Euler(-90f, 90f, 0f), ((Component)this).transform);
					}
				}
				else if (num == 16)
				{
					Object.Instantiate<GameObject>(Pillar, new Vector3((float)(m * 6), Offset, (float)(n * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
				}
				else
				{
					PossibleSpawnPoint.Add(new Vector2((float)(m * 6), (float)(n * 6)));
				}
			}
		}
		if (((NetworkBehaviour)this).IsServer)
		{
			((Component)this).GetComponent<NavMeshSurface>().BuildNavMesh();
			GameObject val3 = Loader.AssetBundle.LoadAsset<GameObject>("assets/backrooms/smile.prefab");
			for (int num2 = 0; num2 < Loader.NumberOfSmilers.Value; num2++)
			{
				Vector2 val4 = PossibleSpawnPoint[Random.Range(0, PossibleSpawnPoint.Count)];
				Object.Instantiate<GameObject>(val3, new Vector3(val4.x, Offset, val4.y), Quaternion.identity, ((Component)this).transform).GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}

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

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

	[RuntimeInitializeOnLoadMethod]
	internal static void InitializeRPCS_Backrooms()
	{
		//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(2180494496u, new RpcReceiveHandler(__rpc_handler_2180494496));
		NetworkManager.__rpc_func_table.Add(2541916904u, new RpcReceiveHandler(__rpc_handler_2541916904));
		NetworkManager.__rpc_func_table.Add(3078584200u, new RpcReceiveHandler(__rpc_handler_3078584200));
		NetworkManager.__rpc_func_table.Add(1623403188u, new RpcReceiveHandler(__rpc_handler_1623403188));
		NetworkManager.__rpc_func_table.Add(890432861u, new RpcReceiveHandler(__rpc_handler_890432861));
		NetworkManager.__rpc_func_table.Add(3409688981u, new RpcReceiveHandler(__rpc_handler_3409688981));
	}

	private static void __rpc_handler_2180494496(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;
			((Backrooms)(object)target).CleanBackroomsClientRpc();
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2541916904(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 client = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref client);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((Backrooms)(object)target).TeleportToBackroomsServerRpc(client);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3078584200(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 client = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref client);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((Backrooms)(object)target).TeleportToBackroomsClientRpc(client);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_1623403188(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 client = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref client);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((Backrooms)(object)target).TeleportOutOfBackroomsClientRpc(client);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_890432861(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 seed = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref seed);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((Backrooms)(object)target).GenerateClientRpc(seed);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3409688981(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 clientId = default(ulong);
			ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((Backrooms)(object)target).TeleportOutOfBackroomsServerRpc(clientId);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	protected internal override string __getTypeName()
	{
		return "Backrooms";
	}
}
public class Exit : MonoBehaviour
{
	private void Start()
	{
	}

	private IEnumerator Teleport(ulong playerClientId)
	{
		StartOfRound.Instance.allPlayerScripts[playerClientId].beamOutParticle.Play();
		yield return (object)new WaitForSeconds(3f);
		Backrooms.Instance.TeleportOutOfBackroomsServerRpc(playerClientId);
	}

	private void OnTriggerEnter(Collider other)
	{
		PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
		if ((Object)(object)component != (Object)null)
		{
			((MonoBehaviour)this).StartCoroutine(Teleport(component.playerClientId));
			Backrooms.Instance.TeleportOutOfBackroomsServerRpc(component.playerClientId);
		}
	}
}
public static class Hook
{
	[HarmonyPatch(typeof(KillLocalPlayer), "KillPlayer")]
	[HarmonyPrefix]
	private static bool BeforeKilling(PlayerControllerB playerWhoTriggered)
	{
		if (playerWhoTriggered.isPlayerDead || !playerWhoTriggered.AllowPlayerDeath())
		{
			return true;
		}
		if (((Component)playerWhoTriggered).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms)
		{
			return true;
		}
		Debug.Log((object)$"Killzone {Backrooms.Instance.SharedOdds.Value}");
		if ((float)Random.Range(0, 100) < Backrooms.Instance.SharedOdds.Value)
		{
			Backrooms.Instance.TeleportToBackroomsServerRpc((int)playerWhoTriggered.playerClientId);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
	[HarmonyPrefix]
	private static bool BeforeDamage(PlayerControllerB __instance)
	{
		if (__instance.isPlayerDead || !__instance.AllowPlayerDeath())
		{
			return true;
		}
		if (((Component)__instance).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms)
		{
			return true;
		}
		Debug.Log((object)$"Damage taken {Backrooms.Instance.SharedOdds.Value}");
		if ((float)Random.Range(0, 100) < Backrooms.Instance.SharedOdds.Value)
		{
			Backrooms.Instance.TeleportToBackroomsServerRpc((int)__instance.playerClientId);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(PlayerControllerB), "Start")]
	[HarmonyPostfix]
	private static void AddComponents(PlayerControllerB __instance)
	{
		((Component)__instance).gameObject.AddComponent<BackroomsHelper>();
	}

	[HarmonyPatch(typeof(RoundManager), "Start")]
	[HarmonyPostfix]
	private static void SpawnBackrooms(RoundManager __instance)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		if (((NetworkBehaviour)__instance).IsServer)
		{
			Debug.Log((object)"Spawning backrooms");
			Object.Instantiate<GameObject>(Loader.AssetBundle.LoadAsset<GameObject>("assets/backrooms/backrooms.prefab"), new Vector3(0f, Backrooms.Offset, 0f), Quaternion.identity).GetComponent<NetworkObject>().Spawn(false);
		}
	}

	[HarmonyPatch(typeof(RoundManager), "UnloadSceneObjectsEarly")]
	[HarmonyPostfix]
	public static void DeleteBackrooms(RoundManager __instance)
	{
		if (((NetworkBehaviour)__instance).IsServer)
		{
			Backrooms.Instance.ServerClean();
		}
	}

	[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
	[HarmonyPrefix]
	public static void GenerateBackrooms(RoundManager __instance)
	{
		if (((NetworkBehaviour)__instance).IsServer)
		{
			Backrooms.Instance.ServerGenerate();
		}
	}

	[HarmonyPatch(typeof(StartOfRound), "WritePlayerNotes")]
	[HarmonyPostfix]
	public static void BackroomsPlayerNote(StartOfRound __instance)
	{
		for (int i = 0; i < __instance.gameStats.allPlayerStats.Length; i++)
		{
			if (__instance.gameStats.allPlayerStats[i].isActivePlayer && ((Component)__instance.allPlayerScripts[i]).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms)
			{
				if (__instance.allPlayerScripts[i].isPlayerDead)
				{
					__instance.gameStats.allPlayerStats[i].playerNotes.Add("Should have been more careful in the Backrooms.");
				}
				else
				{
					__instance.gameStats.allPlayerStats[i].playerNotes.Add("Had a blast in the Backrooms.");
				}
			}
		}
	}

	[HarmonyPatch(typeof(MenuManager), "Start")]
	[HarmonyPostfix]
	public static void NetworkManagerPatch(MenuManager __instance)
	{
		if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs.Select((NetworkPrefab pref) => ((Object)pref.Prefab).name).Contains("backrooms"))
		{
			Debug.Log((object)"Load prefabs to Network Manager");
			string[] array = new string[2] { "assets/backrooms/backrooms.prefab", "assets/backrooms/smile.prefab" };
			foreach (string text in array)
			{
				GameObject val = Loader.AssetBundle.LoadAsset<GameObject>(text);
				NetworkManager.Singleton.AddNetworkPrefab(val);
			}
		}
	}
}
[BepInPlugin("Neekhaulas.Backrooms", "Backrooms", "0.1.3")]
public class Loader : BaseUnityPlugin
{
	public static AssetBundle AssetBundle { get; private set; }

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

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

	private void Awake()
	{
		TeleportationOdds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Teleportation odds", 3f, "Odds to be teleported (in %) - This settings has to be changed by the host");
		NumberOfSmilers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Number of smilers", 1, "Number of smilers to spawn in the Backrooms - This settings has to be changed by the host");
		AssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "backrooms"));
		Harmony.CreateAndPatchAll(typeof(Hook), (string)null);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Backrooms is loaded!");
		Type[] types = Assembly.GetExecutingAssembly().GetTypes();
		for (int i = 0; i < types.Length; i++)
		{
			MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
				{
					methodInfo.Invoke(null, null);
				}
			}
		}
	}
}
public class SoundPatch : MonoBehaviour
{
	private void Start()
	{
		((Component)this).gameObject.AddComponent<OccludeAudio>();
		((Component)this).GetComponent<AudioSource>().Play();
	}
}
public class Smiler : NetworkBehaviour
{
	private NavMeshAgent NavMeshAgent;

	private PlayerControllerB Target;

	private void Start()
	{
		NavMeshAgent = ((Component)this).GetComponent<NavMeshAgent>();
	}

	private void Update()
	{
		//IL_0079: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		if (!((NetworkBehaviour)this).IsServer)
		{
			return;
		}
		if ((Object)(object)Target != (Object)null && Target.isPlayerDead)
		{
			Target = null;
			NavMeshAgent.speed = 2f;
		}
		if (!NavMeshAgent.pathPending && NavMeshAgent.remainingDistance <= NavMeshAgent.stoppingDistance)
		{
			if (NavMeshAgent.hasPath)
			{
				Vector3 velocity = NavMeshAgent.velocity;
				if (((Vector3)(ref velocity)).sqrMagnitude != 0f)
				{
					goto IL_00f0;
				}
			}
			if ((Object)(object)Target != (Object)null)
			{
				NavMeshAgent.SetDestination(((Component)Target).transform.position);
			}
			else
			{
				int index = Random.Range(0, Backrooms.Instance.PossibleSpawnPoint.Count);
				NavMeshAgent.SetDestination(Vector2.op_Implicit(Backrooms.Instance.PossibleSpawnPoint[index]));
			}
		}
		goto IL_00f0;
		IL_00f0:
		for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
			if (val.isPlayerControlled && !val.isPlayerDead)
			{
				if (val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up, 45f, 15, -1f))
				{
					Target = val;
					NavMeshAgent.SetDestination(((Component)val).transform.position);
					NavMeshAgent.speed = 7f;
					break;
				}
				bool flag = false;
				if ((Object)(object)val.currentlyHeldObjectServer != (Object)null && ((object)val.currentlyHeldObjectServer).GetType() == typeof(FlashlightItem) && val.currentlyHeldObjectServer.isBeingUsed)
				{
					flag = true;
				}
				if ((Object)(object)val.pocketedFlashlight != (Object)null && ((object)val.pocketedFlashlight).GetType() == typeof(FlashlightItem) && val.pocketedFlashlight.isBeingUsed)
				{
					flag = true;
				}
				if (flag && val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up, 45f, 100, -1f))
				{
					Target = val;
					NavMeshAgent.SetDestination(((Component)val).transform.position);
					NavMeshAgent.speed = 7f;
				}
			}
		}
	}

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

	protected internal override string __getTypeName()
	{
		return "Smiler";
	}
}

BuyableShotgun/BuyableShotgun.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("BuyableShotgun")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2023 MegaPiggy")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6ffb6f3fd20c49ad8e1b0d0d02f22146da06ea59")]
[assembly: AssemblyProduct("BuyableShotgun")]
[assembly: AssemblyTitle("BuyableShotgun")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BuyableShotgun
{
	[BepInDependency("evaisa.lethallib", "0.13.2")]
	[BepInPlugin("MegaPiggy.BuyableShotgun", "Buyable Shotgun", "1.0.3")]
	public class BuyableShotgun : BaseUnityPlugin
	{
		private const string modGUID = "MegaPiggy.BuyableShotgun";

		private const string modName = "Buyable Shotgun";

		private const string modVersion = "1.0.3";

		private readonly Harmony harmony = new Harmony("MegaPiggy.BuyableShotgun");

		private static BuyableShotgun Instance;

		private ConfigEntry<int> ShotgunPriceConfig;

		private static Dictionary<string, TerminalNode> infoNodes = new Dictionary<string, TerminalNode>();

		private static ManualLogSource LoggerInstance => ((BaseUnityPlugin)Instance).Logger;

		public List<Item> AllItems => Resources.FindObjectsOfTypeAll<Item>().Concat(Object.FindObjectsByType<Item>((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList();

		public Item Shotgun => ((IEnumerable<Item>)AllItems).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name.Equals("Shotgun")));

		public Item ShotgunClone { get; private set; }

		public int ShotgunPrice => ShotgunPriceConfig.Value;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll();
			ShotgunPriceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Prices", "ShotgunPrice", 700, "Credits needed to buy shotgun");
			SceneManager.sceneLoaded += OnSceneLoaded;
			ShotgunClone = MakeNonScrap(ShotgunPrice);
			AddToShop();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Buyable Shotgun is loaded with version 1.0.3!");
		}

		private Item MakeNonScrap(int price)
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			Item val = ScriptableObject.CreateInstance<Item>();
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).name = "Error";
			val.itemName = "Error";
			val.itemId = 6624;
			val.isScrap = false;
			val.creditsWorth = price;
			val.canBeGrabbedBeforeGameStart = true;
			val.automaticallySetUsingPower = false;
			val.batteryUsage = 300f;
			val.canBeInspected = false;
			val.isDefensiveWeapon = true;
			val.saveItemVariable = true;
			val.syncGrabFunction = false;
			val.twoHandedAnimation = true;
			val.verticalOffset = 0.25f;
			GameObject val2 = NetworkPrefabs.CreateNetworkPrefab("Cube");
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
			val3.transform.SetParent(val2.transform, false);
			((Renderer)val3.GetComponent<MeshRenderer>()).sharedMaterial.shader = Shader.Find("HDRP/Lit");
			val2.AddComponent<BoxCollider>().size = Vector3.one * 2f;
			val2.AddComponent<AudioSource>();
			PhysicsProp val4 = val2.AddComponent<PhysicsProp>();
			((GrabbableObject)val4).itemProperties = val;
			((GrabbableObject)val4).grabbable = true;
			val.spawnPrefab = val2;
			val2.tag = "PhysicsProp";
			val2.layer = LayerMask.NameToLayer("Props");
			val3.layer = LayerMask.NameToLayer("Props");
			try
			{
				GameObject val5 = Object.Instantiate<GameObject>(Items.scanNodePrefab, val2.transform);
				((Object)val5).name = "ScanNode";
				val5.transform.localPosition = new Vector3(0f, 0f, 0f);
				Transform transform = val5.transform;
				transform.localScale *= 2f;
				ScanNodeProperties component = val5.GetComponent<ScanNodeProperties>();
				component.nodeType = 1;
				component.headerText = "Error";
				component.subText = "A mod is incompatible with Buyable Shotgun";
			}
			catch (Exception ex)
			{
				LoggerInstance.LogError((object)ex.ToString());
			}
			val2.transform.localScale = Vector3.one / 2f;
			return val;
		}

		private void CloneNonScrap(Item original, Item clone, int price)
		{
			//IL_00c9: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			Object.DontDestroyOnLoad((Object)(object)original.spawnPrefab);
			((Object)clone).name = "Buyable" + ((Object)original).name;
			clone.itemName = original.itemName;
			clone.itemId = original.itemId;
			clone.spawnPrefab = original.spawnPrefab;
			clone.creditsWorth = price;
			clone.canBeGrabbedBeforeGameStart = original.canBeGrabbedBeforeGameStart;
			clone.automaticallySetUsingPower = original.automaticallySetUsingPower;
			clone.batteryUsage = original.batteryUsage;
			clone.canBeInspected = original.canBeInspected;
			clone.isDefensiveWeapon = original.isDefensiveWeapon;
			clone.saveItemVariable = original.saveItemVariable;
			clone.syncGrabFunction = original.syncGrabFunction;
			clone.twoHandedAnimation = original.twoHandedAnimation;
			clone.weight = original.weight;
			clone.floorYOffset = original.floorYOffset;
			clone.positionOffset = original.positionOffset;
			clone.rotationOffset = original.rotationOffset;
			clone.restingRotation = original.restingRotation;
			clone.verticalOffset = original.verticalOffset;
		}

		private TerminalNode CreateInfoNode(string name, string description)
		{
			if (infoNodes.ContainsKey(name))
			{
				return infoNodes[name];
			}
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			Object.DontDestroyOnLoad((Object)(object)val);
			val.clearPreviousText = true;
			((Object)val).name = name + "InfoNode";
			val.displayText = description + "\n\n";
			infoNodes.Add(name, val);
			return val;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			LoggerInstance.LogInfo((object)("Scene \"" + ((Scene)(ref scene)).name + "\" loaded with " + ((object)(LoadSceneMode)(ref mode)).ToString() + " mode."));
			if (!((Object)(object)Shotgun == (Object)null))
			{
				CloneNonScrap(Shotgun, ShotgunClone, ShotgunPrice);
			}
		}

		private void AddToShop()
		{
			Item shotgunClone = ShotgunClone;
			int shotgunPrice = ShotgunPrice;
			Items.RegisterShopItem(shotgunClone, (TerminalNode)null, (TerminalNode)null, CreateInfoNode("Shotgun", "Nutcracker's shotgun. Can hold 2 shells. Recommended to keep safety on while not using or it might shoot randomly."), shotgunPrice);
			LoggerInstance.LogInfo((object)$"Shotgun added to Shop for {ShotgunPrice} credits");
		}
	}
}

BuyableShotgunShells/BuyableShotgunShells.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("BuyableShotgunShells")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2023 MegaPiggy")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7478a51a89cb2a1d209d0af8f5d221ffeecf1901")]
[assembly: AssemblyProduct("BuyableShotgunShells")]
[assembly: AssemblyTitle("BuyableShotgunShells")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BuyableShotgunShells
{
	[BepInDependency("evaisa.lethallib", "0.13.2")]
	[BepInPlugin("MegaPiggy.BuyableShotgunShells", "Buyable Shotgun Shells", "1.0.4")]
	public class BuyableShotgunShells : BaseUnityPlugin
	{
		private const string modGUID = "MegaPiggy.BuyableShotgunShells";

		private const string modName = "Buyable Shotgun Shells";

		private const string modVersion = "1.0.4";

		private readonly Harmony harmony = new Harmony("MegaPiggy.BuyableShotgunShells");

		private static BuyableShotgunShells Instance;

		private ConfigEntry<int> ShellPriceConfig;

		private static Dictionary<string, TerminalNode> infoNodes = new Dictionary<string, TerminalNode>();

		private static ManualLogSource LoggerInstance => ((BaseUnityPlugin)Instance).Logger;

		public List<Item> AllItems => Resources.FindObjectsOfTypeAll<Item>().Concat(Object.FindObjectsByType<Item>((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList();

		public Item ShotgunShell => ((IEnumerable<Item>)AllItems).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name.Equals("GunAmmo")));

		public Item ShotgunShellClone { get; private set; }

		public int ShellPrice => ShellPriceConfig.Value;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll();
			ShellPriceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Prices", "ShotgunShellPrice", 20, "Credits needed to buy shotgun shells");
			SceneManager.sceneLoaded += OnSceneLoaded;
			ShotgunShellClone = MakeNonScrap(ShellPrice);
			AddToShop();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Buyable Shotgun Shells is loaded with version 1.0.4!");
		}

		private Item MakeNonScrap(int price)
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			Item val = ScriptableObject.CreateInstance<Item>();
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).name = "Error";
			val.itemName = "Error";
			val.itemId = 6624;
			val.isScrap = false;
			val.creditsWorth = price;
			val.canBeGrabbedBeforeGameStart = true;
			val.automaticallySetUsingPower = false;
			val.batteryUsage = 300f;
			val.canBeInspected = false;
			val.isDefensiveWeapon = true;
			val.saveItemVariable = true;
			val.syncGrabFunction = false;
			val.twoHandedAnimation = true;
			val.verticalOffset = 0.25f;
			GameObject val2 = NetworkPrefabs.CreateNetworkPrefab("Cube");
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
			val3.transform.SetParent(val2.transform, false);
			((Renderer)val3.GetComponent<MeshRenderer>()).sharedMaterial.shader = Shader.Find("HDRP/Lit");
			val2.AddComponent<BoxCollider>().size = Vector3.one * 2f;
			val2.AddComponent<AudioSource>();
			PhysicsProp val4 = val2.AddComponent<PhysicsProp>();
			((GrabbableObject)val4).itemProperties = val;
			((GrabbableObject)val4).grabbable = true;
			val.spawnPrefab = val2;
			val2.tag = "PhysicsProp";
			val2.layer = LayerMask.NameToLayer("Props");
			val3.layer = LayerMask.NameToLayer("Props");
			try
			{
				GameObject val5 = Object.Instantiate<GameObject>(Items.scanNodePrefab, val2.transform);
				((Object)val5).name = "ScanNode";
				val5.transform.localPosition = new Vector3(0f, 0f, 0f);
				Transform transform = val5.transform;
				transform.localScale *= 2f;
				ScanNodeProperties component = val5.GetComponent<ScanNodeProperties>();
				component.nodeType = 1;
				component.headerText = "Error";
				component.subText = "A mod is incompatible with Buyable Shotgun Shells";
			}
			catch (Exception ex)
			{
				LoggerInstance.LogError((object)ex.ToString());
			}
			val2.transform.localScale = Vector3.one / 2f;
			return val;
		}

		private void CloneNonScrap(Item original, Item clone, int price)
		{
			//IL_00c9: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			Object.DontDestroyOnLoad((Object)(object)original.spawnPrefab);
			((Object)clone).name = "Buyable" + ((Object)original).name;
			clone.itemName = original.itemName;
			clone.itemId = original.itemId;
			clone.spawnPrefab = original.spawnPrefab;
			clone.creditsWorth = price;
			clone.canBeGrabbedBeforeGameStart = original.canBeGrabbedBeforeGameStart;
			clone.automaticallySetUsingPower = original.automaticallySetUsingPower;
			clone.batteryUsage = original.batteryUsage;
			clone.canBeInspected = original.canBeInspected;
			clone.isDefensiveWeapon = original.isDefensiveWeapon;
			clone.saveItemVariable = original.saveItemVariable;
			clone.syncGrabFunction = original.syncGrabFunction;
			clone.twoHandedAnimation = original.twoHandedAnimation;
			clone.weight = original.weight;
			clone.floorYOffset = original.floorYOffset;
			clone.positionOffset = original.positionOffset;
			clone.rotationOffset = original.rotationOffset;
			clone.restingRotation = original.restingRotation;
			clone.verticalOffset = original.verticalOffset;
		}

		private TerminalNode CreateInfoNode(string name, string description)
		{
			if (infoNodes.ContainsKey(name))
			{
				return infoNodes[name];
			}
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.clearPreviousText = true;
			((Object)val).name = name + "InfoNode";
			val.displayText = description + "\n\n";
			infoNodes.Add(name, val);
			return val;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (!((Object)(object)ShotgunShell == (Object)null))
			{
				CloneNonScrap(ShotgunShell, ShotgunShellClone, ShellPrice);
				ShotgunShellClone.itemName = "Shells";
			}
		}

		private void AddToShop()
		{
			Item shotgunShellClone = ShotgunShellClone;
			int shellPrice = ShellPrice;
			Items.RegisterShopItem(shotgunShellClone, (TerminalNode)null, (TerminalNode)null, CreateInfoNode("ShotgunShell", "Ammo for the Nutcracker's Shotgun."), shellPrice);
			LoggerInstance.LogInfo((object)$"Shotgun Shell added to Shop for {ShellPrice} credits");
		}
	}
}

crawlingmine/OnionMilk_crawlingmine.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OnionMilk_crawlingmine;
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: AssemblyCompany("OnionMilk_crawlingmine")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Crawling mine plugin for BepInEx (Lethal Company)")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5")]
[assembly: AssemblyProduct("OnionMilk_crawlingmine")]
[assembly: AssemblyTitle("OnionMilk_crawlingmine")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HealthMetrics.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatches
	{
		[HarmonyPatch("ChooseClosestNodeToPosition")]
		[HarmonyPrefix]
		private static void ChooseClosestNodeToPosition(ref EnemyAI __instance, Vector3 pos, bool avoidLineOfSight = false, int offset = 0)
		{
			if (__instance.allAINodes.Any((GameObject n) => (Object)(object)n == (Object)null || ((object)n).Equals((object?)null)))
			{
				__instance.allAINodes = __instance.allAINodes.Where((GameObject n) => (Object)(object)n != (Object)null && !((object)n).Equals((object?)null)).ToArray();
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatches
	{
		[HarmonyPatch("ResetPooledObjects")]
		[HarmonyPostfix]
		private static void ResetPooledObjects(ref StartOfRound __instance, bool destroy = false)
		{
			LandminePatches.jumpTimer = new Dictionary<Landmine, float>();
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class LandminePatches
	{
		public static Dictionary<Landmine, float> jumpTimer;

		private static Random rnd;

		private static Coroutine crawlCoutine;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(ref Landmine __instance)
		{
			if (jumpTimer == null)
			{
				jumpTimer = new Dictionary<Landmine, float>();
			}
			if (rnd == null)
			{
				rnd = new Random(StartOfRound.Instance.randomMapSeed + 2137);
			}
			if (rnd.NextDouble() < (double)Plugin.cfgJumpMineSpawnChance.Value)
			{
				ScanNodeProperties componentInChildren = ((Component)((Component)__instance).transform.parent).GetComponentInChildren<ScanNodeProperties>();
				componentInChildren.headerText = "Crawling Mine";
				componentInChildren.subText = "It crawls around!";
				if (((NetworkBehaviour)__instance).IsServer)
				{
					jumpTimer.Add(__instance, Time.time + GetInterval());
					Plugin.Log("Planted!");
				}
				if (!Plugin.cfgCrawlingMineSound.Value)
				{
					DisableAudio(__instance);
				}
			}
			if (!Plugin.cfgMineSound.Value)
			{
				DisableAudio(__instance);
			}
		}

		private static void DisableAudio(Landmine __instance)
		{
			((Behaviour)__instance.mineAudio).enabled = false;
			__instance.mineAudio.volume = 0f;
			((Behaviour)__instance.mineFarAudio).enabled = false;
			__instance.mineFarAudio.volume = 0f;
		}

		private static float GetInterval()
		{
			return Mathf.Max(0.5f, Random.Range(Plugin.cfgJumpIntervalMin.Value, Plugin.cfgJumpIntervalMax.Value));
		}

		private static float GetRange()
		{
			return Mathf.Max(0.5f, Random.Range(Plugin.cfgJumpRangeMin.Value, Plugin.cfgJumpRangeMax.Value));
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void SetOffMineAnimation(ref Landmine __instance)
		{
			if (crawlCoutine != null)
			{
				((MonoBehaviour)__instance).StopCoroutine(crawlCoutine);
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Update(ref Landmine __instance)
		{
			//IL_0050: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b2: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)__instance).IsServer && jumpTimer.TryGetValue(__instance, out var value) && value < Time.time)
			{
				List<Vector3> list = new List<Vector3>();
				float num = MathF.PI / 4f;
				float range = GetRange();
				for (int i = 0; i < 8; i++)
				{
					float num2 = num * (float)i;
					IEnumerable<Vector3> collection = Raycast(((Component)__instance).transform.position + new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * range);
					list.AddRange(collection);
				}
				if (list.Count > 0)
				{
					Vector3 target = list[Random.Range(0, list.Count)];
					crawlCoutine = ((MonoBehaviour)__instance).StartCoroutine(CrawlRoutine(__instance, target));
					jumpTimer[__instance] = Time.time + GetInterval();
				}
				else
				{
					jumpTimer.Remove(__instance);
				}
			}
		}

		private static IEnumerator CrawlRoutine(Landmine mine, Vector3 target)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (mine.hasExploded)
			{
				yield break;
			}
			float time = 0.5f;
			Transform mineTransform = ((Component)mine).transform;
			Vector3 orgPos = mineTransform.position;
			while (time > 0f)
			{
				if (mine.hasExploded)
				{
					yield break;
				}
				float num = 1f - time / 0.5f;
				Vector3 position = Vector3.Lerp(orgPos, target, num);
				mineTransform.position = position;
				time -= Time.deltaTime;
				yield return null;
			}
			mineTransform.position = target;
		}

		private static IEnumerable<Vector3> Raycast(Vector3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			RaycastHit[] array = Physics.RaycastAll(pos + Vector3.up, Vector3.down, 2.5f);
			if (array.Length != 0)
			{
				return array.Select((RaycastHit h) => ((RaycastHit)(ref h)).point);
			}
			return Array.Empty<Vector3>();
		}
	}
}
namespace OnionMilk_crawlingmine
{
	[BepInPlugin("OnionMilk_crawlingmine", "OnionMilk_crawlingmine", "1.0.5")]
	public class Plugin : BaseUnityPlugin
	{
		private static Plugin instance;

		private readonly Harmony _harmony = new Harmony("OnionMilk.CrawlingMine");

		public static ConfigEntry<bool> cfgEnabled;

		public static ConfigEntry<float> cfgJumpMineSpawnChance;

		public static ConfigEntry<bool> cfgMineSound;

		public static ConfigEntry<bool> cfgCrawlingMineSound;

		public static ConfigEntry<float> cfgJumpIntervalMin;

		public static ConfigEntry<float> cfgJumpIntervalMax;

		public static ConfigEntry<float> cfgJumpRangeMin;

		public static ConfigEntry<float> cfgJumpRangeMax;

		private static string getPath;

		public static string GetPath
		{
			get
			{
				if (getPath == null)
				{
					getPath = Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path));
				}
				return getPath;
			}
		}

		public static void Log(string msg)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)("[OnionMilk_crawlingmine] " + msg));
		}

		private void Awake()
		{
			instance = this;
			cfgJumpRangeMax = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "minRangeInterval", 1f, "Minimal jump range of mine (minval: 0.5)");
			cfgJumpRangeMin = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "maxRangeInterval", 3f, "Maximal jump range of mine (minval: 0.5)");
			cfgJumpIntervalMax = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "minJumpInterval", 4f, "Minimal of interval after which mine would change it's position (minval: 0.5)");
			cfgJumpIntervalMin = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "maxJumpInterval", 10f, "Maximal of interval after which mine would change it's position (minval: 0.5)");
			cfgJumpMineSpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "chance", 0.1f, "Chance of transforming regular mine into jumping one (0.0-1.0)");
			cfgMineSound = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "mineBeepSound", true, "let's you disable beeping sound");
			cfgCrawlingMineSound = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "crawlingMineBeepSound", true, "let's you disable beeping sound of crawling mine ;)");
			cfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enabled", true, "Is plugin enabled?");
			if (cfgEnabled.Value)
			{
				Log("Mod loaded and set up!");
				_harmony.PatchAll();
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "OnionMilk_crawlingmine";

		public const string PLUGIN_NAME = "OnionMilk_crawlingmine";

		public const string PLUGIN_VERSION = "1.0.5";
	}
}

DeadAndBored/DeadAndBored.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using DeadAndBored.Configuration;
using DeadAndBored.Patches;
using Dissonance.Audio.Playback;
using GameNetcodeStuff;
using HarmonyLib;
using LC_API.Networking;
using SpectateEnemy;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("DeadAndBored")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("DeadAndBored")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DeadAndBored")]
[assembly: AssemblyTitle("DeadAndBored")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DeadAndBored
{
	internal class BroadcastParameters
	{
		public string controllerName;

		public string enemyName;

		public float x;

		public float y;

		public float z;
	}
	internal class DeadAndBoredObject : MonoBehaviour
	{
		public static DeadAndBoredObject Instance = null;

		private bool wasSpectatingEnemies = false;

		private GameObject oldSpectatingEnemy = null;

		public bool isDeadAndTalking = false;

		private bool wasPushToTalk = false;

		private static string deadAndTalkingUniqueName = "TheDeadTalk";

		private static string deadAndStopTalkingUniqueName = "TheDeadStopTalk";

		public static void DABLogging(string logString)
		{
			if (Config.enableDebugLogging)
			{
				Debug.Log((object)("DEAD AND BORED: " + logString));
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			Init();
			SceneManager.activeSceneChanged += OnSceneChanged;
			Debug.Log((object)$"DeadAndBored Debugger: {Config.enableDebugLogging}");
		}

		private void OnSceneChanged(Scene old, Scene newScene)
		{
			Reset();
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			if (UnityInput.Current.GetKeyDown(Config.manuallyResetAudioData))
			{
				Reset();
			}
			if (!SpectateEnemiesAPI.IsLoaded)
			{
				return;
			}
			if ((Object)(object)oldSpectatingEnemy != (Object)(object)SpectateEnemiesAPI.CurrentEnemySpectating())
			{
				oldSpectatingEnemy = SpectateEnemiesAPI.CurrentEnemySpectating();
				if (isDeadAndTalking)
				{
					StopTalk(((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).NetworkObjectId);
				}
			}
			if (wasSpectatingEnemies != SpectateEnemiesAPI.IsSpectatingEnemies)
			{
				wasSpectatingEnemies = SpectateEnemiesAPI.IsSpectatingEnemies;
				if (isDeadAndTalking)
				{
					StopTalk(((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).NetworkObjectId);
				}
			}
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || !GameNetworkManager.Instance.localPlayerController.isPlayerDead)
			{
				return;
			}
			if (SpectateEnemiesAPI.IsSpectatingEnemies && UnityInput.Current.GetKeyDown(Config.deadAndTalkingKey) && !isDeadAndTalking)
			{
				BroadcastParameters broadcastParameters = new BroadcastParameters();
				broadcastParameters.controllerName = ((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).NetworkObjectId.ToString();
				GameObject val = SpectateEnemiesAPI.CurrentEnemySpectating();
				if ((Object)(object)val != (Object)null)
				{
					broadcastParameters.enemyName = ((Object)val).name;
					broadcastParameters.x = val.transform.position.x;
					broadcastParameters.y = val.transform.position.y;
					broadcastParameters.z = val.transform.position.z;
					Talk(broadcastParameters);
				}
			}
			if (UnityInput.Current.GetKeyUp(Config.deadAndTalkingKey) && isDeadAndTalking)
			{
				StopTalk(((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).NetworkObjectId);
			}
		}

		private void Talk(BroadcastParameters param)
		{
			if (IngamePlayerSettings.Instance.settings.pushToTalk)
			{
				IngamePlayerSettings.Instance.settings.pushToTalk = false;
				wasPushToTalk = true;
			}
			isDeadAndTalking = true;
			Network.Broadcast<BroadcastParameters>(deadAndTalkingUniqueName, param);
			DABLogging("Begin talk for player: " + param.controllerName);
			StartOfRound.Instance.UpdatePlayerVoiceEffects();
		}

		private void StopTalk(ulong controllerName)
		{
			if (wasPushToTalk)
			{
				IngamePlayerSettings.Instance.settings.pushToTalk = true;
				wasPushToTalk = false;
			}
			isDeadAndTalking = false;
			Network.Broadcast<string>(deadAndStopTalkingUniqueName, controllerName.ToString());
			DABLogging($"Stop talk for player: {controllerName}");
			StartOfRound.Instance.UpdatePlayerVoiceEffects();
		}

		public void Init()
		{
			Action<ulong, BroadcastParameters> action = delegate(ulong sender, BroadcastParameters args)
			{
				TheDeadTalk(args);
			};
			Action<ulong, string> action2 = delegate(ulong sender, string args)
			{
				TheDeadStopTalk(args);
			};
			Network.RegisterMessage<BroadcastParameters>(deadAndTalkingUniqueName, false, action);
			Network.RegisterMessage<string>(deadAndStopTalkingUniqueName, false, action2);
			Reset();
		}

		public void Reset()
		{
			DABLogging("CALLING RESET");
			if (isDeadAndTalking && (Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				StopTalk(((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).NetworkObjectId);
			}
			isDeadAndTalking = false;
			if (UpdatePlayerVoiceEffectsPatch.Configs != null)
			{
				UpdatePlayerVoiceEffectsPatch.Configs.Clear();
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null)
			{
				StartOfRound.Instance.UpdatePlayerVoiceEffects();
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB val in allPlayerScripts)
				{
					if (!((Object)(object)val != (Object)null) || !((Object)(object)val.currentVoiceChatAudioSource != (Object)null))
					{
						continue;
					}
					if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
					{
						if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)val)
						{
							val.currentVoiceChatAudioSource.volume = 1f;
						}
					}
					else
					{
						val.currentVoiceChatAudioSource.volume = 1f;
					}
				}
			}
			if (SpectateEnemiesAPI.IsLoaded)
			{
				wasSpectatingEnemies = SpectateEnemiesAPI.IsSpectatingEnemies;
			}
			else
			{
				wasSpectatingEnemies = false;
			}
			wasPushToTalk = false;
			oldSpectatingEnemy = null;
		}

		private void TheDeadTalk(BroadcastParameters param)
		{
			PlayerControllerB val = FindPlayerByNetworkID(param.controllerName);
			DABLogging("--------------- Talking Player recieved: " + param.controllerName);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			DABLogging($"UpdatePlayerVoiceEffects Contains Player: {UpdatePlayerVoiceEffectsPatch.Configs.ContainsKey(val)}");
			if (UpdatePlayerVoiceEffectsPatch.Configs.ContainsKey(val))
			{
				AudioConfig audioConfig = UpdatePlayerVoiceEffectsPatch.Configs[val];
				GameObject val2 = FindEnemyByNameAndPos(param);
				if ((Object)(object)val2 != (Object)null)
				{
					audioConfig.EnemyT = val2.transform;
				}
				else
				{
					DABLogging("Could not find enemy from name and position");
				}
				UpdatePlayerVoiceEffectsPatch.Configs[val] = audioConfig;
			}
			DABLogging("-------------- Finishing The Dead Talk");
			StartOfRound.Instance.UpdatePlayerVoiceEffects();
		}

		private void TheDeadStopTalk(string controllerID)
		{
			DABLogging("-------------- Start The Dead Stop Talk");
			PlayerControllerB val = FindPlayerByNetworkID(controllerID);
			DABLogging($"Found Player: {(Object)(object)val != (Object)null}");
			if (!((Object)(object)val == (Object)null))
			{
				DABLogging($"Config Contains Player: {UpdatePlayerVoiceEffectsPatch.Configs.ContainsKey(val)}");
				if (UpdatePlayerVoiceEffectsPatch.Configs.ContainsKey(val))
				{
					AudioConfig audioConfig = UpdatePlayerVoiceEffectsPatch.Configs[val];
					audioConfig.EnemyT = null;
					UpdatePlayerVoiceEffectsPatch.Configs[val] = audioConfig;
					StartOfRound.Instance.UpdatePlayerVoiceEffects();
					DABLogging("-------------- Finish The Dead Stop Talk");
				}
			}
		}

		private PlayerControllerB FindPlayerByNetworkID(string networkID)
		{
			PlayerControllerB[] array = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0);
			foreach (PlayerControllerB val in array)
			{
				if (((NetworkBehaviour)val).NetworkObjectId == ulong.Parse(networkID))
				{
					return val;
				}
			}
			return null;
		}

		private GameObject FindEnemyByNameAndPos(BroadcastParameters bParams)
		{
			//IL_005a: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(bParams.x, bParams.y, bParams.z);
			GameObject[] array = Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0);
			float num = float.PositiveInfinity;
			GameObject result = null;
			GameObject[] array2 = array;
			foreach (GameObject val2 in array2)
			{
				if (((Object)val2).name == bParams.enemyName)
				{
					float num2 = Vector3.Distance(val2.transform.position, val);
					if (Vector3.Distance(val2.transform.position, val) < num)
					{
						result = val2;
						num = num2;
					}
				}
			}
			return result;
		}
	}
	public class DeadAndBoredAPI
	{
		public static bool IsLoaded => (Object)(object)DeadAndBoredObject.Instance != (Object)null;

		public static bool IsDeadAndTalking => DeadAndBoredObject.Instance.isDeadAndTalking;
	}
	[BepInPlugin("DeadAndBored", "DeadAndBored", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony harmony;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			harmony = new Harmony("DeadAndBored");
			Config.Init();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Dead And Bored loaded!");
			harmony.PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "DeadAndBored";

		public const string PLUGIN_NAME = "DeadAndBored";

		public const string PLUGIN_VERSION = "1.1.0";
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DeadAndBored";

		public const string PLUGIN_NAME = "DeadAndBored";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DeadAndBored.Patches
{
	internal class AudioConfig
	{
		private PlayerControllerB playerControllerB;

		private Transform enemyTransform;

		private bool lowPassFilter = false;

		private bool highPassFilter = false;

		private float panStereo = 0f;

		private float playerVoicePitchTargets = 0f;

		private float playerPitch = 0f;

		private float spatialBlend = 0f;

		private bool set2D = false;

		private float volume = 0f;

		public bool LowPassFilter => lowPassFilter;

		public bool HighPassFilter => highPassFilter;

		public float PanStereo => panStereo;

		public float PlayerVoicePitchTargets => playerVoicePitchTargets;

		public float PlayerPitch => playerPitch;

		public float SpatialBlend => spatialBlend;

		public bool Set2D => set2D;

		public float Volume => volume;

		public Transform EnemyT
		{
			get
			{
				return ((Object)(object)enemyTransform == (Object)null) ? null : enemyTransform;
			}
			set
			{
				enemyTransform = value;
			}
		}

		public Transform AudioSourceT => ((Component)playerControllerB.currentVoiceChatAudioSource).transform;

		public AudioConfig(PlayerControllerB playerControllerB, bool lowPassFilter, bool highPassFilter, float panStereo, float playerVoicePitchTargets, float playerPitch, float spatialBlend, bool set2D, float volume)
		{
			this.playerControllerB = playerControllerB;
			enemyTransform = null;
			this.lowPassFilter = lowPassFilter;
			this.highPassFilter = highPassFilter;
			this.panStereo = panStereo;
			this.playerVoicePitchTargets = playerVoicePitchTargets;
			this.playerPitch = playerPitch;
			this.spatialBlend = spatialBlend;
			this.set2D = set2D;
			this.volume = volume;
		}
	}
	[HarmonyPatch]
	internal class DissonancePatch
	{
		public static MethodBase TargetMethod()
		{
			return AccessTools.FirstMethod(typeof(VoicePlayback), (Func<MethodInfo, bool>)((MethodInfo method) => method.Name.Contains("SetTransform")));
		}

		private static bool Prefix(object __instance)
		{
			foreach (AudioConfig value in UpdatePlayerVoiceEffectsPatch.Configs.Values)
			{
				if ((Object)(object)value.EnemyT == (Object)null || !((object)((Component)((__instance is VoicePlayback) ? __instance : null)).transform).Equals((object?)value.AudioSourceT))
				{
					continue;
				}
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Update")]
	internal class HUDManagerPatch
	{
		private static void Postfix(HUDManager __instance)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (SpectateEnemiesAPI.IsSpectatingEnemies && Config.enableTooltip)
			{
				KeyCode deadAndTalkingKey;
				if (DeadAndBoredObject.Instance.isDeadAndTalking)
				{
					TextMeshProUGUI holdButtonToEndGameEarlyText = __instance.holdButtonToEndGameEarlyText;
					string text = ((TMP_Text)holdButtonToEndGameEarlyText).text;
					deadAndTalkingKey = Config.deadAndTalkingKey;
					((TMP_Text)holdButtonToEndGameEarlyText).text = text + "\n\n<color=#1c73ff>Talk As Enemy: [" + ((object)(KeyCode)(ref deadAndTalkingKey)).ToString() + "]</color>";
				}
				else
				{
					TextMeshProUGUI holdButtonToEndGameEarlyText2 = __instance.holdButtonToEndGameEarlyText;
					string text2 = ((TMP_Text)holdButtonToEndGameEarlyText2).text;
					deadAndTalkingKey = Config.deadAndTalkingKey;
					((TMP_Text)holdButtonToEndGameEarlyText2).text = text2 + "\n\nTalk As Enemy: [" + ((object)(KeyCode)(ref deadAndTalkingKey)).ToString() + "]";
				}
			}
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "Start")]
	internal class QuickMenuManager_Patches
	{
		private static void Postfix(QuickMenuManager __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)DeadAndBoredObject.Instance == (Object)null)
			{
				GameObject val = new GameObject("DeadAndBoredObject");
				val.AddComponent<DeadAndBoredObject>();
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "Start")]
	internal class StartOfRoundPatch
	{
		private static void Postfix()
		{
			DeadAndBoredObject.DABLogging($"PostFix Start: {(Object)(object)DeadAndBoredObject.Instance != (Object)null}");
			if ((Object)(object)DeadAndBoredObject.Instance != (Object)null)
			{
				DeadAndBoredObject.Instance.Reset();
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
	internal class ShipLeavePatch
	{
		private static void Postfix()
		{
			DeadAndBoredObject.DABLogging($"Postfix Leave: {(Object)(object)DeadAndBoredObject.Instance != (Object)null}");
			if ((Object)(object)DeadAndBoredObject.Instance != (Object)null)
			{
				DeadAndBoredObject.Instance.Reset();
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "UpdatePlayerVoiceEffects")]
	internal class UpdatePlayerVoiceEffectsPatch
	{
		private static bool updateStarted = false;

		private static Dictionary<PlayerControllerB, AudioConfig> configs = new Dictionary<PlayerControllerB, AudioConfig>();

		public static Dictionary<PlayerControllerB, AudioConfig> Configs => configs;

		[HarmonyBefore(new string[] { "BiggerLobby" })]
		private static void Prefix()
		{
			if (configs == null)
			{
				configs = new Dictionary<PlayerControllerB, AudioConfig>();
			}
			if (!updateStarted)
			{
				((MonoBehaviour)HUDManager.Instance).StartCoroutine(UpdateNumerator());
				updateStarted = true;
			}
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null)
			{
				return;
			}
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
				if (!((Object)(object)val == (Object)null) && (val.isPlayerControlled || val.isPlayerDead) && (Object)(object)val != (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					AudioSource currentVoiceChatAudioSource = val.currentVoiceChatAudioSource;
					if (!((Object)(object)currentVoiceChatAudioSource == (Object)null) && val.isPlayerDead && !configs.ContainsKey(val))
					{
						DeadAndBoredObject.DABLogging($"------- -- - -- ADD Player to configs: {((NetworkBehaviour)val).NetworkObjectId}");
						DeadAndBoredObject.DABLogging("-------------------------------");
						Dictionary<PlayerControllerB, AudioConfig> dictionary = configs;
						float panStereo = (currentVoiceChatAudioSource.panStereo = 0f);
						dictionary.Add(val, new AudioConfig(val, lowPassFilter: true, highPassFilter: false, panStereo, 1f, 1f, 1f, set2D: false, 1f));
					}
				}
			}
		}

		private static void Postfix()
		{
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			if (configs == null)
			{
				configs = new Dictionary<PlayerControllerB, AudioConfig>();
			}
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			PlayerControllerB[] array = configs.Keys.ToArray();
			foreach (PlayerControllerB val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				AudioConfig audioConfig = configs[val];
				if (audioConfig == null)
				{
					continue;
				}
				DeadAndBoredObject.DABLogging($"PlayerControllerB: {((NetworkBehaviour)val).NetworkObjectId}");
				if (GameNetworkManager.Instance.localPlayerController.isPlayerDead && val.isPlayerDead && (Object)(object)configs[val].EnemyT != (Object)null && !Config.hearOtherDeadTeammates)
				{
					val.currentVoiceChatAudioSource.spatialBlend = 1f;
					val.currentVoiceChatIngameSettings.set2D = false;
					val.voicePlayerState.Volume = 0f;
					DeadAndBoredObject.DABLogging($"Stopping volume of Player {((NetworkBehaviour)val).NetworkObjectId}");
					continue;
				}
				DeadAndBoredObject.DABLogging("---------------------------------------------------------");
				DeadAndBoredObject.DABLogging($"Player Controlled: {val.isPlayerControlled}");
				DeadAndBoredObject.DABLogging($"Is Player Dead: {val.isPlayerDead}");
				DeadAndBoredObject.DABLogging($"Local Player: {GameNetworkManager.Instance.localPlayerController}");
				DeadAndBoredObject.DABLogging("---------------------------------------------------------");
				if ((val.isPlayerControlled || val.isPlayerDead) && !((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController))
				{
					DeadAndBoredObject.DABLogging($"Current Voice Chat Audio Source: {(Object)(object)val.currentVoiceChatAudioSource != (Object)null}");
					if ((Object)(object)val.currentVoiceChatAudioSource == (Object)null)
					{
						continue;
					}
					AudioSource currentVoiceChatAudioSource = val.currentVoiceChatAudioSource;
					DeadAndBoredObject.DABLogging($"Enemy Voice Chat Audio Source: {(Object)(object)configs[val].EnemyT != (Object)null}");
					if ((Object)(object)configs[val].EnemyT != (Object)null)
					{
						((Component)currentVoiceChatAudioSource).transform.position = configs[val].EnemyT.position;
						currentVoiceChatAudioSource.panStereo = audioConfig.PanStereo;
						currentVoiceChatAudioSource.spatialBlend = audioConfig.SpatialBlend;
						AudioLowPassFilter component = ((Component)currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>();
						AudioHighPassFilter component2 = ((Component)currentVoiceChatAudioSource).GetComponent<AudioHighPassFilter>();
						if ((Object)(object)component != (Object)null)
						{
							((Behaviour)component).enabled = audioConfig.LowPassFilter;
						}
						if ((Object)(object)component2 != (Object)null)
						{
							((Behaviour)component2).enabled = audioConfig.HighPassFilter;
						}
						if ((Object)(object)SoundManager.Instance != (Object)null)
						{
							SoundManager.Instance.playerVoicePitchTargets[(int)(IntPtr)(long)val.playerClientId] = audioConfig.PlayerVoicePitchTargets;
							SoundManager.Instance.SetPlayerPitch(audioConfig.PlayerPitch, (int)val.playerClientId);
						}
						val.currentVoiceChatIngameSettings.set2D = audioConfig.Set2D;
						val.voicePlayerState.Volume = audioConfig.Volume;
						val.currentVoiceChatAudioSource.volume = audioConfig.Volume;
					}
				}
				else if (!val.isPlayerDead)
				{
					configs.Remove(val);
				}
			}
		}

		private static IEnumerator UpdateNumerator()
		{
			yield return 0;
			while (true)
			{
				UpdatePlayersStatus();
				yield return (object)new WaitForFixedUpdate();
			}
		}

		private static void UpdatePlayersStatus()
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if (configs == null)
			{
				return;
			}
			bool flag = false;
			KeyValuePair<PlayerControllerB, AudioConfig>[] array = configs.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				KeyValuePair<PlayerControllerB, AudioConfig> keyValuePair = array[i];
				if (!((Object)(object)keyValuePair.Key == (Object)null))
				{
					if (!keyValuePair.Key.isPlayerDead)
					{
						configs.Remove(keyValuePair.Key);
						flag = true;
					}
					else if ((Object)(object)keyValuePair.Value.EnemyT != (Object)null && (Object)(object)keyValuePair.Value.AudioSourceT != (Object)null)
					{
						keyValuePair.Value.AudioSourceT.position = keyValuePair.Value.EnemyT.position;
					}
				}
			}
			if (flag)
			{
				StartOfRound.Instance.UpdatePlayerVoiceEffects();
			}
		}

		private static float GetPitch(PlayerControllerB playerControllerB)
		{
			int num = (int)playerControllerB.playerClientId;
			float result = default(float);
			SoundManager.Instance.diageticMixer.GetFloat($"PlayerPitch{num}", ref result);
			return result;
		}
	}
}
namespace DeadAndBored.Configuration
{
	internal static class Config
	{
		private const string CONFIG_FILE_NAME = "DeadAndBored.cfg";

		private static ConfigFile config;

		private static ConfigEntry<KeyCode> deadAndTalkingKeyConfig;

		private static ConfigEntry<bool> enableTooltipConfig;

		private static ConfigEntry<bool> hearOtherTeammates;

		private static ConfigEntry<bool> enableLogging;

		private static ConfigEntry<KeyCode> manuallyResetAudioDataConfig;

		public static KeyCode deadAndTalkingKey => deadAndTalkingKeyConfig.Value;

		public static bool enableTooltip => enableTooltipConfig.Value;

		public static bool hearOtherDeadTeammates => hearOtherTeammates.Value;

		public static bool enableDebugLogging => enableLogging.Value;

		public static KeyCode manuallyResetAudioData => manuallyResetAudioDataConfig.Value;

		public static void Init()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			string text = Path.Combine(Paths.ConfigPath, "DeadAndBored.cfg");
			config = new ConfigFile(text, true);
			deadAndTalkingKeyConfig = config.Bind<KeyCode>("Config", "Key To Talk", (KeyCode)121, "Key press to talk as enemy (when spectating enemy).");
			enableTooltipConfig = config.Bind<bool>("Config", "Enable Tooltip", true, "Enable the tooltip menu");
			hearOtherTeammates = config.Bind<bool>("Config", "Hear Other Dead Teammates While They Are Talking As An Enemy", false, "With this set to False, you will not hear your other dead teammates when they are talking as an enemy. You will hear them again when they stop talking as an enemy. Note there is a delay so you may still hear/not hear them for a brief period of time.");
			enableLogging = config.Bind<bool>("Config", "Enable Debug Logging", false, "Set to true for debugging");
			manuallyResetAudioDataConfig = config.Bind<KeyCode>("Config", "If a player loses audio, they can press this key to reset their audio data.", (KeyCode)117, "Key press to manually reset audio data");
		}
	}
}

DontTouchMe/DontTouchMe.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DontTouchMe")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DontTouchMe")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2b5c0b79-7fa5-44d5-a3d7-384bed3474cb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace DontTouchMe;

public class Assets
{
	public static AssetBundle MainAssetBundle;

	public static EnemyType EnemyType;

	public static TerminalNode EnemyNode;

	public static TerminalKeyword EnemyKeyword;

	public static AudioClip AudioMasked1;

	public static AudioClip AudioMasked2;

	internal static Stream GetEmbededResource(string name)
	{
		return Assembly.GetExecutingAssembly().GetManifestResourceStream("DontTouchMe." + name);
	}

	public static void Init()
	{
		Stream embededResource = GetEmbededResource("dtm.bundle");
		MainAssetBundle = AssetBundle.LoadFromStream(embededResource);
		EnemyType = MainAssetBundle.LoadAsset<EnemyType>("Assets/Mods/DontTouchMe/Resources/DTMEnemy.asset");
		EnemyNode = MainAssetBundle.LoadAsset<TerminalNode>("Assets/Mods/DontTouchMe/Resources/DTMNode.asset");
		EnemyKeyword = MainAssetBundle.LoadAsset<TerminalKeyword>("Assets/Mods/DontTouchMe/Resources/DTMKeyword.asset");
		AudioMasked1 = MainAssetBundle.LoadAsset<AudioClip>("Assets/Mods/DontTouchMe/Resources/dtm_masked_laugh1.wav");
		AudioMasked2 = MainAssetBundle.LoadAsset<AudioClip>("Assets/Mods/DontTouchMe/Resources/dtm_masked_laugh2.wav");
	}
}
public class DTMEntityAI : EnemyAI
{
	public static List<DTMEntityAI> Instances = new List<DTMEntityAI>();

	[Header("DTM Specific")]
	public InteractTrigger[] Triggers;

	public GameObject Music;

	public AudioSource VoiceA;

	public AudioSource VoiceB;

	private float AttackTime;

	private bool IsAttacking;

	private bool HasAttacked;

	private bool AttemptedMurder;

	public MaskedPlayerEnemy MaskedEnemy;

	private float StaringTimestamp;

	[Header("Disguise")]
	public GameObject MainModel;

	public GameObject Disguise;

	private int DisguiseID;

	private float ScreenShakeTime;

	private const float KillWindowMin = 2.3f;

	private const float KillWindowMax = 3.5f;

	private float KillWindowStart = 2.8f;

	private const string ButtonTouchParam = "Touched";

	private const string ButtonPressParam = "Press";

	private Coroutine ExplodePlayerCoroutine;

	public static int Count => Instances.Count;

	public static DTMEntityAI GetClosest(Vector3 pos)
	{
		//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)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		DTMEntityAI dTMEntityAI = null;
		if (Instances.Count == 0)
		{
			return dTMEntityAI;
		}
		if (Instances.Count == 1)
		{
			return Instances[0];
		}
		float num = float.MaxValue;
		foreach (DTMEntityAI instance in Instances)
		{
			if ((Object)(object)instance == (Object)null)
			{
				Instances.RemoveAll((DTMEntityAI v) => (Object)(object)v == (Object)null);
				dTMEntityAI = GetClosest(pos);
				break;
			}
			float num2 = Vector3.Distance(((Component)instance).transform.position, pos);
			if ((Object)(object)dTMEntityAI == (Object)null || num2 < num)
			{
				dTMEntityAI = instance;
				num = num2;
			}
		}
		return dTMEntityAI;
	}

	public void SetTrigger(bool interactable)
	{
		InteractTrigger[] triggers = Triggers;
		foreach (InteractTrigger val in triggers)
		{
			val.interactable = interactable;
		}
	}

	public bool CanBeShocked()
	{
		if (!IsAttacking)
		{
			return !HasAttacked;
		}
		return false;
	}

	public override void OnDestroy()
	{
		((EnemyAI)this).OnDestroy();
		Instances.Remove(this);
	}

	public override void Start()
	{
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Expected O, but got Unknown
		Instances.Add(this);
		base.skinnedMeshRenderers = ((Component)this).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
		base.meshRenderers = ((Component)this).gameObject.GetComponentsInChildren<MeshRenderer>(true);
		base.thisNetworkObject = ((Component)this).gameObject.GetComponentInChildren<NetworkObject>(true);
		base.thisEnemyIndex = RoundManager.Instance.numberOfEnemiesInScene;
		RoundManager instance = RoundManager.Instance;
		instance.numberOfEnemiesInScene++;
		base.isOutside = Plugin.SpawnOutsideChance > 0 && Random.Range(0, 100) < Plugin.SpawnOutsideChance;
		if (base.isOutside)
		{
			base.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				((EnemyAI)this).EnableEnemyMesh(!StartOfRound.Instance.hangarDoorsClosed || !GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom, false);
			}
		}
		else
		{
			base.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
		}
		base.serverPosition = ((Component)this).transform.position;
		base.updatePositionThreshold = 0f;
		base.path1 = new NavMeshPath();
		base.openDoorSpeedMultiplier = base.enemyType.doorSpeedMultiplier;
		ResetInteraction(changeLocation: true);
		Debug.Log((object)"DON'T TOUCH ME | DON'T TOUCH ME | DON'T TOUCH ME | DON'T TOUCH ME | DON'T TOUCH ME | DON'T TOUCH ME");
		Debug.Log((object)("Spawned Outside: " + base.isOutside));
	}

	private void ResetInteraction(bool changeLocation)
	{
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_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_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		MaskedEnemy = null;
		base.targetPlayer = null;
		IsAttacking = false;
		HasAttacked = false;
		AttemptedMurder = false;
		SetTrigger(interactable: true);
		Music.SetActive(false);
		((Component)VoiceA).gameObject.SetActive(false);
		base.creatureAnimator.ResetTrigger("Touched");
		base.creatureAnimator.ResetTrigger("Press");
		if (changeLocation)
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				Vector3 position = base.allAINodes[Random.Range(0, base.allAINodes.Length)].transform.position;
				position = RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 1f, -1);
				((Component)this).transform.position = position;
				((Component)this).transform.rotation = Quaternion.Euler(0f, Random.Range(-180f, 180f), 0f);
				DisguiseID = ((Random.Range(0, 100) < Plugin.DisguiseAsItemChance) ? Random.Range(1, Disguise.transform.childCount) : (-1));
				Debug.Log((object)"[DTM] Trying to sync position with other players.");
				SyncSpawnOnServer();
			}
			else
			{
				base.isClientCalculatingAI = false;
			}
		}
	}

	public override void Update()
	{
		//IL_0047: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_038e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0393: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)MaskedEnemy != (Object)null)
		{
			if (((NetworkBehaviour)MaskedEnemy).IsOwner && !((EnemyAI)MaskedEnemy).isEnemyDead && ((EnemyAI)MaskedEnemy).moveTowardsDestination && Vector3.Distance(((EnemyAI)MaskedEnemy).destination, ((Component)this).transform.position) < 1.5f && Object.op_Implicit((Object)(object)base.targetPlayer) && ((EnemyAI)MaskedEnemy).isOutside == !base.targetPlayer.isInsideFactory && !base.targetPlayer.isPlayerDead && ((EnemyAI)MaskedEnemy).currentBehaviourState != null)
			{
				float num = Vector3.Distance(((Component)MaskedEnemy).transform.position, ((Component)this).transform.position);
				switch (((EnemyAI)MaskedEnemy).currentBehaviourState.name)
				{
				case "FoundDTM":
					if (!(num > 1.5f))
					{
						Debug.Log((object)"[MASK] Start staring.");
						StaringTimestamp = Time.time + Random.Range(1f, 4f);
						MaskedEnemy.LookAtPlayerServerRpc((int)base.targetPlayer.playerClientId);
						((EnemyAI)MaskedEnemy).SetDestinationToPosition(((Component)MaskedEnemy).transform.position, false);
						((EnemyAI)MaskedEnemy).SwitchToBehaviourState(((EnemyAI)MaskedEnemy).currentBehaviourStateIndex + 1);
					}
					break;
				case "StareDTM":
					if (!(Time.time < StaringTimestamp))
					{
						Debug.Log((object)"[MASK] Look at the button.");
						StaringTimestamp = Time.time + Random.Range(1f, 2f);
						MaskedEnemy.StopLookingAtTransformServerRpc();
						MaskedEnemy.LookAtPositionServerRpc(((Component)this).transform.position, 10f);
						((EnemyAI)MaskedEnemy).SwitchToBehaviourState(((EnemyAI)MaskedEnemy).currentBehaviourStateIndex + 1);
					}
					break;
				case "PressDTM":
					if (!(Time.time < StaringTimestamp))
					{
						Debug.Log((object)"[MASK] Pressing the button.");
						OnTouched(base.targetPlayer);
						MaskedEnemy.StopLookingAtTransformServerRpc();
						((EnemyAI)MaskedEnemy).SwitchToBehaviourState(0);
						MaskedEnemy = null;
						base.targetPlayer = null;
					}
					break;
				}
			}
			else
			{
				Debug.Log((object)"[MASK] Lost interest.");
				MaskedEnemy.StopLookingAtTransformServerRpc();
				((EnemyAI)MaskedEnemy).SwitchToBehaviourState(0);
				MaskedEnemy = null;
				base.targetPlayer = null;
			}
		}
		if (!IsAttacking)
		{
			return;
		}
		if (Object.op_Implicit((Object)(object)MaskedEnemy))
		{
			MaskedEnemy = null;
			base.targetPlayer = null;
		}
		float num2 = Time.time - AttackTime;
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		bool flag = ((EnemyAI)this).PlayerIsTargetable(localPlayerController, false, false) || (localPlayerController.hasBegunSpectating && Object.op_Implicit((Object)(object)localPlayerController.spectatedPlayerScript) && ((EnemyAI)this).PlayerIsTargetable(localPlayerController.spectatedPlayerScript, false, false));
		if (flag && ScreenShakeTime < Time.time)
		{
			HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
			ScreenShakeTime = Time.time + 0.1f;
		}
		AudioSource voiceA = VoiceA;
		bool flag3 = (VoiceB.mute = flag);
		voiceA.mute = !flag3;
		if (num2 > KillWindowStart && num2 < 4.4f)
		{
			if (localPlayerController.isPlayerControlled && !localPlayerController.isPlayerDead && flag)
			{
				Vector3 val = ((Component)localPlayerController).transform.position - ((Component)this).transform.position;
				Vector3 val2 = ((Vector3)(ref val)).normalized * Random.Range(15f, 30f);
				val2.y = Random.Range(10f, 15f);
				localPlayerController.KillPlayer(val2, true, (CauseOfDeath)3, 0);
				ExplodePlayerServerRpc((int)localPlayerController.playerClientId);
			}
			if (Plugin.IncludeMonstersOnKill && ((NetworkBehaviour)this).IsServer && !AttemptedMurder)
			{
				foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
				{
					if (Object.op_Implicit((Object)(object)spawnedEnemy) && spawnedEnemy.isOutside == base.isOutside && (Object)(object)((Component)spawnedEnemy).gameObject != (Object)(object)((Component)this).gameObject && spawnedEnemy.thisNetworkObject.IsSpawned && (Plugin.IncludeUnkillableMonsters || spawnedEnemy.enemyType.canDie))
					{
						Debug.Log((object)("[DTM] Killing " + ((Object)spawnedEnemy).name));
						spawnedEnemy.thisNetworkObject.Despawn(true);
					}
				}
				AttemptedMurder = true;
			}
		}
		if (num2 >= 5f)
		{
			if (Plugin.DestroyEntityAfterTouch)
			{
				IsAttacking = false;
				HasAttacked = true;
				((EnemyAI)this).KillEnemy(true);
			}
			else
			{
				ResetInteraction(Plugin.ChangeLocationAfterTouch);
			}
		}
	}

	private IEnumerator ExplodePlayerEffect(int clientId)
	{
		PlayerControllerB killedPlayer = StartOfRound.Instance.allPlayerScripts[clientId];
		float startTime = Time.realtimeSinceStartup;
		yield return (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - startTime > 1f || (Object)(object)killedPlayer.deadBody != (Object)null));
		Transform transform = ((Component)killedPlayer).transform;
		if ((Object)(object)killedPlayer.deadBody != (Object)null)
		{
			transform = ((Component)killedPlayer.deadBody).transform;
		}
		Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, transform.position + Vector3.up * 0.5f, Quaternion.Euler(-90f, 0f, 0f), RoundManager.Instance.mapPropsContainer.transform).SetActive(true);
		base.inSpecialAnimation = false;
	}

	[ClientRpc]
	private void ExplodePlayerClientRpc(int clientId)
	{
		//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)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3906254083u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, clientId);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3906254083u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (ExplodePlayerCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(ExplodePlayerCoroutine);
			}
			ExplodePlayerCoroutine = ((MonoBehaviour)this).StartCoroutine(ExplodePlayerEffect(clientId));
		}
	}

	[ServerRpc(RequireOwnership = false)]
	private void ExplodePlayerServerRpc(int clientId)
	{
		//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)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(877622320u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 877622320u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ExplodePlayerClientRpc(clientId);
			}
		}
	}

	private void UpdateDisguise()
	{
		MainModel.SetActive(DisguiseID < 1);
		Disguise.SetActive(!MainModel.activeSelf);
		if (Disguise.activeSelf)
		{
			Transform transform = Disguise.transform;
			for (int i = 1; i < transform.childCount; i++)
			{
				((Component)transform.GetChild(i)).gameObject.SetActive(i == DisguiseID);
			}
		}
	}

	private void SyncSpawnOnServer()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		base.serverPosition = ((Component)this).transform.position;
		if (((NetworkBehaviour)this).IsOwner)
		{
			SpawnClientRpc(base.serverPosition, ((Component)this).transform.eulerAngles.y, DisguiseID);
		}
		else
		{
			SpawnServerRpc(base.serverPosition, ((Component)this).transform.eulerAngles.y, DisguiseID);
		}
	}

	[ClientRpc]
	public void SpawnClientRpc(Vector3 newPos, float yRot, int disguise)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3860255087u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref newPos);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref yRot, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, disguise);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3860255087u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				DisguiseID = disguise;
				((Component)this).transform.position = newPos;
				((Component)this).transform.rotation = Quaternion.Euler(0f, yRot, 0f);
				Music.SetActive(Plugin.PlayMusic && DisguiseID < 1);
				UpdateDisguise();
			}
		}
	}

	[ServerRpc]
	public void SpawnServerRpc(Vector3 newPos, float yRot, int disguise)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Invalid comparison between Unknown and I4
		//IL_0137: 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_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_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: 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
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__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(2003288437u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe(ref newPos);
			((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref yRot, default(ForPrimitives));
			BytePacker.WriteValueBitPacked(val2, disguise);
			((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2003288437u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			SpawnClientRpc(newPos, yRot, disguise);
		}
	}

	public void OnTouched(PlayerControllerB player)
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		if (!IsAttacking && !((Object)(object)player == (Object)null))
		{
			int num = ((DisguiseID > 0) ? 80 : 20);
			if (Random.Range(0, 100) > num)
			{
				StartAttack(!player.isInsideFactory);
			}
			else if (Random.Range(0, 100) < 10)
			{
				player.JumpToFearLevel(1f, true);
			}
			else
			{
				player.DamagePlayer(999, true, true, (CauseOfDeath)0, Random.Range(1, 3), false, default(Vector3));
			}
		}
	}

	public void StartAttack(bool outside)
	{
		Debug.Log((object)"[DTM] Starting attack");
		if (((NetworkBehaviour)this).IsOwner)
		{
			AttackClientRpc(outside);
		}
		else
		{
			AttackServerRpc(outside);
		}
	}

	[ClientRpc]
	public void AttackClientRpc(bool outside)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3888608358u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref outside, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3888608358u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			Debug.Log((object)"[DTM] Attempting attack on client");
			if (!IsAttacking && !HasAttacked)
			{
				AttackTime = Time.time;
				ScreenShakeTime = 0f;
				KillWindowStart = Random.Range(2.3f, 3.5f);
				DisguiseID = -1;
				Disguise.SetActive(false);
				MainModel.SetActive(true);
				Music.SetActive(false);
				((Component)VoiceA).gameObject.SetActive(true);
				base.isOutside = outside;
				SetTrigger(interactable: false);
				IsAttacking = true;
				base.creatureAnimator.SetTrigger("Touched");
			}
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void AttackServerRpc(bool outside)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2283008872u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref outside, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2283008872u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Debug.Log((object)"[DTM] Attempting attack from server");
				AttackClientRpc(outside);
			}
		}
	}

	public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
	{
		Debug.Log((object)("[DTM] Hit by enemy: " + (object)playerWhoHit));
		OnTouched(playerWhoHit);
	}

	public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null)
	{
		if (setToStunned)
		{
			OnTouched(setStunnedByPlayer);
		}
	}

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

	[RuntimeInitializeOnLoadMethod]
	internal static void InitializeRPCS_DTMEntityAI()
	{
		//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(3906254083u, new RpcReceiveHandler(__rpc_handler_3906254083));
		NetworkManager.__rpc_func_table.Add(877622320u, new RpcReceiveHandler(__rpc_handler_877622320));
		NetworkManager.__rpc_func_table.Add(3860255087u, new RpcReceiveHandler(__rpc_handler_3860255087));
		NetworkManager.__rpc_func_table.Add(2003288437u, new RpcReceiveHandler(__rpc_handler_2003288437));
		NetworkManager.__rpc_func_table.Add(3888608358u, new RpcReceiveHandler(__rpc_handler_3888608358));
		NetworkManager.__rpc_func_table.Add(2283008872u, new RpcReceiveHandler(__rpc_handler_2283008872));
	}

	private static void __rpc_handler_3906254083(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 clientId = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((DTMEntityAI)(object)target).ExplodePlayerClientRpc(clientId);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_877622320(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 clientId = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((DTMEntityAI)(object)target).ExplodePlayerServerRpc(clientId);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3860255087(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			Vector3 newPos = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref newPos);
			float yRot = default(float);
			((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref yRot, default(ForPrimitives));
			int disguise = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref disguise);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((DTMEntityAI)(object)target).SpawnClientRpc(newPos, yRot, disguise);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2003288437(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_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_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!");
			}
			return;
		}
		Vector3 newPos = default(Vector3);
		((FastBufferReader)(ref reader)).ReadValueSafe(ref newPos);
		float yRot = default(float);
		((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref yRot, default(ForPrimitives));
		int disguise = default(int);
		ByteUnpacker.ReadValueBitPacked(reader, ref disguise);
		target.__rpc_exec_stage = (__RpcExecStage)1;
		((DTMEntityAI)(object)target).SpawnServerRpc(newPos, yRot, disguise);
		target.__rpc_exec_stage = (__RpcExecStage)0;
	}

	private static void __rpc_handler_3888608358(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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool outside = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref outside, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((DTMEntityAI)(object)target).AttackClientRpc(outside);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2283008872(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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool outside = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref outside, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((DTMEntityAI)(object)target).AttackServerRpc(outside);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	protected internal override string __getTypeName()
	{
		return "DTMEntityAI";
	}
}
public class DTMHitBox : MonoBehaviour, IHittable, IShockableWithGun
{
	public DTMEntityAI mainScript;

	bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX)
	{
		((EnemyAI)mainScript).SetEnemyStunned(true, 1f, playerWhoHit);
		return true;
	}

	bool IShockableWithGun.CanBeShocked()
	{
		return mainScript.CanBeShocked();
	}

	Vector3 IShockableWithGun.GetShockablePosition()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)((EnemyAI)mainScript).eye != (Object)null)
		{
			return ((EnemyAI)mainScript).eye.position;
		}
		return ((Component)this).transform.position + Vector3.up * 1f;
	}

	float IShockableWithGun.GetDifficultyMultiplier()
	{
		return ((EnemyAI)mainScript).enemyType.stunGameDifficultyMultiplier;
	}

	void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
	{
		((EnemyAI)mainScript).SetEnemyStunned(true, 0.25f, shockedByPlayer);
		DTMEntityAI dTMEntityAI = mainScript;
		((EnemyAI)dTMEntityAI).stunnedIndefinitely = ((EnemyAI)dTMEntityAI).stunnedIndefinitely + 1;
	}

	Transform IShockableWithGun.GetShockableTransform()
	{
		return ((Component)this).transform;
	}

	NetworkObject IShockableWithGun.GetNetworkObject()
	{
		return ((NetworkBehaviour)mainScript).NetworkObject;
	}

	void IShockableWithGun.StopShockingWithGun()
	{
	}
}
[HarmonyPatch(typeof(MaskedPlayerEnemy))]
internal class MaskedEnemyPatch
{
	public const float InteractProximity = 1.5f;

	public const float DetectProximity = 10f;

	public const float StaringTimeMin = 1f;

	public const float StaringTimeMax = 4f;

	private static EnemyBehaviourState[] BehaviourStates;

	public const string BehaviourStateFound = "FoundDTM";

	public const string BehaviourStateStare = "StareDTM";

	public const string BehaviourStatePress = "PressDTM";

	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	private static void StartPatch(ref MaskedPlayerEnemy __instance)
	{
		//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_0022: 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_003f: Expected O, but got Unknown
		//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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_008f: Expected O, but got Unknown
		if (BehaviourStates == null)
		{
			BehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[3]
			{
				new EnemyBehaviourState
				{
					name = "FoundDTM",
					playOneShotVoice = ((Object)(object)Assets.AudioMasked1 != (Object)null),
					VoiceClip = Assets.AudioMasked1
				},
				new EnemyBehaviourState
				{
					name = "StareDTM",
					VoiceClip = null,
					playOneShotVoice = false
				},
				new EnemyBehaviourState
				{
					name = "PressDTM",
					playOneShotVoice = ((Object)(object)Assets.AudioMasked2 != (Object)null),
					VoiceClip = Assets.AudioMasked2
				}
			};
		}
		EnemyBehaviourState[] enemyBehaviourStates = ((EnemyAI)__instance).enemyBehaviourStates;
		int num = enemyBehaviourStates.Length;
		EnemyBehaviourState[] array = (EnemyBehaviourState[])(object)new EnemyBehaviourState[num + BehaviourStates.Length];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = ((i < num) ? enemyBehaviourStates[i] : BehaviourStates[i % num]);
		}
		((EnemyAI)__instance).enemyBehaviourStates = array;
	}

	[HarmonyPatch("DoAIInterval")]
	[HarmonyPostfix]
	private static void DoAIIntervalPatch(ref MaskedPlayerEnemy __instance)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0058: 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_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		if (DTMEntityAI.Count <= 0 || ((EnemyAI)__instance).currentBehaviourStateIndex != 1)
		{
			return;
		}
		Vector3 position = ((Component)__instance).transform.position;
		DTMEntityAI closest = DTMEntityAI.GetClosest(position);
		if ((Object)(object)closest == (Object)null || !closest.CanBeShocked() || (Object)(object)closest.MaskedEnemy != (Object)null)
		{
			return;
		}
		Vector3 position2 = ((Component)closest).transform.position;
		float num = Vector3.Distance(position, position2);
		PlayerControllerB targetPlayer = ((EnemyAI)__instance).targetPlayer;
		if ((Object)(object)targetPlayer != (Object)null && ((EnemyAI)__instance).movingTowardsTargetPlayer && num < 10f && !((EnemyAI)__instance).PathIsIntersectedByLineOfSight(position2, false, true))
		{
			((EnemyAI)__instance).path1 = new NavMeshPath();
			if (((EnemyAI)__instance).agent.CalculatePath(position2, ((EnemyAI)__instance).path1) && !(Vector3.Distance(((EnemyAI)__instance).path1.corners[((EnemyAI)__instance).path1.corners.Length - 1], RoundManager.Instance.GetNavMeshPosition(position2, RoundManager.Instance.navHit, 2.7f, -1)) > 1.55f) && ((EnemyAI)__instance).SetDestinationToPosition(position2, true))
			{
				__instance.StopLookingAtTransformServerRpc();
				((EnemyAI)__instance).SwitchToBehaviourState(Array.IndexOf(((EnemyAI)__instance).enemyBehaviourStates, BehaviourStates[0]));
				closest.MaskedEnemy = __instance;
				((EnemyAI)closest).targetPlayer = targetPlayer;
			}
		}
	}
}
[BepInPlugin("Kittenji.DontTouchMe", "Don't Touch Me", "1.2.1")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().AddNetworkPrefab(Assets.EnemyType.enemyPrefab);
			Debug.Log((object)"[DTM] Added network prefab");
		}
	}

	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		private static Random TerminalRandom = new Random();

		private static FieldInfo InteractTriggerField = AccessTools.Field(typeof(Terminal), "terminalTrigger");

		private static InteractTrigger m_Trigger;

		private static bool HandlingSpecialEvent;

		private static InteractTrigger GetTrigger(Terminal __instance)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if ((Object)(object)m_Trigger == (Object)null)
			{
				m_Trigger = (InteractTrigger)InteractTriggerField.GetValue(__instance);
			}
			return m_Trigger;
		}

		private static void PerformRandomTPOnPlayer(PlayerControllerB localPlayer, int index, bool redirected = false)
		{
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_00f7: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			if (localPlayer.isPlayerDead)
			{
				return;
			}
			bool flag;
			Vector3 val;
			switch (index)
			{
			default:
				return;
			case 0:
			case 1:
			{
				flag = index == 0;
				GameObject[] array = (flag ? RoundManager.Instance.insideAINodes : RoundManager.Instance.outsideAINodes);
				if (array.Length != 0)
				{
					val = array[Random.Range(0, array.Length)].transform.position;
					val = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(val, 10f, default(NavMeshHit));
					Debug.LogWarning((object)"Where am I anyway?");
					break;
				}
				return;
			}
			case 2:
			{
				Turret[] array2 = Object.FindObjectsOfType<Turret>(false);
				if (array2 == null || array2.Length == 0)
				{
					PerformRandomTPOnPlayer(localPlayer, redirected ? Random.Range(0, 2) : 3, redirected: true);
					return;
				}
				Turret val3 = array2[Random.Range(0, array2.Length)];
				if ((Object)(object)val3 == (Object)null)
				{
					return;
				}
				val = ((Component)val3).transform.position;
				flag = val.y < -80f;
				val = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(val, 2f, default(NavMeshHit));
				Debug.LogError((object)"Run Forest, RUN!!!");
				break;
			}
			case 3:
			{
				Landmine[] array3 = Object.FindObjectsOfType<Landmine>(false);
				if (array3 == null || array3.Length == 0)
				{
					PerformRandomTPOnPlayer(localPlayer, redirected ? Random.Range(0, 2) : 2, redirected: true);
					return;
				}
				Landmine val4 = array3[Random.Range(0, array3.Length)];
				if ((Object)(object)val4 == (Object)null)
				{
					return;
				}
				val = ((Component)val4).transform.position;
				flag = val.y < -80f;
				val = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(val, 2f, default(NavMeshHit));
				Debug.LogError((object)"WAIT, DON'T MOVE!!!... Or do... I'm a programmer, not a land mine inspector.");
				break;
			}
			case 4:
			{
				List<EnemyAI> spawnedEnemies = RoundManager.Instance.SpawnedEnemies;
				if (spawnedEnemies == null || spawnedEnemies.Count == 0)
				{
					PerformRandomTPOnPlayer(localPlayer, Random.Range(0, 2), redirected: true);
					return;
				}
				EnemyAI val2 = spawnedEnemies[Random.Range(0, spawnedEnemies.Count)];
				val = ((Component)val2).transform.position;
				flag = val.y < -80f;
				val = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(val, 8f, default(NavMeshHit));
				Debug.LogError((object)"OH NO!, that is horrible!!!............ anyway..");
				break;
			}
			case 5:
				val = ((Component)localPlayer).transform.position + Vector3.up * 100f;
				flag = false;
				Debug.LogError((object)"Fly like a bird... wait, why are you falling?");
				break;
			}
			if (!localPlayer.isPlayerDead)
			{
				localPlayer.DropAllHeldItems(true, false);
				localPlayer.isInElevator = false;
				localPlayer.isInHangarShipRoom = false;
				localPlayer.isInsideFactory = flag;
				localPlayer.averageVelocity = 0f;
				localPlayer.velocityLastFrame = Vector3.zero;
				localPlayer.TeleportPlayer(val, false, 0f, false, true);
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
		}

		private static IEnumerator SpecialEvent(Terminal __instance, int index)
		{
			HandlingSpecialEvent = true;
			PlayerControllerB localPlayer = GameNetworkManager.Instance.localPlayerController;
			InteractTrigger trigger = GetTrigger(__instance);
			if (!Object.op_Implicit((Object)(object)trigger))
			{
				HandlingSpecialEvent = false;
				yield break;
			}
			yield return (object)new WaitForSeconds(0.35f);
			switch (index)
			{
			case 1:
				__instance.QuitTerminal();
				if (Random.Range(0, 100) < 34)
				{
					while (trigger.currentCooldownValue > 0f)
					{
						yield return null;
					}
					localPlayer.DropAllHeldItems(true, false);
					Debug.LogError((object)"Haha, butter fingers!");
				}
				else
				{
					Debug.LogWarning((object)"GET OUT!");
				}
				break;
			case 2:
				__instance.QuitTerminal();
				while (trigger.currentCooldownValue > 0f)
				{
					yield return null;
				}
				if (!StartOfRound.Instance.inShipPhase)
				{
					index = RoundManager.Instance.GetRandomWeightedIndex(Terminal_Weights_TP, (Random)null);
					PerformRandomTPOnPlayer(localPlayer, index);
				}
				break;
			case 3:
			{
				__instance.QuitTerminal();
				while (trigger.currentCooldownValue > 0f)
				{
					yield return null;
				}
				for (int i = 0; i < localPlayer.ItemSlots.Length; i++)
				{
					GrabbableObject val = localPlayer.ItemSlots[i];
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.itemProperties) && val.itemProperties.requiresBattery)
					{
						val.insertedBattery = new Battery(true, 0f);
					}
				}
				Debug.LogError((object)"This mod is not sponsored by DURACELL");
				break;
			}
			case 4:
			{
				__instance.QuitTerminal();
				while (trigger.currentCooldownValue > 0f)
				{
					yield return null;
				}
				if (StartOfRound.Instance.inShipPhase)
				{
					break;
				}
				GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes;
				if (outsideAINodes.Length != 0)
				{
					int num = Random.Range(1, 5);
					for (int j = 0; j < num; j++)
					{
						RoundManager.Instance.SpawnEnemyOnServer(Vector3.zero, Random.Range(-180f, 180f), -3);
					}
					Debug.LogError((object)("OOPS! Have fun with " + ((num > 1) ? "those" : "that") + "..."));
				}
				break;
			}
			case 5:
				__instance.QuitTerminal();
				while (trigger.currentCooldownValue > 0f)
				{
					yield return null;
				}
				if (!StartOfRound.Instance.inShipPhase && localPlayer.health > 5)
				{
					localPlayer.DamagePlayer(localPlayer.health - 5, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					Debug.LogError((object)"Ouch, that must hurt.");
				}
				break;
			case 6:
				__instance.QuitTerminal();
				while (trigger.currentCooldownValue > 0f)
				{
					yield return null;
				}
				if (!StartOfRound.Instance.inShipPhase)
				{
					localPlayer.KillPlayer(Vector3.up, true, (CauseOfDeath)0, 0);
					Debug.LogError((object)"Curiosity killed the cat, in this case... you");
				}
				break;
			}
			HandlingSpecialEvent = false;
		}

		[HarmonyPatch("RunTerminalEvents")]
		[HarmonyPostfix]
		private static void RunTerminalEventsPatch(ref Terminal __instance, TerminalNode node)
		{
			if (node.terminalEvent == "dontReadMe")
			{
				Debug.Log((object)"Don't read me, please.");
				int randomWeightedIndex = RoundManager.Instance.GetRandomWeightedIndex(Terminal_Weights, TerminalRandom);
				if (!HandlingSpecialEvent)
				{
					((MonoBehaviour)__instance).StartCoroutine(SpecialEvent(__instance, randomWeightedIndex));
				}
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartPatch(ref Terminal __instance)
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			Debug.Log((object)"[DTM] Adding terminal entries");
			TerminalNode terminalNode = Assets.EnemyNode;
			TerminalKeyword val = __instance.terminalNodes.allKeywords.First((TerminalKeyword k) => k.word == "info");
			if (!__instance.enemyFiles.Any((TerminalNode x) => x.creatureName == terminalNode.creatureName))
			{
				TerminalKeyword keyword = Assets.EnemyKeyword;
				keyword.defaultVerb = val;
				List<TerminalKeyword> list = __instance.terminalNodes.allKeywords.ToList();
				if (!list.Any((TerminalKeyword x) => x.word == keyword.word))
				{
					list.Add(keyword);
					__instance.terminalNodes.allKeywords = list.ToArray();
				}
				List<CompatibleNoun> list2 = val.compatibleNouns.ToList();
				if (!list2.Any((CompatibleNoun x) => x.noun.word == keyword.word))
				{
					list2.Add(new CompatibleNoun
					{
						noun = keyword,
						result = terminalNode
					});
				}
				val.compatibleNouns = list2.ToArray();
				terminalNode.creatureFileID = __instance.enemyFiles.Count;
				__instance.enemyFiles.Add(terminalNode);
				Assets.EnemyType.enemyPrefab.GetComponentInChildren<ScanNodeProperties>().creatureScanID = terminalNode.creatureFileID;
				Debug.Log((object)"[DTM] Done adding entries.");
			}
		}
	}

	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(ref StartOfRound __instance)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			EnemyType enemyDef = Assets.EnemyType;
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if (val.Enemies.Count >= 2 && !val.Enemies.Any((SpawnableEnemyWithRarity e) => (Object)(object)e.enemyType == (Object)(object)enemyDef))
				{
					Debug.Log((object)("[DTM] Adding entity to level: " + val.PlanetName));
					val.Enemies.Add(new SpawnableEnemyWithRarity
					{
						enemyType = enemyDef,
						rarity = SpawnRarity
					});
				}
			}
		}
	}

	private const string modGUID = "Kittenji.DontTouchMe";

	private readonly Harmony harmony = new Harmony("Kittenji.DontTouchMe");

	public static bool PlayMusic = true;

	public static bool IncludeMonstersOnKill = true;

	public static bool IncludeUnkillableMonsters = true;

	public static bool DestroyMonstersOnKill = true;

	public static int SpawnRarity = 24;

	public static int SpawnOutsideChance = 2;

	public static bool ChangeLocationAfterTouch = true;

	public static bool DestroyEntityAfterTouch = true;

	public static int DisguiseAsItemChance = 40;

	private const int Terminal_Weight_None = 5;

	private const int Terminal_Weight_Quit = 50;

	private const int Terminal_Weight_TP = 15;

	private const int Terminal_Weight_Battery = 14;

	private const int Terminal_Weight_Punish = 14;

	private const int Terminal_Weight_Break = 3;

	private const int Terminal_Weight_Kill = 1;

	private const int Terminal_Weight_TP_Inside = 36;

	private const int Terminal_Weight_TP_Outside = 36;

	private const int Terminal_Weight_TP_Turret = 18;

	private const int Terminal_Weight_TP_Landmine = 6;

	private const int Terminal_Weight_TP_Monster = 3;

	private const int Terminal_Weight_TP_Sky = 1;

	private const int Terminal_Punish_Min = 1;

	private const int Terminal_Punish_Max = 5;

	private static readonly int[] Terminal_Weights = new int[7] { 5, 50, 15, 14, 14, 3, 1 };

	private static readonly int[] Terminal_Weights_TP = new int[6] { 36, 36, 18, 6, 3, 1 };

	private void Awake()
	{
		SpawnRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Spawn Rarity", 24, "Spawn rarity. Lower value means lower chance to spawn. (default = 24)").Value;
		SpawnOutsideChance = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Spawn Rarity Outside", 2, "Random chance percentage for this entity to spawn outside. (default = 2)").Value;
		DisguiseAsItemChance = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Disguise As Item Chance", 45, "Random chance percentage for this entity to disguise itself as an item. (default = 45)").Value;
		ChangeLocationAfterTouch = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Changes Location", true, "If 'true' the entity will change it's position to a random location after the animation. (default = true)").Value;
		DestroyEntityAfterTouch = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Destroy After Touch", false, "If 'true' the entity will hide for the rest of the round after touch. It will teleport to a different location. (default = false)").Value;
		IncludeMonstersOnKill = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Include Monsters On Kill", true, "If 'true' the entity will not pick favorites and will try killing monsters in the facility as well. (default = true)").Value;
		DestroyMonstersOnKill = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Destroy Monsters On Kill", true, "If 'true' monsters will directly despawn to prevent lag and other potential issues. (default = true)").Value;
		IncludeUnkillableMonsters = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Include Unkillable Monsters", true, "If 'true' the entity will also kill unkillable monsters too. (default = true)").Value;
		PlayMusic = ((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "Play Music", true, "If 'true' the entity will play ominous music (Lobotomy Corp OST - Neutral 01) that can be heard in the distance, getting more noticeable the closer you get to it. (default = true)").Value;
		SpawnRarity = Mathf.Min(100, Mathf.Max(1, SpawnRarity));
		SpawnOutsideChance = Mathf.Min(100, Mathf.Max(0, SpawnOutsideChance));
		DisguiseAsItemChance = Mathf.Min(100, Mathf.Max(0, DisguiseAsItemChance));
		((BaseUnityPlugin)this).Config.Save();
		Assets.Init();
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched!");
		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);
				}
			}
		}
	}
}

LethalEscape/LethalEscape.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LethalEscape")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalEscape")]
[assembly: AssemblyTitle("LethalEscape")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalEscape
{
	internal class LETimerFunctions : MonoBehaviour
	{
		public static float MinuteEscapeTimerPuffer;

		public static float MinuteEscapeTimerBracken;

		public static float MinuteEscapeTimerHoardingBug;

		public static LETimerFunctions instance;

		private void Awake()
		{
			instance = this;
		}

		private void Update()
		{
			MinuteEscapeTimerBracken += Time.deltaTime;
			MinuteEscapeTimerHoardingBug += Time.deltaTime;
			MinuteEscapeTimerPuffer += Time.deltaTime;
		}
	}
	[BepInPlugin("xCeezy.LethalEscape", "Lethal Escape", "0.8.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static GameObject ExtraValues;

		private const string modGUID = "xCeezy.LethalEscape";

		private const string modName = "Lethal Escape";

		private const string modVersion = "0.8.2";

		private Harmony _harmony = new Harmony("LethalEscape");

		public static ManualLogSource mls;

		public static float TimeStartTeleport;

		public static ConfigEntry<bool> CanThumperEscape;

		public static ConfigEntry<bool> CanBrackenEscape;

		public static ConfigEntry<bool> CanJesterEscape;

		public static ConfigEntry<bool> CanHoardingBugEscape;

		public static ConfigEntry<bool> CanCoilHeadEscape;

		public static ConfigEntry<bool> CanSpiderEscape;

		public static ConfigEntry<bool> CanNutCrackerEscape;

		public static ConfigEntry<bool> CanHygrodereEscape;

		public static ConfigEntry<bool> CanPufferEscape;

		public static float JesterSpeedWindup;

		public static ConfigEntry<float> BrackenChanceToEscapeEveryMinute;

		public static ConfigEntry<float> PufferChanceToEscapeEveryMinute;

		public static ConfigEntry<float> HoardingBugChanceToEscapeEveryMinute;

		public static ConfigEntry<float> HoardingBugChanceToNestNearShip;

		public static ConfigEntry<float> HoardingBugChanceToSpawnOutside;

		public static ConfigEntry<float> BrackenChanceToSpawnOutside;

		public static ConfigEntry<float> PufferChanceToSpawnOutside;

		public static ConfigEntry<float> JesterChanceToSpawnOutside;

		public static ConfigEntry<float> HygrodereChanceToSpawnOutside;

		public static ConfigEntry<float> NutCrackerChanceToSpawnOutside;

		public static ConfigEntry<float> ThumperChanceToSpawnOutside;

		public static ConfigEntry<float> SpiderChanceToSpawnOutside;

		public static ConfigEntry<float> JesterSpeedIncreasePerSecond;

		public static ConfigEntry<float> MaxJesterOutsideSpeed;

		public static ConfigEntry<float> BrackenEscapeDelay;

		public static ConfigEntry<float> ThumperEscapeDelay;

		public static ConfigEntry<int> SpiderMinWebsOutside;

		public static ConfigEntry<int> SpiderMaxWebsOutside;

		private void Awake()
		{
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Expected O, but got Unknown
			CanThumperEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "ThumperEscape", true, "Whether or not the Thumper can escape");
			CanBrackenEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "BrackenEscape", true, "Whether or not the Bracken can escape");
			CanJesterEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "JesterEscape", true, "Whether or not the Jester can escape");
			CanHoardingBugEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "HoardingBugEscape", true, "Whether or not the Hoarding Bugs can escape");
			CanCoilHeadEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "CoilHeadEscape", true, "Whether or not Coil Head can escape");
			CanSpiderEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "SpiderEscape", true, "Whether or not the Spider can escape");
			CanNutCrackerEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "NutCrackerEscape", true, "Whether or not the Nut Cracker can escape");
			CanHygrodereEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "HygrodereEscape", false, "Whether or not the Hygrodere/Slime can escape");
			CanPufferEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Can Monster Escape", "CanPufferEscape", true, "Whether or not the Puffer/Spore Lizard can escape");
			ThumperChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "ThumperSpawnOutsideChance", 5f, "The chance that the Thumper will spawn outside");
			BrackenChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "BrackenSpawnOutsideChance", 10f, "The chance that the Bracken will spawn outside");
			JesterChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "JesterSpawnOutsideChance", 0f, "The chance that the Jester will spawn outside");
			HoardingBugChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "HoardingBugSpawnOutsideChance", 30f, "The chance that the Hoarding Bug will spawn outside");
			SpiderChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "SpiderSpawnOutsideChance", 5f, "The chance that the Spider will spawn outside");
			NutCrackerChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "NutCrackerSpawnOutsideChance", 5f, "The chance that the NutCracker will spawn outside");
			HygrodereChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "HygrodereSpawnOutsideChance", 0f, "The chance that the Hygrodere will spawn outside");
			PufferChanceToSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Escape Settings", "PufferSpawnOutsideChance", 5f, "The chance that the Puffer will spawn outside");
			PufferChanceToEscapeEveryMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Puffer Escape Chance", 10f, "The chance that the Puffer/Spore Lizard will escape randomly every minute");
			BrackenChanceToEscapeEveryMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Bracken Escape Chance", 10f, "The chance that the Bracken will escape randomly every minute");
			HoardingBugChanceToEscapeEveryMinute = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "HoardingBug Escape Chance", 15f, "The chance that the Hoarding Bug will escape randomly every minute");
			HoardingBugChanceToNestNearShip = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "HoardingBugShipNestChance", 50f, "The chance that the Hoarding Bug will make their nest at/near the ship");
			BrackenEscapeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Bracken Escape Delay", 5f, "Time it takes for the Bracken to follow a player outside");
			ThumperEscapeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Thumper Escape Delay", -5f, "Time it takes for the Thumper to follow a player outside which is based on how long the player was seen minus this value (Might break when under -15 and will force thumper outside when it sees someone when above 0)");
			SpiderMaxWebsOutside = ((BaseUnityPlugin)this).Config.Bind<int>("Escape Settings", "Max Spider Webs Outside", 28, "The maximum amount of spider webs the game will allow the spider to create webs outside (Vanilla game is 7 or 9 if update 47)");
			SpiderMinWebsOutside = ((BaseUnityPlugin)this).Config.Bind<int>("Escape Settings", "Min Spider Webs Outside", 20, "The minimum amount of spider webs the game will allow the spider to create webs outside (Vanilla game is 4 or 6 if update 47)");
			JesterSpeedIncreasePerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Jester Speed Increase", 1.35f, "How much speed the jester gets per second");
			MaxJesterOutsideSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Escape Settings", "Jester Outside Speed", 10f, "The max speed the Jester moves while outside (5 is the speed its at while in the box and 18 is jesters max speed inside the facility)");
			if ((Object)(object)ExtraValues == (Object)null)
			{
				ExtraValues = new GameObject();
				Object.DontDestroyOnLoad((Object)(object)ExtraValues);
				((Object)ExtraValues).hideFlags = (HideFlags)61;
				ExtraValues.AddComponent<LETimerFunctions>();
			}
			mls = Logger.CreateLogSource("GameMaster");
			mls.LogInfo((object)"Loaded xCeezy.LethalEscape. Patching.");
			_harmony.PatchAll(typeof(Plugin));
		}

		[HarmonyPatch(typeof(CrawlerAI), "Update")]
		[HarmonyPrefix]
		private static void CrawlerLEPrefixAI(CrawlerAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanThumperEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex != 0 && __instance.noticePlayerTimer < ThumperEscapeDelay.Value && (Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(CrawlerAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void ThumperAILEOutsideAttack(CrawlerAI __instance, ref Collider other)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !((double)__instance.timeSinceHittingPlayer <= 0.65) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f))
				{
					__instance.timeSinceHittingPlayer = 0f;
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
					component.DamagePlayer(40, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(40, Vector3.zero, -1);
					((EnemyAI)__instance).agent.speed = 0f;
					__instance.HitPlayerServerRpc((int)component.playerClientId);
					component.JumpToFearLevel(1f, true);
				}
			}
		}

		[HarmonyPatch(typeof(CrawlerAI), "Start")]
		[HarmonyPostfix]
		private static void CrawlerAILEPostfixStart(CrawlerAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ThumperChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= ThumperChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(JesterAI), "Update")]
		[HarmonyPrefix]
		private static void JesterLEPrefixAI(JesterAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanJesterEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex == 2 && (Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					JesterSpeedWindup = 0f;
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(JesterAI), "Update")]
		[HarmonyPostfix]
		private static void JesterLEPostfixAI(JesterAI __instance)
		{
			if (!CanJesterEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost || !((EnemyAI)__instance).isOutside)
			{
				return;
			}
			if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
			bool flag = false;
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				if (StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled && !StartOfRound.Instance.allPlayerScripts[i].isInsideFactory)
				{
					flag = true;
				}
			}
			if (flag)
			{
				((EnemyAI)__instance).SwitchToBehaviourState(2);
				((EnemyAI)__instance).agent.stoppingDistance = 0f;
			}
			JesterSpeedWindup = Mathf.Clamp(JesterSpeedWindup + Time.deltaTime * JesterSpeedIncreasePerSecond.Value, 0f, MaxJesterOutsideSpeed.Value);
			((EnemyAI)__instance).agent.speed = JesterSpeedWindup;
		}

		[HarmonyPatch(typeof(JesterAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void JesterAILEOutsideAttack(JesterAI __instance, ref Collider other)
		{
			if (!((EnemyAI)__instance).isEnemyDead && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ((EnemyAI)__instance).isOutside)
			{
				if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
				{
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
				}
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<PlayerControllerB>()) && ((EnemyAI)__instance).currentBehaviourStateIndex == 2)
				{
					__instance.KillPlayerServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(JesterAI), "Start")]
		[HarmonyPostfix]
		private static void JesterAILEPostfixStart(JesterAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && JesterChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= JesterChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "Update")]
		[HarmonyPrefix]
		private static void FlowermanAILEPrefixAI(FlowermanAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanBrackenEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory && (((EnemyAI)__instance).currentBehaviourStateIndex == 1 || __instance.evadeStealthTimer > 0f) && Time.time - TimeStartTeleport >= BrackenEscapeDelay.Value + 5f)
				{
					TimeStartTeleport = Time.time;
				}
				if (Time.time - TimeStartTeleport > BrackenEscapeDelay.Value && Time.time - TimeStartTeleport < BrackenEscapeDelay.Value + 5f)
				{
					SendEnemyOutside((EnemyAI)(object)__instance);
				}
				else if (LETimerFunctions.MinuteEscapeTimerBracken >= 60f && (Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null)
				{
					LETimerFunctions.MinuteEscapeTimerBracken = 0f;
					if (BrackenChanceToEscapeEveryMinute.Value != 0f && (float)Random.Range(1, 100) <= BrackenChanceToEscapeEveryMinute.Value)
					{
						SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
					}
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "Update")]
		[HarmonyPostfix]
		private static void FlowermanAILEPostfixAI(FlowermanAI __instance)
		{
			if (!((EnemyAI)__instance).isEnemyDead && CanBrackenEscape.Value && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void FlowerManAILEOutsideAttack(FlowermanAI __instance, ref Collider other, bool ___startingKillAnimationLocalClient)
		{
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !__instance.inKillAnimation && !___startingKillAnimationLocalClient)
				{
					__instance.KillPlayerAnimationServerRpc((int)component.playerClientId);
					___startingKillAnimationLocalClient = true;
				}
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "Start")]
		[HarmonyPostfix]
		private static void FlowermanAILEPostfixStart(FlowermanAI __instance)
		{
			TimeStartTeleport = 0f;
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && BrackenChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= BrackenChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Update")]
		[HarmonyPrefix]
		private static void HoardingBugAILEPrefixAI(HoarderBugAI __instance)
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			if (((EnemyAI)__instance).isEnemyDead || !CanHoardingBugEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory && __instance.searchForPlayer.inProgress)
				{
					SendEnemyOutside((EnemyAI)(object)__instance);
				}
				else
				{
					if (!(LETimerFunctions.MinuteEscapeTimerHoardingBug >= 60f) || !((Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null))
					{
						return;
					}
					LETimerFunctions.MinuteEscapeTimerHoardingBug = 0f;
					if ((float)Random.Range(1, 100) <= HoardingBugChanceToEscapeEveryMinute.Value / (float)Object.FindObjectsOfType(typeof(HoarderBugAI)).Length)
					{
						SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
						if (HoardingBugChanceToNestNearShip.Value != 0f && (float)Random.Range(1, 100) <= HoardingBugChanceToNestNearShip.Value)
						{
							StartOfRound val = (StartOfRound)Object.FindObjectOfType(typeof(StartOfRound));
							Transform val2 = ((EnemyAI)__instance).ChooseClosestNodeToPosition(val.elevatorTransform.position, false, 0);
							__instance.nestPosition = val2.position;
						}
					}
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void HoardingBugAILEOutsideAttack(HoarderBugAI __instance, ref Collider other)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !((double)__instance.timeSinceHittingPlayer <= 0.5) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f) && __instance.inChase)
				{
					__instance.timeSinceHittingPlayer = 0f;
					component.DamagePlayer(30, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(30, Vector3.zero, -1);
					__instance.HitPlayerServerRpc();
				}
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Start")]
		[HarmonyPostfix]
		private static void HoardingBugAILEPostfixStart(HoarderBugAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && HoardingBugChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= HoardingBugChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(SpringManAI), "Update")]
		[HarmonyPrefix]
		private static void CoilHeadAILEPrefixAI(SpringManAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanCoilHeadEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(SpringManAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void CoilHeadAILEOutsideAttack(SpringManAI __instance, ref Collider other)
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !__instance.stoppingMovement && ((EnemyAI)__instance).currentBehaviourStateIndex == 1 && !(__instance.timeSinceHittingPlayer >= 0f) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f))
				{
					__instance.timeSinceHittingPlayer = 0.2f;
					component.DamagePlayer(90, true, true, (CauseOfDeath)6, 2, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(90, Vector3.zero, -1);
					component.JumpToFearLevel(1f, true);
				}
			}
		}

		[HarmonyPatch(typeof(SandSpiderAI), "Update")]
		[HarmonyPrefix]
		private static void SpiderAILEPrefixAI(SandSpiderAI __instance)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (((EnemyAI)__instance).isEnemyDead || !CanSpiderEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
					__instance.meshContainerPosition = ((EnemyAI)__instance).serverPosition;
					__instance.meshContainerTarget = ((EnemyAI)__instance).serverPosition;
					__instance.maxWebTrapsToPlace += Random.Range(SpiderMinWebsOutside.Value, SpiderMaxWebsOutside.Value);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(SandSpiderAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void SpiderAILEOutsideAttack(SandSpiderAI __instance, ref Collider other)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !__instance.onWall && !(__instance.timeSinceHittingPlayer <= 1f) && !(((EnemyAI)__instance).stunNormalizedTimer > 0f))
				{
					__instance.timeSinceHittingPlayer = 0f;
					component.DamagePlayer(90, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(90, Vector3.zero, -1);
					__instance.HitPlayerServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(SandSpiderAI), "Start")]
		[HarmonyPostfix]
		private static void SpiderAILEPostfixStart(SandSpiderAI __instance)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && SpiderChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= SpiderChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
				__instance.meshContainerPosition = ((EnemyAI)__instance).serverPosition;
				__instance.meshContainerTarget = ((EnemyAI)__instance).serverPosition;
				__instance.maxWebTrapsToPlace = Random.Range(SpiderMinWebsOutside.Value, SpiderMaxWebsOutside.Value);
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "Update")]
		[HarmonyPrefix]
		private static void NutCrackerAILEPrefixAI(NutcrackerEnemyAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanNutCrackerEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance);
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void NutCrackerAILEOutsideAttack(NutcrackerEnemyAI __instance, ref Collider other)
		{
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(((EnemyAI)__instance).stunNormalizedTimer >= 0f) && !(__instance.timeSinceHittingPlayer < 1f))
				{
					__instance.timeSinceHittingPlayer = 0f;
					__instance.LegKickPlayerServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "Start")]
		[HarmonyPostfix]
		private static void NutCrackerAILEPostfixStart(NutcrackerEnemyAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && NutCrackerChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= NutCrackerChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(BlobAI), "Update")]
		[HarmonyPrefix]
		private static void BlobAILEPrefixAI(BlobAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanHygrodereEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
					__instance.centerPoint = ((Component)__instance).transform;
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(BlobAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void BlobAILEOutsideAttack(BlobAI __instance, ref Collider other)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			if (((EnemyAI)__instance).isEnemyDead || !((EnemyAI)__instance).isOutside || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(__instance.timeSinceHittingLocalPlayer < 0.25f) && (!(__instance.tamedTimer > 0f) || !(__instance.angeredTimer < 0f)))
			{
				__instance.timeSinceHittingLocalPlayer = 0f;
				component.DamagePlayerFromOtherClientServerRpc(35, Vector3.zero, -1);
				component.DamagePlayer(35, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				if (component.isPlayerDead)
				{
					__instance.SlimeKillPlayerEffectServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(BlobAI), "Start")]
		[HarmonyPostfix]
		private static void HygrodereAILEPostfixStart(BlobAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && HygrodereChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= HygrodereChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
				__instance.centerPoint = ((Component)__instance).transform;
			}
		}

		[HarmonyPatch(typeof(PufferAI), "Update")]
		[HarmonyPrefix]
		private static void PufferAILEPrefixAI(PufferAI __instance)
		{
			if (((EnemyAI)__instance).isEnemyDead || !CanPufferEscape.Value || !((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				return;
			}
			if (!((EnemyAI)__instance).isOutside)
			{
				if ((Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && !((EnemyAI)__instance).targetPlayer.isInsideFactory)
				{
					SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
				}
				else if (LETimerFunctions.MinuteEscapeTimerPuffer >= 60f && (Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null)
				{
					LETimerFunctions.MinuteEscapeTimerPuffer = 0f;
					if (PufferChanceToEscapeEveryMinute.Value != 0f && (float)Random.Range(1, 100) <= PufferChanceToEscapeEveryMinute.Value)
					{
						SendEnemyOutside((EnemyAI)(object)__instance, SpawnOnDoor: false);
					}
				}
			}
			else if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(PufferAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void PufferAILEOutsideAttack(PufferAI __instance, ref Collider other)
		{
			//IL_009f: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (!((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).isOutside && ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && !(__instance.timeSinceHittingPlayer <= 1f))
				{
					__instance.timeSinceHittingPlayer = 0f;
					component.DamagePlayer(20, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
					component.DamagePlayerFromOtherClientServerRpc(20, Vector3.zero, -1);
					__instance.BitePlayerServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(PufferAI), "Start")]
		[HarmonyPostfix]
		private static void PufferAILEPostfixStart(PufferAI __instance)
		{
			if (((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost && PufferChanceToSpawnOutside.Value != 0f && (float)Random.Range(1, 100) <= PufferChanceToSpawnOutside.Value)
			{
				SendEnemyOutside((EnemyAI)(object)__instance);
			}
		}

		public static void SendEnemyInside(EnemyAI __instance)
		{
			//IL_0069: 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_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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			__instance.isOutside = false;
			__instance.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(false);
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].entranceId == 0 && !array[i].isEntranceToBuilding)
				{
					__instance.serverPosition = array[i].entrancePoint.position;
					break;
				}
			}
			Transform val = __instance.ChooseClosestNodeToPosition(__instance.serverPosition, false, 0);
			if (Vector3.Magnitude(val.position - __instance.serverPosition) > 10f)
			{
				__instance.serverPosition = val.position;
				((Component)__instance).transform.position = __instance.serverPosition;
			}
			((Component)__instance).transform.position = __instance.serverPosition;
			__instance.agent.Warp(__instance.serverPosition);
			__instance.SyncPositionToClients();
		}

		public static void SendEnemyOutside(EnemyAI __instance, bool SpawnOnDoor = true)
		{
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			//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_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			__instance.isOutside = true;
			__instance.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(false);
			float num = 999f;
			for (int i = 0; i < array.Length; i++)
			{
				if (!array[i].isEntranceToBuilding)
				{
					continue;
				}
				for (int j = 0; j < StartOfRound.Instance.connectedPlayersAmount + 1; j++)
				{
					if (!StartOfRound.Instance.allPlayerScripts[j].isInsideFactory & (Vector3.Magnitude(((Component)StartOfRound.Instance.allPlayerScripts[j]).transform.position - array[i].entrancePoint.position) < num))
					{
						num = Vector3.Magnitude(((Component)StartOfRound.Instance.allPlayerScripts[j]).transform.position - array[i].entrancePoint.position);
						__instance.serverPosition = array[i].entrancePoint.position;
					}
				}
			}
			if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				__instance.ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
			Transform val = __instance.ChooseClosestNodeToPosition(__instance.serverPosition, false, 0);
			if (Vector3.Magnitude(val.position - __instance.serverPosition) > 10f || !SpawnOnDoor)
			{
				__instance.serverPosition = val.position;
			}
			((Component)__instance).transform.position = __instance.serverPosition;
			__instance.agent.Warp(__instance.serverPosition);
			__instance.SyncPositionToClients();
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				__instance.EnableEnemyMesh(!StartOfRound.Instance.hangarDoorsClosed || !GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom, false);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

LethalPresents/LethalPresents.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On;
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("LethalPresents")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("LethalPresents mod")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("LethalPresents")]
[assembly: AssemblyTitle("LethalPresents")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalPresents
{
	[BepInPlugin("LethalPresents", "LethalPresents", "1.0.4")]
	public class LethalPresentsPlugin : BaseUnityPlugin
	{
		public static ManualLogSource mls;

		private static int spawnChance = 5;

		private static string[] disabledEnemies = new string[0];

		private static bool IsAllowlist = false;

		private static bool ShouldSpawnMines = false;

		private static bool ShouldSpawnTurrets = false;

		private static bool ShouldSpawnBees = false;

		private static bool isHost => ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;

		private static SelectableLevel currentLevel => RoundManager.Instance.currentLevel;

		internal static T GetPrivateField<T>(object instance, string fieldName)
		{
			FieldInfo field = instance.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
			return (T)field.GetValue(instance);
		}

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			mls = Logger.CreateLogSource("LethalPresents");
			mls.LogInfo((object)"Plugin LethalPresents is loaded!");
			loadConfig();
			RoundManager.AdvanceHourAndSpawnNewBatchOfEnemies += new hook_AdvanceHourAndSpawnNewBatchOfEnemies(updateCurrentLevelInfo);
			GiftBoxItem.OpenGiftBoxServerRpc += new hook_OpenGiftBoxServerRpc(spawnRandomEntity);
		}

		private void updateCurrentLevelInfo(orig_AdvanceHourAndSpawnNewBatchOfEnemies orig, RoundManager self)
		{
			orig.Invoke(self);
			mls.LogInfo((object)"List of spawnable enemies (inside):");
			currentLevel.Enemies.ForEach(delegate(SpawnableEnemyWithRarity e)
			{
				mls.LogInfo((object)((Object)e.enemyType).name);
			});
			mls.LogInfo((object)"List of spawnable enemies (outside):");
			currentLevel.OutsideEnemies.ForEach(delegate(SpawnableEnemyWithRarity e)
			{
				mls.LogInfo((object)((Object)e.enemyType).name);
			});
		}

		private void loadConfig()
		{
			spawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SpawnChance", 5, "Chance of spawning an enemy when opening a present [0-100]").Value;
			disabledEnemies = ((BaseUnityPlugin)this).Config.Bind<string>("General", "EnemyBlocklist", "", "Enemy blocklist separated by , and without whitespaces").Value.Split(",");
			IsAllowlist = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IsAllowlist", false, "Turns blocklist into allowlist, blocklist must contain at least one inside and one outside enemy, use at your own risk").Value;
			ShouldSpawnMines = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShouldSpawnMines", true, "Add mines to the spawn pool").Value;
			ShouldSpawnTurrets = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShouldSpawnTurrets", true, "Add turrets to the spawn pool").Value;
			if (IsAllowlist)
			{
				mls.LogInfo((object)"Only following enemies can spawn from the gift:");
			}
			else
			{
				mls.LogInfo((object)"Following enemies wont be spawned from the gift:");
			}
			string[] array = disabledEnemies;
			foreach (string text in array)
			{
				mls.LogInfo((object)text);
			}
		}

		private void spawnRandomEntity(orig_OpenGiftBoxServerRpc orig, GiftBoxItem self)
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)self).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				orig.Invoke(self);
				return;
			}
			int privateField = GetPrivateField<int>(self, "__rpc_exec_stage");
			mls.LogInfo((object)("IsServer:" + networkManager.IsServer + " IsHost:" + networkManager.IsHost + " __rpc_exec_stage:" + privateField));
			if (privateField != 1 || !isHost)
			{
				orig.Invoke(self);
				return;
			}
			int num = Random.Range(1, 100);
			mls.LogInfo((object)("Player's fortune:" + num));
			if (num >= spawnChance)
			{
				orig.Invoke(self);
				return;
			}
			chooseAndSpawnEnemy(((GrabbableObject)self).isInFactory, ((Component)self).transform.position, ((Component)self.previousPlayerHeldBy).transform.position);
			orig.Invoke(self);
		}

		private static void chooseAndSpawnEnemy(bool inside, Vector3 pos, Vector3 player_pos)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource obj = mls;
			Vector3 val = player_pos;
			obj.LogInfo((object)("Player pos " + ((object)(Vector3)(ref val)).ToString()));
			List<SpawnableEnemyWithRarity> list = currentLevel.Enemies.Where((SpawnableEnemyWithRarity e) => disabledEnemies.Contains(((Object)e.enemyType).name) ? IsAllowlist : (!IsAllowlist)).ToList();
			List<SpawnableEnemyWithRarity> list2 = currentLevel.OutsideEnemies.Where((SpawnableEnemyWithRarity e) => disabledEnemies.Contains(((Object)e.enemyType).name) ? IsAllowlist : (!IsAllowlist)).ToList();
			int num = Random.Range(1, 2 + (list2.Count + list.Count) / 2);
			if (num == 2 && !ShouldSpawnMines)
			{
				num = 1;
			}
			if (num == 1 && !ShouldSpawnTurrets)
			{
				num = 2;
			}
			if (num == 2 && !ShouldSpawnMines)
			{
				num = 3;
			}
			switch (num)
			{
			case 1:
			{
				SpawnableMapObject[] spawnableMapObjects2 = currentLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val4 in spawnableMapObjects2)
				{
					if (!((Object)(object)val4.prefabToSpawn.GetComponentInChildren<Turret>() == (Object)null))
					{
						pos -= Vector3.up * 1.8f;
						GameObject val5 = Object.Instantiate<GameObject>(val4.prefabToSpawn, pos, Quaternion.identity);
						val5.transform.position = pos;
						Transform transform = val5.transform;
						val = player_pos - pos;
						transform.forward = ((Vector3)(ref val)).normalized;
						val5.GetComponent<NetworkObject>().Spawn(true);
						ManualLogSource obj3 = mls;
						val = pos;
						obj3.LogInfo((object)("Tried spawning a turret at " + ((object)(Vector3)(ref val)).ToString()));
						break;
					}
				}
				return;
			}
			case 2:
			{
				SpawnableMapObject[] spawnableMapObjects = currentLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val2 in spawnableMapObjects)
				{
					if (!((Object)(object)val2.prefabToSpawn.GetComponentInChildren<Landmine>() == (Object)null))
					{
						pos -= Vector3.up * 1.8f;
						GameObject val3 = Object.Instantiate<GameObject>(val2.prefabToSpawn, pos, Quaternion.identity);
						val3.transform.position = pos;
						val3.transform.forward = new Vector3(1f, 0f, 0f);
						val3.GetComponent<NetworkObject>().Spawn(true);
						ManualLogSource obj2 = mls;
						val = pos;
						obj2.LogInfo((object)("Tried spawning a mine at " + ((object)(Vector3)(ref val)).ToString()));
						break;
					}
				}
				return;
			}
			}
			SpawnableEnemyWithRarity val6;
			if (inside)
			{
				if (list.Count < 1)
				{
					mls.LogInfo((object)"Cant spawn enemy - no other enemies present to copy from");
					return;
				}
				val6 = list[Random.Range(0, list.Count - 1)];
			}
			else
			{
				if (list2.Count < 1)
				{
					mls.LogInfo((object)"Cant spawn enemy - no other enemies present to copy from");
					return;
				}
				val6 = list2[Random.Range(0, list2.Count - 1)];
			}
			pos += Vector3.up * 0.25f;
			ManualLogSource obj4 = mls;
			string enemyName = val6.enemyType.enemyName;
			val = pos;
			obj4.LogInfo((object)("Spawning " + enemyName + " at " + ((object)(Vector3)(ref val)).ToString()));
			SpawnEnemy(val6, pos, 0f);
		}

		private static void SpawnEnemy(SpawnableEnemyWithRarity enemy, Vector3 pos, float rot)
		{
			//IL_0006: 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)
			RoundManager.Instance.SpawnEnemyGameObject(pos, rot, -1, enemy.enemyType);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalPresents";

		public const string PLUGIN_NAME = "LethalPresents";

		public const string PLUGIN_VERSION = "1.0.4";
	}
}

LockDoors/LockDoorsMod.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
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(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("LockDoorsMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LockDoorsMod")]
[assembly: AssemblyTitle("LockDoorsMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LockDoorsMod
{
	[HarmonyPatch(typeof(HUDManager))]
	public class Broadcaster
	{
		public static Action<string, string> GetString = delegate
		{
		};

		public static void BroadcastString(string data, string signature)
		{
			HUDManager.Instance.AddTextToChatOnServer("<size=0>ENZDATA/" + data + "/" + signature + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1);
		}

		[HarmonyPatch(typeof(HUDManager), "AddChatMessage")]
		[HarmonyPostfix]
		internal static void AddChatMessagePatch(string chatMessage, string nameOfUserWhoTyped = "")
		{
			string[] array = chatMessage.Split(new char[1] { '/' });
			if (chatMessage.StartsWith("<size=0>ENZDATA") && !(GameNetworkManager.Instance.localPlayerController.playerClientId.ToString() == array[3]))
			{
				GetString(array[1], array[2]);
			}
		}
	}
	public static class LDMPluginInfo
	{
		public const string PLUGIN_GUID = "ENZDS.LockDoorsMod";

		public const string PLUGIN_NAME = "Lock Doors Mod";

		public const string PLUGIN_VERSION = "1.1.0";
	}
	public static class LDMLogger
	{
		public static readonly ManualLogSource logger = Logger.CreateLogSource("LockDoorsMod");
	}
	[JsonObject]
	internal class LockDoorData
	{
		[JsonProperty]
		public ulong networkObjectId { get; set; }

		[JsonProperty]
		public ulong clientId { get; set; }
	}
	[HarmonyPatch(typeof(DoorLock))]
	public class DoorLockPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static void Awake()
		{
			Broadcaster.GetString = (Action<string, string>)Delegate.Combine(Broadcaster.GetString, new Action<string, string>(CloseDoorReceived));
		}

		private static void CloseDoorReceived(string data, string signature)
		{
			LockDoorData lockDoorData = JsonConvert.DeserializeObject<LockDoorData>(data);
			LDMLogger.logger.LogInfo((object)("[BROADCAST_RECEIVE] Got message \n data: " + data + " \n signature: " + signature));
			if (signature == "lock_door")
			{
				GameObject val = FindObjectById(Convert.ToUInt64(lockDoorData.networkObjectId));
				DoorLock componentInChildren = val.GetComponentInChildren<DoorLock>();
				LDMLogger.logger.LogInfo((object)$"[BROADCAST_RECEIVE] found object with id {lockDoorData.networkObjectId}: {val} \n {componentInChildren} \n doorLockNID: {((NetworkBehaviour)componentInChildren).NetworkObjectId}");
				componentInChildren.LockDoor(30f);
			}
		}

		[HarmonyPatch("LockDoor")]
		[HarmonyPrefix]
		private static bool LockDoorPatch(ref DoorLock __instance, ref bool ___isDoorOpened, ref bool ___isLocked, ref AudioSource ___doorLockSFX, ref AudioClip ___unlockSFX)
		{
			if (___isDoorOpened | ___isLocked)
			{
				LDMLogger.logger.LogInfo((object)"The door is opened or locked. Can't lock it");
				return false;
			}
			AudioSource val = ___doorLockSFX;
			val.PlayOneShot(___unlockSFX);
			return true;
		}

		public static void LockDoorPatchSyncWithServer(ulong networkObjectId)
		{
			LockDoorData lockDoorData = new LockDoorData
			{
				networkObjectId = networkObjectId,
				clientId = GameNetworkManager.Instance.localPlayerController.playerClientId
			};
			LDMLogger.logger.LogInfo((object)"[BROADCAST] Locking the door");
			Broadcaster.BroadcastString(JsonConvert.SerializeObject((object)lockDoorData, (Formatting)0), "lock_door");
		}

		private static GameObject FindObjectById(ulong networkId)
		{
			return (networkId == 0L) ? null : ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId]).gameObject;
		}
	}
	[HarmonyPatch(typeof(KeyItem))]
	internal class KeyItemPatch
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPrefix]
		private static bool ItemActivatePatch(ref KeyItem __instance, bool used, bool buttonDown = true)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy;
			bool isOwner = ((NetworkBehaviour)__instance).IsOwner;
			RaycastHit val = default(RaycastHit);
			if ((Object)(object)playerHeldBy == (Object)null || !isOwner || !Physics.Raycast(new Ray(((Component)playerHeldBy.gameplayCamera).transform.position, ((Component)playerHeldBy.gameplayCamera).transform.forward), ref val, 3f, 2816))
			{
				return false;
			}
			DoorLock component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<DoorLock>();
			if ((Object)(object)component == (Object)null || component.isPickingLock)
			{
				return false;
			}
			if ((bool)typeof(DoorLock).GetField("isDoorOpened", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(component))
			{
				LDMLogger.logger.LogInfo((object)"The door is opened");
				return false;
			}
			if (!component.isLocked)
			{
				component.LockDoor(30f);
				DoorLockPatch.LockDoorPatchSyncWithServer(((NetworkBehaviour)component).NetworkObjectId);
			}
			else
			{
				component.UnlockDoorSyncWithServer();
			}
			((GrabbableObject)__instance).playerHeldBy.DespawnHeldObject();
			return false;
		}
	}
	[BepInPlugin("ENZDS.LockDoorsMod", "Lock Doors Mod", "1.1.0")]
	public class LockingKeyModBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("ENZDS.LockDoorsMod");

		private static LockingKeyModBase instance;

		private void Awake()
		{
			if (instance == null)
			{
				instance = this;
			}
			LDMLogger.logger.LogInfo((object)"Lock Doors 1.1.0 :)");
			harmony.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LockDoorsMod";

		public const string PLUGIN_NAME = "LockDoorsMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

Mimics/Mimics.dll

Decompiled 8 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyMimics.Properties;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Mimics")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod that adds mimics to Lethal Company")]
[assembly: AssemblyFileVersion("2.3.2.0")]
[assembly: AssemblyInformationalVersion("2.3.2")]
[assembly: AssemblyProduct("Mimics")]
[assembly: AssemblyTitle("Mimics")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.2.0")]
[module: UnverifiableCode]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
	}
}
namespace LethalCompanyMimics.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

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

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

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

		internal Resources()
		{
		}
	}
}
namespace Mimics
{
	[BepInPlugin("x753.Mimics", "Mimics", "2.3.2")]
	public class Mimics : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GameNetworkManager))]
		internal class GameNetworkManagerPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPatch()
			{
				((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().AddNetworkPrefab(MimicNetworkerPrefab);
			}
		}

		[HarmonyPatch(typeof(StartOfRound))]
		internal class StartOfRoundPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPatch(ref StartOfRound __instance)
			{
				if (((NetworkBehaviour)__instance).IsServer && (Object)(object)MimicNetworker.Instance == (Object)null)
				{
					GameObject val = Object.Instantiate<GameObject>(MimicNetworkerPrefab);
					val.GetComponent<NetworkObject>().Spawn(true);
					MimicNetworker.SpawnWeight0.Value = SpawnRates[0];
					MimicNetworker.SpawnWeight1.Value = SpawnRates[1];
					MimicNetworker.SpawnWeight2.Value = SpawnRates[2];
					MimicNetworker.SpawnWeight3.Value = SpawnRates[3];
					MimicNetworker.SpawnWeight4.Value = SpawnRates[4];
					MimicNetworker.SpawnWeightMax.Value = SpawnRates[5];
					MimicNetworker.SpawnRateDynamic.Value = DynamicSpawnRate;
				}
			}
		}

		[HarmonyPatch(typeof(Terminal))]
		internal class TerminalPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPatch(ref StartOfRound __instance)
			{
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: 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_00b8: Expected O, but got Unknown
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Expected O, but got Unknown
				Terminal val = Object.FindObjectOfType<Terminal>();
				if (!Object.op_Implicit((Object)(object)val.enemyFiles.Find((TerminalNode node) => node.creatureName == "Mimics")))
				{
					MimicCreatureID = val.enemyFiles.Count;
					MimicFile.creatureFileID = MimicCreatureID;
					val.enemyFiles.Add(MimicFile);
					TerminalKeyword val2 = val.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info");
					TerminalKeyword val3 = new TerminalKeyword
					{
						word = "mimics",
						isVerb = false,
						defaultVerb = val2
					};
					List<CompatibleNoun> list = val2.compatibleNouns.ToList();
					list.Add(new CompatibleNoun
					{
						noun = val3,
						result = MimicFile
					});
					val2.compatibleNouns = list.ToArray();
					List<TerminalKeyword> list2 = val.terminalNodes.allKeywords.ToList();
					list2.Add(val3);
					val.terminalNodes.allKeywords = list2.ToArray();
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager))]
		internal class RoundManagerPatch
		{
			[HarmonyPatch("SetExitIDs")]
			[HarmonyPostfix]
			private static void SetExitIDsPatch(ref RoundManager __instance, Vector3 mainEntrancePosition)
			{
				//IL_0536: Unknown result type (might be due to invalid IL or missing references)
				//IL_0547: Unknown result type (might be due to invalid IL or missing references)
				//IL_054c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0551: Unknown result type (might be due to invalid IL or missing references)
				//IL_0556: Unknown result type (might be due to invalid IL or missing references)
				//IL_0235: Unknown result type (might be due to invalid IL or missing references)
				//IL_0241: Unknown result type (might be due to invalid IL or missing references)
				//IL_0255: Unknown result type (might be due to invalid IL or missing references)
				//IL_025a: Unknown result type (might be due to invalid IL or missing references)
				//IL_025f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0272: Unknown result type (might be due to invalid IL or missing references)
				//IL_0286: Unknown result type (might be due to invalid IL or missing references)
				//IL_0296: Unknown result type (might be due to invalid IL or missing references)
				//IL_029b: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_0565: Unknown result type (might be due to invalid IL or missing references)
				//IL_056a: Unknown result type (might be due to invalid IL or missing references)
				//IL_056c: Unknown result type (might be due to invalid IL or missing references)
				//IL_056e: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_06da: Unknown result type (might be due to invalid IL or missing references)
				//IL_06de: Unknown result type (might be due to invalid IL or missing references)
				//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_033d: Unknown result type (might be due to invalid IL or missing references)
				//IL_034e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0353: Unknown result type (might be due to invalid IL or missing references)
				//IL_0358: Unknown result type (might be due to invalid IL or missing references)
				//IL_035d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0367: Unknown result type (might be due to invalid IL or missing references)
				//IL_036c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0371: Unknown result type (might be due to invalid IL or missing references)
				//IL_0377: Unknown result type (might be due to invalid IL or missing references)
				//IL_037f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0388: Unknown result type (might be due to invalid IL or missing references)
				//IL_0392: Unknown result type (might be due to invalid IL or missing references)
				//IL_067b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0414: Unknown result type (might be due to invalid IL or missing references)
				//IL_041c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0425: Unknown result type (might be due to invalid IL or missing references)
				//IL_042f: Unknown result type (might be due to invalid IL or missing references)
				//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_07dd: Expected O, but got Unknown
				//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_08d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_084d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0874: Unknown result type (might be due to invalid IL or missing references)
				//IL_0987: Unknown result type (might be due to invalid IL or missing references)
				//IL_09ae: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)MimicNetworker.Instance == (Object)null)
				{
					return;
				}
				MimicDoor.allMimics = new List<MimicDoor>();
				int num = 0;
				Dungeon currentDungeon = __instance.dungeonGenerator.Generator.CurrentDungeon;
				if (!((Object)currentDungeon.DungeonFlow).name.StartsWith("Level1") && !((Object)currentDungeon.DungeonFlow).name.StartsWith("Level2"))
				{
					return;
				}
				int num2 = 0;
				int[] array = new int[6]
				{
					MimicNetworker.SpawnWeight0.Value,
					MimicNetworker.SpawnWeight1.Value,
					MimicNetworker.SpawnWeight2.Value,
					MimicNetworker.SpawnWeight3.Value,
					MimicNetworker.SpawnWeight4.Value,
					MimicNetworker.SpawnWeightMax.Value
				};
				int num3 = 0;
				int[] array2 = array;
				foreach (int num4 in array2)
				{
					num3 += num4;
				}
				Random random = new Random(StartOfRound.Instance.randomMapSeed + 753);
				int num5 = random.Next(0, num3);
				int num6 = 0;
				for (int j = 0; j < array.Length; j++)
				{
					if (num5 < array[j] + num6)
					{
						num2 = j;
						break;
					}
					num6 += array[j];
				}
				if (num2 == 5)
				{
					num2 = 999;
				}
				EntranceTeleport[] array3 = Object.FindObjectsOfType<EntranceTeleport>(false);
				int num7 = (array3.Length - 2) / 2;
				if (MimicNetworker.SpawnRateDynamic.Value && num2 < num7 && num7 > 1)
				{
					num2 += random.Next(0, 2);
				}
				if (MimicNetworker.SpawnRateDynamic.Value && currentDungeon.AllTiles.Count > 100)
				{
					num2 += random.Next(0, 2);
				}
				List<Doorway> list = new List<Doorway>();
				Bounds val2 = default(Bounds);
				foreach (Tile allTile in currentDungeon.AllTiles)
				{
					foreach (Doorway unusedDoorway in allTile.UnusedDoorways)
					{
						if (unusedDoorway.HasDoorPrefabInstance || (Object)(object)((Component)unusedDoorway).GetComponentInChildren<SpawnSyncedObject>(true) == (Object)null)
						{
							continue;
						}
						GameObject gameObject = ((Component)((Component)((Component)unusedDoorway).GetComponentInChildren<SpawnSyncedObject>(true)).transform.parent).gameObject;
						if (!((Object)gameObject).name.StartsWith("AlleyExitDoorContainer") || gameObject.activeSelf)
						{
							continue;
						}
						bool flag = false;
						Matrix4x4 val = Matrix4x4.TRS(((Component)unusedDoorway).transform.position, ((Component)unusedDoorway).transform.rotation, new Vector3(1f, 1f, 1f));
						((Bounds)(ref val2))..ctor(new Vector3(0f, 1.5f, 5.5f), new Vector3(2f, 6f, 8f));
						((Bounds)(ref val2)).center = ((Matrix4x4)(ref val)).MultiplyPoint3x4(((Bounds)(ref val2)).center);
						Collider[] array4 = Physics.OverlapBox(((Bounds)(ref val2)).center, ((Bounds)(ref val2)).extents, ((Component)unusedDoorway).transform.rotation, LayerMask.GetMask(new string[3] { "Room", "Railing", "MapHazards" }));
						Collider[] array5 = array4;
						int num8 = 0;
						if (num8 < array5.Length)
						{
							Collider val3 = array5[num8];
							flag = true;
						}
						if (flag)
						{
							continue;
						}
						foreach (Tile allTile2 in currentDungeon.AllTiles)
						{
							if (!((Object)(object)allTile == (Object)(object)allTile2))
							{
								Vector3 origin = ((Component)unusedDoorway).transform.position + 5f * ((Component)unusedDoorway).transform.forward;
								Bounds val4 = UnityUtil.CalculateProxyBounds(((Component)allTile2).gameObject, true, Vector3.up);
								Ray val5 = default(Ray);
								((Ray)(ref val5)).origin = origin;
								((Ray)(ref val5)).direction = Vector3.up;
								if (((Bounds)(ref val4)).IntersectRay(val5) && (((Object)allTile2).name.Contains("Catwalk") || ((Object)allTile2).name.Contains("LargeForkTile") || ((Object)allTile2).name.Contains("4x4BigStair") || ((Object)allTile2).name.Contains("ElevatorConnector") || (((Object)allTile2).name.Contains("StartRoom") && !((Object)allTile2).name.Contains("Manor"))))
								{
									flag = true;
								}
								val5 = default(Ray);
								((Ray)(ref val5)).origin = origin;
								((Ray)(ref val5)).direction = Vector3.down;
								if (((Bounds)(ref val4)).IntersectRay(val5) && (((Object)allTile2).name.Contains("MediumRoomHallway1B") || ((Object)allTile2).name.Contains("LargeForkTile") || ((Object)allTile2).name.Contains("4x4BigStair") || ((Object)allTile2).name.Contains("ElevatorConnector") || ((Object)allTile2).name.Contains("StartRoom")))
								{
									flag = true;
								}
							}
						}
						if (!flag)
						{
							list.Add(unusedDoorway);
						}
					}
				}
				Shuffle(list, StartOfRound.Instance.randomMapSeed);
				List<Vector3> list2 = new List<Vector3>();
				foreach (Doorway item in list)
				{
					if (num >= num2)
					{
						break;
					}
					bool flag2 = false;
					Vector3 val6 = ((Component)item).transform.position + 5f * ((Component)item).transform.forward;
					foreach (Vector3 item2 in list2)
					{
						if (Vector3.Distance(val6, item2) < 4f)
						{
							flag2 = true;
							break;
						}
					}
					if (flag2)
					{
						continue;
					}
					list2.Add(val6);
					GameObject gameObject2 = ((Component)((Component)((Component)item).GetComponentInChildren<SpawnSyncedObject>(true)).transform.parent).gameObject;
					GameObject val7 = Object.Instantiate<GameObject>(MimicPrefab, ((Component)item).transform);
					val7.transform.position = gameObject2.transform.position;
					MimicDoor component = val7.GetComponent<MimicDoor>();
					component.scanNode.creatureScanID = MimicCreatureID;
					AudioSource[] componentsInChildren = val7.GetComponentsInChildren<AudioSource>(true);
					foreach (AudioSource val8 in componentsInChildren)
					{
						val8.volume = MimicVolume / 100f;
						val8.outputAudioMixerGroup = StartOfRound.Instance.ship3DAudio.outputAudioMixerGroup;
					}
					if (SpawnRates[5] == 9753 && num == 0)
					{
						val7.transform.position = new Vector3(-7f, 0f, -10f);
					}
					MimicDoor.allMimics.Add(component);
					component.mimicIndex = num;
					num++;
					GameObject gameObject3 = ((Component)((Component)item).transform.GetChild(0)).gameObject;
					gameObject3.SetActive(false);
					Bounds bounds = ((Collider)component.frameBox).bounds;
					Vector3 center = ((Bounds)(ref bounds)).center;
					bounds = ((Collider)component.frameBox).bounds;
					Collider[] array6 = Physics.OverlapBox(center, ((Bounds)(ref bounds)).extents, Quaternion.identity);
					foreach (Collider val9 in array6)
					{
						if (((Object)((Component)val9).gameObject).name.Contains("Shelf"))
						{
							((Component)val9).gameObject.SetActive(false);
						}
					}
					Light componentInChildren = gameObject2.GetComponentInChildren<Light>(true);
					((Component)componentInChildren).transform.parent.SetParent(val7.transform);
					MeshRenderer[] componentsInChildren2 = val7.GetComponentsInChildren<MeshRenderer>();
					MeshRenderer[] array7 = componentsInChildren2;
					foreach (MeshRenderer val10 in array7)
					{
						Material[] materials = ((Renderer)val10).materials;
						foreach (Material val11 in materials)
						{
							val11.shader = ((Renderer)gameObject3.GetComponentInChildren<MeshRenderer>(true)).material.shader;
							val11.renderQueue = ((Renderer)gameObject3.GetComponentInChildren<MeshRenderer>(true)).material.renderQueue;
						}
					}
					component.interactTrigger.onInteract = new InteractEvent();
					((UnityEvent<PlayerControllerB>)(object)component.interactTrigger.onInteract).AddListener((UnityAction<PlayerControllerB>)component.TouchMimic);
					if (MimicPerfection)
					{
						continue;
					}
					component.interactTrigger.timeToHold = 0.9f;
					if (!ColorBlindMode)
					{
						if ((StartOfRound.Instance.randomMapSeed + num) % 2 == 0)
						{
							((Renderer)val7.GetComponentsInChildren<MeshRenderer>()[0]).material.color = new Color(0.490566f, 0.1226415f, 0.1302275f);
							((Renderer)val7.GetComponentsInChildren<MeshRenderer>()[1]).material.color = new Color(0.4339623f, 0.1043965f, 0.1150277f);
							componentInChildren.colorTemperature = 1250f;
						}
						else
						{
							((Renderer)val7.GetComponentsInChildren<MeshRenderer>()[0]).material.color = new Color(0.5f, 0.1580188f, 0.1657038f);
							((Renderer)val7.GetComponentsInChildren<MeshRenderer>()[1]).material.color = new Color(43f / 106f, 0.1358579f, 0.1393619f);
							componentInChildren.colorTemperature = 1300f;
						}
					}
					else if ((StartOfRound.Instance.randomMapSeed + num) % 2 == 0)
					{
						component.interactTrigger.timeToHold = 1.1f;
					}
					else
					{
						component.interactTrigger.timeToHold = 1f;
					}
					if (!EasyMode)
					{
						continue;
					}
					Random random2 = new Random(StartOfRound.Instance.randomMapSeed + num);
					switch (random2.Next(0, 4))
					{
					case 0:
						if (!ColorBlindMode)
						{
							((Renderer)val7.GetComponentsInChildren<MeshRenderer>()[0]).material.color = new Color(0.489f, 0.2415526f, 0.1479868f);
							((Renderer)val7.GetComponentsInChildren<MeshRenderer>()[1]).material.color = new Color(0.489f, 0.2415526f, 0.1479868f);
						}
						else
						{
							component.interactTrigger.timeToHold = 1.5f;
						}
						break;
					case 1:
						component.interactTrigger.hoverTip = "Feed : [LMB]";
						component.interactTrigger.holdTip = "Feed : [LMB]";
						break;
					case 2:
						component.interactTrigger.hoverIcon = component.LostFingersIcon;
						break;
					case 3:
						component.interactTrigger.holdTip = "DIE : [LMB]";
						component.interactTrigger.timeToHold = 0.5f;
						break;
					default:
						component.interactTrigger.hoverTip = "BUG, REPORT TO DEVELOPER";
						break;
					}
				}
			}
		}

		[HarmonyPatch(typeof(SprayPaintItem))]
		internal class SprayPaintItemPatch
		{
			private static FieldInfo SprayHit = typeof(SprayPaintItem).GetField("sprayHit", BindingFlags.Instance | BindingFlags.NonPublic);

			[HarmonyPatch("SprayPaintClientRpc")]
			[HarmonyPostfix]
			private static void SprayPaintClientRpcPatch(SprayPaintItem __instance, Vector3 sprayPos, Vector3 sprayRot)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)MimicNetworker.Instance == (Object)null)
				{
					return;
				}
				RaycastHit val = (RaycastHit)SprayHit.GetValue(__instance);
				if ((Object)(object)((RaycastHit)(ref val)).collider != (Object)null && ((Object)((RaycastHit)(ref val)).collider).name == "MimicSprayCollider")
				{
					MimicDoor component = ((Component)((Component)((RaycastHit)(ref val)).collider).transform.parent.parent).GetComponent<MimicDoor>();
					component.sprayCount++;
					if (component.sprayCount > 8)
					{
						MimicNetworker.Instance.MimicAddAnger(1, component.mimicIndex);
					}
				}
			}
		}

		[HarmonyPatch(typeof(LockPicker))]
		internal class LockPickerPatch
		{
			private static FieldInfo RayHit = typeof(LockPicker).GetField("hit", BindingFlags.Instance | BindingFlags.NonPublic);

			[HarmonyPatch("ItemActivate")]
			[HarmonyPostfix]
			private static void ItemActivatePatch(LockPicker __instance, bool used, bool buttonDown = true)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)MimicNetworker.Instance == (Object)null)
				{
					return;
				}
				RaycastHit val = (RaycastHit)RayHit.GetValue(__instance);
				if (!((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null) && !((object)(RaycastHit)(ref val)).Equals((object)default(RaycastHit)) && !((Object)(object)((RaycastHit)(ref val)).transform.parent == (Object)null))
				{
					Transform parent = ((RaycastHit)(ref val)).transform.parent;
					if (((Object)parent).name.StartsWith("MimicDoor"))
					{
						MimicNetworker.Instance.MimicLockPick(__instance, ((Component)parent).GetComponent<MimicDoor>().mimicIndex);
					}
				}
			}
		}

		private const string modGUID = "x753.Mimics";

		private const string modName = "Mimics";

		private const string modVersion = "2.3.2";

		private readonly Harmony harmony = new Harmony("x753.Mimics");

		private static Mimics Instance;

		public static GameObject MimicPrefab;

		public static GameObject MimicNetworkerPrefab;

		public static TerminalNode MimicFile;

		public static int MimicCreatureID;

		public static int[] SpawnRates;

		public static bool MimicPerfection;

		public static bool EasyMode;

		public static bool ColorBlindMode;

		public static float MimicVolume;

		public static bool DynamicSpawnRate;

		private void Awake()
		{
			AssetBundle val = AssetBundle.LoadFromMemory(Resources.mimicdoor);
			MimicPrefab = val.LoadAsset<GameObject>("Assets/MimicDoor.prefab");
			MimicNetworkerPrefab = val.LoadAsset<GameObject>("Assets/MimicNetworker.prefab");
			MimicFile = val.LoadAsset<TerminalNode>("Assets/MimicFile.asset");
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Mimics is loaded!");
			SpawnRates = new int[6]
			{
				((BaseUnityPlugin)this).Config.Bind<int>("Spawn Rate", "Zero Mimics", 23, "Weight of zero mimics spawning").Value,
				((BaseUnityPlugin)this).Config.Bind<int>("Spawn Rate", "One Mimic", 69, "Weight of one mimic spawning").Value,
				((BaseUnityPlugin)this).Config.Bind<int>("Spawn Rate", "Two Mimics", 7, "Weight of two mimics spawning").Value,
				((BaseUnityPlugin)this).Config.Bind<int>("Spawn Rate", "Three Mimics", 1, "Weight of three mimics spawning").Value,
				((BaseUnityPlugin)this).Config.Bind<int>("Spawn Rate", "Four Mimics", 0, "Weight of four mimics spawning").Value,
				((BaseUnityPlugin)this).Config.Bind<int>("Spawn Rate", "Maximum Mimics", 0, "Weight of maximum mimics spawning").Value
			};
			DynamicSpawnRate = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn Rate", "Dynamic Spawn Rate", true, "Increases mimic spawn rate based on dungeon size and the number of instances of the real thing.").Value;
			MimicPerfection = ((BaseUnityPlugin)this).Config.Bind<bool>("Difficulty", "Perfect Mimics", false, "Select this if you want mimics to be the exact same color as the real thing. Overrides all difficulty settings.").Value;
			EasyMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Difficulty", "Easy Mode", false, "Each mimic will have one of several possible imperfections to help you tell if it's a mimic.").Value;
			ColorBlindMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Difficulty", "Color Blind Mode", false, "Replaces all color differences with another way to differentiate mimics.").Value;
			MimicVolume = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SFX Volume", 100, "Volume of the mimic's SFX (0-100)").Value;
			if (MimicVolume < 0f)
			{
				MimicVolume = 0f;
			}
			if (MimicVolume > 100f)
			{
				MimicVolume = 100f;
			}
			((BaseUnityPlugin)this).Config.Bind<int>("Difficulty", "Difficulty Level", 0, "This is an old setting, ignore it.");
			((BaseUnityPlugin)this).Config.Remove(((BaseUnityPlugin)this).Config["Difficulty", "Difficulty Level"].Definition);
			((BaseUnityPlugin)this).Config.Bind<int>("Spawn Rate", "Five Mimics", 0, "This is an old setting, ignore it.");
			((BaseUnityPlugin)this).Config.Remove(((BaseUnityPlugin)this).Config["Spawn Rate", "Five Mimics"].Definition);
			((BaseUnityPlugin)this).Config.Save();
			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);
					}
				}
			}
		}

		public static void Shuffle<T>(IList<T> list, int seed)
		{
			Random random = new Random(seed);
			int num = list.Count;
			while (num > 1)
			{
				num--;
				int index = random.Next(num + 1);
				T value = list[index];
				list[index] = list[num];
				list[num] = value;
			}
		}
	}
	public class MimicNetworker : NetworkBehaviour
	{
		public static MimicNetworker Instance;

		public static NetworkVariable<int> SpawnWeight0 = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static NetworkVariable<int> SpawnWeight1 = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static NetworkVariable<int> SpawnWeight2 = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static NetworkVariable<int> SpawnWeight3 = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static NetworkVariable<int> SpawnWeight4 = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static NetworkVariable<int> SpawnWeightMax = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static NetworkVariable<bool> SpawnRateDynamic = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private void Awake()
		{
			Instance = this;
		}

		public void MimicAttack(int playerId, int mimicIndex, bool ownerOnly = false)
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				Instance.MimicAttackClientRpc(playerId, mimicIndex);
			}
			else if (!ownerOnly)
			{
				Instance.MimicAttackServerRpc(playerId, mimicIndex);
			}
		}

		[ClientRpc]
		public void MimicAttackClientRpc(int playerId, int mimicIndex)
		{
			//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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2885019175u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, mimicIndex);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2885019175u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(MimicDoor.allMimics[mimicIndex].Attack(playerId));
				}
			}
		}

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

		public void MimicAddAnger(int amount, int mimicIndex)
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				Instance.MimicAddAngerClientRpc(amount, mimicIndex);
			}
			else
			{
				Instance.MimicAddAngerServerRpc(amount, mimicIndex);
			}
		}

		[ClientRpc]
		public void MimicAddAngerClientRpc(int amount, int mimicIndex)
		{
			//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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1137632670u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, amount);
					BytePacker.WriteValueBitPacked(val2, mimicIndex);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1137632670u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(MimicDoor.allMimics[mimicIndex].AddAnger(amount));
				}
			}
		}

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

		public void MimicLockPick(LockPicker lockPicker, int mimicIndex, bool ownerOnly = false)
		{
			int playerId = (int)((GrabbableObject)lockPicker).playerHeldBy.playerClientId;
			if (((NetworkBehaviour)this).IsOwner)
			{
				Instance.MimicLockPickClientRpc(playerId, mimicIndex);
			}
			else if (!ownerOnly)
			{
				Instance.MimicLockPickServerRpc(playerId, mimicIndex);
			}
		}

		[ClientRpc]
		public void MimicLockPickClientRpc(int playerId, int mimicIndex)
		{
			//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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3716888238u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					BytePacker.WriteValueBitPacked(val2, mimicIndex);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3716888238u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(MimicDoor.allMimics[mimicIndex].MimicLockPick(playerId));
				}
			}
		}

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

		protected override void __initializeVariables()
		{
			if (SpawnWeight0 == null)
			{
				throw new Exception("MimicNetworker.SpawnWeight0 cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)SpawnWeight0).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SpawnWeight0, "SpawnWeight0");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)SpawnWeight0);
			if (SpawnWeight1 == null)
			{
				throw new Exception("MimicNetworker.SpawnWeight1 cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)SpawnWeight1).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SpawnWeight1, "SpawnWeight1");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)SpawnWeight1);
			if (SpawnWeight2 == null)
			{
				throw new Exception("MimicNetworker.SpawnWeight2 cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)SpawnWeight2).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SpawnWeight2, "SpawnWeight2");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)SpawnWeight2);
			if (SpawnWeight3 == null)
			{
				throw new Exception("MimicNetworker.SpawnWeight3 cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)SpawnWeight3).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SpawnWeight3, "SpawnWeight3");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)SpawnWeight3);
			if (SpawnWeight4 == null)
			{
				throw new Exception("MimicNetworker.SpawnWeight4 cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)SpawnWeight4).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SpawnWeight4, "SpawnWeight4");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)SpawnWeight4);
			if (SpawnWeightMax == null)
			{
				throw new Exception("MimicNetworker.SpawnWeightMax cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)SpawnWeightMax).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SpawnWeightMax, "SpawnWeightMax");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)SpawnWeightMax);
			if (SpawnRateDynamic == null)
			{
				throw new Exception("MimicNetworker.SpawnRateDynamic cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)SpawnRateDynamic).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SpawnRateDynamic, "SpawnRateDynamic");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)SpawnRateDynamic);
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_MimicNetworker()
		{
			//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(2885019175u, new RpcReceiveHandler(__rpc_handler_2885019175));
			NetworkManager.__rpc_func_table.Add(1024971481u, new RpcReceiveHandler(__rpc_handler_1024971481));
			NetworkManager.__rpc_func_table.Add(1137632670u, new RpcReceiveHandler(__rpc_handler_1137632670));
			NetworkManager.__rpc_func_table.Add(669208889u, new RpcReceiveHandler(__rpc_handler_669208889));
			NetworkManager.__rpc_func_table.Add(3716888238u, new RpcReceiveHandler(__rpc_handler_3716888238));
			NetworkManager.__rpc_func_table.Add(1897916243u, new RpcReceiveHandler(__rpc_handler_1897916243));
		}

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

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

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

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

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

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

		protected internal override string __getTypeName()
		{
			return "MimicNetworker";
		}
	}
	public class MimicDoor : MonoBehaviour
	{
		public GameObject playerTarget;

		public BoxCollider frameBox;

		public Sprite LostFingersIcon;

		public Animator mimicAnimator;

		public GameObject grabPoint;

		public InteractTrigger interactTrigger;

		public ScanNodeProperties scanNode;

		public int anger;

		public bool angering;

		public int sprayCount;

		private bool attacking;

		public static List<MimicDoor> allMimics;

		public int mimicIndex;

		private static MethodInfo RetractClaws = typeof(LockPicker).GetMethod("RetractClaws", BindingFlags.Instance | BindingFlags.NonPublic);

		public void TouchMimic(PlayerControllerB player)
		{
			if (!attacking)
			{
				MimicNetworker.Instance.MimicAttack((int)player.playerClientId, mimicIndex);
			}
		}

		public IEnumerator Attack(int playerId)
		{
			attacking = true;
			interactTrigger.interactable = false;
			PlayerControllerB player = StartOfRound.Instance.allPlayerScripts[playerId];
			mimicAnimator.SetTrigger("Attack");
			playerTarget.transform.position = ((Component)player).transform.position;
			yield return (object)new WaitForSeconds(0.1f);
			playerTarget.transform.position = ((Component)player).transform.position;
			yield return (object)new WaitForSeconds(0.1f);
			playerTarget.transform.position = ((Component)player).transform.position;
			yield return (object)new WaitForSeconds(0.1f);
			playerTarget.transform.position = ((Component)player).transform.position;
			yield return (object)new WaitForSeconds(0.1f);
			float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)frameBox).transform.position);
			if (num < 8f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else if (num < 14f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			yield return (object)new WaitForSeconds(0.2f);
			if (((NetworkBehaviour)player).IsOwner && Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position) < 8.75f)
			{
				player.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 0);
			}
			float startTime = Time.timeSinceLevelLoad;
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)player.deadBody != (Object)null || Time.timeSinceLevelLoad - startTime > 4f));
			if ((Object)(object)player.deadBody != (Object)null)
			{
				player.deadBody.attachedTo = grabPoint.transform;
				player.deadBody.attachedLimb = player.deadBody.bodyParts[5];
				player.deadBody.matchPositionExactly = true;
				for (int i = 0; i < player.deadBody.bodyParts.Length; i++)
				{
					((Component)player.deadBody.bodyParts[i]).GetComponent<Collider>().excludeLayers = LayerMask.op_Implicit(-1);
				}
			}
			yield return (object)new WaitForSeconds(2f);
			if ((Object)(object)player.deadBody != (Object)null)
			{
				player.deadBody.attachedTo = null;
				player.deadBody.attachedLimb = null;
				player.deadBody.matchPositionExactly = false;
				((Component)((Component)player.deadBody).transform.GetChild(0)).gameObject.SetActive(false);
				player.deadBody = null;
			}
			yield return (object)new WaitForSeconds(4.5f);
			attacking = false;
			interactTrigger.interactable = true;
		}

		public IEnumerator MimicLockPick(int playerId)
		{
			if (angering || attacking)
			{
				yield break;
			}
			LockPicker lockPicker = default(LockPicker);
			ref LockPicker reference = ref lockPicker;
			GrabbableObject currentlyHeldObjectServer = StartOfRound.Instance.allPlayerScripts[playerId].currentlyHeldObjectServer;
			reference = (LockPicker)(object)((currentlyHeldObjectServer is LockPicker) ? currentlyHeldObjectServer : null);
			if ((Object)(object)lockPicker == (Object)null)
			{
				yield break;
			}
			attacking = true;
			interactTrigger.interactable = false;
			AudioSource component = ((Component)lockPicker).GetComponent<AudioSource>();
			component.PlayOneShot(lockPicker.placeLockPickerClips[Random.Range(0, lockPicker.placeLockPickerClips.Length)]);
			lockPicker.armsAnimator.SetBool("mounted", true);
			lockPicker.armsAnimator.SetBool("picking", true);
			component.Play();
			component.pitch = Random.Range(0.94f, 1.06f);
			lockPicker.isOnDoor = true;
			lockPicker.isPickingLock = true;
			((GrabbableObject)lockPicker).grabbable = false;
			if (((NetworkBehaviour)lockPicker).IsOwner)
			{
				((GrabbableObject)lockPicker).playerHeldBy.DiscardHeldObject(true, ((NetworkBehaviour)MimicNetworker.Instance).NetworkObject, ((Component)this).transform.position + ((Component)this).transform.up * 1.5f - ((Component)this).transform.forward * 1.15f, true);
			}
			float startTime = Time.timeSinceLevelLoad;
			yield return (object)new WaitUntil((Func<bool>)(() => !((GrabbableObject)lockPicker).isHeld || Time.timeSinceLevelLoad - startTime > 10f));
			((Component)lockPicker).transform.localEulerAngles = new Vector3(((Component)this).transform.eulerAngles.x, ((Component)this).transform.eulerAngles.y + 90f, ((Component)this).transform.eulerAngles.z);
			yield return (object)new WaitForSeconds(5f);
			RetractClaws.Invoke(lockPicker, null);
			((Component)lockPicker).transform.SetParent((Transform)null);
			((GrabbableObject)lockPicker).startFallingPosition = ((Component)lockPicker).transform.position;
			((GrabbableObject)lockPicker).FallToGround(false);
			((GrabbableObject)lockPicker).grabbable = true;
			yield return (object)new WaitForSeconds(1f);
			anger = 3;
			attacking = false;
			interactTrigger.interactable = false;
			PlayerControllerB val = null;
			float num = 9999f;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val2).transform.position);
				if (num2 < num)
				{
					num = num2;
					val = val2;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				MimicNetworker.Instance.MimicAttackClientRpc((int)val.playerClientId, mimicIndex);
			}
			else
			{
				interactTrigger.interactable = true;
			}
		}

		public IEnumerator AddAnger(int amount)
		{
			if (angering || attacking)
			{
				yield break;
			}
			angering = true;
			anger += amount;
			if (anger == 1)
			{
				Sprite oldIcon2 = interactTrigger.hoverIcon;
				interactTrigger.hoverIcon = LostFingersIcon;
				mimicAnimator.SetTrigger("Growl");
				yield return (object)new WaitForSeconds(2.75f);
				interactTrigger.hoverIcon = oldIcon2;
				sprayCount = 0;
				angering = false;
				yield break;
			}
			if (anger == 2)
			{
				interactTrigger.holdTip = "DIE : [LMB]";
				interactTrigger.timeToHold = 0.25f;
				Sprite oldIcon2 = interactTrigger.hoverIcon;
				interactTrigger.hoverIcon = LostFingersIcon;
				mimicAnimator.SetTrigger("Growl");
				yield return (object)new WaitForSeconds(2.75f);
				interactTrigger.hoverIcon = oldIcon2;
				sprayCount = 0;
				angering = false;
				yield break;
			}
			if (anger > 2)
			{
				PlayerControllerB val = null;
				float num = 9999f;
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB val2 in allPlayerScripts)
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val2).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = val2;
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					MimicNetworker.Instance.MimicAttackClientRpc((int)val.playerClientId, mimicIndex);
				}
			}
			sprayCount = 0;
			angering = false;
		}
	}
	public class MimicCollider : MonoBehaviour, IHittable
	{
		public MimicDoor mimic;

		bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false)
		{
			MimicNetworker.Instance.MimicAddAnger(force, mimic.mimicIndex);
			return true;
		}
	}
	public class MimicListener : MonoBehaviour, INoiseListener
	{
		public MimicDoor mimic;

		private int tolerance = 100;

		void INoiseListener.DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if ((noiseLoudness >= 0.9f || noiseID == 101158) && Vector3.Distance(noisePosition, ((Component)mimic).transform.position) < 5f)
			{
				switch (noiseID)
				{
				case 75:
					tolerance--;
					break;
				case 5:
					tolerance -= 15;
					break;
				case 101158:
					tolerance -= 35;
					break;
				default:
					tolerance -= 30;
					break;
				}
				if (tolerance <= 0)
				{
					tolerance = 100;
					MimicNetworker.Instance.MimicAddAnger(1, mimic.mimicIndex);
				}
			}
		}
	}
}

MoreBlood/MoreBlood.dll

Decompiled 8 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using MoreBlood.Config;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoreBlood")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreBlood")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d1f1321d-30a3-4600-9bf8-1e69fe1abf8c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreBlood
{
	[BepInPlugin("FlipMods.MoreBlood", "MoreBlood", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			instance = this;
			_harmony = new Harmony("MoreBlood");
			ConfigSettings.BindConfigSettings();
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MoreBlood loaded");
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.MoreBlood";

		public const string PLUGIN_NAME = "MoreBlood";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace MoreBlood.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class MoreBloodPatcher
	{
		private static int bloodCount;

		[HarmonyPatch("DropBlood")]
		[HarmonyPostfix]
		public static void MoreBlood(PlayerControllerB __instance, Vector3 direction = default(Vector3), bool leaveBlood = true, bool leaveFootprint = false)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			bloodCount++;
			if (bloodCount < ConfigSettings.numBloodPools.Value)
			{
				__instance.DropBlood(direction, leaveBlood, leaveFootprint);
			}
			else
			{
				bloodCount = 0;
			}
		}

		[HarmonyPatch("RandomizeBloodRotationAndScale")]
		[HarmonyPostfix]
		public static void RandomizeBloodScale(ref Transform blood, PlayerControllerB __instance)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Transform obj = blood;
			obj.localScale *= ConfigSettings.bloodScale.Value;
			blood.position += new Vector3((float)Random.Range(-1, 1) * ConfigSettings.bloodScale.Value, 0.55f, (float)Random.Range(-1, 1) * ConfigSettings.bloodScale.Value);
		}
	}
}
namespace MoreBlood.Config
{
	public static class ConfigSettings
	{
		public static ConfigEntry<float> bloodScale;

		public static ConfigEntry<int> numBloodPools;

		public static void BindConfigSettings()
		{
			Plugin.Log("BindingConfigs");
			bloodScale = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("MoreBlood", "BloodScale", 4f, "The size of the blood pools");
			numBloodPools = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("MoreBlood", "NumberOfBloodPools", 4, "Max number of blood pools spread around the blood source.");
		}
	}
}

Motionsense/ForestGiantMotionsense.dll

Decompiled 8 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TanmanG")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("CC BY-NC-SA")]
[assembly: AssemblyDescription("A Harmony patch to adjust Forest Giant AI to only detect motion.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ForestGiantMotionsense")]
[assembly: AssemblyTitle("ForestGiantMotionsense")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/TanmanG/LethalCompany_ForestGiantMotionsense")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ForestGiantMotionsense;

[BepInPlugin("ForestGiantMotionsense", "ForestGiantMotionsense", "1.0.0")]
public class FoGiMoSeMod : BaseUnityPlugin
{
	private static FoGiMoSeMod Instance;

	private void Awake()
	{
		Instance = this;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ForestGiantMotionsense is loaded!");
		Harmony.CreateAndPatchAll(typeof(FoGiMoSeMod), (string)null);
	}

	[HarmonyPatch(typeof(ForestGiantAI), "LookForPlayers")]
	[HarmonyTranspiler]
	private static IEnumerable<CodeInstruction> MotionPatch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Expected O, but got Unknown
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Expected O, but got Unknown
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Expected O, but got Unknown
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Expected O, but got Unknown
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Expected O, but got Unknown
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Expected O, but got Unknown
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Expected O, but got Unknown
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Expected O, but got Unknown
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Expected O, but got Unknown
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Expected O, but got Unknown
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Expected O, but got Unknown
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Expected O, but got Unknown
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Expected O, but got Unknown
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Expected O, but got Unknown
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Expected O, but got Unknown
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Expected O, but got Unknown
		//IL_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Expected O, but got Unknown
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Expected O, but got Unknown
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Expected O, but got Unknown
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Expected O, but got Unknown
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Expected O, but got Unknown
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Expected O, but got Unknown
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Expected O, but got Unknown
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Expected O, but got Unknown
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Expected O, but got Unknown
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Expected O, but got Unknown
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Expected O, but got Unknown
		LocalBuilder localBuilder = generator.DeclareLocal(typeof(bool));
		LocalBuilder localBuilder2 = generator.DeclareLocal(typeof(bool));
		CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
		val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[5]
		{
			new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldelem_Ref, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null)
		}).Advance(1);
		((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"First: {val.Remaining}");
		if (val.Remaining == 0)
		{
			((BaseUnityPlugin)Instance).Logger.LogFatal((object)"Could not find first LookForPlayers patch, flagging to abort!");
		}
		Label label = val.Instruction.labels.First();
		val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[6]
		{
			new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldelem_R4, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ble_Un, (object)null, (string)null)
		});
		((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"Second: {val.Remaining}");
		if (val.Remaining == 0)
		{
			((BaseUnityPlugin)Instance).Logger.LogFatal((object)"Could not find second LookForPlayers patch, flagging to abort!");
		}
		CodeInstruction instruction = val.Advance(2).Instruction;
		CodeInstruction instruction2 = val.Advance(2).Instruction;
		val.Advance(-4);
		val.RemoveInstructions(6).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[24]
		{
			new CodeInstruction(OpCodes.Ldarg_0, (object)null),
			new CodeInstruction(OpCodes.Ldfld, (object)typeof(ForestGiantAI).GetField("playerStealthMeters", BindingFlags.Instance | BindingFlags.Public)),
			instruction,
			new CodeInstruction(OpCodes.Ldelem_R4, (object)null),
			instruction2,
			new CodeInstruction(OpCodes.Cgt, (object)null),
			new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder),
			new CodeInstruction(OpCodes.Call, (object)typeof(StartOfRound).GetMethod("get_Instance", BindingFlags.Static | BindingFlags.Public)),
			new CodeInstruction(OpCodes.Ldfld, (object)typeof(StartOfRound).GetField("allPlayerScripts", BindingFlags.Instance | BindingFlags.Public)),
			instruction,
			new CodeInstruction(OpCodes.Ldelem_Ref, (object)null),
			new CodeInstruction(OpCodes.Dup, (object)null),
			new CodeInstruction(OpCodes.Ldfld, (object)typeof(PlayerControllerB).GetField("timeSincePlayerMoving", BindingFlags.Instance | BindingFlags.Public)),
			new CodeInstruction(OpCodes.Ldc_R4, (object)2.25f),
			new CodeInstruction(OpCodes.Clt, (object)null),
			new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder2),
			new CodeInstruction(OpCodes.Ldarg_0, (object)null),
			new CodeInstruction(OpCodes.Ldfld, (object)typeof(ForestGiantAI).GetField("chasingPlayer", BindingFlags.Instance | BindingFlags.Public)),
			new CodeInstruction(OpCodes.Call, (object)typeof(Object).GetMethod("op_Equality")),
			new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder2),
			new CodeInstruction(OpCodes.Or, (object)null),
			new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder),
			new CodeInstruction(OpCodes.And, (object)null),
			new CodeInstruction(OpCodes.Brfalse_S, (object)label)
		});
		return val.InstructionEnumeration();
	}

	[HarmonyPatch(typeof(PlayerControllerB), "UpdatePlayerPositionClientRpc")]
	[HarmonyTranspiler]
	private static IEnumerable<CodeInstruction> TimeSinceMovePatch(IEnumerable<CodeInstruction> instructions)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Expected O, but got Unknown
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Expected O, but got Unknown
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Expected O, but got Unknown
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Expected O, but got Unknown
		CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[8]
		{
			new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Dup, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stfld, (object)null, (string)null)
		});
		((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"First RPC: {val.Remaining}");
		if (val.Remaining == 0)
		{
			((BaseUnityPlugin)Instance).Logger.LogFatal((object)"Could not find UpdatePlayerPositionClientRPC patch location, flagging to abort!");
		}
		val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3]
		{
			new CodeInstruction(OpCodes.Ldarg_0, (object)null),
			new CodeInstruction(OpCodes.Ldc_R4, (object)0f),
			new CodeInstruction(OpCodes.Stfld, (object)typeof(PlayerControllerB).GetField("timeSincePlayerMoving", BindingFlags.Instance | BindingFlags.Public))
		});
		return val.InstructionEnumeration();
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "ForestGiantMotionsense";

	public const string PLUGIN_NAME = "ForestGiantMotionsense";

	public const string PLUGIN_VERSION = "1.0.0";
}

RollingGiant/RollingGiant.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RollingGiant;
using RollingGiant.Patches;
using RollingGiant.Settings;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.InputSystem;
using UnityEngine.Pool;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RollingGiant")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RollingGiant")]
[assembly: AssemblyTitle("RollingGiant")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<RollingGiantAiType>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<RollingGiantAiType>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
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 RollingGiant
{
	public class NetworkHandler : NetworkBehaviour
	{
		private static readonly List<RollingGiantAiType> _aiTypes = Enum.GetValues(typeof(RollingGiantAiType)).Cast<RollingGiantAiType>().Take(Enum.GetValues(typeof(RollingGiantAiType)).Length - 1)
			.ToList();

		private NetworkVariable<RollingGiantAiType> _aiType = new NetworkVariable<RollingGiantAiType>(RollingGiantAiType.RandomlyMoveWhileLooking, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private static InputAction _gotoPreviousAiType;

		private static InputAction _gotoNextAiType;

		private static InputAction _reloadConfig;

		public static NetworkHandler Instance { get; private set; }

		public static RollingGiantAiType AiType => Instance._aiType.Value;

		public override void OnNetworkSpawn()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				if (Object.op_Implicit((Object)(object)Instance))
				{
					((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				}
				_aiType.Value = CustomConfig.AiType.GetFirst();
			}
			Instance = this;
			InputAction gotoPreviousAiType = _gotoPreviousAiType;
			if (gotoPreviousAiType != null)
			{
				gotoPreviousAiType.Disable();
			}
			InputAction gotoPreviousAiType2 = _gotoPreviousAiType;
			if (gotoPreviousAiType2 != null)
			{
				gotoPreviousAiType2.Dispose();
			}
			_gotoPreviousAiType = new InputAction("gotoPreviousAiType", (InputActionType)1, CustomConfig.GotoPreviousAiTypeKey.Value, (string)null, (string)null, (string)null);
			_gotoPreviousAiType.Enable();
			InputAction gotoNextAiType = _gotoNextAiType;
			if (gotoNextAiType != null)
			{
				gotoNextAiType.Disable();
			}
			InputAction gotoNextAiType2 = _gotoNextAiType;
			if (gotoNextAiType2 != null)
			{
				gotoNextAiType2.Dispose();
			}
			_gotoNextAiType = new InputAction("gotoNextAiType", (InputActionType)1, CustomConfig.GotoNextAiTypeKey.Value, (string)null, (string)null, (string)null);
			_gotoNextAiType.Enable();
			InputAction reloadConfig = _reloadConfig;
			if (reloadConfig != null)
			{
				reloadConfig.Disable();
			}
			InputAction reloadConfig2 = _reloadConfig;
			if (reloadConfig2 != null)
			{
				reloadConfig2.Dispose();
			}
			_reloadConfig = new InputAction("reloadConfig", (InputActionType)1, CustomConfig.ReloadConfigKey.Value, (string)null, (string)null, (string)null);
			_reloadConfig.Enable();
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		public void SetAiType(RollingGiantAiType aiType)
		{
			if (((NetworkBehaviour)this).IsServer || ((NetworkBehaviour)this).IsHost)
			{
				SetNewAiType(aiType, showTip: false);
			}
		}

		private void Update()
		{
			if (!((NetworkBehaviour)this).IsServer && !((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			if (_gotoPreviousAiType.WasPressedThisFrame())
			{
				int num = _aiTypes.IndexOf(_aiType.Value) - 1;
				if (num < 0)
				{
					num = _aiTypes.Count - 1;
				}
				SetNewAiType(_aiTypes[num]);
			}
			else if (_gotoNextAiType.WasPressedThisFrame())
			{
				int num2 = _aiTypes.IndexOf(_aiType.Value) + 1;
				if (num2 >= _aiTypes.Count)
				{
					num2 = 0;
				}
				SetNewAiType(_aiTypes[num2]);
			}
			else if (_reloadConfig.WasPressedThisFrame())
			{
				Plugin.Config.Reload();
				SyncedInstance<CustomConfig>.Instance.Reload();
				_aiType.Value = CustomConfig.AiType.GetFirst();
				SetNewAiType(_aiType.Value);
				HUDManager.Instance.DisplayTip("Config reloaded", $"Ai defaulted to {_aiType.Value}", false, false, "LC_Tip1");
			}
		}

		private void SetNewAiType(RollingGiantAiType aiType, bool showTip = true)
		{
			RollingGiantAiType value = _aiType.Value;
			_aiType.Value = aiType;
			CustomConfig.SetCurrentAi();
			EmitSharedServerSettingsClientRpc();
			if (Object.op_Implicit((Object)(object)HUDManager.Instance) && value != aiType && showTip)
			{
				HUDManager.Instance.DisplayTip("Rolling Giant AI changed", aiType.ToString(), false, false, "LC_Tip1");
			}
			Plugin.Log.LogMessage((object)$"Rolling Giant AI changed: {aiType}");
		}

		[ClientRpc]
		private void EmitSharedServerSettingsClientRpc()
		{
			//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(4257552972u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4257552972u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					CustomConfig.RequestSync();
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_NetworkHandler()
		{
			//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(4257552972u, new RpcReceiveHandler(__rpc_handler_4257552972));
		}

		private static void __rpc_handler_4257552972(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;
				((NetworkHandler)(object)target).EmitSharedServerSettingsClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "NetworkHandler";
		}
	}
	[BepInPlugin("nomnomab.rollinggiant", "Rolling Giant", "2.4.4")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "nomnomab.rollinggiant";

		public const string PluginName = "Rolling Giant";

		public const string PluginVersion = "2.4.4";

		private const int SaveFileVersion = 9;

		public static string PluginDirectory;

		public static AssetBundle Bundle;

		public static EnemyType EnemyTypeInside;

		public static EnemyType EnemyTypeOutside;

		public static EnemyType EnemyTypeOutsideDaytime;

		public static TerminalNode EnemyTerminalNode;

		public static TerminalKeyword EnemyTerminalKeyword;

		public static AudioClip WalkSound;

		public static AudioClip[] StopSounds;

		public static GameObject PlayerRagdoll;

		public static Item PosterItem;

		public static Material BlackAndWhiteMaterial;

		internal static ManualLogSource Log;

		public static CustomConfig CustomConfig { get; private set; }

		public static ConfigFile Config { get; private set; }

		private void Awake()
		{
			Config = ((BaseUnityPlugin)this).Config;
			Log = ((BaseUnityPlugin)this).Logger;
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
			LoadSettings();
			RemoveOldSettings();
			LoadAssets();
			LoadNetWeaver();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RollingGiant is loaded!");
		}

		private void LoadNetWeaver()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				try
				{
					MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
					foreach (MethodInfo methodInfo in methods)
					{
						if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
						{
							methodInfo.Invoke(null, null);
						}
					}
				}
				catch
				{
					Log.LogWarning((object)("NetWeaver is skipping " + type.FullName));
				}
			}
		}

		private void LoadSettings()
		{
			CustomConfig = new CustomConfig(((BaseUnityPlugin)this).Config);
		}

		private void RemoveOldSettings()
		{
			int value = ((BaseUnityPlugin)this).Config.Bind<int>("z_Ignore", "__version", 0, "The version of this config file. Do not change this.").Value;
			if (value != 9)
			{
				Log.LogMessage((object)$"Removing old settings... ({value} != {9})");
				string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
				string destFileName = configFilePath + ".bak";
				File.Copy(configFilePath, destFileName, overwrite: true);
				File.WriteAllText(configFilePath, "");
				((BaseUnityPlugin)this).Config.Reload();
				CustomConfig.Reload(setValues: false);
				((BaseUnityPlugin)this).Config.Bind<int>("z_Ignore", "__version", 9, (ConfigDescription)null).Value = 9;
				CustomConfig.AssignFromSaved();
				((BaseUnityPlugin)this).Config.Save();
			}
			else
			{
				Log.LogMessage((object)$"Settings version is up to date ({value} == {9})");
			}
		}

		private void LoadAssets()
		{
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PluginDirectory) ?? throw new Exception("Failed to get directory name!"), "rollinggiant"));
				EnemyTypeInside = Bundle.LoadAsset<EnemyType>("Assets/RollingGiant/Data/RollingGiant_EnemyType.asset");
				EnemyTypeOutside = Bundle.LoadAsset<EnemyType>("Assets/RollingGiant/Data/RollingGiant_EnemyType_Outside.asset");
				EnemyTypeOutsideDaytime = Bundle.LoadAsset<EnemyType>("Assets/RollingGiant/Data/RollingGiant_EnemyType_Outside_Daytime.asset");
				EnemyTypeInside.MaxCount = CustomConfig.MaxPerLevel;
				EnemyTypeOutside.MaxCount = CustomConfig.MaxPerLevel;
				EnemyTypeOutsideDaytime.MaxCount = CustomConfig.MaxPerLevel;
				NetworkPatches.RegisterPrefab(EnemyTypeInside.enemyPrefab);
				NetworkPatches.RegisterPrefab(EnemyTypeOutside.enemyPrefab);
				NetworkPatches.RegisterPrefab(EnemyTypeOutsideDaytime.enemyPrefab);
				EnemyTerminalNode = Bundle.LoadAsset<TerminalNode>("Assets/RollingGiant/Data/RollingGiant_TerminalNode.asset");
				EnemyTerminalKeyword = Bundle.LoadAsset<TerminalKeyword>("Assets/RollingGiant/Data/RollingGiant_TerminalKeyword.asset");
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Failed to load asset bundle! {arg}");
			}
			try
			{
				WalkSound = Bundle.LoadAsset<AudioClip>("Assets/RollingGiant/Audio/MovingLoop.wav");
				StopSounds = (AudioClip[])(object)new AudioClip[5];
				for (int i = 0; i < 5; i++)
				{
					StopSounds[i] = Bundle.LoadAsset<AudioClip>($"Assets/RollingGiant/Audio/Stopped{i + 1}.wav");
				}
				PlayerRagdoll = Bundle.LoadAsset<GameObject>("Assets/RollingGiant/PlayerRagdollRollingGiant Variant.prefab");
				PlayerRagdoll.AddComponent<RollingGiantDeadBody>();
				PosterItem = Bundle.LoadAsset<Item>("Assets/RollingGiant/Data/RollingGiant_PosterItem.asset");
				Item posterItem = PosterItem;
				posterItem.rotationOffset += new Vector3(45f, 0f, 0f);
				Item posterItem2 = PosterItem;
				posterItem2.positionOffset += new Vector3(-0.1f, -0.12f, 0.15f);
				Object.Destroy((Object)(object)PosterItem.spawnPrefab.GetComponent<PhysicsProp>());
				PosterItem.spawnPrefab.AddComponent<Poster>().Init();
				NetworkPatches.RegisterPrefab(PosterItem.spawnPrefab);
				BlackAndWhiteMaterial = Bundle.LoadAsset<Material>("Assets/RollingGiant/Materials/RollingGiant_Gray.mat");
			}
			catch (Exception arg2)
			{
				Log.LogError((object)$"Failed to load assets! {arg2}");
			}
		}
	}
	[Flags]
	public enum RollingGiantAiType
	{
		[Description("Coilhead AI")]
		Coilhead = 1,
		[Description("Move when player is looking at it")]
		InverseCoilhead = 2,
		[Description("Randomly move while the player is looking at it")]
		RandomlyMoveWhileLooking = 4,
		[Description("If the player looks at it for too long it doesn't stop chasing")]
		LookingTooLongKeepsAgro = 8,
		[Description("Once the player is noticed, the Rolling Giant will follow the player constantly")]
		FollowOnceAgro = 0x10,
		[Description("Once the player sees the Rolling Giant, it will chase the player after a timer")]
		OnceSeenAgroAfterTimer = 0x20,
		[Description("All AI types")]
		All = 0x3F
	}
	public static class RollingGiantAiTypeExtensions
	{
		public static RollingGiantAiType GetFirst(this RollingGiantAiType aiType)
		{
			RollingGiantAiType[] array = Enum.GetValues(typeof(RollingGiantAiType)).Cast<RollingGiantAiType>().ToArray();
			for (int i = 0; i < array.Length - 1; i++)
			{
				RollingGiantAiType rollingGiantAiType = array[i];
				if ((aiType & rollingGiantAiType) == rollingGiantAiType)
				{
					return rollingGiantAiType;
				}
			}
			return aiType;
		}

		public static RollingGiantAiType GetRandom(this RollingGiantAiType aiType)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			List<RollingGiantAiType> list = default(List<RollingGiantAiType>);
			PooledObject<List<RollingGiantAiType>> val = CollectionPool<List<RollingGiantAiType>, RollingGiantAiType>.Get(ref list);
			try
			{
				RollingGiantAiType[] array = Enum.GetValues(typeof(RollingGiantAiType)).Cast<RollingGiantAiType>().ToArray();
				for (int i = 0; i < array.Length - 1; i++)
				{
					RollingGiantAiType rollingGiantAiType = array[i];
					if ((aiType & rollingGiantAiType) == rollingGiantAiType)
					{
						list.Add(rollingGiantAiType);
					}
				}
				RollingGiantAiType result = aiType;
				Random random = new Random(StartOfRound.Instance.randomMapSeed);
				int index = random.Next(0, list.Count);
				if (list.Count > 1)
				{
					result = list[index];
				}
				else if (list.Count == 0)
				{
					result = array[random.Next(0, array.Length - 1)];
				}
				return result;
			}
			finally
			{
				((IDisposable)val).Dispose();
			}
		}
	}
	public class Poster : PhysicsProp
	{
		public void Init()
		{
			((GrabbableObject)this).grabbable = true;
			((GrabbableObject)this).itemProperties = Plugin.PosterItem;
			((GrabbableObject)this).isInFactory = true;
			((GrabbableObject)this).mainObjectRenderer = ((Component)this).GetComponent<MeshRenderer>();
			((GrabbableObject)this).grabbableToEnemies = true;
		}

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

		protected internal override string __getTypeName()
		{
			return "Poster";
		}
	}
	public class RollingGiantAI : EnemyAI
	{
		private const float ROAMING_AUDIO_PERCENT = 0.4f;

		[SerializeField]
		private AISearchRoutine _searchForPlayers;

		[SerializeField]
		private Collider _mainCollider;

		[SerializeField]
		private AudioClip[] _stopNoises;

		private AudioSource _rollingSFX;

		private NetworkVariable<float> _velocity = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private NetworkVariable<float> _waitTimer = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private NetworkVariable<float> _moveTimer = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private NetworkVariable<float> _lookTimer = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private NetworkVariable<float> _agroTimer = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private float _timeSinceHittingPlayer;

		private bool _wantsToChaseThisClient;

		private bool _hasEnteredChaseState;

		private bool _wasStopped;

		private bool _wasFeared;

		private bool _isAgro;

		private float _lastSpeed;

		private bool _tooBig;

		private static RollingGiantAiType _aiType => NetworkHandler.AiType;

		private static SharedAiSettings _sharedAiSettings => CustomConfig.SharedAiSettings;

		private static void LogInfo(object message)
		{
		}

		private static float NextDouble()
		{
			if (!Object.op_Implicit((Object)(object)RoundManager.Instance) || RoundManager.Instance.LevelRandom == null)
			{
				return Random.value;
			}
			return (float)RoundManager.Instance.LevelRandom.NextDouble();
		}

		public override void Start()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			Init(((Component)this).transform.localScale.x);
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsOwner)
			{
				AssignInitData_LocalClient();
			}
			LogInfo($"Rolling giant spawned with ai type: {NetworkHandler.AiType}, owner? {((NetworkBehaviour)this).IsOwner}");
		}

		private void Init(float scale)
		{
			base.agent = ((Component)this).gameObject.GetComponentInChildren<NavMeshAgent>();
			_rollingSFX = ((Component)((Component)this).transform.Find("RollingSFX")).GetComponent<AudioSource>();
			AudioMixerGroup outputAudioMixerGroup = SoundManager.Instance.diageticMixer.outputAudioMixerGroup;
			_rollingSFX.outputAudioMixerGroup = outputAudioMixerGroup;
			base.creatureVoice.outputAudioMixerGroup = outputAudioMixerGroup;
			base.creatureSFX.outputAudioMixerGroup = outputAudioMixerGroup;
			_rollingSFX.loop = true;
			_rollingSFX.clip = Plugin.WalkSound;
			float time = NextDouble() * Plugin.WalkSound.length;
			_rollingSFX.time = time;
			_rollingSFX.pitch = Mathf.Lerp(1.1f, 0.8f, Mathf.InverseLerp(0.9f, 1.2f, scale));
			_rollingSFX.volume = 0f;
			_rollingSFX.Play();
			base.isOutside = base.enemyType.isOutsideEnemy || base.enemyType.isDaytimeEnemy;
			if (base.isOutside)
			{
				base.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			}
		}

		public override void DaytimeEnemyLeave()
		{
			((EnemyAI)this).DaytimeEnemyLeave();
			Renderer[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				if (!(((Object)val).name == "object_3"))
				{
					val.sharedMaterial = Plugin.BlackAndWhiteMaterial;
				}
			}
			_mainCollider.isTrigger = true;
		}

		public override void DoAIInterval()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			if (base.daytimeEnemyLeaving)
			{
				_mainCollider.isTrigger = true;
				return;
			}
			((EnemyAI)this).DoAIInterval();
			if (StartOfRound.Instance.livingPlayers == 0 || base.isEnemyDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if (!((NetworkBehaviour)this).IsServer)
				{
					((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
					break;
				}
				if (!_searchForPlayers.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, _searchForPlayers);
					LogInfo($"[DoAIInterval::{NetworkHandler.AiType}] StartSearch({((Component)this).transform.position}, _searchForPlayers)");
					break;
				}
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB val in allPlayerScripts)
				{
					if (!val.isPlayerDead && ((NetworkBehaviour)val).IsSpawned && base.isOutside != val.isInsideFactory && (base.isOutside || ((EnemyAI)this).PlayerIsTargetable(val, false, false)))
					{
						float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
						bool flag = num < (float)(base.isOutside ? 90 : 30);
						if (Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)val.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && flag)
						{
							((EnemyAI)this).SwitchToBehaviourState(1);
							LogInfo($"[DoAIInterval::{NetworkHandler.AiType}] SwitchToBehaviourState(1), found {val?.playerUsername} at distance {num}m");
							return;
						}
					}
				}
				if (base.isOutside)
				{
					PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false);
					bool flag2 = Vector3.Distance(((Component)this).transform.position, ((Component)closestPlayer).transform.position) < (float)(base.isOutside ? 90 : 30);
					if (Object.op_Implicit((Object)(object)closestPlayer) && Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)closestPlayer.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && flag2)
					{
						base.targetPlayer = closestPlayer;
						((EnemyAI)this).SwitchToBehaviourState(1);
						LogInfo($"[DoAIInterval::{NetworkHandler.AiType}] ClosestPlayer! SwitchToBehaviourState(1), found {base.targetPlayer?.playerUsername}");
					}
				}
				break;
			}
			case 1:
				if (!((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f))
				{
					base.movingTowardsTargetPlayer = false;
					if (!_searchForPlayers.inProgress)
					{
						((EnemyAI)this).SwitchToBehaviourState(0);
						LogInfo($"[DoAIInterval::{NetworkHandler.AiType}] lost player; StartSearch({((Component)this).transform.position}, _searchForPlayers)");
					}
				}
				else if (_searchForPlayers.inProgress)
				{
					((EnemyAI)this).StopSearch(_searchForPlayers, true);
					base.movingTowardsTargetPlayer = true;
					LogInfo($"[DoAIInterval::{NetworkHandler.AiType}] StopSearch(_searchForPlayers), found {base.targetPlayer?.playerUsername}");
				}
				break;
			}
		}

		public override void Update()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			if (base.daytimeEnemyLeaving)
			{
				_mainCollider.isTrigger = true;
				return;
			}
			Vector3 velocity2;
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				NetworkVariable<float> velocity = _velocity;
				velocity2 = base.agent.velocity;
				velocity.Value = ((Vector3)(ref velocity2)).magnitude;
			}
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				return;
			}
			velocity2 = base.agent.velocity;
			_lastSpeed = ((Vector3)(ref velocity2)).magnitude;
			CalculateAgentSpeed();
			_timeSinceHittingPlayer += Time.deltaTime;
			_mainCollider.isTrigger = _velocity.Value > 0.01f;
			float value = _velocity.Value;
			LogInfo($"[Update::{NetworkHandler.AiType}] speed: {value}/{_sharedAiSettings.moveSpeed}, moveTowardsDestination: {base.moveTowardsDestination}: movingTowardsTargetPlayer: {base.movingTowardsTargetPlayer}, onNavmesh: {base.agent.isOnNavMesh}, isActiveAndEnabled: {((Behaviour)base.agent).isActiveAndEnabled}");
			if (value > 0.1f)
			{
				_rollingSFX.volume = Mathf.Lerp(0f, Mathf.Clamp01(0.4f * value + 0.05f), value / _sharedAiSettings.moveSpeed);
			}
			else
			{
				_rollingSFX.volume = Mathf.Lerp(_rollingSFX.volume, 0f, Time.deltaTime);
			}
			GameNetworkManager instance = GameNetworkManager.Instance;
			PlayerControllerB localPlayerController = instance.localPlayerController;
			if (_wasStopped && !_wasFeared && localPlayerController.HasLineOfSightToPosition(base.eye.position, 70f, 25, -1f))
			{
				_wasFeared = true;
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)localPlayerController).transform.position);
				if (num < 4f)
				{
					instance.localPlayerController.JumpToFearLevel(0.9f, true);
				}
				else if (num < 9f)
				{
					instance.localPlayerController.JumpToFearLevel(0.4f, true);
				}
				if (_lastSpeed > 1f)
				{
					RoundManager.PlayRandomClip(base.creatureVoice, _stopNoises, false, 1f, 0);
				}
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (_hasEnteredChaseState)
				{
					_hasEnteredChaseState = false;
					_wantsToChaseThisClient = false;
					_wasStopped = false;
					_wasFeared = false;
					base.agent.speed = 0f;
					if (_aiType != RollingGiantAiType.OnceSeenAgroAfterTimer)
					{
						_isAgro = false;
						if (((NetworkBehaviour)this).IsOwner)
						{
							_agroTimer.Value = 0f;
						}
					}
					if (((NetworkBehaviour)this).IsOwner)
					{
						_waitTimer.Value = 0f;
						_moveTimer.Value = 0f;
						_lookTimer.Value = 0f;
					}
				}
				if (((NetworkBehaviour)this).IsOwner && ((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f) && !_wantsToChaseThisClient)
				{
					_wantsToChaseThisClient = true;
					BeginChasingPlayer_ServerRpc((int)base.targetPlayer.playerClientId);
					LogInfo($"[Update::{NetworkHandler.AiType}] began chasing local player {base.targetPlayer?.playerUsername}");
				}
				break;
			case 1:
			{
				if (!_hasEnteredChaseState)
				{
					_hasEnteredChaseState = true;
					_wantsToChaseThisClient = false;
					_wasStopped = false;
					_wasFeared = false;
					if (_aiType != RollingGiantAiType.OnceSeenAgroAfterTimer)
					{
						_isAgro = false;
						if (((NetworkBehaviour)this).IsOwner)
						{
							_agroTimer.Value = 0f;
						}
					}
					if (((NetworkBehaviour)this).IsOwner)
					{
						_waitTimer.Value = 0f;
						_moveTimer.Value = 0f;
						_lookTimer.Value = 0f;
					}
				}
				if (base.stunNormalizedTimer > 0f)
				{
					break;
				}
				PlayerControllerB targetPlayer = base.targetPlayer;
				if (((NetworkBehaviour)this).IsOwner)
				{
					if (!base.isOutside && !((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f))
					{
						((EnemyAI)this).SwitchToBehaviourState(0);
						EndChasingPlayer_ServerRpc();
						LogInfo($"[Update::{NetworkHandler.AiType}] not in range; SwitchToBehaviourState(0)");
						break;
					}
					if (base.isOutside && !((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f))
					{
						PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false);
						if (!Object.op_Implicit((Object)(object)closestPlayer))
						{
							((EnemyAI)this).SwitchToBehaviourState(0);
							EndChasingPlayer_ServerRpc();
							LogInfo($"[Update::{NetworkHandler.AiType}] not in range; SwitchToBehaviourState(0)");
							break;
						}
						base.targetPlayer = closestPlayer;
					}
					if (_wasStopped && _sharedAiSettings.rotateToLookAtPlayer && _lookTimer.Value >= _sharedAiSettings.delayBeforeLookingAtPlayer)
					{
						Vector3 position = ((Component)base.targetPlayer).transform.position;
						Vector3 position2 = ((Component)this).transform.position;
						Vector3 val = position - position2;
						val.y = 0f;
						((Vector3)(ref val)).Normalize();
						Quaternion val2 = Quaternion.LookRotation(val);
						((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, val2, Time.deltaTime / _sharedAiSettings.lookAtPlayerDuration);
					}
				}
				RollingGiantAiType aiType = NetworkHandler.AiType;
				PlayerControllerB closestPlayer2;
				switch (aiType)
				{
				case RollingGiantAiType.Coilhead:
					if (AmIBeingLookedAt(out closestPlayer2))
					{
						_wasStopped = true;
						return;
					}
					break;
				case RollingGiantAiType.InverseCoilhead:
					if (!AmIBeingLookedAt(out closestPlayer2) && _isAgro)
					{
						_wasStopped = true;
						return;
					}
					break;
				case RollingGiantAiType.RandomlyMoveWhileLooking:
					if (AmIBeingLookedAt(out closestPlayer2) && _moveTimer.Value <= 0f)
					{
						_wasStopped = true;
						return;
					}
					break;
				case RollingGiantAiType.LookingTooLongKeepsAgro:
					if (AmIBeingLookedAt(out closestPlayer2) && _agroTimer.Value < 1f)
					{
						_wasStopped = true;
						return;
					}
					break;
				case RollingGiantAiType.OnceSeenAgroAfterTimer:
					if (_isAgro && _agroTimer.Value <= 0f)
					{
						_wasStopped = true;
						return;
					}
					break;
				default:
					Plugin.Log.LogWarning((object)$"Unknown ai type: {aiType}");
					break;
				case RollingGiantAiType.FollowOnceAgro:
					break;
				}
				_wasStopped = false;
				_wasFeared = false;
				if (((NetworkBehaviour)this).IsOwner && (Object)(object)targetPlayer != (Object)(object)base.targetPlayer)
				{
					((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
					LogInfo($"[Update::{NetworkHandler.AiType}] SetMovingTowardsTargetPlayer, player {base.targetPlayer?.playerUsername}");
				}
				break;
			}
			}
		}

		private static float SmoothLerp(float a, float b, float t)
		{
			return a + t * t * (b - a);
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_006c: 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)
			if (base.daytimeEnemyLeaving)
			{
				return;
			}
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!(_timeSinceHittingPlayer < 0.6f))
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if (Object.op_Implicit((Object)(object)val) && (!_tooBig || !val.isInHangarShipRoom))
				{
					_timeSinceHittingPlayer = 0.2f;
					int num = StartOfRound.Instance.playerRagdolls.IndexOf(Plugin.PlayerRagdoll);
					val.DamagePlayer(90, true, true, (CauseOfDeath)4, num, false, default(Vector3));
					base.agent.speed = 0f;
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1f, true);
				}
			}
		}

		private void CalculateAgentSpeed()
		{
			if (base.stunNormalizedTimer >= 0f)
			{
				base.agent.speed = 0f;
				base.agent.acceleration = 200f;
			}
			else if (base.currentBehaviourStateIndex == 0)
			{
				MoveAccelerate();
			}
			else
			{
				if (base.currentBehaviourStateIndex != 1)
				{
					return;
				}
				if (((NetworkBehaviour)this).IsOwner && !IsAgentOnNavMesh(((Component)base.agent).gameObject))
				{
					MoveAccelerate();
					LogInfo($"[CalculateAgentSpeed::{NetworkHandler.AiType}] not on navmesh");
					return;
				}
				PlayerControllerB closestPlayer;
				bool flag = AmIBeingLookedAt(out closestPlayer);
				if (((NetworkBehaviour)this).IsOwner)
				{
					if (flag)
					{
						NetworkVariable<float> lookTimer = _lookTimer;
						lookTimer.Value += Time.deltaTime;
					}
					else
					{
						_lookTimer.Value = 0f;
					}
				}
				RollingGiantAiType aiType = NetworkHandler.AiType;
				switch (aiType)
				{
				case RollingGiantAiType.Coilhead:
					if (flag)
					{
						MoveDecelerate();
					}
					else
					{
						MoveAccelerate();
					}
					break;
				case RollingGiantAiType.InverseCoilhead:
					if (!flag && _isAgro)
					{
						MoveDecelerate();
						break;
					}
					MoveAccelerate();
					_isAgro = true;
					break;
				case RollingGiantAiType.RandomlyMoveWhileLooking:
					if (flag)
					{
						if (_waitTimer.Value <= 0f && _moveTimer.Value <= 0f)
						{
							GenerateWaitTime();
						}
						if (_waitTimer.Value > 0f && _moveTimer.Value <= 0f)
						{
							MoveDecelerate();
							if (((NetworkBehaviour)this).IsOwner)
							{
								LogInfo($"_waitTimer: {_waitTimer.Value}");
								NetworkVariable<float> waitTimer = _waitTimer;
								waitTimer.Value -= Time.deltaTime;
								if (_waitTimer.Value <= 0f)
								{
									GenerateMoveTime();
								}
							}
							break;
						}
					}
					MoveAccelerate();
					if (_moveTimer.Value > 0f && ((NetworkBehaviour)this).IsOwner)
					{
						LogInfo($"_moveTimer: {_moveTimer.Value}");
						NetworkVariable<float> moveTimer = _moveTimer;
						moveTimer.Value -= Time.deltaTime;
						if (_moveTimer.Value <= 0f)
						{
							GenerateWaitTime();
						}
					}
					break;
				case RollingGiantAiType.LookingTooLongKeepsAgro:
					if (!_isAgro)
					{
						if (flag)
						{
							if (((NetworkBehaviour)this).IsOwner)
							{
								NetworkVariable<float> agroTimer2 = _agroTimer;
								agroTimer2.Value += Time.deltaTime / _sharedAiSettings.lookTimeBeforeAgro;
							}
							LogInfo($"[Update::{NetworkHandler.AiType}] _agroTimer: {_agroTimer.Value}");
							if (_agroTimer.Value >= 1f)
							{
								_isAgro = true;
								LogInfo($"[Update::{NetworkHandler.AiType}] got agro");
							}
							MoveDecelerate();
						}
						else
						{
							if (((NetworkBehaviour)this).IsOwner)
							{
								_agroTimer.Value = Mathf.Lerp(_agroTimer.Value, 0f, Time.deltaTime / (_sharedAiSettings.lookTimeBeforeAgro * 1.5f));
								LogInfo($"[Update::{NetworkHandler.AiType}] _agroTimer: {_agroTimer.Value}");
							}
							MoveAccelerate();
						}
					}
					else
					{
						MoveAccelerate();
					}
					break;
				case RollingGiantAiType.FollowOnceAgro:
					if (!_isAgro && flag)
					{
						_isAgro = true;
						MoveDecelerate();
						LogInfo($"[Update::{NetworkHandler.AiType}] got agro");
					}
					else
					{
						MoveAccelerate();
					}
					break;
				case RollingGiantAiType.OnceSeenAgroAfterTimer:
					if (!_isAgro)
					{
						if (flag)
						{
							_isAgro = true;
							LogInfo($"[Update::{NetworkHandler.AiType}] got agro");
							if (((NetworkBehaviour)this).IsOwner)
							{
								_agroTimer.Value = Mathf.Lerp(_sharedAiSettings.waitTimeMin, _sharedAiSettings.waitTimeMax, NextDouble());
							}
							MoveDecelerate();
						}
					}
					else if (_agroTimer.Value >= 0f)
					{
						LogInfo($"[Update::{NetworkHandler.AiType}] _agroTimer: {_agroTimer.Value}");
						if (((NetworkBehaviour)this).IsOwner)
						{
							NetworkVariable<float> agroTimer = _agroTimer;
							agroTimer.Value -= Time.deltaTime;
						}
						if (_agroTimer.Value < 0f)
						{
							LogInfo($"[Update::{NetworkHandler.AiType}] chasing time");
						}
						MoveDecelerate();
					}
					else
					{
						MoveAccelerate();
					}
					break;
				default:
					Plugin.Log.LogWarning((object)$"Unknown ai type: {aiType}");
					break;
				}
			}
		}

		private void MoveAccelerate()
		{
			base.agent.speed = ((_sharedAiSettings.moveAcceleration == 0f) ? _sharedAiSettings.moveSpeed : Mathf.Lerp(base.agent.speed, _sharedAiSettings.moveSpeed, Time.deltaTime / _sharedAiSettings.moveAcceleration));
			base.agent.acceleration = Mathf.Lerp(base.agent.acceleration, 200f, Time.deltaTime);
		}

		private void MoveDecelerate()
		{
			base.agent.speed = ((_sharedAiSettings.moveDeceleration == 0f) ? 0f : Mathf.Lerp(base.agent.speed, 0f, Time.deltaTime / _sharedAiSettings.moveDeceleration));
			base.agent.acceleration = 200f;
		}

		private bool AmIBeingLookedAt(out PlayerControllerB closestPlayer)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			float num = float.MaxValue;
			closestPlayer = null;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if ((base.isOutside || ((EnemyAI)this).PlayerIsTargetable(val, false, false)) && !val.isPlayerDead && ((NetworkBehaviour)val).IsSpawned && val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.6f, 68f, 60, -1f))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (num2 < num)
					{
						num = num2;
						closestPlayer = val;
					}
				}
			}
			return Object.op_Implicit((Object)(object)closestPlayer);
		}

		private bool IsAgentOnNavMesh(GameObject agentObject)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = agentObject.transform.position;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(position, ref val, 3f, -1) && Mathf.Approximately(position.x, ((NavMeshHit)(ref val)).position.x) && Mathf.Approximately(position.z, ((NavMeshHit)(ref val)).position.z))
			{
				return position.y >= ((NavMeshHit)(ref val)).position.y;
			}
			return false;
		}

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

		[ClientRpc]
		private void BeginChasingPlayer_ClientRpc(int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2111596117u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2111596117u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
					PlayerControllerB movingTowardsTargetPlayer = StartOfRound.Instance.allPlayerScripts[playerId];
					((EnemyAI)this).SetMovingTowardsTargetPlayer(movingTowardsTargetPlayer);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void EndChasingPlayer_ServerRpc()
		{
			//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)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3771085912u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3771085912u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					EndChasingPlayer_ClientRpc();
				}
			}
		}

		[ClientRpc]
		private void EndChasingPlayer_ClientRpc()
		{
			//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)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1947504516u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1947504516u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.movingTowardsTargetPlayer = false;
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(0);
				}
			}
		}

		private void GenerateWaitTime()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				float value = Mathf.Lerp(_sharedAiSettings.waitTimeMin, _sharedAiSettings.waitTimeMax, NextDouble());
				_waitTimer.Value = value;
			}
		}

		private void GenerateAgroTime()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				_agroTimer.Value = _sharedAiSettings.lookTimeBeforeAgro;
			}
		}

		private void GenerateMoveTime()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				float value = Mathf.Lerp(_sharedAiSettings.randomMoveTimeMin, _sharedAiSettings.randomMoveTimeMax, NextDouble());
				_moveTimer.Value = value;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void AssignInitData_ServerRpc(float scale)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2584131514u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref scale, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2584131514u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					AssignAgentData(scale);
					((Component)base.agent).transform.localScale = Vector3.one * scale;
					AssignInitData_ClientRpc(scale);
				}
			}
		}

		private void AssignInitData_LocalClient()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			CustomConfig instance = SyncedInstance<CustomConfig>.Instance;
			Vector2 val = (base.isOutside ? new Vector2(instance.GiantScaleOutsideMin, instance.GiantScaleOutsideMax) : new Vector2(instance.GiantScaleInsideMin, instance.GiantScaleInsideMax));
			float num = Mathf.Lerp(val.x, val.y, NextDouble());
			AssignAgentData(num);
			((Component)base.agent).transform.localScale = Vector3.one * num;
			AssignInitData_ServerRpc(num);
		}

		[ClientRpc]
		private void AssignInitData_ClientRpc(float scale)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3644677666u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref scale, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3644677666u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.updatePositionThreshold = float.MaxValue;
					AssignAgentData(scale);
					((Component)base.agent).transform.localScale = Vector3.one * scale;
				}
			}
		}

		private void AssignAgentData(float scale)
		{
			Init(scale);
			if (scale >= 1.2f)
			{
				int areaMask = base.agent.areaMask;
				areaMask &= ~(1 << NavMesh.GetAreaFromName("SmallSpace"));
				areaMask &= ~(1 << NavMesh.GetAreaFromName("MediumSpace"));
				areaMask &= ~(1 << NavMesh.GetAreaFromName("Climb"));
				areaMask &= ~(1 << NavMesh.GetAreaFromName("PlayerShip"));
				base.agent.areaMask = areaMask;
				_tooBig = true;
			}
		}

		protected override void __initializeVariables()
		{
			if (_velocity == null)
			{
				throw new Exception("RollingGiantAI._velocity cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_velocity).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_velocity, "_velocity");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_velocity);
			if (_waitTimer == null)
			{
				throw new Exception("RollingGiantAI._waitTimer cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_waitTimer).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_waitTimer, "_waitTimer");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_waitTimer);
			if (_moveTimer == null)
			{
				throw new Exception("RollingGiantAI._moveTimer cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_moveTimer).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_moveTimer, "_moveTimer");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_moveTimer);
			if (_lookTimer == null)
			{
				throw new Exception("RollingGiantAI._lookTimer cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_lookTimer).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_lookTimer, "_lookTimer");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_lookTimer);
			if (_agroTimer == null)
			{
				throw new Exception("RollingGiantAI._agroTimer cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_agroTimer).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_agroTimer, "_agroTimer");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_agroTimer);
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_RollingGiantAI()
		{
			//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(913739805u, new RpcReceiveHandler(__rpc_handler_913739805));
			NetworkManager.__rpc_func_table.Add(2111596117u, new RpcReceiveHandler(__rpc_handler_2111596117));
			NetworkManager.__rpc_func_table.Add(3771085912u, new RpcReceiveHandler(__rpc_handler_3771085912));
			NetworkManager.__rpc_func_table.Add(1947504516u, new RpcReceiveHandler(__rpc_handler_1947504516));
			NetworkManager.__rpc_func_table.Add(2584131514u, new RpcReceiveHandler(__rpc_handler_2584131514));
			NetworkManager.__rpc_func_table.Add(3644677666u, new RpcReceiveHandler(__rpc_handler_3644677666));
		}

		private static void __rpc_handler_913739805(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 playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RollingGiantAI)(object)target).BeginChasingPlayer_ServerRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2111596117(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 playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RollingGiantAI)(object)target).BeginChasingPlayer_ClientRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3771085912(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RollingGiantAI)(object)target).EndChasingPlayer_ServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1947504516(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;
				((RollingGiantAI)(object)target).EndChasingPlayer_ClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2584131514(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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float scale = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref scale, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RollingGiantAI)(object)target).AssignInitData_ServerRpc(scale);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3644677666(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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float scale = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref scale, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RollingGiantAI)(object)target).AssignInitData_ClientRpc(scale);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "RollingGiantAI";
		}
	}
	public class RollingGiantDeadBody : MonoBehaviour
	{
	}
	public static class Utility
	{
		public static object InvokeNotOverride(this MethodInfo methodInfo, object targetObject, params object[] arguments)
		{
			ParameterInfo[] parameters = methodInfo.GetParameters();
			if (parameters.Length == 0)
			{
				if (arguments != null && arguments.Length != 0)
				{
					throw new Exception("Arguments cont doesn't match");
				}
			}
			else if (parameters.Length != arguments.Length)
			{
				throw new Exception("Arguments cont doesn't match");
			}
			Type returnType = null;
			if (methodInfo.ReturnType != typeof(void))
			{
				returnType = methodInfo.ReturnType;
			}
			Type type = targetObject.GetType();
			DynamicMethod dynamicMethod = new DynamicMethod("", returnType, new Type[2]
			{
				type,
				typeof(object)
			}, type);
			ILGenerator iLGenerator = dynamicMethod.GetILGenerator();
			iLGenerator.Emit(OpCodes.Ldarg_0);
			for (int i = 0; i < parameters.Length; i++)
			{
				ParameterInfo obj = parameters[i];
				iLGenerator.Emit(OpCodes.Ldarg_1);
				iLGenerator.Emit(OpCodes.Ldc_I4_S, i);
				iLGenerator.Emit(OpCodes.Ldelem_Ref);
				Type parameterType = obj.ParameterType;
				if (parameterType.IsPrimitive)
				{
					iLGenerator.Emit(OpCodes.Unbox_Any, parameterType);
				}
				else if (!(parameterType == typeof(object)))
				{
					iLGenerator.Emit(OpCodes.Castclass, parameterType);
				}
			}
			iLGenerator.Emit(OpCodes.Call, methodInfo);
			iLGenerator.Emit(OpCodes.Ret);
			return dynamicMethod.Invoke(null, new object[2] { targetObject, arguments });
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RollingGiant";

		public const string PLUGIN_NAME = "RollingGiant";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace RollingGiant.Settings
{
	public struct SharedAiSettings : INetworkSerializable
	{
		public float moveSpeed;

		public float moveAcceleration;

		public float moveDeceleration;

		public bool rotateToLookAtPlayer;

		public float delayBeforeLookingAtPlayer;

		public float lookAtPlayerDuration;

		public float waitTimeMin;

		public float waitTimeMax;

		public float randomMoveTimeMin;

		public float randomMoveTimeMax;

		public float lookTimeBeforeAgro;

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref moveSpeed, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref moveAcceleration, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref moveDeceleration, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref rotateToLookAtPlayer, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref delayBeforeLookingAtPlayer, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref lookAtPlayerDuration, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref waitTimeMin, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref waitTimeMax, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref randomMoveTimeMin, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref randomMoveTimeMax, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref lookTimeBeforeAgro, default(ForPrimitives));
		}

		public override string ToString()
		{
			return $"moveSpeed: {moveSpeed}, moveAcceleration: {moveAcceleration}, moveDeceleration: {moveDeceleration}, rotateToLookAtPlayer: {rotateToLookAtPlayer}, delayBeforeLookingAtPlayer: {delayBeforeLookingAtPlayer}, lookAtPlayerDuration: {lookAtPlayerDuration}, waitTimeMin: {waitTimeMin}, waitTimeMax: {waitTimeMax}, randomMoveTimeMin: {randomMoveTimeMin}, randomMoveTimeMax: {randomMoveTimeMax}, lookTimeBeforeAgro: {lookTimeBeforeAgro}";
		}
	}
	[Serializable]
	public class CustomConfig : SyncedInstance<CustomConfig>
	{
		public const string ROLLINGGIANT_ONREQUESTCONFIGSYNC = "RollingGiant_OnRequestConfigSync";

		public const string ROLLINGGIANT_ONRECEIVECONFIGSYNC = "RollingGiant_OnReceiveConfigSync";

		private static ConfigFile _config;

		public const string Name1 = "1. General Settings";

		public const string Name2 = "2. AI Settings";

		public const string AiTypeDescription = "The AI type of the Rolling Giant.\n(Putting multiple will randomly choose between them each time you land on a moon)";

		public const string MoveSpeedDescription = "The speed of the Rolling Giant in m/s².";

		public const string MoveAccelerationDescription = "How long it takes the Rolling Giant to get to its movement speed. in seconds";

		public const string MoveDecelerationDescription = "How long it takes the Rolling Giant to stop moving in seconds.";

		public const string RotateToLookAtPlayerDescription = "If the Rolling Giant should rotate to look at the player.";

		public const string DelayBeforeLookingAtPlayerDescription = "The delay before the Rolling Giant looks at the player in seconds.";

		public const string LookAtPlayerDurationDescription = "The duration the Rolling Giant looks at the player in seconds.";

		public static SharedAiSettings SharedAiSettings { get; private set; }

		public static ConfigEntry<string> GotoPreviousAiTypeKey { get; private set; }

		public static ConfigEntry<string> GotoNextAiTypeKey { get; private set; }

		public static ConfigEntry<string> ReloadConfigKey { get; private set; }

		public static ConfigEntry<string> SpawnInEntry { get; private set; }

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

		public static ConfigEntry<bool> SpawnInAnyEntry { get; private set; }

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

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

		public static ConfigEntry<bool> CanSpawnInsideEntry { get; private set; }

		public static ConfigEntry<bool> CanSpawnOutsideEntry { get; private set; }

		public static ConfigEntry<bool> DisableOutsideAtNightEntry { get; private set; }

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

		public static ConfigEntry<string> SpawnPosterInEntry { get; private set; }

		public float GiantScaleInsideMin { get; private set; }

		public float GiantScaleInsideMax { get; private set; }

		public float GiantScaleOutsideMin { get; private set; }

		public float GiantScaleOutsideMax { get; private set; }

		public static string SpawnIn { get; private set; }

		public static int SpawnInOutsideChance { get; private set; }

		public static bool SpawnInAny { get; private set; }

		public static int SpawnInAnyChance { get; private set; }

		public static int SpawnInAnyOutsideChance { get; private set; }

		public static bool CanSpawnInside { get; private set; }

		public static bool CanSpawnOutside { get; private set; }

		public static bool DisableOutsideAtNight { get; private set; }

		public static int MaxPerLevel { get; private set; }

		public static string SpawnPosterIn { get; private set; }

		public static RollingGiantAiType AiType { get; internal set; }

		public float MoveSpeed { get; private set; }

		public float MoveAcceleration { get; private set; }

		public float MoveDeceleration { get; private set; }

		public bool RotateToLookAtPlayer { get; private set; }

		public float DelayBeforeLookingAtPlayer { get; private set; }

		public float LookAtPlayerDuration { get; private set; }

		public float RandomlyMoveWhenLooking_WaitTimeMin { get; private set; }

		public float RandomlyMoveWhenLooking_WaitTimeMax { get; private set; }

		public float RandomlyMoveWhenLooking_RandomMoveTimeMin { get; private set; }

		public float RandomlyMoveWhenLooking_RandomMoveTimeMax { get; private set; }

		public float LookingTooLongKeepsAgro_LookTimeBeforeAgro { get; private set; }

		public float OnceSeenAgroAfterTimer_WaitTimeMin { get; private set; }

		public float OnceSeenAgroAfterTimer_WaitTimeMax { get; private set; }

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

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

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

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

		public static ConfigEntry<RollingGiantAiType> AiTypeEntry { get; private set; }

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

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

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

		public static ConfigEntry<bool> RotateToLookAtPlayerEntry { get; private set; }

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

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

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

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

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

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

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

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

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

		public CustomConfig(ConfigFile config)
		{
			_config = config;
			InitInstance(this);
			Reload();
		}

		public void Save()
		{
			if (_config == null)
			{
				throw new NullReferenceException("Config is null.");
			}
			_config.Save();
		}

		public void AssignFromSaved()
		{
			GiantScaleInsideMinEntry.Value = GiantScaleInsideMin;
			GiantScaleInsideMaxEntry.Value = GiantScaleInsideMax;
			GiantScaleOutsideMinEntry.Value = GiantScaleOutsideMin;
			GiantScaleOutsideMaxEntry.Value = GiantScaleOutsideMax;
			SpawnInEntry.Value = SpawnIn;
			SpawnInOutsideChanceEntry.Value = SpawnInAnyOutsideChance;
			SpawnInAnyEntry.Value = SpawnInAny;
			SpawnInAnyChanceEntry.Value = SpawnInAnyChance;
			SpawnInAnyOutsideChanceEntry.Value = SpawnInAnyOutsideChance;
			CanSpawnInsideEntry.Value = CanSpawnInside;
			CanSpawnOutsideEntry.Value = CanSpawnOutside;
			DisableOutsideAtNightEntry.Value = DisableOutsideAtNight;
			MaxPerLevelEntry.Value = MaxPerLevel;
			SpawnPosterInEntry.Value = SpawnPosterIn;
			AiTypeEntry.Value = AiType;
			MoveSpeedEntry.Value = MoveSpeed;
			MoveAccelerationEntry.Value = MoveAcceleration;
			MoveDecelerationEntry.Value = MoveDeceleration;
			RotateToLookAtPlayerEntry.Value = RotateToLookAtPlayer;
			DelayBeforeLookingAtPlayerEntry.Value = DelayBeforeLookingAtPlayer;
			LookAtPlayerDurationEntry.Value = LookAtPlayerDuration;
			RandomlyMoveWhenLooking_WaitTimeMinEntry.Value = RandomlyMoveWhenLooking_WaitTimeMin;
			RandomlyMoveWhenLooking_WaitTimeMaxEntry.Value = RandomlyMoveWhenLooking_WaitTimeMax;
			RandomlyMoveWhenLooking_RandomMoveTimeMinEntry.Value = RandomlyMoveWhenLooking_RandomMoveTimeMin;
			RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry.Value = RandomlyMoveWhenLooking_RandomMoveTimeMax;
			LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry.Value = LookingTooLongKeepsAgro_LookTimeBeforeAgro;
			OnceSeenAgroAfterTimer_WaitTimeMinEntry.Value = OnceSeenAgroAfterTimer_WaitTimeMin;
			OnceSeenAgroAfterTimer_WaitTimeMaxEntry.Value = OnceSeenAgroAfterTimer_WaitTimeMax;
		}

		public void Reload(bool setValues = true)
		{
			GiantScaleInsideMinEntry = _config.Bind<float>("1. General Settings", "GiantScaleInsideMin", 0.9f, "The min scale of the Rolling Giant inside.\nThis is a multiplier, so 0.5 is half as large.");
			GiantScaleInsideMaxEntry = _config.Bind<float>("1. General Settings", "GiantScaleInsideMax", 1.1f, "The max scale of the Rolling Giant inside.\nThis is a multiplier, so 2 is twice as large.");
			GiantScaleOutsideMinEntry = _config.Bind<float>("1. General Settings", "GiantScaleOutsideMin", 0.9f, "The min scale of the Rolling Giant outside.\nThis is a multiplier, so 0.5 is half as large.");
			GiantScaleOutsideMaxEntry = _config.Bind<float>("1. General Settings", "GiantScaleOutsideMax", 1.1f, "The max scale of the Rolling Giant outside.\nThis is a multiplier, so 2 is twice as large.");
			SpawnInEntry = _config.Bind<string>("1. General Settings", "SpawnIn", "Vow:45,March:45,Rend:54,Dine:65,Offense:45,Titan:65", "Where the Rolling Giant can spawn.\nSeparate each level with a comma, and put a chance (no decimals) separated by a colon.\nVanilla caps at 100, but you can go farther.\nThis chance is also a weight, not a percentage.\nHigher chance = higher chance to get picked\nThe names are what you see in the terminal\nExample: Vow:6,March:10");
			SpawnInOutsideChanceEntry = _config.Bind<int>("1. General Settings", "SpawnInOutsideChance", 45, "The chance for the Rolling Giant to spawn outside.\nIs used alongside SpawnIn.\nThis is a weight, not a percentage.\nHigher chance = higher chance to get picked");
			SpawnInAnyEntry = _config.Bind<bool>("1. General Settings", "SpawnInAny", false, "If the Rolling Giant can spawn in any level.");
			SpawnInAnyChanceEntry = _config.Bind<int>("1. General Settings", "SpawnInAnyChance", 45, "The chance for the Rolling Giant to spawn in any level.\nRequires SpawnInAny to be enabled!\nThis is a weight, not a percentage.\nHigher chance = higher chance to get picked");
			SpawnInAnyOutsideChanceEntry = _config.Bind<int>("1. General Settings", "SpawnInAnyOutsideChance", 45, "The chance for the Rolling Giant to spawn outside when spawning in any level.\nRequires SpawnInAny to be enabled!\nThis is a weight, not a percentage.\nHigher chance = higher chance to get picked");
			CanSpawnInsideEntry = _config.Bind<bool>("1. General Settings", "CanSpawnInside", true, "If the Rolling Giant can spawn inside.");
			CanSpawnOutsideEntry = _config.Bind<bool>("1. General Settings", "CanSpawnOutside", false, "If the Rolling Giant can spawn outside.");
			DisableOutsideAtNightEntry = _config.Bind<bool>("1. General Settings", "DisableOutsideAtNight", false, "If the Rolling Giant will turn off if it is outside at night.");
			MaxPerLevelEntry = _config.Bind<int>("1. General Settings", "MaxPerLevel", 3, "The maximum amount of Rolling Giants that can spawn in a level.");
			SpawnPosterInEntry = _config.Bind<string>("1. General Settings", "SpawnPosterIn", "Vow:12,March:12,Rend:12,Dine:12,Offense:12,Titan:12", "Where the Rolling Giant poster scrap can spawn.\nSeparate each level with a comma, and put a chance separated by a colon.\nVanilla caps at 100, but you can go farther.\nThis chance is also a weight, not a percentage.\nHigher chance = higher chance to get picked\nThe names are what you see in the terminal\nExample: Vow:12,March:12,Rend:12,Dine:12,Offense:12,Titan:12");
			if (GotoPreviousAiTypeKey == null)
			{
				GotoPreviousAiTypeKey = _config.Bind<string>("Host", "GotoPreviousAiTypeKey", "<Keyboard>/numpad7", "The key to go to the previous AI type. This uses Unity's New Input System's key-bind names.\nhttps://docs.unity3d.com/Packages/[email protected]/manual/Controls.html#control-paths");
			}
			if (GotoNextAiTypeKey == null)
			{
				GotoNextAiTypeKey = _config.Bind<string>("Host", "GotoNextAiTypeKey", "<Keyboard>/numpad8", "The key to go to the next AI type. This uses Unity's New Input System's key-bind names.\nhttps://docs.unity3d.com/Packages/[email protected]/manual/Controls.html#control-paths");
			}
			if (ReloadConfigKey == null)
			{
				ReloadConfigKey = _config.Bind<string>("Host", "ReloadConfigKey", "<Keyboard>/numpad9", "The key to reload the config. Does not update spawn conditions. This uses Unity's New Input System's key-bind names.\nhttps://docs.unity3d.com/Packages/[email protected]/manual/Controls.html#control-paths");
			}
			string text = "The AI type of the Rolling Giant.\n(Putting multiple will randomly choose between them each time you land on a moon)";
			foreach (object value in Enum.GetValues(typeof(RollingGiantAiType)))
			{
				string arg = GetAttributeOfType<DescriptionAttribute>((Enum)value)?.Description ?? "No description found.";
				text += $"\n{value}: {arg}";
			}
			AiTypeEntry = _config.Bind<RollingGiantAiType>("2. AI Settings", "AiType", RollingGiantAiType.RandomlyMoveWhileLooking, text);
			MoveSpeedEntry = _config.Bind<float>("2. AI Settings", "MoveSpeed", 6f, "The speed of the Rolling Giant in m/s².");
			MoveAccelerationEntry = _config.Bind<float>("2. AI Settings", "MoveAcceleration", 2f, "How long it takes the Rolling Giant to get to its movement speed. in seconds");
			MoveDecelerationEntry = _config.Bind<float>("2. AI Settings", "MoveDeceleration", 0.5f, "How long it takes the Rolling Giant to stop moving in seconds.");
			RotateToLookAtPlayerEntry = _config.Bind<bool>("2. AI Settings", "RotateToLookAtPlayer", true, "If the Rolling Giant should rotate to look at the player.");
			DelayBeforeLookingAtPlayerEntry = _config.Bind<float>("2. AI Settings", "DelayBeforeLookingAtPlayer", 2f, "The delay before the Rolling Giant looks at the player in seconds.");
			LookAtPlayerDurationEntry = _config.Bind<float>("2. AI Settings", "LookAtPlayerDuration", 3f, "The duration the Rolling Giant looks at the player in seconds.");
			RandomlyMoveWhenLooking_WaitTimeMinEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "WaitTimeMin", 1f, "The minimum duration in seconds that the Rolling Giant waits before moving again.");
			RandomlyMoveWhenLooking_WaitTimeMaxEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "WaitTimeMax", 3f, "The maximum duration in seconds that the Rolling Giant waits before moving again.");
			RandomlyMoveWhenLooking_RandomMoveTimeMinEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "RandomMoveTimeMin", 1f, "The minimum duration in seconds that the Rolling Giant moves for.");
			RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "RandomMoveTimeMax", 3f, "The maximum duration in seconds that the Rolling Giant moves for.");
			LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry = _config.Bind<float>("AI.LookingTooLongKeepsAgro", "LookTimeBeforeAgro", 30f, "How long the player can look at the Rolling Giant before it starts chasing in seconds.");
			OnceSeenAgroAfterTimer_WaitTimeMinEntry = _config.Bind<float>("AI.OnceSeenAgroAfterTimer", "WaitTimeMin", 30f, "The minimum duration in seconds the Rolling Giant waits before chasing the player.");
			OnceSeenAgroAfterTimer_WaitTimeMaxEntry = _config.Bind<float>("AI.OnceSeenAgroAfterTimer", "WaitTimeMax", 60f, "The minimum duration in seconds the Rolling Giant waits before chasing the player.");
			if (setValues)
			{
				GiantScaleInsideMin = GiantScaleInsideMinEntry.Value;
				GiantScaleInsideMax = GiantScaleInsideMaxEntry.Value;
				GiantScaleOutsideMin = GiantScaleOutsideMinEntry.Value;
				GiantScaleOutsideMax = GiantScaleOutsideMaxEntry.Value;
				SpawnIn = SpawnInEntry.Value;
				SpawnInOutsideChance = SpawnInOutsideChanceEntry.Value;
				SpawnInAny = SpawnInAnyEntry.Value;
				SpawnInAnyChance = SpawnInAnyChanceEntry.Value;
				SpawnInAnyOutsideChance = SpawnInAnyOutsideChanceEntry.Value;
				CanSpawnInside = CanSpawnInsideEntry.Value;
				CanSpawnOutside = CanSpawnOutsideEntry.Value;
				DisableOutsideAtNight = DisableOutsideAtNightEntry.Value;
				MaxPerLevel = MaxPerLevelEntry.Value;
				SpawnPosterIn = SpawnPosterInEntry.Value;
				AiType = AiTypeEntry.Value;
				MoveSpeed = MoveSpeedEntry.Value;
				MoveAcceleration = MoveAccelerationEntry.Value;
				MoveDeceleration = MoveDecelerationEntry.Value;
				RotateToLookAtPlayer = RotateToLookAtPlayerEntry.Value;
				DelayBeforeLookingAtPlayer = DelayBeforeLookingAtPlayerEntry.Value;
				LookAtPlayerDuration = LookAtPlayerDurationEntry.Value;
				RandomlyMoveWhenLooking_WaitTimeMin = RandomlyMoveWhenLooking_WaitTimeMinEntry.Value;
				RandomlyMoveWhenLooking_WaitTimeMax = RandomlyMoveWhenLooking_WaitTimeMaxEntry.Value;
				RandomlyMoveWhenLooking_RandomMoveTimeMin = RandomlyMoveWhenLooking_RandomMoveTimeMinEntry.Value;
				RandomlyMoveWhenLooking_RandomMoveTimeMax = RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry.Value;
				LookingTooLongKeepsAgro_LookTimeBeforeAgro = LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry.Value;
				OnceSeenAgroAfterTimer_WaitTimeMin = OnceSeenAgroAfterTimer_WaitTimeMinEntry.Value;
				OnceSeenAgroAfterTimer_WaitTimeMax = OnceSeenAgroAfterTimer_WaitTimeMaxEntry.Value;
				SetCurrentAi();
			}
			Plugin.Log.LogInfo((object)"Config reloaded.");
		}

		private static T GetAttributeOfType<T>(Enum enumVal) where T : Attribute
		{
			object[] customAttributes = enumVal.GetType().GetMember(enumVal.ToString())[0].GetCustomAttributes(typeof(T), inherit: false);
			if (customAttributes.Length == 0)
			{
				return null;
			}
			return (T)customAttributes[0];
		}

		public static SharedAiSettings GetSharedAiSettings()
		{
			SharedAiSettings result = default(SharedAiSettings);
			result.moveSpeed = SyncedInstance<CustomConfig>.Instance.MoveSpeed;
			result.moveAcceleration = SyncedInstance<CustomConfig>.Instance.MoveAcceleration;
			result.moveDeceleration = SyncedInstance<CustomConfig>.Instance.MoveDeceleration;
			result.rotateToLookAtPlayer = SyncedInstance<CustomConfig>.Instance.RotateToLookAtPlayer;
			result.delayBeforeLookingAtPlayer = SyncedInstance<CustomConfig>.Instance.DelayBeforeLookingAtPlayer;
			result.lookAtPlayerDuration = SyncedInstance<CustomConfig>.Instance.LookAtPlayerDuration;
			return result;
		}

		public static void RequestSync()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<CustomConfig>.IsClient)
			{
				Plugin.Log.LogError((object)"Config sync error: Not a client.");
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<CustomConfig>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<CustomConfig>.MessageManager.SendNamedMessage("RollingGiant_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
				Plugin.Log.LogInfo((object)"Config sync request sent.");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<CustomConfig>.IsHost)
			{
				Plugin.Log.LogError((object)"Config sync error: Not a host.");
				return;
			}
			Plugin.Log.LogInfo((object)$"Config sync request received from client: {clientId}");
			byte[] array = SyncedInstance<CustomConfig>.SerializeToBytes(SyncedInstance<CustomConfig>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<CustomConfig>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<CustomConfig>.MessageManager.SendNamedMessage("RollingGiant_OnReceiveConfigSync", clientId, val, (NetworkDelivery)4);
				Plugin.Log.LogInfo((object)$"Config sync sent to client: {clientId}");
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

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

		public static void SetCurrentAi()
		{
			if (Object.op_Implicit((Object)(object)NetworkHandler.Instance))
			{
				RollingGiantAiType aiType = NetworkHandler.AiType;
				SharedAiSettings sharedAiSettings2;
				switch (aiType)
				{
				case RollingGiantAiType.Coilhead:
					sharedAiSettings2 = GetSharedAiSettings();
					break;
				case RollingGiantAiType.InverseCoilhead:
					sharedAiSettings2 = GetSharedAiSettings();
					break;
				case RollingGiantAiType.RandomlyMoveWhileLooking:
				{
					SharedAiSettings sharedAiSettings = GetSharedAiSettings();
					sharedAiSettings.waitTimeMin = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_WaitTimeMin;
					sharedAiSettings.waitTimeMax = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_WaitTimeMax;
					sharedAiSettings.randomMoveTimeMin = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_RandomMoveTimeMin;
					sharedAiSettings.randomMoveTimeMax = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_RandomMoveTimeMax;
					sharedAiSettings2 = sharedAiSettings;
					break;
				}
				case RollingGiantAiType.LookingTooLongKeepsAgro:
				{
					SharedAiSettings sharedAiSettings = GetSharedAiSettings();
					sharedAiSettings.lookTimeBeforeAgro = SyncedInstance<CustomConfig>.Instance.LookingTooLongKeepsAgro_LookTimeBeforeAgro;
					sharedAiSettings2 = sharedAiSettings;
					break;
				}
				case RollingGiantAiType.FollowOnceAgro:
					sharedAiSettings2 = GetSharedAiSettings();
					break;
				case RollingGiantAiType.OnceSeenAgroAfterTimer:
				{
					SharedAiSettings sharedAiSettings = GetSharedAiSettings();
					sharedAiSettings.waitTimeMin = SyncedInstance<CustomConfig>.Instance.OnceSeenAgroAfterTimer_WaitTimeMin;
					sharedAiSettings.waitTimeMax = SyncedInstance<CustomConfig>.Instance.OnceSeenAgroAfterTimer_WaitTimeMax;
					sharedAiSettings2 = sharedAiSettings;
					break;
				}
				default:
					throw new ArgumentOutOfRangeException();
				}
				SharedAiSettings = sharedAiSettings2;
				Plugin.Log.LogInfo((object)$"[{aiType}]: {SharedAiSettings}");
			}
		}
	}
	public class GeneralSettings
	{
		public const string Name = "1. General Settings";

		public ConfigEntry<float> ChanceForGiant;

		public ConfigEntry<float> GiantScaleMin;

		public ConfigEntry<float> GiantScaleMax;

		public ConfigEntry<bool> SpawnInAllLevels;

		public ConfigEntry<bool> SpawnInLevelsWithCoilHead;

		public ConfigEntry<bool> SpawnInside;

		public ConfigEntry<bool> SpawnDaytime;

		public ConfigEntry<bool> SpawnOutside;

		public ConfigEntry<int> Version;

		public ConfigEntry<string> GotoPreviousAiTypeKey;

		public ConfigEntry<string> GotoNextAiTypeKey;

		public GeneralSettings(ConfigFile configFile)
		{
			ChanceForGiant = configFile.Bind<float>("1. General Settings", "ChanceForGiant", 0.4f, "0.0-1.0: Chance for a Rolling Giant to spawn. Higher means more chances for a Rolling Giant.");
			GiantScaleMin = configFile.Bind<float>("1. General Settings", "GiantScaleMin", 1f, "The minimum scale of the Rolling Giant.");
			GiantScaleMax = configFile.Bind<float>("1. General Settings", "GiantScaleMax", 1f, "The maximum scale of the Rolling Giant.");
			SpawnInAllLevels = configFile.Bind<bool>("1. General Settings", "SpawnInAllLevels", false, "If the Rolling Giant should spawn in all levels.");
			SpawnInLevelsWithCoilHead = configFile.Bind<bool>("1. General Settings", "SpawnInLevelsWithCoilHead", true, "If the Rolling Giant should spawn in levels with a Coilhead.");
			SpawnInside = configFile.Bind<bool>("1. General Settings", "SpawnInside", true, "If the Rolling Giant should spawn inside.");
			SpawnDaytime = configFile.Bind<bool>("1. General Settings", "SpawnDaytime", false, "If the Rolling Giant should spawn during the day.");
			SpawnOutside = configFile.Bind<bool>("1. General Settings", "SpawnOutside", false, "If the Rolling Giant should spawn outside.");
			Version = configFile.Bind<int>("z_Ignore", "__version", 0, "The version of this config file. Do not change this.");
			GotoPreviousAiTypeKey = configFile.Bind<string>("Dev", "GotoPreviousAiTypeKey", "<Keyboard>/numpad7", "The key to go to the previous AI type. This uses Unity's New Input System's key-bind names.");
			GotoNextAiTypeKey = configFile.Bind<string>("Dev", "GotoNextAiTypeKey", "<Keyboard>/numpad9", "The key to go to the next AI type. This uses Unity's New Input System's key-bind names.");
		}

		public float GetRandomScale(Random rng)
		{
			float num = (float)rng.NextDouble();
			float value = GiantScaleMin.Value;
			float value2 = GiantScaleMax.Value;
			return Mathf.Lerp(value, value2, num);
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

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

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

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

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

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

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

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

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

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
}
namespace RollingGiant.Patches
{
	[HarmonyPatch]
	public static class EnemyPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void RegisterEnemy(StartOfRound __instance)
		{
			SelectableLevel[] levels = __instance.levels;
			if (!__instance.allItemsList.itemsList.Contains(Plugin.PosterItem))
			{
				__instance.allItemsList.itemsList.Add(Plugin.PosterItem);
			}
			HandleSpawnScrap(levels);
			if (CustomConfig.SpawnInAny)
			{
				HandleSpawnInAny(levels);
			}
			else
			{
				HandleSpawnInSelection(levels);
			}
		}

		private static void HandleSpawnInSelection(SelectableLevel[] levels)
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			Plugin.Log.LogMessage((object)("[HandleSpawnInSelection] Adding enemies to " + CustomConfig.SpawnIn));
			(string, int)[] levelChances = GetLevelChances(CustomConfig.SpawnIn);
			foreach (SelectableLevel val in levels)
			{
				try
				{
					string text = val.PlanetName.ToLower().Replace(" ", string.Empty);
					(string, int)[] array = levelChances;
					for (int j = 0; j < array.Length; j++)
					{
						var (value, num) = array[j];
						if (text.Contains(value))
						{
							if (CustomConfig.CanSpawnInside && val.Enemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeInside))
							{
								val.Enemies.Add(new SpawnableEnemyWithRarity
								{
									enemyType = Plugin.EnemyTypeInside,
									rarity = num
								});
								Plugin.Log.LogMessage((object)$"Added {Plugin.EnemyTypeOutside.enemyName} to {val.PlanetName} with chance of {num} (inside)");
							}
							if (!CustomConfig.DisableOutsideAtNight && CustomConfig.CanSpawnOutside && val.OutsideEnemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeOutside))
							{
								val.OutsideEnemies.Add(new SpawnableEnemyWithRarity
								{
									enemyType = Plugin.EnemyTypeOutside,
									rarity = CustomConfig.SpawnInOutsideChance
								});
								Plugin.Log.LogMessage((object)$"Added {Plugin.EnemyTypeOutside.enemyName} to {val.PlanetName} with chance of {CustomConfig.SpawnInOutsideChance} (outside)");
							}
							if (CustomConfig.DisableOutsideAtNight && CustomConfig.CanSpawnOutside && val.DaytimeEnemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeOutsideDaytime))
							{
								val.DaytimeEnemies.Add(new SpawnableEnemyWithRarity
								{
									enemyType = Plugin.EnemyTypeOutsideDaytime,
									rarity = CustomConfig.SpawnInOutsideChance
								});
								Plugin.Log.LogMessage((object)$"Added {Plugin.EnemyTypeOutsideDaytime.enemyName} to {val.PlanetName} with chance of {CustomConfig.SpawnInOutsideChance} (daytime)");
							}
						}
					}
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)$"Failed to add enemy to {val.PlanetName}!\n{arg}");
				}
			}
		}

		private static void HandleSpawnInAny(SelectableLevel[] levels)
		{
			//IL_0064: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missi

ShipLoot/ShipLoot.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ShipLoot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("ShipLoot")]
[assembly: AssemblyCopyright("Copyright © tinyhoot 2023")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ShipLoot
{
	[BepInPlugin("com.github.tinyhoot.ShipLoot", "ShipLoot", "1.0")]
	internal class ShipLoot : BaseUnityPlugin
	{
		public const string GUID = "com.github.tinyhoot.ShipLoot";

		public const string NAME = "ShipLoot";

		public const string VERSION = "1.0";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("com.github.tinyhoot.ShipLoot").PatchAll(Assembly.GetExecutingAssembly());
		}
	}
}
namespace ShipLoot.Patches
{
	[HarmonyPatch]
	internal class HudManagerPatcher
	{
		private static GameObject _totalCounter;

		private static TextMeshProUGUI _textMesh;

		private static float _displayTimeLeft;

		private const float DisplayTime = 5f;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
		private static void OnScan(HUDManager __instance, CallbackContext context)
		{
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && __instance.CanPlayerScan() && !(__instance.playerPingingScan > -0.5f) && (StartOfRound.Instance.inShipPhase || GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom))
			{
				if (!Object.op_Implicit((Object)(object)_totalCounter))
				{
					CopyValueCounter();
				}
				float num = CalculateLootValue();
				((TMP_Text)_textMesh).text = $"SHIP: ${num:F0}";
				_displayTimeLeft = 5f;
				if (!_totalCounter.activeSelf)
				{
					((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(ShipLootCoroutine());
				}
			}
		}

		private static IEnumerator ShipLootCoroutine()
		{
			_totalCounter.SetActive(true);
			while (_displayTimeLeft > 0f)
			{
				float displayTimeLeft = _displayTimeLeft;
				_displayTimeLeft = 0f;
				yield return (object)new WaitForSeconds(displayTimeLeft);
			}
			_totalCounter.SetActive(false);
		}

		private static float CalculateLootValue()
		{
			List<GrabbableObject> list = (from obj in GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>()
				where ((Object)obj).name != "ClipboardManual" && ((Object)obj).name != "StickyNoteItem"
				select obj).ToList();
			ShipLoot.Log.LogDebug((object)"Calculating total ship scrap value.");
			CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)list, (Action<GrabbableObject>)delegate(GrabbableObject scrap)
			{
				ShipLoot.Log.LogDebug((object)$"{((Object)scrap).name} - ${scrap.scrapValue}");
			});
			return list.Sum((GrabbableObject scrap) => scrap.scrapValue);
		}

		private static void CopyValueCounter()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/ValueCounter");
			if (!Object.op_Implicit((Object)(object)val))
			{
				ShipLoot.Log.LogError((object)"Failed to find ValueCounter object to copy!");
			}
			_totalCounter = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false);
			_totalCounter.transform.Translate(0f, 1f, 0f);
			Vector3 localPosition = _totalCounter.transform.localPosition;
			_totalCounter.transform.localPosition = new Vector3(localPosition.x + 50f, -50f, localPosition.z);
			_textMesh = _totalCounter.GetComponentInChildren<TextMeshProUGUI>();
		}
	}
}

Skinwalkers/SkinwalkerMod.dll

Decompiled 8 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dissonance;
using Dissonance.Config;
using HarmonyLib;
using SkinwalkerMod.Properties;
using Steamworks;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SkinwalkerMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SkinwalkerMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fd4979a2-cef0-46af-8bf8-97e630b11475")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
namespace SkinwalkerMod
{
	internal class LogoManager : MonoBehaviour
	{
		private AssetBundle bundle;

		private readonly Logo[] logos = new Logo[6]
		{
			new Logo
			{
				fileName = "Teo",
				playerNames = new string[9] { "SAMMY", "paddy", "Ozias", "Teo", "Rugbug Redfern", "WuluKing", "Boolie", "TeaEditor", "FlashGamesNemesis" }
			},
			new Logo
			{
				fileName = "OfflineTV",
				playerNames = new string[3] { "Masayoshi", "QUARTERJADE", "DisguisedToast" }
			},
			new Logo
			{
				fileName = "Neuro",
				playerNames = new string[1] { "vedal" }
			},
			new Logo
			{
				fileName = "Mogul",
				playerNames = new string[2] { "ludwig", "AirCoots" }
			},
			new Logo
			{
				fileName = "Imp",
				playerNames = new string[1] { "camila" }
			},
			new Logo
			{
				fileName = "Iron",
				playerNames = new string[1] { "ironmouse" }
			}
		};

		private Image cachedHeader;

		private Image cachedLogoHeader;

		private void Awake()
		{
			try
			{
				bundle = AssetBundle.LoadFromMemory(Resources.logos);
				SceneManager.sceneLoaded += OnSceneLoaded;
			}
			catch (Exception ex)
			{
				SkinwalkerLogger.LogError("LogoManager Awake Error: " + ex.Message);
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			try
			{
				if (!(((Scene)(ref scene)).name == "MainMenu"))
				{
					return;
				}
				cachedHeader = GameObject.Find("HeaderImage").GetComponent<Image>();
				cachedLogoHeader = ((Component)GameObject.Find("Canvas/MenuContainer").transform.GetChild(0).GetChild(1)).GetComponent<Image>();
				string value = SteamClient.Name.ToString();
				Logo[] array = logos;
				foreach (Logo logo in array)
				{
					string[] playerNames = logo.playerNames;
					foreach (string text in playerNames)
					{
						if (text.Equals(value, StringComparison.OrdinalIgnoreCase))
						{
							((MonoBehaviour)this).StartCoroutine(I_ChangeLogo(bundle.LoadAsset<Sprite>("Assets/Logos/" + logo.fileName + ".png")));
							return;
						}
					}
				}
			}
			catch (Exception ex)
			{
				SkinwalkerLogger.LogError("LogoManager OnSceneLoaded Error: " + ex.Message + ". If you launched in LAN mode, then this is just gonna happen, it doesn't break anything so don't worry about it.");
			}
		}

		private IEnumerator I_ChangeLogo(Sprite sprite)
		{
			for (int i = 0; i < 20; i++)
			{
				if ((Object)(object)cachedHeader == (Object)null)
				{
					break;
				}
				if ((Object)(object)cachedLogoHeader == (Object)null)
				{
					break;
				}
				SetHeaderImage(sprite);
				yield return null;
			}
		}

		private void SetHeaderImage(Sprite sprite)
		{
			if (!((Object)(object)sprite == (Object)null))
			{
				cachedHeader.sprite = sprite;
				cachedLogoHeader.sprite = sprite;
			}
		}
	}
	internal class Logo
	{
		public string fileName;

		public string[] playerNames;
	}
	[BepInPlugin("RugbugRedfern.SkinwalkerMod", "Skinwalker Mod", "2.0.7")]
	internal class PluginLoader : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("RugbugRedfern.SkinwalkerMod");

		private const string modGUID = "RugbugRedfern.SkinwalkerMod";

		private const string modVersion = "2.0.7";

		private static bool initialized;

		public static PluginLoader Instance { get; private set; }

		private void Awake()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			if (initialized)
			{
				return;
			}
			initialized = true;
			Instance = this;
			harmony.PatchAll(Assembly.GetExecutingAssembly());
			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);
					}
				}
			}
			SkinwalkerLogger.Initialize("RugbugRedfern.SkinwalkerMod");
			SkinwalkerLogger.Log("SKINWALKER MOD STARTING UP 2.0.7");
			SkinwalkerConfig.InitConfig();
			SceneManager.sceneLoaded += SkinwalkerNetworkManagerHandler.ClientConnectInitializer;
			GameObject val = new GameObject("Skinwalker Mod");
			val.AddComponent<SkinwalkerModPersistent>();
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val);
			Logs.SetLogLevel((LogCategory)1, (LogLevel)4);
			Logs.SetLogLevel((LogCategory)3, (LogLevel)4);
			Logs.SetLogLevel((LogCategory)2, (LogLevel)4);
			GameObject val2 = new GameObject("Logo Manager");
			val2.AddComponent<LogoManager>();
			((Object)val2).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val2);
		}

		public void BindConfig<T>(ref ConfigEntry<T> config, string section, string key, T defaultValue, string description = "")
		{
			config = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description);
		}
	}
	internal class SkinwalkerBehaviour : MonoBehaviour
	{
		private AudioSource audioSource;

		public const float PLAY_INTERVAL_MIN = 15f;

		public const float PLAY_INTERVAL_MAX = 40f;

		private const float MAX_DIST = 100f;

		private float nextTimeToPlayAudio;

		private EnemyAI ai;

		public void Initialize(EnemyAI ai)
		{
			this.ai = ai;
			audioSource = ai.creatureVoice;
			SetNextTime();
		}

		private void Update()
		{
			if (Time.time > nextTimeToPlayAudio)
			{
				SetNextTime();
				AttemptPlaySound();
			}
		}

		private void AttemptPlaySound()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			float num = -1f;
			if (Object.op_Implicit((Object)(object)ai) && !ai.isEnemyDead)
			{
				if (((Object)((Component)ai).gameObject).name == "DressGirl(Clone)")
				{
					DressGirlAI val = (DressGirlAI)ai;
					if ((Object)(object)val.hauntingPlayer != (Object)(object)StartOfRound.Instance.localPlayerController)
					{
						SkinwalkerLogger.Log(((Object)this).name + " played voice line no (not haunted) EnemyAI: " + (object)ai);
						return;
					}
					if (!val.staringInHaunt && !((EnemyAI)val).moveTowardsDestination)
					{
						SkinwalkerLogger.Log(((Object)this).name + " played voice line no (not visible) EnemyAI: " + (object)ai);
						return;
					}
				}
				Vector3 val2 = (StartOfRound.Instance.localPlayerController.isPlayerDead ? ((Component)StartOfRound.Instance.spectateCamera).transform.position : ((Component)StartOfRound.Instance.localPlayerController).transform.position);
				if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.localPlayerController == (Object)null || (num = Vector3.Distance(val2, ((Component)this).transform.position)) < 100f)
				{
					AudioClip sample = SkinwalkerModPersistent.Instance.GetSample();
					if (Object.op_Implicit((Object)(object)sample))
					{
						SkinwalkerLogger.Log(((Object)this).name + " played voice line 1");
						audioSource.PlayOneShot(sample);
					}
					else
					{
						SkinwalkerLogger.Log(((Object)this).name + " played voice line 0");
					}
				}
				else
				{
					SkinwalkerLogger.Log(((Object)this).name + " played voice line no (too far away) " + num);
				}
			}
			else
			{
				SkinwalkerLogger.Log(((Object)this).name + " played voice line no (dead) EnemyAI: " + (object)ai);
			}
		}

		private void SetNextTime()
		{
			if (SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value <= 0f)
			{
				nextTimeToPlayAudio = Time.time + 100000000f;
			}
			else
			{
				nextTimeToPlayAudio = Time.time + Random.Range(15f, 40f) / SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value;
			}
		}

		private T CopyComponent<T>(T original, GameObject destination) where T : Component
		{
			Type type = ((object)original).GetType();
			Component val = destination.AddComponent(type);
			FieldInfo[] fields = type.GetFields();
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				fieldInfo.SetValue(val, fieldInfo.GetValue(original));
			}
			return (T)(object)((val is T) ? val : null);
		}
	}
	internal class SkinwalkerConfig
	{
		public static ConfigEntry<bool> VoiceEnabled_BaboonHawk;

		public static ConfigEntry<bool> VoiceEnabled_Bracken;

		public static ConfigEntry<bool> VoiceEnabled_BunkerSpider;

		public static ConfigEntry<bool> VoiceEnabled_Centipede;

		public static ConfigEntry<bool> VoiceEnabled_CoilHead;

		public static ConfigEntry<bool> VoiceEnabled_EyelessDog;

		public static ConfigEntry<bool> VoiceEnabled_ForestGiant;

		public static ConfigEntry<bool> VoiceEnabled_GhostGirl;

		public static ConfigEntry<bool> VoiceEnabled_GiantWorm;

		public static ConfigEntry<bool> VoiceEnabled_HoardingBug;

		public static ConfigEntry<bool> VoiceEnabled_Hygrodere;

		public static ConfigEntry<bool> VoiceEnabled_Jester;

		public static ConfigEntry<bool> VoiceEnabled_Masked;

		public static ConfigEntry<bool> VoiceEnabled_Nutcracker;

		public static ConfigEntry<bool> VoiceEnabled_SporeLizard;

		public static ConfigEntry<bool> VoiceEnabled_Thumper;

		public static ConfigEntry<bool> VoiceEnabled_OtherEnemies;

		public static ConfigEntry<float> VoiceLineFrequency;

		public static void InitConfig()
		{
			PluginLoader.Instance.BindConfig(ref VoiceLineFrequency, "Voice Settings", "VoiceLineFrequency", 1f, "1 is the default, and voice lines will occur every " + 15f.ToString("0") + " to " + 40f.ToString("0") + " seconds per enemy. Setting this to 2 means they will occur twice as often, 0.5 means half as often, etc.");
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_BaboonHawk, "Monster Voices", "Baboon Hawk", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Bracken, "Monster Voices", "Bracken", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_BunkerSpider, "Monster Voices", "Bunker Spider", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Centipede, "Monster Voices", "Centipede", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_CoilHead, "Monster Voices", "Coil Head", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_EyelessDog, "Monster Voices", "Eyeless Dog", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_ForestGiant, "Monster Voices", "Forest Giant", defaultValue: false);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_GhostGirl, "Monster Voices", "Ghost Girl", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_GiantWorm, "Monster Voices", "Giant Worm", defaultValue: false);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_HoardingBug, "Monster Voices", "Hoarding Bug", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Hygrodere, "Monster Voices", "Hygrodere", defaultValue: false);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Jester, "Monster Voices", "Jester", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Masked, "Monster Voices", "Masked", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Nutcracker, "Monster Voices", "Nutcracker", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_SporeLizard, "Monster Voices", "Spore Lizard", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_Thumper, "Monster Voices", "Thumper", defaultValue: true);
			PluginLoader.Instance.BindConfig(ref VoiceEnabled_OtherEnemies, "Monster Voices", "Other Enemies (Including Modded)", defaultValue: true);
			SkinwalkerLogger.Log("VoiceEnabled_BaboonHawk" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BaboonHawk.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Bracken" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Bracken.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_BunkerSpider" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BunkerSpider.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Centipede" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Centipede.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_CoilHead" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_CoilHead.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_EyelessDog" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_EyelessDog.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_ForestGiant" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_ForestGiant.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_GhostGirl" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GhostGirl.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_GiantWorm" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GiantWorm.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_HoardingBug" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_HoardingBug.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Hygrodere" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Hygrodere.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Jester" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Jester.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Masked" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Masked.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Nutcracker" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Nutcracker.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_SporeLizard" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_SporeLizard.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_Thumper" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Thumper.Value}]");
			SkinwalkerLogger.Log("VoiceEnabled_OtherEnemies" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_OtherEnemies.Value}]");
			SkinwalkerLogger.Log("VoiceLineFrequency" + $" VALUE LOADED FROM CONFIG: [{VoiceLineFrequency.Value}]");
		}
	}
	internal static class SkinwalkerLogger
	{
		internal static ManualLogSource logSource;

		public static void Initialize(string modGUID)
		{
			logSource = Logger.CreateLogSource(modGUID);
		}

		public static void Log(object message)
		{
			logSource.LogInfo(message);
		}

		public static void LogError(object message)
		{
			logSource.LogError(message);
		}

		public static void LogWarning(object message)
		{
			logSource.LogWarning(message);
		}
	}
	public class SkinwalkerModPersistent : MonoBehaviour
	{
		private string audioFolder;

		private List<AudioClip> cachedAudio = new List<AudioClip>();

		private float nextTimeToCheckFolder = 30f;

		private float nextTimeToCheckEnemies = 30f;

		private const float folderScanInterval = 8f;

		private const float enemyScanInterval = 5f;

		public static SkinwalkerModPersistent Instance { get; private set; }

		private void Awake()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			((Component)this).transform.position = Vector3.zero;
			SkinwalkerLogger.Log("Skinwalker Mod Object Initialized");
			audioFolder = Path.Combine(Application.dataPath, "..", "Dissonance_Diagnostics");
			EnableRecording();
			if (!Directory.Exists(audioFolder))
			{
				Directory.CreateDirectory(audioFolder);
			}
		}

		private void Start()
		{
			try
			{
				if (Directory.Exists(audioFolder))
				{
					Directory.Delete(audioFolder, recursive: true);
				}
			}
			catch (Exception message)
			{
				SkinwalkerLogger.Log(message);
			}
		}

		private void OnApplicationQuit()
		{
			DisableRecording();
		}

		private void EnableRecording()
		{
			DebugSettings.Instance.EnablePlaybackDiagnostics = true;
			DebugSettings.Instance.RecordFinalAudio = true;
		}

		private void Update()
		{
			if (Time.realtimeSinceStartup > nextTimeToCheckFolder)
			{
				nextTimeToCheckFolder = Time.realtimeSinceStartup + 8f;
				if (!Directory.Exists(audioFolder))
				{
					SkinwalkerLogger.Log("Audio folder not present. Don't worry about it, it will be created automatically when you play with friends. (" + audioFolder + ")");
					return;
				}
				string[] files = Directory.GetFiles(audioFolder);
				SkinwalkerLogger.Log($"Got audio file paths ({files.Length})");
				string[] array = files;
				foreach (string path in array)
				{
					((MonoBehaviour)this).StartCoroutine(LoadWavFile(path, delegate(AudioClip audioClip)
					{
						cachedAudio.Add(audioClip);
					}));
				}
			}
			if (!(Time.realtimeSinceStartup > nextTimeToCheckEnemies))
			{
				return;
			}
			nextTimeToCheckEnemies = Time.realtimeSinceStartup + 5f;
			EnemyAI[] array2 = Object.FindObjectsOfType<EnemyAI>(true);
			EnemyAI[] array3 = array2;
			SkinwalkerBehaviour skinwalkerBehaviour = default(SkinwalkerBehaviour);
			foreach (EnemyAI val in array3)
			{
				SkinwalkerLogger.Log("IsEnemyEnabled " + ((Object)val).name + " " + IsEnemyEnabled(val));
				if (IsEnemyEnabled(val) && !((Component)val).TryGetComponent<SkinwalkerBehaviour>(ref skinwalkerBehaviour))
				{
					((Component)val).gameObject.AddComponent<SkinwalkerBehaviour>().Initialize(val);
				}
			}
		}

		private bool IsEnemyEnabled(EnemyAI enemy)
		{
			if ((Object)(object)enemy == (Object)null)
			{
				return false;
			}
			return ((Object)((Component)enemy).gameObject).name switch
			{
				"MaskedPlayerEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Masked.Value, 
				"NutcrackerEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Nutcracker.Value, 
				"BaboonHawkEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BaboonHawk.Value, 
				"Flowerman(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Bracken.Value, 
				"SandSpider(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BunkerSpider.Value, 
				"RedLocustBees(Clone)" => false, 
				"Centipede(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Centipede.Value, 
				"SpringMan(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_CoilHead.Value, 
				"MouthDog(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_EyelessDog.Value, 
				"ForestGiant(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_ForestGiant.Value, 
				"DressGirl(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GhostGirl.Value, 
				"SandWorm(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GiantWorm.Value, 
				"HoarderBug(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_HoardingBug.Value, 
				"Blob(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Hygrodere.Value, 
				"JesterEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Jester.Value, 
				"PufferEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_SporeLizard.Value, 
				"Crawler(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Thumper.Value, 
				"DocileLocustBees(Clone)" => false, 
				"DoublewingedBird(Clone)" => false, 
				_ => SkinwalkerNetworkManager.Instance.VoiceEnabled_OtherEnemies.Value, 
			};
		}

		internal IEnumerator LoadWavFile(string path, Action<AudioClip> callback)
		{
			UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			try
			{
				yield return www.SendWebRequest();
				if ((int)www.result == 1)
				{
					SkinwalkerLogger.Log("Loaded clip from path " + path);
					AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www);
					if (audioClip.length > 0.9f)
					{
						callback(audioClip);
					}
					try
					{
						File.Delete(path);
					}
					catch (Exception e)
					{
						SkinwalkerLogger.LogWarning(e);
					}
				}
			}
			finally
			{
				((IDisposable)www)?.Dispose();
			}
		}

		private void DisableRecording()
		{
			DebugSettings.Instance.EnablePlaybackDiagnostics = false;
			DebugSettings.Instance.RecordFinalAudio = false;
			if (Directory.Exists(audioFolder))
			{
				Directory.Delete(audioFolder, recursive: true);
			}
		}

		public AudioClip GetSample()
		{
			while (cachedAudio.Count > 200)
			{
				cachedAudio.RemoveAt(Random.Range(0, cachedAudio.Count));
			}
			if (cachedAudio.Count > 0)
			{
				int index = Random.Range(0, cachedAudio.Count - 1);
				AudioClip result = cachedAudio[index];
				cachedAudio.RemoveAt(index);
				return result;
			}
			return null;
		}

		public void ClearCache()
		{
			cachedAudio.Clear();
		}
	}
	internal static class SkinwalkerNetworkManagerHandler
	{
		internal static void ClientConnectInitializer(Scene sceneName, LoadSceneMode sceneEnum)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (((Scene)(ref sceneName)).name == "SampleSceneRelay")
			{
				GameObject val = new GameObject("SkinwalkerNetworkManager");
				val.AddComponent<NetworkObject>();
				val.AddComponent<SkinwalkerNetworkManager>();
				Debug.Log((object)"Initialized SkinwalkerNetworkManager");
			}
		}
	}
	internal class SkinwalkerNetworkManager : NetworkBehaviour
	{
		public NetworkVariable<bool> VoiceEnabled_BaboonHawk = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Bracken = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_BunkerSpider = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Centipede = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_CoilHead = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_EyelessDog = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_ForestGiant = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_GhostGirl = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_GiantWorm = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_HoardingBug = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Hygrodere = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Jester = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Masked = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Nutcracker = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_SporeLizard = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_Thumper = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> VoiceEnabled_OtherEnemies = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<float> VoiceLineFrequency = new NetworkVariable<float>(1f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static SkinwalkerNetworkManager Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			if (GameNetworkManager.Instance.isHostingGame)
			{
				VoiceEnabled_BaboonHawk.Value = SkinwalkerConfig.VoiceEnabled_BaboonHawk.Value;
				VoiceEnabled_Bracken.Value = SkinwalkerConfig.VoiceEnabled_Bracken.Value;
				VoiceEnabled_BunkerSpider.Value = SkinwalkerConfig.VoiceEnabled_BunkerSpider.Value;
				VoiceEnabled_Centipede.Value = SkinwalkerConfig.VoiceEnabled_Centipede.Value;
				VoiceEnabled_CoilHead.Value = SkinwalkerConfig.VoiceEnabled_CoilHead.Value;
				VoiceEnabled_EyelessDog.Value = SkinwalkerConfig.VoiceEnabled_EyelessDog.Value;
				VoiceEnabled_ForestGiant.Value = SkinwalkerConfig.VoiceEnabled_ForestGiant.Value;
				VoiceEnabled_GhostGirl.Value = SkinwalkerConfig.VoiceEnabled_GhostGirl.Value;
				VoiceEnabled_GiantWorm.Value = SkinwalkerConfig.VoiceEnabled_GiantWorm.Value;
				VoiceEnabled_HoardingBug.Value = SkinwalkerConfig.VoiceEnabled_HoardingBug.Value;
				VoiceEnabled_Hygrodere.Value = SkinwalkerConfig.VoiceEnabled_Hygrodere.Value;
				VoiceEnabled_Jester.Value = SkinwalkerConfig.VoiceEnabled_Jester.Value;
				VoiceEnabled_Masked.Value = SkinwalkerConfig.VoiceEnabled_Masked.Value;
				VoiceEnabled_Nutcracker.Value = SkinwalkerConfig.VoiceEnabled_Nutcracker.Value;
				VoiceEnabled_SporeLizard.Value = SkinwalkerConfig.VoiceEnabled_SporeLizard.Value;
				VoiceEnabled_Thumper.Value = SkinwalkerConfig.VoiceEnabled_Thumper.Value;
				VoiceEnabled_OtherEnemies.Value = SkinwalkerConfig.VoiceEnabled_OtherEnemies.Value;
				VoiceLineFrequency.Value = SkinwalkerConfig.VoiceLineFrequency.Value;
				SkinwalkerLogger.Log("HOST SENDING CONFIG TO CLIENTS");
			}
			SkinwalkerLogger.Log("SkinwalkerNetworkManager Awake");
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).OnDestroy();
			SkinwalkerLogger.Log("SkinwalkerNetworkManager OnDestroy");
			SkinwalkerModPersistent.Instance?.ClearCache();
		}

		protected override void __initializeVariables()
		{
			if (VoiceEnabled_BaboonHawk == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BaboonHawk cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_BaboonHawk).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk, "VoiceEnabled_BaboonHawk");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk);
			if (VoiceEnabled_Bracken == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Bracken cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Bracken).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Bracken, "VoiceEnabled_Bracken");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Bracken);
			if (VoiceEnabled_BunkerSpider == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BunkerSpider cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_BunkerSpider).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider, "VoiceEnabled_BunkerSpider");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider);
			if (VoiceEnabled_Centipede == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Centipede cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Centipede).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Centipede, "VoiceEnabled_Centipede");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Centipede);
			if (VoiceEnabled_CoilHead == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_CoilHead cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_CoilHead).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_CoilHead, "VoiceEnabled_CoilHead");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_CoilHead);
			if (VoiceEnabled_EyelessDog == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_EyelessDog cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_EyelessDog).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_EyelessDog, "VoiceEnabled_EyelessDog");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_EyelessDog);
			if (VoiceEnabled_ForestGiant == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_ForestGiant cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_ForestGiant).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_ForestGiant, "VoiceEnabled_ForestGiant");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_ForestGiant);
			if (VoiceEnabled_GhostGirl == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GhostGirl cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_GhostGirl).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GhostGirl, "VoiceEnabled_GhostGirl");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GhostGirl);
			if (VoiceEnabled_GiantWorm == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GiantWorm cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_GiantWorm).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GiantWorm, "VoiceEnabled_GiantWorm");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GiantWorm);
			if (VoiceEnabled_HoardingBug == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_HoardingBug cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_HoardingBug).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_HoardingBug, "VoiceEnabled_HoardingBug");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_HoardingBug);
			if (VoiceEnabled_Hygrodere == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Hygrodere cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Hygrodere).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Hygrodere, "VoiceEnabled_Hygrodere");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Hygrodere);
			if (VoiceEnabled_Jester == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Jester cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Jester).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Jester, "VoiceEnabled_Jester");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Jester);
			if (VoiceEnabled_Masked == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Masked cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Masked).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Masked, "VoiceEnabled_Masked");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Masked);
			if (VoiceEnabled_Nutcracker == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Nutcracker cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Nutcracker).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Nutcracker, "VoiceEnabled_Nutcracker");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Nutcracker);
			if (VoiceEnabled_SporeLizard == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_SporeLizard cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_SporeLizard).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_SporeLizard, "VoiceEnabled_SporeLizard");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_SporeLizard);
			if (VoiceEnabled_Thumper == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Thumper cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_Thumper).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Thumper, "VoiceEnabled_Thumper");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Thumper);
			if (VoiceEnabled_OtherEnemies == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_OtherEnemies cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceEnabled_OtherEnemies).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_OtherEnemies, "VoiceEnabled_OtherEnemies");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_OtherEnemies);
			if (VoiceLineFrequency == null)
			{
				throw new Exception("SkinwalkerNetworkManager.VoiceLineFrequency cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)VoiceLineFrequency).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceLineFrequency, "VoiceLineFrequency");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceLineFrequency);
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "SkinwalkerNetworkManager";
		}
	}
}
namespace SkinwalkerMod.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

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

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

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

		internal Resources()
		{
		}
	}
}

StrangeObjects/StrangeObjects.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dissonance.Integrations.Unity_NFGO;
using GameNetcodeStuff;
using HarmonyLib;
using StrangeObjects.Patches;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StrangeObjects")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StrangeObjects")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e7e087a1-2426-4476-9b63-af35329e5ac2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StrangeObjects
{
	[BepInPlugin("Bits.StrangeObjects", "Strange Objects", "1.2.0.0")]
	public class StrangeObjectsBase : BaseUnityPlugin
	{
		private const string modGUID = "Bits.StrangeObjects";

		private const string modName = "Strange Objects";

		private const string modVersion = "1.2.0.0";

		private readonly Harmony harmony = new Harmony("Bits.StrangeObjects");

		private static StrangeObjectsBase Instance;

		internal ManualLogSource mls;

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

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

		public static ConfigEntry<bool> EnableCurseOfPain { get; private set; }

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

		public static ConfigEntry<bool> EnableCurseOfSight { get; private set; }

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

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

		public static ConfigEntry<bool> EnableCurseOfSloth { get; private set; }

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

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

		public static ConfigEntry<bool> EnableCurseOfMidas { get; private set; }

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

		public static ConfigEntry<bool> EnableCurseOfVoice { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Bits.StrangeObjects");
			StrangeObjectSpawnRate = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SpawnRate", 20, "Probability of a scrap item being strange. 20 means 20% chance. Range 1-100");
			StrangeObjectValueMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ValueMultiplier", 0.3f, "Controls how much value strange objects have. 0.3 is 30% higher value. Range 0.0-infinity");
			EnableCurseOfPain = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Pain", "EnableCurseofPain", true, "Disables curse if false");
			PainLevelOnePlayerDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Curse of Pain", "Level1Pain", 40, "Damage done to player from level one pain curse. Default is 40 same as falling down a cliff twice.");
			EnableCurseOfSight = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Sight", "EnableCurseofSight", true, "Disables curse if false");
			SightLevelOneDrunkDebuff = ((BaseUnityPlugin)this).Config.Bind<float>("Curse of Sight", "Level1DrunkDebuff", 0.2f, "Percentage of Drunkness for Level 1. Default is 20% or 0.2. Range 0.0-1.0");
			SightLevelTwoDrunkDebuff = ((BaseUnityPlugin)this).Config.Bind<float>("Curse of Sight", "Level2DrunkDebuff", 1f, "Percentage of Drunkness for Level 2. Default is 100% or 1.0. Range 0.0-1.0");
			EnableCurseOfSloth = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Sloth", "EnableCurseofSloth", true, "Disables curse if false");
			SlothLevelOneMovementDebuff = ((BaseUnityPlugin)this).Config.Bind<float>("Curse of Sloth", "Level1MovementDebuff", 0.75f, "Percentage of Movement Speed after Level 1 Debuff. Default is 75% or 0.75. Range 0.0-1.0");
			SlothLevelTwoMovementDebuff = ((BaseUnityPlugin)this).Config.Bind<float>("Curse of Sloth", "Level2MovementDebuff", 0.5f, "Percentage of Movement Speed after Level 2 Debuff. Default is 50% or 0.5. Range 0.0-1.0");
			EnableCurseOfMidas = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Midas", "EnableCurseofMidas", true, "Disables curse if false");
			MidasMaxScrapValue = ((BaseUnityPlugin)this).Config.Bind<int>("Curse of Midas", "MaxValueShinyObjects", 100, "This is the maximum scrap value a shiny object can randomly roll");
			EnableCurseOfVoice = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Voice", "EnableCurseofVoice", false, "Disables curse if false");
			harmony.PatchAll(typeof(StrangeObjectsBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(SpawnScrapInLevelPatch));
			harmony.PatchAll(typeof(GrabbleObjectPatch));
			harmony.PatchAll(typeof(HUDManagerPatch));
			harmony.PatchAll(typeof(NegativeEffectPatch));
			harmony.PatchAll(typeof(ShipLeavingPatch));
			harmony.PatchAll(typeof(VoiceRefreshPatch));
			harmony.PatchAll(typeof(SyncScrapValuesPatch));
			harmony.PatchAll(typeof(PlaceObjectPatch));
			harmony.PatchAll(typeof(DropAllItemsPatch));
		}
	}
}
namespace StrangeObjects.Patches
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class DropAllItemsPatch
	{
		[HarmonyPostfix]
		private static void removeCurseEffectPatch(ref float ___drunkness, ref float ___movementSpeed)
		{
			___drunkness = 0f;
			___movementSpeed = 4.6f;
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				GameNetworkManager.Instance.localPlayerController.maxSlideFriction = 0f;
				GameNetworkManager.Instance.localPlayerController.voiceMuffledByEnemy = false;
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbleObjectPatch
	{
		[HarmonyPatch("SetScrapValue")]
		[HarmonyPostfix]
		private static void SubtextPatch(ref GrabbableObject __instance, ref Item ___itemProperties)
		{
			if (__instance.scrapValue < 900 && !(___itemProperties.batteryUsage >= 900f))
			{
				return;
			}
			List<string> list = new List<string> { "Strange", "Painful", "Sloth", "Shiny", "Tipsy", "Silent" };
			if (__instance.scrapValue >= 9000)
			{
				___itemProperties.batteryUsage = 999f;
				GrabbableObject obj = __instance;
				obj.scrapValue -= 9999;
			}
			Random random = new Random(__instance.scrapValue + __instance.itemProperties.minValue + __instance.itemProperties.maxValue + (int)__instance.itemProperties.weight);
			char c = (char)(65 + random.Next(0, 26));
			string text = random.Next(0, 10).ToString() + random.Next(0, 10);
			ScanNodeProperties componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<ScanNodeProperties>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				string[] array = componentInChildren.headerText.Split(new char[1] { ' ' });
				if (array.Length != 0 && !list.Contains(array[0]))
				{
					componentInChildren.headerText = "Strange " + componentInChildren.headerText;
				}
				componentInChildren.subText = $"Value: ${__instance.scrapValue}" + " \nObject: " + c + "-" + text;
				componentInChildren.scrapValue = __instance.scrapValue;
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("UpdateScanNodes")]
		[HarmonyPostfix]
		private static void SubtextPatch(ref HUDManager __instance, ref TextMeshProUGUI[] ___scanElementText, ref RectTransform[] ___scanElements)
		{
			for (int i = 0; i < ___scanElements.Length; i++)
			{
				try
				{
					___scanElementText = ((Component)___scanElements[i]).gameObject.GetComponentsInChildren<TextMeshProUGUI>();
					if (___scanElementText.Length > 1)
					{
						string[] array = ((TMP_Text)___scanElementText[1]).text.Split(new char[1] { ' ' });
						if (array.Length > 2 && array[2] == "\nObject:")
						{
							((Component)___scanElements[i]).GetComponent<Animator>().SetInteger("colorNumber", 1);
						}
					}
				}
				catch (Exception arg)
				{
					Debug.LogError((object)$"Error in updatescanNodes F: {arg}");
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class NegativeEffectPatch
	{
		[HarmonyPatch("GrabObject")]
		[HarmonyPostfix]
		private static void grabObjectPatch(ref bool ___grabInvalidated, ref GrabbableObject ___currentlyGrabbingObject, ref float ___insanityLevel, ref float ___maxSlideFriction)
		{
			if (___grabInvalidated)
			{
				return;
			}
			if (___currentlyGrabbingObject.itemProperties.batteryUsage == 995f)
			{
				Random random = new Random();
				Random random2 = new Random();
				___currentlyGrabbingObject.scrapValue = random.Next(1, random2.Next(10, Math.Min(___currentlyGrabbingObject.itemProperties.maxValue, StrangeObjectsBase.MidasMaxScrapValue.Value)));
			}
			if (___currentlyGrabbingObject.itemProperties.batteryUsage == 999f)
			{
				Random random3 = new Random(___currentlyGrabbingObject.scrapValue + ___currentlyGrabbingObject.itemProperties.minValue + ___currentlyGrabbingObject.itemProperties.maxValue + (int)___currentlyGrabbingObject.itemProperties.weight);
				List<float> list = new List<float>();
				if (StrangeObjectsBase.EnableCurseOfPain.Value)
				{
					list.Add(998f);
				}
				if (StrangeObjectsBase.EnableCurseOfSight.Value)
				{
					list.Add(997f);
				}
				if (StrangeObjectsBase.EnableCurseOfSloth.Value)
				{
					list.Add(996f);
				}
				if (StrangeObjectsBase.EnableCurseOfMidas.Value)
				{
					list.Add(995f);
				}
				if (StrangeObjectsBase.EnableCurseOfVoice.Value)
				{
					list.Add(994f);
				}
				if (list.Count == 0)
				{
					return;
				}
				int index = random3.Next(0, list.Count);
				float batteryUsage = list[index];
				___currentlyGrabbingObject.itemProperties.batteryUsage = batteryUsage;
				if (___currentlyGrabbingObject.itemProperties.batteryUsage == 995f)
				{
					Random random4 = new Random();
					Random random5 = new Random();
					___currentlyGrabbingObject.scrapValue = random4.Next(1, random5.Next(10, Math.Min(___currentlyGrabbingObject.itemProperties.maxValue, StrangeObjectsBase.MidasMaxScrapValue.Value)));
				}
				___insanityLevel += 10f;
				ScanNodeProperties componentInChildren = ((Component)___currentlyGrabbingObject).gameObject.GetComponentInChildren<ScanNodeProperties>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					string[] array = componentInChildren.headerText.Split(new char[1] { ' ' });
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 997f)
					{
						array[0] = "Tipsy";
					}
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 998f)
					{
						array[0] = "Painful";
					}
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 996f)
					{
						array[0] = "Sloth";
					}
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 995f)
					{
						array[0] = "Shiny";
					}
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 994f)
					{
						array[0] = "Silent";
					}
					componentInChildren.headerText = string.Join(" ", array);
				}
			}
			___currentlyGrabbingObject.SetScrapValue(___currentlyGrabbingObject.scrapValue);
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class PlaceObjectPatch
	{
		[HarmonyPostfix]
		private static void removeCurseEffectPatch(GrabbableObject placeObject, ref float ___drunkness, ref float ___movementSpeed)
		{
			if (placeObject.itemProperties.batteryUsage == 997f)
			{
				___drunkness = 0f;
			}
			if (placeObject.itemProperties.batteryUsage == 996f)
			{
				___movementSpeed = 4.6f;
			}
			if (placeObject.itemProperties.batteryUsage == 994f && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				GameNetworkManager.Instance.localPlayerController.maxSlideFriction = 0f;
				GameNetworkManager.Instance.localPlayerController.voiceMuffledByEnemy = false;
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void addNegativePatch(ref PlayerControllerB __instance, ref GrabbableObject[] ___ItemSlots, ref float ___maxSlideFriction, ref float ___drunkness, ref float ___movementSpeed, ref bool ___isPlayerDead, ref bool ___isPlayerControlled)
		{
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			if (___isPlayerDead || !___isPlayerControlled)
			{
				___drunkness = 0f;
				___movementSpeed = 4.6f;
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
				{
					GameNetworkManager.Instance.localPlayerController.maxSlideFriction = 0f;
				}
				return;
			}
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			int num6 = 0;
			List<int> list = new List<int>();
			for (int i = 0; i < ___ItemSlots.Length; i++)
			{
				if (!((Object)(object)___ItemSlots[i] == (Object)null))
				{
					if (___ItemSlots[i].itemProperties.batteryUsage == 998f)
					{
						num++;
						num2++;
						list.Add(i);
					}
					if (___ItemSlots[i].itemProperties.batteryUsage == 997f)
					{
						num++;
						num3++;
					}
					if (___ItemSlots[i].itemProperties.batteryUsage == 996f)
					{
						num++;
						num4++;
					}
					if (___ItemSlots[i].itemProperties.batteryUsage == 995f)
					{
						num++;
						num5++;
					}
					if (___ItemSlots[i].itemProperties.batteryUsage == 994f)
					{
						num++;
						num6++;
					}
				}
			}
			if (num3 == 1)
			{
				___drunkness = StrangeObjectsBase.SightLevelOneDrunkDebuff.Value;
			}
			if (num >= 2 && num3 >= 1)
			{
				___drunkness = StrangeObjectsBase.SightLevelTwoDrunkDebuff.Value;
			}
			if (num2 == 1)
			{
				__instance.DamagePlayer(StrangeObjectsBase.PainLevelOnePlayerDamage.Value, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				for (int j = 0; j < list.Count; j++)
				{
					___ItemSlots[list[j]].itemProperties.batteryUsage = 999f;
				}
			}
			if (num4 == 1)
			{
				___movementSpeed = 4.6f * StrangeObjectsBase.SlothLevelOneMovementDebuff.Value;
			}
			if (num >= 2 && num4 >= 1)
			{
				___movementSpeed = 4.6f * StrangeObjectsBase.SlothLevelTwoMovementDebuff.Value;
			}
			if (num6 == 1 && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				GameNetworkManager.Instance.localPlayerController.maxSlideFriction = -5f;
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
		}
	}
	[HarmonyPatch(typeof(ElevatorAnimationEvents))]
	internal class ShipLeavingPatch
	{
		[HarmonyPatch("ElevatorFullyRunning")]
		[HarmonyPostfix]
		private static void adjustMaxSlideFrictionPatch()
		{
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				GameNetworkManager.Instance.localPlayerController.drunkness = 0f;
				GameNetworkManager.Instance.localPlayerController.movementSpeed = 4.6f;
				GameNetworkManager.Instance.localPlayerController.maxSlideFriction = 0f;
				GameNetworkManager.Instance.localPlayerController.voiceMuffledByEnemy = false;
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class SpawnScrapInLevelPatch
	{
		private static FieldInfo f_someField = AccessTools.Field(typeof(GrabbableObject), "fallTime");

		private static FieldInfo f_someField_2 = AccessTools.Field(typeof(GrabbableObject), "scrapValue");

		private static FieldInfo f_someField_3 = AccessTools.Field(typeof(GrabbableObject), "itemProperties");

		private static FieldInfo f_someField_4 = AccessTools.Field(typeof(Item), "batteryUsage");

		private static FieldInfo f_someField_5 = AccessTools.Field(typeof(RoundManager), "scrapValueMultiplier");

		private static MethodInfo m_randomChance = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => randomChance()));

		private static MethodInfo m_multiValue = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => multiValue()));

		private static MethodInfo m_listCount = typeof(List<int>).GetProperty("Count").GetGetMethod();

		private static MethodInfo m_listGet = typeof(List<int>).GetProperty("Item").GetGetMethod();

		private static MethodInfo m_listSet = typeof(List<int>).GetProperty("Item").GetSetMethod();

		private static MethodInfo getComponentGenericMethod = AccessTools.Method(typeof(Component), "GetComponent", new Type[0], (Type[])null);

		private static MethodInfo m_component = getComponentGenericMethod.MakeGenericMethod(typeof(GrabbableObject));

		private static int myClamp(int value)
		{
			if (value < 1)
			{
				return 1;
			}
			if (value > 100)
			{
				return 100;
			}
			return value;
		}

		private static float multiValue()
		{
			return StrangeObjectsBase.StrangeObjectValueMultiplier.Value;
		}

		private static int randomChance()
		{
			Random random = new Random();
			int result = 0;
			if (random.Next(0, 100) < myClamp(StrangeObjectsBase.StrangeObjectSpawnRate.Value))
			{
				result = 1;
			}
			return result;
		}

		private static IEnumerable<CodeInstruction> Transpiler(ILGenerator generator, IEnumerable<CodeInstruction> instructions)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Expected O, but got Unknown
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Expected O, but got Unknown
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Expected O, but got Unknown
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Expected O, but got Unknown
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Expected O, but got Unknown
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Expected O, but got Unknown
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Expected O, but got Unknown
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Expected O, but got Unknown
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Expected O, but got Unknown
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Expected O, but got Unknown
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Expected O, but got Unknown
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Expected O, but got Unknown
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Expected O, but got Unknown
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			bool flag = false;
			bool flag2 = false;
			Label label = generator.DefineLabel();
			Label label2 = generator.DefineLabel();
			for (int i = 0; i < list.Count; i++)
			{
				if (CodeInstructionExtensions.StoresField(list[i], f_someField) && !flag)
				{
					list.Insert(i + 1, new CodeInstruction(OpCodes.Nop, (object)null)
					{
						labels = new List<Label> { label }
					});
					list.Insert(i + 1, new CodeInstruction(OpCodes.Stfld, (object)f_someField_5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Add, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_multiValue));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldfld, (object)f_someField_5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Beq_S, (object)label));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, (object)0));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_S, (object)1));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Stloc_S, (object)1));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_randomChance));
					flag = true;
				}
				if (CodeInstructionExtensions.StoresField(list[i], f_someField_2) && !flag2)
				{
					list.Insert(i + 1, new CodeInstruction(OpCodes.Nop, (object)null)
					{
						labels = new List<Label> { label2 }
					});
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listSet));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Add, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, (object)9999));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listGet));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Sub, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4_1, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listCount));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_2, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_2, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Sub, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4_1, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listCount));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_2, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_2, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Stfld, (object)f_someField_5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Sub, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_multiValue));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldfld, (object)f_someField_5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Beq_S, (object)label2));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, (object)0));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_S, (object)1));
					flag2 = true;
				}
			}
			return list;
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class SyncScrapValuesPatch
	{
		[HarmonyPostfix]
		private static void fixScrapTotalPatch(int[] allScrapValue, ref float ___totalScrapValueInLevel)
		{
			int num = 0;
			if (allScrapValue != null)
			{
				for (int i = 0; i < allScrapValue.Length; i++)
				{
					num = ((allScrapValue[i] < 9000) ? (num + allScrapValue[i]) : (num + (allScrapValue[i] - 9999)));
				}
			}
			___totalScrapValueInLevel = num;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class VoiceRefreshPatch
	{
		[HarmonyPatch("RefreshPlayerVoicePlaybackObjects")]
		[HarmonyPostfix]
		private static void addMufflePatch(ref PlayerControllerB[] ___allPlayerScripts)
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			PlayerVoiceIngameSettings[] array = Object.FindObjectsOfType<PlayerVoiceIngameSettings>(true);
			for (int i = 0; i < ___allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = ___allPlayerScripts[i];
				if (!val.isPlayerControlled && !val.isPlayerDead)
				{
					continue;
				}
				for (int j = 0; j < array.Length; j++)
				{
					if (array[j]._playerState == null)
					{
						array[j].FindPlayerIfNull();
						if (array[j]._playerState != null)
						{
						}
					}
					else if (((Behaviour)array[j]).isActiveAndEnabled && array[j]._playerState.Name == ((Component)val).gameObject.GetComponentInChildren<NfgoPlayer>().PlayerId)
					{
						val.voicePlayerState = array[j]._playerState;
						val.currentVoiceChatAudioSource = array[j].voiceAudio;
						val.currentVoiceChatIngameSettings = array[j];
						val.currentVoiceChatAudioSource.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[val.playerClientId];
						if (GameNetworkManager.Instance.localPlayerController.maxSlideFriction == -5f)
						{
							((Component)val.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 5f;
							OccludeAudio component = ((Component)val.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>();
							component.overridingLowPass = true;
							component.lowPassOverride = 500f;
							Debug.Log((object)$"Applied Muffle to player voice object #{j} and player object #{i}");
							val.voiceMuffledByEnemy = true;
						}
						else
						{
							((Component)val.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 1f;
							OccludeAudio component2 = ((Component)val.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>();
							component2.overridingLowPass = false;
							component2.lowPassOverride = 20000f;
							val.voiceMuffledByEnemy = false;
						}
					}
				}
			}
		}
	}
}