Decompiled source of Asset Browser v1.6.0

plugins/AssetBrowser.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SideLoader;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AssetBrowser")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Asset Browser")]
[assembly: AssemblyTitle("AssetBrowser")]
[assembly: AssemblyVersion("1.6.0.0")]
[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 AssetBrowser
{
	[BepInPlugin("com.wrango.assetbrowser", "Asset Browser", "1.6.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency("com.wrango.customeffects", "1.4.0")]
	public class AssetBrowserPlugin : BaseUnityPlugin
	{
		private enum Mode
		{
			Sound,
			VFX,
			ItemVFX,
			Projectile,
			Blast,
			Animation
		}

		public const string GUID = "com.wrango.assetbrowser";

		public const string NAME = "Asset Browser";

		public const string VERSION = "1.6.0";

		internal static ManualLogSource Log;

		internal static AssetBrowserPlugin Instance;

		private ConfigEntry<bool> m_enabled;

		private ConfigEntry<float> m_autoStopSeconds;

		private ConfigEntry<KeyboardShortcut> m_keyNext;

		private ConfigEntry<KeyboardShortcut> m_keyPrev;

		private ConfigEntry<KeyboardShortcut> m_keyJumpForward;

		private ConfigEntry<KeyboardShortcut> m_keyJumpBack;

		private ConfigEntry<KeyboardShortcut> m_keyReplay;

		private ConfigEntry<KeyboardShortcut> m_keyNextGroup;

		private ConfigEntry<KeyboardShortcut> m_keyPrevGroup;

		private ConfigEntry<KeyboardShortcut> m_keyKeep;

		private ConfigEntry<KeyboardShortcut> m_keyToggleMode;

		private ConfigEntry<KeyboardShortcut> m_keyStop;

		private ConfigEntry<int> m_jumpSize;

		private ConfigEntry<float> m_projectileLifespan;

		private ConfigEntry<float> m_projectileForce;

		private ConfigEntry<Vector3> m_vfxPosition;

		private ConfigEntry<Vector3> m_projPosition;

		private ConfigEntry<Vector3> m_blastPosition;

		private ConfigEntry<bool> m_enableAnimations;

		private ConfigEntry<bool> m_allowHarmfulAnimations;

		private ConfigEntry<bool> m_enableItemVFX;

		private ConfigEntry<string> m_filter;

		private const float PreviewBlastRadius = 3f;

		private static readonly string[] Groups = new string[7] { "SFX", "ENV", "UI", "FT", "BGM", "LOC", "CS" };

		private readonly Dictionary<string, List<Sounds>> m_byGroup = new Dictionary<string, List<Sounds>>();

		private int m_groupIndex;

		private int m_soundIndex;

		private SplitableSoundSource m_playing;

		private Sounds m_playingSound;

		private float m_stopAt = -1f;

		private bool m_wroteKeeperHeader;

		private const int ModeCount = 6;

		private Mode m_mode;

		private int m_vfxIndex;

		private readonly List<VFXPrefabs> m_vfxList = new List<VFXPrefabs>();

		private GameObject m_vfxInstance;

		private int m_blastIndex;

		private readonly List<BlastPrefabs> m_blastList = new List<BlastPrefabs>();

		private int m_animIndex;

		private readonly List<SpellCastType> m_animList = new List<SpellCastType>();

		private int m_vfxTotal;

		private int m_projTotal;

		private int m_blastTotal;

		private int m_animTotal;

		private readonly Dictionary<string, int> m_groupTotals = new Dictionary<string, int>();

		private bool m_animPlaying;

		private static readonly SpellCastType[] HarmfulAnimations;

		private static readonly SpellCastType[] MobileCasts;

		private static readonly SpellCastType[] UnusedCasts;

		private const int FirstAttackCast = 500;

		private const string CustomEffectsGUID = "com.wrango.customeffects";

		private static readonly Version FirstItemVFXVersion;

		private static readonly int[] PreviewWeapons;

		private Type m_itemVFXType;

		private Type m_itemVFXSetType;

		private FieldInfo m_itemVFXField;

		private string m_itemVFXMissing;

		private int m_itemVFXIndex;

		private int m_itemVFXTotal;

		private readonly List<object> m_itemVFXList = new List<object>();

		private int m_weaponIndex;

		private Equipment m_previewWeapon;

		private Component m_previewItemVFX;

		private readonly List<string> m_restoreUIDs = new List<string>();

		private object m_pendingSet;

		private int m_pendingAfterFrame;

		private ShootBlast m_blaster;

		private GameObject m_blasterObject;

		private int m_projIndex;

		private readonly List<ProjectilePrefabs> m_projList = new List<ProjectilePrefabs>();

		private GameObject m_projInstance;

		private ShootProjectile m_shooter;

		private GameObject m_shooterObject;

		private List<Sounds> Current => m_byGroup[Groups[m_groupIndex]];

		private static string KeeperPath => Path.Combine(Paths.BepInExRootPath, "AssetBrowserKept.txt");

		private bool FilterActive
		{
			get
			{
				if (m_filter != null)
				{
					return !string.IsNullOrEmpty(m_filter.Value);
				}
				return false;
			}
		}

		private bool ItemVFXAvailable => m_itemVFXType != null;

		private void BindConfig()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Expected O, but got Unknown
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Expected O, but got Unknown
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Expected O, but got Unknown
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Expected O, but got Unknown
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Expected O, but got Unknown
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Expected O, but got Unknown
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Expected O, but got Unknown
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			m_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Master switch", true, new ConfigDescription("Turn off to ignore every hotkey without uninstalling.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 60
				}
			}));
			m_autoStopSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Auto-stop seconds", 5f, new ConfigDescription("Cut a playing sound after this many seconds.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 40
				}
			}));
			m_enableAnimations = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable animations", false, new ConfigDescription("Include ANIMATION in the browse cycle. Off by default: animations play on your own character.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 55
				}
			}));
			m_allowHarmfulAnimations = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Allow harmful animations", false, new ConfigDescription("Un-hide the animations that do something real (WARNING: DeathIndirect kills you).", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 54
				}
			}));
			m_allowHarmfulAnimations.SettingChanged += delegate
			{
				BuildAnimationList();
			};
			m_filter = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Filter", "", new ConfigDescription("Browse only assets whose name contains this text. Case-insensitive. Cleared when the game restarts.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 58
				}
			}));
			if (!string.IsNullOrEmpty(m_filter.Value))
			{
				Log.LogMessage((object)("Cleared the Filter left over from the last session (\"" + m_filter.Value + "\")."));
				m_filter.Value = "";
			}
			m_filter.SettingChanged += delegate
			{
				RebuildAll();
			};
			m_enableAnimations.SettingChanged += delegate
			{
				if (!m_enableAnimations.Value && m_mode == Mode.Animation)
				{
					StopEverything();
					m_mode = Mode.Sound;
				}
			};
			m_enableItemVFX = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable item VFX", false, new ConfigDescription("Include ITEM VFX in the browse cycle. Off by default: it swaps the weapon in your hands.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 56
				}
			}));
			m_enableItemVFX.SettingChanged += delegate
			{
				if (!m_enableItemVFX.Value && m_mode == Mode.ItemVFX)
				{
					StopEverything();
					m_mode = Mode.Sound;
				}
			};
			m_enabled.SettingChanged += delegate
			{
				if (!m_enabled.Value)
				{
					StopEverything();
				}
			};
			m_jumpSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Jump size", 25, new ConfigDescription("How many entries the jump keys skip.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 50
				}
			}));
			m_projectileLifespan = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Projectile lifespan", 5f, new ConfigDescription("How many seconds a previewed projectile flies before it expires. Blasts share it.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 30
				}
			}));
			m_projectileForce = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Projectile force", 20f, new ConfigDescription("Launch speed for previewed projectiles.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 20
				}
			}));
			m_vfxPosition = ((BaseUnityPlugin)this).Config.Bind<Vector3>("General", "VFX position", Vector3.zero, new ConfigDescription("Offset from your character. Matches Position on an SL_EffectTransform. Some prefabs re-anchor themselves to you and ignore it.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 12
				}
			}));
			m_projPosition = ((BaseUnityPlugin)this).Config.Bind<Vector3>("General", "Projectile position", new Vector3(0f, 1.5f, 0f), new ConfigDescription("Where the projectile leaves you. Y 1.5 is chest height, so the shot clears your body. Matches LocalPositionAdd in SL_ShootProjectile.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 11
				}
			}));
			m_blastPosition = ((BaseUnityPlugin)this).Config.Bind<Vector3>("General", "Blast position", new Vector3(0f, 1f, 2f), new ConfigDescription("Where the blast is centred relative to you. Z 2 puts it in front of you rather than on top of you. Matches LocalPositionAdd in SL_ShootBlast.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 10
				}
			}));
			m_keyNext = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Next", new KeyboardShortcut((KeyCode)274, Array.Empty<KeyCode>()), "Next entry.");
			m_keyPrev = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Previous", new KeyboardShortcut((KeyCode)273, Array.Empty<KeyCode>()), "Previous entry.");
			m_keyJumpForward = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Jump forward", new KeyboardShortcut((KeyCode)274, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), "Skip forward by the jump size.");
			m_keyJumpBack = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Jump back", new KeyboardShortcut((KeyCode)273, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), "Skip back by the jump size.");
			m_keyReplay = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Replay", new KeyboardShortcut((KeyCode)277, Array.Empty<KeyCode>()), "Play the current entry again.");
			m_keyNextGroup = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Next group", new KeyboardShortcut((KeyCode)275, Array.Empty<KeyCode>()), "Next sound group, or next weapon in ITEM VFX.");
			m_keyPrevGroup = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Previous group", new KeyboardShortcut((KeyCode)276, Array.Empty<KeyCode>()), "Previous sound group, or previous weapon in ITEM VFX.");
			m_keyKeep = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Keep", new KeyboardShortcut((KeyCode)279, Array.Empty<KeyCode>()), "Write the current entry to the log and to AssetBrowserKept.txt as a line ready to paste into an XML.");
			m_keyToggleMode = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Switch mode", new KeyboardShortcut((KeyCode)278, Array.Empty<KeyCode>()), "Cycle SOUND -> VFX -> ITEM VFX -> PROJECTILE -> BLAST -> ANIMATION. ITEM VFX and ANIMATION only when enabled.");
			m_keyStop = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Stop", new KeyboardShortcut((KeyCode)127, Array.Empty<KeyCode>()), "Clear any lingering asset.");
		}

		internal void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			BindConfig();
			BuildSoundGroups();
			FindCustomEffects();
			BuildVFXList();
			try
			{
				new Harmony("com.wrango.assetbrowser").PatchAll(typeof(Projectile_Shoot_KeepAlive));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Harmony patching failed - projectile previews will not fly: " + ex));
			}
			Log.LogMessage((object)"Asset Browser 1.6.0 loaded. Keys are rebindable in the config.");
			string[] groups = Groups;
			foreach (string text in groups)
			{
				Log.LogMessage((object)("  " + text + ": " + CountLabel(m_byGroup[text].Count, m_groupTotals[text], "sounds")));
			}
			Log.LogMessage((object)("  VFX: " + CountLabel(m_vfxList.Count, m_vfxTotal, "prefabs")));
			Log.LogMessage((object)("  Projectiles: " + CountLabel(m_projList.Count, m_projTotal, "prefabs")));
			Log.LogMessage((object)("  Blasts: " + CountLabel(m_blastList.Count, m_blastTotal, "prefabs")));
			Log.LogMessage((object)("  Item VFX: " + (ItemVFXAvailable ? (CountLabel(m_itemVFXList.Count, m_itemVFXTotal, "sets") + " on " + PreviewWeapons.Length + " weapons") : ("off - " + m_itemVFXMissing))));
		}

		internal void Update()
		{
			if (m_stopAt > 0f && Time.time >= m_stopAt)
			{
				StopCurrentSound();
			}
			if (m_pendingSet != null && Time.frameCount > m_pendingAfterFrame)
			{
				if (Object.op_Implicit((Object)(object)m_previewItemVFX))
				{
					SetItemVFXList(m_pendingSet);
				}
				m_pendingSet = null;
			}
			if (m_enabled.Value)
			{
				if (Pressed(m_keyJumpForward))
				{
					Step(m_jumpSize.Value);
				}
				else if (Pressed(m_keyJumpBack))
				{
					Step(-m_jumpSize.Value);
				}
				else if (Pressed(m_keyNext))
				{
					Step(1);
				}
				else if (Pressed(m_keyPrev))
				{
					Step(-1);
				}
				else if (Pressed(m_keyReplay))
				{
					Play();
				}
				else if (Pressed(m_keyNextGroup))
				{
					StepGroup(1);
				}
				else if (Pressed(m_keyPrevGroup))
				{
					StepGroup(-1);
				}
				else if (Pressed(m_keyKeep))
				{
					Keep();
				}
				else if (Pressed(m_keyToggleMode))
				{
					ToggleMode();
				}
				else if (Pressed(m_keyStop))
				{
					StopEverything();
				}
			}
		}

		private static bool Pressed(ConfigEntry<KeyboardShortcut> key)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (key != null)
			{
				KeyboardShortcut value = key.Value;
				return ((KeyboardShortcut)(ref value)).IsDown();
			}
			return false;
		}

		private static int Wrap(int index, int delta, int count)
		{
			return ((index + delta) % count + count) % count;
		}

		private void Step(int delta)
		{
			if (m_mode == Mode.VFX)
			{
				if (m_vfxList.Count != 0)
				{
					m_vfxIndex = Wrap(m_vfxIndex, delta, m_vfxList.Count);
					Play();
				}
				return;
			}
			if (m_mode == Mode.ItemVFX)
			{
				if (m_itemVFXList.Count != 0)
				{
					m_itemVFXIndex = Wrap(m_itemVFXIndex, delta, m_itemVFXList.Count);
					Play();
				}
				return;
			}
			if (m_mode == Mode.Projectile)
			{
				if (m_projList.Count != 0)
				{
					m_projIndex = Wrap(m_projIndex, delta, m_projList.Count);
					Play();
				}
				return;
			}
			if (m_mode == Mode.Blast)
			{
				if (m_blastList.Count != 0)
				{
					m_blastIndex = Wrap(m_blastIndex, delta, m_blastList.Count);
					Play();
				}
				return;
			}
			if (m_mode == Mode.Animation)
			{
				if (m_animList.Count != 0)
				{
					m_animIndex = Wrap(m_animIndex, delta, m_animList.Count);
					Play();
				}
				return;
			}
			List<Sounds> current = Current;
			if (current.Count != 0)
			{
				m_soundIndex = Wrap(m_soundIndex, delta, current.Count);
				Play();
			}
		}

		private void StepGroup(int delta)
		{
			if (m_mode == Mode.ItemVFX)
			{
				StepWeapon(delta);
			}
			else
			{
				if (m_mode != Mode.Sound)
				{
					return;
				}
				for (int i = 0; i < Groups.Length; i++)
				{
					m_groupIndex = Wrap(m_groupIndex, delta, Groups.Length);
					if (Current.Count > 0)
					{
						break;
					}
				}
				m_soundIndex = 0;
				Notify("== " + Groups[m_groupIndex] + " == " + CountLabel(Current.Count, GroupTotal(), "sounds"));
				Play();
			}
		}

		private unsafe void Play()
		{
			//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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			if (m_mode == Mode.VFX)
			{
				PlayVFX();
				return;
			}
			if (m_mode == Mode.ItemVFX)
			{
				PlayItemVFX();
				return;
			}
			if (m_mode == Mode.Projectile)
			{
				PlayProjectile();
				return;
			}
			if (m_mode == Mode.Blast)
			{
				PlayBlast();
				return;
			}
			if (m_mode == Mode.Animation)
			{
				PlayAnimation();
				return;
			}
			List<Sounds> current = Current;
			if (current.Count != 0)
			{
				Sounds val = current[m_soundIndex];
				string text = "[" + (m_soundIndex + 1) + "/" + current.Count + "] " + ((object)(*(Sounds*)(&val))/*cast due to .constrained prefix*/).ToString();
				StopCurrentSound();
				Character val2 = LocalPlayer();
				if (Object.op_Implicit((Object)(object)val2) && (Object)(object)Global.AudioManager != (Object)null)
				{
					m_playing = Global.AudioManager.PlaySoundAtPosition(val, ((Component)val2).transform, 0f, 1f, 1f, 1f, 1f);
					m_playingSound = val;
					m_stopAt = Time.time + m_autoStopSeconds.Value;
					text += ClipLength(m_playing);
				}
				Notify(text);
				Log.LogMessage((object)text);
			}
		}

		private static string BlastShape(BlastPrefabs prefabEnum)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject blastPrefab = SL_ShootBlast.GetBlastPrefab(prefabEnum);
				if (!Object.op_Implicit((Object)(object)blastPrefab))
				{
					return "";
				}
				Blast component = blastPrefab.GetComponent<Blast>();
				if ((Object)(object)component == (Object)null)
				{
					return "";
				}
				return ((object)component).GetType().Name switch
				{
					"Blast" => "", 
					"ConeBlast" => "  (cone)", 
					"LanternConeBlast" => "  (cone, lantern)", 
					"BlastGround" => "  (ground)", 
					"LingeringBlast" => "  (lingering)", 
					"CircularBlast" => "  (circular)", 
					"BlastTurret" => "  (turret)", 
					"BlastDelayedHits" => "  (delayed hits)", 
					"ActivationBlast" => "  (activation)", 
					"BlastNoPhysics" => "  (no physics)", 
					"BlastNoPhysicsMaxTarget" => "  (no physics, max target)", 
					_ => "  (" + ((object)component).GetType().Name + ")", 
				};
			}
			catch
			{
				return "";
			}
		}

		private static string ClipLength(SplitableSoundSource source)
		{
			if ((Object)(object)source == (Object)null)
			{
				return "";
			}
			AudioSource[] componentsInChildren = ((Component)source).GetComponentsInChildren<AudioSource>(true);
			if (componentsInChildren == null || componentsInChildren.Length == 0)
			{
				return "";
			}
			float num = 0f;
			float num2 = float.MaxValue;
			int num3 = 0;
			AudioSource[] array = componentsInChildren;
			foreach (AudioSource val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.clip))
				{
					num3++;
					if (val.clip.length > num)
					{
						num = val.clip.length;
					}
					if (val.clip.length < num2)
					{
						num2 = val.clip.length;
					}
				}
			}
			if (num3 == 0)
			{
				return "";
			}
			string text = "  (" + num.ToString("0.00") + "s";
			if (num3 > 1 && num - num2 > 0.01f)
			{
				text = text + ", longest of " + num3;
			}
			return text + ")";
		}

		private void StopCurrentSound()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_playing == (Object)null))
			{
				if ((Object)(object)Global.AudioManager != (Object)null)
				{
					Global.AudioManager.StopSound(m_playingSound, m_playing, 0.15f, false);
				}
				m_playing = null;
				m_stopAt = -1f;
			}
		}

		private unsafe void Keep()
		{
			//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_0061: 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_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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Invalid comparison between Unknown and I4
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			if (m_mode == Mode.VFX)
			{
				if (m_vfxList.Count != 0)
				{
					Kept("<VFXPrefab>" + ((object)m_vfxList[m_vfxIndex]/*cast due to .constrained prefix*/).ToString() + "</VFXPrefab>  (or <StartVFX>" + ((object)m_vfxList[m_vfxIndex]/*cast due to .constrained prefix*/).ToString() + "</StartVFX>)", ((object)m_vfxList[m_vfxIndex]/*cast due to .constrained prefix*/).ToString());
				}
			}
			else if (m_mode == Mode.ItemVFX)
			{
				if (m_itemVFXList.Count != 0)
				{
					object obj = m_itemVFXList[m_itemVFXIndex];
					Kept("<VFX>" + obj?.ToString() + "</VFX>  (SL_ItemVFX, inside <VFX>)", obj.ToString());
				}
			}
			else if (m_mode == Mode.Projectile)
			{
				if (m_projList.Count != 0)
				{
					Kept("<BaseProjectile>" + ((object)m_projList[m_projIndex]/*cast due to .constrained prefix*/).ToString() + "</BaseProjectile>", ((object)m_projList[m_projIndex]/*cast due to .constrained prefix*/).ToString());
				}
			}
			else if (m_mode == Mode.Blast)
			{
				if (m_blastList.Count != 0)
				{
					Kept("<BaseBlast>" + ((object)m_blastList[m_blastIndex]/*cast due to .constrained prefix*/).ToString() + "</BaseBlast>" + BlastShape(m_blastList[m_blastIndex]), ((object)m_blastList[m_blastIndex]/*cast due to .constrained prefix*/).ToString());
				}
			}
			else if (m_mode == Mode.Animation)
			{
				if (m_animList.Count != 0)
				{
					SpellCastType val = m_animList[m_animIndex];
					string text = null;
					if ((int)val >= 500)
					{
						text = "Attack";
					}
					else if (IsMobileCast(val))
					{
						text = "Mobile";
					}
					string text2 = "<Animation>" + ((object)(*(SpellCastType*)(&val))/*cast due to .constrained prefix*/).ToString() + "</Animation>";
					text2 = ((text != null) ? (text2 + "  <Modifier>" + text + "</Modifier>  (SL_PlayAnimation; on an item, CastType and <CastModifier>" + text + "</CastModifier>)") : (text2 + "  (SL_PlayAnimation, or CastType on an item)"));
					Kept(text2, ((object)(*(SpellCastType*)(&val))/*cast due to .constrained prefix*/).ToString());
				}
			}
			else
			{
				List<Sounds> current = Current;
				if (current.Count != 0)
				{
					Kept("<Sounds>" + ((object)current[m_soundIndex]/*cast due to .constrained prefix*/).ToString() + "</Sounds>", ((object)current[m_soundIndex]/*cast due to .constrained prefix*/).ToString());
				}
			}
		}

		private void Kept(string line, string name)
		{
			Log.LogMessage((object)("KEEP  " + line));
			AppendKeeper(line);
			Notify("Kept: " + name);
		}

		private void AppendKeeper(string line)
		{
			try
			{
				if (!m_wroteKeeperHeader)
				{
					m_wroteKeeperHeader = true;
					string text = "# " + DateTime.Now.ToString("dd-MM-yy HH:mm") + Environment.NewLine;
					if (File.Exists(KeeperPath) && new FileInfo(KeeperPath).Length > 0)
					{
						text = Environment.NewLine + text;
					}
					File.AppendAllText(KeeperPath, text);
				}
				File.AppendAllText(KeeperPath, line + Environment.NewLine);
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Could not write the keeper to " + KeeperPath + " - " + ex.Message));
			}
		}

		private static bool IsHarmful(SpellCastType type)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between I4 and Unknown
			for (int i = 0; i < HarmfulAnimations.Length; i++)
			{
				if ((int)HarmfulAnimations[i] == (int)type)
				{
					return true;
				}
			}
			return false;
		}

		private static bool IsMobileCast(SpellCastType type)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between I4 and Unknown
			for (int i = 0; i < MobileCasts.Length; i++)
			{
				if ((int)MobileCasts[i] == (int)type)
				{
					return true;
				}
			}
			return false;
		}

		private static bool IsUnusedCast(SpellCastType type)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between I4 and Unknown
			for (int i = 0; i < UnusedCasts.Length; i++)
			{
				if ((int)UnusedCasts[i] == (int)type)
				{
					return true;
				}
			}
			return false;
		}

		private void BuildVFXList()
		{
			//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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			m_vfxList.Clear();
			m_projList.Clear();
			m_blastList.Clear();
			m_vfxTotal = 0;
			m_projTotal = 0;
			m_blastTotal = 0;
			foreach (VFXPrefabs value in Enum.GetValues(typeof(VFXPrefabs)))
			{
				if ((int)value != 0)
				{
					m_vfxTotal++;
					if (Matches(((object)value/*cast due to .constrained prefix*/).ToString()))
					{
						m_vfxList.Add(value);
					}
				}
			}
			foreach (ProjectilePrefabs value2 in Enum.GetValues(typeof(ProjectilePrefabs)))
			{
				if ((int)value2 != 0)
				{
					m_projTotal++;
					if (Matches(((object)value2/*cast due to .constrained prefix*/).ToString()))
					{
						m_projList.Add(value2);
					}
				}
			}
			foreach (BlastPrefabs value3 in Enum.GetValues(typeof(BlastPrefabs)))
			{
				if ((int)value3 != 0)
				{
					m_blastTotal++;
					if (Matches(((object)value3/*cast due to .constrained prefix*/).ToString()))
					{
						m_blastList.Add(value3);
					}
				}
			}
			if (m_vfxIndex >= m_vfxList.Count)
			{
				m_vfxIndex = 0;
			}
			if (m_projIndex >= m_projList.Count)
			{
				m_projIndex = 0;
			}
			if (m_blastIndex >= m_blastList.Count)
			{
				m_blastIndex = 0;
			}
			BuildItemVFXList();
			BuildAnimationList();
		}

		private void BuildSoundGroups()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			string[] groups = Groups;
			foreach (string key in groups)
			{
				if (m_byGroup.ContainsKey(key))
				{
					m_byGroup[key].Clear();
				}
				else
				{
					m_byGroup[key] = new List<Sounds>();
				}
				m_groupTotals[key] = 0;
			}
			foreach (Sounds value in Enum.GetValues(typeof(Sounds)))
			{
				string text = ((object)value/*cast due to .constrained prefix*/).ToString();
				groups = Groups;
				foreach (string text2 in groups)
				{
					if (text.StartsWith(text2 + "_", StringComparison.Ordinal))
					{
						m_groupTotals[text2]++;
						if (Matches(text))
						{
							m_byGroup[text2].Add(value);
						}
						break;
					}
				}
			}
			if (m_soundIndex >= Current.Count)
			{
				m_soundIndex = 0;
			}
		}

		private bool Matches(string name)
		{
			if (!FilterActive)
			{
				return true;
			}
			return name.IndexOf(m_filter.Value, StringComparison.OrdinalIgnoreCase) >= 0;
		}

		private int GroupTotal()
		{
			if (!m_groupTotals.TryGetValue(Groups[m_groupIndex], out var value))
			{
				return 0;
			}
			return value;
		}

		private string CountLabel(int shown, int total, string noun)
		{
			if (!FilterActive)
			{
				return shown + " " + noun;
			}
			return shown + " of " + total + " " + noun + " match \"" + m_filter.Value + "\"";
		}

		private void RebuildAll()
		{
			StopEverything();
			BuildSoundGroups();
			BuildVFXList();
			m_vfxIndex = 0;
			m_projIndex = 0;
			m_blastIndex = 0;
			m_animIndex = 0;
			m_itemVFXIndex = 0;
			m_soundIndex = 0;
			for (int i = 0; i < Groups.Length; i++)
			{
				if (Current.Count != 0)
				{
					break;
				}
				m_groupIndex = Wrap(m_groupIndex, 1, Groups.Length);
			}
			int num = m_vfxList.Count + m_itemVFXList.Count + m_projList.Count + m_blastList.Count + m_animList.Count;
			string[] groups = Groups;
			foreach (string key in groups)
			{
				num += m_byGroup[key].Count;
			}
			if (!FilterActive)
			{
				Log.LogMessage((object)"Filter cleared - browsing everything again.");
				Notify("Filter cleared");
				return;
			}
			if (num == 0)
			{
				Log.LogWarning((object)("Filter \"" + m_filter.Value + "\" matches NOTHING. Every mode is empty and the browse keys will do nothing until you clear it."));
				Notify("Filter \"" + m_filter.Value + "\" matches nothing");
				return;
			}
			Log.LogMessage((object)("Filter \"" + m_filter.Value + "\": " + num + " assets match."));
			Notify("Filter \"" + m_filter.Value + "\" - " + num + " match");
		}

		private void BuildAnimationList()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			bool flag = m_allowHarmfulAnimations != null && m_allowHarmfulAnimations.Value;
			m_animList.Clear();
			m_animTotal = 0;
			foreach (SpellCastType value in Enum.GetValues(typeof(SpellCastType)))
			{
				if ((int)value != -1 && (flag || !IsHarmful(value)))
				{
					m_animTotal++;
					if (Matches(((object)value/*cast due to .constrained prefix*/).ToString()))
					{
						m_animList.Add(value);
					}
				}
			}
			if (m_animIndex >= m_animList.Count)
			{
				m_animIndex = 0;
			}
		}

		private void ToggleMode()
		{
			for (int i = 0; i < 6; i++)
			{
				m_mode = (Mode)((int)(m_mode + 1) % 6);
				if (ModeAvailable(m_mode))
				{
					break;
				}
			}
			StopEverything();
			switch (m_mode)
			{
			case Mode.VFX:
				Notify("== VFX == " + CountLabel(m_vfxList.Count, m_vfxTotal, "prefabs"));
				break;
			case Mode.ItemVFX:
				Notify("== ITEM VFX == " + CountLabel(m_itemVFXList.Count, m_itemVFXTotal, "sets"));
				break;
			case Mode.Projectile:
				Notify("== PROJECTILE == " + CountLabel(m_projList.Count, m_projTotal, "prefabs"));
				break;
			case Mode.Blast:
				Notify("== BLAST == " + CountLabel(m_blastList.Count, m_blastTotal, "prefabs"));
				break;
			case Mode.Animation:
				Notify("== ANIMATION == " + CountLabel(m_animList.Count, m_animTotal, "casts") + (m_allowHarmfulAnimations.Value ? ", harmful included" : ""));
				break;
			default:
				Notify("== SOUND == " + Groups[m_groupIndex] + ", " + CountLabel(Current.Count, GroupTotal(), "sounds"));
				break;
			}
			Play();
		}

		private unsafe void PlayAnimation()
		{
			//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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Invalid comparison between Unknown and I4
			//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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			if (m_animList.Count == 0)
			{
				return;
			}
			Character val = LocalPlayer();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			SpellCastType val2 = m_animList[m_animIndex];
			string text = "[" + (m_animIndex + 1) + "/" + m_animList.Count + "] " + ((object)(*(SpellCastType*)(&val2))/*cast due to .constrained prefix*/).ToString();
			ClearAnimation();
			if ((int)val2 >= 500)
			{
				val.ForceCastSpell(val2, ((Component)val).gameObject, (SpellCastModifier)2, 0, -1f);
				text += "  (weapon attack)";
			}
			else
			{
				bool flag = IsMobileCast(val2);
				bool num = val.CastSpell(val2, ((Component)val).gameObject, (SpellCastModifier)(flag ? 1 : 0), 0, -1f);
				if (flag)
				{
					text += "  (mobile)";
				}
				if (IsUnusedCast(val2))
				{
					text += "  (unused)";
				}
				if (!num)
				{
					text += "  (refused)";
				}
			}
			m_animPlaying = true;
			Notify(text);
			Log.LogMessage((object)text);
		}

		private void ClearAnimation()
		{
			if (m_animPlaying)
			{
				m_animPlaying = false;
				Character val = LocalPlayer();
				if (Object.op_Implicit((Object)(object)val))
				{
					val.ForceCancel(true, true);
				}
			}
		}

		private void StopEverything()
		{
			StopCurrentSound();
			ClearVFX();
			ClearItemVFX();
			ClearProjectile();
			ClearBlast();
			ClearAnimation();
		}

		private bool ModeAvailable(Mode mode)
		{
			switch (mode)
			{
			case Mode.Animation:
				return m_enableAnimations.Value;
			case Mode.ItemVFX:
				if (m_enableItemVFX.Value)
				{
					return ItemVFXAvailable;
				}
				return false;
			default:
				return true;
			}
		}

		private void FindCustomEffects()
		{
			m_itemVFXMissing = "needs Custom Effects 1.4.0 or later";
			if (!Chainloader.PluginInfos.TryGetValue("com.wrango.customeffects", out var value) || value == null || (Object)(object)value.Instance == (Object)null)
			{
				return;
			}
			if (value.Metadata.Version < FirstItemVFXVersion)
			{
				m_itemVFXMissing = m_itemVFXMissing + " (found " + value.Metadata.Version?.ToString() + ")";
				return;
			}
			Assembly assembly = ((object)value.Instance).GetType().Assembly;
			Type type = assembly.GetType("CustomEffects.ItemVFX");
			Type type2 = assembly.GetType("CustomEffects.ItemVFXSet");
			FieldInfo fieldInfo = ((type != null) ? type.GetField("VFX") : null);
			if (type == null || type2 == null || fieldInfo == null)
			{
				m_itemVFXMissing = "Custom Effects " + value.Metadata.Version?.ToString() + " has no ItemVFX";
				return;
			}
			m_itemVFXType = type;
			m_itemVFXSetType = type2;
			m_itemVFXField = fieldInfo;
			m_itemVFXMissing = null;
		}

		private void BuildItemVFXList()
		{
			m_itemVFXList.Clear();
			m_itemVFXTotal = 0;
			if (m_itemVFXSetType != null)
			{
				foreach (object value in Enum.GetValues(m_itemVFXSetType))
				{
					m_itemVFXTotal++;
					if (Matches(value.ToString()))
					{
						m_itemVFXList.Add(value);
					}
				}
			}
			if (m_itemVFXIndex >= m_itemVFXList.Count)
			{
				m_itemVFXIndex = 0;
			}
		}

		private void PlayItemVFX()
		{
			if (m_itemVFXList.Count == 0)
			{
				return;
			}
			Character val = LocalPlayer();
			if (Object.op_Implicit((Object)(object)val))
			{
				object obj = m_itemVFXList[m_itemVFXIndex];
				string text = "[" + (m_itemVFXIndex + 1) + "/" + m_itemVFXList.Count + "] " + obj;
				if (!Object.op_Implicit((Object)(object)m_previewWeapon) && !SpawnPreviewWeapon(val))
				{
					text = text + "  (could not spawn item " + PreviewWeapons[m_weaponIndex] + ")";
				}
				else
				{
					ApplyItemVFX(obj);
					text = text + "  (on " + ((Item)m_previewWeapon).Name + ")";
				}
				Notify(text);
				Log.LogMessage((object)text);
			}
		}

		private void StepWeapon(int delta)
		{
			m_weaponIndex = Wrap(m_weaponIndex, delta, PreviewWeapons.Length);
			DestroyPreviewWeapon();
			Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(PreviewWeapons[m_weaponIndex]);
			Notify("== " + (Object.op_Implicit((Object)(object)itemPrefab) ? itemPrefab.Name : PreviewWeapons[m_weaponIndex].ToString()) + " == " + (m_weaponIndex + 1) + "/" + PreviewWeapons.Length + " weapons");
			Play();
		}

		private bool SpawnPreviewWeapon(Character player)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			Item val = ItemManager.Instance.GenerateItemNetwork(PreviewWeapons[m_weaponIndex]);
			Equipment val2 = (Equipment)(object)((val is Equipment) ? val : null);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					ItemManager.Instance.DestroyItem(val.UID);
				}
				return false;
			}
			((Item)val2).ForceNonSavable = true;
			((Item)val2).ClientGenerated = PhotonNetwork.isNonMasterClientInRoom;
			((Item)val2).SetKeepAlive();
			ClearHandsFor(player, val2);
			((Component)val2).transform.SetParent(((Component)player.Inventory.GetMatchingEquipmentSlot(val2.EquipSlot)).transform);
			((Item)val2).ForceStartInit();
			m_previewWeapon = val2;
			m_previewItemVFX = null;
			return true;
		}

		private void ClearHandsFor(Character player, Equipment weapon)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			Item equippedItem = player.Inventory.GetEquippedItem((EquipmentSlotIDs)5);
			Equipment val = (Equipment)(object)((equippedItem is Equipment) ? equippedItem : null);
			Item equippedItem2 = player.Inventory.GetEquippedItem((EquipmentSlotIDs)6);
			Equipment val2 = (Equipment)(object)((equippedItem2 is Equipment) ? equippedItem2 : null);
			if ((Object)(object)val2 == (Object)(object)val)
			{
				val2 = null;
			}
			bool flag = weapon.TwoHanded || (int)weapon.EquipSlot == 6;
			if (weapon.TwoHanded || (int)weapon.EquipSlot == 5 || (flag && Object.op_Implicit((Object)(object)val) && val.TwoHanded))
			{
				PutAway(player, val);
			}
			if (flag)
			{
				PutAway(player, val2);
			}
		}

		private void PutAway(Character player, Equipment item)
		{
			if (Object.op_Implicit((Object)(object)item) && !((Item)item).IsPendingDestroy)
			{
				if (!m_restoreUIDs.Contains(((Item)item).UID))
				{
					m_restoreUIDs.Add(((Item)item).UID);
				}
				player.Inventory.UnequipItem(item);
				((Item)item).ForceUpdateParentChange();
			}
		}

		private void ApplyItemVFX(object set)
		{
			if (!Object.op_Implicit((Object)(object)m_previewItemVFX))
			{
				m_previewItemVFX = ((Component)m_previewWeapon).gameObject.AddComponent(m_itemVFXType);
				SetItemVFXList(set);
				m_pendingSet = null;
			}
			else
			{
				SetItemVFXList(null);
				m_pendingSet = set;
				m_pendingAfterFrame = Time.frameCount;
			}
		}

		private void SetItemVFXList(object set)
		{
			Array array = Array.CreateInstance(m_itemVFXSetType, (set != null) ? 1 : 0);
			if (set != null)
			{
				array.SetValue(set, 0);
			}
			m_itemVFXField.SetValue(m_previewItemVFX, array);
		}

		private void DestroyPreviewWeapon()
		{
			m_pendingSet = null;
			m_previewItemVFX = null;
			if (!Object.op_Implicit((Object)(object)m_previewWeapon))
			{
				m_previewWeapon = null;
				return;
			}
			string uID = ((Item)m_previewWeapon).UID;
			m_previewWeapon = null;
			ItemManager.Instance.DestroyItem(uID);
			if (!PhotonNetwork.isMasterClient)
			{
				ItemManager.Instance.SendDestroyItem(uID);
			}
		}

		private void ClearItemVFX()
		{
			DestroyPreviewWeapon();
			if (m_restoreUIDs.Count == 0)
			{
				return;
			}
			Character val = LocalPlayer();
			if (Object.op_Implicit((Object)(object)val))
			{
				foreach (string restoreUID in m_restoreUIDs)
				{
					Item item = ItemManager.Instance.GetItem(restoreUID);
					Equipment val2 = (Equipment)(object)((item is Equipment) ? item : null);
					if (Object.op_Implicit((Object)(object)val2) && (Object)(object)((EffectSynchronizer)val2).OwnerCharacter == (Object)(object)val)
					{
						val.Inventory.EquipItem(val2, false);
					}
				}
			}
			m_restoreUIDs.Clear();
		}

		private void ClearVFX()
		{
			if (Object.op_Implicit((Object)(object)m_vfxInstance))
			{
				VFXSystem component = m_vfxInstance.GetComponent<VFXSystem>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.Stop();
				}
				Object.Destroy((Object)(object)m_vfxInstance);
				m_vfxInstance = null;
			}
		}

		private unsafe void PlayVFX()
		{
			//IL_0020: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			if (m_vfxList.Count == 0)
			{
				return;
			}
			ClearVFX();
			VFXPrefabs val = m_vfxList[m_vfxIndex];
			string text = "[" + (m_vfxIndex + 1) + "/" + m_vfxList.Count + "] " + ((object)(*(VFXPrefabs*)(&val))/*cast due to .constrained prefix*/).ToString();
			Character val2 = LocalPlayer();
			GameObject vfxSystem = SL_PlayVFX.GetVfxSystem(val);
			if (Object.op_Implicit((Object)(object)val2) && vfxSystem != null)
			{
				m_vfxInstance = Object.Instantiate<GameObject>(vfxSystem);
				m_vfxInstance.transform.SetParent(((Component)val2).transform);
				UnityEngineExtensions.ResetLocal(m_vfxInstance.transform, true);
				m_vfxInstance.transform.localPosition = m_vfxPosition.Value;
				m_vfxInstance.SetActive(true);
				VFXSystem component = m_vfxInstance.GetComponent<VFXSystem>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					Log.LogMessage((object)(text + "  (no VFXSystem component)"));
					return;
				}
				component.Play(val2, (Character)null);
			}
			else if (vfxSystem == null)
			{
				Log.LogMessage((object)(text + "  (prefab not found)"));
				return;
			}
			Notify(text);
			Log.LogMessage((object)text);
		}

		private void Notify(string message)
		{
			Character val = LocalPlayer();
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.CharacterUI))
			{
				val.CharacterUI.ShowInfoNotification(message);
			}
		}

		private static Character LocalPlayer()
		{
			if (!Object.op_Implicit((Object)(object)CharacterManager.Instance))
			{
				return null;
			}
			foreach (Character value in CharacterManager.Instance.Characters.Values)
			{
				if (Object.op_Implicit((Object)(object)value) && value.IsLocalPlayer)
				{
					return value;
				}
			}
			return null;
		}

		private void ClearBlast()
		{
			if (Object.op_Implicit((Object)(object)m_blasterObject))
			{
				Object.Destroy((Object)(object)m_blasterObject);
				m_blasterObject = null;
				m_blaster = null;
			}
		}

		private unsafe void PlayBlast()
		{
			//IL_0020: 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_007f: 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_00ab: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			if (m_blastList.Count == 0)
			{
				return;
			}
			ClearBlast();
			BlastPrefabs val = m_blastList[m_blastIndex];
			string text = "[" + (m_blastIndex + 1) + "/" + m_blastList.Count + "] " + ((object)(*(BlastPrefabs*)(&val))/*cast due to .constrained prefix*/).ToString() + BlastShape(val);
			Character val2 = LocalPlayer();
			if (Object.op_Implicit((Object)(object)val2))
			{
				m_blasterObject = new GameObject("AssetBrowserBlaster");
				m_blasterObject.transform.SetParent(((Component)val2).transform, false);
				m_blasterObject.transform.localPosition = Vector3.zero;
				m_blaster = m_blasterObject.AddComponent<ShootBlast>();
				((SL_Effect)new SL_ShootBlast
				{
					SyncType = (SyncTypes)2,
					CastPosition = (CastPositionType)0,
					LocalPositionAdd = m_blastPosition.Value,
					NoAim = true,
					TargetType = (TargetTypes)0,
					TransformName = "BlasterTransform",
					BaseBlast = val,
					Radius = 3f,
					RefreshTime = 0f,
					BlastLifespan = m_projectileLifespan.Value,
					InstantiatedAmount = 1,
					Interruptible = false,
					MaxHitTargetCount = 1,
					AffectHitTargetCenter = false,
					HitOnShoot = false,
					IgnoreShooter = true,
					IgnoreStop = false,
					NoTargetForwardMultiplier = 1f,
					ParentToShootTransform = false,
					UseTargetCharacterPositionType = false,
					DontPlayHitSound = false,
					FXIsWorld = false,
					PlaySounOnRefresh = false,
					DelayFirstShoot = 0f,
					PlayFXOnRefresh = false,
					EffectBehaviour = (EditBehaviours)2,
					BlastEffects = (SL_EffectTransform[])(object)new SL_EffectTransform[0]
				}).ApplyToComponent<ShootBlast>(m_blaster);
				try
				{
					((Shooter)m_blaster).Setup((Factions[])(object)new Factions[1], m_blasterObject.transform);
					((Effect)m_blaster).Affect(val2);
				}
				catch (Exception ex)
				{
					text += ((ex is NullReferenceException) ? "  (cannot preview: needs an owning character)" : ("  (cannot preview: " + ex.GetType().Name + ")"));
				}
				Notify(text);
				Log.LogMessage((object)text);
			}
		}

		private void ClearProjectile()
		{
			if (Object.op_Implicit((Object)(object)m_projInstance))
			{
				Object.Destroy((Object)(object)m_projInstance);
				m_projInstance = null;
			}
			if (Object.op_Implicit((Object)(object)m_shooterObject))
			{
				Object.Destroy((Object)(object)m_shooterObject);
				m_shooterObject = null;
				m_shooter = null;
			}
		}

		private unsafe void PlayProjectile()
		{
			//IL_0020: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00d5: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			if (m_projList.Count == 0)
			{
				return;
			}
			ClearProjectile();
			ProjectilePrefabs baseProjectile = m_projList[m_projIndex];
			string text = "[" + (m_projIndex + 1) + "/" + m_projList.Count + "] " + ((object)(*(ProjectilePrefabs*)(&baseProjectile))/*cast due to .constrained prefix*/).ToString();
			Character val = LocalPlayer();
			if (Object.op_Implicit((Object)(object)val))
			{
				m_shooterObject = new GameObject("AssetBrowserShooter");
				m_shooterObject.transform.SetParent(((Component)val).transform, false);
				m_shooter = m_shooterObject.AddComponent<ShootProjectile>();
				m_shooterObject.transform.localPosition = Vector3.zero;
				((SL_Effect)new SL_ShootProjectile
				{
					SyncType = (SyncTypes)2,
					CastPosition = (CastPositionType)0,
					LocalPositionAdd = m_projPosition.Value,
					NoAim = false,
					TargetType = (TargetTypes)0,
					TransformName = "ShooterTransform",
					BaseProjectile = baseProjectile,
					InstantiatedAmount = 1,
					Lifespan = m_projectileLifespan.Value,
					LateShootTime = 0.1f,
					Unblockable = false,
					EffectsOnlyIfHitCharacter = false,
					EndMode = (EndLifeMode)0,
					DisableOnHit = true,
					IgnoreShooterCollision = true,
					TargetingMode = (TargetMode)0,
					TargetCountPerProjectile = 1,
					TargetRange = 0f,
					AutoTarget = false,
					AutoTargetMaxAngle = 360f,
					AutoTargetRange = 5f,
					ProjectileForce = m_projectileForce.Value,
					DefenseLength = 3f,
					DefenseRange = 3f,
					TrailEnabled = false,
					TrailTime = 0.075f,
					LightIntensityFade = new Vector2(10f, 2f),
					PointOffset = Vector3.zero,
					AddDirection = Vector3.zero,
					AddRotationForce = Vector3.zero,
					YMagnitudeAffect = 0f,
					YMagnitudeForce = 0f,
					CameraAddYDirection = 0f,
					EffectBehaviour = (EditBehaviours)2,
					ProjectileEffects = (SL_EffectTransform[])(object)new SL_EffectTransform[0]
				}).ApplyToComponent<ShootProjectile>(m_shooter);
				((Shooter)m_shooter).Setup((Factions[])(object)new Factions[1], m_shooterObject.transform);
				Projectile_Shoot_KeepAlive.PreviewShotPending = true;
				try
				{
					((Effect)m_shooter).Affect(val);
				}
				finally
				{
					Projectile_Shoot_KeepAlive.PreviewShotPending = false;
				}
				if (Object.op_Implicit((Object)(object)m_shooter.BaseProjectile))
				{
					m_projInstance = ((Component)m_shooter.BaseProjectile).gameObject;
				}
				Notify(text);
				Log.LogMessage((object)text);
			}
		}

		static AssetBrowserPlugin()
		{
			SpellCastType[] array = new SpellCastType[6];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			HarmfulAnimations = (SpellCastType[])(object)array;
			SpellCastType[] array2 = new SpellCastType[7];
			RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			MobileCasts = (SpellCastType[])(object)array2;
			UnusedCasts = (SpellCastType[])(object)new SpellCastType[2]
			{
				(SpellCastType)21,
				(SpellCastType)24
			};
			FirstItemVFXVersion = new Version(1, 4, 0);
			PreviewWeapons = new int[15]
			{
				2000010, 2010000, 2020010, 2100080, 2110030, 2120080, 2130110, 2140000, 2150050, 2160000,
				2200000, 5110000, 5110030, 5110100, 2300000
			};
		}
	}
	internal sealed class ConfigurationManagerAttributes
	{
		public int? Order;
	}
	[HarmonyPatch(typeof(Projectile), "Shoot")]
	public class Projectile_Shoot_KeepAlive
	{
		internal static bool PreviewShotPending;

		private static readonly FieldRef<Projectile, bool> FirstUpdate = AccessTools.FieldRefAccess<Projectile, bool>("m_firstUpdate");

		[HarmonyPostfix]
		public static void Postfix(Projectile __instance)
		{
			if (PreviewShotPending && Object.op_Implicit((Object)(object)__instance))
			{
				FirstUpdate.Invoke(__instance) = false;
				if (!((Component)__instance).gameObject.activeSelf)
				{
					((Component)__instance).gameObject.SetActive(true);
				}
			}
		}
	}
}