Decompiled source of BlahajPlush v1.0.3

com.github.zehsteam.BlahajPlush.dll

Decompiled a week ago
using System;
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.BlahajPlush.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.BlahajPlush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a customizable Blåhaj plushie scrap item.")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+75e95b7d38c16d78266d6b3452ddfb59cc4fbbc1")]
[assembly: AssemblyProduct("BlahajPlush")]
[assembly: AssemblyTitle("com.github.zehsteam.BlahajPlush")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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.BlahajPlush
{
	internal class ConfigManager
	{
		public ExtendedConfigEntry<bool> EnableConfiguration;

		public ExtendedConfigEntry<int> SpawnWeight;

		public ExtendedConfigEntry<bool> TwoHanded;

		public ExtendedConfigEntry<int> CarryWeight;

		public ExtendedConfigEntry<int> MinValue;

		public ExtendedConfigEntry<int> MaxValue;

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

		private void BindConfigs()
		{
			EnableConfiguration = new ExtendedConfigEntry<bool>("General Settings", "EnableConfiguration", defaultValue: false, "Enable if you want to use custom set config setting values. If disabled, the default config setting values will be used.");
			SpawnWeight = new ExtendedConfigEntry<int>("General Settings", "SpawnWeight", 10, "Blahaj plush spawn chance weight.", useEnableConfiguration: true);
			TwoHanded = new ExtendedConfigEntry<bool>("General Settings", "TwoHanded", defaultValue: true, "If enabled, the Blahaj plush will be two-handed.", useEnableConfiguration: true);
			CarryWeight = new ExtendedConfigEntry<int>("General Settings", "CarryWeight", 12, "Blahaj plush carry weight in pounds.", useEnableConfiguration: true);
			MinValue = new ExtendedConfigEntry<int>("General Settings", "MinValue", 150, "Blahaj plush min scrap value.", useEnableConfiguration: true);
			MaxValue = new ExtendedConfigEntry<int>("General Settings", "MaxValue", 380, "Blahaj plush max scrap value.", useEnableConfiguration: true);
		}

		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();
		}
	}
	public class ExtendedConfigEntry<T>
	{
		public ConfigEntry<T> ConfigEntry;

		public Func<T> GetValue;

		public Action<T> SetValue;

		public bool UseEnableConfiguration = false;

		public T DefaultValue => (T)((ConfigEntryBase)ConfigEntry).DefaultValue;

		public T Value
		{
			get
			{
				return GetValue();
			}
			set
			{
				SetValue(value);
			}
		}

		public ExtendedConfigEntry(string section, string key, T defaultValue, string description, bool useEnableConfiguration = false)
		{
			ConfigEntry = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, description);
			UseEnableConfiguration = useEnableConfiguration;
			Initialize();
		}

		public ExtendedConfigEntry(string section, string key, T defaultValue, ConfigDescription configDescription = null, bool useEnableConfiguration = false)
		{
			ConfigEntry = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, configDescription);
			UseEnableConfiguration = useEnableConfiguration;
			Initialize();
		}

		private void Initialize()
		{
			if (GetValue == null)
			{
				GetValue = () => (UseEnableConfiguration && !Plugin.ConfigManager.EnableConfiguration.Value) ? DefaultValue : ConfigEntry.Value;
			}
			if (SetValue == null)
			{
				SetValue = delegate(T value)
				{
					ConfigEntry.Value = value;
				};
			}
		}

		public void ResetToDefault()
		{
			ConfigEntry.Value = (T)((ConfigEntryBase)ConfigEntry).DefaultValue;
		}
	}
	internal class Content
	{
		public static Item blahajPlush;

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

		private static void LoadAssetsFromAssetBundle()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, "blahajplush_assets");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				blahajPlush = val.LoadAsset<Item>("BlahajPlush");
				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.BlahajPlush", "BlahajPlush", "1.0.3")]
	[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.BlahajPlush");
			logger.LogInfo((object)"BlahajPlush 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 value = ConfigManager.SpawnWeight.Value;
			bool value2 = ConfigManager.TwoHanded.Value;
			int value3 = ConfigManager.CarryWeight.Value;
			int value4 = ConfigManager.MinValue.Value;
			int value5 = ConfigManager.MaxValue.Value;
			ScrapHelper.RegisterScrap(Content.blahajPlush, value, value2, value3, value4, value5);
		}
	}
	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 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 class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.BlahajPlush";

		public const string PLUGIN_NAME = "BlahajPlush";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}
namespace com.github.zehsteam.BlahajPlush.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(1521125703u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					BytePacker.WriteValueBitPacked(val2, fromPlayerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1521125703u, 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(3750164066u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					BytePacker.WriteValueBitPacked(val2, fromPlayerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3750164066u, 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(1521125703u, new RpcReceiveHandler(__rpc_handler_1521125703));
			NetworkManager.__rpc_func_table.Add(3750164066u, new RpcReceiveHandler(__rpc_handler_3750164066));
		}

		private static void __rpc_handler_1521125703(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_3750164066(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));
		}

		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(2788462826u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref enabled, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2788462826u, 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(3278068140u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3278068140u, 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(2788462826u, new RpcReceiveHandler(__rpc_handler_2788462826));
			NetworkManager.__rpc_func_table.Add(3278068140u, new RpcReceiveHandler(__rpc_handler_3278068140));
		}

		private static void __rpc_handler_2788462826(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_3278068140(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 BlahajBehaviour : AdvancedNoisemakerProp
	{
		public override void ItemActivate(bool used, bool buttonDown = true)
		{
		}

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

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