Decompiled source of MagoPlush v1.0.0

com.github.zehsteam.MagoPlush.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLib.Modules;
using LethalModDataLib.Enums;
using LethalModDataLib.Features;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using com.github.zehsteam.MagoPlush.NetcodePatcher;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.zehsteam.MagoPlush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a customizable Magoroku plushie scrap item.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MagoPlush")]
[assembly: AssemblyTitle("com.github.zehsteam.MagoPlush")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace com.github.zehsteam.MagoPlush
{
	internal class ConfigManager
	{
		private ConfigEntry<int> SpawnWeightCfg;

		private ConfigEntry<bool> TwoHandedCfg;

		private ConfigEntry<int> CarryWeightCfg;

		private ConfigEntry<int> MinValueCfg;

		private ConfigEntry<int> MaxValueCfg;

		private ConfigEntry<bool> EnableRadioModeCfg;

		internal int SpawnWeight
		{
			get
			{
				return SpawnWeightCfg.Value;
			}
			set
			{
				SpawnWeightCfg.Value = value;
			}
		}

		internal bool TwoHanded
		{
			get
			{
				return TwoHandedCfg.Value;
			}
			set
			{
				TwoHandedCfg.Value = value;
			}
		}

		internal int CarryWeight
		{
			get
			{
				return CarryWeightCfg.Value;
			}
			set
			{
				CarryWeightCfg.Value = value;
			}
		}

		internal int MinValue
		{
			get
			{
				return MinValueCfg.Value;
			}
			set
			{
				MinValueCfg.Value = value;
			}
		}

		internal int MaxValue
		{
			get
			{
				return MaxValueCfg.Value;
			}
			set
			{
				MaxValueCfg.Value = value;
			}
		}

		internal bool EnableRadioMode
		{
			get
			{
				return EnableRadioModeCfg.Value;
			}
			set
			{
				EnableRadioModeCfg.Value = value;
			}
		}

		public ConfigManager()
		{
			BindConfigs();
			ClearUnusedEntries();
		}

		private void BindConfigs()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0034: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0060: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_008c: Expected O, but got Unknown
			//IL_009d: 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_00b9: Expected O, but got Unknown
			//IL_00b9: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_00e9: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_0115: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config;
			SpawnWeightCfg = config.Bind<int>(new ConfigDefinition("General Settings", "SpawnWeight"), 10, new ConfigDescription("Mago Plush spawn chance weight. higher = more common.", (AcceptableValueBase)null, Array.Empty<object>()));
			TwoHandedCfg = config.Bind<bool>(new ConfigDefinition("General Settings", "TwoHanded"), false, new ConfigDescription("If enabled, the Mago Plush will be two-handed.", (AcceptableValueBase)null, Array.Empty<object>()));
			CarryWeightCfg = config.Bind<int>(new ConfigDefinition("General Settings", "CarryWeight"), 5, new ConfigDescription("Mago Plush carry weight in pounds.", (AcceptableValueBase)null, Array.Empty<object>()));
			MinValueCfg = config.Bind<int>(new ConfigDefinition("General Settings", "MinValue"), 80, new ConfigDescription("Mago Plush min scrap value.", (AcceptableValueBase)null, Array.Empty<object>()));
			MaxValueCfg = config.Bind<int>(new ConfigDefinition("General Settings", "MaxValue"), 250, new ConfigDescription("Mago Plush max scrap value.", (AcceptableValueBase)null, Array.Empty<object>()));
			EnableRadioModeCfg = config.Bind<bool>(new ConfigDefinition("General Settings", "EnableRadioMode"), false, new ConfigDescription("If enabled, you can switch from random to radio mode for the squeeze voice lines. (Host only)", (AcceptableValueBase)null, Array.Empty<object>()));
		}

		private void ClearUnusedEntries()
		{
			ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config;
			PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null);
			dictionary.Clear();
			config.Save();
		}
	}
	internal class Content
	{
		public static Item magoPlush;

		public static void Load()
		{
			LoadAssetsFromAssetBundle();
		}

		private static void LoadAssetsFromAssetBundle()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, "magoplush_assets");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				magoPlush = val.LoadAsset<Item>("MagoPlush");
				Plugin.logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
			catch (Exception arg)
			{
				Plugin.logger.LogError((object)$"Error: failed to load assets from AssetBundle.\n\n{arg}");
			}
		}
	}
	[BepInPlugin("com.github.zehsteam.MagoPlush", "MagoPlush", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static Plugin Instance;

		internal static ManualLogSource logger;

		internal static ConfigManager ConfigManager;

		public static bool IsHostOrServer => NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("com.github.zehsteam.MagoPlush");
			logger.LogInfo((object)"MagoPlush has awoken!");
			ConfigManager = new ConfigManager();
			Content.Load();
			RegisterScrapItems();
			NetcodePatcherAwake();
		}

		private void NetcodePatcherAwake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		private void RegisterScrapItems()
		{
			int spawnWeight = ConfigManager.SpawnWeight;
			bool twoHanded = ConfigManager.TwoHanded;
			int carryWeight = ConfigManager.CarryWeight;
			int minValue = ConfigManager.MinValue;
			int maxValue = ConfigManager.MaxValue;
			ScrapHelper.RegisterScrap(Content.magoPlush, spawnWeight, twoHanded, carryWeight, minValue, maxValue);
		}
	}
	internal class ScrapHelper
	{
		public static void RegisterScrap(Item item, int iRarity, bool twoHanded, int carryWeight, int minValue, int maxValue)
		{
			item.twoHanded = twoHanded;
			item.weight = (float)carryWeight / 105f + 1f;
			item.minValue = minValue;
			item.maxValue = maxValue;
			Utilities.FixMixerGroups(item.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab);
			Items.RegisterScrap(item, iRarity, (LevelTypes)(-1));
			Plugin.logger.LogInfo((object)$"Registered \"{item.itemName}\" scrap item with {iRarity} rarity.");
		}
	}
	internal class Utils
	{
		public static bool RandomPercent(int percent)
		{
			if (percent <= 0)
			{
				return false;
			}
			if (percent >= 100)
			{
				return true;
			}
			return Random.value <= (float)percent * 0.01f;
		}

		public static int GetLocalPlayerId()
		{
			return (int)GetLocalPlayerScript().playerClientId;
		}

		public static bool IsLocalPlayerId(int clientId)
		{
			return clientId == GetLocalPlayerId();
		}

		public static PlayerControllerB GetLocalPlayerScript()
		{
			return GameNetworkManager.Instance.localPlayerController;
		}

		public static bool IsPlayerNearby(Vector3 position, float range)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if (Vector3.Distance(position, ((Component)val).gameObject.transform.position) <= range)
				{
					return true;
				}
			}
			return false;
		}

		public static void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, int damage = 20, float minDamageRange = 0f, float maxDamageRange = 6.4f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"Spawning explosion at pos: {explosionPosition}");
			Transform val = null;
			if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
			{
				val = RoundManager.Instance.mapPropsContainer.transform;
			}
			if (spawnExplosionEffect)
			{
				Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), val).SetActive(true);
			}
			float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition);
			if (num < 14f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else if (num < 25f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
			PlayerControllerB val2 = null;
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
				if (num2 > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
				{
					continue;
				}
				if (((Component)array[i]).gameObject.layer == 3)
				{
					val2 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
					if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).IsOwner)
					{
						float num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
						val2.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, default(Vector3));
					}
				}
				else if (((Component)array[i]).gameObject.layer == 21)
				{
					Landmine componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<Landmine>();
					if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.hasExploded && num2 < 6f)
					{
						Debug.Log((object)"Setting off other mine");
						((MonoBehaviour)StartOfRound.Instance).StartCoroutine(TriggerOtherMineDelayed(componentInChildren));
					}
				}
				else if (((Component)array[i]).gameObject.layer == 19)
				{
					EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
					{
						componentInChildren2.mainScript.HitEnemyOnLocalClient(enemyHitForce, default(Vector3), attacker, false, -1);
					}
				}
			}
			int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
			num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
			array = Physics.OverlapSphere(explosionPosition, 10f, num4);
			for (int j = 0; j < array.Length; j++)
			{
				Rigidbody component = ((Component)array[j]).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddExplosionForce(70f, explosionPosition, 10f);
				}
			}
		}

		private static IEnumerator TriggerOtherMineDelayed(Landmine mine)
		{
			if (!mine.hasExploded)
			{
				mine.mineAudio.pitch = Random.Range(0.75f, 1.07f);
				mine.hasExploded = true;
				yield return (object)new WaitForSeconds(0.2f);
				mine.SetOffMineAnimation();
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.MagoPlush";

		public const string PLUGIN_NAME = "MagoPlush";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace com.github.zehsteam.MagoPlush.MonoBehaviours
{
	public class AdvancedNoisemakerProp : NoisemakerProp
	{
		[Header("Advanced")]
		[Space(3f)]
		public bool useDynamicCooldown = false;

		public bool cancelActiveSFXOnItemActivate = false;

		protected Random noisemakerRandom;

		[HideInInspector]
		public int uniqueId = 0;

		public bool isHostOrServer => Plugin.IsHostOrServer;

		public bool isHeldByLocalPlayer => (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)Utils.GetLocalPlayerScript();

		public bool canActivateItem => isHeldByLocalPlayer || ((GrabbableObject)this).isHeldByEnemy;

		public string saveKey => string.Format("{0}_{1}", "AdvancedNoisemakerProp", uniqueId);

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			uniqueId = saveData;
		}

		public override int GetItemDataToSave()
		{
			return uniqueId;
		}

		public virtual void Awake()
		{
			if (isHostOrServer)
			{
				uniqueId = Random.Range(0, 1000000);
			}
		}

		public override void Start()
		{
			((NoisemakerProp)this).Start();
			noisemakerRandom = new Random(StartOfRound.Instance.randomMapSeed + 85);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (canActivateItem)
			{
				int index = Random.Range(0, base.noiseSFX.Length);
				PlaySound(index);
			}
		}

		public void PlaySound(int index)
		{
			int fromPlayerId = (isHeldByLocalPlayer ? Utils.GetLocalPlayerId() : (-1));
			if (isHostOrServer)
			{
				PlaySoundClientRpc(index, fromPlayerId);
			}
			else
			{
				PlaySoundServerRpc(index, fromPlayerId);
			}
			PlaySoundOnLocalClient(index);
		}

		[ServerRpc(RequireOwnership = false)]
		protected void PlaySoundServerRpc(int index, int fromPlayerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1377568213u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					BytePacker.WriteValueBitPacked(val2, fromPlayerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1377568213u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PlaySoundClientRpc(index, fromPlayerId);
				}
			}
		}

		[ClientRpc]
		protected void PlaySoundClientRpc(int index, int fromPlayerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1190313263u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					BytePacker.WriteValueBitPacked(val2, fromPlayerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1190313263u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !Utils.IsLocalPlayerId(fromPlayerId))
				{
					PlaySoundOnLocalClient(index);
				}
			}
		}

		protected void PlaySoundOnLocalClient(int index)
		{
			AudioClip audioClip = base.noiseSFX[index];
			AudioClip audioClipFar = base.noiseSFXFar[index];
			PlaySoundOnLocalClient(audioClip, audioClipFar);
		}

		protected void PlaySoundOnLocalClient(AudioClip audioClip, AudioClip audioClipFar)
		{
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)noisemakerRandom.Next((int)(base.minLoudness * 100f), (int)(base.maxLoudness * 100f)) / 100f;
			float pitch = (float)noisemakerRandom.Next((int)(base.minPitch * 100f), (int)(base.maxPitch * 100f)) / 100f;
			if (cancelActiveSFXOnItemActivate)
			{
				base.noiseAudio.Stop();
				base.noiseAudioFar.Stop();
			}
			if (useDynamicCooldown && !cancelActiveSFXOnItemActivate)
			{
				((GrabbableObject)this).currentUseCooldown = audioClip.length;
			}
			base.noiseAudio.pitch = pitch;
			base.noiseAudio.PlayOneShot(audioClip, num);
			if ((Object)(object)base.noiseAudioFar != (Object)null && (Object)(object)audioClipFar != (Object)null)
			{
				base.noiseAudioFar.pitch = pitch;
				base.noiseAudioFar.PlayOneShot(audioClipFar, num);
			}
			if ((Object)(object)base.triggerAnimator != (Object)null)
			{
				base.triggerAnimator.SetTrigger("playAnim");
			}
			WalkieTalkie.TransmitOneShotAudio(base.noiseAudio, audioClip, num);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, base.noiseRange, num, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			if (base.minLoudness >= 0.6f && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.timeSinceMakingLoudNoise = 0f;
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_AdvancedNoisemakerProp()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1377568213u, new RpcReceiveHandler(__rpc_handler_1377568213));
			NetworkManager.__rpc_func_table.Add(1190313263u, new RpcReceiveHandler(__rpc_handler_1190313263));
		}

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

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

		protected internal override string __getTypeName()
		{
			return "AdvancedNoisemakerProp";
		}
	}
	public class AdvancedRadioNoisemakerProp : AdvancedNoisemakerProp
	{
		[HideInInspector]
		public NetworkVariable<bool> isRadioModeEnabled = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<bool> isRadioMode = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[HideInInspector]
		public NetworkVariable<int> clipIndex = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public override void OnNetworkSpawn()
		{
			NetworkVariable<bool> obj = isRadioMode;
			obj.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnIsRadioModeChanged));
			NetworkVariable<int> obj2 = clipIndex;
			obj2.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnClipIndexChanged));
			isRadioModeEnabled.Value = Plugin.ConfigManager.EnableRadioMode;
		}

		public override void LoadItemSaveData(int saveData)
		{
			base.LoadItemSaveData(saveData);
			bool flag = SaveLoadHandler.LoadData<bool>(base.saveKey + "_isRadioMode", (SaveLocation)0, false, true);
			int value = SaveLoadHandler.LoadData<int>(base.saveKey + "_clipIndex", (SaveLocation)0, 0, true);
			isRadioMode.Value = isRadioModeEnabled.Value && flag;
			clipIndex.Value = value;
		}

		public override int GetItemDataToSave()
		{
			SaveItemData();
			return base.GetItemDataToSave();
		}

		private void SaveItemData()
		{
			SaveLoadHandler.SaveData<bool>(isRadioMode.Value, base.saveKey + "_isRadioMode", (SaveLocation)0, true);
			SaveLoadHandler.SaveData<int>(clipIndex.Value, base.saveKey + "_clipIndex", (SaveLocation)0, true);
		}

		public override void OnNetworkDespawn()
		{
			NetworkVariable<bool> obj = isRadioMode;
			obj.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnIsRadioModeChanged));
			NetworkVariable<int> obj2 = clipIndex;
			obj2.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnClipIndexChanged));
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
			}
		}

		public override void DiscardItem()
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
			}
			((GrabbableObject)this).DiscardItem();
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (base.canActivateItem)
			{
				int index = Random.Range(0, ((NoisemakerProp)this).noiseSFX.Length);
				if (isRadioMode.Value)
				{
					index = clipIndex.Value;
				}
				PlaySound(index);
			}
		}

		public override void ItemInteractLeftRight(bool right)
		{
			((GrabbableObject)this).ItemInteractLeftRight(right);
			if (base.isHeldByLocalPlayer)
			{
				if (right)
				{
					ItemInteractRight();
				}
				else
				{
					ItemInteractLeft();
				}
			}
		}

		private void ItemInteractLeft()
		{
			if (isRadioModeEnabled.Value)
			{
				SetIsRadioMode(!isRadioMode.Value);
				SaveItemData();
			}
		}

		private void ItemInteractRight()
		{
			if (isRadioMode.Value)
			{
				SetClipIndex(GetNextClipIndex());
				SaveItemData();
			}
		}

		private int GetNextClipIndex()
		{
			int num = clipIndex.Value + 1;
			if (num > ((NoisemakerProp)this).noiseSFX.Length - 1)
			{
				num = 0;
			}
			return num;
		}

		public override void SetControlTipsForItem()
		{
			SetControlTips();
		}

		private void SetControlTips()
		{
			if (base.isHeldByLocalPlayer)
			{
				if (isRadioMode.Value)
				{
					SetRadioControlTips();
				}
				else
				{
					SetDefaultControlTips();
				}
			}
		}

		private void SetDefaultControlTips()
		{
			string[] arrayWithMinLength = GetArrayWithMinLength(((GrabbableObject)this).itemProperties.toolTips, 3);
			arrayWithMinLength[0] = "Squeeze : [LMB]";
			arrayWithMinLength[1] = (isRadioModeEnabled.Value ? "Switch Mode : [Q]" : string.Empty);
			arrayWithMinLength[2] = string.Empty;
			HUDManager.Instance.ChangeControlTipMultiple(arrayWithMinLength, base.isHeldByLocalPlayer, ((GrabbableObject)this).itemProperties);
		}

		private void SetRadioControlTips()
		{
			string[] arrayWithMinLength = GetArrayWithMinLength(((GrabbableObject)this).itemProperties.toolTips, 3);
			arrayWithMinLength[0] = $"Squeeze #{clipIndex.Value} : [LMB]";
			arrayWithMinLength[1] = "Switch Mode : [Q]";
			arrayWithMinLength[2] = "Next Clip : [E]";
			HUDManager.Instance.ChangeControlTipMultiple(arrayWithMinLength, base.isHeldByLocalPlayer, ((GrabbableObject)this).itemProperties);
		}

		private void SetIsRadioMode(bool enabled)
		{
			if (base.isHostOrServer)
			{
				isRadioMode.Value = enabled;
			}
			else
			{
				SetIsRadioModeServerRpc(enabled);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SetIsRadioModeServerRpc(bool enabled)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1973078897u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref enabled, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1973078897u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					isRadioMode.Value = enabled;
				}
			}
		}

		private void OnIsRadioModeChanged(bool previous, bool current)
		{
			SetControlTips();
		}

		private void SetClipIndex(int index)
		{
			if (base.isHostOrServer)
			{
				clipIndex.Value = index;
			}
			else
			{
				SetClipIndexServerRpc(index);
			}
		}

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

		private void OnClipIndexChanged(int previous, int current)
		{
			SetControlTips();
		}

		private string[] GetArrayWithMinLength(string[] array, int minLength)
		{
			List<string> list = array.ToList();
			int num = minLength - list.Count;
			if (num < 0)
			{
				num = 0;
			}
			for (int i = 0; i < num; i++)
			{
				list.Add(string.Empty);
			}
			return list.ToArray();
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_AdvancedRadioNoisemakerProp()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1973078897u, new RpcReceiveHandler(__rpc_handler_1973078897));
			NetworkManager.__rpc_func_table.Add(3129679409u, new RpcReceiveHandler(__rpc_handler_3129679409));
		}

		private static void __rpc_handler_1973078897(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool isRadioModeServerRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isRadioModeServerRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AdvancedRadioNoisemakerProp)(object)target).SetIsRadioModeServerRpc(isRadioModeServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3129679409(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int clipIndexServerRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clipIndexServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AdvancedRadioNoisemakerProp)(object)target).SetClipIndexServerRpc(clipIndexServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "AdvancedRadioNoisemakerProp";
		}
	}
	public class Magoroku : AdvancedNoisemakerProp
	{
		public override void ItemActivate(bool used, bool buttonDown = true)
		{
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "Magoroku";
		}
	}
}
namespace com.github.zehsteam.MagoPlush.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}