Decompiled source of HAI Laser Weaponry v1.0.0

plugins/HAI_laserweapons.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
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.Configuration;
using BepInEx.Logging;
using Dawn;
using GameNetcodeStuff;
using HAI_laserweapons;
using HAI_laserweapons.NetcodePatcher;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalSettings.UI;
using LethalSettings.UI.Components;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("HAI_laserweapons")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HAI_laserweapons")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f84ac08e-056e-4827-b673-6adedf739c23")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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;
		}
	}
}
public class HAI_LaserImpact : NetworkBehaviour
{
	[Header("Components")]
	public ParticleSystem[] particleSystems = null;

	public AudioSource impactAudioSource = null;

	public DecalProjector decalProjector = null;

	[Header("Timeline Settings")]
	[SerializeField]
	private float coolingDuration = 20f;

	[SerializeField]
	private float sootDuration = 40f;

	[SerializeField]
	private float fadeDuration = 5f;

	[Header("Emission Settings (HDRP Decal)")]
	[SerializeField]
	private string emissiveColorProperty = "_EmissiveColor";

	[SerializeField]
	private Color emissionBaseColor = new Color(1f, 1f, 1f);

	[SerializeField]
	private float startEmissionIntensity = 5f;

	[SerializeField]
	private float endEmissionIntensity = 0f;

	private Material decalMaterialInstance;

	private bool hasStartedFade = false;

	public void InitializeFromCode()
	{
		if (particleSystems == null || particleSystems.Length == 0)
		{
			particleSystems = ((Component)this).GetComponentsInChildren<ParticleSystem>(true);
		}
		if ((Object)(object)impactAudioSource == (Object)null)
		{
			impactAudioSource = ((Component)this).GetComponentInChildren<AudioSource>(true);
		}
		if ((Object)(object)decalProjector == (Object)null)
		{
			decalProjector = ((Component)this).GetComponentInChildren<DecalProjector>(true);
		}
		ManualLogSource mls = Plugin.mls;
		if (mls != null)
		{
			mls.LogInfo((object)$"[HAI_LaserImpact] InitializeFromCode отработал! Найдено партиклов: {particleSystems?.Length}");
		}
	}

	public override void OnNetworkSpawn()
	{
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Expected O, but got Unknown
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		((NetworkBehaviour)this).OnNetworkSpawn();
		if (particleSystems != null)
		{
			ParticleSystem[] array = particleSystems;
			foreach (ParticleSystem val in array)
			{
				if (val != null)
				{
					val.Play();
				}
			}
		}
		if ((Object)(object)impactAudioSource != (Object)null)
		{
			impactAudioSource.pitch = Random.Range(0.9f, 1.15f);
			impactAudioSource.Play();
		}
		if ((Object)(object)decalProjector == (Object)null)
		{
			decalProjector = ((Component)this).GetComponent<DecalProjector>();
		}
		if ((Object)(object)decalProjector != (Object)null && (Object)(object)decalProjector.material != (Object)null)
		{
			decalMaterialInstance = new Material(decalProjector.material);
			decalProjector.material = decalMaterialInstance;
			decalProjector.fadeFactor = 1f;
			if (decalMaterialInstance.HasProperty(emissiveColorProperty))
			{
				decalMaterialInstance.SetColor(emissiveColorProperty, emissionBaseColor * startEmissionIntensity);
			}
		}
		if (!hasStartedFade)
		{
			hasStartedFade = true;
			((MonoBehaviour)this).StartCoroutine(FadeImpactRoutine());
		}
		if (((NetworkBehaviour)this).IsServer)
		{
			float delay = coolingDuration + sootDuration + fadeDuration + 0.5f;
			((MonoBehaviour)this).StartCoroutine(DespawnAfterDelay(delay));
		}
	}

	private IEnumerator FadeImpactRoutine()
	{
		if ((Object)(object)decalProjector != (Object)null)
		{
			((Component)decalProjector).transform.Rotate(0f, 0f, Random.Range(0f, 360f), (Space)1);
		}
		if (particleSystems != null)
		{
			ParticleSystem[] array = particleSystems;
			foreach (ParticleSystem ps in array)
			{
				if ((Object)(object)ps != (Object)null)
				{
					ps.Play();
				}
			}
		}
		if ((Object)(object)impactAudioSource != (Object)null && (Object)(object)impactAudioSource.clip != (Object)null)
		{
			impactAudioSource.Play();
		}
		bool hasProperty = false;
		if ((Object)(object)decalProjector != (Object)null && (Object)(object)decalProjector.material != (Object)null)
		{
			decalMaterialInstance = new Material(decalProjector.material);
			hasProperty = decalMaterialInstance.HasProperty(emissiveColorProperty);
		}
		float elapsed = 0f;
		while (elapsed < coolingDuration)
		{
			elapsed += Time.deltaTime;
			float percent = Mathf.Clamp01(elapsed / coolingDuration);
			float currentIntensity = Mathf.Lerp(startEmissionIntensity, endEmissionIntensity, percent);
			if (hasProperty)
			{
				decalMaterialInstance.SetColor(emissiveColorProperty, emissionBaseColor * currentIntensity);
				decalProjector.material = decalMaterialInstance;
			}
			yield return null;
		}
		if (hasProperty)
		{
			decalMaterialInstance.SetColor(emissiveColorProperty, emissionBaseColor * endEmissionIntensity);
		}
		decalProjector.material = decalMaterialInstance;
		yield return (object)new WaitForSeconds(sootDuration);
		elapsed = 0f;
		while (elapsed < fadeDuration)
		{
			elapsed += Time.deltaTime;
			float percent2 = Mathf.Clamp01(elapsed / fadeDuration);
			decalProjector.fadeFactor = Mathf.Lerp(1f, 0f, percent2);
			yield return null;
		}
		decalProjector.fadeFactor = 0f;
	}

	private IEnumerator DespawnAfterDelay(float delay)
	{
		yield return (object)new WaitForSeconds(delay);
		if ((Object)(object)((NetworkBehaviour)this).NetworkObject != (Object)null && ((NetworkBehaviour)this).NetworkObject.IsSpawned)
		{
			((NetworkBehaviour)this).NetworkObject.Despawn(true);
		}
	}

	public override void OnNetworkDespawn()
	{
		((NetworkBehaviour)this).OnNetworkDespawn();
		if ((Object)(object)decalMaterialInstance != (Object)null)
		{
			Object.Destroy((Object)(object)decalMaterialInstance);
			decalMaterialInstance = null;
		}
	}

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

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

	protected internal override string __getTypeName()
	{
		return "HAI_LaserImpact";
	}
}
namespace HAI_laserweapons
{
	[HarmonyPatch(typeof(Terminal))]
	public class CustomTerminalRegistry
	{
		private const string ManufacturerCommand = "hoplit";

		private const string ManufacturerAlias = "hai";

		private const string CatalogCommand = "laser";

		private static bool IsMatch(string input, string target, int minChars = 2)
		{
			if (string.IsNullOrEmpty(input))
			{
				return false;
			}
			if (input.Length < minChars && input != target)
			{
				return false;
			}
			return target.StartsWith(input);
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void BuildCorporateNetwork(Terminal __instance)
		{
			TerminalKeyword val = ((IEnumerable<TerminalKeyword>)__instance.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword k) => k.word == "help"));
			if ((Object)(object)val != (Object)null && (Object)(object)val.specialKeywordResult != (Object)null)
			{
				string text = (Plugin.translateRussian ? "> КОРПОРАТИВНЫЕ СЕТИ\nДля доступа к каталогам введите `corporate`.\n" : "> CORPORATE NETWORKS\nTo access other companies catalogs type `corporate`.\n");
				if (!val.specialKeywordResult.displayText.Contains("`corporate`"))
				{
					TerminalNode specialKeywordResult = val.specialKeywordResult;
					specialKeywordResult.displayText += text;
				}
			}
			TerminalKeyword orCreateKeyword = GetOrCreateKeyword(__instance, "corporate");
			TerminalNode val2 = orCreateKeyword.specialKeywordResult;
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)val2).name = "CorporateNetworksNode";
				val2.clearPreviousText = true;
				val2.displayText = (Plugin.translateRussian ? "==================================================\n  ОБЪЕДИНЕННАЯ КОРПОРАТИВНАЯ БАЗА ДАННЫХ\n  [ Введите `help` для выхода в общую систему ]\n==================================================\nВыберите производителя для просмотра продукции:\n\n" : "==================================================\n  UNITED CORPORATE DATABASE\n  [ Type `help` to exit to main system ]\n==================================================\nSelect a manufacturer to view products:\n\n");
				orCreateKeyword.specialKeywordResult = val2;
			}
			string text2 = (Plugin.translateRussian ? "> Hoplit Armament Industries (введите `hoplit` или `hai`)\n" : "> Hoplit Armament Industries (type `hoplit` or `hai`)\n");
			if (!val2.displayText.Contains("`hoplit`"))
			{
				TerminalNode obj = val2;
				obj.displayText += text2;
			}
			TerminalKeyword orCreateKeyword2 = GetOrCreateKeyword(__instance, "hoplit");
			TerminalKeyword orCreateKeyword3 = GetOrCreateKeyword(__instance, "hai");
			TerminalNode val3 = orCreateKeyword2.specialKeywordResult;
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)val3).name = "HoplitMainMenuNode";
				val3.clearPreviousText = true;
				val3.displayText = (Plugin.translateRussian ? "==================================================\n  HOPLIT ARMAMENT INDUSTRIES - ГЛАВНЫЙ ТЕРМИНАЛ\n  [ Введите `help` для выхода в общую систему ]\n==================================================\nАвторизация успешна. Доступные каталоги:\n\n" : "==================================================\n  HOPLIT ARMAMENT INDUSTRIES - MAIN TERMINAL\n  [ Type `help` to exit to main system ]\n==================================================\nAuthorization successful. Available catalogs:\n\n");
				orCreateKeyword2.specialKeywordResult = val3;
				orCreateKeyword3.specialKeywordResult = val3;
			}
			string text3 = (Plugin.translateRussian ? "> Лазерное энергооружие (введите `laser`)\n" : "> Laser energy weapons (type `laser`)\n");
			if (!val3.displayText.Contains("`laser`"))
			{
				TerminalNode obj2 = val3;
				obj2.displayText += text3;
			}
			TerminalKeyword orCreateKeyword4 = GetOrCreateKeyword(__instance, "laser");
			if ((Object)(object)orCreateKeyword4.specialKeywordResult == (Object)null)
			{
				TerminalNode val4 = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)val4).name = "LaserCatalogueNode";
				val4.clearPreviousText = true;
				string displayText = (Plugin.translateRussian ? ("==================================================\n         H.A.I. - КАТАЛОГ: ЛАЗЕРНОЕ ОРУЖИЕ\n         [ Введите `help` для выхода ]\n==================================================\nНадежные лазерные энергетические решения для любых угроз.\n\n[ БОЕПРИПАСЫ И ОБСЛУЖИВАНИЕ ]\n" + $"* Энергоячейка // {Plugin.lasercellPrice} $\n\n" + "[ КОМПАКТНОЕ ВООРУЖЕНИЕ ]\n" + $"* Пистолет // {Plugin.laserpistolPrice} $\n" + "--------------------------------------------------\nИНСТРУКЦИЯ ПО ЗАКАЗУ:\nПросто введите название (например: 'эмиттер' или 'карабин').\nТакже доступна команда 'info [название]'.\n==================================================\n\n") : ("==================================================\n         H.A.I. - CATALOGUE: LASER WEAPONRY\n         [ Type `help` to exit ]\n==================================================\nReliable laser energy solutions for any threats.\n\n[ AMMUNITION & MAINTENANCE ]\n" + $"* Energy Cell // ${Plugin.lasercellPrice}\n\n" + "[ COMPACT WEAPONRY ]\n" + $"* Pistol // ${Plugin.laserpistolPrice}\n" + "--------------------------------------------------\nORDER INSTRUCTIONS:\nJust type the name (e.g., 'emitter' or 'carbine').\nCommand 'info [name]' is also available.\n==================================================\n\n"));
				val4.displayText = displayText;
				orCreateKeyword4.specialKeywordResult = val4;
			}
		}

		private static TerminalKeyword GetOrCreateKeyword(Terminal terminal, string word)
		{
			TerminalKeyword val = ((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword k) => k.word == word));
			if ((Object)(object)val == (Object)null)
			{
				val = ScriptableObject.CreateInstance<TerminalKeyword>();
				val.word = word;
				((Object)val).name = word + "Keyword";
				terminal.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(terminal.terminalNodes.allKeywords, val);
			}
			return val;
		}

		private static TerminalNode GetItemInfoNode(string targetEN)
		{
			return (TerminalNode)(targetEN switch
			{
				"Cell" => Plugin.lasercellAmmoItemShopInfo, 
				"Emitter" => Plugin.laseremitterpistolShopInfo, 
				"Pistol" => Plugin.laserpistolItemShopInfo, 
				"Machinegun" => Plugin.lasersmgShopInfo, 
				"Carbine" => Plugin.lasercarbineShopInfo, 
				"Sniper" => Plugin.lasersniperShopInfo, 
				_ => null, 
			});
		}

		[HarmonyPatch("TextPostProcess")]
		[HarmonyPostfix]
		public static void HideFromStandardStore(ref string __result, TerminalNode node)
		{
			if ((!((Object)(object)node != (Object)null) || ((Object)node).name == null || !((Object)node).name.StartsWith("LaserCatalogueNode")) && (!((Object)(object)node != (Object)null) || !node.isConfirmationNode) && !string.IsNullOrEmpty(__result) && __result.Contains("[H.A.I.]"))
			{
				string[] source = __result.Split('\n');
				IEnumerable<string> values = source.Where((string line) => !line.Contains("[H.A.I.]"));
				__result = string.Join("\n", values);
			}
		}

		[HarmonyPatch("ParsePlayerSentence")]
		[HarmonyPrefix]
		public static bool EnforceFolderLock(Terminal __instance, ref TerminalNode __result)
		{
			if ((Object)(object)__instance.currentNode == (Object)null || string.IsNullOrEmpty(((Object)__instance.currentNode).name))
			{
				return true;
			}
			string name = ((Object)__instance.currentNode).name;
			bool flag = name.StartsWith("CorporateNetworksNode");
			bool flag2 = name.StartsWith("HoplitMainMenuNode");
			bool flag3 = name.StartsWith("LaserCatalogueNode");
			bool flag4 = name.EndsWith("_Confirm");
			string text = "";
			text = ((__instance.textAdded < 0 || __instance.textAdded > __instance.screenText.text.Length) ? __instance.screenText.text : __instance.screenText.text.Substring(__instance.textAdded));
			string[] array = text.Split(new char[2] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
			string text2 = ((array.Length != 0) ? array.Last() : "");
			if (text2.Contains("===") || text2.Contains("[") || text2.Contains("]") || text2.Contains(">") || text2.Contains("H.A.I."))
			{
				text2 = "";
			}
			text2 = text2.Trim().ToLower();
			string[] array2 = text2.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			if (array2.Length == 0)
			{
				return true;
			}
			string text3 = array2[0];
			if (text3 == "addmoney")
			{
				__instance.groupCredits += 10000;
				__instance.SyncGroupCreditsServerRpc(__instance.groupCredits, __instance.numberOfItemsInDropship);
				TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
				val.clearPreviousText = true;
				val.displayText = (Plugin.translateRussian ? "> ВНИМАНИЕ: Активирован протокол финансирования H.A.I.\n> На баланс корабля зачислено 10,000 кредитов.\n\n" : "> WARNING: H.A.I. funding protocol activated.\n> 10,000 credits added to ship balance.\n\n");
				__result = val;
				return false;
			}
			if (flag4)
			{
				bool flag5 = IsMatch(text3, "confirm", 1) || IsMatch(text3, "подтвердить", 1) || text3 == "y";
				bool flag6 = IsMatch(text3, "deny", 1) || IsMatch(text3, "отменить", 1) || text3 == "n";
				if (flag5)
				{
					CompatibleNoun val2 = __instance.currentNode.terminalOptions?.FirstOrDefault((Func<CompatibleNoun, bool>)((CompatibleNoun opt) => opt.noun.word == "confirm"));
					if (val2 != null && (Object)(object)val2.result != (Object)null)
					{
						TerminalNode val3 = Object.Instantiate<TerminalNode>(val2.result);
						val3.buyItemIndex = __instance.currentNode.buyItemIndex;
						val3.itemCost = __instance.currentNode.itemCost;
						int num = __instance.currentNode.itemCost * __instance.playerDefinedAmount;
						val3.displayText = val3.displayText.Replace("[totalCost]", num.ToString());
						val3.displayText = val3.displayText.Replace("[variableAmount]", __instance.playerDefinedAmount.ToString());
						__result = val3;
						return false;
					}
				}
				else if (flag6)
				{
					string text4 = name.Replace("_Confirm", "");
					TerminalNode val4 = null;
					TerminalKeyword[] allKeywords = __instance.terminalNodes.allKeywords;
					foreach (TerminalKeyword val5 in allKeywords)
					{
						if ((Object)(object)val5 != (Object)null && (Object)(object)val5.specialKeywordResult != (Object)null && ((Object)val5.specialKeywordResult).name == text4)
						{
							val4 = val5.specialKeywordResult;
							break;
						}
					}
					if ((Object)(object)val4 == (Object)null)
					{
						val4 = ((IEnumerable<TerminalKeyword>)__instance.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword k) => k.word == "laser"))?.specialKeywordResult;
					}
					if ((Object)(object)val4 != (Object)null)
					{
						__result = val4;
						return false;
					}
				}
				TerminalNode val6 = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)val6).name = name;
				val6.clearPreviousText = true;
				val6.terminalOptions = __instance.currentNode.terminalOptions;
				val6.overrideOptions = __instance.currentNode.overrideOptions;
				val6.isConfirmationNode = true;
				val6.buyItemIndex = __instance.currentNode.buyItemIndex;
				val6.itemCost = __instance.currentNode.itemCost;
				string text5 = __instance.currentNode.displayText;
				if (text5.Contains("> ОШИБКА"))
				{
					text5 = text5.Substring(0, text5.IndexOf("> ОШИБКА"));
				}
				if (text5.Contains("> ERROR"))
				{
					text5 = text5.Substring(0, text5.IndexOf("> ERROR"));
				}
				string text6 = (Plugin.translateRussian ? "> ОШИБКА: Ожидается ответ 'confirm' (c) или 'deny' (d).\n\n" : "> ERROR: Expected response 'confirm' (c) or 'deny' (d).\n\n");
				val6.displayText = text5 + text6;
				__result = val6;
				return false;
			}
			if (IsMatch(text3, "help"))
			{
				TerminalKeyword val7 = ((IEnumerable<TerminalKeyword>)__instance.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword k) => k.word == "help"));
				if ((Object)(object)val7 != (Object)null && (Object)(object)val7.specialKeywordResult != (Object)null)
				{
					__result = val7.specialKeywordResult;
					return false;
				}
			}
			if (IsMatch(text3, "corporate") || IsMatch(text3, "hoplit") || IsMatch(text3, "hai") || IsMatch(text3, "laser"))
			{
				string matchedWord = "";
				if (IsMatch(text3, "corporate"))
				{
					matchedWord = "corporate";
				}
				else if (IsMatch(text3, "hoplit"))
				{
					matchedWord = "hoplit";
				}
				else if (IsMatch(text3, "hai"))
				{
					matchedWord = "hai";
				}
				else if (IsMatch(text3, "laser"))
				{
					matchedWord = "laser";
				}
				bool flag7 = false;
				if (matchedWord == "corporate")
				{
					flag7 = true;
				}
				else if (matchedWord == "hoplit" || matchedWord == "hai")
				{
					if (flag || (!flag && !flag2 && !flag3))
					{
						flag7 = true;
					}
				}
				else if (matchedWord == "laser" && (flag2 || (!flag && !flag2 && !flag3)))
				{
					flag7 = true;
				}
				if (flag7)
				{
					TerminalKeyword val8 = ((IEnumerable<TerminalKeyword>)__instance.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword k) => k.word == matchedWord));
					if ((Object)(object)val8 != (Object)null && (Object)(object)val8.specialKeywordResult != (Object)null)
					{
						__result = val8.specialKeywordResult;
						return false;
					}
				}
			}
			if (!flag && !flag2 && !flag3)
			{
				return true;
			}
			bool flag8 = false;
			string text7 = "";
			if (flag)
			{
				flag8 = true;
				text7 = (Plugin.translateRussian ? ("> ОШИБКА ДОСТУПА: Корпорация '" + text3 + "' не найдена.\n> Введите `help` для выхода.\n\n") : ("> ACCESS ERROR: Corporation '" + text3 + "' not found.\n> Type `help` to exit.\n\n"));
			}
			else if (flag2)
			{
				flag8 = true;
				text7 = (Plugin.translateRussian ? ("> ОШИБКА ДОСТУПА: Каталог '" + text3 + "' отсутствует.\n> Введите `help` для выхода.\n\n") : ("> ACCESS ERROR: Catalog '" + text3 + "' missing.\n> Type `help` to exit.\n\n"));
			}
			else if (flag3)
			{
				bool flag9 = false;
				string input = text3;
				if (text3 == "buy" && array2.Length > 1)
				{
					input = array2[1];
				}
				else if (text3 == "info")
				{
					flag9 = true;
					if (array2.Length > 1)
					{
						input = array2[1];
					}
				}
				string text8 = "";
				string value = "";
				if (IsMatch(input, "cell") || IsMatch(input, "energy") || IsMatch(input, "ячейка") || IsMatch(input, "энерго", 4))
				{
					text8 = "Cell";
					value = "Энергоячейка";
				}
				else if (IsMatch(input, "emitter") || IsMatch(input, "эмиттер"))
				{
					text8 = "Emitter";
					value = "Эмиттер";
				}
				else if (IsMatch(input, "pistol") || IsMatch(input, "пистолет"))
				{
					text8 = "Pistol";
					value = "Пистолет";
				}
				else if (IsMatch(input, "smg") || IsMatch(input, "machinegun", 3) || IsMatch(input, "пп"))
				{
					text8 = "Machinegun";
					value = "ПП";
				}
				else if (IsMatch(input, "carbine") || IsMatch(input, "карабин"))
				{
					text8 = "Carbine";
					value = "Карабин";
				}
				else if (IsMatch(input, "sniper") || IsMatch(input, "precision", 3) || IsMatch(input, "винтовка", 4))
				{
					text8 = "Sniper";
					value = "Винтовка";
				}
				if (!string.IsNullOrEmpty(text8))
				{
					TerminalNode itemInfoNode = GetItemInfoNode(text8);
					if (flag9)
					{
						if ((Object)(object)itemInfoNode != (Object)null)
						{
							TerminalNode val9 = ScriptableObject.CreateInstance<TerminalNode>();
							((Object)val9).name = name;
							val9.clearPreviousText = true;
							string text9 = (Plugin.translateRussian ? "\n[ Введите название предмета для покупки или `help` для выхода ]\n\n" : "\n[ Type item name to purchase or `help` to exit ]\n\n");
							val9.displayText = itemInfoNode.displayText + text9;
							__result = val9;
							return false;
						}
					}
					else
					{
						int itemIndex = -1;
						for (int num3 = 0; num3 < __instance.buyableItemsList.Length; num3++)
						{
							if ((Object)(object)__instance.buyableItemsList[num3] != (Object)null)
							{
								string itemName = __instance.buyableItemsList[num3].itemName;
								if (itemName.Contains(text8) || itemName.Contains(value) || (text8 == "Machinegun" && itemName.Contains("SMG")) || (text8 == "Sniper" && itemName.Contains("Precision")))
								{
									itemIndex = num3;
									break;
								}
							}
						}
						if (itemIndex != -1)
						{
							TerminalKeyword val10 = ((IEnumerable<TerminalKeyword>)__instance.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword k) => k.word == "buy"));
							if ((Object)(object)val10 != (Object)null && val10.compatibleNouns != null)
							{
								CompatibleNoun val11 = ((IEnumerable<CompatibleNoun>)val10.compatibleNouns).FirstOrDefault((Func<CompatibleNoun, bool>)((CompatibleNoun n) => (Object)(object)n.result != (Object)null && n.result.buyItemIndex == itemIndex));
								if (val11 != null && (Object)(object)val11.result != (Object)null)
								{
									int num4 = 1;
									if (array2.Length > 1 && int.TryParse(array2[^1], out var result))
									{
										num4 = Mathf.Clamp(result, 1, 10);
									}
									__instance.playerDefinedAmount = num4;
									TerminalNode val12 = Object.Instantiate<TerminalNode>(val11.result);
									((Object)val12).name = name + "_Confirm";
									val12.buyItemIndex = itemIndex;
									int num5 = (val12.itemCost = __instance.buyableItemsList[itemIndex].creditsWorth);
									string itemName2 = __instance.buyableItemsList[itemIndex].itemName;
									string newValue = (num5 * num4).ToString();
									val12.displayText = val12.displayText.Replace("[variableAmount]", num4.ToString());
									val12.displayText = val12.displayText.Replace("[totalCost]", newValue);
									val12.displayText = val12.displayText.Replace("[itemName]", itemName2);
									if ((Object)(object)itemInfoNode != (Object)null)
									{
										string text10 = "==================================================\n";
										val12.displayText = itemInfoNode.displayText + text10 + val12.displayText;
									}
									__result = val12;
									return false;
								}
							}
						}
					}
				}
				flag8 = true;
				text7 = (Plugin.translateRussian ? ("\n> ОШИБКА: Запрос '" + text3 + "' не распознан.\n> Введите название (`эмиттер`) или `info эмиттер`.\n> Введите `help` для выхода.\n\n") : ("\n> ERROR: Request '" + text3 + "' not recognized.\n> Type name (`emitter`) or `info emitter`.\n> Type `help` to exit.\n\n"));
			}
			if (flag8)
			{
				TerminalNode val13 = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)val13).name = name;
				val13.clearPreviousText = true;
				string text11 = __instance.currentNode.displayText;
				if (text11.Contains("> ОШИБКА"))
				{
					text11 = text11.Substring(0, text11.IndexOf("> ОШИБКА"));
				}
				if (text11.Contains("> ACCESS ERROR"))
				{
					text11 = text11.Substring(0, text11.IndexOf("> ACCESS ERROR"));
				}
				if (text11.Contains("> ERROR"))
				{
					text11 = text11.Substring(0, text11.IndexOf("> ERROR"));
				}
				val13.displayText = text11 + text7;
				__result = val13;
				return false;
			}
			return true;
		}
	}
	public abstract class CustomWeaponBase : GrabbableObject
	{
		protected bool isCrouching;

		protected bool isJumping;

		protected bool isWalking;

		protected bool isSprinting;

		protected bool wasWeaponHold = false;

		protected AnimatorStateInfo currentStateInfo;

		protected float currentAnimationTime;

		private static MethodInfo pingScanMethod;

		protected virtual string HoldParameterName => "WeaponHold";

		protected abstract RuntimeAnimatorController CustomPlayerAnimator { get; }

		protected abstract RuntimeAnimatorController CustomOtherPlayerAnimator { get; }

		private void OnWeaponScanPerformed(CallbackContext context)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)HUDManager.Instance == (Object)null))
			{
				if (pingScanMethod == null)
				{
					pingScanMethod = typeof(HUDManager).GetMethod("PingScan_performed", BindingFlags.Instance | BindingFlags.NonPublic);
				}
				if (pingScanMethod != null)
				{
					pingScanMethod.Invoke(HUDManager.Instance, new object[1] { context });
				}
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			if ((Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				Plugin.InputActionInstance.WeaponScanKey.performed -= OnWeaponScanPerformed;
				Plugin.InputActionInstance.WeaponScanKey.performed += OnWeaponScanPerformed;
			}
		}

		public override void PocketItem()
		{
			Plugin.InputActionInstance.WeaponScanKey.performed -= OnWeaponScanPerformed;
			((GrabbableObject)this).PocketItem();
		}

		public override void DiscardItem()
		{
			Plugin.InputActionInstance.WeaponScanKey.performed -= OnWeaponScanPerformed;
			((GrabbableObject)this).DiscardItem();
		}

		public override void OnDestroy()
		{
			((GrabbableObject)this).OnDestroy();
			Plugin.InputActionInstance.WeaponScanKey.performed -= OnWeaponScanPerformed;
		}

		protected RuntimeAnimatorController GetVanillaAnimator(PlayerControllerB player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			if ((Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				return StartOfRound.Instance.localClientAnimatorController;
			}
			return StartOfRound.Instance.otherClientsAnimatorController;
		}

		protected static bool AnimatorHasParameter(Animator animator, string paramName)
		{
			if ((Object)(object)animator == (Object)null)
			{
				return false;
			}
			AnimatorControllerParameter[] parameters = animator.parameters;
			foreach (AnimatorControllerParameter val in parameters)
			{
				if (val.name == paramName)
				{
					return true;
				}
			}
			return false;
		}

		protected void SaveAnimatorStates(Animator animator)
		{
			//IL_006a: 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 (AnimatorHasParameter(animator, HoldParameterName))
			{
				wasWeaponHold = animator.GetBool(HoldParameterName);
			}
			isCrouching = animator.GetBool("crouching");
			isJumping = animator.GetBool("Jumping");
			isWalking = animator.GetBool("Walking");
			isSprinting = animator.GetBool("Sprinting");
			currentStateInfo = animator.GetCurrentAnimatorStateInfo(0);
			currentAnimationTime = ((AnimatorStateInfo)(ref currentStateInfo)).normalizedTime;
		}

		protected void RestoreAnimatorStates(Animator animator, bool isRestoringVanilla)
		{
			animator.SetBool("crouching", isCrouching);
			animator.SetBool("Jumping", isJumping);
			animator.SetBool("Walking", isWalking);
			animator.SetBool("Sprinting", isSprinting);
			if (!isRestoringVanilla && AnimatorHasParameter(animator, HoldParameterName))
			{
				animator.SetBool(HoldParameterName, wasWeaponHold);
			}
			animator.Play(((AnimatorStateInfo)(ref currentStateInfo)).fullPathHash, 0, currentAnimationTime);
		}

		public void UpdateWeaponAnimator(PlayerControllerB player, Animator playerBodyAnimator, bool isDroppingWeapon)
		{
			if ((Object)(object)player == (Object)null || (Object)(object)playerBodyAnimator == (Object)null)
			{
				return;
			}
			if (!isDroppingWeapon)
			{
				RuntimeAnimatorController val = (((Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController) ? CustomPlayerAnimator : CustomOtherPlayerAnimator);
				if ((Object)(object)playerBodyAnimator.runtimeAnimatorController != (Object)(object)val)
				{
					SaveAnimatorStates(playerBodyAnimator);
					playerBodyAnimator.runtimeAnimatorController = val;
					playerBodyAnimator.Update(0f);
					RestoreAnimatorStates(playerBodyAnimator, isRestoringVanilla: false);
					Plugin.mls.LogInfo((object)("Replaced Player Animator for " + ((Object)((Component)this).gameObject).name + "!"));
				}
				return;
			}
			bool flag = false;
			if (player.ItemSlots != null && player.currentItemSlot >= 0 && player.currentItemSlot < player.ItemSlots.Length)
			{
				GrabbableObject val2 = player.ItemSlots[player.currentItemSlot];
				if ((Object)(object)val2 != (Object)null && val2 is CustomWeaponBase)
				{
					flag = true;
				}
			}
			if (flag)
			{
				Plugin.mls.LogInfo((object)"Skipping vanilla animator restore: switching directly to another custom weapon.");
				return;
			}
			RuntimeAnimatorController vanillaAnimator = GetVanillaAnimator(player);
			if ((Object)(object)vanillaAnimator != (Object)null && (Object)(object)playerBodyAnimator.runtimeAnimatorController != (Object)(object)vanillaAnimator)
			{
				SaveAnimatorStates(playerBodyAnimator);
				playerBodyAnimator.runtimeAnimatorController = vanillaAnimator;
				playerBodyAnimator.Update(0f);
				RestoreAnimatorStates(playerBodyAnimator, isRestoringVanilla: true);
				Plugin.mls.LogInfo((object)("Restored Original Animator after dropping " + ((Object)((Component)this).gameObject).name + "!"));
			}
		}

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

		protected override void __initializeRpcs()
		{
			((GrabbableObject)this).__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "CustomWeaponBase";
		}
	}
	public class HAI_LaserCellItem : GrabbableObject
	{
		public int ammoType = 1000;

		public float currentBatteryCharge = 100f;

		private ScanNodeProperties scanNode;

		private bool scanNodeInitialized = false;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			currentBatteryCharge = Mathf.Clamp(currentBatteryCharge, 0f, 100f);
			scanNode = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
			if ((Object)(object)scanNode != (Object)null)
			{
				scanNodeInitialized = true;
				UpdateScanNodeText();
			}
			if (base.itemProperties.toolTips == null || base.itemProperties.toolTips.Length < 2)
			{
				base.itemProperties.toolTips = new string[2] { "", "System Check" };
			}
			if (base.itemProperties.toolTips.Length > 1)
			{
				base.itemProperties.toolTips[1] = GetChargeTooltip();
			}
			Plugin.mls.LogInfo((object)$"Laser Cell Spawned - Ammo Type ID: {ammoType}");
		}

		public override int GetItemDataToSave()
		{
			((GrabbableObject)this).GetItemDataToSave();
			currentBatteryCharge = Mathf.Clamp(currentBatteryCharge, 0f, 100f);
			return Mathf.RoundToInt(currentBatteryCharge * 100f);
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			currentBatteryCharge = Mathf.Clamp((float)saveData / 100f, 0f, 100f);
			if (scanNodeInitialized)
			{
				UpdateScanNodeText();
			}
		}

		private void UpdateScanNodeText()
		{
			if ((Object)(object)scanNode != (Object)null)
			{
				string arg = (Plugin.translateRussian ? "Боеприпас для лазерного оружия" : "Ammo for laser weapons");
				string arg2 = (Plugin.translateRussian ? "Заряд" : "Charge");
				scanNode.subText = $"{arg}\n{arg2}: {currentBatteryCharge:F1}%";
			}
		}

		private string GetChargeTooltip()
		{
			string arg = (Plugin.translateRussian ? "Заряд батареи" : "Cell charge");
			return $"{arg}: {currentBatteryCharge:F1}%";
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (scanNodeInitialized)
			{
				UpdateScanNodeText();
			}
			if (!base.isHeld || !((Object)(object)base.playerHeldBy != (Object)null) || !((Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController) || base.playerHeldBy.ItemSlots == null || base.playerHeldBy.currentItemSlot < 0 || base.playerHeldBy.currentItemSlot >= base.playerHeldBy.ItemSlots.Length || !((Object)(object)base.playerHeldBy.ItemSlots[base.playerHeldBy.currentItemSlot] == (Object)(object)this))
			{
				return;
			}
			string chargeTooltip = GetChargeTooltip();
			if ((Object)(object)HUDManager.Instance != (Object)null && HUDManager.Instance.controlTipLines != null)
			{
				if (HUDManager.Instance.controlTipLines.Length > 2)
				{
					((TMP_Text)HUDManager.Instance.controlTipLines[2]).text = chargeTooltip;
					((Behaviour)HUDManager.Instance.controlTipLines[2]).enabled = true;
				}
				else if (HUDManager.Instance.controlTipLines.Length > 1)
				{
					((TMP_Text)HUDManager.Instance.controlTipLines[1]).text = chargeTooltip;
					((Behaviour)HUDManager.Instance.controlTipLines[1]).enabled = true;
				}
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
		}

		[ServerRpc(RequireOwnership = false)]
		public void UpdateBatteryChargeServerRpc(float newCharge)
		{
			//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_00dc: 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 val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3961940959u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref newCharge, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 3961940959u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					currentBatteryCharge = newCharge;
					UpdateBatteryChargeClientRpc(newCharge);
				}
			}
		}

		[ClientRpc]
		public void UpdateBatteryChargeClientRpc(float newCharge)
		{
			//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_00dc: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3704695492u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref newCharge, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3704695492u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				currentBatteryCharge = newCharge;
				if (scanNodeInitialized)
				{
					UpdateScanNodeText();
				}
				if (base.itemProperties.toolTips != null && base.itemProperties.toolTips.Length > 1)
				{
					base.itemProperties.toolTips[1] = GetChargeTooltip();
				}
				if (base.isHeld && (Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController && (Object)(object)base.playerHeldBy.ItemSlots[base.playerHeldBy.currentItemSlot] == (Object)(object)this)
				{
					((GrabbableObject)this).SetControlTipsForItem();
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3961940959u, new RpcReceiveHandler(__rpc_handler_3961940959), "UpdateBatteryChargeServerRpc");
			((NetworkBehaviour)this).__registerRpc(3704695492u, new RpcReceiveHandler(__rpc_handler_3704695492), "UpdateBatteryChargeClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_3961940959(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 newCharge = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref newCharge, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((HAI_LaserCellItem)(object)target).UpdateBatteryChargeServerRpc(newCharge);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3704695492(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 newCharge = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref newCharge, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((HAI_LaserCellItem)(object)target).UpdateBatteryChargeClientRpc(newCharge);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "HAI_LaserCellItem";
		}
	}
	public class HAI_LaserEmitterItem : CustomWeaponBase
	{
		private enum ActionType
		{
			None,
			Aim,
			Inspect,
			Other
		}

		[Header("Configuration")]
		public bool enableDebugTracers = true;

		public bool enablePositionDebug = false;

		public int gunCompatibleAmmoID = 1000;

		public float energyCostPerSecond = 2.5f;

		public float heatPerSecond = 15f;

		public float maxBeamDistance = 4f;

		public float triggerVolume = 0.2f;

		public float shootVolume = 3f;

		public float maxHissVolume = 1f;

		public float emitterLoopVolume = 0.2f;

		private float currentLoopVolume = 0f;

		[Header("Heat System")]
		public float coolingRate = 25f;

		public float overheatCoolingRate = 5f;

		public float heatWarningThreshold = 80f;

		[Header("Positioning Offsets")]
		private Vector3 firstPersonPos = new Vector3(0.125f, 0.109f, -0.016f);

		private Vector3 firstPersonRot = new Vector3(8.257f, 17.169f, -85.342f);

		private Vector3 thirdPersonPos = new Vector3(0.143f, 0.076f, 0.033f);

		private Vector3 thirdPersonRot = new Vector3(8.257f, 2.362f, -85.342f);

		[Header("States")]
		public bool isLoaded = false;

		public bool isLoading;

		public bool isUnloading;

		public bool isReloading;

		public bool isSwitchingMode;

		public bool cantFire;

		public bool isOverheated;

		public bool isModeSafe = true;

		public bool isFiringBeam = false;

		private bool localClientSendingFiringRPC = false;

		public bool isInspectingToggle = false;

		public bool isInspectingHold = false;

		private float nextShootTime = 0f;

		public float fireCooldown = 0.6f;

		private ScanNodeProperties scanNode;

		private bool scanNodeInitialized = false;

		public float currentBatteryCharge = 0f;

		public float currentHeatLevel = 0f;

		[Header("Aiming")]
		public bool isAiming = false;

		public float zoomDelay = 0.5f;

		private float aimStartTime = 0f;

		private bool localClientSendingAimRPC = false;

		private bool canZoom = false;

		[Header("Overheat State")]
		public bool isPlayingOverheatAnim = false;

		private Coroutine overheatAnimCoroutine;

		[Header("Door Breaching")]
		public float normalDoorMeltTime = 8f;

		public float bigDoorMeltTime = 16f;

		private static Dictionary<ulong, float> doorMeltProgress = new Dictionary<ulong, float>();

		private GameObject targetedDoor = null;

		private ulong targetedDoorId = 0uL;

		private float targetedDoorMaxTime = 1f;

		private Texture2D breachProgressTexture;

		private Texture2D breachBgTexture;

		private Texture2D breachLineTexture;

		private GUIStyle breachTextStyle;

		[Header("Components")]
		public Animator gunAnimator;

		public AudioSource gunAudio;

		private AudioSource hissAudioSource;

		private AudioSource loopAudioSource;

		public Transform gunRayPoint;

		public LineRenderer laserBeam;

		public MeshRenderer laserCellInPistolMesh;

		public MeshRenderer laserCellInHandMesh;

		[Header("Audio Clips")]
		public AudioClip triggerClickSFX;

		public AudioClip batteryInsertSFX;

		public AudioClip batteryEjectSFX;

		public AudioClip modeSwitchSFX;

		public AudioClip overheatSFX;

		public AudioClip overheatBeepSFX;

		public AudioClip gunHissLoopSFX;

		public AudioClip dischargedBeepSFX;

		[Header("Audio Clips")]
		public List<AudioClip> gunShootSFX = new List<AudioClip>();

		public AudioClip emitterLoopSFX;

		public AudioClip emitterEndSFX;

		private bool reloadHoldCompleted = false;

		private bool safetyHoldCompleted = false;

		private EnemyAI heldByEnemy;

		private bool localClientSendingSafetyRPC = false;

		private bool localClientSendingInspectToggleRPC = false;

		private bool localClientSendingInspectHoldRPC = false;

		private PlayerControllerB previousPlayerHeldBy;

		private float qPressTime = 0f;

		private bool qWasPressed = false;

		private float rPressTime = 0f;

		private bool rWasPressed = false;

		private float ePressTime = 0f;

		private bool eWasPressed = false;

		private const float HOLD_THRESHOLD = 0.5f;

		private const float ACTION_COOLDOWN = 0.5f;

		private float stopActionTime = 0f;

		private float lastBeepTime = 0f;

		private float lastDamageTime = 0f;

		private const float DAMAGE_TICK_RATE = 0.3f;

		private ActionType lastAction = ActionType.None;

		private float defaultFOV = 66f;

		private float zoomFOV = 50f;

		private float zoomSpeed = 15f;

		protected override RuntimeAnimatorController CustomPlayerAnimator => Plugin.playerAnimator;

		protected override RuntimeAnimatorController CustomOtherPlayerAnimator => Plugin.otherPlayerAnimator;

		protected override string HoldParameterName => "LaspistHold";

		public override void Start()
		{
			((GrabbableObject)this).Start();
			if ((Object)(object)gunAnimator == (Object)null)
			{
				Plugin.mls.LogError((object)"АХТУНГ! Эмиттер не нашел свой Animator!");
			}
			hissAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			hissAudioSource.spatialBlend = 1f;
			hissAudioSource.rolloffMode = (AudioRolloffMode)1;
			hissAudioSource.minDistance = 2f;
			hissAudioSource.maxDistance = 15f;
			hissAudioSource.loop = true;
			hissAudioSource.playOnAwake = false;
			if ((Object)(object)gunHissLoopSFX != (Object)null)
			{
				hissAudioSource.clip = gunHissLoopSFX;
			}
			loopAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			loopAudioSource.spatialBlend = 1f;
			loopAudioSource.rolloffMode = (AudioRolloffMode)1;
			loopAudioSource.minDistance = 2f;
			loopAudioSource.maxDistance = 15f;
			loopAudioSource.loop = true;
			loopAudioSource.playOnAwake = false;
			if ((Object)(object)emitterLoopSFX != (Object)null)
			{
				loopAudioSource.clip = emitterLoopSFX;
			}
			scanNode = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
			if ((Object)(object)scanNode != (Object)null)
			{
				scanNodeInitialized = true;
				UpdateScanNodeText();
			}
			if ((Object)(object)laserBeam != (Object)null)
			{
				((Renderer)laserBeam).enabled = false;
			}
			if ((Object)(object)laserCellInPistolMesh != (Object)null)
			{
				((Renderer)laserCellInPistolMesh).enabled = isLoaded;
			}
			if ((Object)(object)laserCellInHandMesh != (Object)null)
			{
				((Renderer)laserCellInHandMesh).enabled = false;
			}
			currentBatteryCharge = Mathf.Clamp(currentBatteryCharge, 0f, 100f);
			currentHeatLevel = Mathf.Clamp(currentHeatLevel, 0f, 100f);
			InitializeSafetyState();
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (scanNodeInitialized)
			{
				UpdateScanNodeText();
			}
			ProcessOverheatSystem();
			ProcessContinuousFiring();
			if ((Object)(object)loopAudioSource != (Object)null && (Object)(object)loopAudioSource.clip != (Object)null)
			{
				float num = 6.6666665f;
				if (isFiringBeam)
				{
					currentLoopVolume = Mathf.MoveTowards(currentLoopVolume, 1f, num * Time.deltaTime);
					if (!loopAudioSource.isPlaying && currentLoopVolume > 0f)
					{
						loopAudioSource.Play();
					}
				}
				else
				{
					currentLoopVolume = Mathf.MoveTowards(currentLoopVolume, 0f, num * Time.deltaTime);
					if (currentLoopVolume <= 0f && loopAudioSource.isPlaying)
					{
						loopAudioSource.Stop();
					}
				}
				loopAudioSource.volume = currentLoopVolume * emitterLoopVolume;
			}
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) && ((GrabbableObject)this).isHeld && !((GrabbableObject)this).isPocketed && !((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !isPlayingOverheatAnim)
			{
				bool isPressed = Mouse.current.leftButton.isPressed;
				if (Plugin.InputActionInstance.WeaponReloadKey.IsPressed() || Plugin.InputActionInstance.InspectKey.IsPressed() || Plugin.InputActionInstance.WeaponFireModeKey.IsPressed())
				{
					ForceStopFiring();
				}
				else if (!isPressed && (isFiringBeam || ((Object)(object)gunAnimator != (Object)null && gunAnimator.GetBool("Shooting"))))
				{
					ForceStopFiring();
				}
				HandleInspectInput();
				HandleReloadInput();
				HandleSafetyInput();
				HandleAimInput();
				HandleZoom();
			}
		}

		public override void LateUpdate()
		{
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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)
			//IL_0152: 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)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: 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_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			if (!((GrabbableObject)this).isPocketed)
			{
				if (!isLoading && !isUnloading && !isReloading)
				{
					if ((Object)(object)laserCellInHandMesh != (Object)null && ((Renderer)laserCellInHandMesh).enabled)
					{
						((Renderer)laserCellInHandMesh).enabled = false;
					}
					if ((Object)(object)laserCellInPistolMesh != (Object)null && ((Renderer)laserCellInPistolMesh).enabled != isLoaded)
					{
						((Renderer)laserCellInPistolMesh).enabled = isLoaded;
					}
				}
			}
			else
			{
				if ((Object)(object)laserCellInHandMesh != (Object)null && ((Renderer)laserCellInHandMesh).enabled)
				{
					((Renderer)laserCellInHandMesh).enabled = false;
				}
				if ((Object)(object)laserCellInPistolMesh != (Object)null && ((Renderer)laserCellInPistolMesh).enabled)
				{
					((Renderer)laserCellInPistolMesh).enabled = false;
				}
			}
			if (((GrabbableObject)this).isHeld && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				bool flag = (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController;
				Vector3 positionOffset = (flag ? firstPersonPos : thirdPersonPos);
				Vector3 rotationOffset = (flag ? firstPersonRot : thirdPersonRot);
				if (enablePositionDebug)
				{
					bool isPressed = ((ButtonControl)Keyboard.current.leftAltKey).isPressed;
					bool isPressed2 = ((ButtonControl)Keyboard.current.rightAltKey).isPressed;
					if (isPressed || isPressed2)
					{
						float num = 0.25f * Time.deltaTime;
						float num2 = 15f * Time.deltaTime;
						if (isPressed)
						{
							if (((ButtonControl)Keyboard.current.lKey).isPressed)
							{
								positionOffset.x += num;
							}
							if (((ButtonControl)Keyboard.current.jKey).isPressed)
							{
								positionOffset.x -= num;
							}
							if (((ButtonControl)Keyboard.current.oKey).isPressed)
							{
								positionOffset.y += num;
							}
							if (((ButtonControl)Keyboard.current.uKey).isPressed)
							{
								positionOffset.y -= num;
							}
							if (((ButtonControl)Keyboard.current.iKey).isPressed)
							{
								positionOffset.z += num;
							}
							if (((ButtonControl)Keyboard.current.kKey).isPressed)
							{
								positionOffset.z -= num;
							}
						}
						else if (isPressed2)
						{
							if (((ButtonControl)Keyboard.current.iKey).isPressed)
							{
								rotationOffset.x += num2;
							}
							if (((ButtonControl)Keyboard.current.kKey).isPressed)
							{
								rotationOffset.x -= num2;
							}
							if (((ButtonControl)Keyboard.current.lKey).isPressed)
							{
								rotationOffset.y += num2;
							}
							if (((ButtonControl)Keyboard.current.jKey).isPressed)
							{
								rotationOffset.y -= num2;
							}
							if (((ButtonControl)Keyboard.current.oKey).isPressed)
							{
								rotationOffset.z += num2;
							}
							if (((ButtonControl)Keyboard.current.uKey).isPressed)
							{
								rotationOffset.z -= num2;
							}
						}
						if (((ButtonControl)Keyboard.current.enterKey).wasPressedThisFrame)
						{
							CultureInfo invariantCulture = CultureInfo.InvariantCulture;
							string text = positionOffset.x.ToString("F3", invariantCulture);
							string text2 = positionOffset.y.ToString("F3", invariantCulture);
							string text3 = positionOffset.z.ToString("F3", invariantCulture);
							string text4 = rotationOffset.x.ToString("F3", invariantCulture);
							string text5 = rotationOffset.y.ToString("F3", invariantCulture);
							string text6 = rotationOffset.z.ToString("F3", invariantCulture);
							string text7 = (flag ? "1-Е ЛИЦО" : "3-Е ЛИЦО");
							string text8 = (flag ? "firstPersonPos" : "thirdPersonPos");
							string text9 = (flag ? "firstPersonRot" : "thirdPersonRot");
							Plugin.mls.LogInfo((object)("====== ИДЕАЛЬНЫЕ КООРДИНАТЫ: " + text7 + " ======"));
							Plugin.mls.LogInfo((object)("private Vector3 " + text8 + " = new Vector3(" + text + "f, " + text2 + "f, " + text3 + "f);"));
							Plugin.mls.LogInfo((object)("private Vector3 " + text9 + " = new Vector3(" + text4 + "f, " + text5 + "f, " + text6 + "f);"));
							Plugin.mls.LogInfo((object)"==========================================");
						}
					}
					if (flag)
					{
						firstPersonPos = positionOffset;
						firstPersonRot = rotationOffset;
					}
					else
					{
						thirdPersonPos = positionOffset;
						thirdPersonRot = rotationOffset;
					}
				}
				((GrabbableObject)this).itemProperties.positionOffset = positionOffset;
				((GrabbableObject)this).itemProperties.rotationOffset = rotationOffset;
			}
			((GrabbableObject)this).LateUpdate();
		}

		private void UpdateScanNodeText()
		{
			if ((Object)(object)scanNode != (Object)null)
			{
				string text = (Plugin.translateRussian ? "Лазерный Эмиттер" : "Laser Emitter");
				string arg = (Plugin.translateRussian ? "Заряд" : "Charge");
				if (isLoaded)
				{
					scanNode.subText = $"{text}\n{arg}: {currentBatteryCharge:F1}%";
					return;
				}
				string text2 = (Plugin.translateRussian ? "БАТАРЕЯ ОТСУТСТВУЕТ" : "NO CELL INSERTED");
				scanNode.subText = text + "\n" + text2;
			}
		}

		public override int GetItemDataToSave()
		{
			((GrabbableObject)this).GetItemDataToSave();
			int num = Mathf.RoundToInt(currentBatteryCharge * 100f);
			int num2 = Mathf.RoundToInt(currentHeatLevel * 100f);
			int num3 = (num << 16) | (num2 & 0xFFFF);
			if (isModeSafe)
			{
				num3 |= int.MinValue;
			}
			if (isLoaded)
			{
				num3 |= 0x40000000;
			}
			return num3;
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			if (saveData != 0)
			{
				isModeSafe = (saveData & int.MinValue) != 0;
				isLoaded = (saveData & 0x40000000) != 0;
				int num = saveData & 0x3FFFFFFF;
				int num2 = (num >> 16) & 0xFFFF;
				int num3 = num & 0xFFFF;
				currentBatteryCharge = Mathf.Clamp((float)num2 / 100f, 0f, 100f);
				currentHeatLevel = Mathf.Clamp((float)num3 / 100f, 0f, 100f);
				if ((Object)(object)laserCellInPistolMesh != (Object)null)
				{
					((Renderer)laserCellInPistolMesh).enabled = isLoaded;
				}
				InitializeSafetyState();
			}
		}

		private bool CanPerformAction(ActionType attemptingAction)
		{
			if (Time.time < stopActionTime + 0.5f)
			{
				if (attemptingAction == ActionType.Aim && lastAction == ActionType.Aim)
				{
					return true;
				}
				if (attemptingAction == ActionType.Inspect && lastAction == ActionType.Inspect)
				{
					return true;
				}
				return false;
			}
			if (attemptingAction == ActionType.Aim && (isInspectingToggle || isInspectingHold))
			{
				return false;
			}
			if (attemptingAction == ActionType.Inspect && isAiming)
			{
				return false;
			}
			if (attemptingAction == ActionType.Other && (isAiming || isInspectingToggle || isInspectingHold))
			{
				return false;
			}
			return true;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (isSwitchingMode || isLoading || isUnloading || isReloading || isPlayingOverheatAnim)
			{
				return;
			}
			if (isInspectingToggle)
			{
				if (buttonDown)
				{
					ToggleInspectAndSync();
				}
			}
			else
			{
				if (Time.time < stopActionTime + 0.5f || Plugin.InputActionInstance.InspectKey.IsPressed())
				{
					return;
				}
				if (buttonDown)
				{
					if (!(Time.time < nextShootTime))
					{
						nextShootTime = Time.time + fireCooldown;
						if ((Object)(object)gunAnimator != (Object)null)
						{
							gunAnimator.SetBool("Shooting", true);
						}
						if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.playerBodyAnimator != (Object)null)
						{
							((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("LasEmitShoot", true);
						}
						if ((Object)(object)triggerClickSFX != (Object)null)
						{
							gunAudio.PlayOneShot(triggerClickSFX, triggerVolume);
						}
						if (!isInspectingHold && !isModeSafe && !isOverheated && currentBatteryCharge > 0f)
						{
							SetFiringStateAndSync(fire: true);
						}
					}
				}
				else
				{
					ForceStopFiring();
				}
			}
		}

		public override void ItemInteractLeftRight(bool right)
		{
			((GrabbableObject)this).ItemInteractLeftRight(right);
		}

		public override void EquipItem()
		{
			//IL_006e: 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_0046: 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)
			((GrabbableObject)this).itemProperties.disableHandsOnWall = true;
			base.EquipItem();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				if ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					((Component)this).transform.localPosition = firstPersonPos;
					((Component)this).transform.localEulerAngles = firstPersonRot;
				}
				else
				{
					((Component)this).transform.localPosition = thirdPersonPos;
					((Component)this).transform.localEulerAngles = thirdPersonRot;
				}
			}
			if ((Object)(object)laserCellInPistolMesh != (Object)null)
			{
				((Renderer)laserCellInPistolMesh).enabled = isLoaded;
			}
			if ((Object)(object)laserCellInHandMesh != (Object)null)
			{
				((Renderer)laserCellInHandMesh).enabled = false;
			}
			previousPlayerHeldBy = ((GrabbableObject)this).playerHeldBy;
			previousPlayerHeldBy.equippedUsableItemQE = true;
			UpdateWeaponAnimator(((GrabbableObject)this).playerHeldBy, ((GrabbableObject)this).playerHeldBy.playerBodyAnimator, isDroppingWeapon: false);
			if ((Object)(object)((GrabbableObject)this).playerHeldBy.playerBodyAnimator != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("LaspistHold", true);
				((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("LaspistSafety", isModeSafe);
				((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetTrigger("SwitchHoldAnimationTwoHanded");
			}
			if ((Object)(object)gunAnimator != (Object)null)
			{
				gunAnimator.SetBool("SafetyMode", isModeSafe);
			}
			if ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				defaultFOV = ((GrabbableObject)this).playerHeldBy.gameplayCamera.fieldOfView;
			}
			isAiming = false;
		}

		public override void PocketItem()
		{
			SetFiringStateAndSync(fire: false);
			CleanUpOnDrop();
			base.PocketItem();
		}

		public override void DiscardItem()
		{
			SetFiringStateAndSync(fire: false);
			CleanUpOnDrop();
			base.DiscardItem();
		}

		private void CleanUpOnDrop()
		{
			if (isPlayingOverheatAnim)
			{
				if (overheatAnimCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(overheatAnimCoroutine);
				}
				isPlayingOverheatAnim = false;
				cantFire = false;
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					((GrabbableObject)this).playerHeldBy.isGrabbingObjectAnimation = false;
				}
			}
			if ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController && (Object)(object)((GrabbableObject)this).playerHeldBy.gameplayCamera != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.gameplayCamera.fieldOfView = defaultFOV;
			}
			ResetInteractionState();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				UpdateWeaponAnimator(((GrabbableObject)this).playerHeldBy, ((GrabbableObject)this).playerHeldBy.playerBodyAnimator, isDroppingWeapon: true);
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			if ((Object)(object)laserCellInPistolMesh != (Object)null)
			{
				((Renderer)laserCellInPistolMesh).enabled = isLoaded;
			}
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				UpdateWeaponAnimator(((GrabbableObject)this).playerHeldBy, ((GrabbableObject)this).playerHeldBy.playerBodyAnimator, isDroppingWeapon: false);
			}
		}

		public override void GrabItemFromEnemy(EnemyAI enemy)
		{
			((GrabbableObject)this).GrabItemFromEnemy(enemy);
			if ((Object)(object)laserCellInPistolMesh != (Object)null)
			{
				((Renderer)laserCellInPistolMesh).enabled = isLoaded;
			}
			heldByEnemy = enemy;
		}

		public override void DiscardItemFromEnemy()
		{
			((GrabbableObject)this).DiscardItemFromEnemy();
			if ((Object)(object)laserCellInPistolMesh != (Object)null)
			{
				((Renderer)laserCellInPistolMesh).enabled = isLoaded;
			}
			heldByEnemy = null;
		}

		private void SetFiringStateAndSync(bool fire)
		{
			if (isFiringBeam != fire)
			{
				localClientSendingFiringRPC = true;
				SetFiringStateLocal(fire);
				SetFiringStateServerRpc(fire);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetFiringStateServerRpc(bool fire)
		{
			//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_00dc: 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 val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1831832056u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref fire, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1831832056u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SetFiringStateClientRpc(fire);
				}
			}
		}

		[ClientRpc]
		public void SetFiringStateClientRpc(bool fire)
		{
			//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_00dc: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2224198530u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref fire, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2224198530u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (localClientSendingFiringRPC)
				{
					localClientSendingFiringRPC = false;
				}
				else
				{
					SetFiringStateLocal(fire);
				}
			}
		}

		private void SetFiringStateLocal(bool fire)
		{
			isFiringBeam = fire;
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.playerBodyAnimator != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("LasEmitShoot", fire);
			}
			if ((Object)(object)gunAnimator != (Object)null)
			{
				gunAnimator.SetBool("Shooting", fire);
			}
			if ((Object)(object)laserBeam != (Object)null)
			{
				((Renderer)laserBeam).enabled = fire;
			}
			if (fire)
			{
				if (gunShootSFX.Count > 0)
				{
					int index = Random.Range(0, gunShootSFX.Count);
					gunAudio.PlayOneShot(gunShootSFX[index], shootVolume);
				}
				return;
			}
			if ((Object)(object)emitterEndSFX != (Object)null)
			{
				gunAudio.PlayOneShot(emitterEndSFX);
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				UpdateBatteryChargeServerRpc(currentBatteryCharge);
			}
		}

		private void ProcessContinuousFiring()
		{
			if (!isFiringBeam)
			{
				return;
			}
			if (isModeSafe || isOverheated || currentBatteryCharge <= 0f || isReloading || isSwitchingMode || ((GrabbableObject)this).isPocketed || !((GrabbableObject)this).isHeld)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					SetFiringStateAndSync(fire: false);
				}
				return;
			}
			float num = energyCostPerSecond * Time.deltaTime;
			currentBatteryCharge -= num;
			float num2 = heatPerSecond * Time.deltaTime;
			currentHeatLevel += num2;
			UpdateBeamVisuals();
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (currentBatteryCharge <= 0f)
				{
					currentBatteryCharge = 0f;
					SetFiringStateAndSync(fire: false);
					PlayDischargeBeepClientRpc();
				}
				if (currentHeatLevel >= 100f)
				{
					currentHeatLevel = 100f;
					SetFiringStateAndSync(fire: false);
					TriggerOverheat();
				}
				else if (currentHeatLevel >= heatWarningThreshold && (Object)(object)overheatBeepSFX != (Object)null && Time.time >= lastBeepTime + 3f)
				{
					gunAudio.PlayOneShot(overheatBeepSFX, triggerVolume * 0.75f);
					lastBeepTime = Time.time;
				}
			}
		}

		private void UpdateBeamVisuals()
		{
			//IL_0056: 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_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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: 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_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: 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_07ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_081f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0818: Unknown result type (might be due to invalid IL or missing references)
			//IL_0824: Unknown result type (might be due to invalid IL or missing references)
			//IL_0827: Unknown result type (might be due to invalid IL or missing references)
			//IL_0828: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_083b: Unknown result type (might be due to invalid IL or missing references)
			//IL_083f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: 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_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: 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_0714: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_0727: 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_072b: 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_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0793: Unknown result type (might be due to invalid IL or missing references)
			//IL_0795: Unknown result type (might be due to invalid IL or missing references)
			//IL_073e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0742: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_07aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0777: Unknown result type (might be due to invalid IL or missing references)
			//IL_077e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: 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_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)gunRayPoint == (Object)null)
			{
				return;
			}
			Transform val = (((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null) ? ((Component)((GrabbableObject)this).playerHeldBy).transform : (((Object)(object)heldByEnemy != (Object)null) ? ((Component)heldByEnemy).transform : null));
			Vector3 position = gunRayPoint.position;
			Vector3 forward = gunRayPoint.forward;
			float num = maxBeamDistance;
			float num2 = 0.2f;
			float num3 = 0.2f;
			int num4 = (StartOfRound.Instance.collidersAndRoomMaskAndDefault | 0x200 | 8 | 0x80000 | 0x1000 | 0x100 | 0x200000) & -268435457;
			RaycastHit[] array = Physics.SphereCastAll(position, num3, forward, num, num4, (QueryTriggerInteraction)2);
			Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
			Vector3 val2 = position + forward * num;
			bool flag = false;
			bool flag2 = false;
			List<GameObject> list = new List<GameObject>();
			bool flag3 = Time.time - lastDamageTime >= 0.3f;
			targetedDoor = null;
			if (flag3 && ((NetworkBehaviour)this).IsOwner)
			{
				TryDamageBugsOnPlayer(((GrabbableObject)this).playerHeldBy, Plugin.laseremitterpistolMonsterDamage, forward);
			}
			RaycastHit[] array2 = array;
			IHittable val7 = default(IHittable);
			RaycastHit val9 = default(RaycastHit);
			for (int num5 = 0; num5 < array2.Length; num5++)
			{
				RaycastHit val3 = array2[num5];
				GameObject gameObject = ((Component)((RaycastHit)(ref val3)).collider).gameObject;
				int layer = gameObject.layer;
				string name = ((Object)((RaycastHit)(ref val3)).collider).name;
				Vector3 val4 = ((((RaycastHit)(ref val3)).point != Vector3.zero) ? ((RaycastHit)(ref val3)).point : (position + forward * ((RaycastHit)(ref val3)).distance));
				if (((Object)(object)val != (Object)null && ((Object)(object)((RaycastHit)(ref val3)).transform == (Object)(object)val || ((RaycastHit)(ref val3)).transform.IsChildOf(val))) || list.Contains(gameObject))
				{
					continue;
				}
				list.Add(gameObject);
				if (layer == 28 || layer == 6 || layer == 12 || name.Contains("Stair") || name.Contains("Catwalk") || name.Contains("Rail") || name.Contains("Raiing"))
				{
					continue;
				}
				DoorLock normalDoor = gameObject.GetComponent<DoorLock>() ?? gameObject.GetComponentInParent<DoorLock>();
				if ((Object)(object)normalDoor != (Object)null)
				{
					if (normalDoor.isLocked)
					{
						targetedDoor = ((Component)normalDoor).gameObject;
						ProcessDoorMelting(((NetworkBehaviour)normalDoor).NetworkObjectId, normalDoorMeltTime, flag3, delegate
						{
							normalDoor.UnlockDoorSyncWithServer();
						});
						val2 = val4;
						flag = true;
						if (enableDebugTracers && flag3)
						{
							CreateDebugBurnMark(val4, ((RaycastHit)(ref val3)).normal, ((RaycastHit)(ref val3)).transform);
						}
						break;
					}
					if (((RaycastHit)(ref val3)).collider.isTrigger)
					{
						continue;
					}
					val2 = val4;
					flag = true;
					if (enableDebugTracers && flag3)
					{
						CreateDebugBurnMark(val4, ((RaycastHit)(ref val3)).normal, ((RaycastHit)(ref val3)).transform);
					}
					break;
				}
				TerminalAccessibleObject bigDoor = gameObject.GetComponent<TerminalAccessibleObject>() ?? gameObject.GetComponentInParent<TerminalAccessibleObject>();
				if ((Object)(object)bigDoor != (Object)null && bigDoor.isBigDoor)
				{
					FieldInfo field = typeof(TerminalAccessibleObject).GetField("isDoorOpen", BindingFlags.Instance | BindingFlags.NonPublic);
					if (!(field != null) || !(bool)field.GetValue(bigDoor))
					{
						targetedDoor = ((Component)bigDoor).gameObject;
						ProcessDoorMelting(((NetworkBehaviour)bigDoor).NetworkObjectId, bigDoorMeltTime, flag3, delegate
						{
							bigDoor.SetDoorOpenServerRpc(true);
						});
						val2 = val4;
						flag = true;
						if (enableDebugTracers && flag3)
						{
							CreateDebugBurnMark(val4, ((RaycastHit)(ref val3)).normal, ((RaycastHit)(ref val3)).transform);
						}
						break;
					}
					if (((RaycastHit)(ref val3)).collider.isTrigger)
					{
						continue;
					}
					val2 = val4;
					flag = true;
					if (enableDebugTracers && flag3)
					{
						CreateDebugBurnMark(val4, ((RaycastHit)(ref val3)).normal, ((RaycastHit)(ref val3)).transform);
					}
					break;
				}
				PlayerControllerB val5 = gameObject.GetComponent<PlayerControllerB>() ?? gameObject.GetComponentInParent<PlayerControllerB>();
				if ((Object)(object)val5 != (Object)null)
				{
					if (!((Object)(object)val5 != (Object)(object)((GrabbableObject)this).playerHeldBy) || val5.isPlayerDead || val5.health <= 0)
					{
						continue;
					}
					if (flag3 && !TryDamageBugsOnPlayer(val5, Mathf.Max(1, Plugin.laseremitterpistolMonsterDamage), forward) && ((NetworkBehaviour)this).IsOwner)
					{
						val5.DamagePlayerFromOtherClientServerRpc(Plugin.laseremitterpistolPlayerDamage, forward * 10f, (int)((GrabbableObject)this).playerHeldBy.playerClientId);
					}
					val2 = val4;
					flag = true;
					if (enableDebugTracers && flag3)
					{
						CreateDebugVisualsSphere(val4, num3, Color.blue);
					}
					break;
				}
				Landmine val6 = gameObject.GetComponentInParent<Landmine>() ?? gameObject.GetComponentInChildren<Landmine>();
				if ((Object)(object)val6 != (Object)null)
				{
					if (flag3 && ((NetworkBehaviour)this).IsOwner && !val6.hasExploded)
					{
						val6.ExplodeMineServerRpc();
					}
					val2 = val4;
					flag = true;
					if (enableDebugTracers && flag3)
					{
						CreateDebugVisualsSphere(val4, num3, new Color(1f, 0.5f, 0f));
					}
					break;
				}
				if (((Component)((RaycastHit)(ref val3)).collider).TryGetComponent<IHittable>(ref val7))
				{
					EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref val3)).collider).GetComponent<EnemyAICollisionDetect>();
					if (!((Object)(object)component != (Object)null) || !((Object)(object)component.mainScript != (Object)null) || (!component.mainScript.isEnemyDead && component.mainScript.enemyHP > 0 && (!((Object)(object)heldByEnemy != (Object)null) || !((Object)(object)component.mainScript == (Object)(object)heldByEnemy))))
					{
						if (flag3 && ((NetworkBehaviour)this).IsOwner)
						{
							val7.Hit(Mathf.Max(1, Plugin.laseremitterpistolMonsterDamage), forward, ((GrabbableObject)this).playerHeldBy, true, -1);
						}
						val2 = val4;
						flag = true;
						if (enableDebugTracers && flag3)
						{
							CreateDebugVisualsSphere(val4, num3, Color.red);
						}
						break;
					}
				}
				else
				{
					if (((RaycastHit)(ref val3)).collider.isTrigger)
					{
						continue;
					}
					Vector3 val8 = val4 + forward * (num2 + 0.01f);
					if (Physics.Linecast(val8, val4, ref val9, num4, (QueryTriggerInteraction)1))
					{
						float num6 = Vector3.Distance(val4, ((RaycastHit)(ref val9)).point);
						if (num6 < num2)
						{
							num2 -= num6;
							flag2 = true;
							if (enableDebugTracers && flag3)
							{
								CreateDebugBurnMark(((RaycastHit)(ref val9)).point, ((RaycastHit)(ref val9)).normal, ((RaycastHit)(ref val9)).transform);
							}
							continue;
						}
					}
					val2 = val4;
					flag = true;
					if (enableDebugTracers && flag3)
					{
						CreateDebugBurnMark(val4, ((RaycastHit)(ref val3)).normal, ((RaycastHit)(ref val3)).transform);
					}
					break;
				}
			}
			if ((Object)(object)laserBeam != (Object)null)
			{
				laserBeam.SetPosition(0, position);
				laserBeam.SetPosition(1, val2);
			}
			if (enableDebugTracers && flag3)
			{
				Color col = (flag2 ? Color.yellow : Color.green);
				CreateDebugVisualsLine(position, val2, col);
				if (flag)
				{
					CreateDebugVisualsSphere(val2, num3, Color.yellow);
				}
			}
			if (flag3)
			{
				lastDamageTime = Time.time;
			}
		}

		private void ProcessDoorMelting(ulong doorId, float maxTime, bool isTick, Action onComplete)
		{
			targetedDoorId = doorId;
			targetedDoorMaxTime = maxTime;
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (!doorMeltProgress.ContainsKey(doorId))
			{
				doorMeltProgress[doorId] = 0f;
			}
			doorMeltProgress[doorId] += Time.deltaTime;
			if (isTick)
			{
				AddDoorMeltProgressServerRpc(doorId, 0.3f, ((GrabbableObject)this).playerHeldBy.playerClientId);
			}
			if (doorMeltProgress[doorId] >= maxTime)
			{
				onComplete?.Invoke();
				doorMeltProgress[doorId] = 0f;
				targetedDoor = null;
				if ((Object)(object)triggerClickSFX != (Object)null)
				{
					gunAudio.PlayOneShot(triggerClickSFX, 1f);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void AddDoorMeltProgressServerRpc(ulong doorId, float amount, ulong senderId)
		{
			//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_0071: 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_00f6: 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 val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(829105579u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, doorId);
					((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref amount, default(ForPrimitives));
					BytePacker.WriteValueBitPacked(val, senderId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 829105579u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					AddDoorMeltProgressClientRpc(doorId, amount, senderId);
				}
			}
		}

		[ClientRpc]
		public void AddDoorMeltProgressClientRpc(ulong doorId, float amount, ulong senderId)
		{
			//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_0071: 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_00f6: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3451129523u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, doorId);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref amount, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val, senderId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3451129523u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) || GameNetworkManager.Instance.localPlayerController.playerClientId != senderId)
			{
				if (!doorMeltProgress.ContainsKey(doorId))
				{
					doorMeltProgress[doorId] = 0f;
				}
				doorMeltProgress[doorId] += amount;
			}
		}

		protected void OnGUI()
		{
			//IL_02b9: 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_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: 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_00a3: Expected O, but got Unknown
			//IL_039e: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected O, but got Unknown
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			if (!isFiringBeam || !((Object)(object)targetedDoor != (Object)null) || !((NetworkBehaviour)this).IsOwner || !((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null) || !((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				return;
			}
			float num = (doorMeltProgress.ContainsKey(targetedDoorId) ? doorMeltProgress[targetedDoorId] : 0f);
			float num2 = Mathf.Clamp01(num / targetedDoorMaxTime);
			if (breachTextStyle == null)
			{
				breachTextStyle = new GUIStyle();
				Font val = null;
				Font[] array = Resources.FindObjectsOfTypeAll<Font>();
				foreach (Font val2 in array)
				{
					if (((Object)val2).name.Contains("3270") || ((Object)val2).name.Contains("brawl") || ((Object)val2).name.ToLower().Contains("pixel"))
					{
						val = val2;
						break;
					}
				}
				breachTextStyle.font = (((Object)(object)val != (Object)null) ? val : Resources.GetBuiltinResource<Font>("Arial.ttf"));
				breachTextStyle.alignment = (TextAnchor)4;
				breachTextStyle.fontSize = 52;
				breachTextStyle.fontStyle = (FontStyle)1;
				breachTextStyle.normal.textColor = new Color(0f, 0.9f, 1f, 0.7f);
				breachBgTexture = new Texture2D(1, 1);
				breachBgTexture.SetPixel(0, 0, new Color(0f, 0.1f, 0.25f, 0.25f));
				breachBgTexture.Apply();
				breachProgressTexture = new Texture2D(1, 1);
				breachProgressTexture.SetPixel(0, 0, new Color(0f, 0.5f, 1f, 0.4f));
				breachProgressTexture.Apply();
				breachLineTexture = new Texture2D(1, 2);
				breachLineTexture.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.15f));
				breachLineTexture.SetPixel(0, 1, new Color(0f, 0f, 0f, 0f));
				((Texture)breachLineTexture).filterMode = (FilterMode)0;
				((Texture)breachLineTexture).wrapMode = (TextureWrapMode)0;
				breachLineTexture.Apply();
			}
			float num3 = 900f;
			float num4 = 100f;
			float num5 = ((float)Screen.width - num3) / 2f;
			float num6 = (float)Screen.height - 450f;
			GUI.color = Color.white;
			GUI.DrawTexture(new Rect(num5, num6, num3, num4), (Texture)(object)breachBgTexture, (ScaleMode)0);
			float num7 = (num3 - 10f) * num2;
			GUI.DrawTexture(new Rect(num5 + 5f, num6 + 5f, num7, num4 - 10f), (Texture)(object)breachProgressTexture, (ScaleMode)0);
			GUI.color = new Color(1f, 1f, 1f, 0.4f);
			GUI.DrawTextureWithTexCoords(new Rect(num5, num6, num3, num4), (Texture)(object)breachLineTexture, new Rect(0f, 0f, 1f, num4 / 4f));
			string text = (Plugin.translateRussian ? $"ПЛАВКА... {num2 * 100f:F0}%" : $"MELTING... {num2 * 100f:F0}%");
			GUI.color = Color.white;
			GUI.Label(new Rect(num5, num6, num3, num4), text, breachTextStyle);
		}

		private void CreateDebugVisualsLine(Vector3 start, Vector3 end, Color col)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002d: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0056: 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)
			GameObject val = new GameObject("DebugLaserLine");
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			val2.startWidth = 0.01f;
			val2.endWidth = 0.01f;
			val2.SetPosition(0, start);
			val2.SetPosition(1, end);
			Material material = new Material(Shader.Find("Sprites/Default"));
			((Renderer)val2).material = material;
			val2.startColor = col;
			val2.endColor = col;
			Object.Destroy((Object)(object)val, 2f);
		}

		private void CreateDebugVisualsSphere(Vector3 pos, float radius, Color col)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val).name = "DebugHitSphere";
			Collider val2 = default(Collider);
			if (val.TryGetComponent<Collider>(ref val2))
			{
				Object.Destroy((Object)(object)val2);
			}
			val.transform.position = pos;
			val.transform.localScale = Vector3.one * (radius * 2f);
			Renderer component = val.GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				Material material = new Material(Shader.Find("Sprites/Default"));
				component.material = material;
				component.material.color = col;
			}
			Object.Destroy((Object)(object)val, 2f);
		}

		private void CreateDebugBurnMark(Vector3 point, Vector3 normal, Transform parent)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0070: 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_00a1: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val).name = "DebugBurnMark";
			Collid