Decompiled source of DontTouchMyClogs v1.0.3

com.github.zehsteam.DontTouchMyClogs.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 DontTouchMyClogs;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Video;
using com.github.zehsteam.DontTouchMyClogs;
using com.github.zehsteam.DontTouchMyClogs.MonoBehaviours;
using com.github.zehsteam.DontTouchMyClogs.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.DontTouchMyClogs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Don't touch my clogs!")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+213cd5f3674f415446b89fc8e33833f17c3a0842")]
[assembly: AssemblyProduct("DontTouchMyClogs")]
[assembly: AssemblyTitle("com.github.zehsteam.DontTouchMyClogs")]
[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 DontTouchMyClogs
{
	[BepInPlugin("com.github.zehsteam.DontTouchMyClogs", "DontTouchMyClogs", "1.0.3")]
	[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.DontTouchMyClogs");
			logger.LogInfo((object)"DontTouchMyClogs 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.woodenClogs, value, value2, value3, value4, value5);
		}

		public void SpawnVideoPlayer()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)VideoPlayerBehaviour.Instance != (Object)null))
			{
				Object.Instantiate<GameObject>(Content.videoPlayerPrefab, Vector3.zero, Quaternion.identity);
				logger.LogInfo((object)"Spawned video player.");
			}
		}
	}
}
namespace com.github.zehsteam.DontTouchMyClogs
{
	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 ExtendedConfigEntry<float> VideoVolume;

		public ExtendedConfigEntry<bool> EnableMusic;

		public ExtendedConfigEntry<float> MusicVolume;

		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", 5, "Wooden Clogs spawn chance weight.", useEnableConfiguration: true);
			TwoHanded = new ExtendedConfigEntry<bool>("General Settings", "TwoHanded", defaultValue: false, "If enabled, the Wooden Clogs will be two-handed.", useEnableConfiguration: true);
			CarryWeight = new ExtendedConfigEntry<int>("General Settings", "CarryWeight", 12, "Wooden Clogs carry weight in pounds.", useEnableConfiguration: true);
			MinValue = new ExtendedConfigEntry<int>("General Settings", "MinValue", 80, "Wooden Clogs min scrap value.", useEnableConfiguration: true);
			MaxValue = new ExtendedConfigEntry<int>("General Settings", "MaxValue", 250, "Wooden Clogs max scrap value.", useEnableConfiguration: true);
			VideoVolume = new ExtendedConfigEntry<float>("Karaoke Settings", "VideoVolume", 0.7f, "The volume of the karaoke video. (0.0 to 1.0)", useEnableConfiguration: true);
			EnableMusic = new ExtendedConfigEntry<bool>("Music Settings", "EnableMusic", defaultValue: false, "STREAMER WARNING! Music is DMCA.\nIf enabled, the music will be play. (This does not affect Karaoke)", useEnableConfiguration: true);
			MusicVolume = new ExtendedConfigEntry<float>("Music Settings", "MusicVolume", 0.8f, "The volume of the music. (0.0 to 1.0)", 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()
		{
			GetValue = () => (UseEnableConfiguration && !Plugin.ConfigManager.EnableConfiguration.Value) ? DefaultValue : ConfigEntry.Value;
			SetValue = delegate(T value)
			{
				ConfigEntry.Value = value;
			};
		}

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

		public static GameObject videoPlayerPrefab;

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

		private static void LoadAssetsFromAssetBundle()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, "donttouchmyclogs_assets");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				woodenClogs = val.LoadAsset<Item>("WoodenClogs");
				videoPlayerPrefab = val.LoadAsset<GameObject>("VideoPlayer");
				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}");
			}
		}
	}
	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 PlayerControllerB GetLocalPlayerScript()
		{
			return GameNetworkManager.Instance.localPlayerController;
		}

		public static void DisplayNotification(string displayText)
		{
			HUDManager.Instance.globalNotificationAnimator.SetTrigger("TriggerNotif");
			((TMP_Text)HUDManager.Instance.globalNotificationText).text = displayText;
			HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.globalNotificationSFX);
		}

		public static void DisplayTip(string headerText, string bodyText, bool isWarning = false)
		{
			((TMP_Text)HUDManager.Instance.tipsPanelHeader).text = headerText;
			((TMP_Text)HUDManager.Instance.tipsPanelBody).text = bodyText;
			if (isWarning)
			{
				HUDManager.Instance.tipsPanelAnimator.SetTrigger("TriggerWarning");
				RoundManager.PlayRandomClip(HUDManager.Instance.UIAudio, HUDManager.Instance.warningSFX, false, 1f, 0, 1000);
			}
			else
			{
				HUDManager.Instance.tipsPanelAnimator.SetTrigger("TriggerHint");
				RoundManager.PlayRandomClip(HUDManager.Instance.UIAudio, HUDManager.Instance.tipsSFX, false, 1f, 0, 1000);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.DontTouchMyClogs";

		public const string PLUGIN_NAME = "DontTouchMyClogs";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}
namespace com.github.zehsteam.DontTouchMyClogs.MonoBehaviours
{
	public class ClogsBehaviour : NoisemakerProp
	{
		[Header("Clogs")]
		[Space(3f)]
		public AudioSource musicAudio = null;

		public AudioSource musicAudioFar = null;

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

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

		public bool isPlayingVideo => (Object)(object)VideoPlayerBehaviour.Instance != (Object)null && VideoPlayerBehaviour.Instance.isPlaying;

		public bool isPlayingMusic => musicAudio.isPlaying;

		public override void OnNetworkSpawn()
		{
			NetworkVariable<bool> obj = isMusicMode;
			obj.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnIsMusicModeChanged));
		}

		public override void OnNetworkDespawn()
		{
			NetworkVariable<bool> obj = isMusicMode;
			obj.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnIsMusicModeChanged));
		}

		public override void Start()
		{
			((NoisemakerProp)this).Start();
			float volume = Mathf.Clamp(Plugin.ConfigManager.MusicVolume.Value, 0f, 1f);
			if (!Plugin.ConfigManager.EnableMusic.Value)
			{
				musicAudio.mute = true;
				musicAudioFar.mute = true;
			}
			musicAudio.volume = volume;
			musicAudioFar.volume = volume;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (isHeldByLocalPlayer)
			{
				SetIsMusicMode(!isMusicMode.Value);
			}
		}

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

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
			if (isHeldByLocalPlayer)
			{
				Plugin.Instance.SpawnVideoPlayer();
			}
		}

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

		private void ItemInteractLeft()
		{
			if ((Object)(object)VideoPlayerBehaviour.Instance == (Object)null)
			{
				Plugin.logger.LogError((object)"Error: Failed to reset video. VideoPlayerBehaviour Instance does not exist.");
			}
			else if (isMusicMode.Value)
			{
				ResetMusic();
			}
			else
			{
				VideoPlayerBehaviour.Instance.ResetVideo();
			}
		}

		private void ItemInteractRight()
		{
			if ((Object)(object)VideoPlayerBehaviour.Instance == (Object)null)
			{
				Plugin.logger.LogError((object)"Error: Failed to play video. VideoPlayerBehaviour Instance does not exist.");
			}
			else if (isMusicMode.Value)
			{
				bool flag = !isPlayingMusic;
				if (Plugin.ConfigManager.EnableMusic.Value)
				{
					SetIsPlayingMusic(flag);
				}
				else if (!flag)
				{
					SetIsPlayingMusic(flag);
				}
				else
				{
					Utils.DisplayTip("DontTouchMyClogs", "STREAMER WARNING! Music is DMCA.\n\nWooden Clogs - Music is disabled in the config settings.", isWarning: true);
				}
			}
			else
			{
				VideoPlayerBehaviour.Instance.ToggleVideoPlay();
				SetControlTips();
			}
		}

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

		private void SetControlTips()
		{
			if (isHeldByLocalPlayer)
			{
				if (isMusicMode.Value)
				{
					SetMusicControlTips();
				}
				else
				{
					SetKaraokeControlTips();
				}
			}
		}

		private void SetKaraokeControlTips()
		{
			string[] toolTips = ((GrabbableObject)this).itemProperties.toolTips;
			if (toolTips.Length <= 2)
			{
				Plugin.logger.LogError((object)"Wooden Clogs control tips array length is too short to set tips!");
				return;
			}
			if (isPlayingVideo)
			{
				toolTips[1] = "Pause Karaoke : [E]";
			}
			else
			{
				toolTips[1] = "Play Karaoke : [E]";
			}
			toolTips[2] = "Reset Karaoke : [Q]";
			HUDManager.Instance.ChangeControlTipMultiple(toolTips, isHeldByLocalPlayer, ((GrabbableObject)this).itemProperties);
		}

		private void SetMusicControlTips()
		{
			string[] toolTips = ((GrabbableObject)this).itemProperties.toolTips;
			if (toolTips.Length <= 2)
			{
				Plugin.logger.LogError((object)"Wooden Clogs control tips array length is too short to set tips!");
				return;
			}
			if (isPlayingMusic)
			{
				toolTips[1] = "Pause Music : [E]";
			}
			else
			{
				toolTips[1] = "Play Music : [E]";
			}
			toolTips[2] = "Reset Music : [Q]";
			HUDManager.Instance.ChangeControlTipMultiple(toolTips, isHeldByLocalPlayer, ((GrabbableObject)this).itemProperties);
		}

		private void SetIsMusicMode(bool enabled)
		{
			if (enabled)
			{
				VideoPlayerBehaviour.Instance.PauseVideo();
			}
			if (Plugin.IsHostOrServer)
			{
				isMusicMode.Value = enabled;
			}
			else
			{
				SetIsMusicModeServerRpc(enabled);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SetIsMusicModeServerRpc(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(709245738u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref enabled, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 709245738u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					isMusicMode.Value = enabled;
				}
			}
		}

		private void OnIsMusicModeChanged(bool previous, bool current)
		{
			if (Plugin.IsHostOrServer && !current && isPlayingMusic)
			{
				SetIsPlayingMusic(isPlaying: false);
			}
			SetControlTips();
		}

		private void SetIsPlayingMusic(bool isPlaying)
		{
			if (Plugin.IsHostOrServer)
			{
				SetIsPlayingMusicClientRpc(isPlaying);
			}
			else
			{
				SetIsPlayingMusicServerRpc(isPlaying);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SetIsPlayingMusicServerRpc(bool isPlaying)
		{
			//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(3724498787u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isPlaying, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3724498787u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetIsPlayingMusicClientRpc(isPlaying);
				}
			}
		}

		[ClientRpc]
		private void SetIsPlayingMusicClientRpc(bool isPlaying)
		{
			//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)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1109088116u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isPlaying, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1109088116u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (isPlaying)
				{
					musicAudio.Play();
					musicAudioFar.Play();
				}
				else
				{
					musicAudio.Pause();
					musicAudioFar.Pause();
				}
				SetControlTips();
			}
		}

		private void ResetMusic()
		{
			if (Plugin.IsHostOrServer)
			{
				ResetMusicClientRpc();
			}
			else
			{
				ResetMusicServerRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ResetMusicServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: 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(2064704352u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2064704352u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ResetMusicClientRpc();
				}
			}
		}

		[ClientRpc]
		private void ResetMusicClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: 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(1251920394u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1251920394u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					musicAudio.time = 0f;
					musicAudioFar.time = 0f;
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ClogsBehaviour()
		{
			//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
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(709245738u, new RpcReceiveHandler(__rpc_handler_709245738));
			NetworkManager.__rpc_func_table.Add(3724498787u, new RpcReceiveHandler(__rpc_handler_3724498787));
			NetworkManager.__rpc_func_table.Add(1109088116u, new RpcReceiveHandler(__rpc_handler_1109088116));
			NetworkManager.__rpc_func_table.Add(2064704352u, new RpcReceiveHandler(__rpc_handler_2064704352));
			NetworkManager.__rpc_func_table.Add(1251920394u, new RpcReceiveHandler(__rpc_handler_1251920394));
		}

		private static void __rpc_handler_709245738(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 isMusicModeServerRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isMusicModeServerRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ClogsBehaviour)(object)target).SetIsMusicModeServerRpc(isMusicModeServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3724498787(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 isPlayingMusicServerRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isPlayingMusicServerRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ClogsBehaviour)(object)target).SetIsPlayingMusicServerRpc(isPlayingMusicServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1109088116(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 isPlayingMusicClientRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isPlayingMusicClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ClogsBehaviour)(object)target).SetIsPlayingMusicClientRpc(isPlayingMusicClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2064704352(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ClogsBehaviour)(object)target).ResetMusicServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1251920394(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ClogsBehaviour)(object)target).ResetMusicClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ClogsBehaviour";
		}
	}
	public class VideoPlayerBehaviour : MonoBehaviour
	{
		public static VideoPlayerBehaviour Instance;

		public GameObject containerObject;

		public VideoPlayer videoPlayer;

		public bool isPlaying => videoPlayer.isPlaying;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
		}

		private void Start()
		{
			PauseVideo();
			ResetVideo();
			float num = Mathf.Clamp(Plugin.ConfigManager.VideoVolume.Value, 0f, 1f);
			videoPlayer.SetDirectAudioVolume((ushort)0, num);
		}

		private void OnEnable()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			videoPlayer.loopPointReached += new EventHandler(OnVideoPlayerFinished);
		}

		private void OnDisable()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			videoPlayer.loopPointReached -= new EventHandler(OnVideoPlayerFinished);
		}

		private void OnVideoPlayerFinished(VideoPlayer source)
		{
			containerObject.SetActive(false);
			ResetVideo();
		}

		public void PlayVideo()
		{
			containerObject.SetActive(true);
			videoPlayer.Play();
		}

		public void PauseVideo()
		{
			containerObject.SetActive(false);
			videoPlayer.Pause();
		}

		public void ToggleVideoPlay()
		{
			if (isPlaying)
			{
				PauseVideo();
			}
			else
			{
				PlayVideo();
			}
		}

		public void ResetVideo()
		{
			videoPlayer.time = 0.75;
		}
	}
}
namespace com.github.zehsteam.DontTouchMyClogs.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}