Decompiled source of AuroraEthereal v1.0.0

plugins/Ethereal.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Aurora Server")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Ethereal donor reward system - auras and colored names for supporters")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Ethereal")]
[assembly: AssemblyTitle("Ethereal")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Ethereal
{
	public static class AuraManager
	{
		private const string AuraObjectName = "EtherealAura";

		private static Dictionary<Player, GameObject> _activeAuras = new Dictionary<Player, GameObject>();

		private static Dictionary<Player, float> _rainbowHue = new Dictionary<Player, float>();

		public static void ApplyAura(Player player, string colorName)
		{
			//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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0073: 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 ((Object)(object)player == (Object)null)
			{
				return;
			}
			RemoveAura(player);
			if (!(colorName == "None") && !string.IsNullOrEmpty(colorName))
			{
				Color auraColor = EtherealPlugin.GetAuraColor(colorName);
				GameObject val = new GameObject("EtherealAura");
				val.transform.SetParent(((Component)player).transform);
				val.transform.localPosition = new Vector3(0f, 1f, 0f);
				EtherealAuraEffect etherealAuraEffect = val.AddComponent<EtherealAuraEffect>();
				etherealAuraEffect.Initialize(colorName, auraColor, player);
				_activeAuras[player] = val;
				if (colorName == "Rainbow")
				{
					_rainbowHue[player] = 0f;
				}
				EtherealPlugin.Log.LogInfo((object)("Applied " + colorName + " aura to " + player.GetPlayerName()));
			}
		}

		public static void RemoveAura(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			if (_activeAuras.TryGetValue(player, out var value))
			{
				if ((Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
				_activeAuras.Remove(player);
			}
			_rainbowHue.Remove(player);
			Transform val = ((Component)player).transform.Find("AuraTrail");
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			Transform val2 = ((Component)player).transform.Find("EtherealAura");
			if ((Object)(object)val2 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
		}

		public static void UpdateAllAuras()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			List<Player> list = new List<Player>(_rainbowHue.Keys);
			foreach (Player item in list)
			{
				if (!((Object)(object)item == (Object)null) && _activeAuras.TryGetValue(item, out var value) && (Object)(object)value != (Object)null)
				{
					EtherealAuraEffect component = value.GetComponent<EtherealAuraEffect>();
					if ((Object)(object)component != (Object)null)
					{
						float num = (_rainbowHue[item] + Time.deltaTime * 0.2f) % 1f;
						_rainbowHue[item] = num;
						Color newColor = Color.HSVToRGB(num, 0.8f, 1f);
						component.UpdateColor(newColor);
					}
				}
			}
		}

		public static void CleanupDeadAuras()
		{
			List<Player> list = new List<Player>();
			foreach (KeyValuePair<Player, GameObject> activeAura in _activeAuras)
			{
				if ((Object)(object)activeAura.Key == (Object)null || (Object)(object)activeAura.Value == (Object)null)
				{
					list.Add(activeAura.Key);
				}
			}
			foreach (Player item in list)
			{
				_activeAuras.Remove(item);
				_rainbowHue.Remove(item);
			}
		}

		public static void ApplyAurasToAllPlayers()
		{
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (!((Object)(object)allPlayer == (Object)null))
				{
					string playerName = allPlayer.GetPlayerName();
					EtherealPlayerData etherealData = EtherealPlugin.GetEtherealData(playerName);
					if (etherealData != null && etherealData.SelectedColor != "None" && (!_activeAuras.ContainsKey(allPlayer) || (Object)(object)_activeAuras[allPlayer] == (Object)null))
					{
						ApplyAura(allPlayer, etherealData.SelectedColor);
					}
				}
			}
		}

		public static bool HasAura(Player player)
		{
			return _activeAuras.ContainsKey(player) && (Object)(object)_activeAuras[player] != (Object)null;
		}
	}
	public class EtherealAuraEffect : MonoBehaviour
	{
		private string _colorName;

		private Color _baseColor;

		private Light _auraLight;

		private ParticleSystem _particleSystem;

		private ParticleSystem _sparkleSystem;

		private ParticleSystem _trailSystem;

		private float _pulseTime = 0f;

		private Player _player;

		private Vector3 _lastPosition;

		private float _trailEmissionTimer = 0f;

		public void Initialize(string colorName, Color color, Player player)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			_colorName = colorName;
			_baseColor = color;
			_player = player;
			_lastPosition = (((Object)(object)player != (Object)null) ? ((Component)player).transform.position : Vector3.zero);
			CreatePointLight();
			CreateMainParticles();
			CreateSparkleParticles();
			CreateTrailParticles();
		}

		private void CreatePointLight()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("AuraLight");
			val.transform.SetParent(((Component)this).transform);
			val.transform.localPosition = Vector3.zero;
			_auraLight = val.AddComponent<Light>();
			_auraLight.type = (LightType)2;
			_auraLight.color = _baseColor;
			_auraLight.intensity = 1.5f;
			_auraLight.range = 4f;
			_auraLight.shadows = (LightShadows)0;
		}

		private void CreateMainParticles()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0024: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: 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_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("AuraParticles");
			val.transform.SetParent(((Component)this).transform);
			val.transform.localPosition = Vector3.zero;
			_particleSystem = val.AddComponent<ParticleSystem>();
			MainModule main = _particleSystem.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.3f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.15f);
			((MainModule)(ref main)).maxParticles = 50;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(_baseColor.r, _baseColor.g, _baseColor.b, 0.6f));
			EmissionModule emission = _particleSystem.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(20f);
			ShapeModule shape = _particleSystem.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.5f;
			ColorOverLifetimeModule colorOverLifetime = _particleSystem.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val2 = new Gradient();
			val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(_baseColor, 0f),
				new GradientColorKey(_baseColor, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(0.6f, 0.3f),
				new GradientAlphaKey(0.6f, 0.7f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
			SizeOverLifetimeModule sizeOverLifetime = _particleSystem.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			AnimationCurve val3 = new AnimationCurve();
			val3.AddKey(0f, 0.5f);
			val3.AddKey(0.5f, 1f);
			val3.AddKey(1f, 0f);
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, val3);
			VelocityOverLifetimeModule velocityOverLifetime = _particleSystem.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = MinMaxCurve.op_Implicit(0.5f);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).material = CreateParticleMaterial();
		}

		private void CreateSparkleParticles()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0024: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_0126: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("AuraSparkles");
			val.transform.SetParent(((Component)this).transform);
			val.transform.localPosition = Vector3.zero;
			_sparkleSystem = val.AddComponent<ParticleSystem>();
			MainModule main = _sparkleSystem.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.08f);
			((MainModule)(ref main)).maxParticles = 30;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 1f, 1f, 0.8f));
			EmissionModule emission = _sparkleSystem.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(15f);
			ShapeModule shape = _sparkleSystem.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.8f;
			ColorOverLifetimeModule colorOverLifetime = _sparkleSystem.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val2 = new Gradient();
			val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(_baseColor, 0.5f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(1f, 0.5f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
			SizeOverLifetimeModule sizeOverLifetime = _sparkleSystem.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			AnimationCurve val3 = new AnimationCurve();
			val3.AddKey(0f, 0f);
			val3.AddKey(0.2f, 1f);
			val3.AddKey(0.5f, 0.3f);
			val3.AddKey(0.8f, 1f);
			val3.AddKey(1f, 0f);
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, val3);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).material = CreateParticleMaterial();
		}

		private void CreateTrailParticles()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Expected O, but got Unknown
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("AuraTrail");
			val.transform.SetParent(((Component)this).transform.parent);
			val.transform.localPosition = new Vector3(0f, 0.1f, 0f);
			_trailSystem = val.AddComponent<ParticleSystem>();
			MainModule main = _trailSystem.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.3f, 0.5f);
			((MainModule)(ref main)).maxParticles = 100;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(_baseColor.r, _baseColor.g, _baseColor.b, 0.5f));
			EmissionModule emission = _trailSystem.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(0f);
			ShapeModule shape = _trailSystem.shape;
			((ShapeModule)(ref shape)).enabled = false;
			ColorOverLifetimeModule colorOverLifetime = _trailSystem.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val2 = new Gradient();
			val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(_baseColor, 0f),
				new GradientColorKey(_baseColor, 0.5f),
				new GradientColorKey(_baseColor * 0.5f, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0.6f, 0f),
				new GradientAlphaKey(0.4f, 0.5f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
			SizeOverLifetimeModule sizeOverLifetime = _trailSystem.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			AnimationCurve val3 = new AnimationCurve();
			val3.AddKey(0f, 1f);
			val3.AddKey(1f, 0f);
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, val3);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).material = CreateParticleMaterial();
		}

		private Material CreateParticleMaterial()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			Material val = null;
			string[] array = new string[4] { "Particles/Standard Unlit", "Legacy Shaders/Particles/Additive", "Particles/Additive", "Sprites/Default" };
			string[] array2 = array;
			foreach (string text in array2)
			{
				Shader val2 = Shader.Find(text);
				if ((Object)(object)val2 != (Object)null)
				{
					val = new Material(val2);
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				val = new Material(Shader.Find("Standard"));
			}
			Texture2D mainTexture = CreateCircleTexture(32);
			val.mainTexture = (Texture)(object)mainTexture;
			return val;
		}

		private Texture2D CreateCircleTexture(int size)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			float num = (float)size / 2f;
			float num2 = (float)size / 2f;
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num, num));
					float num4 = Mathf.Clamp01(1f - num3 / num2);
					num4 *= num4;
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num4));
				}
			}
			val.Apply();
			return val;
		}

		public void UpdateColor(Color newColor)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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_003e: 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_0046: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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)
			_baseColor = newColor;
			if ((Object)(object)_auraLight != (Object)null)
			{
				_auraLight.color = newColor;
			}
			if ((Object)(object)_particleSystem != (Object)null)
			{
				MainModule main = _particleSystem.main;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(newColor.r, newColor.g, newColor.b, 0.6f));
			}
			if ((Object)(object)_trailSystem != (Object)null)
			{
				MainModule main2 = _trailSystem.main;
				((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(new Color(newColor.r, newColor.g, newColor.b, 0.5f));
			}
		}

		private void Update()
		{
			//IL_0086: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			_pulseTime += Time.deltaTime;
			float num = 1f + Mathf.Sin(_pulseTime * 2f) * 0.2f;
			if ((Object)(object)_auraLight != (Object)null)
			{
				_auraLight.intensity = 1.5f * num;
			}
			if (!((Object)(object)_player != (Object)null) || !((Object)(object)_trailSystem != (Object)null))
			{
				return;
			}
			Vector3 position = ((Component)_player).transform.position;
			float num2 = Vector3.Distance(position, _lastPosition);
			if (num2 > 0.05f)
			{
				_trailEmissionTimer += Time.deltaTime;
				if (_trailEmissionTimer >= 0.15f)
				{
					_trailEmissionTimer = 0f;
					EmitParams val = default(EmitParams);
					((EmitParams)(ref val)).position = position + new Vector3(Random.Range(-0.2f, 0.2f), 0.05f, Random.Range(-0.2f, 0.2f));
					((EmitParams)(ref val)).velocity = Vector3.up * 0.1f;
					((EmitParams)(ref val)).startSize = Random.Range(0.3f, 0.5f);
					((EmitParams)(ref val)).startLifetime = Random.Range(1.5f, 2.5f);
					((EmitParams)(ref val)).startColor = Color32.op_Implicit(new Color(_baseColor.r, _baseColor.g, _baseColor.b, 0.6f));
					_trailSystem.Emit(val, 1);
				}
			}
			_lastPosition = position;
		}

		private void OnDestroy()
		{
			CleanupParticleSystem(_particleSystem);
			CleanupParticleSystem(_sparkleSystem);
			if (!((Object)(object)_trailSystem != (Object)null) || !((Object)(object)((Component)_trailSystem).gameObject != (Object)null))
			{
				return;
			}
			ParticleSystemRenderer component = ((Component)_trailSystem).GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).material != (Object)null)
			{
				if ((Object)(object)((Renderer)component).material.mainTexture != (Object)null)
				{
					Object.Destroy((Object)(object)((Renderer)component).material.mainTexture);
				}
				Object.Destroy((Object)(object)((Renderer)component).material);
			}
			Object.Destroy((Object)(object)((Component)_trailSystem).gameObject);
		}

		private void CleanupParticleSystem(ParticleSystem ps)
		{
			if (!((Object)(object)ps != (Object)null))
			{
				return;
			}
			ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).material != (Object)null)
			{
				if ((Object)(object)((Renderer)component).material.mainTexture != (Object)null)
				{
					Object.Destroy((Object)(object)((Renderer)component).material.mainTexture);
				}
				Object.Destroy((Object)(object)((Renderer)component).material);
			}
		}
	}
	public static class CommandHandler
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__1_0;

			public static ConsoleEvent <>9__1_1;

			public static ConsoleEvent <>9__1_2;

			public static ConsoleEvent <>9__1_3;

			internal void <RegisterCommands>b__1_0(ConsoleEventArgs args)
			{
				if (!IsAdmin())
				{
					Terminal context = args.Context;
					if (context != null)
					{
						context.AddString("You must be an admin to use this command.");
					}
					return;
				}
				if (args.Length < 2)
				{
					Terminal context2 = args.Context;
					if (context2 != null)
					{
						context2.AddString("Usage: addethereal <playername>");
					}
					return;
				}
				string text = string.Join(" ", args.Args.Skip(1));
				if (EtherealPlugin.AddEtherealPlayer(text))
				{
					Terminal context3 = args.Context;
					if (context3 != null)
					{
						context3.AddString("Added " + text + " to Ethereal players!");
					}
					BroadcastEtherealChange(text, added: true);
					Player val = EtherealPlugin.FindPlayerByName(text);
					if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)Player.m_localPlayer)
					{
						MessageHud instance = MessageHud.instance;
						if (instance != null)
						{
							instance.ShowMessage((MessageType)2, "You have been granted Ethereal status!\nType /ethereal in chat to select your aura.", 0, (Sprite)null, false);
						}
					}
				}
				else
				{
					Terminal context4 = args.Context;
					if (context4 != null)
					{
						context4.AddString(text + " is already an Ethereal player.");
					}
				}
			}

			internal void <RegisterCommands>b__1_1(ConsoleEventArgs args)
			{
				if (!IsAdmin())
				{
					Terminal context = args.Context;
					if (context != null)
					{
						context.AddString("You must be an admin to use this command.");
					}
					return;
				}
				if (args.Length < 2)
				{
					Terminal context2 = args.Context;
					if (context2 != null)
					{
						context2.AddString("Usage: removeethereal <playername>");
					}
					return;
				}
				string text = string.Join(" ", args.Args.Skip(1));
				if (EtherealPlugin.RemoveEtherealPlayer(text))
				{
					Terminal context3 = args.Context;
					if (context3 != null)
					{
						context3.AddString("Removed " + text + " from Ethereal players.");
					}
					BroadcastEtherealChange(text, added: false);
					Player val = EtherealPlugin.FindPlayerByName(text);
					if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)Player.m_localPlayer)
					{
						MessageHud instance = MessageHud.instance;
						if (instance != null)
						{
							instance.ShowMessage((MessageType)2, "Your Ethereal status has been revoked.", 0, (Sprite)null, false);
						}
					}
				}
				else
				{
					Terminal context4 = args.Context;
					if (context4 != null)
					{
						context4.AddString(text + " is not an Ethereal player.");
					}
				}
			}

			internal void <RegisterCommands>b__1_2(ConsoleEventArgs args)
			{
				if (EtherealPlugin.EtherealPlayers.Count == 0)
				{
					Terminal context = args.Context;
					if (context != null)
					{
						context.AddString("No Ethereal players registered.");
					}
					return;
				}
				Terminal context2 = args.Context;
				if (context2 != null)
				{
					context2.AddString("===== Ethereal Players =====");
				}
				foreach (KeyValuePair<string, EtherealPlayerData> etherealPlayer in EtherealPlugin.EtherealPlayers)
				{
					string selectedColor = etherealPlayer.Value.SelectedColor;
					Terminal context3 = args.Context;
					if (context3 != null)
					{
						context3.AddString("  " + etherealPlayer.Key + " - Aura: " + selectedColor);
					}
				}
				Terminal context4 = args.Context;
				if (context4 != null)
				{
					context4.AddString("============================");
				}
			}

			internal void <RegisterCommands>b__1_3(ConsoleEventArgs args)
			{
				HandleEtherealCommand();
			}
		}

		private static bool _commandsRegistered;

		public static void RegisterCommands()
		{
			//IL_0043: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00eb: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			if (_commandsRegistered)
			{
				return;
			}
			try
			{
				object obj = <>c.<>9__1_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate(ConsoleEventArgs args)
					{
						if (!IsAdmin())
						{
							Terminal context9 = args.Context;
							if (context9 != null)
							{
								context9.AddString("You must be an admin to use this command.");
							}
						}
						else if (args.Length < 2)
						{
							Terminal context10 = args.Context;
							if (context10 != null)
							{
								context10.AddString("Usage: addethereal <playername>");
							}
						}
						else
						{
							string text2 = string.Join(" ", args.Args.Skip(1));
							if (EtherealPlugin.AddEtherealPlayer(text2))
							{
								Terminal context11 = args.Context;
								if (context11 != null)
								{
									context11.AddString("Added " + text2 + " to Ethereal players!");
								}
								BroadcastEtherealChange(text2, added: true);
								Player val6 = EtherealPlugin.FindPlayerByName(text2);
								if ((Object)(object)val6 != (Object)null && (Object)(object)val6 == (Object)(object)Player.m_localPlayer)
								{
									MessageHud instance2 = MessageHud.instance;
									if (instance2 != null)
									{
										instance2.ShowMessage((MessageType)2, "You have been granted Ethereal status!\nType /ethereal in chat to select your aura.", 0, (Sprite)null, false);
									}
								}
							}
							else
							{
								Terminal context12 = args.Context;
								if (context12 != null)
								{
									context12.AddString(text2 + " is already an Ethereal player.");
								}
							}
						}
					};
					<>c.<>9__1_0 = val;
					obj = (object)val;
				}
				new ConsoleCommand("addethereal", "[name] - Add a player to Ethereal list", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj2 = <>c.<>9__1_1;
				if (obj2 == null)
				{
					ConsoleEvent val2 = delegate(ConsoleEventArgs args)
					{
						if (!IsAdmin())
						{
							Terminal context5 = args.Context;
							if (context5 != null)
							{
								context5.AddString("You must be an admin to use this command.");
							}
						}
						else if (args.Length < 2)
						{
							Terminal context6 = args.Context;
							if (context6 != null)
							{
								context6.AddString("Usage: removeethereal <playername>");
							}
						}
						else
						{
							string text = string.Join(" ", args.Args.Skip(1));
							if (EtherealPlugin.RemoveEtherealPlayer(text))
							{
								Terminal context7 = args.Context;
								if (context7 != null)
								{
									context7.AddString("Removed " + text + " from Ethereal players.");
								}
								BroadcastEtherealChange(text, added: false);
								Player val5 = EtherealPlugin.FindPlayerByName(text);
								if ((Object)(object)val5 != (Object)null && (Object)(object)val5 == (Object)(object)Player.m_localPlayer)
								{
									MessageHud instance = MessageHud.instance;
									if (instance != null)
									{
										instance.ShowMessage((MessageType)2, "Your Ethereal status has been revoked.", 0, (Sprite)null, false);
									}
								}
							}
							else
							{
								Terminal context8 = args.Context;
								if (context8 != null)
								{
									context8.AddString(text + " is not an Ethereal player.");
								}
							}
						}
					};
					<>c.<>9__1_1 = val2;
					obj2 = (object)val2;
				}
				new ConsoleCommand("removeethereal", "[name] - Remove a player from Ethereal list", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj3 = <>c.<>9__1_2;
				if (obj3 == null)
				{
					ConsoleEvent val3 = delegate(ConsoleEventArgs args)
					{
						if (EtherealPlugin.EtherealPlayers.Count == 0)
						{
							Terminal context = args.Context;
							if (context != null)
							{
								context.AddString("No Ethereal players registered.");
							}
						}
						else
						{
							Terminal context2 = args.Context;
							if (context2 != null)
							{
								context2.AddString("===== Ethereal Players =====");
							}
							foreach (KeyValuePair<string, EtherealPlayerData> etherealPlayer in EtherealPlugin.EtherealPlayers)
							{
								string selectedColor = etherealPlayer.Value.SelectedColor;
								Terminal context3 = args.Context;
								if (context3 != null)
								{
									context3.AddString("  " + etherealPlayer.Key + " - Aura: " + selectedColor);
								}
							}
							Terminal context4 = args.Context;
							if (context4 != null)
							{
								context4.AddString("============================");
							}
						}
					};
					<>c.<>9__1_2 = val3;
					obj3 = (object)val3;
				}
				new ConsoleCommand("listethereals", "List all Ethereal players", (ConsoleEvent)obj3, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj4 = <>c.<>9__1_3;
				if (obj4 == null)
				{
					ConsoleEvent val4 = delegate
					{
						HandleEtherealCommand();
					};
					<>c.<>9__1_3 = val4;
					obj4 = (object)val4;
				}
				new ConsoleCommand("ethereal", "Open Ethereal aura selection menu", (ConsoleEvent)obj4, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				_commandsRegistered = true;
				EtherealPlugin.Log.LogInfo((object)"Ethereal console commands registered!");
			}
			catch (Exception ex)
			{
				EtherealPlugin.Log.LogError((object)("Failed to register commands: " + ex.Message));
			}
		}

		private static bool IsAdmin()
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return true;
			}
			if (ZNet.instance.IsServer())
			{
				return true;
			}
			return ZNet.instance.LocalPlayerIsAdminOrHost();
		}

		private static void BroadcastEtherealChange(string playerName, bool added)
		{
			EtherealPlugin.Log.LogInfo((object)$"BroadcastEtherealChange called: {playerName}, added={added}");
			if (ZRoutedRpc.instance == null)
			{
				EtherealPlugin.Log.LogWarning((object)"ZRoutedRpc.instance is null, cannot broadcast");
				return;
			}
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				EtherealPlugin.Log.LogWarning((object)"ZNet.instance is null, cannot broadcast");
				return;
			}
			string text = (added ? "None" : "");
			if (added)
			{
				EtherealPlayerData etherealData = EtherealPlugin.GetEtherealData(playerName);
				if (etherealData != null)
				{
					text = etherealData.SelectedColor;
				}
			}
			EtherealPlugin.Log.LogInfo((object)$"Broadcasting ethereal change: {playerName} -> '{text}' (added={added})");
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Ethereal_SyncColor", new object[2] { playerName, text });
			if (ZNet.instance.IsServer())
			{
				EtherealPlugin.Log.LogInfo((object)"Server: Also updating local ethereal data");
			}
		}

		public static void HandleEtherealCommand()
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				EtherealPlugin.Log.LogWarning((object)"No local player for ethereal command");
				return;
			}
			string playerName = Player.m_localPlayer.GetPlayerName();
			EtherealPlugin.Log.LogInfo((object)("Ethereal command called by '" + playerName + "'"));
			EtherealPlugin.Log.LogInfo((object)$"Current ethereal players: {EtherealPlugin.EtherealPlayers.Count}");
			foreach (KeyValuePair<string, EtherealPlayerData> etherealPlayer in EtherealPlugin.EtherealPlayers)
			{
				EtherealPlugin.Log.LogInfo((object)("  - '" + etherealPlayer.Key + "' (color: " + etherealPlayer.Value.SelectedColor + ")"));
			}
			bool flag = EtherealPlugin.IsEthereal(playerName);
			EtherealPlugin.Log.LogInfo((object)$"Is '{playerName}' ethereal? {flag}");
			if (!flag)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, "You don't have Ethereal status.\nThis is a special feature for supporters!", 0, (Sprite)null);
				return;
			}
			EtherealPlugin.ShowColorMenu = true;
			EtherealPlugin.Log.LogInfo((object)"Opening Ethereal menu");
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	public static class Terminal_InitTerminal_Patch
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			CommandHandler.RegisterCommands();
		}
	}
	public class ChatCommandMonitor : MonoBehaviour
	{
		private static ChatCommandMonitor _instance;

		public static void Initialize()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (!((Object)(object)_instance != (Object)null))
			{
				GameObject val = new GameObject("EtherealChatMonitor");
				_instance = val.AddComponent<ChatCommandMonitor>();
				Object.DontDestroyOnLoad((Object)(object)val);
				EtherealPlugin.Log.LogInfo((object)"Chat command monitor initialized");
			}
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
			{
				CheckChatInput();
			}
		}

		private void CheckChatInput()
		{
			try
			{
				if ((Object)(object)Chat.instance == (Object)null)
				{
					return;
				}
				Type typeFromHandle = typeof(Chat);
				FieldInfo field = typeFromHandle.GetField("m_input", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field == null)
				{
					return;
				}
				object value = field.GetValue(Chat.instance);
				if (value == null)
				{
					return;
				}
				PropertyInfo property = value.GetType().GetProperty("text");
				if (!(property == null))
				{
					string text = property.GetValue(value) as string;
					if (!string.IsNullOrEmpty(text) && text.Trim().Equals("/ethereal", StringComparison.OrdinalIgnoreCase))
					{
						EtherealPlugin.Log.LogInfo((object)"Detected /ethereal in chat!");
						property.SetValue(value, "");
						CommandHandler.HandleEtherealCommand();
					}
				}
			}
			catch
			{
			}
		}
	}
	[BepInPlugin("com.aurora.ethereal", "Ethereal", "1.0.0")]
	public class EtherealPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.aurora.ethereal";

		public const string PluginName = "Ethereal";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		public static Dictionary<string, EtherealPlayerData> EtherealPlayers = new Dictionary<string, EtherealPlayerData>();

		public static bool ShowColorMenu = false;

		private Rect _menuRect;

		private Vector2 _scrollPosition;

		private bool _menuInitialized = false;

		public static readonly Dictionary<string, Color> AuraColors = new Dictionary<string, Color>
		{
			{
				"None",
				Color.clear
			},
			{
				"Crimson",
				new Color(0.86f, 0.08f, 0.24f)
			},
			{
				"Scarlet",
				new Color(1f, 0.14f, 0f)
			},
			{
				"Orange",
				new Color(1f, 0.5f, 0f)
			},
			{
				"Gold",
				new Color(1f, 0.84f, 0f)
			},
			{
				"Yellow",
				new Color(1f, 1f, 0.2f)
			},
			{
				"Lime",
				new Color(0.5f, 1f, 0f)
			},
			{
				"Emerald",
				new Color(0.31f, 0.78f, 0.47f)
			},
			{
				"Jade",
				new Color(0f, 0.66f, 0.42f)
			},
			{
				"Cyan",
				new Color(0f, 1f, 1f)
			},
			{
				"Azure",
				new Color(0f, 0.5f, 1f)
			},
			{
				"Sapphire",
				new Color(0.06f, 0.32f, 0.73f)
			},
			{
				"Violet",
				new Color(0.54f, 0.17f, 0.89f)
			},
			{
				"Purple",
				new Color(0.63f, 0.13f, 0.94f)
			},
			{
				"Magenta",
				new Color(1f, 0f, 1f)
			},
			{
				"Rose",
				new Color(1f, 0.08f, 0.58f)
			},
			{
				"Pink",
				new Color(1f, 0.41f, 0.71f)
			},
			{
				"White",
				new Color(1f, 1f, 1f)
			},
			{
				"Silver",
				new Color(0.75f, 0.75f, 0.75f)
			},
			{
				"Ethereal Blue",
				new Color(0.4f, 0.8f, 1f)
			},
			{
				"Ethereal Green",
				new Color(0.4f, 1f, 0.8f)
			},
			{
				"Ethereal Purple",
				new Color(0.8f, 0.4f, 1f)
			},
			{
				"Rainbow",
				Color.white
			}
		};

		public static EtherealPlugin Instance { get; private set; }

		public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		private static string DataFilePath => Path.Combine(Paths.ConfigPath, "Ethereal_Players.txt");

		private void Awake()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			Instance = this;
			_harmony = new Harmony("com.aurora.ethereal");
			_harmony.PatchAll();
			LoadEtherealData();
			ChatCommandMonitor.Initialize();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Ethereal v1.0.0 loaded!");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			SaveEtherealData();
		}

		private void Update()
		{
			if (ShowColorMenu && Input.GetKeyDown((KeyCode)27))
			{
				ShowColorMenu = false;
				Cursor.lockState = (CursorLockMode)1;
				Cursor.visible = false;
			}
		}

		private void OnGUI()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (ShowColorMenu && !((Object)(object)Player.m_localPlayer == (Object)null))
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
				if (!_menuInitialized)
				{
					_menuRect = new Rect((float)(Screen.width / 2 - 200), (float)(Screen.height / 2 - 250), 400f, 500f);
					_menuInitialized = true;
				}
				GUI.backgroundColor = new Color(0.1f, 0.1f, 0.15f, 0.95f);
				_menuRect = GUI.Window(98765, _menuRect, new WindowFunction(DrawColorMenu), "Ethereal Aura Selection");
			}
		}

		private void DrawColorMenu(int windowID)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00ef: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Space(10f);
			GUIStyle val = new GUIStyle(GUI.skin.label);
			val.alignment = (TextAnchor)4;
			val.fontSize = 14;
			val.fontStyle = (FontStyle)1;
			val.normal.textColor = new Color(0.8f, 0.9f, 1f);
			GUILayout.Label("Select your aura color:", val, Array.Empty<GUILayoutOption>());
			GUILayout.Space(10f);
			string playerName = Player.m_localPlayer.GetPlayerName();
			string text = "None";
			EtherealPlayerData etherealData = GetEtherealData(playerName);
			if (etherealData != null)
			{
				text = etherealData.SelectedColor;
			}
			Color color = Color.white;
			if (AuraColors.TryGetValue(text, out var value))
			{
				color = value;
			}
			GUIStyle val2 = new GUIStyle(GUI.skin.label);
			val2.richText = true;
			val2.alignment = (TextAnchor)4;
			GUILayout.Label("Current: <color=#" + ColorToHex(color) + ">" + text + "</color>", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Space(10f);
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(350f) });
			int num = 2;
			int num2 = 0;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			foreach (KeyValuePair<string, Color> auraColor in AuraColors)
			{
				if (num2 >= num)
				{
					GUILayout.EndHorizontal();
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					num2 = 0;
				}
				Color backgroundColor = ((auraColor.Key == "None") ? Color.gray : auraColor.Value);
				GUI.backgroundColor = backgroundColor;
				string text2 = auraColor.Key;
				if (auraColor.Key == text)
				{
					text2 = "> " + auraColor.Key + " <";
				}
				if (GUILayout.Button(text2, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(180f),
					GUILayout.Height(35f)
				}))
				{
					SelectAuraColor(auraColor.Key);
				}
				num2++;
			}
			GUILayout.EndHorizontal();
			GUILayout.EndScrollView();
			GUI.backgroundColor = new Color(0.1f, 0.1f, 0.15f, 0.95f);
			GUILayout.Space(10f);
			GUI.backgroundColor = new Color(0.6f, 0.2f, 0.2f);
			if (GUILayout.Button("Close", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				ShowColorMenu = false;
				Cursor.lockState = (CursorLockMode)1;
				Cursor.visible = false;
			}
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
		}

		private void SelectAuraColor(string colorName)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			string playerName = Player.m_localPlayer.GetPlayerName();
			if (!IsEthereal(playerName))
			{
				Log.LogWarning((object)("Player '" + playerName + "' is not in Ethereal list!"));
				return;
			}
			string normalizedPlayerName = GetNormalizedPlayerName(playerName);
			EtherealPlayers[normalizedPlayerName].SelectedColor = colorName;
			SaveEtherealData();
			AuraManager.ApplyAura(Player.m_localPlayer, colorName);
			SyncEtherealData(normalizedPlayerName, colorName);
			string text = ((colorName == "None") ? "Your Ethereal aura has been removed." : ("Your Ethereal aura is now " + colorName + "!"));
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false);
			}
			Log.LogInfo((object)("Player '" + normalizedPlayerName + "' selected aura color: " + colorName));
		}

		public static string ColorToHex(Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ColorUtility.ToHtmlStringRGB(color);
		}

		public static Color GetAuraColor(string colorName)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0013: 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)
			if (AuraColors.TryGetValue(colorName, out var value))
			{
				return value;
			}
			return Color.white;
		}

		public static void LoadEtherealData()
		{
			try
			{
				EtherealPlayers.Clear();
				if (!File.Exists(DataFilePath))
				{
					return;
				}
				string[] array = File.ReadAllLines(DataFilePath);
				string[] array2 = array;
				foreach (string text in array2)
				{
					if (!string.IsNullOrWhiteSpace(text))
					{
						string[] array3 = text.Split(new char[1] { '|' });
						if (array3.Length >= 2)
						{
							string text2 = array3[0].Trim();
							string selectedColor = array3[1].Trim();
							EtherealPlayers[text2] = new EtherealPlayerData
							{
								PlayerName = text2,
								SelectedColor = selectedColor
							};
						}
					}
				}
				Log.LogInfo((object)$"Loaded {EtherealPlayers.Count} Ethereal players from file.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to load Ethereal data: " + ex.Message));
			}
		}

		public static void SaveEtherealData()
		{
			try
			{
				List<string> list = new List<string>();
				foreach (KeyValuePair<string, EtherealPlayerData> etherealPlayer in EtherealPlayers)
				{
					list.Add(etherealPlayer.Value.PlayerName + "|" + etherealPlayer.Value.SelectedColor);
				}
				File.WriteAllLines(DataFilePath, list);
				Log.LogInfo((object)$"Saved {EtherealPlayers.Count} Ethereal players to file.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to save Ethereal data: " + ex.Message));
			}
		}

		public static bool AddEtherealPlayer(string playerName)
		{
			playerName = playerName?.Trim();
			if (string.IsNullOrEmpty(playerName))
			{
				return false;
			}
			if (IsEthereal(playerName))
			{
				return false;
			}
			EtherealPlayers[playerName] = new EtherealPlayerData
			{
				PlayerName = playerName,
				SelectedColor = "None"
			};
			SaveEtherealData();
			Log.LogInfo((object)("Added '" + playerName + "' to Ethereal players."));
			return true;
		}

		public static bool RemoveEtherealPlayer(string playerName)
		{
			playerName = playerName?.Trim();
			if (string.IsNullOrEmpty(playerName))
			{
				return false;
			}
			string text = null;
			foreach (string key in EtherealPlayers.Keys)
			{
				if (key.Equals(playerName, StringComparison.OrdinalIgnoreCase))
				{
					text = key;
					break;
				}
			}
			if (text == null)
			{
				return false;
			}
			EtherealPlayers.Remove(text);
			SaveEtherealData();
			Player val = FindPlayerByName(playerName);
			if ((Object)(object)val != (Object)null)
			{
				AuraManager.RemoveAura(val);
			}
			Log.LogInfo((object)("Removed '" + text + "' from Ethereal players."));
			return true;
		}

		public static Player FindPlayerByName(string name)
		{
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (allPlayer.GetPlayerName().Equals(name, StringComparison.OrdinalIgnoreCase))
				{
					return allPlayer;
				}
			}
			return null;
		}

		public static bool IsEthereal(string playerName)
		{
			foreach (string key in EtherealPlayers.Keys)
			{
				if (key.Equals(playerName, StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		public static EtherealPlayerData GetEtherealData(string playerName)
		{
			foreach (KeyValuePair<string, EtherealPlayerData> etherealPlayer in EtherealPlayers)
			{
				if (etherealPlayer.Key.Equals(playerName, StringComparison.OrdinalIgnoreCase))
				{
					return etherealPlayer.Value;
				}
			}
			return null;
		}

		public static string GetNormalizedPlayerName(string playerName)
		{
			foreach (string key in EtherealPlayers.Keys)
			{
				if (key.Equals(playerName, StringComparison.OrdinalIgnoreCase))
				{
					return key;
				}
			}
			return playerName;
		}

		private void SyncEtherealData(string playerName, string colorName)
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				Log.LogWarning((object)"SyncEtherealData: ZNet.instance is null");
				return;
			}
			if (ZRoutedRpc.instance == null)
			{
				Log.LogWarning((object)"SyncEtherealData: ZRoutedRpc.instance is null");
				return;
			}
			Log.LogInfo((object)("SyncEtherealData: Broadcasting " + playerName + " -> " + colorName));
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Ethereal_SyncColor", new object[2] { playerName, colorName });
		}

		public static void RegisterRPCs()
		{
			if (ZRoutedRpc.instance == null)
			{
				Log.LogWarning((object)"RegisterRPCs: ZRoutedRpc.instance is null!");
				return;
			}
			ZRoutedRpc.instance.Register<string, string>("Ethereal_SyncColor", (Action<long, string, string>)RPC_SyncColor);
			ZRoutedRpc.instance.Register<string>("Ethereal_RequestData", (Action<long, string>)RPC_RequestData);
			ZRoutedRpc.instance.Register<string>("Ethereal_SendAllData", (Action<long, string>)RPC_ReceiveAllData);
			Log.LogInfo((object)"Ethereal RPCs registered.");
		}

		public static void RequestDataFromServer()
		{
			if (ZRoutedRpc.instance == null)
			{
				Log.LogWarning((object)"RequestDataFromServer: ZRoutedRpc.instance is null");
				return;
			}
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				Log.LogWarning((object)"RequestDataFromServer: ZNet.instance is null");
				return;
			}
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				Log.LogWarning((object)"RequestDataFromServer: No local player");
				return;
			}
			string playerName = Player.m_localPlayer.GetPlayerName();
			Log.LogInfo((object)("Requesting ethereal data from server for " + playerName));
			ZNetPeer serverPeer = ZNet.instance.GetServerPeer();
			if (serverPeer != null)
			{
				long uid = serverPeer.m_uid;
				Log.LogInfo((object)$"Sending request to server peer {uid}");
				ZRoutedRpc.instance.InvokeRoutedRPC(uid, "Ethereal_RequestData", new object[1] { playerName });
			}
			else
			{
				Log.LogInfo((object)"No server peer found, we might be the server");
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Ethereal_RequestData", new object[1] { playerName });
			}
		}

		private static void RPC_SyncColor(long sender, string playerName, string colorName)
		{
			Log.LogInfo((object)$"RPC_SyncColor received: {playerName} -> '{colorName}' from sender {sender}");
			if (string.IsNullOrEmpty(colorName))
			{
				string text = null;
				foreach (string key in EtherealPlayers.Keys)
				{
					if (key.Equals(playerName, StringComparison.OrdinalIgnoreCase))
					{
						text = key;
						break;
					}
				}
				if (text != null)
				{
					EtherealPlayers.Remove(text);
					if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
					{
						SaveEtherealData();
					}
					Log.LogInfo((object)("Removed " + text + " from Ethereal list via sync"));
					Player val = FindPlayerByName(playerName);
					if ((Object)(object)val != (Object)null)
					{
						AuraManager.RemoveAura(val);
					}
				}
				return;
			}
			string text2 = null;
			foreach (string key2 in EtherealPlayers.Keys)
			{
				if (key2.Equals(playerName, StringComparison.OrdinalIgnoreCase))
				{
					text2 = key2;
					break;
				}
			}
			if (text2 != null)
			{
				EtherealPlayers[text2].SelectedColor = colorName;
			}
			else
			{
				EtherealPlayers[playerName] = new EtherealPlayerData
				{
					PlayerName = playerName,
					SelectedColor = colorName
				};
			}
			if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
			{
				SaveEtherealData();
			}
			Log.LogInfo((object)$"Updated ethereal data: {playerName} -> {colorName}, total players: {EtherealPlayers.Count}");
			Player val2 = FindPlayerByName(playerName);
			if ((Object)(object)val2 != (Object)null)
			{
				AuraManager.ApplyAura(val2, colorName);
			}
		}

		private static void RPC_RequestData(long sender, string requesterName)
		{
			Log.LogInfo((object)$"RPC_RequestData received from {sender} for {requesterName}");
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				Log.LogInfo((object)"Not server, ignoring request");
				return;
			}
			string text = SerializeAllData();
			Log.LogInfo((object)$"Sending all ethereal data to {sender}: {text}");
			ZRoutedRpc.instance.InvokeRoutedRPC(sender, "Ethereal_SendAllData", new object[1] { text });
		}

		private static void RPC_ReceiveAllData(long sender, string data)
		{
			Log.LogInfo((object)("RPC_ReceiveAllData received: " + data));
			DeserializeAllData(data);
			Log.LogInfo((object)$"After deserialize, ethereal players: {EtherealPlayers.Count}");
			foreach (KeyValuePair<string, EtherealPlayerData> etherealPlayer in EtherealPlayers)
			{
				Log.LogInfo((object)("  - " + etherealPlayer.Key + ": " + etherealPlayer.Value.SelectedColor));
			}
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				string playerName = allPlayer.GetPlayerName();
				EtherealPlayerData etherealData = GetEtherealData(playerName);
				if (etherealData != null)
				{
					AuraManager.ApplyAura(allPlayer, etherealData.SelectedColor);
				}
			}
		}

		private static string SerializeAllData()
		{
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, EtherealPlayerData> etherealPlayer in EtherealPlayers)
			{
				list.Add(etherealPlayer.Key + ":" + etherealPlayer.Value.SelectedColor);
			}
			return string.Join(";", list);
		}

		private static void DeserializeAllData(string data)
		{
			try
			{
				if (string.IsNullOrEmpty(data))
				{
					return;
				}
				string[] array = data.Split(new char[1] { ';' });
				string[] array2 = array;
				foreach (string text in array2)
				{
					string[] array3 = text.Split(new char[1] { ':' });
					if (array3.Length >= 2)
					{
						EtherealPlayers[array3[0]] = new EtherealPlayerData
						{
							PlayerName = array3[0],
							SelectedColor = array3[1]
						};
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to deserialize Ethereal data: " + ex.Message));
			}
		}
	}
	[Serializable]
	public class EtherealPlayerData
	{
		public string PlayerName;

		public string SelectedColor = "None";
	}
	public static class NameColorPatches
	{
		public static readonly Color EtherealShoutColor = new Color(1f, 0.35f, 0f);

		public static string GetColoredName(string originalName)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(originalName))
			{
				return originalName;
			}
			EtherealPlayerData etherealData = EtherealPlugin.GetEtherealData(originalName);
			if (etherealData == null || etherealData.SelectedColor == "None")
			{
				return originalName;
			}
			Color color = EtherealPlugin.GetAuraColor(etherealData.SelectedColor);
			if (etherealData.SelectedColor == "Rainbow")
			{
				float num = Time.time * 0.3f % 1f;
				color = Color.HSVToRGB(num, 0.8f, 1f);
			}
			string text = EtherealPlugin.ColorToHex(color);
			return "<color=#" + text + ">" + originalName + "</color>";
		}

		public static string StripColorTags(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return text;
			}
			string pattern = "<color=[^>]+>|</color>";
			return Regex.Replace(text, pattern, "");
		}

		public static string GetEtherealShoutColorHex()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return EtherealPlugin.ColorToHex(EtherealShoutColor);
		}

		public static void ColorizeTextComponent(Text textComponent)
		{
			if ((Object)(object)textComponent == (Object)null)
			{
				return;
			}
			string text = textComponent.text;
			if (string.IsNullOrEmpty(text) || text.Contains("<color="))
			{
				return;
			}
			foreach (KeyValuePair<string, EtherealPlayerData> etherealPlayer in EtherealPlugin.EtherealPlayers)
			{
				if (etherealPlayer.Value.SelectedColor == "None" || !text.Contains(etherealPlayer.Key))
				{
					continue;
				}
				string coloredName = GetColoredName(etherealPlayer.Key);
				textComponent.text = text.Replace(etherealPlayer.Key, coloredName);
				textComponent.supportRichText = true;
				break;
			}
		}

		public static string ColorizeString(string text)
		{
			if (string.IsNullOrEmpty(text) || text.Contains("<color="))
			{
				return text;
			}
			foreach (KeyValuePair<string, EtherealPlayerData> etherealPlayer in EtherealPlugin.EtherealPlayers)
			{
				if (etherealPlayer.Value.SelectedColor == "None" || !text.Contains(etherealPlayer.Key))
				{
					continue;
				}
				return text.Replace(etherealPlayer.Key, GetColoredName(etherealPlayer.Key));
			}
			return text;
		}
	}
	[HarmonyPatch]
	public static class NetworkPatches
	{
		[CompilerGenerated]
		private sealed class <ApplyAllAurasDelayed>d__3 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>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(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					EtherealPlugin.Log.LogInfo((object)"Applying auras to all players after spawn");
					AuraManager.ApplyAurasToAllPlayers();
					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 <ApplyAuraDelayed>d__2 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Player player;

			public string colorName;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>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 ((Object)(object)player != (Object)null)
					{
						AuraManager.ApplyAura(player, colorName);
					}
					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();
			}
		}

		[HarmonyPatch(typeof(ZNet), "Start")]
		[HarmonyPostfix]
		public static void ZNet_Start_Postfix()
		{
			EtherealPlugin.RegisterRPCs();
		}

		[HarmonyPatch(typeof(Player), "OnSpawned")]
		[HarmonyPostfix]
		public static void Player_OnSpawned_Postfix(Player __instance)
		{
			try
			{
				string playerName = __instance.GetPlayerName();
				EtherealPlugin.Log.LogInfo((object)$"Player spawned: {playerName} (local: {(Object)(object)__instance == (Object)(object)Player.m_localPlayer})");
				if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
				{
					EtherealPlugin.RequestDataFromServer();
				}
				EtherealPlayerData etherealData = EtherealPlugin.GetEtherealData(playerName);
				if (etherealData != null && etherealData.SelectedColor != "None")
				{
					EtherealPlugin.Log.LogInfo((object)("Applying aura to " + playerName + " on spawn"));
					((MonoBehaviour)__instance).StartCoroutine(ApplyAuraDelayed(__instance, etherealData.SelectedColor));
				}
				if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
				{
					((MonoBehaviour)__instance).StartCoroutine(ApplyAllAurasDelayed());
				}
			}
			catch (Exception ex)
			{
				EtherealPlugin.Log.LogError((object)("Error in OnSpawned: " + ex.Message));
			}
		}

		[IteratorStateMachine(typeof(<ApplyAuraDelayed>d__2))]
		private static IEnumerator ApplyAuraDelayed(Player player, string colorName)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ApplyAuraDelayed>d__2(0)
			{
				player = player,
				colorName = colorName
			};
		}

		[IteratorStateMachine(typeof(<ApplyAllAurasDelayed>d__3))]
		private static IEnumerator ApplyAllAurasDelayed()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ApplyAllAurasDelayed>d__3(0);
		}

		[HarmonyPatch(typeof(Player), "OnDestroy")]
		[HarmonyPrefix]
		public static void Player_OnDestroy_Prefix(Player __instance)
		{
			AuraManager.RemoveAura(__instance);
		}
	}
	[HarmonyPatch(typeof(Player), "Update")]
	public static class PlayerUpdatePatch
	{
		private static float _lastUpdate;

		private static float _lastAuraCheck;

		[HarmonyPostfix]
		public static void Postfix(Player __instance)
		{
			if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !(Time.time - _lastUpdate < 0.1f))
			{
				_lastUpdate = Time.time;
				AuraManager.UpdateAllAuras();
				AuraManager.CleanupDeadAuras();
				if (Time.time - _lastAuraCheck > 2f)
				{
					_lastAuraCheck = Time.time;
					AuraManager.ApplyAurasToAllPlayers();
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "TakeInput")]
	public static class Player_TakeInput_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Player __instance, ref bool __result)
		{
			if (EtherealPlugin.ShowColorMenu)
			{
				__result = false;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
	public static class GameCamera_UpdateMouseCapture_Patch
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			if (EtherealPlugin.ShowColorMenu)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}
	}
	[HarmonyPatch(typeof(Menu), "IsVisible")]
	public static class Menu_IsVisible_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(ref bool __result)
		{
			if (EtherealPlugin.ShowColorMenu)
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(Chat), "RPC_ChatMessage")]
	public static class Chat_RPC_ChatMessage_Patch
	{
		[HarmonyPrefix]
		public static void Prefix(ref string text, ref int type)
		{
			try
			{
				if (type == 2 && !((Object)(object)Player.m_localPlayer == (Object)null))
				{
					string playerName = Player.m_localPlayer.GetPlayerName();
					EtherealPlayerData etherealData = EtherealPlugin.GetEtherealData(playerName);
					if (etherealData != null && etherealData.SelectedColor != "None")
					{
						EtherealPlugin.Log.LogInfo((object)("Ethereal player " + playerName + " is shouting"));
					}
				}
			}
			catch (Exception ex)
			{
				EtherealPlugin.Log.LogWarning((object)("Error in RPC_ChatMessage patch: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(Chat), "UpdateWorldTexts")]
	public static class Chat_UpdateWorldTexts_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(Chat __instance)
		{
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				FieldInfo field = typeof(Chat).GetField("m_worldTexts", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field == null || !(field.GetValue(__instance) is IList list))
				{
					return;
				}
				foreach (object item in list)
				{
					FieldInfo field2 = item.GetType().GetField("m_type");
					FieldInfo fieldInfo = item.GetType().GetField("m_textMeshField") ?? item.GetType().GetField("m_text");
					FieldInfo field3 = item.GetType().GetField("m_name");
					if (field2 == null || field3 == null)
					{
						continue;
					}
					object value = field2.GetValue(item);
					if (value == null || (int)value != 2)
					{
						continue;
					}
					string text = field3.GetValue(item) as string;
					if (string.IsNullOrEmpty(text))
					{
						continue;
					}
					EtherealPlayerData etherealData = EtherealPlugin.GetEtherealData(text);
					if (etherealData == null || etherealData.SelectedColor == "None" || !(fieldInfo != null))
					{
						continue;
					}
					object value2 = fieldInfo.GetValue(item);
					if (value2 != null)
					{
						PropertyInfo property = value2.GetType().GetProperty("color");
						if (property != null)
						{
							property.SetValue(value2, NameColorPatches.EtherealShoutColor);
						}
					}
				}
			}
			catch
			{
			}
		}
	}
}