Decompiled source of LazerWeaponry v1.0.1

BepInEx/plugins/LazerWeaponry/cyclozarin.contentwarning.LazerWeaponry.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using ConfigSync;
using ContentSettings.API.Attributes;
using ContentSettings.API.Settings;
using LazerWeaponry.Hooks;
using Microsoft.CodeAnalysis;
using MortalEnemies;
using MyceliumNetworking;
using On;
using Photon.Pun;
using Steamworks;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Localization.PropertyVariants;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;
using Zorro.Core.CLI;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Ashley.MeshSplitter")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("com.rlabrecque.steamworks.net")]
[assembly: IgnoresAccessChecksTo("Discord")]
[assembly: IgnoresAccessChecksTo("HBAO.Demo.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("MeshSplit")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("pworld")]
[assembly: IgnoresAccessChecksTo("sc.posteffects.runtime")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Tayx.Graphy")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.PlayableGraphVisualizer")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipeline.Universal.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Shaders")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.Splines")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("Zorro.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.PhotonUtility")]
[assembly: IgnoresAccessChecksTo("Zorro.Recorder")]
[assembly: IgnoresAccessChecksTo("Zorro.Settings.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.UI.Runtime")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("cyclozarin.contentwarning.LazerWeaponry")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+f9dab314c7d8046e56245804cfe684f375489dac")]
[assembly: AssemblyProduct("LazerWeaponry")]
[assembly: AssemblyTitle("cyclozarin.contentwarning.LazerWeaponry")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace LazerWeaponry
{
	[BepInPlugin("cyclozarin.contentwarning.LazerWeaponry", "LazerWeaponry", "1.0.1")]
	[ContentWarningPlugin("cyclozarin.contentwarning.LazerWeaponry", "1.0.1", false)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class LazerWeaponryPlugin : BaseUnityPlugin
	{
		internal static class InitialSettings
		{
			internal static float HeadshotSoundVolume = 0.75f;

			internal static float KillSoundVolume = 1f;

			internal static int Damage => (int)SyncedSettings.sync_Damage.CurrentValue;

			internal static int MaxAmmo => (int)SyncedSettings.sync_MaxAmmo.CurrentValue;

			internal static float DelayAfterFire => (float)SyncedSettings.sync_DelayAfterFire.CurrentValue;

			internal static float HeadshotDamageMultiplier => (float)SyncedSettings.sync_HeadshotDamageMultiplier.CurrentValue;

			internal static bool PVPMode => (bool)SyncedSettings.sync_PVPMode.CurrentValue;

			internal static float MonsterFallTime => (float)SyncedSettings.sync_MonsterFallTime.CurrentValue;

			internal static float MonsterHitForceMultiplier => (float)SyncedSettings.sync_MonsterHitForceMultiplier.CurrentValue;

			internal static int RecoilForce => (int)SyncedSettings.sync_RecoilForce.CurrentValue;

			internal static int PlayerKillReward => (int)SyncedSettings.sync_PlayerKillReward.CurrentValue;

			internal static int MonsterKillReward => (int)SyncedSettings.sync_MonsterKillReward.CurrentValue;

			internal static bool VulnerableEnemies => (bool)SyncedSettings.sync_VulnerableEnemies.CurrentValue;

			internal static float HeadshotFallTime => (float)SyncedSettings.sync_HeadshotFallTime.CurrentValue;
		}

		internal static class SyncedSettings
		{
			internal static Configuration sync_PVPMode = new Configuration("LazerWeaponryPlugin", "LW_PvPMode", (object)false);

			internal static Configuration sync_Damage = new Configuration("LazerWeaponryPlugin", "LW_Damage", (object)10);

			internal static Configuration sync_MaxAmmo = new Configuration("LazerWeaponryPlugin", "LW_MaxAmmo", (object)10);

			internal static Configuration sync_DelayAfterFire = new Configuration("LazerWeaponryPlugin", "LW_DelayAfterFire", (object)0.1f);

			internal static Configuration sync_HeadshotDamageMultiplier = new Configuration("LazerWeaponryPlugin", "LW_HeadshotDamageMultiplier", (object)2f);

			internal static Configuration sync_MonsterFallTime = new Configuration("LazerWeaponryPlugin", "LW_MonsterFallTime", (object)2f);

			internal static Configuration sync_MonsterHitForceMultiplier = new Configuration("LazerWeaponryPlugin", "LW_MonsterHitForceMultiplier", (object)0.25f);

			internal static Configuration sync_RecoilForce = new Configuration("LazerWeaponryPlugin", "LW_RecoilForce", (object)25);

			internal static Configuration sync_PlayerKillReward = new Configuration("LazerWeaponryPlugin", "LW_PlayerKillReward", (object)35);

			internal static Configuration sync_MonsterKillReward = new Configuration("LazerWeaponryPlugin", "LW_MonsterKillReward", (object)15);

			internal static Configuration sync_HeadshotFallTime = new Configuration("LazerWeaponryPlugin", "LW_HeadshotFallTime", (object)1.5f);

			internal static Configuration sync_VulnerableEnemies = new Configuration("LazerWeaponryPlugin", "LW_VulnerableEnemies", (object)false);
		}

		private enum SoundType
		{
			Headshot,
			Kill
		}

		internal static GameObject Projectile = null;

		internal const uint MYCELIUM_ID = 391309u;

		internal AssetBundle Bundle;

		internal AudioClip HeadshotSound;

		internal AudioClip KillSound;

		internal static Dictionary<string, int> MapNameToDiveBellCount = new Dictionary<string, int>
		{
			{ "FactoryScene", 20 },
			{ "HarbourScene", 8 },
			{ "MinesScene", 7 }
		};

		private static Item _rescueHookItem = null;

		private int _totalRewardForAllKills;

		public static LazerWeaponryPlugin Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static int LocalPhotonViewID => Player.localPlayer.refs.view.ViewID;

		internal static bool IsOnSurface
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				Scene activeScene = SceneManager.GetActiveScene();
				return ((Scene)(ref activeScene)).name.Contains("Surface");
			}
		}

		internal static bool MortalityLoaded => Chainloader.PluginInfos.ContainsKey("rivinwin.MortalEnemies");

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			if (!MortalityLoaded)
			{
				Logger.LogWarning((object)"MortalEnemies is not loaded. Vulnerable enemies setting won't work.");
			}
			HookAll();
			RegisterSyncedSettings();
			MyceliumNetwork.RegisterNetworkObject((object)this, 391309u, 0);
			MyceliumNetwork.RegisterLobbyDataKey("diveBellArrivingMessage");
			MyceliumNetwork.RegisterLobbyDataKey("diveBellIndexes");
			Logger.LogInfo((object)("LazerWeaponry by " + "cyclozarin.contentwarning.LazerWeaponry".Split(".")[0] + " has loaded!"));
		}

		private void Start()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			Logger.LogInfo((object)"Assigning all important stuff...");
			Projectile = Resources.Load<GameObject>("Dog").GetComponentInChildren<Attack_Dog>().projectile;
			Bundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("LazerWeaponry.Bundles.sfxbundle"));
			HeadshotSound = Bundle.LoadAsset<AudioClip>("headshot");
			KillSound = Bundle.LoadAsset<AudioClip>("killsound");
			_rescueHookItem = ((DatabaseAsset<ItemDatabase, Item>)(object)SingletonAsset<ItemDatabase>.Instance).Objects.Where((Item item) => item.displayName == "Rescue Hook").FirstOrDefault();
			Player.Start += new hook_Start(MMHook_Postfix_AddKillingRevenue);
			Logger.LogInfo((object)"Done!");
		}

		private static void HookAll()
		{
			Logger.LogInfo((object)"Hooking...");
			RescueHookHook.Init();
			DiveBellHook.Init();
			Logger.LogInfo((object)"Done!");
		}

		private IEnumerator MMHook_Postfix_AddKillingRevenue(orig_Start orig, Player self)
		{
			IEnumerator _orig = orig.Invoke(self);
			while (_orig.MoveNext())
			{
				yield return _orig.Current;
			}
			if (IsOnSurface && _totalRewardForAllKills > 0)
			{
				UserInterface.ShowMoneyNotification("Killing revenue", $"${_totalRewardForAllKills}", (MoneyCellType)1);
				SurfaceNetworkHandler.RoomStats.AddMoney(_totalRewardForAllKills);
				_totalRewardForAllKills = 0;
			}
		}

		private void RegisterSyncedSettings()
		{
			SyncedSettings.sync_PVPMode.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed PvP mode to {SyncedSettings.sync_PVPMode.CurrentValue}!");
			};
			SyncedSettings.sync_Damage.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed damage to {SyncedSettings.sync_Damage.CurrentValue}!");
			};
			SyncedSettings.sync_MaxAmmo.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed max ammo to {SyncedSettings.sync_PVPMode.CurrentValue}!");
			};
			SyncedSettings.sync_DelayAfterFire.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed delay after fire to {SyncedSettings.sync_DelayAfterFire.CurrentValue}!");
			};
			SyncedSettings.sync_HeadshotDamageMultiplier.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed headshot damage multiplier to {SyncedSettings.sync_HeadshotDamageMultiplier.CurrentValue}!");
			};
			SyncedSettings.sync_MonsterFallTime.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed monster fall time to {SyncedSettings.sync_MonsterFallTime.CurrentValue}!");
			};
			SyncedSettings.sync_MonsterHitForceMultiplier.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed monster force multiplier on hit to {SyncedSettings.sync_MonsterHitForceMultiplier.CurrentValue}!");
			};
			SyncedSettings.sync_RecoilForce.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed recoil force to {SyncedSettings.sync_RecoilForce.CurrentValue}!");
			};
			SyncedSettings.sync_PlayerKillReward.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed player kill reward to {SyncedSettings.sync_PlayerKillReward.CurrentValue}!");
			};
			SyncedSettings.sync_MonsterKillReward.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed monster kill reward to {SyncedSettings.sync_MonsterKillReward.CurrentValue}!");
			};
			SyncedSettings.sync_VulnerableEnemies.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed vulnerable enemies to {SyncedSettings.sync_VulnerableEnemies.CurrentValue}!");
			};
			SyncedSettings.sync_HeadshotFallTime.ConfigChanged += delegate
			{
				Logger.LogWarning((object)$"Host dude changed headshot fall time to {SyncedSettings.sync_HeadshotFallTime.CurrentValue}!");
			};
		}

		private CSteamID GetSteamIdFromString(string rawSteamId)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if (ulong.TryParse(rawSteamId, out var result))
			{
				return new CSteamID(result);
			}
			return default(CSteamID);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void HandleDamageToMortality(Collider mortalityCollider, float damage)
		{
			Mortality componentInParent = ((Component)mortalityCollider).GetComponentInParent<Mortality>();
			componentInParent.Damage(damage);
		}

		internal static void AddRescueHookToPlayer(Player player)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			PlayerInventory val = default(PlayerInventory);
			InventorySlot val2 = default(InventorySlot);
			InventorySlot val3 = default(InventorySlot);
			if (player.TryGetInventory(ref val) && !val.TryGetSlotWithItem(_rescueHookItem, ref val2) && val.TryAddItem(new ItemDescriptor(_rescueHookItem, new ItemInstanceData(Guid.NewGuid())), ref val3))
			{
				Logger.LogInfo((object)("Added rescue hook to " + ((MonoBehaviourPun)player).photonView.Owner.NickName));
				player.refs.view.RPC("RPC_SelectSlot", ((MonoBehaviourPun)player).photonView.Owner, new object[1] { val3.SlotID });
			}
		}

		internal static void AddRescueHookToAll()
		{
			foreach (Player item in PlayerHandler.instance.playersAlive)
			{
				AddRescueHookToPlayer(item);
			}
		}

		[CustomRPC]
		internal void RPC_ToggleBell(int bellIndex, bool toggle)
		{
			((Component)((Component)DiveBellParent.instance).transform.GetChild(bellIndex)).gameObject.SetActive(toggle);
		}

		[CustomRPC]
		internal void RPC_SpawnBellOwnerText(int bellIndex)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			Transform child = ((Component)DiveBellParent.instance).transform.GetChild(bellIndex);
			GameObject gameObject = ((Component)child.Find("Tools/Screen/ScreenPivot/Canvas/ACTIVE")).gameObject;
			GameObject val = Object.Instantiate<GameObject>(gameObject, gameObject.transform.position, new Quaternion(0f, 0f, 0f, 0f), gameObject.transform.parent);
			Transform transform = val.transform;
			Vector3 localPosition = val.transform.localPosition;
			localPosition.x = 0f;
			transform.localPosition = localPosition;
			Object.Destroy((Object)(object)val.GetComponent<GameObjectLocalizer>());
			TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = ((MonoBehaviourPun)Player.localPlayer).photonView.Owner.NickName + "'s bell";
			((Graphic)component).color = Player.localPlayer.refs.visor.visorColor.value;
		}

		[CustomRPC]
		internal void RPC_SetLocalHelmetText(string stringToAdd, bool append, bool addCombo)
		{
			if (addCombo)
			{
				RescueHookHook.HeadshotCombo++;
			}
			if (append)
			{
				RescueHookHook.HelmetTextString += stringToAdd.Replace("<insertCombo>", RescueHookHook.HeadshotCombo.ToString());
			}
			else
			{
				RescueHookHook.HelmetTextString = stringToAdd.Replace("<insertCombo>", RescueHookHook.HeadshotCombo.ToString());
			}
		}

		[CustomRPC]
		internal void RPC_PlayLocalSound(int soundNumber, float volume)
		{
			AudioClip val = default(AudioClip);
			switch (soundNumber)
			{
			case 0:
				val = HeadshotSound;
				break;
			case 1:
				val = KillSound;
				break;
			default:
				global::<PrivateImplementationDetails>.ThrowSwitchExpressionException((SoundType)soundNumber);
				break;
			}
			AudioClip clip = val;
			RescueHookHook.PlaySoundEffect(clip, volume);
		}

		[CustomRPC]
		internal void RPC_ApplyLocalHelmetText()
		{
			((TMP_Text)HelmetText.Instance.m_TextObject).text = RescueHookHook.HelmetTextString;
			((Graphic)HelmetText.Instance.m_TextObject).SetAllDirty();
			((MonoBehaviour)this).StartCoroutine(RescueHookHook.WaitAndWipeHelmetTextAndCombo(5f));
		}

		[CustomRPC]
		internal void RPC_AppendLocalKillReward(string killedObjectName, int reward)
		{
			if (!IsOnSurface)
			{
				UserInterface.ShowMoneyNotification("Reward for killing " + killedObjectName, $"${reward}", (MoneyCellType)1);
				_totalRewardForAllKills += reward;
			}
		}

		[CustomRPC]
		internal void RPC_SpawnBullet(Vector3 position, Quaternion rotation, RPCInfo shooterInfo)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(Projectile, position, rotation);
			Projectile component = val.GetComponent<Projectile>();
			Player val2 = PlayerHandler.instance.players.First((Player player) => (CSteamID)ulong.Parse((string)player.refs.view.Owner.CustomProperties[(object)"SteamID"]) == shooterInfo.SenderSteamID);
			RescueHookHook.ChangeProjectileColor(val, val2.refs.visor.visorColor.value);
			component.damage = InitialSettings.Damage;
			component.hitAction = (Action<RaycastHit>)Delegate.Combine(component.hitAction, (Action<RaycastHit>)delegate(RaycastHit hit)
			{
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Invalid comparison between Unknown and I4
				//IL_0185: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_0434: Unknown result type (might be due to invalid IL or missing references)
				//IL_0210: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0349: Unknown result type (might be due to invalid IL or missing references)
				//IL_0385: 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)
				Player componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<Player>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					string text = ((Object)((Component)((RaycastHit)(ref hit)).collider).transform.root).name.Replace("(Clone)", string.Empty).Replace("Toolkit_", string.Empty).Replace("2", string.Empty);
					string nickName = ((MonoBehaviourPun)componentInParent).photonView.Owner.NickName;
					bool flag = (int)componentInParent.refs.ragdoll.GetBodypartFromCollider(((RaycastHit)(ref hit)).collider).bodypartType == 4;
					int num = (int)((float)InitialSettings.Damage * InitialSettings.HeadshotDamageMultiplier) - InitialSettings.Damage;
					if (flag && !componentInParent.data.dead)
					{
						MyceliumNetwork.RPCTargetMasked(391309u, "RPC_SetLocalHelmetText", shooterInfo.SenderSteamID, (ReliableType)1, LocalPhotonViewID, new object[3] { "headshot! (x<insertCombo>)\n", false, true });
						MyceliumNetwork.RPCTargetMasked(391309u, "RPC_PlayLocalSound", shooterInfo.SenderSteamID, (ReliableType)1, LocalPhotonViewID, new object[2]
						{
							0,
							InitialSettings.HeadshotSoundVolume
						});
						if (!componentInParent.ai)
						{
							componentInParent.CallTakeDamageAndTase(MortalityLoaded ? 0f : ((float)num), InitialSettings.HeadshotFallTime);
						}
						if (MortalityLoaded)
						{
							HandleDamageToMortality(((RaycastHit)(ref hit)).collider, num);
						}
					}
					if (componentInParent.ai)
					{
						componentInParent.CallTakeDamageAndAddForceAndFall(0f, ((RaycastHit)(ref hit)).point * InitialSettings.MonsterHitForceMultiplier, InitialSettings.MonsterFallTime * (float)((!flag) ? 1 : 2));
						if (InitialSettings.VulnerableEnemies && MortalityLoaded)
						{
							HandleDamageToMortality(((RaycastHit)(ref hit)).collider, InitialSettings.Damage);
						}
					}
					if (componentInParent.data.sinceDied == 1000f && componentInParent.data.dead)
					{
						Bot val3 = null;
						if (!componentInParent.ai)
						{
							string text2 = ColorUtility.ToHtmlStringRGB(componentInParent.refs.visor.visorColor.value);
							MyceliumNetwork.RPCTargetMasked(391309u, "RPC_SetLocalHelmetText", shooterInfo.SenderSteamID, (ReliableType)1, LocalPhotonViewID, new object[3]
							{
								"<color=red>killed</color> <color=#" + text2 + ">" + nickName + "!</color>",
								true,
								false
							});
						}
						else
						{
							val3 = ((Component)componentInParent).GetComponentInChildren<Bot>();
							string text3 = string.Empty;
							switch (val3.jumpScareLevel)
							{
							case 1:
								text3 = "white";
								break;
							case 0:
							case 2:
								text3 = "yellow";
								break;
							case 3:
								text3 = "red";
								break;
							}
							MyceliumNetwork.RPCTargetMasked(391309u, "RPC_SetLocalHelmetText", shooterInfo.SenderSteamID, (ReliableType)1, LocalPhotonViewID, new object[3]
							{
								"<color=red>killed</color> <color=" + text3 + ">" + text + "!</color>",
								true,
								false
							});
						}
						MyceliumNetwork.RPCTargetMasked(391309u, "RPC_PlayLocalSound", shooterInfo.SenderSteamID, (ReliableType)1, LocalPhotonViewID, new object[2]
						{
							1,
							InitialSettings.KillSoundVolume
						});
						MyceliumNetwork.RPCTargetMasked(391309u, "RPC_AppendLocalKillReward", shooterInfo.SenderSteamID, (ReliableType)1, LocalPhotonViewID, new object[2]
						{
							componentInParent.ai ? text : nickName,
							(!componentInParent.ai) ? new int?(InitialSettings.PlayerKillReward) : (InitialSettings.MonsterKillReward * ((val3 != null && val3.jumpScareLevel == 0) ? new int?(2) : val3?.jumpScareLevel))
						});
					}
					MyceliumNetwork.RPCTargetMasked(391309u, "RPC_ApplyLocalHelmetText", shooterInfo.SenderSteamID, (ReliableType)1, LocalPhotonViewID, Array.Empty<object>());
				}
			});
		}

		[ConsoleCommand]
		public static void GiveEveryoneRescueHook()
		{
			if (MyceliumNetwork.IsHost && !MainMenuHandler.SteamLobbyHandler.IsPlayingWithRandoms())
			{
				AddRescueHookToAll();
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "cyclozarin.contentwarning.LazerWeaponry";

		public const string PLUGIN_NAME = "LazerWeaponry";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace LazerWeaponry.Settings
{
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Rescue hook's lazer mode settings")]
	internal class Damage : IntSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_Damage.SetValue((object)((IntSetting)this).Value);
		}

		public string GetDisplayName()
		{
			return "Bullet damage";
		}

		protected override int GetDefaultValue()
		{
			return 10;
		}

		protected override (int, int) GetMinMaxValue()
		{
			return (5, 25);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Rescue hook's lazer mode settings")]
	internal class DelayAfterFire : FloatSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_DelayAfterFire.SetValue((object)(float)Math.Round(((FloatSetting)this).Value, 2));
		}

		public string GetDisplayName()
		{
			return "Delay after firing bullet";
		}

		public override float GetDefaultValue()
		{
			return 0.15f;
		}

		public override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(0.01f, 0.5f);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Rescue hook's lazer mode settings")]
	internal class HeadshotDamageMultiplier : FloatSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_HeadshotDamageMultiplier.SetValue((object)(float)Math.Round(((FloatSetting)this).Value, 2));
		}

		public string GetDisplayName()
		{
			return "Damage multiplier on headshot";
		}

		public override float GetDefaultValue()
		{
			return 2f;
		}

		public override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(1f, 4f);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Rescue hook's lazer mode settings")]
	internal class HeadshotFallTime : FloatSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_HeadshotFallTime.SetValue((object)(float)Math.Round(((FloatSetting)this).Value, 2));
		}

		public string GetDisplayName()
		{
			return "Player fall time upon headshot";
		}

		public override float GetDefaultValue()
		{
			return 1.5f;
		}

		public override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(0f, 3f);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Sound settings")]
	internal class HeadshotSoundVolume : IntSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.InitialSettings.HeadshotSoundVolume = (float)((IntSetting)this).Value / 100f;
		}

		public string GetDisplayName()
		{
			return "Headshot sound volume";
		}

		protected override int GetDefaultValue()
		{
			return 75;
		}

		protected override (int, int) GetMinMaxValue()
		{
			return (0, 100);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Sound settings")]
	internal class KillSoundVolume : IntSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.InitialSettings.KillSoundVolume = (float)((IntSetting)this).Value / 100f;
		}

		public string GetDisplayName()
		{
			return "Kill sound volume";
		}

		protected override int GetDefaultValue()
		{
			return 100;
		}

		protected override (int, int) GetMinMaxValue()
		{
			return (0, 100);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Rescue hook's lazer mode settings")]
	internal class MaxAmmo : IntSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_MaxAmmo.SetValue((object)((IntSetting)this).Value);
		}

		public string GetDisplayName()
		{
			return "Ammo";
		}

		protected override int GetDefaultValue()
		{
			return 10;
		}

		protected override (int, int) GetMinMaxValue()
		{
			return (2, 20);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Monster behaviour on hit")]
	internal class MonsterFallTime : FloatSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_MonsterFallTime.SetValue((object)(float)Math.Round(((FloatSetting)this).Value, 2));
		}

		public string GetDisplayName()
		{
			return "Monster fall time on hit";
		}

		public override float GetDefaultValue()
		{
			return 2f;
		}

		public override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(0f, 5f);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Monster behaviour on hit")]
	internal class MonsterHitForceMultiplier : FloatSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_MonsterHitForceMultiplier.SetValue((object)(float)Math.Round(((FloatSetting)this).Value, 2));
		}

		public string GetDisplayName()
		{
			return "Monster force multiplier on hit";
		}

		public override float GetDefaultValue()
		{
			return 0.25f;
		}

		public override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(0f, 1f);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Rescue hook's lazer mode settings")]
	internal class MonsterKillReward : IntSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_MonsterKillReward.SetValue((object)((IntSetting)this).Value);
		}

		public string GetDisplayName()
		{
			return "Money reward for killing monster";
		}

		protected override int GetDefaultValue()
		{
			return 15;
		}

		protected override (int, int) GetMinMaxValue()
		{
			return (5, 35);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Rescue hook's lazer mode settings")]
	internal class PlayerKillReward : IntSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_PlayerKillReward.SetValue((object)((IntSetting)this).Value);
		}

		public string GetDisplayName()
		{
			return "Money reward for killing player";
		}

		protected override int GetDefaultValue()
		{
			return 35;
		}

		protected override (int, int) GetMinMaxValue()
		{
			return (20, 75);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "PvP settings")]
	internal class PVPMode : BoolSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_PVPMode.SetValue((object)((BoolSetting)this).Value);
		}

		public string GetDisplayName()
		{
			return "PvP mode";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "Rescue hook's lazer mode settings")]
	internal class RecoilForce : IntSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_RecoilForce.SetValue((object)((IntSetting)this).Value);
		}

		public string GetDisplayName()
		{
			return "Recoil force";
		}

		protected override int GetDefaultValue()
		{
			return 25;
		}

		protected override (int, int) GetMinMaxValue()
		{
			return (10, 50);
		}
	}
	[SettingRegister("<size=75%>LAZERWEAPONRY SETTINGS</size>", "PvP settings")]
	internal class VulnerableEnemies : BoolSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			LazerWeaponryPlugin.SyncedSettings.sync_VulnerableEnemies.SetValue((object)((BoolSetting)this).Value);
		}

		public string GetDisplayName()
		{
			return "Vulnerable enemies";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}
	}
}
namespace LazerWeaponry.Hooks
{
	internal class DiveBellHook
	{
		private class NotReadyBecauseSomeoneIsAliveState : DivingBellState
		{
			public override void SetStatusText(TextMeshProUGUI statusText)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				((TMP_Text)statusText).text = FillPlayerCountPlaceholder(_currentMessageForDiveBellNotBeingReadyBecauseSomeoneIsAlive);
				((Graphic)statusText).color = DivingBellState.RED;
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_GetSpawn <0>__MMHook_Prefix_IndividualRandomDiveBell;

			public static hook_Start <1>__MMHook_Postfix_DiveBellStuff;

			public static hook_Update <2>__MMHook_Prefix_ForceSwitchState;

			public static hook_Interact <3>__MMHook_Prefix_RestictLeavingWhenSomeoneIsAlive;

			public static hook_SetStatusText <4>__MMHook_Postfix_SetWinText;

			public static hook_TransitionGameFeel <5>__MMHook_Postfix_GenerateDiveBellIndexes;
		}

		private static bool _triedToSumbergeWhenSomeoneIsAlive = false;

		private static string _currentMessageForDiveBellNotBeingReadyBecauseSomeoneIsAlive = "";

		private static string _currentWinMessageForDiveBell = "you win!";

		private static int _currentDiveBellIndex;

		private static string[] _oldWorldEnterMessages = new string[3] { "You're alone now, with fear of sudden death and any counter of your friend.", "Friends that you happily met before now would battle not for live, but for death.", "Jokes are over, you arrived to the battlefield." };

		private static string[] _notReadyBecauseSomeoneIsAliveMessages = new string[6] { "cannot submerge when someone is alive, dumbass!", "you thought you can leave when <playerCount> player(-s) is alive, huh?", "you need to finish remaining people first. or just survive until you will be alone.", "<playerCount> people is certainly alive. submerge cancelled.", "error 0x0000000C: cannot submerge because diving bell is severely damaged", "your diveos license is expired! come back later when you will be able to afford it by killing." };

		private static string FillPlayerCountPlaceholder(string stringToFill)
		{
			return stringToFill.Replace("<playerCount>", (PlayerHandler.instance.playersAlive.Count - 1).ToString());
		}

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: 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_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			object obj = <>O.<0>__MMHook_Prefix_IndividualRandomDiveBell;
			if (obj == null)
			{
				hook_GetSpawn val = MMHook_Prefix_IndividualRandomDiveBell;
				<>O.<0>__MMHook_Prefix_IndividualRandomDiveBell = val;
				obj = (object)val;
			}
			DiveBellParent.GetSpawn += (hook_GetSpawn)obj;
			object obj2 = <>O.<1>__MMHook_Postfix_DiveBellStuff;
			if (obj2 == null)
			{
				hook_Start val2 = MMHook_Postfix_DiveBellStuff;
				<>O.<1>__MMHook_Postfix_DiveBellStuff = val2;
				obj2 = (object)val2;
			}
			DivingBell.Start += (hook_Start)obj2;
			object obj3 = <>O.<2>__MMHook_Prefix_ForceSwitchState;
			if (obj3 == null)
			{
				hook_Update val3 = MMHook_Prefix_ForceSwitchState;
				<>O.<2>__MMHook_Prefix_ForceSwitchState = val3;
				obj3 = (object)val3;
			}
			DivingBell.Update += (hook_Update)obj3;
			object obj4 = <>O.<3>__MMHook_Prefix_RestictLeavingWhenSomeoneIsAlive;
			if (obj4 == null)
			{
				hook_Interact val4 = MMHook_Prefix_RestictLeavingWhenSomeoneIsAlive;
				<>O.<3>__MMHook_Prefix_RestictLeavingWhenSomeoneIsAlive = val4;
				obj4 = (object)val4;
			}
			UseDivingBellButton.Interact += (hook_Interact)obj4;
			object obj5 = <>O.<4>__MMHook_Postfix_SetWinText;
			if (obj5 == null)
			{
				hook_SetStatusText val5 = MMHook_Postfix_SetWinText;
				<>O.<4>__MMHook_Postfix_SetWinText = val5;
				obj5 = (object)val5;
			}
			DivingBellReadyState.SetStatusText += (hook_SetStatusText)obj5;
			object obj6 = <>O.<5>__MMHook_Postfix_GenerateDiveBellIndexes;
			if (obj6 == null)
			{
				hook_TransitionGameFeel val6 = MMHook_Postfix_GenerateDiveBellIndexes;
				<>O.<5>__MMHook_Postfix_GenerateDiveBellIndexes = val6;
				obj6 = (object)val6;
			}
			DivingBell.TransitionGameFeel += (hook_TransitionGameFeel)obj6;
		}

		private static void MMHook_Postfix_SetWinText(orig_SetStatusText orig, DivingBellReadyState self, TextMeshProUGUI statusText)
		{
			orig.Invoke(self, statusText);
			if (!self.OnSurface && LazerWeaponryPlugin.InitialSettings.PVPMode && PlayerHandler.instance.playersAlive.Count == 1)
			{
				((TMP_Text)statusText).text = _currentWinMessageForDiveBell;
			}
		}

		private static void MMHook_Prefix_ForceSwitchState(orig_Update orig, DivingBell self)
		{
			DivingBell self2 = self;
			PlayerHandler.instance.players.ForEach(delegate(Player p)
			{
				p.data.isInDiveBell = self2.playerDetector.CheckForPlayers().Contains(p);
			});
			if (LazerWeaponryPlugin.InitialSettings.PVPMode && !self2.onSurface)
			{
				if (PlayerHandler.instance.playersAlive.Count == 1)
				{
					((StateMachine<DivingBellState>)(object)self2.StateMachine).SwitchState<DivingBellReadyState>();
					return;
				}
				if (_triedToSumbergeWhenSomeoneIsAlive)
				{
					((StateMachine<DivingBellState>)(object)self2.StateMachine).SwitchState<NotReadyBecauseSomeoneIsAliveState>();
					return;
				}
			}
			orig.Invoke(self2);
		}

		private static void MMHook_Prefix_RestictLeavingWhenSomeoneIsAlive(orig_Interact orig, UseDivingBellButton self, Player player)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerHandler.instance.playersAlive.Count != 1 && LazerWeaponryPlugin.InitialSettings.PVPMode && !self.divingBell.onSurface)
			{
				((Interactable)self).hoverText = "unable to submerge";
				self.divingBell.sfx.notAll.Play(((Component)self.divingBell).transform.position, false, 1f, (Transform)null);
				_triedToSumbergeWhenSomeoneIsAlive = true;
			}
			else
			{
				orig.Invoke(self, player);
			}
		}

		private static IEnumerator WaitForOthersAndDoStuff(DivingBell bell)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => PlayerHandler.instance.playersAlive.Contains(Player.localPlayer)));
			if (MyceliumNetwork.IsHost)
			{
				MyceliumNetwork.SetLobbyData("diveBellArrivingMessage", (object)_oldWorldEnterMessages[Random.Range(0, _oldWorldEnterMessages.Length)]);
			}
			yield return (object)new WaitUntil((Func<bool>)(() => PlayerHandler.instance.playersAlive.Count == MyceliumNetwork.PlayerCount));
			bell.AttemptSetOpen(true);
			if (MyceliumNetwork.IsHost)
			{
				LazerWeaponryPlugin.AddRescueHookToAll();
			}
			MyceliumNetwork.RPC(391309u, "RPC_SpawnBellOwnerText", (ReliableType)1, new object[1] { _currentDiveBellIndex });
			HelmetText.Instance.SetHelmetText(MyceliumNetwork.GetLobbyData<string>("diveBellArrivingMessage"), 3f);
			yield return (object)new WaitForSecondsRealtime(10f);
			HelmetText.Instance.SetHelmetText("\n<color=red>Good luck.</color>", 3f);
		}

		private static void MMHook_Postfix_DiveBellStuff(orig_Start orig, DivingBell self)
		{
			orig.Invoke(self);
			if (MyceliumNetwork.InLobby)
			{
				((StateMachine<DivingBellState>)(object)self.StateMachine).RegisterState((DivingBellState)(object)new NotReadyBecauseSomeoneIsAliveState());
				if (self.onSurface)
				{
					self.AttemptSetOpen(true);
				}
			}
		}

		private static void MMHook_Postfix_GenerateDiveBellIndexes(orig_TransitionGameFeel orig, DivingBell self)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (MyceliumNetwork.IsHost)
			{
				State state = Random.state;
				int hashCode = Guid.NewGuid().GetHashCode();
				Random.InitState(hashCode);
				LazerWeaponryPlugin.Logger.LogDebug((object)$"generated seed {hashCode} for generating dive bell spawn locations");
				byte[] array = new byte[MyceliumNetwork.PlayerCount];
				string text = new List<string> { "FactoryScene", "MinesScene", "HarbourScene" }[SurfaceNetworkHandler.RoomStats.LevelToPlay];
				LazerWeaponryPlugin.Logger.LogDebug((object)$"generating dive bell locations for {text} on day {SurfaceNetworkHandler.RoomStats.CurrentDay}");
				for (int i = 0; i < MyceliumNetwork.PlayerCount; i++)
				{
					int num = Random.Range(0, LazerWeaponryPlugin.MapNameToDiveBellCount[text] - 1);
					array[i] = (byte)num;
					LazerWeaponryPlugin.Logger.LogDebug((object)$"will spawn {SteamFriends.GetFriendPersonaName(MyceliumNetwork.Players[i])} at bell #{num}");
				}
				MyceliumNetwork.SetLobbyData("diveBellIndexes", (object)Convert.ToBase64String(array));
				LazerWeaponryPlugin.Logger.LogDebug((object)"done generating dive bell spawn locations, rolling back to previous random state");
				Random.state = state;
			}
		}

		private static SpawnPoint MMHook_Prefix_IndividualRandomDiveBell(orig_GetSpawn orig, DiveBellParent self)
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (LazerWeaponryPlugin.InitialSettings.PVPMode)
			{
				byte[] array = Convert.FromBase64String(MyceliumNetwork.GetLobbyData<string>("diveBellIndexes"));
				LazerWeaponryPlugin.Logger.LogDebug((object)("received dive bell indexes: " + string.Join(" ", array)));
				for (int i = 0; i < ((Component)self).transform.childCount; i++)
				{
					((Component)((Component)self).transform.GetChild(i)).gameObject.SetActive(false);
				}
				for (int j = 0; j < array.Length; j++)
				{
					((Component)((Component)self).transform.GetChild((int)array[j])).gameObject.SetActive(true);
				}
				int num = Array.IndexOf(MyceliumNetwork.Players, MyceliumNetwork.Players.First((CSteamID player) => SteamFriends.GetFriendPersonaName(player) == SteamFriends.GetPersonaName()));
				_currentMessageForDiveBellNotBeingReadyBecauseSomeoneIsAlive = _notReadyBecauseSomeoneIsAliveMessages[Random.Range(0, _notReadyBecauseSomeoneIsAliveMessages.Length)];
				_currentDiveBellIndex = array[num];
				DivingBell component = ((Component)((Component)self).transform.GetChild(_currentDiveBellIndex)).gameObject.GetComponent<DivingBell>();
				((MonoBehaviour)self).StartCoroutine(WaitForOthersAndDoStuff(component));
				LazerWeaponryPlugin.Logger.LogDebug((object)$"player index: {num} bell index: {_currentDiveBellIndex}");
				return ((Component)((Component)self).transform.GetChild(_currentDiveBellIndex)).GetComponentInChildren<SpawnPoint>();
			}
			return orig.Invoke(self);
		}
	}
	public class RescueHookHook
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__MMHook_Postfix_SetRescueHookDataOnStart;

			public static hook_Update <1>__MMHook_Postfix_ToggleRescueHookModeAndCheckForIt;

			public static hook_Fire <2>__MMHook_Prefix_LazersInRescueHook;

			public static hook_Start <3>__MMHook_Postfix_CreateCustomSourcesAndReregisterInMycelium;
		}

		private static bool _lazerMode = false;

		private static bool _ableToFire = true;

		private static bool _firedWhileAgo = false;

		private static bool _recharging = false;

		private static float _rechargeTime = 3f;

		private static AudioSource _chargeSource = null;

		private static AudioSource _customSource = null;

		private static string _sourceName = "LazerWeaponry source";

		private static Coroutine? _hookRechargeCoroutine = null;

		internal static int HeadshotCombo = 0;

		internal static string HelmetTextString = "";

		private static IEnumerator StartDelayAfterFire()
		{
			_ableToFire = false;
			yield return (object)new WaitForSecondsRealtime(LazerWeaponryPlugin.InitialSettings.DelayAfterFire);
			_ableToFire = true;
		}

		private static IEnumerator DelayAndHookRecharge(RescueHook hook)
		{
			yield return (object)new WaitForSecondsRealtime(_rechargeTime);
			_recharging = true;
			while (hook.m_batteryEntry.m_charge != hook.m_batteryEntry.m_maxCharge)
			{
				hook.m_batteryEntry.AddCharge(1f);
				((Behaviour)_chargeSource).enabled = true;
				_chargeSource.PlayOneShot(_chargeSource.clip);
				_chargeSource.volume = Mathf.Lerp(_chargeSource.volume, 0.1f, Time.deltaTime * 10f);
				_chargeSource.pitch = Mathf.Lerp(_chargeSource.pitch, 0.25f + hook.m_batteryEntry.m_charge * 4f, Time.deltaTime * 10f);
				yield return (object)new WaitForSecondsRealtime(0.01f);
			}
			_recharging = false;
			_chargeSource.pitch = 1f;
			_chargeSource.volume = 0.01f;
			((Behaviour)_chargeSource).enabled = false;
			_hookRechargeCoroutine = null;
		}

		internal static IEnumerator WaitAndWipeHelmetTextAndCombo(float time)
		{
			yield return (object)new WaitForSecondsRealtime(time);
			HelmetTextString = "";
			((TMP_Text)HelmetText.Instance.m_TextObject).text = "";
			HeadshotCombo = 0;
		}

		internal static void ChangeProjectileColor(GameObject projectile, Color color)
		{
			//IL_0029: 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_0041: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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)
			MeshRenderer componentInChildren = projectile.GetComponentInChildren<MeshRenderer>();
			ParticleSystemRenderer component = projectile.GetComponent<Projectile_SpawnObject>().objectToSpawn.GetComponent<ParticleSystemRenderer>();
			Material material = ((Renderer)componentInChildren).material;
			Material val = ((Renderer)component).materials[1];
			material.color = color;
			material.SetColor("_BaseMap", color);
			material.SetColor("_Emission", color * 30f);
			val.color = color;
			val.SetColor("_BaseMap", color);
			val.SetColor("_Emission", color * 30f);
			((Renderer)componentInChildren).material = material;
			((Renderer)component).material = val;
		}

		private static void ChangeRescueHookBeamColor(RescueHook hook)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			Material material = ((Renderer)hook.lightObject.GetComponentInChildren<MeshRenderer>()).material;
			? color;
			if (!_lazerMode)
			{
				color = new Color(1f, 0.57f, 0f, 0.027f);
			}
			else
			{
				Color red = Color.red;
				red.a = 0.2f;
				color = red;
			}
			material.color = (Color)color;
		}

		internal static void PlaySoundEffect(AudioClip clip, float volume)
		{
			_customSource.PlayOneShot(clip, volume);
		}

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: 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_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			object obj = <>O.<0>__MMHook_Postfix_SetRescueHookDataOnStart;
			if (obj == null)
			{
				hook_Start val = MMHook_Postfix_SetRescueHookDataOnStart;
				<>O.<0>__MMHook_Postfix_SetRescueHookDataOnStart = val;
				obj = (object)val;
			}
			RescueHook.Start += (hook_Start)obj;
			object obj2 = <>O.<1>__MMHook_Postfix_ToggleRescueHookModeAndCheckForIt;
			if (obj2 == null)
			{
				hook_Update val2 = MMHook_Postfix_ToggleRescueHookModeAndCheckForIt;
				<>O.<1>__MMHook_Postfix_ToggleRescueHookModeAndCheckForIt = val2;
				obj2 = (object)val2;
			}
			RescueHook.Update += (hook_Update)obj2;
			object obj3 = <>O.<2>__MMHook_Prefix_LazersInRescueHook;
			if (obj3 == null)
			{
				hook_Fire val3 = MMHook_Prefix_LazersInRescueHook;
				<>O.<2>__MMHook_Prefix_LazersInRescueHook = val3;
				obj3 = (object)val3;
			}
			RescueHook.Fire += (hook_Fire)obj3;
			object obj4 = <>O.<3>__MMHook_Postfix_CreateCustomSourcesAndReregisterInMycelium;
			if (obj4 == null)
			{
				hook_Start val4 = MMHook_Postfix_CreateCustomSourcesAndReregisterInMycelium;
				<>O.<3>__MMHook_Postfix_CreateCustomSourcesAndReregisterInMycelium = val4;
				obj4 = (object)val4;
			}
			Player.Start += (hook_Start)obj4;
		}

		private static IEnumerator MMHook_Postfix_CreateCustomSourcesAndReregisterInMycelium(orig_Start orig, Player self)
		{
			IEnumerator _orig = orig.Invoke(self);
			while (_orig.MoveNext())
			{
				yield return _orig.Current;
			}
			if (!self.ai)
			{
				_chargeSource = ((Component)self).GetComponent<PlayerDataSounds>().throwCharge;
				GameObject val = GameObject.Find(_sourceName);
				if ((Object)(object)GameObject.Find(_sourceName) == (Object)null)
				{
					GameObject val2 = Object.Instantiate<GameObject>(new GameObject(_sourceName), self.HeadPosition(), self.refs.headPos.rotation);
					((Object)val2).hideFlags = (HideFlags)61;
					_customSource = val2.AddComponent<AudioSource>();
					Object.DontDestroyOnLoad((Object)(object)val2);
				}
				else
				{
					_customSource = val.GetComponent<AudioSource>();
				}
				MyceliumNetwork.RegisterNetworkObject((object)LazerWeaponryPlugin.Instance, 391309u, LazerWeaponryPlugin.LocalPhotonViewID);
			}
		}

		private static void MMHook_Postfix_SetRescueHookDataOnStart(orig_Start orig, RescueHook self)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			orig.Invoke(self);
			List<ItemKeyTooltip> tooltips = ((ItemInstanceBehaviour)self).itemInstance.item.Tooltips;
			if (!tooltips.Any((ItemKeyTooltip x) => x.m_key == "[R] Toggle lazer mode"))
			{
				tooltips.Add(new ItemKeyTooltip("[R] Toggle lazer mode"));
			}
			ChangeRescueHookBeamColor(self);
			if (_recharging || self.m_batteryEntry.m_charge == 0f)
			{
				LazerWeaponryPlugin.Logger.LogDebug((object)"rescue hook was switched to different slot, we'll charge it");
				((MonoBehaviour)self).StartCoroutine(DelayAndHookRecharge(self));
			}
		}

		private static void MMHook_Postfix_ToggleRescueHookModeAndCheckForIt(orig_Update orig, RescueHook self)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			try
			{
				PlayerInventory val = default(PlayerInventory);
				Player.localPlayer.TryGetInventory(ref val);
				ItemDescriptor val2 = default(ItemDescriptor);
				val.TryGetItemInSlot(Player.localPlayer.data.selectedItemSlot, ref val2);
				((Behaviour)_chargeSource).enabled = (Object)(object)val2.item == (Object)(object)((ItemInstanceBehaviour)self).itemInstance.item && !_firedWhileAgo;
				if (_lazerMode)
				{
					self.isPulling = false;
				}
				if (((ItemInstanceBehaviour)self).isHeldByMe && self.playerHoldingItem.input.toggleCameraFlipWasPressed && !self.playerHoldingItem.HasLockedInput() && GlobalInputHandler.CanTakeInput())
				{
					_lazerMode = !_lazerMode;
					ChangeRescueHookBeamColor(self);
				}
			}
			catch
			{
			}
		}

		private static void MMHook_Prefix_LazersInRescueHook(orig_Fire orig, RescueHook self)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			if (LazerWeaponryPlugin.InitialSettings.PVPMode)
			{
				_firedWhileAgo = true;
				if (_hookRechargeCoroutine != null)
				{
					((MonoBehaviour)self).StopCoroutine(_hookRechargeCoroutine);
				}
				_hookRechargeCoroutine = ((MonoBehaviour)self).StartCoroutine(DelayAndHookRecharge(self));
			}
			if (_lazerMode)
			{
				if (_ableToFire)
				{
					self.m_batteryEntry.AddCharge((0f - self.m_batteryEntry.m_maxCharge) / (float)LazerWeaponryPlugin.InitialSettings.MaxAmmo);
					MyceliumNetwork.RPC(391309u, "RPC_SpawnBullet", (ReliableType)1, new object[2]
					{
						self.dragPoint.position + self.dragPoint.forward * 1.5f + Vector3.down * 0.15f + Vector3.left * 0.05f,
						Quaternion.LookRotation(self.dragPoint.forward)
					});
					self.playerHoldingItem.CallAddForceToBodyParts(new int[1] { self.playerHoldingItem.refs.ragdoll.GetBodyPartID((BodypartType)10) }, (Vector3[])(object)new Vector3[1] { -self.dragPoint.forward * (float)LazerWeaponryPlugin.InitialSettings.RecoilForce });
					((MonoBehaviour)self).StartCoroutine(StartDelayAfterFire());
				}
			}
			else
			{
				orig.Invoke(self);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}