Decompiled source of Rave Cart v1.0.1

VideoCart.dll

Decompiled 2 days 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Video;

[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VideoCart")]
[assembly: AssemblyTitle("VideoCart")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Empress.CartVideo
{
	[BepInPlugin("dev.empress.repo.cartvideo", "Cart Video Screen", "1.7.0")]
	public sealed class CartVideoPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "dev.empress.repo.cartvideo";

		public const string PluginName = "Cart Video Screen";

		public const string PluginVersion = "1.7.0";

		private const string AsciiBanner = "\r\n/*  ██████╗ ███╗   ███╗███╗   ██╗██╗                           */\r\n/* ██╔═══██╗████╗ ████║████╗  ██║██║                           */\r\n/* ██║   ██║██╔████╔██║██╔██╗ ██║██║                           */\r\n/* ██║   ██║██║╚██╔╝██║██║╚██╗██║██║                           */\r\n/* ╚██████╔╝██║ ╚═╝ ██║██║ ╚████║██║                           */\r\n/*  ╚═════╝ ╚═╝     ╚═╝╚═╝  ╚═══╝╚═╝                           */\r\n/*                                                             */\r\n/* ███████╗███╗   ███╗██████╗ ██████╗ ███████╗███████╗███████╗ */\r\n/* ██╔════╝████╗ ████║██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝ */\r\n/* █████╗  ██╔████╔██║██████╔╝██████╔╝█████╗  ███████╗███████╗ */\r\n/* ██╔══╝  ██║╚██╔╝██║██╔═══╝ ██╔══██╗██╔══╝  ╚════██║╚════██║ */\r\n/* ███████╗██║ ╚═╝ ██║██║     ██║  ██║███████╗███████║███████║ */\r\n/* ╚══════╝╚═╝     ╚═╝╚═╝     ╚═╝  ╚═╝╚══════╝╚══════╝╚══════╝ */\r\n";

		internal static ConfigEntry<bool> CfgEnabled;

		internal static ConfigEntry<string> CfgUrl;

		internal static ConfigEntry<bool> CfgLoop;

		internal static ConfigEntry<bool> CfgEnableAudio;

		internal static ConfigEntry<float> CfgVolume;

		internal static ConfigEntry<float> CfgScrollVolumeStep;

		internal static ConfigEntry<KeyCode> CfgStartKey;

		internal static ConfigEntry<int> CfgTargetWidth;

		internal static ConfigEntry<int> CfgTargetHeight;

		internal static ConfigEntry<bool> CfgApplyToCartMesh;

		internal static ConfigEntry<bool> CfgApplyToGrabMesh;

		internal static ConfigEntry<bool> CfgReplaceAlbedo;

		internal static ConfigEntry<bool> CfgReplaceEmissionMap;

		internal static ConfigEntry<Color> CfgEmissionTint;

		internal static ConfigEntry<bool> CfgForceWhiteEmission;

		internal static ConfigEntry<bool> CfgRaveLights;

		internal static ConfigEntry<int> CfgRaveLightCount;

		internal static ConfigEntry<float> CfgRaveRadius;

		internal static ConfigEntry<float> CfgRaveIntensityMin;

		internal static ConfigEntry<float> CfgRaveIntensityMax;

		internal static ConfigEntry<float> CfgRaveHueSpeed;

		internal static ConfigEntry<float> CfgRaveResponsiveness;

		internal static ConfigEntry<bool> CfgBillboardEnabled;

		internal static ConfigEntry<float> CfgBillboardHeight;

		internal static ConfigEntry<float> CfgBillboardScale;

		internal static ConfigEntry<float> CfgBillboardFadeSeconds;

		internal static ConfigEntry<float> CfgChorusTime;

		internal static ConfigEntry<int> CfgPartyGrabCount;

		internal static ConfigEntry<float> CfgPartyRadius;

		internal static ConfigEntry<float> CfgPartyDuration;

		internal static readonly float CartFlipStartSec = 25f;

		private Harmony _harmony;

		internal static Type T_PhysGrabCart;

		internal static Type T_PhysGrabObject;

		internal static FieldInfo F_cartMesh;

		internal static FieldInfo F_grabMesh;

		internal static FieldInfo F_pgo;

		internal static FieldInfo F_PGO_playerGrabbing;

		internal static MethodInfo M_Start;

		internal static MethodInfo M_StateSwitch;

		internal static MethodInfo M_StateSwitchRPC;

		private static readonly string[] PriorityExt = new string[3] { ".mp4", ".webm", ".m3u8" };

		internal static string[] AutoPickedAbsoluteFiles = Array.Empty<string>();

		internal static string[] AutoPickedUrls = Array.Empty<string>();

		private void Awake()
		{
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Expected O, but got Unknown
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Expected O, but got Unknown
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Expected O, but got Unknown
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Expected O, but got Unknown
			CfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "");
			CfgUrl = ((BaseUnityPlugin)this).Config.Bind<string>("Video", "Url", "", "");
			CfgLoop = ((BaseUnityPlugin)this).Config.Bind<bool>("Video", "Loop", true, "");
			CfgEnableAudio = ((BaseUnityPlugin)this).Config.Bind<bool>("Video", "AudioEnabled", true, "");
			CfgVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Video", "Volume", 0.75f, "");
			CfgScrollVolumeStep = ((BaseUnityPlugin)this).Config.Bind<float>("Video", "ScrollVolumeStep", 0.06f, "");
			CfgStartKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Video", "StartKey", (KeyCode)101, "");
			CfgTargetWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Render", "Width", 512, "");
			CfgTargetHeight = ((BaseUnityPlugin)this).Config.Bind<int>("Render", "Height", 512, "");
			CfgApplyToCartMesh = ((BaseUnityPlugin)this).Config.Bind<bool>("Apply", "ToCartMesh", true, "");
			CfgApplyToGrabMesh = ((BaseUnityPlugin)this).Config.Bind<bool>("Apply", "ToGrabMesh", true, "");
			CfgReplaceAlbedo = ((BaseUnityPlugin)this).Config.Bind<bool>("Apply", "ReplaceAlbedo", false, "");
			CfgReplaceEmissionMap = ((BaseUnityPlugin)this).Config.Bind<bool>("Apply", "ReplaceEmissionMap", true, "");
			CfgEmissionTint = ((BaseUnityPlugin)this).Config.Bind<Color>("Apply", "EmissionTint", new Color(1f, 1f, 1f, 1f), "");
			CfgForceWhiteEmission = ((BaseUnityPlugin)this).Config.Bind<bool>("Apply", "ForceWhiteEmission", true, "");
			CfgRaveLights = ((BaseUnityPlugin)this).Config.Bind<bool>("Rave", "Enabled", true, "");
			CfgRaveLightCount = ((BaseUnityPlugin)this).Config.Bind<int>("Rave", "Count", 6, "");
			CfgRaveRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Rave", "Radius", 0.9f, "");
			CfgRaveIntensityMin = ((BaseUnityPlugin)this).Config.Bind<float>("Rave", "IntensityMin", 0.15f, "");
			CfgRaveIntensityMax = ((BaseUnityPlugin)this).Config.Bind<float>("Rave", "IntensityMax", 1.5f, "");
			CfgRaveHueSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Rave", "HueSpeed", 0.3f, "");
			CfgRaveResponsiveness = ((BaseUnityPlugin)this).Config.Bind<float>("Rave", "Responsiveness", 4f, "");
			CfgBillboardEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Billboard", "Enabled", true, "");
			CfgBillboardHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Billboard", "Height", 1.1f, "");
			CfgBillboardScale = ((BaseUnityPlugin)this).Config.Bind<float>("Billboard", "Scale", 0.0026f, "");
			CfgBillboardFadeSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Billboard", "FadeSeconds", 0.6f, "");
			CfgChorusTime = ((BaseUnityPlugin)this).Config.Bind<float>("Party", "ChorusTimeSec", 26f, "");
			CfgPartyGrabCount = ((BaseUnityPlugin)this).Config.Bind<int>("Party", "GrabCount", 8, "");
			CfgPartyRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Party", "Radius", 7f, "");
			CfgPartyDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Party", "DurationSec", 10f, "");
			T_PhysGrabCart = AccessTools.TypeByName("PhysGrabCart");
			T_PhysGrabObject = AccessTools.TypeByName("PhysGrabObject");
			if (!(T_PhysGrabCart == null))
			{
				F_cartMesh = AccessTools.Field(T_PhysGrabCart, "cartMesh");
				F_grabMesh = AccessTools.Field(T_PhysGrabCart, "grabMesh");
				F_pgo = AccessTools.Field(T_PhysGrabCart, "physGrabObject");
				if (T_PhysGrabObject != null)
				{
					F_PGO_playerGrabbing = AccessTools.Field(T_PhysGrabObject, "playerGrabbing");
				}
				M_Start = AccessTools.Method(T_PhysGrabCart, "Start", (Type[])null, (Type[])null);
				M_StateSwitch = AccessTools.Method(T_PhysGrabCart, "StateSwitch", new Type[1] { AccessTools.TypeByName("PhysGrabCart+State") }, (Type[])null);
				M_StateSwitchRPC = AccessTools.Method(T_PhysGrabCart, "StateSwitchRPC", new Type[1] { AccessTools.TypeByName("PhysGrabCart+State") }, (Type[])null);
				if (string.IsNullOrWhiteSpace(CfgUrl.Value))
				{
					TryAutoPickAllMediaNextToDll();
				}
				_harmony = new Harmony("dev.empress.repo.cartvideo");
				if (M_Start != null)
				{
					_harmony.Patch((MethodBase)M_Start, (HarmonyMethod)null, new HarmonyMethod(typeof(CartVideoPlugin).GetMethod("Postfix_AttachVideoController", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				if (M_StateSwitch != null)
				{
					_harmony.Patch((MethodBase)M_StateSwitch, (HarmonyMethod)null, new HarmonyMethod(typeof(CartVideoPlugin).GetMethod("Postfix_RestoreEmissionAfterStateSwitch", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				if (M_StateSwitchRPC != null)
				{
					_harmony.Patch((MethodBase)M_StateSwitchRPC, (HarmonyMethod)null, new HarmonyMethod(typeof(CartVideoPlugin).GetMethod("Postfix_RestoreEmissionAfterStateSwitch", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		private static void Postfix_AttachVideoController(MonoBehaviour __instance)
		{
			try
			{
				CartVideoController cartVideoController = default(CartVideoController);
				if (CfgEnabled.Value && !((Component)__instance).gameObject.TryGetComponent<CartVideoController>(ref cartVideoController))
				{
					((Component)__instance).gameObject.AddComponent<CartVideoController>();
				}
			}
			catch
			{
			}
		}

		private static void Postfix_RestoreEmissionAfterStateSwitch(MonoBehaviour __instance)
		{
			try
			{
				if (CfgEnabled.Value && CfgForceWhiteEmission.Value)
				{
					((Component)__instance).GetComponent<CartVideoController>()?.RestoreEmissionTint();
				}
			}
			catch
			{
			}
		}

		private static void TryAutoPickAllMediaNextToDll()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				if (string.IsNullOrEmpty(directoryName) || !Directory.Exists(directoryName))
				{
					return;
				}
				List<string> list = new List<string>();
				string[] priorityExt = PriorityExt;
				foreach (string text in priorityExt)
				{
					list.AddRange(Directory.EnumerateFiles(directoryName, "*" + text, SearchOption.TopDirectoryOnly).OrderBy<string, string>((string p) => Path.GetFileName(p), StringComparer.OrdinalIgnoreCase));
				}
				AutoPickedAbsoluteFiles = list.ToArray();
				AutoPickedUrls = list.Select((string p) => new Uri(Path.GetFullPath(p)).AbsoluteUri).ToArray();
			}
			catch
			{
			}
		}

		internal static string ResolveInitialUrl()
		{
			return (!string.IsNullOrWhiteSpace(CfgUrl.Value)) ? CfgUrl.Value : ((AutoPickedUrls.Length != 0) ? AutoPickedUrls[0] : "");
		}
	}
	internal sealed class CartVideoController : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <ResetCartRotationSmooth>d__35 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CartVideoController <>4__this;

			private Quaternion <start>5__1;

			private Quaternion <target>5__2;

			private float <t>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ResetCartRotationSmooth>d__35(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<start>5__1 = ((Component)<>4__this).transform.localRotation;
					<target>5__2 = Quaternion.identity;
					<t>5__3 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<t>5__3 < 0.4f && !<>4__this._isPlaying)
				{
					<t>5__3 += Time.deltaTime;
					((Component)<>4__this).transform.localRotation = Quaternion.Slerp(<start>5__1, <target>5__2, <t>5__3 / 0.4f);
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if (!<>4__this._isPlaying)
				{
					((Component)<>4__this).transform.localRotation = <target>5__2;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private MeshRenderer _cartMesh;

		private MeshRenderer[] _grabMesh;

		private readonly List<Material> _mats = new List<Material>();

		private RenderTexture _rt;

		private VideoPlayer _vp;

		private AudioSource _audio;

		private Component _cart;

		private Component _pgo;

		private bool _prepared;

		private bool _startRequested;

		private bool _isPlaying;

		private double _playStartTime;

		private float _unityStartTime;

		private int _mediaIndex;

		private readonly List<Light> _lights = new List<Light>();

		private float[] _spec = new float[64];

		private float _energySmoothed;

		private float _hue;

		private GameObject _billboardGO;

		private TextMesh _billTM;

		private float _billAlphaTarget = 0f;

		private float _billAlpha = 0f;

		private GameObject _padGO;

		private MeshRenderer _padMR;

		private bool _partyTriggered;

		private float _partyEndTime;

		private readonly List<(Rigidbody rb, Transform t, Material[] mats, Transform originalParent)> _partyObjs = new List<(Rigidbody, Transform, Material[], Transform)>();

		private float _asciiWobble;

		private void Awake()
		{
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_cart = ((Component)this).GetComponent(CartVideoPlugin.T_PhysGrabCart);
				if ((Object)(object)_cart == (Object)null)
				{
					((Behaviour)this).enabled = false;
					return;
				}
				if (CartVideoPlugin.F_pgo != null)
				{
					ref Component pgo = ref _pgo;
					object? value = CartVideoPlugin.F_pgo.GetValue(_cart);
					pgo = (Component)((value is Component) ? value : null);
				}
				ref MeshRenderer cartMesh = ref _cartMesh;
				object? obj = CartVideoPlugin.F_cartMesh?.GetValue(_cart);
				cartMesh = (MeshRenderer)((obj is MeshRenderer) ? obj : null);
				_grabMesh = CartVideoPlugin.F_grabMesh?.GetValue(_cart) as MeshRenderer[];
				if (CartVideoPlugin.CfgApplyToCartMesh.Value && (Object)(object)_cartMesh != (Object)null)
				{
					_mats.AddRange(((Renderer)_cartMesh).materials);
				}
				if (CartVideoPlugin.CfgApplyToGrabMesh.Value && _grabMesh != null)
				{
					MeshRenderer[] grabMesh = _grabMesh;
					foreach (MeshRenderer val in grabMesh)
					{
						if (Object.op_Implicit((Object)(object)val))
						{
							_mats.AddRange(((Renderer)val).materials);
						}
					}
				}
				if (_mats.Count == 0)
				{
					((Behaviour)this).enabled = false;
					return;
				}
				_rt = new RenderTexture(Mathf.Max(64, CartVideoPlugin.CfgTargetWidth.Value), Mathf.Max(64, CartVideoPlugin.CfgTargetHeight.Value), 0, (RenderTextureFormat)0)
				{
					name = $"CartVideoRT_{((Object)this).GetInstanceID()}"
				};
				_rt.Create();
				_vp = ((Component)this).gameObject.AddComponent<VideoPlayer>();
				_vp.playOnAwake = false;
				_vp.isLooping = CartVideoPlugin.CfgLoop.Value;
				_vp.renderMode = (VideoRenderMode)2;
				_vp.targetTexture = _rt;
				_vp.audioOutputMode = (VideoAudioOutputMode)(CartVideoPlugin.CfgEnableAudio.Value ? 1 : 0);
				if (CartVideoPlugin.CfgEnableAudio.Value)
				{
					_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
					_audio.playOnAwake = false;
					_audio.spatialBlend = 1f;
					_audio.volume = Mathf.Clamp01(CartVideoPlugin.CfgVolume.Value);
					_vp.SetTargetAudioSource((ushort)0, _audio);
					_vp.controlledAudioTrackCount = 1;
					_vp.EnableAudioTrack((ushort)0, true);
				}
				ApplyTextureToAll((Texture)(object)_rt, CartVideoPlugin.CfgEmissionTint.Value);
				string text = CartVideoPlugin.ResolveInitialUrl();
				if (!string.IsNullOrEmpty(text) && !IsYouTube(text))
				{
					_mediaIndex = ResolveIndexForUrl(text);
					PrepareUrl(text);
				}
				if (CartVideoPlugin.CfgRaveLights.Value)
				{
					BuildRaveLights();
				}
				if (CartVideoPlugin.CfgBillboardEnabled.Value)
				{
					BuildBillboard();
				}
			}
			catch
			{
				((Behaviour)this).enabled = false;
			}
		}

		private void Update()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			bool flag = IsGrabbedByAnyone();
			if (flag && Input.GetKeyDown(CartVideoPlugin.CfgStartKey.Value))
			{
				if (_isPlaying)
				{
					StopPlayback();
				}
				else
				{
					_startRequested = true;
					TryStartPlayback();
				}
			}
			if (flag && CartVideoPlugin.CfgEnableAudio.Value && (Object)(object)_audio != (Object)null)
			{
				float y = Input.mouseScrollDelta.y;
				if (Mathf.Abs(y) > 0.0001f)
				{
					_audio.volume = Mathf.Clamp01(_audio.volume + y * CartVideoPlugin.CfgScrollVolumeStep.Value);
				}
				if (Input.GetMouseButtonDown(1))
				{
					CycleNextMedia();
				}
			}
			float energy = ComputeSmoothedEnergy();
			AnimateRaveLights(energy);
			AnimateBillboard(energy);
			HandleCartAndParty(energy);
			UpdateParty(energy);
			AnimateAsciiParty(energy);
			if ((Object)(object)_billboardGO != (Object)null && (Object)(object)Camera.main != (Object)null)
			{
				_billboardGO.transform.rotation = Quaternion.LookRotation(_billboardGO.transform.position - ((Component)Camera.main).transform.position);
			}
		}

		private void OnDestroy()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			try
			{
				if ((Object)(object)_vp != (Object)null)
				{
					_vp.prepareCompleted -= new EventHandler(OnPrepared);
					_vp.errorReceived -= new ErrorEventHandler(OnError);
					if (_vp.isPlaying)
					{
						_vp.Stop();
					}
				}
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)_audio != (Object)null && _audio.isPlaying)
				{
					_audio.Stop();
				}
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)_rt != (Object)null)
				{
					_rt.Release();
					Object.Destroy((Object)(object)_rt);
				}
			}
			catch
			{
			}
			try
			{
				foreach (Light light in _lights)
				{
					if (Object.op_Implicit((Object)(object)light))
					{
						Object.Destroy((Object)(object)((Component)light).gameObject);
					}
				}
				_lights.Clear();
			}
			catch
			{
			}
			try
			{
				if (Object.op_Implicit((Object)(object)_billboardGO))
				{
					Object.Destroy((Object)(object)_billboardGO);
				}
			}
			catch
			{
			}
			try
			{
				foreach (var partyObj in _partyObjs)
				{
					if (Object.op_Implicit((Object)(object)partyObj.t))
					{
						partyObj.t.SetParent(partyObj.originalParent, true);
					}
				}
				_partyObjs.Clear();
			}
			catch
			{
			}
		}

		private void PrepareUrl(string url)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			try
			{
				_prepared = false;
				_vp.source = (VideoSource)1;
				_vp.url = url;
				_vp.errorReceived -= new ErrorEventHandler(OnError);
				_vp.prepareCompleted -= new EventHandler(OnPrepared);
				_vp.errorReceived += new ErrorEventHandler(OnError);
				_vp.prepareCompleted += new EventHandler(OnPrepared);
				_vp.Prepare();
			}
			catch
			{
			}
		}

		private void OnPrepared(VideoPlayer vp)
		{
			_prepared = true;
			if (_startRequested)
			{
				TryStartPlayback();
			}
		}

		private void TryStartPlayback()
		{
			if (_prepared && !_isPlaying)
			{
				if (CartVideoPlugin.CfgEnableAudio.Value && (Object)(object)_audio != (Object)null && !_audio.isPlaying)
				{
					_audio.Play();
				}
				_vp.Play();
				_isPlaying = true;
				_billAlphaTarget = 1f;
				_playStartTime = _vp.time;
				_unityStartTime = Time.time;
			}
		}

		private void StopPlayback()
		{
			try
			{
				if ((Object)(object)_vp != (Object)null && _vp.isPlaying)
				{
					_vp.Stop();
				}
				if ((Object)(object)_audio != (Object)null && _audio.isPlaying)
				{
					_audio.Stop();
				}
			}
			catch
			{
			}
			_isPlaying = false;
			_startRequested = false;
			_billAlphaTarget = 0f;
			((MonoBehaviour)this).StartCoroutine(ResetCartRotationSmooth());
			if (_partyTriggered)
			{
				_partyEndTime = Time.time - 0.01f;
			}
		}

		[IteratorStateMachine(typeof(<ResetCartRotationSmooth>d__35))]
		private IEnumerator ResetCartRotationSmooth()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ResetCartRotationSmooth>d__35(0)
			{
				<>4__this = this
			};
		}

		private void OnError(VideoPlayer vp, string msg)
		{
		}

		private int ResolveIndexForUrl(string url)
		{
			if (string.IsNullOrWhiteSpace(url))
			{
				return 0;
			}
			for (int i = 0; i < CartVideoPlugin.AutoPickedUrls.Length; i++)
			{
				if (string.Equals(CartVideoPlugin.AutoPickedUrls[i], url, StringComparison.OrdinalIgnoreCase))
				{
					return i;
				}
			}
			return 0;
		}

		private void CycleNextMedia()
		{
			if (string.IsNullOrWhiteSpace(CartVideoPlugin.CfgUrl.Value) && CartVideoPlugin.AutoPickedUrls.Length > 1)
			{
				_mediaIndex = (_mediaIndex + 1) % CartVideoPlugin.AutoPickedUrls.Length;
				string url = CartVideoPlugin.AutoPickedUrls[_mediaIndex];
				if ((Object)(object)_audio != (Object)null && _audio.isPlaying)
				{
					_audio.Stop();
				}
				_startRequested = true;
				PrepareUrl(url);
			}
		}

		internal void RestoreEmissionTint()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Color value = CartVideoPlugin.CfgEmissionTint.Value;
				foreach (Material mat in _mats)
				{
					if (!((Object)(object)mat == (Object)null) && mat.HasProperty("_EmissionColor"))
					{
						mat.SetColor("_EmissionColor", value);
						mat.EnableKeyword("_EMISSION");
					}
				}
			}
			catch
			{
			}
		}

		private void ApplyTextureToAll(Texture tex, Color emissionTint)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			foreach (Material mat in _mats)
			{
				if ((Object)(object)mat == (Object)null)
				{
					continue;
				}
				if (CartVideoPlugin.CfgReplaceAlbedo.Value)
				{
					try
					{
						mat.mainTexture = tex;
					}
					catch
					{
					}
				}
				if (!CartVideoPlugin.CfgReplaceEmissionMap.Value)
				{
					continue;
				}
				if (mat.HasProperty("_EmissionMap"))
				{
					try
					{
						mat.SetTexture("_EmissionMap", tex);
					}
					catch
					{
					}
				}
				if (mat.HasProperty("_EmissionColor"))
				{
					try
					{
						mat.SetColor("_EmissionColor", emissionTint);
					}
					catch
					{
					}
				}
				mat.EnableKeyword("_EMISSION");
			}
		}

		private bool IsGrabbedByAnyone()
		{
			try
			{
				if ((Object)(object)_pgo != (Object)null && CartVideoPlugin.F_PGO_playerGrabbing != null)
				{
					return CartVideoPlugin.F_PGO_playerGrabbing.GetValue(_pgo) is ICollection collection && collection.Count > 0;
				}
			}
			catch
			{
			}
			return false;
		}

		private void BuildRaveLights()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = Mathf.Clamp(CartVideoPlugin.CfgRaveLightCount.Value, 1, 24);
				float num2 = Mathf.Max(0.1f, CartVideoPlugin.CfgRaveRadius.Value);
				for (int i = 0; i < num; i++)
				{
					GameObject val = new GameObject($"RaveLight_{i}");
					val.transform.SetParent(((Component)this).transform, false);
					float num3 = (float)i / (float)num * MathF.PI * 2f;
					val.transform.localPosition = new Vector3(Mathf.Cos(num3) * num2, 0.4f, Mathf.Sin(num3) * num2);
					val.transform.localRotation = Quaternion.identity;
					Light val2 = val.AddComponent<Light>();
					val2.type = (LightType)2;
					val2.range = 4f;
					val2.intensity = CartVideoPlugin.CfgRaveIntensityMin.Value;
					val2.shadows = (LightShadows)0;
					_lights.Add(val2);
				}
			}
			catch
			{
			}
		}

		private float ComputeSmoothedEnergy()
		{
			try
			{
				if ((Object)(object)_audio != (Object)null)
				{
					_audio.GetSpectrumData(_spec, 0, (FFTWindow)5);
				}
				else
				{
					AudioListener.GetSpectrumData(_spec, 0, (FFTWindow)5);
				}
				float num = 0f;
				for (int i = 1; i < _spec.Length; i++)
				{
					num += Mathf.Sqrt(_spec[i]) * ((float)i * 0.03f);
				}
				num = Mathf.Clamp01(num * 2f);
				float num2 = Mathf.Clamp(CartVideoPlugin.CfgRaveResponsiveness.Value, 1f, 10f);
				_energySmoothed = Mathf.Lerp(_energySmoothed, num, Time.deltaTime * num2);
				return _energySmoothed;
			}
			catch
			{
				return _energySmoothed * 0.98f;
			}
		}

		private void AnimateRaveLights(float energy)
		{
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (!CartVideoPlugin.CfgRaveLights.Value || _lights.Count == 0)
			{
				return;
			}
			float value = CartVideoPlugin.CfgRaveIntensityMin.Value;
			float value2 = CartVideoPlugin.CfgRaveIntensityMax.Value;
			float num = (_isPlaying ? Mathf.Lerp(value, value2, Mathf.Pow(energy, 0.5f)) : value);
			_hue = Mathf.Repeat(_hue + Time.deltaTime * CartVideoPlugin.CfgRaveHueSpeed.Value, 1f);
			for (int i = 0; i < _lights.Count; i++)
			{
				Light val = _lights[i];
				if (Object.op_Implicit((Object)(object)val))
				{
					float num2 = Mathf.Repeat(_hue + (float)i / (float)_lights.Count, 1f);
					val.color = Color.HSVToRGB(num2, 1f, 1f);
					val.intensity = Mathf.Lerp(val.intensity, num, Time.deltaTime * 6f);
				}
			}
		}

		private void BuildBillboard()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_billboardGO = new GameObject("Empress_ASCII_Billboard");
				_billboardGO.transform.SetParent(((Component)this).transform, false);
				_billboardGO.transform.localPosition = new Vector3(0f, CartVideoPlugin.CfgBillboardHeight.Value, 0f);
				_billboardGO.transform.localRotation = Quaternion.identity;
				_billboardGO.transform.localScale = Vector3.one * CartVideoPlugin.CfgBillboardScale.Value;
				_billTM = _billboardGO.AddComponent<TextMesh>();
				_billTM.text = "██████╗  ███╗ ███ ╗███╗   ██╗██╗                           \r\n ██╔═══██╗████╗ ████║████╗  ██║██║                           \r\n ██║   ██║██╔████╔██║██╔██╗ ██║██║                           \r\n ██║   ██║██║╚██╔╝██║██║╚██╗██║██║                           \r\n ╚██████╔╝██║ ╚═╝ ██║██║ ╚████║██║                           \r\n  ╚═════╝ ╚═╝     ╚═╝╚═╝  ╚═══╝╚═╝                           \r\n                                                            \r\n ███████╗███╗   ███╗██████╗ ██████╗ ███████╗███████╗███████╗ \r\n ██╔════╝████╗ ████║██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝ \r\n █████╗  ██╔████╔██║██████╔╝██████╔╝█████╗  ███████╗███████╗ \r\n ██╔══╝  ██║╚██╔╝██║██╔═══╝ ██╔══██╗██╔══╝  ╚════██║╚════██║ \r\n ███████╗██║ ╚═╝ ██║██║     ██║  ██║███████╗███████║███████║ \r\n ╚══════╝╚═╝     ╚═╝╚═╝     ╚═╝  ╚═╝╚══════╝╚══════╝╚══════╝ ";
				_billTM.anchor = (TextAnchor)4;
				_billTM.alignment = (TextAlignment)1;
				_billTM.characterSize = 1f;
				_billTM.fontSize = 90;
				_billTM.lineSpacing = 0.85f;
				_billTM.color = new Color(1f, 1f, 1f, 0f);
				MeshRenderer component = _billboardGO.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
					((Renderer)component).receiveShadows = false;
					((Renderer)component).allowOcclusionWhenDynamic = false;
				}
				CreateOrUpdatePad(visible: false);
				_billAlpha = 0f;
				_billAlphaTarget = 0f;
			}
			catch
			{
			}
		}

		private void CreateOrUpdatePad(bool visible)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_billboardGO == (Object)null)
				{
					return;
				}
				if ((Object)(object)_padGO == (Object)null)
				{
					_padGO = GameObject.CreatePrimitive((PrimitiveType)5);
					((Object)_padGO).name = "BoundsPadder";
					_padGO.transform.SetParent(_billboardGO.transform, false);
					_padGO.transform.localPosition = Vector3.zero;
					_padGO.transform.localRotation = Quaternion.identity;
					_padGO.transform.localScale = new Vector3(20f, 12f, 1f);
					Collider component = _padGO.GetComponent<Collider>();
					if (Object.op_Implicit((Object)(object)component))
					{
						Object.Destroy((Object)(object)component);
					}
					_padMR = _padGO.GetComponent<MeshRenderer>();
					if ((Object)(object)_padMR != (Object)null)
					{
						((Renderer)_padMR).shadowCastingMode = (ShadowCastingMode)0;
						((Renderer)_padMR).receiveShadows = false;
						Shader val = Shader.Find("Unlit/Transparent");
						if ((Object)(object)val == (Object)null)
						{
							val = Shader.Find("Sprites/Default");
						}
						if ((Object)(object)val == (Object)null)
						{
							val = Shader.Find("Legacy Shaders/Particles/Alpha Blended");
						}
						Material val2 = ((!((Object)(object)val != (Object)null)) ? new Material(((Renderer)_padMR).sharedMaterial) : new Material(val));
						if (val2.HasProperty("_Color"))
						{
							val2.SetColor("_Color", new Color(1f, 1f, 1f, 0f));
						}
						else if (val2.HasProperty("_BaseColor"))
						{
							val2.SetColor("_BaseColor", new Color(1f, 1f, 1f, 0f));
						}
						val2.renderQueue = 3000;
						((Renderer)_padMR).material = val2;
					}
				}
				if ((Object)(object)_padMR != (Object)null)
				{
					((Renderer)_padMR).enabled = visible;
				}
			}
			catch
			{
				if ((Object)(object)_padMR != (Object)null)
				{
					((Renderer)_padMR).enabled = false;
				}
			}
		}

		private void AnimateBillboard(float energy)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_billTM == (Object)null))
			{
				float num = Mathf.Clamp01((CartVideoPlugin.CfgBillboardFadeSeconds.Value <= 0f) ? 1f : (Time.deltaTime / CartVideoPlugin.CfgBillboardFadeSeconds.Value));
				_billAlpha = Mathf.Lerp(_billAlpha, _billAlphaTarget, num);
				_hue = Mathf.Repeat(_hue + Time.deltaTime * CartVideoPlugin.CfgRaveHueSpeed.Value * 0.8f, 1f);
				Color val = Color.HSVToRGB(_hue, 1f, 1f);
				float num2 = Mathf.Lerp(0.55f, 1f, Mathf.Pow(energy, 0.45f));
				_billTM.color = new Color(val.r * num2, val.g * num2, val.b * num2, _billAlpha);
				float num3 = 1f + energy * 0.12f;
				if ((Object)(object)_billboardGO != (Object)null)
				{
					_billboardGO.transform.localScale = Vector3.one * CartVideoPlugin.CfgBillboardScale.Value * num3;
				}
				CreateOrUpdatePad(_billAlpha > 0.02f);
			}
		}

		private void HandleCartAndParty(float energy)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			if (_isPlaying)
			{
				float playbackSeconds = GetPlaybackSeconds();
				if (playbackSeconds >= CartVideoPlugin.CartFlipStartSec)
				{
					float num = Mathf.Lerp(0f, 120f, Mathf.Clamp01(energy));
					Vector3 val = default(Vector3);
					((Vector3)(ref val))..ctor(Mathf.Sin(Time.time * 1.3f) * num, Mathf.Cos(Time.time * 1.1f) * num * 0.8f, Mathf.Sin(Time.time * 0.9f + 1.2f) * num * 0.6f);
					((Component)this).transform.Rotate(val * Time.deltaTime, (Space)1);
				}
				if (!_partyTriggered && playbackSeconds >= CartVideoPlugin.CfgChorusTime.Value)
				{
					TryTriggerParty();
				}
				if (playbackSeconds >= CartVideoPlugin.CfgChorusTime.Value)
				{
					float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((energy - 0.35f) * 2.2f));
					float num3 = Mathf.Lerp(80f, 420f, num2);
					Vector3 val2 = default(Vector3);
					((Vector3)(ref val2))..ctor(Mathf.Sin(Time.time * 2.1f) * num3, Mathf.Cos(Time.time * 1.9f) * num3 * 0.9f, Mathf.Sin(Time.time * 1.7f + 1.2f) * num3 * 0.7f);
					((Component)this).transform.Rotate(val2 * Time.deltaTime, (Space)1);
				}
			}
		}

		private float GetPlaybackSeconds()
		{
			try
			{
				if ((Object)(object)_vp != (Object)null && _vp.isPlaying)
				{
					return (float)_vp.time;
				}
			}
			catch
			{
			}
			return _isPlaying ? (Time.time - _unityStartTime) : 0f;
		}

		private void TryTriggerParty()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			if (_partyTriggered)
			{
				return;
			}
			_partyTriggered = true;
			_partyEndTime = Time.time + Mathf.Max(2f, CartVideoPlugin.CfgPartyDuration.Value);
			_asciiWobble = 0f;
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, CartVideoPlugin.CfgPartyRadius.Value, -1, (QueryTriggerInteraction)1);
			List<Rigidbody> list = new List<Rigidbody>();
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if (!Object.op_Implicit((Object)(object)val) || (Object)(object)val.attachedRigidbody == (Object)null)
				{
					continue;
				}
				Rigidbody attachedRigidbody = val.attachedRigidbody;
				if (!attachedRigidbody.isKinematic && !((Component)attachedRigidbody).transform.IsChildOf(((Component)this).transform))
				{
					string text = ((Object)attachedRigidbody).name.ToLowerInvariant();
					if (!text.Contains("floor") && !text.Contains("ground") && !text.Contains("wall"))
					{
						list.Add(attachedRigidbody);
					}
				}
			}
			int num = Mathf.Clamp(CartVideoPlugin.CfgPartyGrabCount.Value, 0, 24);
			for (int j = 0; j < list.Count; j++)
			{
				if (_partyObjs.Count >= num)
				{
					break;
				}
				Rigidbody val2 = list[j];
				if (Object.op_Implicit((Object)(object)val2))
				{
					MeshRenderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<MeshRenderer>(true);
					Material[] item = (from m in componentsInChildren
						select Object.op_Implicit((Object)(object)m) ? ((Renderer)m).material : null into m
						where (Object)(object)m != (Object)null
						select m).ToArray();
					_partyObjs.Add((val2, ((Component)val2).transform, item, ((Component)val2).transform.parent));
					((Component)val2).transform.SetParent(((Component)this).transform, true);
					val2.velocity = Vector3.zero;
					val2.angularVelocity = Vector3.zero;
					val2.AddTorque(Random.onUnitSphere * 12f, (ForceMode)2);
				}
			}
		}

		private void UpdateParty(float energy)
		{
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: 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)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			if (_partyTriggered && Time.time >= _partyEndTime)
			{
				foreach (var partyObj in _partyObjs)
				{
					if (!Object.op_Implicit((Object)(object)partyObj.t))
					{
						continue;
					}
					partyObj.t.SetParent(partyObj.originalParent, true);
					if (Object.op_Implicit((Object)(object)partyObj.rb))
					{
						partyObj.rb.AddTorque(Random.onUnitSphere * 2f, (ForceMode)2);
					}
					Material[] item = partyObj.mats;
					foreach (Material val in item)
					{
						if (Object.op_Implicit((Object)(object)val) && val.HasProperty("_EmissionColor"))
						{
							val.SetColor("_EmissionColor", CartVideoPlugin.CfgEmissionTint.Value);
						}
					}
				}
				_partyObjs.Clear();
				_partyTriggered = false;
			}
			if (!_partyTriggered)
			{
				return;
			}
			float num = Mathf.Lerp(1.5f, 3.5f, energy);
			float num2 = Mathf.Lerp(90f, 360f, energy);
			float time = Time.time;
			Vector3 val2 = default(Vector3);
			for (int j = 0; j < _partyObjs.Count; j++)
			{
				(Rigidbody, Transform, Material[], Transform) tuple = _partyObjs[j];
				if (!Object.op_Implicit((Object)(object)tuple.Item2))
				{
					continue;
				}
				float num3 = (float)j / (float)Mathf.Max(1, _partyObjs.Count) * MathF.PI * 2f + time * num2 * (MathF.PI / 180f) * 0.2f;
				((Vector3)(ref val2))..ctor(Mathf.Cos(num3) * num, Mathf.Sin(time * 1.6f + (float)j) * 0.5f + 0.6f, Mathf.Sin(num3) * num);
				tuple.Item2.localPosition = Vector3.Lerp(tuple.Item2.localPosition, val2, Time.deltaTime * 6f);
				tuple.Item2.Rotate(new Vector3(45f, 60f, 30f) * Time.deltaTime, (Space)1);
				float num4 = Mathf.Repeat(_hue + (float)j * 0.07f, 1f);
				Color val3 = Color.HSVToRGB(num4, 1f, 1f);
				Color val4 = Color.Lerp(Color.black, val3, Mathf.Pow(energy, 0.7f));
				Material[] item2 = tuple.Item3;
				foreach (Material val5 in item2)
				{
					if (Object.op_Implicit((Object)(object)val5))
					{
						if (val5.HasProperty("_EmissionColor"))
						{
							val5.EnableKeyword("_EMISSION");
							val5.SetColor("_EmissionColor", val4);
						}
						if (val5.HasProperty("_Color"))
						{
							val5.SetColor("_Color", Color.Lerp(Color.white * 0.6f, val3, energy));
						}
						else if (val5.HasProperty("_BaseColor"))
						{
							val5.SetColor("_BaseColor", Color.Lerp(Color.white * 0.6f, val3, energy));
						}
					}
				}
			}
		}

		private void AnimateAsciiParty(float energy)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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)
			if (!((Object)(object)_billTM == (Object)null) && _partyTriggered)
			{
				_asciiWobble += Time.deltaTime * Mathf.Lerp(2f, 8f, energy);
				_billTM.characterSize = 1f + Mathf.Sin(_asciiWobble * 1.7f) * 0.05f * (0.5f + energy);
				_billTM.lineSpacing = 0.85f + Mathf.Sin(_asciiWobble * 2.1f + 1.3f) * 0.05f * (0.3f + energy * 0.7f);
				float num = Mathf.SmoothStep(0.6f, 1.3f, Mathf.Clamp01(energy * 1.6f));
				Color color = _billTM.color;
				_billTM.color = new Color(color.r * num, color.g * num, color.b * num, color.a);
			}
		}

		private static bool IsYouTube(string url)
		{
			string text = url.ToLowerInvariant();
			return text.Contains("youtube.com/") || text.Contains("youtu.be/");
		}
	}
}