Decompiled source of DeathNote v0.4.2

DeathNote.dll

Decompiled 5 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 BepInEx.Logging;
using DeathNote.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UIElements;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DeathNote")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a3e19a600183d915fdb2541ca4af96c111140076")]
[assembly: AssemblyProduct("DeathNote")]
[assembly: AssemblyTitle("DeathNote")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace DeathNote
{
	public class DeathController : MonoBehaviour
	{
		private static ManualLogSource logger = DeathNoteBase.LoggerInstance;

		public static bool ShinigamiEyesActivated = false;

		public string? EnemyName;

		public EnemyAI EnemyToDie;

		public PlayerControllerB PlayerToDie = null;

		public static int MaxHealth = 100;

		public static int HalfHealth = MaxHealth / 2;

		public string causeOfDeathString;

		public string detailsString;

		public string TimeOfDeathString;

		public float TimeOfDeath;

		public static List<string> Details = new List<string> { "Heart Attack", "Decapitation", "Coil Decapitation", "Seizure", "Disappearance", "Mask", "Burn" };

		public static List<string> EnemyNames = new List<string>();

		public static List<string> ScannedEnemies = new List<string>();

		public static List<string> GetCauseOfDeathsAsStrings()
		{
			//IL_0009: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			CauseOfDeath val = (CauseOfDeath)0;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)10;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)3;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)1;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)13;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)8;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)9;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)11;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)15;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)2;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)7;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)12;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)6;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)14;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)4;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			val = (CauseOfDeath)5;
			list.Add(((object)(CauseOfDeath)(ref val)).ToString());
			return list;
		}

		public static CauseOfDeath GetCauseOfDeathFromString(string causeOfDeathString)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: 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_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: 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_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: 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_0272: Unknown result type (might be due to invalid IL or missing references)
			CauseOfDeath val = (CauseOfDeath)0;
			switch (causeOfDeathString.ToLower())
			{
			case "abandoned":
				val = (CauseOfDeath)10;
				break;
			case "blast":
				val = (CauseOfDeath)3;
				break;
			case "bludgeoning":
				val = (CauseOfDeath)1;
				break;
			case "burning":
				val = (CauseOfDeath)13;
				break;
			case "crushing":
				val = (CauseOfDeath)8;
				break;
			case "drowniing":
				val = (CauseOfDeath)9;
				break;
			case "electrocution":
				val = (CauseOfDeath)11;
				break;
			case "fan":
				val = (CauseOfDeath)15;
				break;
			case "gravity":
				val = (CauseOfDeath)2;
				break;
			case "gunshots":
				val = (CauseOfDeath)7;
				break;
			case "kicking":
				val = (CauseOfDeath)12;
				break;
			case "mauling":
				val = (CauseOfDeath)6;
				break;
			case "stabbing":
				val = (CauseOfDeath)14;
				break;
			case "strangulation":
				val = (CauseOfDeath)4;
				break;
			case "suffocation":
				val = (CauseOfDeath)5;
				break;
			case "unknown":
				val = (CauseOfDeath)0;
				break;
			}
			logger.LogDebug((object)$"Got cause of death: {val}");
			return val;
		}

		public void KillWithDeathType(CauseOfDeath causeOfDeath, int time)
		{
			logger.LogDebug((object)"In KillWithDeathType");
		}

		public IEnumerator StartKillTimerCoroutine()
		{
			logger.LogDebug((object)"In StartKillTimerCoroutine");
			Label lblEntityToDie = new Label();
			((VisualElement)lblEntityToDie).style.color = StyleColor.op_Implicit(Color.red);
			if ((Object)(object)PlayerToDie != (Object)null)
			{
				((TextElement)lblEntityToDie).text = PlayerToDie.playerUsername + ": " + causeOfDeathString + ", " + UIControllerScript.Instance.TimeToClock(TimeOfDeath);
			}
			else
			{
				((TextElement)lblEntityToDie).text = EnemyName + ": " + UIControllerScript.Instance.TimeToClock(TimeOfDeath);
			}
			if (lblEntityToDie == null)
			{
				logger.LogError((object)"lblEntityToDie is null");
			}
			ProgressBar pbTimeToDie = new ProgressBar();
			((VisualElement)pbTimeToDie).name = "pbTimeToDie";
			((AbstractProgressBar)pbTimeToDie).lowValue = 0f;
			((AbstractProgressBar)pbTimeToDie).highValue = TimeOfDeath - TimeOfDay.Instance.currentDayTime;
			((VisualElement)pbTimeToDie).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
			((AbstractProgressBar)pbTimeToDie).title = "Remaining Time";
			((VisualElement)UIControllerScript.Instance.svRight).Add((VisualElement)(object)lblEntityToDie);
			((VisualElement)UIControllerScript.Instance.svRight).Add((VisualElement)(object)pbTimeToDie);
			if (pbTimeToDie == null)
			{
				logger.LogError((object)"pbTimeToDie is null");
			}
			float elapsedTime = 0f;
			while (((AbstractProgressBar)pbTimeToDie).value < ((AbstractProgressBar)pbTimeToDie).highValue && !IsEntityDead())
			{
				elapsedTime += Time.deltaTime * TimeOfDay.Instance.globalTimeSpeedMultiplier;
				((AbstractProgressBar)pbTimeToDie).value = Mathf.Lerp(((AbstractProgressBar)pbTimeToDie).lowValue, ((AbstractProgressBar)pbTimeToDie).highValue, elapsedTime / ((AbstractProgressBar)pbTimeToDie).highValue);
				yield return null;
			}
			((VisualElement)UIControllerScript.Instance.svRight).Remove((VisualElement)(object)lblEntityToDie);
			((VisualElement)UIControllerScript.Instance.svRight).Remove((VisualElement)(object)pbTimeToDie);
			if ((Object)(object)PlayerToDie != (Object)null)
			{
				KillPlayer();
			}
			else
			{
				KillEnemy();
			}
		}

		public bool IsEntityDead()
		{
			if ((Object)(object)PlayerToDie != (Object)null)
			{
				if (PlayerToDie.isPlayerDead)
				{
					return true;
				}
			}
			else if (EnemyToDie.isEnemyDead)
			{
				return true;
			}
			return false;
		}

		public void KillPlayer()
		{
			if (PlayerToDie.isPlayerDead)
			{
				UIControllerScript.Instance.ShowResults(PlayerToDie.playerUsername + " has died already.");
				return;
			}
			logger.LogDebug((object)("Killing player " + PlayerToDie.playerUsername + ": " + causeOfDeathString + ", " + TimeOfDeathString));
			NetworkHandler.Instance.KillPlayerServerRpc(PlayerToDie.actualClientId, causeOfDeathString, detailsString);
		}

		public void KillEnemy()
		{
			if (IsEntityDead())
			{
				UIControllerScript.Instance.ShowResults(EnemyName + " has died already.");
				return;
			}
			try
			{
				EnemyToDie.enemyType.canDie = true;
				EnemyToDie.KillEnemyOnOwnerClient(false);
			}
			catch
			{
				logger.LogDebug((object)"Error while attempting to kill the enemy");
			}
		}
	}
	internal class DeathNoteBehavior : PhysicsProp
	{
		private static ManualLogSource logger = DeathNoteBase.LoggerInstance;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//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)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!buttonDown)
			{
				return;
			}
			logger.LogDebug((object)"Using item works!");
			UIControllerScript component = ((Component)this).GetComponent<UIControllerScript>();
			logger.LogDebug((object)"Got veMain");
			logger.LogMessage((object)((object)component.veMain.style.display).ToString());
			_ = component.veMain.style.display;
			if (false)
			{
				logger.LogDebug((object)"veMain.style.display is null");
			}
			else if (component.veMain.style.display == StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1))
			{
				if (DeathController.ShinigamiEyesActivated)
				{
					((VisualElement)component.btnActivateEyes).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
					((TextElement)component.lblSEDescription).text = "You have the shinigami eyes. You can now see entity names. This will reset after the round is over.";
					((VisualElement)component.lblSEDescription).style.color = StyleColor.op_Implicit(Color.red);
				}
				logger.LogDebug((object)"Showing UI");
				component.ShowUI();
			}
		}

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

		protected internal override string __getTypeName()
		{
			return "DeathNoteBehavior";
		}
	}
	public class NetworkHandler : NetworkBehaviour
	{
		private static ManualLogSource logger = DeathNoteBase.LoggerInstance;

		public static NetworkHandler Instance { get; private set; }

		public static PlayerControllerB CurrentClient => StartOfRound.Instance.localPlayerController;

		public override void OnNetworkSpawn()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				NetworkHandler instance = Instance;
				if (instance != null)
				{
					((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ServerRpc(RequireOwnership = false)]
		public void KillPlayerServerRpc(ulong clientId, string causeOfDeathString, string _details)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0095: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3178293882u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				bool flag = causeOfDeathString != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(causeOfDeathString, false);
				}
				bool flag2 = _details != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(_details, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3178293882u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				logger.LogDebug((object)"In ServerRpc KillPlayerServerRpc");
				if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
				{
					KillPlayerClientRpc(clientId, causeOfDeathString, _details);
				}
			}
		}

		[ClientRpc]
		private void KillPlayerClientRpc(ulong clientId, string causeOfDeathString, string _details)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0095: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: 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)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: 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)
			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(3581943848u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				bool flag = causeOfDeathString != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(causeOfDeathString, false);
				}
				bool flag2 = _details != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(_details, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3581943848u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			logger.LogDebug((object)"In ClientRpc KillPlayerClientRpc");
			if (CurrentClient.actualClientId == clientId)
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				CauseOfDeath causeOfDeathFromString = DeathController.GetCauseOfDeathFromString(causeOfDeathString);
				int num = DeathController.Details.IndexOf(_details);
				logger.LogDebug((object)$"Details: {num}");
				if (num == 4)
				{
					localPlayerController.KillPlayer(default(Vector3), false, causeOfDeathFromString, 0);
				}
				else
				{
					localPlayerController.KillPlayer(default(Vector3), true, causeOfDeathFromString, num);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((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
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3178293882u, new RpcReceiveHandler(__rpc_handler_3178293882));
			NetworkManager.__rpc_func_table.Add(3581943848u, new RpcReceiveHandler(__rpc_handler_3581943848));
		}

		private static void __rpc_handler_3178293882(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string causeOfDeathString = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref causeOfDeathString, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				string details = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref details, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandler)(object)target).KillPlayerServerRpc(clientId, causeOfDeathString, details);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3581943848(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string causeOfDeathString = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref causeOfDeathString, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				string details = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref details, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NetworkHandler)(object)target).KillPlayerClientRpc(clientId, causeOfDeathString, details);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "NetworkHandler";
		}
	}
	[HarmonyPatch]
	public class NetworkObjectManager
	{
		private static GameObject networkPrefab;

		private static ManualLogSource logger = DeathNoteBase.LoggerInstance;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = (GameObject)DeathNoteBase.DNAssetBundle.LoadAsset("Assets/DeathNote/NetworkHandlerDN.prefab");
				networkPrefab.AddComponent<NetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
	[BepInPlugin("Snowlance.DeathNote", "DeathNote", "0.4.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class DeathNoteBase : BaseUnityPlugin
	{
		private const string modGUID = "Snowlance.DeathNote";

		private const string modName = "DeathNote";

		private const string modVersion = "0.4.2";

		public static AssetBundle? DNAssetBundle;

		public static ManualLogSource LoggerInstance;

		private readonly Harmony harmony = new Harmony("Snowlance.DeathNote");

		public static ConfigEntry<int> configRarity;

		public static ConfigEntry<bool> configTimer;

		public static ConfigEntry<int> configTimerLength;

		public static ConfigEntry<bool> configAllowEarlySubmit;

		public static ConfigEntry<bool> configShowPlayerList;

		public static ConfigEntry<bool> configShinigamiEyes;

		public static ConfigEntry<bool> configPermanentEyes;

		public static ConfigEntry<bool> configAlwaysShowPlayerNames;

		public static ConfigEntry<bool> configShowEnemyNames;

		public static ConfigEntry<bool> configShowScannedEnemies;

		public static ConfigEntry<bool> configShowUnkillableEnemyNames;

		public static ConfigEntry<bool> configLockUI;

		public static DeathNoteBase PluginInstance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)PluginInstance == (Object)null)
			{
				PluginInstance = this;
			}
			LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger;
			LoggerInstance.LogDebug((object)"Plugin DeathNote loaded successfully.");
			NetcodePatcher();
			configRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Rarity", 5, "Rarity of the death note.");
			configTimer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Timer", true, "If picking the death details should have a time limit.\nWhen you enter a name and click submit, you'll have x in-game seconds to fill in a time and details before it adds the name to the book.");
			configTimerLength = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Timer Length", 40, "Timer length. 40 is lore accurate.");
			configAllowEarlySubmit = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Allow Early Submit", true, "Allows you to click submit again to add it to the book early. Turn this off if you want a cooldown mechanic.");
			configShowPlayerList = ((BaseUnityPlugin)this).Config.Bind<bool>("Accessibility", "Show PlayerList", false, "Show a dropdown list of players under the name input to select from instead.");
			configShinigamiEyes = ((BaseUnityPlugin)this).Config.Bind<bool>("Shinigami Eyes", "Shinigami Eyes", true, "Allows you to trade half of your max health for the ability to see certain entity names (configurable in Names section).\nEnemy names require you to scan them.");
			configPermanentEyes = ((BaseUnityPlugin)this).Config.Bind<bool>("Shinigami Eyes", "Permanent Eyes", false, "Makes Shinigami Eyes permanent. Disabling this will reset the ability at the end of every round.");
			configAlwaysShowPlayerNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Names", "Always Show Player Names", false, "Always shows player names above their head. Disabling this will only show player names when you have the Shinigami Eyes.");
			configShowEnemyNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Names", "ShowEnemyNames", true, "Allows you to see enemy names when scanning them if you have the Shinigami Eyes.");
			configShowScannedEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("Names", "ShowScannedEnemies", false, "Allows you to see scanned enemies as a list in the death note if you have the Shinigami Eyes.");
			configShowUnkillableEnemyNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Experimental", "Show Unkillable Enemy Names", false, "Allows you to see the names of enemies that are immortal. WARNING: Killing them can break things or cause bugs.");
			configLockUI = ((BaseUnityPlugin)this).Config.Bind<bool>("Experimental", "Lock UI", false, "Locks the UI when showing it which should help with renabling input when pressing certain keybinds.");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			DNAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "dn_assets"));
			LoggerInstance.LogDebug((object)("Got DNAssetBundle at: " + Path.Combine(directoryName, "dn_assets")));
			if ((Object)(object)DNAssetBundle == (Object)null)
			{
				LoggerInstance.LogError((object)"Failed to load custom assets.");
				return;
			}
			LoggerInstance.LogDebug((object)"Getting item");
			Item val = DNAssetBundle.LoadAsset<Item>("Assets/DeathNote/DeathNoteItem.asset");
			LoggerInstance.LogDebug((object)("Got item: " + ((Object)val).name));
			DeathNoteBehavior deathNoteBehavior = val.spawnPrefab.AddComponent<DeathNoteBehavior>();
			((GrabbableObject)deathNoteBehavior).grabbable = true;
			((GrabbableObject)deathNoteBehavior).grabbableToEnemies = true;
			((GrabbableObject)deathNoteBehavior).itemProperties = val;
			LoggerInstance.LogDebug((object)"Setting up UI");
			UIControllerScript uIControllerScript = val.spawnPrefab.AddComponent<UIControllerScript>();
			if ((Object)(object)uIControllerScript == (Object)null)
			{
				LoggerInstance.LogError((object)"uiController not found.");
				return;
			}
			LoggerInstance.LogDebug((object)"Got UIControllerScript");
			int value = configRarity.Value;
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Utilities.FixMixerGroups(val.spawnPrefab);
			Items.RegisterScrap(val, value, (LevelTypes)(-1));
			harmony.PatchAll();
			LoggerInstance.LogInfo((object)"Snowlance.DeathNote v0.4.2 has loaded!");
		}

		private void Update()
		{
			//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)
			if ((Object)(object)StartOfRound.Instance != (Object)null && DeathController.ShinigamiEyesActivated)
			{
				PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
				if (localPlayerController.health > DeathController.HalfHealth)
				{
					localPlayerController.DamagePlayer(localPlayerController.health - DeathController.HalfHealth, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
		}

		private static void NetcodePatcher()
		{
			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 class UIControllerScript : MonoBehaviour
	{
		private static ManualLogSource logger = DeathNoteBase.LoggerInstance;

		public static UIControllerScript Instance;

		private DeathController deathController;

		public VisualElement veMain;

		public ScrollView svRight;

		public int timeRemaining = DeathNoteBase.configTimerLength.Value;

		private bool verifying = false;

		private bool showingUI = false;

		public Label lblResult;

		public TextField txtName;

		public DropdownField dpdnPlayerList;

		public DropdownField dpdnScannedEnemiesList;

		public Button btnSubmit;

		public TextField txtTimeOfDeath;

		public DropdownField dpdnDeathType;

		public DropdownField dpdnDetails;

		public ProgressBar pbRemainingTime;

		public Label lblSETitle;

		public Label lblSEDescription;

		public Button btnActivateEyes;

		private void Start()
		{
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Expected O, but got Unknown
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0712: Unknown result type (might be due to invalid IL or missing references)
			//IL_0729: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0817: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)"UIControllerScript: Start()");
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			timeRemaining = DeathNoteBase.configTimerLength.Value;
			logger.LogDebug((object)"Getting UIDocument");
			UIDocument component = ((Component)this).GetComponent<UIDocument>();
			if ((Object)(object)component == (Object)null)
			{
				logger.LogError((object)"uiDocument not found.");
				return;
			}
			logger.LogDebug((object)"Getting visual tree asset");
			if ((Object)(object)component.visualTreeAsset == (Object)null)
			{
				logger.LogError((object)"visualTreeAsset not found.");
				return;
			}
			VisualElement val = (VisualElement)(object)component.visualTreeAsset.Instantiate();
			if (val == null)
			{
				logger.LogError((object)"root is null!");
				return;
			}
			logger.LogDebug((object)"Adding root");
			component.rootVisualElement.Add(val);
			if (component.rootVisualElement == null)
			{
				logger.LogError((object)"uiDocument.rootVisualElement not found.");
				return;
			}
			logger.LogDebug((object)"Got root");
			val = component.rootVisualElement;
			veMain = UQueryExtensions.Q<VisualElement>(component.rootVisualElement, "veMain", (string)null);
			veMain.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			if (veMain == null)
			{
				logger.LogError((object)"veMain not found.");
				return;
			}
			svRight = UQueryExtensions.Q<ScrollView>(component.rootVisualElement, "svRight", (string)null);
			if (svRight == null)
			{
				logger.LogError((object)"svRight not found.");
				return;
			}
			lblResult = UQueryExtensions.Q<Label>(val, "lblResult", (string)null);
			if (lblResult == null)
			{
				logger.LogError((object)"lblResult not found.");
				return;
			}
			txtName = UQueryExtensions.Q<TextField>(val, "txtName", (string)null);
			if (txtName == null)
			{
				logger.LogError((object)"txtName not found.");
				return;
			}
			if (DeathNoteBase.configShowPlayerList.Value)
			{
				dpdnPlayerList = UQueryExtensions.Q<DropdownField>(val, "dpdnPlayerList", (string)null);
				if (dpdnPlayerList == null)
				{
					logger.LogError((object)"dpdnPlayerList not found.");
					return;
				}
				((BasePopupField<string, string>)(object)dpdnPlayerList).choices.Add(" ");
				((BasePopupField<string, string>)(object)dpdnPlayerList).choices.AddRange((from x in StartOfRound.Instance.allPlayerScripts
					where x.isPlayerControlled
					select x.playerUsername).ToList());
				((VisualElement)dpdnPlayerList).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
			}
			if (DeathNoteBase.configShowScannedEnemies.Value)
			{
				dpdnScannedEnemiesList = UQueryExtensions.Q<DropdownField>(val, "dpdnScannedEnemiesList", (string)null);
				if (dpdnScannedEnemiesList == null)
				{
					logger.LogError((object)"dpdnScannedEnemiesList not found.");
					return;
				}
				((VisualElement)dpdnScannedEnemiesList).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
			}
			btnSubmit = UQueryExtensions.Q<Button>(val, "btnSubmit", (string)null);
			if (btnSubmit == null)
			{
				logger.LogError((object)"btnSubmit not found.");
				return;
			}
			txtTimeOfDeath = UQueryExtensions.Q<TextField>(val, "txtTimeOfDeath", (string)null);
			if (txtTimeOfDeath == null)
			{
				logger.LogError((object)"txtTimeOfDeath not found.");
				return;
			}
			dpdnDeathType = UQueryExtensions.Q<DropdownField>(val, "dpdnDeathType", (string)null);
			if (dpdnDeathType == null)
			{
				logger.LogError((object)"dpdnDeathType not found.");
				return;
			}
			((BasePopupField<string, string>)(object)dpdnDeathType).choices = DeathController.GetCauseOfDeathsAsStrings();
			((PopupField<string>)(object)dpdnDeathType).index = 0;
			dpdnDetails = UQueryExtensions.Q<DropdownField>(val, "dpdnDetails", (string)null);
			if (dpdnDetails == null)
			{
				logger.LogError((object)"dpdnDetails not found.");
				return;
			}
			((BasePopupField<string, string>)(object)dpdnDetails).choices = DeathController.Details;
			((PopupField<string>)(object)dpdnDetails).index = 0;
			lblSETitle = UQueryExtensions.Q<Label>(val, "lblSETitle", (string)null);
			if (lblSETitle == null)
			{
				logger.LogError((object)"lblSETitle not found.");
				return;
			}
			lblSEDescription = UQueryExtensions.Q<Label>(val, "lblSEDescription", (string)null);
			if (lblSEDescription == null)
			{
				logger.LogError((object)"lblSEDescription not found.");
				return;
			}
			if (DeathNoteBase.configPermanentEyes.Value)
			{
				Label obj = lblSEDescription;
				((TextElement)obj).text = ((TextElement)obj).text + "\nWARNING: This is permanent!";
			}
			else
			{
				Label obj2 = lblSEDescription;
				((TextElement)obj2).text = ((TextElement)obj2).text + "\nThis will reset at the end of the round.";
			}
			btnActivateEyes = UQueryExtensions.Q<Button>(val, "btnActivateEyes", (string)null);
			if (btnActivateEyes == null)
			{
				logger.LogError((object)"btnActivateEyes not found.");
				return;
			}
			txtTimeOfDeath = UQueryExtensions.Q<TextField>(val, "txtTimeOfDeath", (string)null);
			if (txtTimeOfDeath == null)
			{
				logger.LogError((object)"txtTimeOfDeath not found.");
				return;
			}
			VisualElement val2 = UQueryExtensions.Q<VisualElement>(val, "veLeft", (string)null);
			int num = val2.IndexOf((VisualElement)(object)txtTimeOfDeath);
			pbRemainingTime = new ProgressBar();
			((VisualElement)pbRemainingTime).name = "pbRemainingTime";
			((AbstractProgressBar)pbRemainingTime).title = "Time Remaining";
			((VisualElement)pbRemainingTime).style.flexGrow = StyleFloat.op_Implicit(0.9f);
			((VisualElement)pbRemainingTime).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			val2.Insert(num + 1, (VisualElement)(object)pbRemainingTime);
			pbRemainingTime = UQueryExtensions.Q<ProgressBar>(val, "pbRemainingTime", (string)null);
			if (pbRemainingTime == null)
			{
				logger.LogError((object)"pbRemainingTime not found.");
				return;
			}
			((AbstractProgressBar)pbRemainingTime).highValue = timeRemaining;
			lblSEDescription = UQueryExtensions.Q<Label>(val, "lblSEDescription", (string)null);
			if (lblSEDescription == null)
			{
				logger.LogError((object)"lblSEDescription not found.");
				return;
			}
			btnActivateEyes = UQueryExtensions.Q<Button>(val, "btnActivateEyes", (string)null);
			if (btnActivateEyes == null)
			{
				logger.LogError((object)"btnActivateEyes not found.");
				return;
			}
			if (!DeathNoteBase.configShinigamiEyes.Value)
			{
				((VisualElement)btnActivateEyes).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
				((VisualElement)lblSETitle).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
				((VisualElement)lblSEDescription).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			}
			logger.LogDebug((object)"Got Controls for UI");
			btnSubmit.clickable.clicked += BtnSubmitOnClick;
			((CallbackEventHandler)btnActivateEyes).RegisterCallback<ClickEvent>((EventCallback<ClickEvent>)BtnActivateEyesOnClick, (TrickleDown)0);
			((CallbackEventHandler)txtName).RegisterCallback<KeyUpEvent>((EventCallback<KeyUpEvent>)txtPlayerUsernameOnValueChanged, (TrickleDown)0);
			if (!DeathNoteBase.configTimer.Value)
			{
				((VisualElement)txtTimeOfDeath).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
				((BaseField<string>)(object)txtTimeOfDeath).value = "";
				((VisualElement)dpdnDeathType).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
				((PopupField<string>)(object)dpdnDeathType).index = 0;
				((VisualElement)dpdnDetails).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
				((PopupField<string>)(object)dpdnDetails).index = 0;
			}
			logger.LogDebug((object)"UIControllerScript: Start() complete");
		}

		private void Update()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (veMain.style.display == StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0) && ((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame)
			{
				HideUI();
			}
			if (showingUI)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
				StartOfRound.Instance.localPlayerUsingController = false;
				IngamePlayerSettings.Instance.playerInput.DeactivateInput();
				StartOfRound.Instance.localPlayerController.disableLookInput = true;
			}
		}

		public void ShowUI()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)"Showing UI");
			showingUI = true;
			veMain.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
			if (DeathController.ShinigamiEyesActivated)
			{
				((VisualElement)btnActivateEyes).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			}
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			StartOfRound.Instance.localPlayerUsingController = false;
			IngamePlayerSettings.Instance.playerInput.DeactivateInput();
			StartOfRound.Instance.localPlayerController.disableLookInput = true;
			if (DeathNoteBase.configShowScannedEnemies.Value)
			{
				((BasePopupField<string, string>)(object)dpdnScannedEnemiesList).choices.Clear();
				((BasePopupField<string, string>)(object)dpdnScannedEnemiesList).choices.Add("");
				((BasePopupField<string, string>)(object)dpdnScannedEnemiesList).choices.AddRange(DeathController.ScannedEnemies);
			}
		}

		public void HideUI()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)"Hiding UI");
			showingUI = false;
			veMain.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			Cursor.lockState = (CursorLockMode)1;
			Cursor.visible = false;
			StartOfRound.Instance.localPlayerUsingController = false;
			IngamePlayerSettings.Instance.playerInput.ActivateInput();
			StartOfRound.Instance.localPlayerController.disableLookInput = false;
		}

		public void ResetUI()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			((BaseField<string>)(object)txtName).value = "";
			((TextInputBaseField<string>)(object)txtName).isReadOnly = false;
			((BaseField<string>)(object)txtTimeOfDeath).value = "";
			((PopupField<string>)(object)dpdnDeathType).index = 0;
			((PopupField<string>)(object)dpdnDetails).index = 0;
			((VisualElement)pbRemainingTime).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			((AbstractProgressBar)pbRemainingTime).highValue = 0f;
			((AbstractProgressBar)pbRemainingTime).lowValue = 0f;
			((AbstractProgressBar)pbRemainingTime).value = 0f;
			if (DeathNoteBase.configTimer.Value)
			{
				((VisualElement)dpdnDeathType).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
				((VisualElement)dpdnDetails).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
				((VisualElement)txtTimeOfDeath).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			}
			if (DeathNoteBase.configShowPlayerList.Value)
			{
				((PopupField<string>)(object)dpdnPlayerList).index = 0;
			}
			verifying = false;
		}

		private void StartProgressBarTimer(DeathController deathController)
		{
			((MonoBehaviour)this).StartCoroutine(StartProgressBarTimerCoroutine(deathController));
		}

		private IEnumerator StartProgressBarTimerCoroutine(DeathController deathController)
		{
			((AbstractProgressBar)pbRemainingTime).lowValue = 0f;
			((AbstractProgressBar)pbRemainingTime).highValue = timeRemaining;
			((BaseField<string>)(object)txtTimeOfDeath).value = TimeToClock(TimeOfDay.Instance.currentDayTime + (float)timeRemaining);
			float elapsedTime = 0f;
			while (((AbstractProgressBar)pbRemainingTime).value < ((AbstractProgressBar)pbRemainingTime).highValue && verifying)
			{
				elapsedTime += Time.deltaTime * TimeOfDay.Instance.globalTimeSpeedMultiplier;
				((AbstractProgressBar)pbRemainingTime).value = Mathf.Lerp(((AbstractProgressBar)pbRemainingTime).lowValue, ((AbstractProgressBar)pbRemainingTime).highValue, elapsedTime / (float)timeRemaining);
				yield return null;
			}
			if (!deathController.IsEntityDead())
			{
				deathController.causeOfDeathString = ((BaseField<string>)(object)dpdnDeathType).value;
				deathController.detailsString = ((BaseField<string>)(object)dpdnDetails).value;
				deathController.TimeOfDeathString = ((TextInputBaseField<string>)(object)txtTimeOfDeath).text;
				float _timeOfDeath = ClockToTime(((TextInputBaseField<string>)(object)txtTimeOfDeath).text);
				if (_timeOfDeath == -1f || !(TimeOfDay.Instance.currentDayTime < _timeOfDeath) || !(_timeOfDeath < TimeOfDay.Instance.totalTime))
				{
					if ((Object)(object)deathController.PlayerToDie != (Object)null)
					{
						deathController.KillPlayer();
					}
					else
					{
						deathController.KillEnemy();
					}
				}
				else
				{
					deathController.TimeOfDeath = _timeOfDeath;
					StartKillTimer(deathController);
				}
			}
			ResetUI();
		}

		public void StartKillTimer(DeathController deathController)
		{
			logger.LogDebug((object)"Starting kill timer");
			((MonoBehaviour)this).StartCoroutine(deathController.StartKillTimerCoroutine());
		}

		private void BtnSubmitOnClick()
		{
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)"BtnSubmitOnClick");
			if (StartOfRound.Instance.inShipPhase)
			{
				ShowResults("Ship must be landed to use this book", 5f, flash: true);
				return;
			}
			if (verifying && DeathNoteBase.configTimer.Value)
			{
				if (DeathNoteBase.configAllowEarlySubmit.Value)
				{
					float num = ClockToTime(((TextInputBaseField<string>)(object)txtTimeOfDeath).text);
					if (num == -1f)
					{
						ShowResults("Wrong time format or out of reach. Format: 00:00AM/PM", 5f);
					}
					else
					{
						verifying = false;
					}
				}
				return;
			}
			deathController = new DeathController();
			PlayerControllerB val = (from x in StartOfRound.Instance.allPlayerScripts.ToList()
				where x.playerUsername.ToLower() == ((TextInputBaseField<string>)(object)txtName).text.ToLower()
				select x).FirstOrDefault();
			string text = DeathController.EnemyNames.Where((string x) => x.ToLower().Replace(" ", "") == ((TextInputBaseField<string>)(object)txtName).text.ToLower().Replace(" ", "")).FirstOrDefault();
			if (text == null && DeathNoteBase.configShowScannedEnemies.Value && ((BaseField<string>)(object)dpdnScannedEnemiesList).value != "")
			{
				text = ((BaseField<string>)(object)dpdnScannedEnemiesList).value;
			}
			if (text != null)
			{
				int index = int.Parse(text.Substring(text.LastIndexOf('-') + 1));
				EnemyAI val2 = RoundManager.Instance.SpawnedEnemies.Where((EnemyAI x) => x.thisEnemyIndex == index).FirstOrDefault();
				if ((Object)(object)val2 == (Object)null)
				{
					logger.LogError((object)$"Could not find enemy with index: {index}");
					ShowResults("Error: Could not find entity to kill", 5f, flash: true);
					return;
				}
				if (val2.isEnemyDead)
				{
					ShowResults("Enemy is already dead");
					return;
				}
				logger.LogDebug((object)("Found enemy to kill: " + text));
				ShowResults("Found enemy to kill: " + text, 5f, flash: true);
				deathController.EnemyName = text;
				deathController.EnemyToDie = val2;
				if (!DeathNoteBase.configTimer.Value)
				{
					deathController.TimeOfDeathString = ((TextInputBaseField<string>)(object)txtTimeOfDeath).text;
					float num2 = ClockToTime(((TextInputBaseField<string>)(object)txtTimeOfDeath).text);
					if (num2 == -1f || !(TimeOfDay.Instance.currentDayTime < num2) || !(num2 < TimeOfDay.Instance.totalTime))
					{
						deathController.KillEnemy();
					}
					else
					{
						deathController.TimeOfDeath = num2;
						StartKillTimer(deathController);
					}
					ResetUI();
				}
				else
				{
					((TextInputBaseField<string>)(object)txtName).isReadOnly = true;
					((VisualElement)txtTimeOfDeath).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
					((BaseField<string>)(object)txtTimeOfDeath).value = "";
					((VisualElement)pbRemainingTime).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
					verifying = true;
					StartProgressBarTimer(deathController);
				}
				return;
			}
			if ((Object)(object)val == (Object)null)
			{
				if (!DeathNoteBase.configShowPlayerList.Value || ((BaseField<string>)(object)dpdnPlayerList).value == "")
				{
					ShowResults("Could not find entity!", 5f, flash: true);
					return;
				}
				val = StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB x) => x.playerUsername == ((BaseField<string>)(object)dpdnPlayerList).value).FirstOrDefault();
				if ((Object)(object)val == (Object)null)
				{
					logger.LogError((object)"Couldnt find playerToDie in btnSubmitOnClick");
				}
			}
			if (val.isPlayerDead)
			{
				ShowResults("Player is already dead");
				return;
			}
			logger.LogDebug((object)("Found player to kill: " + val.playerUsername));
			ShowResults("Found player to kill: " + val.playerUsername, 5f, flash: true);
			deathController.PlayerToDie = val;
			if (!DeathNoteBase.configTimer.Value)
			{
				deathController.causeOfDeathString = ((BaseField<string>)(object)dpdnDeathType).value;
				deathController.detailsString = ((BaseField<string>)(object)dpdnDetails).value;
				deathController.TimeOfDeathString = ((TextInputBaseField<string>)(object)txtTimeOfDeath).text;
				float num3 = ClockToTime(((TextInputBaseField<string>)(object)txtTimeOfDeath).text);
				if (num3 == -1f || !(TimeOfDay.Instance.currentDayTime < num3) || !(num3 < TimeOfDay.Instance.totalTime))
				{
					deathController.KillPlayer();
				}
				else
				{
					deathController.TimeOfDeath = num3;
					StartKillTimer(deathController);
				}
				ResetUI();
			}
			else
			{
				((TextInputBaseField<string>)(object)txtName).isReadOnly = true;
				((VisualElement)txtTimeOfDeath).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
				((BaseField<string>)(object)txtTimeOfDeath).value = "";
				((VisualElement)dpdnDeathType).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
				((PopupField<string>)(object)dpdnDeathType).index = 0;
				((VisualElement)dpdnDetails).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
				((PopupField<string>)(object)dpdnDetails).index = 0;
				((VisualElement)pbRemainingTime).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
				verifying = true;
				StartProgressBarTimer(deathController);
			}
		}

		private void txtPlayerUsernameOnValueChanged(KeyUpEvent evt)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if ((int)((KeyboardEventBase<KeyUpEvent>)(object)evt).keyCode == 13)
			{
				BtnSubmitOnClick();
			}
		}

		public string TimeToClock(float time)
		{
			int numberOfHours = TimeOfDay.Instance.numberOfHours;
			float num = time / TimeOfDay.Instance.totalTime;
			int num2 = (int)(num * (60f * (float)numberOfHours)) + 360;
			logger.LogDebug((object)$"num: {num2}");
			int num3 = (int)Mathf.Floor((float)(num2 / 60));
			logger.LogDebug((object)$"num2: {num3}");
			string text = "AM";
			if (num3 >= 24)
			{
				return "12:00AM";
			}
			text = ((num3 >= 12) ? "PM" : "AM");
			if (num3 > 12)
			{
				num3 %= 12;
				logger.LogDebug((object)$"num2 changed: {num3}");
			}
			int num4 = num2 % 60;
			logger.LogDebug((object)$"num3: {num4}");
			return $"{num3:00}:{num4:00}".TrimStart('0') + text;
		}

		public float ClockToTime(string timeString)
		{
			timeString = timeString.ToUpper().Replace(" ", "").Replace("\n", "");
			int numberOfHours = TimeOfDay.Instance.numberOfHours;
			float lengthOfHours = TimeOfDay.Instance.lengthOfHours;
			float totalTime = TimeOfDay.Instance.totalTime;
			int num = 24 - numberOfHours;
			string[] array = timeString.Split(':');
			if (!int.TryParse(array[0], out var result))
			{
				return -1f;
			}
			if (!int.TryParse(array[1].Substring(0, 2), out var result2))
			{
				return -1f;
			}
			string text = array[1].Substring(2);
			if (text == "PM")
			{
				result += 12;
			}
			else if (text == "AM" && result == 12)
			{
				result = 0;
			}
			result -= num;
			return (float)result * lengthOfHours + (float)result2;
		}

		public void ShowResults(string message, float duration = 3f, bool flash = false)
		{
			((TextElement)lblResult).text = message;
			((MonoBehaviour)this).StartCoroutine(ShowResultsCoroutine(message, duration, flash));
		}

		private IEnumerator ShowResultsCoroutine(string message, float duration, bool flash)
		{
			float endTime = Time.time + duration;
			bool isRed = true;
			if (flash)
			{
				while (Time.time < endTime)
				{
					if (isRed)
					{
						((VisualElement)lblResult).style.color = StyleColor.op_Implicit(Color.black);
					}
					else
					{
						((VisualElement)lblResult).style.color = StyleColor.op_Implicit(Color.red);
					}
					isRed = !isRed;
					yield return (object)new WaitForSeconds(0.75f);
				}
			}
			else
			{
				yield return (object)new WaitForSeconds(duration);
			}
			((VisualElement)lblResult).style.color = StyleColor.op_Implicit(Color.red);
			((TextElement)lblResult).text = "";
		}

		private void BtnActivateEyesOnClick(ClickEvent evt)
		{
			//IL_001d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)"BtnActivateEyesOnClick");
			((VisualElement)btnActivateEyes).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			((TextElement)lblSEDescription).text = "You have the shinigami eyes. You can now see entity names. This will reset after the round is over.";
			((VisualElement)lblSEDescription).style.color = StyleColor.op_Implicit(Color.red);
			DeathController.ShinigamiEyesActivated = true;
		}
	}
}
namespace DeathNote.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		private static ManualLogSource logger = DeathNoteBase.LoggerInstance;

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void StartPostFix(EnemyAI __instance)
		{
			string text = __instance.enemyType.enemyName + new Random().Next(100, 1000) + "-" + __instance.thisEnemyIndex;
			logger.LogDebug((object)("Adding name: " + text));
			DeathController.EnemyNames.Add(text);
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		private static ManualLogSource logger = DeathNoteBase.LoggerInstance;

		[HarmonyPostfix]
		[HarmonyPatch("PingScan_performed")]
		public static void PingScan_performedPostFix()
		{
			if (!DeathController.ShinigamiEyesActivated || !DeathNoteBase.configShowEnemyNames.Value)
			{
				return;
			}
			logger.LogDebug((object)$"Got {HUDManager.Instance.nodesOnScreen.Count} nodes");
			foreach (ScanNodeProperties item in HUDManager.Instance.nodesOnScreen)
			{
				if (item.nodeType != 1)
				{
					continue;
				}
				logger.LogDebug((object)$"{item.nodeType} {item.headerText} {item.subText}");
				EnemyAI enemy = ((Component)item).gameObject.GetComponentInParent<EnemyAI>();
				if (DeathNoteBase.configShowUnkillableEnemyNames.Value || enemy.enemyType.canDie)
				{
					logger.LogDebug((object)$"Got enemy from scannode:{enemy.thisEnemyIndex}: {enemy.enemyType.enemyName}");
					string text = DeathController.EnemyNames.Where((string x) => int.Parse(x.Substring(x.LastIndexOf('-') + 1)) == enemy.thisEnemyIndex).FirstOrDefault();
					if (text != null)
					{
						logger.LogDebug((object)("Found name: " + text));
						item.headerText = text;
						item.subText = enemy.enemyType.enemyName;
						DeathController.ScannedEnemies.Add(text);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("ShowNameBillboard")]
		public static bool ShowNameBillboardPrefix()
		{
			if (!DeathNoteBase.configAlwaysShowPlayerNames.Value && !DeathController.ShinigamiEyesActivated)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager))]
	internal class QuickMenuManagerPatch
	{
		private static ManualLogSource logger = DeathNoteBase.LoggerInstance;

		[HarmonyPrefix]
		[HarmonyPatch("OpenQuickMenu")]
		public static bool OpenQuickMenuPatch()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)UIControllerScript.Instance == (Object)null)
			{
				return true;
			}
			if (UIControllerScript.Instance.veMain == null)
			{
				logger.LogError((object)"veMain is null!");
				return true;
			}
			if (UIControllerScript.Instance.veMain.style.display == StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		private static ManualLogSource logger = DeathNoteBase.LoggerInstance;

		[HarmonyPostfix]
		[HarmonyPatch("EndOfGame")]
		private static void EndOfGamePrefix()
		{
			//IL_00a1: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			logger.LogDebug((object)"In EndOfGamePrefix");
			if (DeathNoteBase.configShinigamiEyes.Value && !DeathNoteBase.configPermanentEyes.Value)
			{
				logger.LogDebug((object)"Passed config checks");
				DeathController.ShinigamiEyesActivated = false;
				logger.LogDebug((object)"Set ShinigamiEyesActivated to false");
				DeathController.EnemyNames = new List<string>();
				DeathController.ScannedEnemies = new List<string>();
				logger.LogDebug((object)"Cleared EnemyNames");
				if (!((Object)(object)UIControllerScript.Instance == (Object)null))
				{
					((VisualElement)UIControllerScript.Instance.btnActivateEyes).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
					((TextElement)UIControllerScript.Instance.lblSEDescription).text = "You may, in exchange of half of your life, acquire the power of the Shinigami Eyes, which will enable you to see an entity's name when looking at them.\nThis will reset at the end of the round.";
					((VisualElement)UIControllerScript.Instance.lblSEDescription).style.color = StyleColor.op_Implicit(Color.black);
					logger.LogDebug((object)"Showed ShinigamiEyesActivated");
					logger.LogDebug((object)"Finished");
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace DeathNote.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}