Decompiled source of StarlightMagic v1.1.2

plugins/StarlightMagic.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using StarlightMagic.Framework;
using StarlightMagic.Pack;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StarlightMagic")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StarlightMagic")]
[assembly: AssemblyTitle("StarlightMagic")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 StarlightMagic
{
	[BepInPlugin("starlightmagic", "StarlightMagic", "1.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "starlightmagic";

		public const string Name = "StarlightMagic";

		public const string Version = "1.1.2";

		internal static Plugin Instance;

		internal static ConfigEntry<float> BaseEitr;

		internal static ConfigEntry<Color> StarColor;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0073: 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_01f7: Expected O, but got Unknown
			Instance = this;
			string? directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			Loc.Load(directoryName);
			SpellTomes.Init(directoryName);
			BaseEitr = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BaseEitr", 30f, Loc.Cfg("starlight_cfg_base_eitr"));
			StarColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "StarColor", new Color(0.55f, 0.75f, 1f, 1f), Loc.Cfg("starlight_cfg_star_color"));
			StarlightPack.Register(((BaseUnityPlugin)this).Config);
			StatusPack.Register(((BaseUnityPlugin)this).Config);
			SummonPack.Register(((BaseUnityPlugin)this).Config);
			TravelPack.Register(((BaseUnityPlugin)this).Config);
			SpellProgress.Bind(((BaseUnityPlugin)this).Config);
			SpellGrowthTable.Bind(((BaseUnityPlugin)this).Config);
			SpellVfx.Bind(((BaseUnityPlugin)this).Config);
			SpellLoot.Bind(((BaseUnityPlugin)this).Config);
			SpellTrader.Bind(((BaseUnityPlugin)this).Config);
			SpellCommands.Register();
			ConfigFile config = ((BaseUnityPlugin)this).Config;
			KeyCode[] array = new KeyCode[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			SpellSlots.Bind(config, (KeyCode[])(object)array, (KeyCode)117);
			SpellTomes.RegisterTexts();
			SpellLoadout.SetDefaults(new string[4] { "starlight.bolt", "starlight.haste", "starlight.might", "starlight.ioncannon" });
			PrefabManager.OnVanillaPrefabsAvailable += StarlightPack.SetupAssets;
			PrefabManager.OnVanillaPrefabsAvailable += StatusPack.SetupAssets;
			PrefabManager.OnVanillaPrefabsAvailable += SummonPack.SetupAssets;
			PrefabManager.OnVanillaPrefabsAvailable += TravelPack.SetupAssets;
			PrefabManager.OnVanillaPrefabsAvailable += RegisterTomes;
			_harmony = new Harmony("starlightmagic");
			_harmony.PatchAll();
			CleanupConfig();
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded ({2} spells)", "StarlightMagic", "1.1.2", SpellRegistry.All.Count));
		}

		private void CleanupConfig()
		{
			if (typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(((BaseUnityPlugin)this).Config) is IDictionary { Count: >0 } dictionary)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Removed {dictionary.Count} unused config entries");
				dictionary.Clear();
			}
			((BaseUnityPlugin)this).Config.Save();
		}

		private static void RegisterTomes()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterTomes;
			SpellTomes.Register();
			SpellLoot.Apply();
			SpellTrader.Apply();
		}

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
			{
				LoadoutPanel.Close();
				return;
			}
			SpellProgress.EnsureLoaded(localPlayer);
			SpellLoadout.EnsureLoaded(localPlayer);
			LoadoutPanel.ReleaseStuckInput();
			if (LoadoutPanel.IsOpen)
			{
				if (SpellSlots.MenuKeyDown() || Input.GetKeyDown((KeyCode)27))
				{
					LoadoutPanel.Close();
				}
			}
			else if (CanUseInput())
			{
				if (SpellSlots.MenuKeyDown())
				{
					LoadoutPanel.Open();
				}
				else
				{
					SpellSlots.Update(localPlayer);
				}
			}
		}

		private static bool CanUseInput()
		{
			if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus())
			{
				return false;
			}
			if (Console.IsVisible() || TextInput.IsVisible() || Menu.IsVisible())
			{
				return false;
			}
			if (InventoryGui.IsVisible() || Minimap.IsOpen() || StoreGui.IsVisible())
			{
				return false;
			}
			return true;
		}

		internal static void Log(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
		}

		internal static void Warn(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogWarning((object)msg);
		}
	}
	[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
	internal static class BaseEitrPatch
	{
		private static void Postfix(ref float eitr)
		{
			eitr += Plugin.BaseEitr.Value;
		}
	}
	internal static class StarVisuals
	{
		private static Shader _additive;

		private static bool _additiveSearched;

		private static readonly string[] AdditiveShaders = new string[3] { "Legacy Shaders/Particles/Additive", "Mobile/Particles/Additive", "Particles/Standard Unlit" };

		internal static GameObject CloneRecolored(GameObject source, string name, Color tint)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PrefabManager.Instance.CreateClonedPrefab(name, source);
			Recolor(val, tint);
			if ((Object)(object)val.GetComponent<ZNetView>() != (Object)null)
			{
				PrefabManager.Instance.AddPrefab(val);
			}
			return val;
		}

		internal static EffectList RecolorEffects(EffectList source, string namePrefix, Color tint)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			if (source?.m_effectPrefabs == null)
			{
				return source;
			}
			EffectList val = new EffectList
			{
				m_effectPrefabs = (EffectData[])(object)new EffectData[source.m_effectPrefabs.Length]
			};
			for (int i = 0; i < source.m_effectPrefabs.Length; i++)
			{
				EffectData val2 = source.m_effectPrefabs[i];
				EffectData val3 = new EffectData
				{
					m_enabled = val2.m_enabled,
					m_variant = val2.m_variant,
					m_attach = val2.m_attach,
					m_follow = val2.m_follow,
					m_inheritParentRotation = val2.m_inheritParentRotation,
					m_inheritParentScale = val2.m_inheritParentScale,
					m_multiplyParentVisualScale = val2.m_multiplyParentVisualScale,
					m_randomRotation = val2.m_randomRotation,
					m_scale = val2.m_scale,
					m_childTransform = val2.m_childTransform,
					m_prefab = val2.m_prefab
				};
				if ((Object)(object)val2.m_prefab != (Object)null && HasVisuals(val2.m_prefab))
				{
					val3.m_prefab = CloneRecolored(val2.m_prefab, $"{namePrefix}_{i}", tint);
				}
				val.m_effectPrefabs[i] = val3;
			}
			return val;
		}

		private static bool HasVisuals(GameObject go)
		{
			if (!((Object)(object)go.GetComponentInChildren<ParticleSystem>(true) != (Object)null) && !((Object)(object)go.GetComponentInChildren<Light>(true) != (Object)null))
			{
				return (Object)(object)go.GetComponentInChildren<Renderer>(true) != (Object)null;
			}
			return true;
		}

		private static void Recolor(GameObject go, Color tint)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			//IL_001f: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0044: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: 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_01ac: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem[] componentsInChildren = go.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem obj in componentsInChildren)
			{
				MainModule main = obj.main;
				((MainModule)(ref main)).startColor = Tint(((MainModule)(ref main)).startColor, tint);
				ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
				if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
				{
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Tint(((ColorOverLifetimeModule)(ref colorOverLifetime)).color, tint);
				}
				TrailModule trails = obj.trails;
				if (((TrailModule)(ref trails)).enabled)
				{
					((TrailModule)(ref trails)).colorOverLifetime = Tint(((TrailModule)(ref trails)).colorOverLifetime, tint);
				}
			}
			Light[] componentsInChildren2 = go.GetComponentsInChildren<Light>(true);
			foreach (Light obj2 in componentsInChildren2)
			{
				obj2.color = Tint(obj2.color, tint);
			}
			TrailRenderer[] componentsInChildren3 = go.GetComponentsInChildren<TrailRenderer>(true);
			foreach (TrailRenderer obj3 in componentsInChildren3)
			{
				obj3.colorGradient = Tint(obj3.colorGradient, tint);
			}
			LineRenderer[] componentsInChildren4 = go.GetComponentsInChildren<LineRenderer>(true);
			foreach (LineRenderer obj4 in componentsInChildren4)
			{
				obj4.colorGradient = Tint(obj4.colorGradient, tint);
			}
			Renderer[] componentsInChildren5 = go.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren5)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					if ((Object)(object)sharedMaterials[j] == (Object)null)
					{
						continue;
					}
					Material val2 = new Material(sharedMaterials[j]);
					if (val is ParticleSystemRenderer && ((Object)val2.shader).name.Contains("Gradient Mapped") && !MakeAdditive(val2))
					{
						val.enabled = false;
						continue;
					}
					Shader shader = val2.shader;
					for (int k = 0; k < shader.GetPropertyCount(); k++)
					{
						if ((int)shader.GetPropertyType(k) == 0)
						{
							string propertyName = shader.GetPropertyName(k);
							val2.SetColor(propertyName, Tint(val2.GetColor(propertyName), tint));
						}
					}
					sharedMaterials[j] = val2;
				}
				val.sharedMaterials = sharedMaterials;
			}
		}

		private static Shader FindAdditiveShader()
		{
			if (_additiveSearched)
			{
				return _additive;
			}
			_additiveSearched = true;
			string[] additiveShaders = AdditiveShaders;
			foreach (string text in additiveShaders)
			{
				Shader val = Shader.Find(text) ?? FindLoadedShader(text);
				if (!((Object)(object)val == (Object)null))
				{
					_additive = val;
					Plugin.Log("加算用シェーダー: " + ((Object)val).name);
					return _additive;
				}
			}
			_additive = FindAnyAdditiveShader();
			if ((Object)(object)_additive != (Object)null)
			{
				Plugin.Warn("バニラの加算シェーダーが見つからない。代わりに " + ((Object)_additive).name + " を使う(他Mod由来の可能性)");
			}
			else
			{
				Plugin.Warn("加算シェーダーが見つからない。炎の粒子は表示しない");
			}
			return _additive;
		}

		private static Shader FindLoadedShader(string name)
		{
			Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
			foreach (Shader val in array)
			{
				if ((Object)(object)val != (Object)null && ((Object)val).name == name)
				{
					return val;
				}
			}
			return null;
		}

		private static Shader FindAnyAdditiveShader()
		{
			Shader val = null;
			Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
			foreach (Shader val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null) && !((Object)val2).name.Contains("Gradient Mapped"))
				{
					string name = ((Object)val2).name;
					if (name.IndexOf("additive", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return val2;
					}
					if ((Object)(object)val == (Object)null && name.IndexOf("particle", StringComparison.OrdinalIgnoreCase) >= 0 && HasBlendProps(val2))
					{
						val = val2;
					}
				}
			}
			return val;
		}

		private static bool HasBlendProps(Shader shader)
		{
			bool flag = false;
			bool flag2 = false;
			for (int i = 0; i < shader.GetPropertyCount(); i++)
			{
				string propertyName = shader.GetPropertyName(i);
				if (propertyName == "_SrcBlend")
				{
					flag = true;
				}
				if (propertyName == "_DstBlend")
				{
					flag2 = true;
				}
			}
			return flag && flag2;
		}

		private static bool MakeAdditive(Material mat)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			Shader val = FindAdditiveShader();
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Texture mainTexture = mat.mainTexture;
			mat.shader = val;
			mat.mainTexture = mainTexture;
			if (mat.HasProperty("_Mode"))
			{
				mat.SetFloat("_Mode", 4f);
			}
			if (mat.HasProperty("_SrcBlend"))
			{
				mat.SetInt("_SrcBlend", 5);
			}
			if (mat.HasProperty("_DstBlend"))
			{
				mat.SetInt("_DstBlend", 1);
			}
			if (mat.HasProperty("_ZWrite"))
			{
				mat.SetInt("_ZWrite", 0);
			}
			if (mat.HasProperty("_TintColor"))
			{
				mat.SetColor("_TintColor", new Color(0.5f, 0.5f, 0.5f, 0.5f));
			}
			mat.renderQueue = 3000;
			return true;
		}

		internal static void Dump(GameObject go)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Invalid comparison between Unknown and I4
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log("[dump] " + ((Object)go).name);
			ParticleSystem[] componentsInChildren = go.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val in componentsInChildren)
			{
				MainModule main = val.main;
				object[] obj = new object[4]
				{
					Path(((Component)val).transform, go.transform),
					null,
					null,
					null
				};
				MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
				obj[1] = ((MinMaxGradient)(ref startColor)).mode;
				ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime;
				obj[2] = ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled;
				TrailModule trails = val.trails;
				obj[3] = ((TrailModule)(ref trails)).enabled;
				Plugin.Log(string.Format("[dump]  PS {0} start={1} col={2} trails={3}", obj));
			}
			Light[] componentsInChildren2 = go.GetComponentsInChildren<Light>(true);
			foreach (Light val2 in componentsInChildren2)
			{
				Plugin.Log($"[dump]  Light {Path(((Component)val2).transform, go.transform)} {val2.color}");
			}
			Renderer[] componentsInChildren3 = go.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val3 in componentsInChildren3)
			{
				Material[] sharedMaterials = val3.sharedMaterials;
				foreach (Material val4 in sharedMaterials)
				{
					if ((Object)(object)val4 == (Object)null)
					{
						continue;
					}
					StringBuilder stringBuilder = new StringBuilder();
					Shader shader = val4.shader;
					for (int k = 0; k < shader.GetPropertyCount(); k++)
					{
						ShaderPropertyType propertyType = shader.GetPropertyType(k);
						string propertyName = shader.GetPropertyName(k);
						if ((int)propertyType == 0)
						{
							stringBuilder.Append($" {propertyName}={val4.GetColor(propertyName)}");
						}
						else if ((int)propertyType == 4)
						{
							stringBuilder.Append(" " + propertyName + "=tex:" + (((Object)(object)val4.GetTexture(propertyName) != (Object)null) ? ((Object)val4.GetTexture(propertyName)).name : "-"));
						}
					}
					Plugin.Log($"[dump]  {((object)val3).GetType().Name} {Path(((Component)val3).transform, go.transform)} mat={((Object)val4).name} shader={((Object)shader).name}{stringBuilder}");
				}
			}
		}

		private static string Path(Transform t, Transform root)
		{
			string text = ((Object)t).name;
			while ((Object)(object)t != (Object)(object)root && (Object)(object)t.parent != (Object)null)
			{
				t = t.parent;
				text = ((Object)t).name + "/" + text;
			}
			return text;
		}

		private static Color Tint(Color c, Color tint)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(c.r, Mathf.Max(c.g, c.b));
			return new Color(tint.r * num, tint.g * num, tint.b * num, c.a);
		}

		private static Gradient Tint(Gradient g, Color tint)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			if (g == null)
			{
				return null;
			}
			GradientColorKey[] colorKeys = g.colorKeys;
			for (int i = 0; i < colorKeys.Length; i++)
			{
				colorKeys[i].color = Tint(colorKeys[i].color, tint);
			}
			Gradient val = new Gradient
			{
				mode = g.mode
			};
			val.SetKeys(colorKeys, g.alphaKeys);
			return val;
		}

		private static MinMaxGradient Tint(MinMaxGradient m, Color tint)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			//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_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_0061: 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_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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			//IL_0054: 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)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystemGradientMode mode = ((MinMaxGradient)(ref m)).mode;
			switch ((int)mode)
			{
			case 0:
				return new MinMaxGradient(Tint(((MinMaxGradient)(ref m)).color, tint));
			case 2:
				return new MinMaxGradient(Tint(((MinMaxGradient)(ref m)).colorMin, tint), Tint(((MinMaxGradient)(ref m)).colorMax, tint));
			case 1:
				return new MinMaxGradient(Tint(((MinMaxGradient)(ref m)).gradient, tint));
			case 3:
				return new MinMaxGradient(Tint(((MinMaxGradient)(ref m)).gradientMin, tint), Tint(((MinMaxGradient)(ref m)).gradientMax, tint));
			case 4:
			{
				MinMaxGradient result = default(MinMaxGradient);
				((MinMaxGradient)(ref result))..ctor(Tint(((MinMaxGradient)(ref m)).gradient, tint));
				((MinMaxGradient)(ref result)).mode = (ParticleSystemGradientMode)4;
				return result;
			}
			default:
				return m;
			}
		}
	}
}
namespace StarlightMagic.Pack
{
	internal static class IonCannon
	{
		private const float BeamHeight = 150f;

		private static readonly List<GameObject> _burstPrefabs = new List<GameObject>();

		private static Material _beamMaterial;

		private static bool _busy;

		internal const string VisualKey = "ioncannon";

		private const float VisualDistance = 600f;

		internal static void SetupAssets(Projectile boltProjectile, Color tint)
		{
			//IL_002d: 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)
			_burstPrefabs.Clear();
			if ((Object)(object)boltProjectile == (Object)null)
			{
				return;
			}
			if ((Object)(object)boltProjectile.m_spawnOnHit != (Object)null)
			{
				AddBurst(boltProjectile.m_spawnOnHit, "IonCannon_burst", tint);
			}
			EffectData[] array = boltProjectile.m_hitEffects?.m_effectPrefabs;
			if (array != null)
			{
				for (int i = 0; i < array.Length; i++)
				{
					if ((Object)(object)array[i]?.m_prefab != (Object)null)
					{
						AddBurst(array[i].m_prefab, $"IonCannon_hit_{i}", tint);
					}
				}
			}
			Plugin.Log($"イオンカノン: 爆発エフェクト {_burstPrefabs.Count} 個を用意");
		}

		private static void AddBurst(GameObject source, string name, Color tint)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PrefabManager.Instance.CreateClonedPrefab(name, source);
			Aoe[] componentsInChildren = val.GetComponentsInChildren<Aoe>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			ZNetView[] componentsInChildren2 = val.GetComponentsInChildren<ZNetView>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			Collider[] componentsInChildren3 = val.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
			}
			ParticleSystem[] componentsInChildren4 = val.GetComponentsInChildren<ParticleSystem>(true);
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				MainModule main = componentsInChildren4[i].main;
				((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
			}
			_burstPrefabs.Add(val);
		}

		internal static bool Cast(Player player, SpellCast cast)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (_busy)
			{
				cast.Fail(Loc.T("starlight_msg_ion_busy"));
				return false;
			}
			if (!TryGetTarget(StarlightPack.IonRange.Value, out var point))
			{
				cast.Fail(Loc.T("starlight_msg_no_target"));
				return false;
			}
			if (!cast.TrySpend())
			{
				return false;
			}
			float num = StarlightPack.IonRadius.Value * cast.Extent;
			float damage = StarlightPack.IonDamage.Value * cast.Magnitude;
			float value = StarlightPack.IonBeamWidth.Value;
			float value2 = StarlightPack.IonChargeTime.Value;
			if (!SpellNet.Broadcast("ioncannon", point, new Vector3(num, value, value2)))
			{
				Play(point, num, value, value2);
			}
			_busy = true;
			((MonoBehaviour)Plugin.Instance).StartCoroutine(DealDamage(player, point, damage, num, value2));
			return true;
		}

		internal static void RegisterNet()
		{
			SpellNet.Handle("ioncannon", delegate(Vector3 pos, Vector3 v)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: 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)
				Play(pos, v.x, v.y, v.z);
			});
		}

		private static void Play(Vector3 target, float radius, float width, float charge)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer != (Object)null) || !(Vector3.Distance(((Component)localPlayer).transform.position, target) > 600f))
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(Fire(target, radius, width, charge));
			}
		}

		private static IEnumerator DealDamage(Player caster, Vector3 target, float damage, float radius, float charge)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(charge);
			DamageArea(caster, target, radius, damage, friendlyFire: true, StarlightPack.IonDamageBuildings.Value, 80f, 3f, "ioncannon");
			yield return (object)new WaitForSeconds(0.6f);
			_busy = false;
		}

		internal static bool TryGetTarget(float range, out Vector3 point)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			//IL_0062: 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)
			Transform transform = ((Component)GameCamera.instance).transform;
			int mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" });
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(transform.position, transform.forward, ref val, range, mask, (QueryTriggerInteraction)1))
			{
				point = ((RaycastHit)(ref val)).point;
				return true;
			}
			point = Vector3.zero;
			return false;
		}

		private static IEnumerator Fire(Vector3 target, float radius, float width, float charge)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Color value = Plugin.StarColor.Value;
			GameObject root = new GameObject("StarlightIonCannon");
			root.transform.position = target;
			Renderer marker = CreateCylinder(root.transform, "marker", new Color(value.r, value.g, value.b, 0.35f));
			Renderer beam = CreateCylinder(root.transform, "beam", new Color(value.r, value.g, value.b, 0.55f));
			Renderer core = CreateCylinder(root.transform, "core", new Color(1f, 1f, 1f, 0.8f));
			Light light = new GameObject("light").AddComponent<Light>();
			((Component)light).transform.SetParent(root.transform, false);
			((Component)light).transform.localPosition = Vector3.up * 3f;
			light.type = (LightType)2;
			light.color = value;
			light.range = radius * 2.5f;
			light.intensity = 0f;
			IonSounds.PlayCharge(target);
			for (float t = 0f; t < charge; t += Time.deltaTime)
			{
				float num = t / charge;
				float num2 = 1f + Mathf.Sin(t * 12f) * 0.05f;
				SetCylinder(marker, radius * 2f * num2, 0.05f, 0.05f);
				SetCylinder(beam, Mathf.Lerp(0.3f, width, num * num), 150f, 75f);
				SetCylinder(core, Mathf.Lerp(0.1f, width * 0.35f, num * num), 150f, 75f);
				light.intensity = Mathf.Lerp(0.5f, 4f, num);
				GameCamera instance = GameCamera.instance;
				if (instance != null)
				{
					instance.AddShake(target, radius * 4f, num * 0.6f, false);
				}
				yield return null;
			}
			Explode(target, radius);
			for (float t = 0f; t < 0.6f; t += Time.deltaTime)
			{
				float num3 = 1f - t / 0.6f;
				SetCylinder(beam, width * 2.5f * num3 + 0.01f, 150f, 75f);
				SetCylinder(core, width * 1.2f * num3 + 0.01f, 150f, 75f);
				SetCylinder(marker, radius * 2f, 0.05f, 0.05f);
				SetAlpha(marker, 0.35f * num3);
				light.intensity = 12f * num3;
				yield return null;
			}
			Object.Destroy((Object)(object)root);
		}

		private static void Explode(Vector3 center, float radius)
		{
			//IL_000b: 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_002c: 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_005d: 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_006d: 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)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			GameCamera instance = GameCamera.instance;
			if (instance != null)
			{
				instance.AddShake(center, radius * 6f, 3f, false);
			}
			IonSounds.PlayImpact(center);
			float num = radius / 3f;
			SpawnBurst(center, num);
			for (int i = 0; i < 6; i++)
			{
				float num2 = (float)i * MathF.PI / 3f;
				Vector3 val = new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * radius * 0.6f;
				SpawnBurst(center + val, num * 0.5f);
			}
		}

		internal static void SpawnBurst(Vector3 pos, float scale)
		{
			//IL_0016: 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_002e: 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)
			foreach (GameObject burstPrefab in _burstPrefabs)
			{
				GameObject val = Object.Instantiate<GameObject>(burstPrefab, pos, Quaternion.identity);
				val.transform.localScale = burstPrefab.transform.localScale * scale;
				Light[] componentsInChildren = val.GetComponentsInChildren<Light>(true);
				foreach (Light obj in componentsInChildren)
				{
					obj.range *= scale;
				}
				Object.Destroy((Object)(object)val, 10f);
			}
		}

		internal static void DamageArea(Player caster, Vector3 center, float radius, float damage, bool friendlyFire, bool buildings, float push, float stagger, string label)
		{
			//IL_000c: 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_0067: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			HashSet<Character> hashSet = new HashSet<Character>();
			HashSet<IDestructible> hashSet2 = new HashSet<IDestructible>();
			Collider[] array = Physics.OverlapSphere(center, radius, -1, (QueryTriggerInteraction)2);
			foreach (Collider val in array)
			{
				Character componentInParent = ((Component)val).GetComponentInParent<Character>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					if (hashSet.Add(componentInParent) && (friendlyFire || (!((Object)(object)componentInParent == (Object)(object)caster) && BaseAI.IsEnemy((Character)(object)caster, componentInParent))))
					{
						HitData val2 = BuildHit(componentInParent.GetCenterPoint(), center, radius, damage, push, stagger);
						if (!(componentInParent is Player))
						{
							val2.SetAttacker((Character)(object)caster);
						}
						componentInParent.Damage(val2);
					}
				}
				else
				{
					IDestructible componentInParent2 = ((Component)val).GetComponentInParent<IDestructible>();
					if (componentInParent2 != null && hashSet2.Add(componentInParent2) && (!(componentInParent2 is WearNTear) || buildings))
					{
						HitData val3 = BuildHit(ClosestPoint(val, center), center, radius, damage, push, stagger);
						val3.m_toolTier = 4;
						val3.SetAttacker((Character)(object)caster);
						componentInParent2.Damage(val3);
					}
				}
			}
			Plugin.Log($"{label}: キャラクター {hashSet.Count} / 物体 {hashSet2.Count} が範囲内");
		}

		private static Vector3 ClosestPoint(Collider col, Vector3 point)
		{
			//IL_0023: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			MeshCollider val = (MeshCollider)(object)((col is MeshCollider) ? col : null);
			if (val != null && !val.convex)
			{
				Bounds bounds = col.bounds;
				return ((Bounds)(ref bounds)).ClosestPoint(point);
			}
			return col.ClosestPoint(point);
		}

		private static HitData BuildHit(Vector3 pos, Vector3 center, float radius, float damage, float push, float stagger)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			//IL_0050: 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_0058: 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_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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			float num = Vector3.Distance(pos, center);
			float num2 = Mathf.Lerp(1f, 0.35f, Mathf.Clamp01(num / radius));
			float num3 = damage * num2;
			HitData val = new HitData
			{
				m_point = pos
			};
			Vector3 val2 = pos - center;
			Vector3 dir;
			if (!(((Vector3)(ref val2)).sqrMagnitude > 0.01f))
			{
				dir = Vector3.up;
			}
			else
			{
				val2 = pos - center;
				dir = ((Vector3)(ref val2)).normalized;
			}
			val.m_dir = dir;
			val.m_damage.m_blunt = num3 * 0.4f;
			val.m_damage.m_fire = num3 * 0.3f;
			val.m_damage.m_lightning = num3 * 0.3f;
			val.m_damage.m_chop = num3;
			val.m_damage.m_pickaxe = num3;
			val.m_pushForce = push * num2;
			val.m_staggerMultiplier = stagger;
			val.m_blockable = false;
			val.m_dodgeable = false;
			val.m_skill = (SkillType)9;
			return val;
		}

		private static Renderer CreateCylinder(Transform parent, string name, Color color)
		{
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj).name = name;
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			obj.transform.SetParent(parent, false);
			Renderer component = obj.GetComponent<Renderer>();
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
			component.sharedMaterial = new Material(BeamMaterial())
			{
				color = color
			};
			return component;
		}

		private static Material BeamMaterial()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if ((Object)(object)_beamMaterial == (Object)null)
			{
				_beamMaterial = new Material(Shader.Find("Sprites/Default"));
			}
			return _beamMaterial;
		}

		private static void SetCylinder(Renderer r, float diameter, float height, float centerY)
		{
			//IL_000f: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			((Component)r).transform.localScale = new Vector3(diameter, height * 0.5f, diameter);
			((Component)r).transform.localPosition = Vector3.up * centerY;
		}

		private static void SetAlpha(Renderer r, float alpha)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			Color color = r.sharedMaterial.color;
			color.a = alpha;
			r.sharedMaterial.color = color;
		}
	}
	internal static class IonSounds
	{
		private static readonly List<GameObject> _charge = new List<GameObject>();

		private static readonly List<GameObject> _impact = new List<GameObject>();

		private static readonly string[] ChargePreferred = new string[1] { "sfx_staff_lightning_charge" };

		private static readonly string[] ImpactPreferred = new string[3] { "sfx_distant thunder", "sfx_blobLava_explosion", "sfx_fader_meteor_impact" };

		private static readonly string[] ChargeHints = new string[4] { "lightning", "charge", "beam", "magic" };

		private static readonly string[] ImpactHints = new string[4] { "thunder", "explo", "meteor", "boom" };

		internal static void Setup()
		{
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, Object> prefab in Cache.GetPrefabs(typeof(GameObject)))
			{
				if (prefab.Key.StartsWith("sfx_"))
				{
					Object value = prefab.Value;
					GameObject val = (GameObject)(object)((value is GameObject) ? value : null);
					if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponentInChildren<AudioSource>(true) != (Object)null)
					{
						list.Add(prefab.Key);
					}
				}
			}
			list.Sort();
			List<string> list2 = list.Where((string n) => ChargeHints.Concat(ImpactHints).Any((string h) => n.ToLowerInvariant().Contains(h))).ToList();
			Plugin.Log(string.Format("イオンカノン: 音の候補 {0} 件 / 効果音全体 {1} 件: {2}", list2.Count, list.Count, string.Join(", ", list2)));
			Resolve(StarlightPack.IonChargeSounds.Value, list, ChargePreferred, ChargeHints, 1, _charge, "charge");
			Resolve(StarlightPack.IonImpactSounds.Value, list, ImpactPreferred, ImpactHints, 3, _impact, "impact");
		}

		private static void Resolve(string configured, List<string> candidates, string[] preferred, string[] hints, int autoCount, List<GameObject> into, string label)
		{
			into.Clear();
			List<string> names = new List<string>();
			if (!string.IsNullOrWhiteSpace(configured))
			{
				names.AddRange(from n in configured.Split(',')
					select n.Trim() into n
					where n.Length > 0
					select n);
			}
			else if (preferred.All(candidates.Contains))
			{
				names.AddRange(preferred);
			}
			else
			{
				foreach (string hint in hints)
				{
					string text = candidates.FirstOrDefault((string n) => n.ToLowerInvariant().Contains(hint) && !names.Contains(n));
					if (text != null)
					{
						names.Add(text);
					}
					if (names.Count >= autoCount)
					{
						break;
					}
				}
			}
			foreach (string item in names)
			{
				GameObject prefab = Cache.GetPrefab<GameObject>(item);
				if ((Object)(object)prefab != (Object)null)
				{
					into.Add(prefab);
				}
				else
				{
					Plugin.Warn("イオンカノン: 効果音 " + item + " が見つからない");
				}
			}
			Plugin.Log("イオンカノン: " + label + " の音 = " + string.Join(", ", into.Select((GameObject p) => ((Object)p).name)));
		}

		internal static void PlayCharge(Vector3 pos)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Play(_charge, pos);
		}

		internal static void PlayImpact(Vector3 pos)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Play(_impact, pos);
		}

		private static void Play(List<GameObject> prefabs, Vector3 pos)
		{
			//IL_001e: 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)
			float value = StarlightPack.IonSoundDistance.Value;
			foreach (GameObject prefab in prefabs)
			{
				GameObject val = Object.Instantiate<GameObject>(prefab, pos, Quaternion.identity);
				AudioSource[] componentsInChildren = val.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource obj in componentsInChildren)
				{
					obj.maxDistance = Mathf.Max(obj.maxDistance, value);
					obj.minDistance = Mathf.Max(obj.minDistance, value * 0.15f);
					obj.spatialBlend = Mathf.Min(obj.spatialBlend, 0.6f);
					obj.volume = 1f;
				}
				Object.Destroy((Object)(object)val, 15f);
			}
		}
	}
	internal static class StarlightPack
	{
		internal const string BoltId = "starlight.bolt";

		internal const string HasteId = "starlight.haste";

		internal const string MightId = "starlight.might";

		internal const string IonId = "starlight.ioncannon";

		internal const string WardId = "starlight.ward";

		internal const string HealId = "starlight.heal";

		internal const string BurstId = "starlight.burst";

		private const string BorrowStaff = "StaffFireball";

		internal static ConfigEntry<float> StarBoltDamage;

		internal static ConfigEntry<float> HasteSpeed;

		internal static ConfigEntry<float> HasteDuration;

		internal static ConfigEntry<float> MightDamage;

		internal static ConfigEntry<float> MightDuration;

		internal static ConfigEntry<float> WardDuration;

		internal static ConfigEntry<float> HealAmount;

		internal static ConfigEntry<float> BurstDamage;

		internal static ConfigEntry<float> BurstRadius;

		internal static ConfigEntry<float> BurstRange;

		internal static ConfigEntry<float> IonDamage;

		internal static ConfigEntry<float> IonRadius;

		internal static ConfigEntry<float> IonChargeTime;

		internal static ConfigEntry<float> IonRange;

		internal static ConfigEntry<bool> IonDamageBuildings;

		internal static ConfigEntry<float> IonBeamWidth;

		internal static ConfigEntry<string> IonChargeSounds;

		internal static ConfigEntry<string> IonImpactSounds;

		internal static ConfigEntry<float> IonSoundDistance;

		private static SE_Stats _haste;

		private static SE_Stats _might;

		private static SE_Stats _ward;

		private static GameObject _boltProjectile;

		private static EffectList _boltStartEffect;

		private static float _boltVelocity = 20f;

		private static int _aimMask;

		internal static GameObject BoltPrefab => _boltProjectile;

		internal static float BoltVelocity => _boltVelocity;

		internal static void Register(ConfigFile config)
		{
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: 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_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
			StarBoltDamage = config.Bind<float>("StarBolt", "Damage", 25f, Loc.Cfg("starlight_cfg_bolt_damage"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "starlight.bolt",
				NameKey = "starlight_spell_bolt",
				LoreKey = "starlight_lore_bolt",
				School = SpellSchool.Attack,
				Growth = SpellGrowth.Attack,
				EitrCost = Cost(config, "StarBolt", 10f),
				Cooldown = Cooldown(config, "StarBolt", 0.4f),
				OnCast = CastStarBolt
			});
			HasteSpeed = config.Bind<float>("Haste", "SpeedBonus", 0.25f, Loc.Cfg("starlight_cfg_haste_speed"));
			HasteDuration = config.Bind<float>("Haste", "Duration", 60f, Loc.Cfg("starlight_cfg_duration"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "starlight.haste",
				NameKey = "starlight_spell_haste",
				LoreKey = "starlight_lore_haste",
				School = SpellSchool.Buff,
				Growth = SpellGrowth.Buff,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(0.5f, 0.85f, 1f),
				EitrCost = Cost(config, "Haste", 15f),
				Cooldown = Cooldown(config, "Haste", 1f),
				OnCast = CastHaste
			});
			MightDamage = config.Bind<float>("Might", "DamageBonus", 0.25f, Loc.Cfg("starlight_cfg_might_damage"));
			MightDuration = config.Bind<float>("Might", "Duration", 60f, Loc.Cfg("starlight_cfg_duration"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "starlight.might",
				NameKey = "starlight_spell_might",
				LoreKey = "starlight_lore_might",
				School = SpellSchool.Buff,
				Growth = SpellGrowth.Buff,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(1f, 0.45f, 0.35f),
				EitrCost = Cost(config, "Might", 15f),
				Cooldown = Cooldown(config, "Might", 1f),
				OnCast = CastMight
			});
			IonDamage = config.Bind<float>("IonCannon", "Damage", 400f, Loc.Cfg("starlight_cfg_ion_damage"));
			IonRadius = config.Bind<float>("IonCannon", "Radius", 10f, Loc.Cfg("starlight_cfg_radius"));
			IonChargeTime = config.Bind<float>("IonCannon", "ChargeTime", 2.5f, Loc.Cfg("starlight_cfg_ion_charge"));
			IonRange = config.Bind<float>("IonCannon", "Range", 150f, Loc.Cfg("starlight_cfg_range"));
			IonDamageBuildings = config.Bind<bool>("IonCannon", "DamageBuildings", false, Loc.Cfg("starlight_cfg_ion_buildings"));
			IonBeamWidth = config.Bind<float>("IonCannon", "BeamWidth", 6f, Loc.Cfg("starlight_cfg_ion_beam_width"));
			IonChargeSounds = config.Bind<string>("IonCannon", "ChargeSounds", "", Loc.Cfg("starlight_cfg_ion_charge_sounds"));
			IonImpactSounds = config.Bind<string>("IonCannon", "ImpactSounds", "", Loc.Cfg("starlight_cfg_ion_impact_sounds"));
			IonSoundDistance = config.Bind<float>("IonCannon", "SoundDistance", 400f, Loc.Cfg("starlight_cfg_ion_sound_distance"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "starlight.ioncannon",
				NameKey = "starlight_spell_ioncannon",
				LoreKey = "starlight_lore_ioncannon",
				School = SpellSchool.Attack,
				Growth = SpellGrowth.Attack,
				Tier = 3,
				EitrCost = Cost(config, "IonCannon", 25f),
				Cooldown = Cooldown(config, "IonCannon", 3f),
				OnCast = IonCannon.Cast
			});
			IonCannon.RegisterNet();
			WardDuration = config.Bind<float>("Ward", "Duration", 30f, Loc.Cfg("starlight_cfg_ward_duration"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "starlight.ward",
				NameKey = "starlight_spell_ward",
				LoreKey = "starlight_lore_ward",
				School = SpellSchool.Buff,
				Growth = SpellGrowth.Buff,
				Tier = 2,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(0.85f, 0.7f, 0.35f),
				EitrCost = Cost(config, "Ward", 20f),
				Cooldown = Cooldown(config, "Ward", 1f),
				OnCast = CastWard
			});
			HealAmount = config.Bind<float>("Heal", "Amount", 40f, Loc.Cfg("starlight_cfg_heal_amount"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "starlight.heal",
				NameKey = "starlight_spell_heal",
				LoreKey = "starlight_lore_heal",
				School = SpellSchool.Heal,
				Growth = SpellGrowth.Heal,
				Vfx = SpellVfxKind.Pillar,
				VfxColor = new Color(1f, 0.85f, 0.55f),
				EitrCost = Cost(config, "Heal", 20f),
				Cooldown = Cooldown(config, "Heal", 2f),
				OnCast = CastHeal
			});
			BurstDamage = config.Bind<float>("Burst", "Damage", 60f, Loc.Cfg("starlight_cfg_burst_damage"));
			BurstRadius = config.Bind<float>("Burst", "Radius", 4f, Loc.Cfg("starlight_cfg_radius"));
			BurstRange = config.Bind<float>("Burst", "Range", 40f, Loc.Cfg("starlight_cfg_range"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "starlight.burst",
				NameKey = "starlight_spell_burst",
				LoreKey = "starlight_lore_burst",
				School = SpellSchool.Attack,
				Growth = SpellGrowth.Attack,
				Tier = 2,
				EitrCost = Cost(config, "Burst", 20f),
				Cooldown = Cooldown(config, "Burst", 1f),
				OnCast = CastBurst
			});
		}

		private static ConfigEntry<float> Cost(ConfigFile config, string section, float value)
		{
			return config.Bind<float>(section, "EitrCost", value, Loc.Cfg("starlight_cfg_eitr_cost"));
		}

		private static ConfigEntry<float> Cooldown(ConfigFile config, string section, float value)
		{
			return config.Bind<float>(section, "Cooldown", value, Loc.Cfg("starlight_cfg_cooldown"));
		}

		internal static void SetupAssets()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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)
			PrefabManager.OnVanillaPrefabsAvailable -= SetupAssets;
			_haste = CreateBuff("SE_StarlightHaste", "haste", "Feathers");
			_might = CreateBuff("SE_StarlightMight", "might", "TrophyForestTroll");
			_might.m_modifyAttackSkill = (SkillType)999;
			_ward = CreateBuff("SE_StarlightWard", "ward", "ShieldWood");
			_ward.m_mods = new List<DamageModPair>
			{
				new DamageModPair
				{
					m_type = (DamageType)1,
					m_modifier = (DamageModifier)1
				},
				new DamageModPair
				{
					m_type = (DamageType)2,
					m_modifier = (DamageModifier)1
				},
				new DamageModPair
				{
					m_type = (DamageType)4,
					m_modifier = (DamageModifier)1
				}
			};
			SetupStarBolt();
		}

		private static SE_Stats CreateBuff(string id, string key, string iconItem)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = id;
			((StatusEffect)val).m_name = "$starlight_se_" + key;
			((StatusEffect)val).m_tooltip = "$starlight_se_" + key + "_tooltip";
			((StatusEffect)val).m_icon = FindIcon(iconItem);
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false));
			return val;
		}

		private static void SetupStarBolt()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = Cache.GetPrefab<GameObject>("StaffFireball");
			Attack val = ((prefab != null) ? prefab.GetComponent<ItemDrop>() : null)?.m_itemData.m_shared.m_attack;
			if ((Object)(object)val?.m_attackProjectile == (Object)null)
			{
				Plugin.Warn("StaffFireball の弾が見つからない。星の弾は使えない");
				return;
			}
			Color value = Plugin.StarColor.Value;
			_boltVelocity = val.m_projectileVel;
			_boltProjectile = StarVisuals.CloneRecolored(val.m_attackProjectile, "StarlightBolt_projectile", value);
			Projectile component = _boltProjectile.GetComponent<Projectile>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_hitEffects = StarVisuals.RecolorEffects(component.m_hitEffects, "StarlightBolt_hit", value);
				component.m_hitWaterEffects = StarVisuals.RecolorEffects(component.m_hitWaterEffects, "StarlightBolt_hitwater", value);
				if ((Object)(object)component.m_spawnOnHit != (Object)null)
				{
					component.m_spawnOnHit = StarVisuals.CloneRecolored(component.m_spawnOnHit, "StarlightBolt_burst", value);
				}
			}
			_boltStartEffect = StarVisuals.RecolorEffects(val.m_startEffect, "StarlightBolt_cast", value);
			IonCannon.SetupAssets(component, value);
			IonSounds.Setup();
		}

		private static bool CastStarBolt(Player player, SpellCast cast)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0044: 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)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0061: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00ae: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_boltProjectile == (Object)null || !cast.TrySpend())
			{
				return false;
			}
			Vector3 val = ((Character)player).m_eye.position + ((Character)player).m_eye.forward * 0.6f;
			Vector3 val2 = AimDirection(val);
			Quaternion val3 = Quaternion.LookRotation(val2);
			EffectList boltStartEffect = _boltStartEffect;
			if (boltStartEffect != null)
			{
				boltStartEffect.Create(val, val3, (Transform)null, 1f, -1, default(ZDOID));
			}
			IProjectile component = Object.Instantiate<GameObject>(_boltProjectile, val, val3).GetComponent<IProjectile>();
			if (component == null)
			{
				return true;
			}
			HitData val4 = new HitData();
			val4.m_damage.m_fire = StarBoltDamage.Value * cast.Magnitude;
			val4.m_skill = (SkillType)9;
			val4.m_pushForce = 10f;
			val4.SetAttacker((Character)(object)player);
			component.Setup((Character)(object)player, val2 * _boltVelocity, -1f, val4, (ItemData)null, (ItemData)null);
			return true;
		}

		private static bool CastHaste(Player player, SpellCast cast)
		{
			if ((Object)(object)_haste == (Object)null)
			{
				return false;
			}
			((StatusEffect)_haste).m_ttl = HasteDuration.Value * cast.Extent;
			_haste.m_speedModifier = HasteSpeed.Value * cast.Magnitude;
			return ApplyBuff(player, cast, _haste, "Feathers");
		}

		private static bool CastMight(Player player, SpellCast cast)
		{
			if ((Object)(object)_might == (Object)null)
			{
				return false;
			}
			((StatusEffect)_might).m_ttl = MightDuration.Value * cast.Extent;
			_might.m_damageModifier = 1f + MightDamage.Value * cast.Magnitude;
			return ApplyBuff(player, cast, _might, "TrophyForestTroll");
		}

		private static bool CastWard(Player player, SpellCast cast)
		{
			if ((Object)(object)_ward == (Object)null)
			{
				return false;
			}
			((StatusEffect)_ward).m_ttl = WardDuration.Value * cast.Extent;
			return ApplyBuff(player, cast, _ward, "ShieldWood");
		}

		private static bool ApplyBuff(Player player, SpellCast cast, SE_Stats se, string iconItem)
		{
			if (!cast.TrySpend())
			{
				return false;
			}
			if ((Object)(object)((StatusEffect)se).m_icon == (Object)null)
			{
				((StatusEffect)se).m_icon = FindIcon(iconItem);
			}
			((Character)player).GetSEMan().AddStatusEffect((StatusEffect)(object)se, true, 0, 0f, (short)(-1));
			return true;
		}

		private static bool CastHeal(Player player, SpellCast cast)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			if (((Character)player).GetHealth() >= ((Character)player).GetMaxHealth())
			{
				cast.Fail(Loc.T("starlight_msg_full_health"));
				return false;
			}
			if (!cast.TrySpend())
			{
				return false;
			}
			((Character)player).Heal(HealAmount.Value * cast.Magnitude, true);
			EffectList boltStartEffect = _boltStartEffect;
			if (boltStartEffect != null)
			{
				boltStartEffect.Create(((Character)player).GetCenterPoint(), Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
			}
			return true;
		}

		private static bool CastBurst(Player player, SpellCast cast)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (!IonCannon.TryGetTarget(BurstRange.Value, out var point))
			{
				cast.Fail(Loc.T("starlight_msg_no_target"));
				return false;
			}
			if (!cast.TrySpend())
			{
				return false;
			}
			float num = BurstRadius.Value * cast.Extent;
			IonCannon.SpawnBurst(point, num / 3f);
			GameCamera instance = GameCamera.instance;
			if (instance != null)
			{
				instance.AddShake(point, num * 4f, 1f, false);
			}
			IonCannon.DamageArea(player, point, num, BurstDamage.Value * cast.Magnitude, friendlyFire: false, buildings: false, 30f, 1.5f, "burst");
			return true;
		}

		private static Vector3 AimDirection(Vector3 origin)
		{
			//IL_000c: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)GameCamera.instance).transform;
			Vector3 val = transform.position + transform.forward * 100f;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(transform.position, transform.forward, ref val2, 100f, AimMask(), (QueryTriggerInteraction)1))
			{
				val = ((RaycastHit)(ref val2)).point;
			}
			Vector3 val3 = val - origin;
			return ((Vector3)(ref val3)).normalized;
		}

		private static int AimMask()
		{
			if (_aimMask == 0)
			{
				_aimMask = LayerMask.GetMask(new string[10] { "Default", "static_solid", "Default_small", "piece", "terrain", "character", "character_net", "character_ghost", "hitbox", "vehicle" });
			}
			return _aimMask;
		}

		private static Sprite FindIcon(string itemName)
		{
			GameObject prefab = Cache.GetPrefab<GameObject>(itemName);
			ItemDrop val = ((prefab != null) ? prefab.GetComponent<ItemDrop>() : null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Warn("アイコン用のアイテム " + itemName + " が見つからない");
			}
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return val.m_itemData.GetIcon();
		}
	}
	internal static class StatusPack
	{
		internal const string ChillId = "status.chill";

		internal const string VenomId = "status.venom";

		internal const string WeakenId = "status.weaken";

		internal const string RootId = "status.root";

		private static ConfigEntry<float> _range;

		private static ConfigEntry<float> _chillRadius;

		private static ConfigEntry<float> _chillSlow;

		private static ConfigEntry<float> _chillDuration;

		private static ConfigEntry<float> _venomRadius;

		private static ConfigEntry<float> _venomDamage;

		private static ConfigEntry<float> _venomDuration;

		private static ConfigEntry<float> _weakenRadius;

		private static ConfigEntry<float> _weakenDuration;

		private static ConfigEntry<float> _rootRadius;

		private static ConfigEntry<float> _rootDuration;

		private static SE_Stats _chill;

		private static SE_StarVenom _venom;

		private static SE_Stats _weaken;

		private static SE_Stats _root;

		internal static void Register(ConfigFile config)
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			_range = config.Bind<float>("Status", "Range", 40f, Loc.Cfg("starlight_cfg_range"));
			_chillRadius = config.Bind<float>("Chill", "Radius", 6f, Loc.Cfg("starlight_cfg_radius"));
			_chillSlow = config.Bind<float>("Chill", "SlowAmount", 0.35f, Loc.Cfg("starlight_cfg_chill_slow"));
			_chillDuration = config.Bind<float>("Chill", "Duration", 8f, Loc.Cfg("starlight_cfg_duration"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "status.chill",
				NameKey = "status_spell_chill",
				LoreKey = "status_lore_chill",
				School = SpellSchool.Status,
				Growth = SpellGrowth.Buff,
				Tier = 1,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(0.6f, 0.9f, 1f),
				EitrCost = Cost(config, "Chill", 15f),
				Cooldown = Cooldown(config, "Chill", 3f),
				OnCast = CastChill
			});
			_venomRadius = config.Bind<float>("Venom", "Radius", 5f, Loc.Cfg("starlight_cfg_radius"));
			_venomDamage = config.Bind<float>("Venom", "DamagePerSecond", 6f, Loc.Cfg("starlight_cfg_venom_damage"));
			_venomDuration = config.Bind<float>("Venom", "Duration", 8f, Loc.Cfg("starlight_cfg_duration"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "status.venom",
				NameKey = "status_spell_venom",
				LoreKey = "status_lore_venom",
				School = SpellSchool.Status,
				Growth = SpellGrowth.Attack,
				Tier = 2,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(0.55f, 1f, 0.55f),
				EitrCost = Cost(config, "Venom", 20f),
				Cooldown = Cooldown(config, "Venom", 4f),
				OnCast = CastVenom
			});
			_weakenRadius = config.Bind<float>("Weaken", "Radius", 6f, Loc.Cfg("starlight_cfg_radius"));
			_weakenDuration = config.Bind<float>("Weaken", "Duration", 12f, Loc.Cfg("starlight_cfg_duration"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "status.weaken",
				NameKey = "status_spell_weaken",
				LoreKey = "status_lore_weaken",
				School = SpellSchool.Status,
				Growth = SpellGrowth.Buff,
				Tier = 2,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(0.8f, 0.55f, 1f),
				EitrCost = Cost(config, "Weaken", 20f),
				Cooldown = Cooldown(config, "Weaken", 6f),
				OnCast = CastWeaken
			});
			_rootRadius = config.Bind<float>("Root", "Radius", 5f, Loc.Cfg("starlight_cfg_radius"));
			_rootDuration = config.Bind<float>("Root", "Duration", 3f, Loc.Cfg("starlight_cfg_duration"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "status.root",
				NameKey = "status_spell_root",
				LoreKey = "status_lore_root",
				School = SpellSchool.Status,
				Growth = SpellGrowth.Buff,
				Tier = 3,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(1f, 0.9f, 0.6f),
				EitrCost = Cost(config, "Root", 25f),
				Cooldown = Cooldown(config, "Root", 12f),
				OnCast = CastRoot
			});
		}

		private static ConfigEntry<float> Cost(ConfigFile config, string section, float value)
		{
			return config.Bind<float>(section, "EitrCost", value, Loc.Cfg("starlight_cfg_eitr_cost"));
		}

		private static ConfigEntry<float> Cooldown(ConfigFile config, string section, float value)
		{
			return config.Bind<float>(section, "Cooldown", value, Loc.Cfg("starlight_cfg_cooldown"));
		}

		internal static void SetupAssets()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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)
			//IL_0090: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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)
			_chill = Buff<SE_Stats>("SE_StarChill", "chill", "Crystal");
			_venom = Buff<SE_StarVenom>("SE_StarVenom", "venom", "Ooze");
			_weaken = Buff<SE_Stats>("SE_StarWeaken", "weaken", "TrophySkeleton");
			_root = Buff<SE_Stats>("SE_StarRoot", "root", "Root");
			_weaken.m_mods = new List<DamageModPair>
			{
				new DamageModPair
				{
					m_type = (DamageType)1,
					m_modifier = (DamageModifier)2
				},
				new DamageModPair
				{
					m_type = (DamageType)2,
					m_modifier = (DamageModifier)2
				},
				new DamageModPair
				{
					m_type = (DamageType)4,
					m_modifier = (DamageModifier)2
				},
				new DamageModPair
				{
					m_type = (DamageType)32,
					m_modifier = (DamageModifier)2
				},
				new DamageModPair
				{
					m_type = (DamageType)64,
					m_modifier = (DamageModifier)2
				},
				new DamageModPair
				{
					m_type = (DamageType)128,
					m_modifier = (DamageModifier)2
				}
			};
		}

		private static T Buff<T>(string id, string key, string iconItem) where T : StatusEffect
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			T val = ScriptableObject.CreateInstance<T>();
			((Object)(object)val).name = id;
			((StatusEffect)val).m_name = "$status_se_" + key;
			((StatusEffect)val).m_tooltip = "$status_se_" + key + "_tooltip";
			((StatusEffect)val).m_icon = FindIcon(iconItem);
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false));
			return val;
		}

		private static Sprite FindIcon(string itemName)
		{
			GameObject prefab = Cache.GetPrefab<GameObject>(itemName);
			ItemDrop val = ((prefab != null) ? prefab.GetComponent<ItemDrop>() : null);
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return val.m_itemData.GetIcon();
		}

		private static bool CastChill(Player player, SpellCast cast)
		{
			return CastArea(player, cast, _chillRadius.Value * cast.Extent, delegate(Character target)
			{
				((StatusEffect)_chill).m_ttl = _chillDuration.Value * cast.Extent;
				_chill.m_speedModifier = 0f - Mathf.Clamp(_chillSlow.Value * cast.Magnitude, 0f, 0.9f);
				Apply(target, (StatusEffect)(object)_chill);
			});
		}

		private static bool CastVenom(Player player, SpellCast cast)
		{
			return CastArea(player, cast, _venomRadius.Value * cast.Extent, delegate(Character target)
			{
				((StatusEffect)_venom).m_ttl = _venomDuration.Value;
				_venom.m_damagePerSecond = _venomDamage.Value * cast.Magnitude;
				Apply(target, (StatusEffect)(object)_venom);
			});
		}

		private static bool CastWeaken(Player player, SpellCast cast)
		{
			return CastArea(player, cast, _weakenRadius.Value * cast.Extent, delegate(Character target)
			{
				((StatusEffect)_weaken).m_ttl = _weakenDuration.Value * cast.Extent;
				Apply(target, (StatusEffect)(object)_weaken);
			});
		}

		private static bool CastRoot(Player player, SpellCast cast)
		{
			return CastArea(player, cast, _rootRadius.Value * cast.Extent, delegate(Character target)
			{
				((StatusEffect)_root).m_ttl = _rootDuration.Value * cast.Extent;
				_root.m_speedModifier = -0.95f;
				Apply(target, (StatusEffect)(object)_root);
			});
		}

		private static void Apply(Character target, StatusEffect se)
		{
			target.GetSEMan().AddStatusEffect(se, true, 0, 0f, (short)(-1));
		}

		private static bool CastArea(Player player, SpellCast cast, float radius, Action<Character> effect)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (!SpellArea.TryGetTarget(_range.Value, out var point))
			{
				cast.Fail(Loc.T("starlight_msg_no_target"));
				return false;
			}
			if (!cast.TrySpend())
			{
				return false;
			}
			IonCannon.SpawnBurst(point, radius / 5f);
			int hit = 0;
			SpellArea.ForEachEnemy(player, point, radius, delegate(Character c)
			{
				effect(c);
				hit++;
			});
			((Character)player).Message((MessageType)1, Loc.T("status_msg_applied", cast.Spell.DisplayName, hit), 0, (Sprite)null, false);
			return true;
		}
	}
	public class SE_StarVenom : StatusEffect
	{
		public float m_damagePerSecond = 5f;

		private float _timer;

		public override void UpdateStatusEffect(float dt)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			((StatusEffect)this).UpdateStatusEffect(dt);
			if (!((Object)(object)base.m_character == (Object)null) && !base.m_character.IsDead())
			{
				_timer += dt;
				if (!(_timer < 1f))
				{
					_timer -= 1f;
					HitData val = new HitData();
					val.m_point = base.m_character.GetCenterPoint();
					val.m_damage.m_poison = m_damagePerSecond;
					base.m_character.Damage(val);
				}
			}
		}
	}
	internal static class SummonPack
	{
		internal const string SentinelId = "summon.sentinel";

		internal const string MotesId = "summon.motes";

		private static readonly string[] CreatureCandidates = new string[3] { "Skeleton_Friendly", "Skeleton", "Greyling" };

		private static ConfigEntry<string> _creature;

		private static ConfigEntry<int> _sentinelCount;

		private static ConfigEntry<int> _sentinelMax;

		private static ConfigEntry<float> _sentinelDuration;

		private static ConfigEntry<float> _sentinelRange;

		private static ConfigEntry<int> _motesCount;

		private static ConfigEntry<float> _motesDamage;

		private static ConfigEntry<float> _motesDuration;

		private static ConfigEntry<float> _motesInterval;

		private static ConfigEntry<float> _motesRange;

		private static readonly List<GameObject> _summoned = new List<GameObject>();

		private static string _creatureName;

		internal static void Register(ConfigFile config)
		{
			//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_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			_creature = config.Bind<string>("Sentinel", "Creature", "", Loc.Cfg("starlight_cfg_summon_creature"));
			_sentinelCount = config.Bind<int>("Sentinel", "Count", 1, Loc.Cfg("starlight_cfg_summon_count"));
			_sentinelMax = config.Bind<int>("Sentinel", "MaxAlive", 4, Loc.Cfg("starlight_cfg_summon_max"));
			_sentinelDuration = config.Bind<float>("Sentinel", "Duration", 60f, Loc.Cfg("starlight_cfg_duration"));
			_sentinelRange = config.Bind<float>("Sentinel", "Range", 30f, Loc.Cfg("starlight_cfg_range"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "summon.sentinel",
				NameKey = "summon_spell_sentinel",
				LoreKey = "summon_lore_sentinel",
				School = SpellSchool.Summon,
				Growth = SpellGrowth.Buff,
				Tier = 3,
				Vfx = SpellVfxKind.Pillar,
				VfxColor = new Color(0.7f, 0.85f, 1f),
				EitrCost = Cost(config, "Sentinel", 30f),
				Cooldown = Cooldown(config, "Sentinel", 10f),
				OnCast = CastSentinel
			});
			_motesCount = config.Bind<int>("Motes", "Count", 3, Loc.Cfg("starlight_cfg_motes_count"));
			_motesDamage = config.Bind<float>("Motes", "Damage", 12f, Loc.Cfg("starlight_cfg_motes_damage"));
			_motesDuration = config.Bind<float>("Motes", "Duration", 30f, Loc.Cfg("starlight_cfg_duration"));
			_motesInterval = config.Bind<float>("Motes", "Interval", 1.2f, Loc.Cfg("starlight_cfg_motes_interval"));
			_motesRange = config.Bind<float>("Motes", "Range", 25f, Loc.Cfg("starlight_cfg_range"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "summon.motes",
				NameKey = "summon_spell_motes",
				LoreKey = "summon_lore_motes",
				School = SpellSchool.Summon,
				Growth = SpellGrowth.Attack,
				Tier = 2,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(0.6f, 0.8f, 1f),
				EitrCost = Cost(config, "Motes", 25f),
				Cooldown = Cooldown(config, "Motes", 8f),
				OnCast = CastMotes
			});
		}

		private static ConfigEntry<float> Cost(ConfigFile config, string section, float value)
		{
			return config.Bind<float>(section, "EitrCost", value, Loc.Cfg("starlight_cfg_eitr_cost"));
		}

		private static ConfigEntry<float> Cooldown(ConfigFile config, string section, float value)
		{
			return config.Bind<float>(section, "Cooldown", value, Loc.Cfg("starlight_cfg_cooldown"));
		}

		internal static void SetupAssets()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= SetupAssets;
			_creatureName = ResolveCreature();
		}

		private static string ResolveCreature()
		{
			if (!string.IsNullOrEmpty(_creature.Value))
			{
				if ((Object)(object)Cache.GetPrefab<GameObject>(_creature.Value) != (Object)null)
				{
					return _creature.Value;
				}
				Plugin.Warn("召喚する生き物 " + _creature.Value + " が見つからない。候補から選び直す");
			}
			string[] creatureCandidates = CreatureCandidates;
			foreach (string text in creatureCandidates)
			{
				if ((Object)(object)Cache.GetPrefab<GameObject>(text) != (Object)null)
				{
					Plugin.Log("星の従者: " + text + " を使う");
					return text;
				}
			}
			Plugin.Warn("召喚に使える生き物が見つからない。星の従者は使えない");
			return null;
		}

		private static bool CastSentinel(Player player, SpellCast cast)
		{
			//IL_004d: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00d8: 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_00e9: 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)
			if (_creatureName == null)
			{
				cast.Fail(Loc.T("summon_msg_unavailable"));
				return false;
			}
			GameObject prefab = Cache.GetPrefab<GameObject>(_creatureName);
			if ((Object)(object)prefab == (Object)null)
			{
				return false;
			}
			if (!SpellArea.TryGetTarget(_sentinelRange.Value, out var point))
			{
				point = ((Component)player).transform.position;
			}
			if (!cast.TrySpend())
			{
				return false;
			}
			int num = Mathf.Max(1, Mathf.RoundToInt((float)_sentinelCount.Value * cast.Extent));
			float ttl = _sentinelDuration.Value * cast.Extent;
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i * MathF.PI * 2f / (float)num;
				Vector3 val = new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * ((num > 1) ? 1.5f : 0f);
				Spawn(player, prefab, point + val + Vector3.up * 0.5f, ttl);
			}
			((Character)player).Message((MessageType)1, Loc.T("summon_msg_sentinel", num), 0, (Sprite)null, false);
			return true;
		}

		private static void Spawn(Player player, GameObject prefab, Vector3 position, float ttl)
		{
			//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)
			GameObject val = Object.Instantiate<GameObject>(prefab, position, Quaternion.identity);
			Character component = val.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.SetTamed(true);
				component.m_name = "$summon_creature_sentinel";
			}
			MonsterAI component2 = val.GetComponent<MonsterAI>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.SetFollowTarget(((Component)player).gameObject);
				component2.SetDespawnInDay(false);
				component2.SetEventCreature(false);
			}
			CharacterDrop[] componentsInChildren = val.GetComponentsInChildren<CharacterDrop>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			ZNetView component3 = val.GetComponent<ZNetView>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.m_persistent = false;
				if (component3.GetZDO() != null)
				{
					component3.GetZDO().Persistent = false;
				}
			}
			_summoned.Add(val);
			TrimOldest();
			((MonoBehaviour)Plugin.Instance).StartCoroutine(Expire(val, ttl));
		}

		private static void TrimOldest()
		{
			_summoned.RemoveAll((GameObject g) => (Object)(object)g == (Object)null);
			while (_summoned.Count > Mathf.Max(1, _sentinelMax.Value))
			{
				GameObject go = _summoned[0];
				_summoned.RemoveAt(0);
				Dismiss(go);
			}
		}

		private static IEnumerator Expire(GameObject go, float ttl)
		{
			yield return (object)new WaitForSeconds(ttl);
			_summoned.Remove(go);
			Dismiss(go);
		}

		private static void Dismiss(GameObject go)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)go == (Object)null))
			{
				IonCannon.SpawnBurst(go.transform.position + Vector3.up * 0.8f, 0.4f);
				if ((Object)(object)ZNetScene.instance != (Object)null)
				{
					ZNetScene.instance.Destroy(go);
				}
				else
				{
					Object.Destroy((Object)(object)go);
				}
			}
		}

		private static bool CastMotes(Player player, SpellCast cast)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)StarlightPack.BoltPrefab == (Object)null)
			{
				cast.Fail(Loc.T("summon_msg_unavailable"));
				return false;
			}
			if (!cast.TrySpend())
			{
				return false;
			}
			StarMotes componentInChildren = ((Component)player).GetComponentInChildren<StarMotes>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)componentInChildren).gameObject);
			}
			int num = Mathf.Max(1, Mathf.RoundToInt((float)_motesCount.Value * cast.Extent));
			GameObject val = new GameObject("StarlightMotes");
			val.transform.SetParent(((Component)player).transform, false);
			val.AddComponent<StarMotes>().Setup(player, num, _motesDamage.Value * cast.Magnitude, _motesDuration.Value * cast.Extent, _motesInterval.Value, _motesRange.Value);
			((Character)player).Message((MessageType)1, Loc.T("summon_msg_motes", num), 0, (Sprite)null, false);
			return true;
		}
	}
	public class StarMotes : MonoBehaviour
	{
		private const float OrbitRadius = 1.3f;

		private const float OrbitHeight = 1.7f;

		private const float OrbitSpeed = 70f;

		private Player _owner;

		private float _damage;

		private float _life;

		private float _interval;

		private float _range;

		private float _age;

		private float _shotTimer;

		private int _next;

		private readonly List<Transform> _orbs = new List<Transform>();

		public void Setup(Player owner, int count, float damage, float life, float interval, float range)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			_owner = owner;
			_damage = damage;
			_life = life;
			_interval = interval;
			_range = range;
			Color value = Plugin.StarColor.Value;
			for (int i = 0; i < count; i++)
			{
				_orbs.Add(MakeOrb(value));
			}
		}

		private Transform MakeOrb(Color color)
		{
			//IL_002a: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localScale = Vector3.one * 0.28f;
			Renderer component = val.GetComponent<Renderer>();
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
			component.material = new Material(Shader.Find("Sprites/Default"))
			{
				color = new Color(color.r, color.g, color.b, 0.9f)
			};
			Light obj = new GameObject("light").AddComponent<Light>();
			((Component)obj).transform.SetParent(val.transform, false);
			obj.type = (LightType)2;
			obj.color = color;
			obj.range = 4f;
			obj.intensity = 1.6f;
			return val.transform;
		}

		private void Update()
		{
			//IL_0064: 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)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_owner == (Object)null || ((Character)_owner).IsDead())
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			_age += Time.deltaTime;
			if (_age >= _life)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			((Component)this).transform.position = ((Component)_owner).transform.position;
			((Component)this).transform.rotation = Quaternion.identity;
			float num = _age * 70f;
			for (int i = 0; i < _orbs.Count; i++)
			{
				float num2 = (num + (float)i * 360f / (float)_orbs.Count) * (MathF.PI / 180f);
				_orbs[i].localPosition = new Vector3(Mathf.Cos(num2) * 1.3f, 1.7f + Mathf.Sin(_age * 2f + (float)i) * 0.12f, Mathf.Sin(num2) * 1.3f);
			}
			_shotTimer -= Time.deltaTime;
			if (!(_shotTimer > 0f))
			{
				_shotTimer = _interval;
				Shoot();
			}
		}

		private void Shoot()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_006b: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if (_orbs.Count != 0 && SpellArea.TryGetNearestEnemy(_owner, ((Component)_owner).transform.position, _range, out var nearest))
			{
				Transform obj = _orbs[_next % _orbs.Count];
				_next++;
				Vector3 position = obj.position;
				Vector3 val = nearest.GetCenterPoint() - position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				IProjectile component = Object.Instantiate<GameObject>(StarlightPack.BoltPrefab, position, Quaternion.LookRotation(normalized)).GetComponent<IProjectile>();
				if (component != null)
				{
					HitData val2 = new HitData();
					val2.m_damage.m_fire = _damage;
					val2.m_skill = (SkillType)9;
					val2.m_pushForce = 5f;
					val2.SetAttacker((Character)(object)_owner);
					component.Setup((Character)(object)_owner, normalized * StarlightPack.BoltVelocity, -1f, val2, (ItemData)null, (ItemData)null);
				}
			}
		}
	}
	internal static class TravelPack
	{
		internal const string LightId = "travel.light";

		internal const string FeatherId = "travel.feather";

		internal const string BlinkId = "travel.blink";

		internal const string SightId = "travel.sight";

		private static ConfigEntry<float> _lightDuration;

		private static ConfigEntry<float> _lightRange;

		private static ConfigEntry<float> _featherDuration;

		private static ConfigEntry<float> _blinkRange;

		private static ConfigEntry<float> _sightRadius;

		private static ConfigEntry<float> _sightDuration;

		private static ConfigEntry<string> _sightTargets;

		private static SE_Stats _lantern;

		private static SE_Stats _feather;

		private static int _mask;

		private static int Mask()
		{
			if (_mask == 0)
			{
				_mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" });
			}
			return _mask;
		}

		internal static void Register(ConfigFile config)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			_lightDuration = config.Bind<float>("Light", "Duration", 300f, Loc.Cfg("starlight_cfg_duration"));
			_lightRange = config.Bind<float>("Light", "LightRange", 18f, Loc.Cfg("starlight_cfg_light_range"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "travel.light",
				NameKey = "travel_spell_light",
				LoreKey = "travel_lore_light",
				School = SpellSchool.Utility,
				Growth = SpellGrowth.Buff,
				Tier = 1,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(1f, 0.92f, 0.7f),
				EitrCost = Cost(config, "Light", 10f),
				Cooldown = Cooldown(config, "Light", 1f),
				OnCast = CastLight
			});
			_featherDuration = config.Bind<float>("Feather", "Duration", 60f, Loc.Cfg("starlight_cfg_duration"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "travel.feather",
				NameKey = "travel_spell_feather",
				LoreKey = "travel_lore_feather",
				School = SpellSchool.Utility,
				Growth = SpellGrowth.Buff,
				Tier = 1,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(0.85f, 0.95f, 1f),
				EitrCost = Cost(config, "Feather", 10f),
				Cooldown = Cooldown(config, "Feather", 1f),
				OnCast = CastFeather
			});
			_blinkRange = config.Bind<float>("Blink", "Range", 20f, Loc.Cfg("starlight_cfg_range"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "travel.blink",
				NameKey = "travel_spell_blink",
				LoreKey = "travel_lore_blink",
				School = SpellSchool.Utility,
				Growth = SpellGrowth.Buff,
				Tier = 2,
				EitrCost = Cost(config, "Blink", 20f),
				Cooldown = Cooldown(config, "Blink", 4f),
				OnCast = CastBlink
			});
			_sightRadius = config.Bind<float>("Sight", "Radius", 40f, Loc.Cfg("starlight_cfg_radius"));
			_sightDuration = config.Bind<float>("Sight", "Duration", 10f, Loc.Cfg("starlight_cfg_duration"));
			_sightTargets = config.Bind<string>("Sight", "Deposits", "copper, tin, silver, mudpile, obsidian, flametal, meteorite", Loc.Cfg("starlight_cfg_sight_targets"));
			SpellRegistry.Register(new SpellDefinition
			{
				Id = "travel.sight",
				NameKey = "travel_spell_sight",
				LoreKey = "travel_lore_sight",
				School = SpellSchool.Utility,
				Growth = SpellGrowth.Buff,
				Tier = 3,
				Vfx = SpellVfxKind.Ring,
				VfxColor = new Color(0.75f, 0