Decompiled source of PaintedUtils v1.1.0

PaintedUtils.dll

Decompiled 3 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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using REPOLib.Objects;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Rendering.PostProcessing;

[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-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("PaintedThornStudios")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Utility Mod for REPO")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+b146dd2fb175251d2e279618d7cbe678063ab8e2")]
[assembly: AssemblyProduct("PaintedUtils")]
[assembly: AssemblyTitle("PaintedUtils")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/yourusername/PaintedUtils.git")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 PaintedThornStudios.PaintedUtils
{
	public class AssetBundleUtil
	{
		public static AssetBundle LoadAssetBundle(BaseUnityPlugin modInstance, string bundleName, ManualLogSource logger)
		{
			string directoryName = Path.GetDirectoryName(modInstance.Info.Location);
			string text = Path.Combine(directoryName, bundleName + ".bundle");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				logger.LogError((object)("Failed to load bundle from " + text));
				return null;
			}
			return val;
		}

		public static void FixAudioMixerGroups(AssetBundle bundle, ManualLogSource logger)
		{
			if ((Object)(object)bundle == (Object)null)
			{
				return;
			}
			string[] allAssetNames = bundle.GetAllAssetNames();
			foreach (string text in allAssetNames)
			{
				GameObject val = bundle.LoadAsset<GameObject>(text);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				AudioSource[] componentsInChildren = val.GetComponentsInChildren<AudioSource>(true);
				AudioSource[] array = componentsInChildren;
				foreach (AudioSource val2 in array)
				{
					if ((Object)(object)val2.outputAudioMixerGroup == (Object)null)
					{
						logger.LogWarning((object)("AudioSource in " + text + " has no mixer group assigned"));
					}
				}
			}
		}
	}
	public class EnemyReflectionUtil
	{
		public static EnemyNavMeshAgent GetEnemyNavMeshAgent(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("NavMeshAgent", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyNavMeshAgent)field.GetValue(enemy);
			}
			Debug.LogError((object)"NavMeshAgent field not found!");
			return null;
		}

		public static EnemyRigidbody GetEnemyRigidbody(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("Rigidbody", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyRigidbody)field.GetValue(enemy);
			}
			Debug.LogError((object)"Rigidbody field not found!");
			return null;
		}

		public static EnemyParent GetEnemyParent(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("EnemyParent", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyParent)field.GetValue(enemy);
			}
			Debug.LogError((object)"EnemyParent field not found!");
			return null;
		}

		public static EnemyVision GetEnemyVision(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("Vision", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyVision)field.GetValue(enemy);
			}
			Debug.LogError((object)"Vision field not found!");
			return null;
		}

		public static EnemyStateInvestigate GetEnemyStateInvestigate(Enemy enemy)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("StateInvestigate", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (EnemyStateInvestigate)field.GetValue(enemy);
			}
			Debug.LogError((object)"StateInvestigate field not found!");
			return null;
		}

		public static bool IsEnemyJumping(Enemy enemy)
		{
			Type type = ((object)enemy).GetType();
			FieldInfo field = type.GetField("Jump", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				Type fieldType = field.FieldType;
				FieldInfo field2 = fieldType.GetField("jumping", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field2 != null)
				{
					return (bool)field2.GetValue(field.GetValue(enemy));
				}
				Debug.LogError((object)"Jumping field not found!");
				return false;
			}
			Debug.LogError((object)"Jump field not found!");
			return false;
		}

		public static bool IsPlayerDisabled(PlayerAvatar playerTarget)
		{
			Type type = ((object)playerTarget).GetType();
			FieldInfo field = type.GetField("isDisabled", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (bool)field.GetValue(playerTarget);
			}
			Debug.LogError((object)"isDisabled field not found!");
			return false;
		}

		public static Vector3 GetAgentVelocity(EnemyNavMeshAgent agent)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Type type = ((object)agent).GetType();
			FieldInfo field = type.GetField("AgentVelocity", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (Vector3)field.GetValue(agent);
			}
			Debug.LogError((object)"AgentVelocity field not found!");
			return Vector3.zero;
		}

		public static Vector3 GetOnInvestigateTriggeredPosition(EnemyStateInvestigate investigate)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Type type = ((object)investigate).GetType();
			FieldInfo field = type.GetField("onInvestigateTriggeredPosition", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (Vector3)field.GetValue(investigate);
			}
			Debug.LogError((object)"onInvestigateTriggeredPosition field not found!");
			return Vector3.zero;
		}

		public static PlayerAvatar GetVisionTriggeredPlayer(EnemyVision vision)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Type type = ((object)vision).GetType();
			FieldInfo field = type.GetField("onVisionTriggeredPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (PlayerAvatar)field.GetValue(vision);
			}
			Debug.LogError((object)"onVisionTriggeredPlayer field not found!");
			return null;
		}

		public static float GetNotMovingTimer(EnemyRigidbody rb)
		{
			Type type = ((object)rb).GetType();
			FieldInfo field = type.GetField("notMovingTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return (float)field.GetValue(rb);
			}
			Debug.LogError((object)"NotMovingTimer field not found!");
			return 0f;
		}

		public static void SetNotMovingTimer(EnemyRigidbody rb, float value)
		{
			Type type = ((object)rb).GetType();
			FieldInfo field = type.GetField("notMovingTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(rb, value);
			}
			else
			{
				Debug.LogError((object)"NotMovingTimer field not found!");
			}
		}
	}
	public class NetworkPrefabUtil
	{
		public static void RegisterNetworkPrefabs(AssetBundle bundle, ManualLogSource logger)
		{
			AssetBundle bundle2 = bundle;
			if ((Object)(object)bundle2 == (Object)null)
			{
				return;
			}
			List<GameObject> list = (from name in bundle2.GetAllAssetNames()
				where name.Contains("/prefabs/") && name.EndsWith(".prefab")
				select bundle2.LoadAsset<GameObject>(name)).ToList();
			foreach (GameObject item in list)
			{
				NetworkPrefabs.RegisterNetworkPrefab(item);
			}
			if (list.Count > 0)
			{
				logger.LogInfo((object)$"Successfully registered {list.Count} network prefabs through REPOLib");
			}
		}
	}
}
namespace PaintedUtils
{
	[BepInPlugin("PaintedThornStudios.PaintedUtils", "PaintedUtils", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class PaintedUtils : BaseUnityPlugin
	{
		private static readonly string BundleName = GetModName();

		private AssetBundle? _assetBundle;

		private bool _hasFixedAudioMixerGroups = false;

		internal static PaintedUtils Instance { get; private set; } = null;


		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private static string GetModName()
		{
			object obj = typeof(PaintedUtils).GetCustomAttributes(typeof(BepInPlugin), inherit: false)[0];
			BepInPlugin val = (BepInPlugin)((obj is BepInPlugin) ? obj : null);
			return ((val != null) ? val.Name : null) ?? "PaintedUtils";
		}

		private void LoadAssetBundle()
		{
			if (!((Object)(object)_assetBundle != (Object)null))
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
				string text = Path.Combine(directoryName, BundleName + ".bundle");
				_assetBundle = AssetBundle.LoadFromFile(text);
				if ((Object)(object)_assetBundle == (Object)null)
				{
					Logger.LogError((object)("Failed to load bundle from " + text));
				}
			}
		}

		private void FixAllPrefabAudioMixerGroups()
		{
			if ((Object)(object)_assetBundle == (Object)null)
			{
				return;
			}
			List<GameObject> list = (from name in _assetBundle.GetAllAssetNames()
				where name.EndsWith(".prefab")
				select _assetBundle.LoadAsset<GameObject>(name)).ToList();
			foreach (GameObject item in list)
			{
				Utilities.FixAudioMixerGroups(item);
			}
		}

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			LoadAssetBundle();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
			Logger.LogInfo((object)"White Roses have been painted Red! @CarsonJF");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
			if (!_hasFixedAudioMixerGroups)
			{
				FixAllPrefabAudioMixerGroups();
				_hasFixedAudioMixerGroups = true;
			}
		}
	}
	public class ColorChanger : MonoBehaviour
	{
		[Serializable]
		public class ColorPreset
		{
			public string presetName;

			public Color color = Color.white;

			public float emissionIntensity = 0f;

			public bool affectChildren = true;
		}

		[SerializeField]
		private List<ColorPreset> colorPresets = new List<ColorPreset>();

		[SerializeField]
		private string currentPresetName;

		[SerializeField]
		private bool applyOnAwake = false;

		private Dictionary<string, ColorPreset> presetLookup = new Dictionary<string, ColorPreset>();

		private List<Renderer> affectedRenderers = new List<Renderer>();

		private List<Material> originalMaterials = new List<Material>();

		public List<ColorPreset> ColorPresets => colorPresets;

		public string CurrentPresetName => currentPresetName;

		private void Awake()
		{
			presetLookup.Clear();
			foreach (ColorPreset colorPreset in colorPresets)
			{
				if (!string.IsNullOrEmpty(colorPreset.presetName) && !presetLookup.ContainsKey(colorPreset.presetName))
				{
					presetLookup.Add(colorPreset.presetName, colorPreset);
				}
			}
			CacheRenderers();
			if (applyOnAwake && !string.IsNullOrEmpty(currentPresetName))
			{
				ApplyColorPreset(currentPresetName);
			}
		}

		private void CacheRenderers()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			affectedRenderers.Clear();
			originalMaterials.Clear();
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				affectedRenderers.Add(val);
				Material[] materials = val.materials;
				Material[] array2 = materials;
				foreach (Material val2 in array2)
				{
					originalMaterials.Add(new Material(val2));
				}
			}
		}

		public void ApplyColorPreset(string presetName)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(presetName) || !presetLookup.ContainsKey(presetName))
			{
				Debug.LogWarning((object)("Color preset '" + presetName + "' not found on " + ((Object)((Component)this).gameObject).name));
				return;
			}
			currentPresetName = presetName;
			ColorPreset colorPreset = presetLookup[presetName];
			int num = 0;
			foreach (Renderer affectedRenderer in affectedRenderers)
			{
				if (!colorPreset.affectChildren && (Object)(object)((Component)affectedRenderer).transform != (Object)(object)((Component)this).transform)
				{
					num++;
					continue;
				}
				Material[] materials = affectedRenderer.materials;
				for (int i = 0; i < materials.Length; i++)
				{
					materials[i].color = colorPreset.color;
					if (materials[i].HasProperty("_EmissionColor") && colorPreset.emissionIntensity > 0f)
					{
						materials[i].EnableKeyword("_EMISSION");
						materials[i].SetColor("_EmissionColor", colorPreset.color * colorPreset.emissionIntensity);
					}
					else if (materials[i].HasProperty("_EmissionColor"))
					{
						materials[i].DisableKeyword("_EMISSION");
					}
				}
				affectedRenderer.materials = materials;
				num++;
			}
			Debug.Log((object)("Applied color preset '" + presetName + "' to " + ((Object)((Component)this).gameObject).name));
		}

		public void ResetToOriginalMaterials()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			int num = 0;
			int num2 = 0;
			foreach (Renderer affectedRenderer in affectedRenderers)
			{
				Material[] materials = affectedRenderer.materials;
				for (int i = 0; i < materials.Length; i++)
				{
					if (num2 < originalMaterials.Count)
					{
						materials[i] = new Material(originalMaterials[num2]);
						num2++;
					}
				}
				affectedRenderer.materials = materials;
				num++;
			}
			Debug.Log((object)("Reset materials on " + ((Object)((Component)this).gameObject).name + " to original state"));
		}

		public void AddColorPreset(string name, Color color, float emissionIntensity = 0f, bool affectChildren = true)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			string name2 = name;
			if (string.IsNullOrEmpty(name2))
			{
				Debug.LogError((object)"Cannot add color preset: name is empty");
				return;
			}
			colorPresets.RemoveAll((ColorPreset p) => p.presetName == name2);
			ColorPreset colorPreset = new ColorPreset
			{
				presetName = name2,
				color = color,
				emissionIntensity = emissionIntensity,
				affectChildren = affectChildren
			};
			colorPresets.Add(colorPreset);
			if (presetLookup.ContainsKey(name2))
			{
				presetLookup[name2] = colorPreset;
			}
			else
			{
				presetLookup.Add(name2, colorPreset);
			}
			Debug.Log((object)("Added color preset '" + name2 + "' to " + ((Object)((Component)this).gameObject).name));
		}

		public static void ColorObject(GameObject targetObject, Color color, float emissionIntensity = 0f)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = targetObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material[] materials = val.materials;
				for (int j = 0; j < materials.Length; j++)
				{
					materials[j].color = color;
					if (materials[j].HasProperty("_EmissionColor") && emissionIntensity > 0f)
					{
						materials[j].EnableKeyword("_EMISSION");
						materials[j].SetColor("_EmissionColor", color * emissionIntensity);
					}
					else if (materials[j].HasProperty("_EmissionColor"))
					{
						materials[j].DisableKeyword("_EMISSION");
					}
				}
				val.materials = materials;
			}
			Debug.Log((object)("Applied color to " + ((Object)targetObject).name));
		}

		public static ColorChanger SetupOnObject(GameObject targetObject)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			ColorChanger colorChanger = targetObject.GetComponent<ColorChanger>();
			if ((Object)(object)colorChanger == (Object)null)
			{
				colorChanger = targetObject.AddComponent<ColorChanger>();
				Debug.Log((object)("Added ColorChanger component to " + ((Object)targetObject).name));
			}
			if (colorChanger.colorPresets.Count == 0)
			{
				colorChanger.AddColorPreset("Default", Color.white);
				colorChanger.AddColorPreset("Red", Color.red, 1.5f);
				colorChanger.AddColorPreset("Green", Color.green, 1.5f);
				colorChanger.AddColorPreset("Blue", Color.blue, 1.5f);
				colorChanger.AddColorPreset("Yellow", Color.yellow, 1.5f);
				colorChanger.AddColorPreset("Purple", new Color(0.5f, 0f, 0.5f), 1.5f);
				colorChanger.AddColorPreset("Glowing", Color.white, 2f);
			}
			return colorChanger;
		}
	}
	public class DebugLogger : MonoBehaviour
	{
		public void PrintToLog(string message)
		{
			Debug.Log((object)("[" + ((Object)((Component)this).gameObject).name + "] " + message));
		}
	}
	[CreateAssetMenu(menuName = "PaintedUtils/Drop Table")]
	public class DropTable : ScriptableObject
	{
		public List<ItemDropper.ItemDrop> drops = new List<ItemDropper.ItemDrop>();

		public List<DropTable> nestedTables;

		[Range(0f, 100f)]
		public int nestedTableChance = 50;
	}
	public class SickEffect : PaintedPostProcessingEffect
	{
		private float rotationSpeed = 0.5f;

		private float rotationAmount = 2f;

		private float currentRotation = 0f;

		private bool rotatingRight = true;

		private float originalCameraNoise;

		private float originalCameraShake;

		public SickEffect(float duration = 10f, float intensity = 1f)
		{
			base.duration = duration;
			base.intensity = intensity;
			isActive = false;
		}

		public override void ApplyEffect(PlayerAvatar player)
		{
			if (player.isLocal)
			{
				isActive = true;
				Debug.Log((object)("Applying Sick Effect to " + ((Object)player).name));
				originalCameraNoise = GameplayManager.instance.cameraNoise;
				originalCameraShake = GameplayManager.instance.cameraShake;
				GameplayManager.instance.OverrideCameraNoise(0.5f * intensity, duration);
				GameplayManager.instance.OverrideCameraShake(0.3f * intensity, duration);
				if ((Object)(object)PostProcessing.Instance != (Object)null)
				{
					((ParameterOverride<float>)(object)PostProcessing.Instance.colorGrading.tint).value = 20f * intensity;
					((ParameterOverride)PostProcessing.Instance.colorGrading.tint).overrideState = true;
					((ParameterOverride<float>)(object)PostProcessing.Instance.chromaticAberration.intensity).value = 0.5f * intensity;
					((ParameterOverride)PostProcessing.Instance.chromaticAberration.intensity).overrideState = true;
				}
			}
		}

		public override void RemoveEffect(PlayerAvatar player)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			if (player.isLocal)
			{
				isActive = false;
				GameplayManager.instance.OverrideCameraNoise(originalCameraNoise, 0.5f);
				GameplayManager.instance.OverrideCameraShake(originalCameraShake, 0.5f);
				if ((Object)(object)PostProcessing.Instance != (Object)null)
				{
					((ParameterOverride)PostProcessing.Instance.colorGrading.tint).overrideState = false;
					((ParameterOverride)PostProcessing.Instance.chromaticAberration.intensity).overrideState = false;
				}
				if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.MainCamera != (Object)null)
				{
					((Component)GameDirector.instance.MainCamera).transform.localRotation = Quaternion.identity;
				}
			}
		}

		public override void UpdateEffect(PlayerAvatar player)
		{
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			if (!isActive || !player.isLocal || !((Object)(object)GameDirector.instance != (Object)null) || !((Object)(object)GameDirector.instance.MainCamera != (Object)null))
			{
				return;
			}
			if (rotatingRight)
			{
				currentRotation += rotationSpeed * Time.deltaTime;
				if (currentRotation >= rotationAmount)
				{
					rotatingRight = false;
				}
			}
			else
			{
				currentRotation -= rotationSpeed * Time.deltaTime;
				if (currentRotation <= 0f - rotationAmount)
				{
					rotatingRight = true;
				}
			}
			((Component)GameDirector.instance.MainCamera).transform.localRotation = Quaternion.Euler(0f, 0f, currentRotation * intensity);
		}
	}
	public abstract class BaseEnemyConfig
	{
		public ConfigEntry<float> Health { get; protected set; }

		public ConfigEntry<float> SpeedMultiplier { get; protected set; }

		public ConfigEntry<int> PlayerDamage { get; protected set; }

		public ConfigEntry<float> PlayerDamageCooldown { get; protected set; }

		public ConfigEntry<float> PlayerTumbleForce { get; protected set; }

		public ConfigEntry<float> PhysHitForce { get; protected set; }

		public ConfigEntry<float> PhysHitTorque { get; protected set; }

		public ConfigEntry<bool> PhysDestroy { get; protected set; }

		protected abstract void InitializeConfig(ConfigFile config);
	}
	public class EnemyConfigController : MonoBehaviour
	{
		protected ItemDropper itemDropper;

		protected EnemyHealth enemyHealth;

		protected NavMeshAgent navMeshAgent;

		protected List<HurtCollider> hurtColliders = new List<HurtCollider>();

		protected EnemyRigidbody enemyRigidbody;

		protected BaseEnemyConfig config;

		protected virtual void Awake()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			itemDropper = ((Component)this).GetComponentInChildren<ItemDropper>(true);
			enemyHealth = ((Component)this).GetComponentInChildren<EnemyHealth>(true);
			enemyRigidbody = ((Component)this).GetComponentInChildren<EnemyRigidbody>(true);
			navMeshAgent = ((Component)this).GetComponentInChildren<NavMeshAgent>(true);
			hurtColliders.AddRange(((Component)this).GetComponentsInChildren<HurtCollider>(true));
			ValidateComponents();
			if ((Object)(object)enemyHealth != (Object)null)
			{
				enemyHealth.onDeath.AddListener(new UnityAction(HandleDeath));
			}
			ApplyConfigurations();
		}

		protected virtual void ValidateComponents()
		{
			if ((Object)(object)itemDropper == (Object)null)
			{
				Debug.LogError((object)("ItemDropper component not found on " + ((Object)((Component)this).gameObject).name + " or its children!"));
			}
			else if ((Object)(object)enemyHealth == (Object)null)
			{
				Debug.LogError((object)("EnemyHealth component not found on " + ((Object)((Component)this).gameObject).name + " or its children!"));
			}
			else if (hurtColliders.Count == 0)
			{
				Debug.LogError((object)("No HurtCollider components found on " + ((Object)((Component)this).gameObject).name + " or its children!"));
			}
			else if ((Object)(object)enemyRigidbody == (Object)null)
			{
				Debug.LogError((object)("EnemyRigidbody component not found on " + ((Object)((Component)this).gameObject).name + " or its children!"));
			}
		}

		protected virtual void OnDestroy()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			if ((Object)(object)enemyHealth != (Object)null)
			{
				enemyHealth.onDeath.RemoveListener(new UnityAction(HandleDeath));
			}
		}

		protected virtual void HandleDeath()
		{
		}

		protected virtual void ApplyConfigurations()
		{
			if (config == null)
			{
				return;
			}
			foreach (HurtCollider hurtCollider in hurtColliders)
			{
				hurtCollider.playerDamage = config.PlayerDamage.Value;
				hurtCollider.playerDamageCooldown = config.PlayerDamageCooldown.Value;
				hurtCollider.playerTumbleForce = config.PlayerTumbleForce.Value;
				hurtCollider.physHitForce = config.PhysHitForce.Value;
				hurtCollider.physHitTorque = config.PhysHitTorque.Value;
				hurtCollider.physDestroy = config.PhysDestroy.Value;
			}
			enemyHealth.health = (int)config.Health.Value;
			enemyRigidbody.positionSpeedIdle *= config.SpeedMultiplier.Value;
			enemyRigidbody.positionSpeedChase *= config.SpeedMultiplier.Value;
			navMeshAgent.speed *= config.SpeedMultiplier.Value;
		}

		public virtual void RefreshConfigurations()
		{
			ApplyConfigurations();
		}
	}
	public class EyeStateManager : MonoBehaviour
	{
		public class EyeStateData
		{
			public float Timer;

			public bool IsSpeaking;

			public bool IsInitialized;

			public Color EyeColor;

			public Color PupilColor;

			public float LightIntensity;

			public bool EyeColorRGB = false;

			public bool PupilColorRGB = false;

			public float RGBCycleSpeed = 0.5f;

			public float PupilSize = 3f;

			private float eyeHue = 0f;

			private float pupilHue = 0f;

			public void UpdateRGBColors()
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: 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)
				if (EyeColorRGB)
				{
					eyeHue = (eyeHue + Time.deltaTime * RGBCycleSpeed) % 1f;
					EyeColor = Color.HSVToRGB(eyeHue, 1f, 1f);
				}
				if (PupilColorRGB)
				{
					pupilHue = (pupilHue + Time.deltaTime * RGBCycleSpeed) % 1f;
					PupilColor = Color.HSVToRGB(pupilHue, 1f, 1f);
				}
			}
		}

		[CompilerGenerated]
		private sealed class <InitializeSpeakingState>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string playerName;

			public EyeStateManager <>4__this;

			private EyeStateData <data>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (<>4__this.activeStates.TryGetValue(playerName, out <data>5__1))
					{
						<data>5__1.IsInitialized = true;
					}
					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 static EyeStateManager? instance;

		private Dictionary<string, EyeStateData> activeStates = new Dictionary<string, EyeStateData>();

		public static EyeStateManager Instance
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)instance == (Object)null)
				{
					GameObject val = new GameObject("EyeStateManager");
					instance = val.AddComponent<EyeStateManager>();
					Object.DontDestroyOnLoad((Object)(object)val);
				}
				return instance;
			}
		}

		private void Update()
		{
			foreach (KeyValuePair<string, EyeStateData> item in activeStates.ToList())
			{
				string key = item.Key;
				EyeStateData value = item.Value;
				if (value.Timer > 0f)
				{
					value.Timer -= Time.deltaTime;
					if (value.Timer <= 0f)
					{
						ResetEyes(key);
						activeStates.Remove(key);
						continue;
					}
				}
				if (value.IsInitialized && (value.EyeColorRGB || value.PupilColorRGB))
				{
					value.UpdateRGBColors();
					ApplyEyeState(key, value);
				}
			}
		}

		public void SetEyeState(string playerName, Color eyeColor, Color pupilColor, float lightIntensity, float duration = 0f, bool eyeColorRGB = false, bool pupilColorRGB = false, float pupilSize = 3f)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			EyeStateData eyeStateData = new EyeStateData
			{
				Timer = duration,
				IsSpeaking = true,
				IsInitialized = false,
				EyeColor = eyeColor,
				PupilColor = pupilColor,
				LightIntensity = lightIntensity,
				EyeColorRGB = eyeColorRGB,
				PupilColorRGB = pupilColorRGB,
				PupilSize = pupilSize
			};
			activeStates[playerName] = eyeStateData;
			ApplyEyeState(playerName, eyeStateData);
			((MonoBehaviour)this).StartCoroutine(InitializeSpeakingState(playerName));
		}

		public void ClearEyeState(string playerName)
		{
			if (activeStates.TryGetValue(playerName, out EyeStateData _))
			{
				ResetEyes(playerName);
				activeStates.Remove(playerName);
			}
		}

		private void ApplyEyeState(string playerName, EyeStateData data)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = SemiFunc.PlayerGetFromName(playerName);
			if (!((Object)(object)val?.playerHealth == (Object)null))
			{
				val.playerHealth.overrideEyeMaterialColor = data.EyeColor;
				val.playerHealth.overridePupilMaterialColor = data.PupilColor;
				val.playerHealth.overrideEyeLightColor = data.EyeColor;
				val.playerHealth.overrideEyeLightIntensity = data.LightIntensity;
				val.playerHealth.EyeMaterialOverride((EyeOverrideState)100, 0.25f, 40);
				PlayerAvatar playerAvatar = ChatManager.instance.playerAvatar;
				if (playerAvatar != null)
				{
					playerAvatar.OverridePupilSize(data.PupilSize, 4, 15f, 0.3f, 15f, 0.3f, 0.1f);
				}
			}
		}

		private void ResetEyes(string playerName)
		{
			PlayerAvatar val = SemiFunc.PlayerGetFromName(playerName);
			if (!((Object)(object)val?.playerHealth == (Object)null))
			{
				val.playerHealth.EyeMaterialOverride((EyeOverrideState)0, 0.25f, 0);
			}
		}

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

		public EyeStateData? GetActiveStateFor(string playerName)
		{
			if (activeStates.TryGetValue(playerName, out EyeStateData value))
			{
				return value;
			}
			return null;
		}
	}
	[HarmonyPatch(typeof(PlayerHealth), "Update")]
	public class ForceCustomEyeStatePatch
	{
		private static void Prefix(PlayerHealth __instance)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.photonView == (Object)null || !__instance.photonView.IsMine)
			{
				return;
			}
			string text = __instance.playerAvatar?.playerName;
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			try
			{
				EyeStateManager.EyeStateData activeStateFor = EyeStateManager.Instance.GetActiveStateFor(text);
				if (activeStateFor != null)
				{
					__instance.overrideEyeMaterialColor = activeStateFor.EyeColor;
					__instance.overridePupilMaterialColor = activeStateFor.PupilColor;
					__instance.overrideEyeLightColor = activeStateFor.EyeColor;
					__instance.overrideEyeLightIntensity = activeStateFor.LightIntensity;
					if (__instance.overrideEyePriority < 50)
					{
						__instance.EyeMaterialOverride((EyeOverrideState)100, 0.25f, 50);
					}
					PlayerAvatar playerAvatar = __instance.playerAvatar;
					if (playerAvatar != null)
					{
						playerAvatar.OverridePupilSize(activeStateFor.PupilSize, 4, 1f, 1f, 15f, 0.3f, 0.1f);
					}
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[EyeStateManager] Failed to apply eye state for {text}: {arg}");
			}
		}
	}
	public class ItemDropper : MonoBehaviour
	{
		public enum PrefabType
		{
			NetworkPrefab,
			Valuable,
			Item
		}

		public enum DropChanceType
		{
			Weight,
			Percentage
		}

		[Serializable]
		public class ItemDrop
		{
			public GameObject itemPrefab;

			public int minQuantity = 1;

			public int maxQuantity = 1;

			public DropChanceType dropChanceType = DropChanceType.Weight;

			[Tooltip("Used when Drop Chance Type is set to Weight")]
			public int weight = 100;

			[Range(0f, 100f)]
			[Tooltip("Percentage chance this item will drop. Used when Drop Chance Type is set to Percentage")]
			public float chance = 100f;

			public bool guaranteed = false;

			public PrefabType prefabType;

			public Rarity rarity;
		}

		[SerializeField]
		private DropTable dropTable;

		[SerializeField]
		private Transform dropTarget;

		[SerializeField]
		private float dropSpreadRadius = 0.5f;

		[SerializeField]
		private bool applyForce = true;

		[SerializeField]
		private float forceStrength = 3f;

		[SerializeField]
		private int minItemTypes = 1;

		[SerializeField]
		private int maxItemTypes = 3;

		public DropTable DropTable => dropTable;

		public float DropSpreadRadius => dropSpreadRadius;

		public float ForceStrength => forceStrength;

		public void InitializeDropTable(string dropTableResourcePath)
		{
			if ((Object)(object)dropTable == (Object)null)
			{
				dropTable = Resources.Load<DropTable>(dropTableResourcePath);
				if (!((Object)(object)dropTable != (Object)null))
				{
				}
			}
		}

		public void InitializeDropTableFromName()
		{
			if ((Object)(object)dropTable != (Object)null)
			{
				return;
			}
			string text = ((Object)((Component)this).gameObject).name;
			string[] array = new string[3] { "Controller", "Prefab", "(Clone)" };
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				if (text.EndsWith(text2))
				{
					text = text.Substring(0, text.Length - text2.Length).Trim();
				}
			}
			string[] array3 = new string[3]
			{
				"DropTables/" + text + "DropTable",
				"DropTables/" + text,
				"DropTables/DefaultDropTable"
			};
			string[] array4 = array3;
			foreach (string dropTableResourcePath in array4)
			{
				InitializeDropTable(dropTableResourcePath);
				if ((Object)(object)dropTable != (Object)null)
				{
					return;
				}
			}
			Debug.LogWarning((object)("Could not auto-load drop table for " + ((Object)((Component)this).gameObject).name + ". Tried paths: " + string.Join(", ", array3)));
		}

		public static ItemDropper SetupDropperOnObject(GameObject targetObject, string dropTablePath, float spreadRadius = 0.5f, float force = 3f)
		{
			ItemDropper itemDropper = targetObject.GetComponent<ItemDropper>();
			if ((Object)(object)itemDropper == (Object)null)
			{
				itemDropper = targetObject.AddComponent<ItemDropper>();
			}
			itemDropper.InitializeDropTable(dropTablePath);
			if ((Object)(object)itemDropper.DropTable != (Object)null)
			{
				typeof(ItemDropper).GetField("dropSpreadRadius", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(itemDropper, spreadRadius);
				typeof(ItemDropper).GetField("forceStrength", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(itemDropper, force);
			}
			return itemDropper;
		}

		public static void DropItemsAtPosition(DropTable dropTable, Vector3 position, float dropRadius = 0.5f, float force = 3f)
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)dropTable == (Object)null)
			{
				Debug.LogWarning((object)"Cannot drop items: No drop table provided to static method");
				dropTable = Resources.Load<DropTable>("DropTables/DefaultDropTable");
				if ((Object)(object)dropTable == (Object)null)
				{
					Debug.LogError((object)"Failed to load fallback drop table. No items will be dropped.");
					return;
				}
			}
			foreach (ItemDrop drop in dropTable.drops)
			{
				bool flag = false;
				if (drop.guaranteed)
				{
					flag = true;
				}
				else if (drop.dropChanceType == DropChanceType.Percentage)
				{
					flag = Random.Range(0f, 100f) < drop.chance;
				}
				if (flag)
				{
					int num = Random.Range(drop.minQuantity, drop.maxQuantity + 1);
					for (int i = 0; i < num; i++)
					{
						Vector3 position2 = position + Random.insideUnitSphere * dropRadius;
						SpawnPrefabStatic(drop, position2, force);
					}
				}
			}
			List<ItemDrop> list = dropTable.drops.FindAll((ItemDrop d) => !d.guaranteed && d.dropChanceType == DropChanceType.Weight && d.weight > 0);
			if (list.Count > 0)
			{
				int num2 = Mathf.Clamp(Random.Range(1, 4), 1, list.Count);
				for (int j = 0; j < num2; j++)
				{
					if (list.Count == 0)
					{
						break;
					}
					int num3 = 0;
					foreach (ItemDrop item in list)
					{
						num3 += item.weight;
					}
					int num4 = Random.Range(0, num3);
					int num5 = 0;
					int index = 0;
					for (int k = 0; k < list.Count; k++)
					{
						num5 += list[k].weight;
						if (num4 < num5)
						{
							index = k;
							break;
						}
					}
					ItemDrop itemDrop = list[index];
					list.RemoveAt(index);
					int num6 = Random.Range(itemDrop.minQuantity, itemDrop.maxQuantity + 1);
					for (int l = 0; l < num6; l++)
					{
						Vector3 position3 = position + Random.insideUnitSphere * dropRadius;
						SpawnPrefabStatic(itemDrop, position3, force);
					}
				}
			}
			if (dropTable.nestedTables != null && dropTable.nestedTables.Count > 0 && Random.Range(0, 100) < dropTable.nestedTableChance)
			{
				int index2 = Random.Range(0, dropTable.nestedTables.Count);
				DropTable dropTable2 = dropTable.nestedTables[index2];
				if ((Object)(object)dropTable2 != (Object)null)
				{
					DropItemsAtPosition(dropTable2, position, dropRadius, force);
				}
			}
		}

		public static void DropItemsAtPosition(string dropTableResourcePath, Vector3 position, float dropRadius = 0.5f, float force = 3f)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			DropTable dropTable = Resources.Load<DropTable>(dropTableResourcePath);
			DropItemsAtPosition(dropTable, position, dropRadius, force);
		}

		public static void DropItemsForGameObject(GameObject sourceObject, string dropTableResourcePath = null)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)sourceObject == (Object)null)
			{
				Debug.LogError((object)"Cannot drop items: Source GameObject is null");
				return;
			}
			ItemDropper component = sourceObject.GetComponent<ItemDropper>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.DropTable != (Object)null)
			{
				DropItemsAtPosition(component.DropTable, sourceObject.transform.position, component.DropSpreadRadius, component.ForceStrength);
			}
			else if (!string.IsNullOrEmpty(dropTableResourcePath))
			{
				DropItemsAtPosition(dropTableResourcePath, sourceObject.transform.position);
			}
			else
			{
				DropItemsAtPosition((DropTable)null, sourceObject.transform.position, 0.5f, 3f);
			}
		}

		private static void SpawnPrefabStatic(ItemDrop drop, Vector3 position, float forceStrength)
		{
			//IL_0042: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_0163: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			GameObject val = null;
			switch (drop.prefabType)
			{
			case PrefabType.NetworkPrefab:
				val = NetworkPrefabs.SpawnNetworkPrefab(((Object)drop.itemPrefab).name, position, Quaternion.identity, (byte)0, (object[])null);
				break;
			case PrefabType.Valuable:
				val = Valuables.SpawnValuable(Valuables.GetValuableByName(((Object)drop.itemPrefab).name), position, Quaternion.identity);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not spawn Valuable: " + ((Object)drop.itemPrefab).name));
				}
				break;
			case PrefabType.Item:
			{
				string text = ((Object)drop.itemPrefab).name;
				if (!text.StartsWith("Item "))
				{
					text = "Item " + text;
				}
				val = NetworkPrefabs.SpawnNetworkPrefab(text, position, Quaternion.identity, (byte)0, (object[])null);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not spawn Item: " + text));
				}
				break;
			}
			}
			if ((Object)(object)val != (Object)null && forceStrength > 0f)
			{
				Rigidbody component = val.GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddForce(Random.onUnitSphere * forceStrength, (ForceMode)1);
				}
			}
			if ((Object)(object)drop.rarity != (Object)null && (Object)(object)val != (Object)null)
			{
				RarityEffectHandle effectHandle = RarityEffectManager.TryPlayEffects(drop.rarity, position, val.transform);
				RarityEffectTracker rarityEffectTracker = val.AddComponent<RarityEffectTracker>();
				rarityEffectTracker.effectHandle = effectHandle;
			}
		}

		public void DropItems()
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00eb: 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)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)this.dropTable == (Object)null)
			{
				InitializeDropTableFromName();
				if ((Object)(object)this.dropTable == (Object)null)
				{
					Debug.LogWarning((object)("No drop table found for " + ((Object)((Component)this).gameObject).name));
					return;
				}
			}
			foreach (ItemDrop drop in this.dropTable.drops)
			{
				bool flag = false;
				if (drop.guaranteed)
				{
					flag = true;
				}
				else if (drop.dropChanceType == DropChanceType.Percentage)
				{
					flag = Random.Range(0f, 100f) < drop.chance;
				}
				if (flag)
				{
					int num = Random.Range(drop.minQuantity, drop.maxQuantity + 1);
					for (int i = 0; i < num; i++)
					{
						Vector3 spreadPosition = GetSpreadPosition(((Component)this).transform.position);
						SpawnPrefab(drop, spreadPosition);
					}
				}
			}
			List<ItemDrop> list = this.dropTable.drops.FindAll((ItemDrop d) => !d.guaranteed && d.dropChanceType == DropChanceType.Weight && d.weight > 0);
			if (list.Count > 0)
			{
				int num2 = Mathf.Clamp(Random.Range(minItemTypes, maxItemTypes + 1), 1, list.Count);
				for (int j = 0; j < num2; j++)
				{
					if (list.Count == 0)
					{
						break;
					}
					int index = PickWeightedIndex(list);
					ItemDrop itemDrop = list[index];
					list.RemoveAt(index);
					int num3 = Random.Range(itemDrop.minQuantity, itemDrop.maxQuantity + 1);
					for (int k = 0; k < num3; k++)
					{
						Vector3 spreadPosition2 = GetSpreadPosition(((Component)this).transform.position);
						SpawnPrefab(itemDrop, spreadPosition2);
					}
				}
			}
			if (this.dropTable.nestedTables != null && this.dropTable.nestedTables.Count > 0 && Random.Range(0, 100) < this.dropTable.nestedTableChance)
			{
				int index2 = Random.Range(0, this.dropTable.nestedTables.Count);
				DropTable dropTable = this.dropTable.nestedTables[index2];
				if ((Object)(object)dropTable != (Object)null)
				{
					DropTable dropTable2 = this.dropTable;
					this.dropTable = dropTable;
					DropItems();
					this.dropTable = dropTable2;
				}
			}
		}

		private Vector3 GetSpreadPosition(Vector3 center)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			return center + Random.insideUnitSphere * dropSpreadRadius;
		}

		private void SpawnPrefab(ItemDrop drop, Vector3 position)
		{
			//IL_0042: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			GameObject val = null;
			switch (drop.prefabType)
			{
			case PrefabType.NetworkPrefab:
				val = NetworkPrefabs.SpawnNetworkPrefab(((Object)drop.itemPrefab).name, position, Quaternion.identity, (byte)0, (object[])null);
				break;
			case PrefabType.Valuable:
				val = Valuables.SpawnValuable(Valuables.GetValuableByName(((Object)drop.itemPrefab).name), position, Quaternion.identity);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not spawn Valuable: " + ((Object)drop.itemPrefab).name));
				}
				break;
			case PrefabType.Item:
			{
				string text = ((Object)drop.itemPrefab).name;
				if (!text.StartsWith("Item "))
				{
					text = "Item " + text;
				}
				val = NetworkPrefabs.SpawnNetworkPrefab(text, position, Quaternion.identity, (byte)0, (object[])null);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not spawn Item: " + text));
				}
				break;
			}
			}
			if ((Object)(object)val != (Object)null && applyForce)
			{
				Rigidbody component = val.GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddForce(Random.onUnitSphere * forceStrength, (ForceMode)1);
				}
			}
			if ((Object)(object)drop.rarity != (Object)null && (Object)(object)val != (Object)null)
			{
				RarityEffectHandle effectHandle = RarityEffectManager.TryPlayEffects(drop.rarity, position, val.transform);
				RarityEffectTracker rarityEffectTracker = val.AddComponent<RarityEffectTracker>();
				rarityEffectTracker.effectHandle = effectHandle;
			}
		}

		private int PickWeightedIndex(List<ItemDrop> drops)
		{
			int num = 0;
			foreach (ItemDrop drop in drops)
			{
				num += drop.weight;
			}
			int num2 = Random.Range(0, num);
			int num3 = 0;
			for (int i = 0; i < drops.Count; i++)
			{
				num3 += drops[i].weight;
				if (num2 < num3)
				{
					return i;
				}
			}
			return 0;
		}
	}
	public interface IPhysGrabber
	{
		IItemAttributes currentlyLookingAtItemAttributes { get; }
	}
	public interface IItemAttributes
	{
		GameObject gameObject { get; }

		string GetDisplayName();
	}
	public static class GameInterfaces
	{
		public static IPhysGrabber PhysGrabber { get; set; }

		public static void UIItemInfoText(IItemAttributes itemAttributes, string promptText)
		{
		}
	}
	[RequireComponent(typeof(Collider))]
	public class ItemLibrary : MonoBehaviour, IItemAttributes
	{
		[Header("Prompt Settings")]
		public bool enablePrompt = true;

		[Tooltip("Displayed when the player looks at the item.")]
		public string promptText = "Press E to Interact";

		[Tooltip("Display name for the item")]
		public string displayName;

		[Header("Battery Settings")]
		public bool useBattery = false;

		public ItemBattery battery;

		[Header("Interaction Settings")]
		public bool allowInteraction = true;

		public KeyCode interactionKey = (KeyCode)101;

		[Header("Unity Events")]
		public UnityEvent onInteract;

		public UnityEvent onLookAt;

		public UnityEvent onBatteryEmpty;

		private bool isLookedAt = false;

		public string GetDisplayName()
		{
			return (!string.IsNullOrEmpty(displayName)) ? displayName : ((Object)((Component)this).gameObject).name;
		}

		private void Start()
		{
			if (useBattery && (Object)(object)battery == (Object)null)
			{
				battery = ((Component)this).GetComponent<ItemBattery>();
				if (!((Object)(object)battery == (Object)null))
				{
				}
			}
		}

		private void Update()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			HandleLookAt();
			if (isLookedAt && allowInteraction && Input.GetKeyDown(interactionKey))
			{
				TryUse();
			}
			if (useBattery && (Object)(object)battery != (Object)null && battery.batteryLife <= 0f)
			{
				onBatteryEmpty.Invoke();
			}
		}

		private void HandleLookAt()
		{
			if (!enablePrompt || GameInterfaces.PhysGrabber == null)
			{
				return;
			}
			if (GameInterfaces.PhysGrabber.currentlyLookingAtItemAttributes != null && (Object)(object)GameInterfaces.PhysGrabber.currentlyLookingAtItemAttributes.gameObject == (Object)(object)((Component)this).gameObject)
			{
				if (!isLookedAt)
				{
					isLookedAt = true;
					onLookAt.Invoke();
				}
				GameInterfaces.UIItemInfoText(this, promptText);
			}
			else
			{
				isLookedAt = false;
			}
		}

		private void TryUse()
		{
			if (allowInteraction && (!useBattery || !((Object)(object)battery != (Object)null) || !(battery.batteryLife <= 0f)))
			{
				onInteract.Invoke();
			}
		}

		GameObject IItemAttributes.get_gameObject()
		{
			return ((Component)this).gameObject;
		}
	}
	public class ItemBattery : MonoBehaviour
	{
		[Header("Battery Settings")]
		public float batteryLife = 100f;

		public float maxBatteryLife = 100f;

		public float drainRate = 1f;

		public bool isDraining = false;

		[Header("Events")]
		public UnityEvent onBatteryEmpty;

		public UnityEvent onBatteryDrained;

		public UnityEvent onBatteryRecharged;

		private bool wasEmpty = false;

		private void Update()
		{
			if (isDraining)
			{
				DrainBattery(drainRate * Time.deltaTime);
			}
			if (batteryLife <= 0f && !wasEmpty)
			{
				wasEmpty = true;
				UnityEvent obj = onBatteryEmpty;
				if (obj != null)
				{
					obj.Invoke();
				}
			}
			else if (batteryLife > 0f && wasEmpty)
			{
				wasEmpty = false;
			}
		}

		public void DrainBattery(float amount)
		{
			if (!(batteryLife <= 0f))
			{
				batteryLife = Mathf.Max(0f, batteryLife - amount);
				UnityEvent obj = onBatteryDrained;
				if (obj != null)
				{
					obj.Invoke();
				}
			}
		}

		public void RechargeBattery(float amount)
		{
			batteryLife = Mathf.Min(maxBatteryLife, batteryLife + amount);
			UnityEvent obj = onBatteryRecharged;
			if (obj != null)
			{
				obj.Invoke();
			}
		}

		public void SetBatteryFull()
		{
			batteryLife = maxBatteryLife;
			UnityEvent obj = onBatteryRecharged;
			if (obj != null)
			{
				obj.Invoke();
			}
		}

		public float GetBatteryPercentage()
		{
			return batteryLife / maxBatteryLife;
		}
	}
	public class MusicalItemHandler : MonoBehaviourPunCallbacks
	{
		public enum PowerOffBehavior
		{
			None,
			OnDrop,
			OnSlamWhenNotHeld,
			OnSlamWhenHeld,
			OnSlam
		}

		public enum SkipBehavior
		{
			None,
			SkipWhenNotHeld,
			SkipWhenHeld,
			SkipAlways
		}

		[CompilerGenerated]
		private sealed class <FadeIn>d__56 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MusicalItemHandler <>4__this;

			private float <startVolume>5__1;

			private float <targetVolume>5__2;

			private float <elapsedTime>5__3;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<startVolume>5__1 = <>4__this.audioSource.volume;
					<targetVolume>5__2 = <>4__this.volume * <>4__this.musicVolumeMultiplier;
					<elapsedTime>5__3 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<elapsedTime>5__3 < <>4__this.fadeDuration)
				{
					<elapsedTime>5__3 += Time.deltaTime;
					<>4__this.audioSource.volume = Mathf.Lerp(<startVolume>5__1, <targetVolume>5__2, <elapsedTime>5__3 / <>4__this.fadeDuration);
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<>4__this.audioSource.volume = <targetVolume>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();
			}
		}

		[CompilerGenerated]
		private sealed class <FadeOut>d__57 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MusicalItemHandler <>4__this;

			private float <startVolume>5__1;

			private float <elapsedTime>5__2;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<startVolume>5__1 = <>4__this.audioSource.volume;
					<elapsedTime>5__2 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<elapsedTime>5__2 < <>4__this.fadeDuration)
				{
					<elapsedTime>5__2 += Time.deltaTime;
					<>4__this.audioSource.volume = Mathf.Lerp(<startVolume>5__1, 0f, <elapsedTime>5__2 / <>4__this.fadeDuration);
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<>4__this.audioSource.volume = 0f;
				<>4__this.audioSource.Stop();
				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();
			}
		}

		[CompilerGenerated]
		private sealed class <RGBCycleLight>d__58 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MusicalItemHandler <>4__this;

			private float <hue>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<hue>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				<hue>5__1 = (<hue>5__1 + Time.deltaTime * <>4__this.rgbCycleSpeed) % 1f;
				if ((Object)(object)<>4__this.speakerLight != (Object)null)
				{
					<>4__this.speakerLight.color = Color.HSVToRGB(<hue>5__1, 1f, 1f);
				}
				<>2__current = null;
				<>1__state = 1;
				return true;
			}

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

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

		[CompilerGenerated]
		private sealed class <StartFirstTrackWithDelay>d__49 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MusicalItemHandler <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.initialTrackDelay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.PlayTrack(<>4__this.currentTrackIndex);
					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();
			}
		}

		[Header("Audio")]
		[SerializeField]
		private AudioSource audioSource;

		[SerializeField]
		private TrackData? trackData;

		[Range(0.1f, 10f)]
		[Tooltip("Multiplies the base volume of the music")]
		public float musicVolumeMultiplier = 1f;

		[Tooltip("Base volume level for the music (0-1)")]
		[Range(0f, 1f)]
		[SerializeField]
		private float volume = 1f;

		[Tooltip("Duration of fade in/out effects in seconds")]
		[SerializeField]
		private float fadeDuration = 1f;

		public Rarity.Sound? powerOnSound;

		public Rarity.Sound? powerOffSound;

		public Rarity.Sound? skipSound;

		private int currentTrack = -1;

		private AudioSource? currentTrackSource;

		[Header("Effects")]
		public ParticleSystem? musicParticles;

		public ParticleSystem? impactParticles;

		public Light? speakerLight;

		public float impactParticleDuration = 2f;

		public float lightIntensity = 2f;

		[Header("Settings")]
		public float minMessageDelay = 8f;

		public float maxMessageDelay = 16f;

		public bool skipOnImpact = true;

		public bool turnOffOnHeavyImpact = true;

		[Tooltip("Delay in seconds before the first track starts playing after power on")]
		public float initialTrackDelay = 1f;

		private float coolDownUntilNextMessage;

		private float initialMessageDelay = 8f;

		private float musicStartDelay = 5f;

		public bool requireHeldForNextTrack = true;

		public PowerOffBehavior powerOffBehavior = PowerOffBehavior.OnSlamWhenNotHeld;

		public SkipBehavior skipBehavior = SkipBehavior.SkipWhenNotHeld;

		private PhysGrabObject? physGrabObject;

		private PhysGrabObjectImpactDetector? impactDetector;

		private bool isPlaying;

		private float nextMessageTime;

		private Coroutine fadeCoroutine;

		private int currentTrackIndex = 0;

		private Coroutine rgbCycleCoroutine;

		private float rgbCycleSpeed = 0.5f;

		private string[][] trackMessages = new string[1][] { new string[6] { "Let's get this party started!", "Time to turn up!", "Music makes the world go round!", "Feel the beat!", "Dance like nobody's watching!", "Let the music take control!" } };

		public void SetTrackMessages(string[][] newMessages)
		{
			trackMessages = newMessages;
		}

		private void Start()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			if ((Object)(object)impactDetector != (Object)null)
			{
				impactDetector.onImpactHeavy.AddListener(new UnityAction(OnHeavyImpact));
			}
			if ((Object)(object)audioSource == (Object)null)
			{
				audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			}
			audioSource.volume = 0f;
			audioSource.spatialBlend = 1f;
			audioSource.rolloffMode = (AudioRolloffMode)2;
			audioSource.maxDistance = 50f;
			if ((Object)(object)musicParticles != (Object)null)
			{
				MainModule main = musicParticles.main;
				((MainModule)(ref main)).playOnAwake = false;
				((MainModule)(ref main)).loop = true;
				musicParticles.Stop(true, (ParticleSystemStopBehavior)0);
			}
			if ((Object)(object)impactParticles != (Object)null)
			{
				MainModule main2 = impactParticles.main;
				((MainModule)(ref main2)).playOnAwake = false;
				impactParticles.Stop(true, (ParticleSystemStopBehavior)0);
			}
			if ((Object)(object)speakerLight != (Object)null)
			{
				((Component)speakerLight).gameObject.SetActive(false);
			}
			isPlaying = false;
		}

		private void OnDestroy()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			if ((Object)(object)impactDetector != (Object)null)
			{
				impactDetector.onImpactHeavy.RemoveListener(new UnityAction(OnHeavyImpact));
			}
			ClearCurrentEyeState();
		}

		private void ClearCurrentEyeState()
		{
			string playerName = ChatManager.instance.playerAvatar.playerName;
			EyeStateManager.Instance.ClearEyeState(playerName);
		}

		private void Update()
		{
			if (!isPlaying || (Object)(object)trackData == (Object)null)
			{
				return;
			}
			if (Time.time >= nextMessageTime)
			{
				SendTrackMessage();
			}
			if ((Object)(object)physGrabObject != (Object)null)
			{
				if (physGrabObject.grabbed && !isPlaying)
				{
					StartMusic();
				}
				else if (physGrabObject.grabbed && isPlaying && Time.time >= nextMessageTime)
				{
					SendTrackMessage();
				}
			}
			if (isPlaying && (Object)(object)speakerLight != (Object)null && ((Component)speakerLight).gameObject.activeSelf)
			{
				TrackMessageData trackMessageData = trackData.GetTrackData(currentTrack);
				if (trackMessageData != null)
				{
					speakerLight.intensity = Mathf.Lerp(speakerLight.intensity, trackMessageData.lightIntensity, Time.deltaTime * 5f);
				}
			}
			if (powerOffBehavior == PowerOffBehavior.OnDrop && (Object)(object)physGrabObject != (Object)null && !physGrabObject.grabbed && isPlaying)
			{
				StopMusic();
			}
		}

		private void SendTrackMessage()
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)trackData == (Object)null || (Object)(object)ChatManager.instance == (Object)null || ChatManager.instance.StateIsPossessed() || (Object)(object)physGrabObject == (Object)null || !physGrabObject.heldByLocalPlayer || (Object)(object)physGrabObject == (Object)null || !physGrabObject.grabbed)
			{
				return;
			}
			TrackMessageData trackMessageData = trackData.GetTrackData(currentTrack);
			if (trackMessageData == null)
			{
				return;
			}
			string randomMessage = trackData.GetRandomMessage(currentTrack);
			if (string.IsNullOrEmpty(randomMessage))
			{
				return;
			}
			float messageDuration = trackData.GetMessageDuration(currentTrack, randomMessage);
			Color val = default(Color);
			((Color)(ref val))..ctor(trackMessageData.eyeColor.r, trackMessageData.eyeColor.g, trackMessageData.eyeColor.b, 1f);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(trackMessageData.pupilColor.r, trackMessageData.pupilColor.g, trackMessageData.pupilColor.b, 1f);
			val.a = 1f;
			val2.a = 1f;
			string playerName = ChatManager.instance.playerAvatar.playerName;
			EyeStateManager.Instance.SetEyeState(playerName, val, val2, trackMessageData.lightIntensity, messageDuration + 1f, eyeColorRGB: false, pupilColorRGB: false, trackMessageData.pupilSize);
			if (SemiFunc.IsMultiplayer())
			{
				((MonoBehaviourPun)this).photonView.RPC("SyncSpeakerEyeEffect", (RpcTarget)1, new object[6]
				{
					playerName,
					new float[4] { val.r, val.g, val.b, val.a },
					new float[4] { val2.r, val2.g, val2.b, val2.a },
					trackMessageData.lightIntensity,
					trackMessageData.pupilSize,
					messageDuration + 1f
				});
			}
			string newValue = "friend";
			if (SemiFunc.IsMultiplayer())
			{
				List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)this).transform.position, false, default(LayerMask));
				PlayerAvatar val3 = null;
				float num = float.MaxValue;
				foreach (PlayerAvatar item in list)
				{
					if ((Object)(object)item != (Object)(object)PlayerAvatar.instance)
					{
						float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position);
						if (num2 < num)
						{
							num = num2;
							val3 = item;
						}
					}
				}
				if ((Object)(object)val3 != (Object)null)
				{
					newValue = val3.playerName;
				}
			}
			randomMessage = randomMessage.Replace("{playerName}", newValue);
			ChatManager.instance.PossessChatScheduleStart(10);
			ChatManager.instance.PossessChat((PossessChatID)1001, randomMessage, messageDuration, val, 0f, false, 0, (UnityEvent)null);
			ChatManager.instance.PossessChatScheduleEnd();
			nextMessageTime = Time.time + trackData.messageFrequency + Random.Range(0f - trackData.messageRandomness, trackData.messageRandomness);
		}

		private void OnHeavyImpact()
		{
			if (!isPlaying)
			{
				return;
			}
			bool flag = (Object)(object)physGrabObject != (Object)null && physGrabObject.grabbed;
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			switch (powerOffBehavior)
			{
			case PowerOffBehavior.OnSlam:
				StopMusic();
				return;
			case PowerOffBehavior.OnSlamWhenHeld:
				if (flag)
				{
					StopMusic();
					return;
				}
				break;
			case PowerOffBehavior.OnSlamWhenNotHeld:
				if (!flag)
				{
					StopMusic();
					return;
				}
				break;
			}
			switch (skipBehavior)
			{
			case SkipBehavior.SkipAlways:
				NextTrack();
				break;
			case SkipBehavior.SkipWhenHeld:
				if (flag)
				{
					NextTrack();
				}
				break;
			case SkipBehavior.SkipWhenNotHeld:
				if (!flag)
				{
					NextTrack();
				}
				break;
			}
		}

		private void OnMediumImpact()
		{
			if (!isPlaying)
			{
				return;
			}
			bool flag = (Object)(object)physGrabObject != (Object)null && physGrabObject.grabbed;
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			switch (skipBehavior)
			{
			case SkipBehavior.SkipAlways:
				NextTrack();
				break;
			case SkipBehavior.SkipWhenHeld:
				if (flag)
				{
					NextTrack();
				}
				break;
			case SkipBehavior.SkipWhenNotHeld:
				if (!flag)
				{
					NextTrack();
				}
				break;
			}
		}

		private void OnLightImpact()
		{
		}

		private void StopImpactParticles()
		{
			if ((Object)(object)impactParticles != (Object)null)
			{
				impactParticles.Stop();
				((Component)impactParticles).gameObject.SetActive(false);
			}
		}

		public void StartMusic()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (isPlaying)
			{
				return;
			}
			if ((Object)(object)trackData == (Object)null)
			{
				Debug.LogError((object)"Cannot start music: trackData is null");
				return;
			}
			isPlaying = true;
			if ((Object)(object)powerOnSound?.clip != (Object)null)
			{
				AudioSource.PlayClipAtPoint(powerOnSound.clip, ((Component)this).transform.position, powerOnSound.volume);
				if (SemiFunc.IsMultiplayer())
				{
					((MonoBehaviourPun)this).photonView.RPC("PlayPowerOnSoundRPC", (RpcTarget)1, Array.Empty<object>());
				}
			}
			((MonoBehaviour)this).StartCoroutine(StartFirstTrackWithDelay());
			if (SemiFunc.IsMultiplayer())
			{
				((MonoBehaviourPun)this).photonView.RPC("StartMusicRPC", (RpcTarget)1, Array.Empty<object>());
			}
		}

		[PunRPC]
		private void StartMusicRPC()
		{
			if (!isPlaying)
			{
				isPlaying = true;
				((MonoBehaviour)this).StartCoroutine(StartFirstTrackWithDelay());
			}
		}

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

		public void StopMusic()
		{
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (!isPlaying)
			{
				return;
			}
			isPlaying = false;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if ((Object)(object)musicParticles != (Object)null)
				{
					musicParticles.Stop();
					((Component)musicParticles).gameObject.SetActive(false);
				}
				if ((Object)(object)impactParticles != (Object)null)
				{
					((Component)impactParticles).gameObject.SetActive(true);
					impactParticles.Play();
				}
				if (rgbCycleCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(rgbCycleCoroutine);
					rgbCycleCoroutine = null;
				}
			}
			if ((Object)(object)powerOffSound?.clip != (Object)null)
			{
				AudioSource.PlayClipAtPoint(powerOffSound.clip, ((Component)this).transform.position);
			}
			if ((Object)(object)speakerLight != (Object)null)
			{
				((Component)speakerLight).gameObject.SetActive(false);
			}
			if (fadeCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(fadeCoroutine);
			}
			fadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeOut());
			if (SemiFunc.IsMultiplayer())
			{
				((MonoBehaviourPun)this).photonView.RPC("StopMusicRPC", (RpcTarget)1, Array.Empty<object>());
			}
		}

		[PunRPC]
		private void StopMusicRPC()
		{
			if (isPlaying)
			{
				isPlaying = false;
				if ((Object)(object)musicParticles != (Object)null)
				{
					musicParticles.Stop(true, (ParticleSystemStopBehavior)0);
					((Component)musicParticles).gameObject.SetActive(false);
				}
				if ((Object)(object)impactParticles != (Object)null)
				{
					((Component)impactParticles).gameObject.SetActive(true);
					impactParticles.Play();
				}
				if (rgbCycleCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(rgbCycleCoroutine);
					rgbCycleCoroutine = null;
				}
				if ((Object)(object)speakerLight != (Object)null)
				{
					((Component)speakerLight).gameObject.SetActive(false);
				}
				if (fadeCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(fadeCoroutine);
				}
				fadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeOut());
			}
		}

		public void ToggleMusic()
		{
			if (isPlaying)
			{
				StopMusic();
			}
			else
			{
				StartMusic();
			}
		}

		public void NextTrack()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if (isPlaying && !((Object)(object)trackData == (Object)null))
			{
				currentTrackIndex = (currentTrackIndex + 1) % trackData.tracks.Count;
				PlayTrack(currentTrackIndex);
				if ((Object)(object)skipSound?.clip != (Object)null)
				{
					AudioSource.PlayClipAtPoint(skipSound.clip, ((Component)this).transform.position);
				}
				if (SemiFunc.IsMultiplayer())
				{
					((MonoBehaviourPun)this).photonView.RPC("NextTrackRPC", (RpcTarget)1, new object[1] { currentTrackIndex });
				}
			}
		}

		[PunRPC]
		private void NextTrackRPC(int trackIndex)
		{
			if (isPlaying && (Object)(object)trackData != (Object)null)
			{
				currentTrackIndex = trackIndex;
				PlayTrack(currentTrackIndex);
			}
		}

		private void PlayTrack(int index)
		{
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)trackData == (Object)null)
			{
				Debug.LogError((object)"PlayTrack failed: trackData is null");
				return;
			}
			if (fadeCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(fadeCoroutine);
			}
			if (rgbCycleCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(rgbCycleCoroutine);
			}
			TrackMessageData trackMessageData = trackData.GetTrackData(index);
			if (trackMessageData == null)
			{
				Debug.LogError((object)$"PlayTrack failed: No track data found for index {index}");
				return;
			}
			if (trackMessageData.sound == null)
			{
				Debug.LogError((object)$"PlayTrack failed: Track {index} has no sound data");
				return;
			}
			if ((Object)(object)trackMessageData.sound.clip == (Object)null)
			{
				Debug.LogError((object)$"PlayTrack failed: Track {index} sound has no audio clip");
				return;
			}
			audioSource.clip = trackMessageData.sound.clip;
			audioSource.loop = true;
			audioSource.spatialBlend = trackMessageData.sound.spatialBlend;
			audioSource.dopplerLevel = trackMessageData.sound.doppler;
			audioSource.reverbZoneMix = trackMessageData.sound.reverbMix;
			audioSource.Play();
			fadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeIn());
			if ((Object)(object)trackMessageData.trackParticles != (Object)null)
			{
				if ((Object)(object)musicParticles != (Object)null)
				{
					musicParticles.Stop(true, (ParticleSystemStopBehavior)0);
					((Component)musicParticles).gameObject.SetActive(false);
				}
				((Component)trackMessageData.trackParticles).gameObject.SetActive(true);
				trackMessageData.trackParticles.Play();
			}
			else if ((Object)(object)musicParticles != (Object)null)
			{
				((Component)musicParticles).gameObject.SetActive(true);
				musicParticles.Play();
			}
			if ((Object)(object)speakerLight != (Object)null)
			{
				((Component)speakerLight).gameObject.SetActive(true);
				speakerLight.color = trackMessageData.lightColor;
				speakerLight.intensity = 0f;
				if (trackMessageData.lightColorRGB)
				{
					rgbCycleCoroutine = ((MonoBehaviour)this).StartCoroutine(RGBCycleLight());
				}
			}
			nextMessageTime = Time.time + trackData.messageFrequency + Random.Range(0f - trackData.messageRandomness, trackData.messageRandomness);
			currentTrack = index;
		}

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

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

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

		[PunRPC]
		private void PlayPowerOnSoundRPC()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)powerOnSound?.clip != (Object)null)
			{
				AudioSource.PlayClipAtPoint(powerOnSound.clip, ((Component)this).transform.position, powerOnSound.volume);
			}
		}

		[PunRPC]
		private void SyncSpeakerEyeEffect(string playerName, float[] eyeRGBA, float[] pupilRGBA, float intensity, float pupilSize, float duration)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Color eyeColor = default(Color);
			((Color)(ref eyeColor))..ctor(eyeRGBA[0], eyeRGBA[1], eyeRGBA[2], eyeRGBA[3]);
			Color pupilColor = default(Color);
			((Color)(ref pupilColor))..ctor(pupilRGBA[0], pupilRGBA[1], pupilRGBA[2], pupilRGBA[3]);
			EyeStateManager.Instance.SetEyeState(playerName, eyeColor, pupilColor, intensity, duration, eyeColorRGB: false, pupilColorRGB: false, pupilSize);
		}
	}
	public abstract class PaintedPostProcessingEffect
	{
		public float duration;

		public float intensity;

		public bool isActive;

		public abstract void ApplyEffect(PlayerAvatar player);

		public abstract void RemoveEffect(PlayerAvatar player);

		public virtual void UpdateEffect(PlayerAvatar player)
		{
		}
	}
	public class PaintedPostProcessing : MonoBehaviour
	{
		private static PaintedPostProcessing instance;

		private Dictionary<PlayerAvatar, List<PaintedPostProcessingEffect>> activeEffects = new Dictionary<PlayerAvatar, List<PaintedPostProcessingEffect>>();

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public static void ApplyEffect(PlayerAvatar player, PaintedPostProcessingEffect effect)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			PaintedPostProcessingEffect effect2 = effect;
			if ((Object)(object)instance == (Object)null)
			{
				GameObject val = new GameObject("PaintedPostProcessing");
				instance = val.AddComponent<PaintedPostProcessing>();
			}
			if (!instance.activeEffects.ContainsKey(player))
			{
				instance.activeEffects[player] = new List<PaintedPostProcessingEffect>();
			}
			PaintedPostProcessingEffect paintedPostProcessingEffect = instance.activeEffects[player].Find((PaintedPostProcessingEffect e) => e.GetType() == effect2.GetType());
			if (paintedPostProcessingEffect != null)
			{
				paintedPostProcessingEffect.RemoveEffect(player);
				instance.activeEffects[player].Remove(paintedPostProcessingEffect);
			}
			instance.activeEffects[player].Add(effect2);
			effect2.ApplyEffect(player);
		}

		public static void RemoveEffect(PlayerAvatar player, PaintedPostProcessingEffect effect)
		{
			if (!((Object)(object)instance == (Object)null) && instance.activeEffects.ContainsKey(player))
			{
				effect.RemoveEffect(player);
				instance.activeEffects[player].Remove(effect);
			}
		}

		private void Update()
		{
			foreach (KeyValuePair<PlayerAvatar, List<PaintedPostProcessingEffect>> activeEffect in activeEffects)
			{
				PaintedPostProcessingEffect[] array = activeEffect.Value.ToArray();
				foreach (PaintedPostProcessingEffect paintedPostProcessingEffect in array)
				{
					if (paintedPostProcessingEffect.duration > 0f)
					{
						paintedPostProcessingEffect.duration -= Time.deltaTime;
						paintedPostProcessingEffect.UpdateEffect(activeEffect.Key);
						if (paintedPostProcessingEffect.duration <= 0f)
						{
							paintedPostProcessingEffect.RemoveEffect(activeEffect.Key);
							activeEffect.Value.Remove(paintedPostProcessingEffect);
						}
					}
				}
			}
		}
	}
	[Serializable]
	public class PlayerEvent : UnityEvent<PhysGrabber>
	{
	}
	[Serializable]
	public class TimerEvent
	{
		public string name;

		public float interval = 1f;

		public bool onlyWhenGrabbed = false;

		public PlayerEvent onTimer;
	}
	[Serializable]
	public class UseEvent
	{
		public string name;

		public bool useCustomKey = false;

		public KeyCode customKey = (KeyCode)101;

		public bool canUseWhenNotGrabbed = false;

		public PlayerEvent onUse;
	}
	public class PaintedUtilItemEvents : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <TimerRoutine>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public TimerEvent timerEvent;

			public PaintedUtilItemEvents <>4__this;

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

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

			[DebuggerHidden]
			public <TimerRoutine>d__11(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_0039: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					if (!timerEvent.onlyWhenGrabbed || <>4__this.wasGrabbed)
					{
						((UnityEvent<PhysGrabber>)(object)timerEvent.onTimer).Invoke(Object.FindObjectOfType<PhysGrabber>());
					}
					break;
				}
				<>2__current = (object)new WaitForSeconds(timerEvent.interval);
				<>1__state = 1;
				return true;
			}

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

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

		[Header("Grab Events")]
		public PlayerEvent onGrabbed;

		public PlayerEvent onReleased;

		[Header("Use Events")]
		public List<UseEvent> useEvents = new List<UseEvent>();

		[Header("Timer Events")]
		public List<TimerEvent> timerEvents = new List<TimerEvent>();

		private List<Coroutine> timerCoroutines = new List<Coroutine>();

		private PhysGrabObject grabObject;

		private bool wasGrabbed = false;

		private void Awake()
		{
			grabObject = ((Component)this).GetComponent<PhysGrabObject>();
			if ((Object)(object)grabObject == (Object)null)
			{
				Debug.LogWarning((object)("PaintedUtilItemEvents on " + ((Object)((Component)this).gameObject).name + " requires a PhysGrabObject component!"));
				((Behaviour)this).enabled = false;
			}
			else
			{
				StartAllTimers();
			}
		}

		private void Update()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (grabObject.grabbedLocal != wasGrabbed)
			{
				wasGrabbed = grabObject.grabbedLocal;
				if (wasGrabbed)
				{
					((UnityEvent<PhysGrabber>)(object)onGrabbed).Invoke(Object.FindObjectOfType<PhysGrabber>());
				}
				else
				{
					((UnityEvent<PhysGrabber>)(object)onReleased).Invoke(Object.FindObjectOfType<PhysGrabber>());
				}
			}
			foreach (UseEvent useEvent in useEvents)
			{
				if (useEvent.useCustomKey ? Input.GetKeyDown(useEvent.customKey) : SemiFunc.InputDown((InputKey)2))
				{
					if (wasGrabbed)
					{
						((UnityEvent<PhysGrabber>)(object)useEvent.onUse).Invoke(Object.FindObjectOfType<PhysGrabber>());
					}
					else if (useEvent.canUseWhenNotGrabbed && IsPlayerLookingAtAndInRange())
					{
						((UnityEvent<PhysGrabber>)(object)useEvent.onUse).Invoke(Object.FindObjectOfType<PhysGrabber>());
					}
				}
			}
		}

		private bool IsPlayerLookingAtAndInRange()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			PhysGrabber val = Object.FindObjectOfType<PhysGrabber>();
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			if ((Object)(object)val.currentlyLookingAtPhysGrabObject != (Object)(object)grabObject)
			{
				return false;
			}
			float num = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position);
			return num <= val.grabRange;
		}

		private void StartAllTimers()
		{
			foreach (TimerEvent timerEvent in timerEvents)
			{
				if (timerEvent.interval > 0f)
				{
					Coroutine item = ((MonoBehaviour)this).StartCoroutine(TimerRoutine(timerEvent));
					timerCoroutines.Add(item);
				}
			}
		}

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

		private void OnDestroy()
		{
			foreach (Coroutine timerCoroutine in timerCoroutines)
			{
				if (timerCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(timerCoroutine);
				}
			}
			timerCoroutines.Clear();
		}
	}
	[CreateAssetMenu(menuName = "PaintedUtils/Rarity")]
	public class Rarity : ScriptableObject
	{
		[Serializable]
		public class Sound
		{
			public AudioClip clip;

			public float volume = 1f;

			[Range(0f, 3f)]
			public float pitch = 1f;

			[Range(0f, 1f)]
			public float volumeRandom = 0f;

			[Range(0f, 1f)]
			public float pitchRandom = 0f;

			[Range(0f, 1f)]
			public float spatialBlend = 1f;

			[Range(-3f, 3f)]
			public float doppler = 1f;

			[Range(0f, 10f)]
			public float reverbMix = 1f;

			public float falloffMultiplier = 1f;

			public int channel = 0;
		}

		public string rarityName;

		public ParticleSystem spawnEffect;

		public bool overrideEffectColor = false;

		public Color overrideColor = Color.white;

		public bool disableEffectOnGrab = false;

		public Sound spawnSound;

		public Color uiColor = Color.white;

		public Sprite icon;

		public void InitializeAudioSource(GameObject gameObject)
		{
			AudioSource val = gameObject.AddComponent<AudioSource>();
			val.clip = spawnSound.clip;
			val.volume = spawnSound.volume * Random.Range(1f - spawnSound.volumeRandom, 1f);
			val.pitch = spawnSound.pitch * Random.Range(1f - spawnSound.pitchRandom, 1f);
			val.spatialBlend = spawnSound.spatialBlend;
			val.dopplerLevel = spawnSound.doppler;
			val.reverbZoneMix = spawnSound.reverbMix;
			val.rolloffMode = (AudioRolloffMode)2;
			val.maxDistance = 50f * spawnSound.falloffMultiplier;
			val.Play();
		}
	}
	public class RarityEffectHandle
	{
		public ParticleSystem particleSystem;

		public GameObject particleGameObject;

		public AudioSource audioSource;

		public void DisableEffects()
		{
			if ((Object)(object)particleSystem != (Object)null)
			{
				particleSystem.Stop(true, (ParticleSystemStopBehavior)0);
			}
			if ((Object)(object)particleGameObject != (Object)null)
			{
				Object.Destroy((Object)(object)particleGameObject);
			}
		}
	}
	public static class RarityEffectManager
	{
		public static RarityEffectHandle TryPlayEffects(Rarity rarity, Vector3 position, Transform parent = null)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			RarityEffectHandle rarityEffectHandle = new RarityEffectHandle();
			if ((Object)(object)rarity.spawnEffect != (Object)null)
			{
				ParticleSystem val = Object.Instantiate<ParticleSystem>(rarity.spawnEffect, position, Quaternion.identity, parent);
				((Component)val).transform.up = Vector3.up;
				val.Play();
				rarityEffectHandle.particleSystem = val;
				rarityEffectHandle.particleGameObject = ((Component)val).gameObject;
				if (rarity.overrideEffectColor)
				{
					ApplyColorOverrideToEffect(((Component)val).gameObject, rarity);
				}
				if (rarity.disableEffectOnGrab && (Object)(object)parent != (Object)null)
				{
					RarityEffectTracker rarityEffectTracker = ((Component)parent).gameObject.AddComponent<RarityEffectTracker>();
					rarityEffectTracker.effectHandle = rarityEffectHandle;
					if ((Object)(object)((Component)parent).gameObject.GetComponent<PhysGrabObject>() != (Object)null)
					{
						((Component)parent).gameObject.AddComponent<RarityGrabEffectHandler>();
					}
				}
			}
			if (rarity.spawnSound != null && (Object)(object)rarity.spawnSound.clip != (Object)null)
			{
				rarity.InitializeAudioSource(rarityEffectHandle.particleGameObject);
			}
			return rarityEffectHandle;
		}

		private static void ApplyColorOverrideToEffect(GameObject targetEffectInstance, Rarity rarity)
		{
			//IL_0031: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targetEffectInstance == (Object)null || (Object)(object)rarity == (Object)null)
			{
				return;
			}
			ParticleSystem[] componentsInChildren = targetEffectInstance.GetComponentsInChildren<ParticleSystem>(true);
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val in array)
			{
				MainModule main = val.main;
				if (rarity.overrideEffectColor)
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(rarity.overrideColor);
				}
			}
		}
	}
	public class RarityEffectTracker : MonoBehaviour
	{
		public RarityEffectHandle effectHandle;

		public void DisableRarityEffects()
		{
			effectHandle?.DisableEffects();
		}
	}
	public class RarityGrabEffectHandler : MonoBehaviour
	{
		private RarityEffectTracker tracker;

		private PhysGrabObject grabObject;

		private bool wasGrabbed = false;

		private void Awake()
		{
			tracker = ((Component)this).GetComponent<RarityEffectTracker>();
			grabObject = ((Component)this).GetComponent<PhysGrabObject>();
		}

		private void Update()
		{
			if (!((Object)(object)tracker == (Object)null) && !((Object)(object)grabObject == (Object)null) && grabObject.grabbedLocal != wasGrabbed)
			{
				wasGrabbed = grabObject.grabbedLocal;
				if (wasGrabbed)
				{
					tracker.DisableRarityEffects();
				}
			}
		}
	}
	[Serializable]
	public class TrackMessageData
	{
		public List<string> messages = new List<string>();

		public Rarity.Sound? sound;

		[Header("Eye Effects")]
		[Tooltip("Color of the eyes during TTS")]
		public Color eyeColor = Color.white;

		[Tooltip("Color of the pupils during TTS")]
		public Color pupilColor = Color.black;

		[Range(0.1f, 5f)]
		[Tooltip("Size of the pupils during TTS")]
		public float pupilSize = 3f;

		[Header("Speaker Light")]
		[Tooltip("Color of the speaker light")]
		public Color lightColor = Color.white;

		[Tooltip("If true, light will cycle through rainbow colors")]
		public bool lightColorRGB