Decompiled source of Custom Effects v1.4.0

plugins/CustomEffects.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Xml.Serialization;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SideLoader;
using UnityEngine;
using UnityEngine.Rendering;

[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("CustomEffects")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Custom Effects")]
[assembly: AssemblyTitle("CustomEffects")]
[assembly: AssemblyVersion("1.4.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 CustomEffects
{
	[BepInPlugin("com.wrango.customeffects", "Custom Effects", "1.4.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CustomEffectsPlugin : BaseUnityPlugin
	{
		public const string GUID = "com.wrango.customeffects";

		public const string NAME = "Custom Effects";

		public const string VERSION = "1.4.0";

		public static CustomEffectsPlugin Instance;

		public static Harmony harmony;

		internal static ManualLogSource Log;

		internal void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			harmony = new Harmony("com.wrango.customeffects");
			harmony.PatchAll(typeof(StatusEffectManager_AddStatusEffect));
			harmony.PatchAll(typeof(Character_AnimSound));
			harmony.PatchAll(typeof(Character_AnimSoundRandom));
			harmony.PatchAll(typeof(CharacterSkillKnowledge_AddItem));
			harmony.PatchAll(typeof(StatusEffectManager_AddStatusEffect_Visuals));
			harmony.PatchAll(typeof(StatusEffectManager_OnReceiveActivatedStatusEffects));
			harmony.PatchAll(typeof(Character_ReceiveHit_Blind));
			harmony.PatchAll(typeof(Character_ReceiveHitPlain_Blind));
			harmony.PatchAll(typeof(Character_ReceiveBlock_Blind));
			harmony.PatchAll(typeof(Character_ReceiveBlockPlain_Blind));
			harmony.PatchAll(typeof(StatusEffectManager_AddStatusEffect_Blind));
			harmony.PatchAll(typeof(StatusEffectManager_AddStatusEffectBuildUp_Blind));
			harmony.PatchAll(typeof(Weapon_HasHit_Blind));
			harmony.PatchAll(typeof(Item_ReduceDurability_Blind));
			Log.LogMessage((object)"Custom Effects 1.4.0 loaded. Effects: SL_UseSkill, SL_Banish, SL_LearnSkillHidden, SL_PlayVFXOnWeapon, SL_PlayVFXOnChar, SL_PlayVFXPulsed, SL_PlayTimedSound, SL_ReliableVisuals, SL_RemoveStatusParentOwner, SL_Blind. Item extensions: SL_ItemVFX.");
		}
	}
	public class SL_Banish : SL_Effect, ICustomModel
	{
		public float Duration = 10f;

		public Type SLTemplateModel => typeof(SL_Banish);

		public Type GameModel => typeof(BanishEffect);

		public override void ApplyToComponent<T>(T component)
		{
			(component as BanishEffect).Duration = Duration;
		}

		public override void SerializeEffect<T>(T effect)
		{
			Duration = (effect as BanishEffect).Duration;
		}
	}
	public class BanishEffect : Effect
	{
		public float Duration = 10f;

		internal static readonly HashSet<string> Banished = new HashSet<string>();

		private static readonly Action<LocalCharacterControl> ControlReleaseTarget = AccessTools.MethodDelegate<Action<LocalCharacterControl>>(AccessTools.Method(typeof(LocalCharacterControl), "ReleaseTarget", (Type[])null, (Type[])null), (object)null, true);

		internal static bool IsBanished(Character c)
		{
			//IL_000e: 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)
			if (Object.op_Implicit((Object)(object)c))
			{
				HashSet<string> banished = Banished;
				UID uID = c.UID;
				return banished.Contains(((UID)(ref uID)).Value);
			}
			return false;
		}

		internal static bool IsLocallyControlled(Character c)
		{
			if (!Object.op_Implicit((Object)(object)c))
			{
				return false;
			}
			if (c.IsAI)
			{
				return PhotonNetwork.isMasterClient;
			}
			return c.IsLocalPlayer;
		}

		private static int ReleaseLocksOn(Character banished)
		{
			int num = 0;
			if (!Object.op_Implicit((Object)(object)CharacterManager.Instance))
			{
				return num;
			}
			foreach (Character value in CharacterManager.Instance.Characters.Values)
			{
				if (!Object.op_Implicit((Object)(object)value) || !value.IsLocalPlayer)
				{
					continue;
				}
				TargetingSystem targetingSystem = value.TargetingSystem;
				if (!((Object)(object)targetingSystem == (Object)null) && targetingSystem.Locked && !((Object)(object)targetingSystem.LockedCharacter != (Object)(object)banished))
				{
					LocalCharacterControl component = ((Component)value).GetComponent<LocalCharacterControl>();
					if (Object.op_Implicit((Object)(object)component) && ControlReleaseTarget != null)
					{
						ControlReleaseTarget(component);
					}
					else
					{
						targetingSystem.ReleaseTarget();
					}
					num++;
				}
			}
			return num;
		}

		internal static void BeginBanish(Character character, float duration, float delay, StatusEffect status)
		{
			//IL_000a: 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)
			if (Object.op_Implicit((Object)(object)character))
			{
				UID uID = character.UID;
				string value = ((UID)(ref uID)).Value;
				if (!Banished.Contains(value) && Object.op_Implicit((Object)(object)CustomEffectsPlugin.Instance))
				{
					Banished.Add(value);
					((MonoBehaviour)CustomEffectsPlugin.Instance).StartCoroutine(BanishRoutineFor(character, value, duration, delay, status));
				}
			}
		}

		protected override void ActivateLocally(Character _affectedCharacter, object[] _infos)
		{
			if (Object.op_Implicit((Object)(object)_affectedCharacter))
			{
				BeginBanish(_affectedCharacter, Duration, 0f, ((Component)this).GetComponentInParent<StatusEffect>());
			}
		}

		private static IEnumerator BanishRoutineFor(Character character, string uid, float duration, float delay, StatusEffect status)
		{
			try
			{
				if (delay > 0f)
				{
					yield return (object)new WaitForSeconds(delay);
				}
				if (!Object.op_Implicit((Object)(object)character))
				{
					yield break;
				}
				bool controls = IsLocallyControlled(character);
				List<Renderer> hiddenRenderers = new List<Renderer>();
				List<Behaviour> disabledHitboxes = new List<Behaviour>();
				List<Collider> disabledColliders = new List<Collider>();
				List<SoundPlayer> silencedSounds = new List<SoundPlayer>();
				List<bool> silencedWasStopOnDisable = new List<bool>();
				List<bool> silencedWasEnabled = new List<bool>();
				bool moveBlockDisabled = false;
				bool controllerDisabled = false;
				Vector3 frozenPosition = ((Component)character).transform.position;
				bool wasQuestNonTargetable = character.QuestNonTargetable;
				CharacterAI ai = ((Component)character).GetComponent<CharacterAI>();
				bool aiWasEnabled = Object.op_Implicit((Object)(object)ai) && ((Behaviour)ai).enabled;
				bool aiRootWasActive = false;
				if (Object.op_Implicit((Object)(object)character.VisualHolderTrans))
				{
					Renderer[] componentsInChildren = ((Component)character.VisualHolderTrans).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val in componentsInChildren)
					{
						if (Object.op_Implicit((Object)(object)val) && val.enabled)
						{
							val.enabled = false;
							hiddenRenderers.Add(val);
						}
					}
				}
				if (character.Hitboxes != null)
				{
					Hitbox[] hitboxes = character.Hitboxes;
					foreach (Hitbox val2 in hitboxes)
					{
						if (Object.op_Implicit((Object)(object)val2))
						{
							if (((Behaviour)val2).enabled)
							{
								((Behaviour)val2).enabled = false;
								disabledHitboxes.Add((Behaviour)(object)val2);
							}
							Collider component = ((Component)val2).GetComponent<Collider>();
							if (Object.op_Implicit((Object)(object)component) && component.enabled)
							{
								component.enabled = false;
								disabledColliders.Add(component);
							}
						}
					}
				}
				SoundPlayer[] componentsInChildren2 = ((Component)character).GetComponentsInChildren<SoundPlayer>(true);
				foreach (SoundPlayer val3 in componentsInChildren2)
				{
					if (Object.op_Implicit((Object)(object)val3))
					{
						silencedSounds.Add(val3);
						silencedWasStopOnDisable.Add(val3.StopOnDisable);
						silencedWasEnabled.Add(((Behaviour)val3).enabled);
						val3.StopOnDisable = true;
						((Behaviour)val3).enabled = false;
					}
				}
				if (Object.op_Implicit((Object)(object)character.CharMoveBlockCollider) && ((Collider)character.CharMoveBlockCollider).enabled)
				{
					((Collider)character.CharMoveBlockCollider).enabled = false;
					moveBlockDisabled = true;
				}
				if (Object.op_Implicit((Object)(object)character.CharacterController) && ((Collider)character.CharacterController).enabled)
				{
					((Collider)character.CharacterController).enabled = false;
					controllerDisabled = true;
				}
				character.QuestNonTargetable = true;
				int num = ReleaseLocksOn(character);
				if (controls)
				{
					if (controllerDisabled)
					{
						frozenPosition = ((Component)character).transform.position;
					}
					if (Object.op_Implicit((Object)(object)ai))
					{
						aiRootWasActive = Object.op_Implicit((Object)(object)ai.AIStatesRoot) && ((Component)ai.AIStatesRoot).gameObject.activeSelf;
						if (aiRootWasActive)
						{
							ai.SetNPCActive(false);
						}
						((Behaviour)ai).enabled = false;
					}
					character.Stun(-1f);
					if (Object.op_Implicit((Object)(object)character.Animator))
					{
						character.Animator.speed = 0f;
					}
				}
				CustomEffectsPlugin.Log.LogMessage((object)("[Banish] t=" + Time.time.ToString("F2") + " " + character.Name + " for " + duration + "s | controls=" + controls + " renderers=" + hiddenRenderers.Count + " sounds=" + silencedSounds.Count + " hitboxes=" + disabledHitboxes.Count + " locksReleased=" + num + " aiRootStopped=" + aiRootWasActive));
				float elapsed = 0f;
				bool died = false;
				bool followStatus = !controls && Object.op_Implicit((Object)(object)status);
				while (Object.op_Implicit((Object)(object)character) && elapsed < duration)
				{
					if (!character.Alive)
					{
						died = true;
						break;
					}
					if (followStatus && !Object.op_Implicit((Object)(object)status))
					{
						break;
					}
					if (controls && controllerDisabled)
					{
						((Component)character).transform.position = frozenPosition;
					}
					elapsed += Time.deltaTime;
					yield return null;
				}
				if (!Object.op_Implicit((Object)(object)character))
				{
					yield break;
				}
				for (int j = 0; j < silencedSounds.Count; j++)
				{
					if (Object.op_Implicit((Object)(object)silencedSounds[j]))
					{
						((Behaviour)silencedSounds[j]).enabled = silencedWasEnabled[j];
						silencedSounds[j].StopOnDisable = silencedWasStopOnDisable[j];
					}
				}
				foreach (Renderer item in hiddenRenderers)
				{
					if (Object.op_Implicit((Object)(object)item))
					{
						item.enabled = true;
					}
				}
				foreach (Behaviour item2 in disabledHitboxes)
				{
					if (Object.op_Implicit((Object)(object)item2))
					{
						item2.enabled = true;
					}
				}
				foreach (Collider item3 in disabledColliders)
				{
					if (Object.op_Implicit((Object)(object)item3))
					{
						item3.enabled = true;
					}
				}
				bool flag = died || !character.Alive;
				if (controllerDisabled && Object.op_Implicit((Object)(object)character.CharacterController) && !flag)
				{
					if (controls)
					{
						((Component)character).transform.position = frozenPosition;
					}
					((Collider)character.CharacterController).enabled = true;
				}
				character.QuestNonTargetable = wasQuestNonTargetable;
				ReleaseLocksOn(character);
				if (controls)
				{
					character.StopStun();
					if (Object.op_Implicit((Object)(object)ai))
					{
						if (aiWasEnabled)
						{
							((Behaviour)ai).enabled = true;
						}
						if (aiRootWasActive && !died && character.Alive)
						{
							ai.SetNPCActive(true);
						}
					}
				}
				if (moveBlockDisabled && Object.op_Implicit((Object)(object)character.CharMoveBlockCollider) && !flag)
				{
					((Collider)character.CharMoveBlockCollider).enabled = true;
				}
				CustomEffectsPlugin.Log.LogMessage((object)("[Banish] t=" + Time.time.ToString("F2") + " " + character.Name + (died ? " died while banished - restored as a body." : " returned.")));
			}
			finally
			{
				Banished.Remove(uid);
			}
		}
	}
	[HarmonyPatch(typeof(StatusEffectManager), "AddStatusEffect", new Type[]
	{
		typeof(StatusEffect),
		typeof(Character),
		typeof(string[])
	})]
	public class StatusEffectManager_AddStatusEffect
	{
		private static readonly FieldRef<StatusEffectManager, Character> ManagerCharacter = AccessTools.FieldRefAccess<StatusEffectManager, Character>("m_character");

		private static bool s_loggedOnce;

		[HarmonyPostfix]
		public static void Postfix(StatusEffectManager __instance, StatusEffect __result)
		{
			if ((Object)(object)__result == (Object)null)
			{
				return;
			}
			BanishEffect componentInChildren = ((Component)__result).GetComponentInChildren<BanishEffect>(true);
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				return;
			}
			Character val = ManagerCharacter.Invoke(__instance);
			if (Object.op_Implicit((Object)(object)val) && (((Component)__result).gameObject.activeInHierarchy || !BanishEffect.IsLocallyControlled(val)))
			{
				if (!s_loggedOnce)
				{
					s_loggedOnce = true;
					CustomEffectsPlugin.Log.LogMessage((object)"SL_Banish: status-arrival patch is live - banish now runs on every client.");
				}
				BanishEffect.BeginBanish(val, componentInChildren.Duration, ((Effect)componentInChildren).Delay, __result);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "AnimSound")]
	public class Character_AnimSound
	{
		[HarmonyPrefix]
		public static bool Prefix(Character __instance)
		{
			return !BanishEffect.IsBanished(__instance);
		}
	}
	[HarmonyPatch(typeof(Character), "AnimSoundRandom")]
	public class Character_AnimSoundRandom
	{
		[HarmonyPrefix]
		public static bool Prefix(Character __instance)
		{
			return !BanishEffect.IsBanished(__instance);
		}
	}
	public enum BlindCue
	{
		Both,
		Sound,
		Visual,
		None
	}
	public class SL_Blind : SL_Effect, ICustomModel
	{
		public bool Consume = true;

		public float Grace = 0.2f;

		public BlindCue PlayCue;

		public VFXPrefabs CueVFX;

		public List<Sounds> CueSounds = new List<Sounds>();

		public Type SLTemplateModel => typeof(SL_Blind);

		public Type GameModel => typeof(BlindEffect);

		public override void ApplyToComponent<T>(T component)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			BlindEffect blindEffect = component as BlindEffect;
			blindEffect.Consume = Consume;
			blindEffect.Grace = Grace;
			blindEffect.PlayCue = PlayCue;
			blindEffect.CueSounds = (Sounds[])((CueSounds != null) ? ((Array)CueSounds.ToArray()) : ((Array)new Sounds[0]));
			blindEffect.CueVFX = null;
			GameObject vfxSystem = SL_PlayVFX.GetVfxSystem(CueVFX);
			if (vfxSystem != null)
			{
				GameObject val = Object.Instantiate<GameObject>(vfxSystem);
				Object.DontDestroyOnLoad((Object)(object)val);
				val.SetActive(false);
				blindEffect.CueVFX = val.transform;
			}
		}

		public override void SerializeEffect<T>(T effect)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			BlindEffect blindEffect = effect as BlindEffect;
			Consume = blindEffect.Consume;
			Grace = blindEffect.Grace;
			PlayCue = blindEffect.PlayCue;
			CueSounds = ((blindEffect.CueSounds != null) ? new List<Sounds>(blindEffect.CueSounds) : new List<Sounds>());
			VFXSystem val = (Object.op_Implicit((Object)(object)blindEffect.CueVFX) ? ((Component)blindEffect.CueVFX).GetComponent<VFXSystem>() : null);
			CueVFX = (VFXPrefabs)(Object.op_Implicit((Object)(object)val) ? ((int)SL_PlayVFX.GetVFXSystemEnum(val)) : 0);
		}
	}
	public class BlindEffect : Effect
	{
		public bool Consume = true;

		public float Grace = 0.2f;

		public BlindCue PlayCue;

		public Transform CueVFX;

		public Sounds[] CueSounds = (Sounds[])(object)new Sounds[0];

		private const float CueGap = 0.5f;

		private const string CueName = "SL_BlindCue";

		private const int MissLogLimit = 20;

		private static readonly Dictionary<string, BlindEffect> s_byStatus = new Dictionary<string, BlindEffect>();

		private static readonly Dictionary<string, float> s_lastCue = new Dictionary<string, float>();

		private static readonly HashSet<string> s_spending = new HashSet<string>();

		private static bool s_live;

		private static int s_missLogged;

		private static Weapon s_hitWeapon;

		private static bool s_hitMissed;

		private static readonly Dictionary<int, int> s_cuePlays = new Dictionary<int, int>();

		protected override void ActivateLocally(Character _affectedCharacter, object[] _infos)
		{
		}

		private static BlindEffect Of(StatusEffect status)
		{
			string identifierName = status.IdentifierName;
			if (string.IsNullOrEmpty(identifierName))
			{
				return Find(status);
			}
			if (s_byStatus.TryGetValue(identifierName, out var value))
			{
				return value;
			}
			StatusEffect val = ((ResourcesPrefabManager.Instance != null) ? ResourcesPrefabManager.Instance.GetStatusEffectPrefab(identifierName) : null);
			value = Find(Object.op_Implicit((Object)(object)val) ? val : status);
			s_byStatus[identifierName] = value;
			return value;
		}

		private static BlindEffect Find(StatusEffect status)
		{
			BlindEffect componentInChildren = ((Component)status).GetComponentInChildren<BlindEffect>(true);
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				return componentInChildren;
			}
			EffectSignature statusEffectSignature = status.StatusEffectSignature;
			if (!Object.op_Implicit((Object)(object)statusEffectSignature))
			{
				return null;
			}
			return ((Component)statusEffectSignature).GetComponentInChildren<BlindEffect>(true);
		}

		private static StatusEffect BlindingStatus(Character c, out BlindEffect blind)
		{
			blind = null;
			if (!Object.op_Implicit((Object)(object)c) || !Object.op_Implicit((Object)(object)c.StatusEffectMngr))
			{
				return null;
			}
			List<StatusEffect> statuses = c.StatusEffectMngr.Statuses;
			for (int i = 0; i < statuses.Count; i++)
			{
				StatusEffect val = statuses[i];
				if (Object.op_Implicit((Object)(object)val))
				{
					BlindEffect blindEffect = Of(val);
					if (Object.op_Implicit((Object)(object)blindEffect))
					{
						blind = blindEffect;
						return val;
					}
				}
			}
			return null;
		}

		internal static bool Misses(Character dealer, Character victim)
		{
			if (!Object.op_Implicit((Object)(object)dealer) || !Object.op_Implicit((Object)(object)victim) || (Object)(object)dealer == (Object)(object)victim)
			{
				return false;
			}
			BlindEffect blind;
			StatusEffect val = BlindingStatus(dealer, out blind);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			if ((Object)(object)dealer.TargetingSystem == (Object)null || !dealer.TargetingSystem.IsTargetable(victim))
			{
				return false;
			}
			if (!s_live)
			{
				s_live = true;
				CustomEffectsPlugin.Log.LogMessage((object)"SL_Blind: first miss - blind characters' blows now miss on this client.");
			}
			if (s_missLogged < 20)
			{
				s_missLogged++;
				CustomEffectsPlugin.Log.LogMessage((object)("SL_Blind: (" + s_missLogged + "/" + 20 + ") " + dealer.Name + " missed " + victim.Name + " (" + val.IdentifierName + ")"));
			}
			if (Object.op_Implicit((Object)(object)s_hitWeapon) && (Object)(object)((EffectSynchronizer)s_hitWeapon).OwnerCharacter == (Object)(object)dealer)
			{
				s_hitMissed = true;
			}
			if (blind.Consume)
			{
				Spend(dealer, val.IdentifierName, blind.Grace);
			}
			if (blind.PlayCue != BlindCue.None)
			{
				Cue(dealer, val, blind);
			}
			return true;
		}

		internal static void BeginHit(Weapon weapon)
		{
			s_hitWeapon = weapon;
			s_hitMissed = false;
		}

		internal static void EndHit()
		{
			s_hitWeapon = null;
			s_hitMissed = false;
		}

		internal static bool SparesDurability(Item item)
		{
			if (s_hitMissed && Object.op_Implicit((Object)(object)s_hitWeapon))
			{
				return (Object)(object)item == (Object)(object)s_hitWeapon;
			}
			return false;
		}

		private static void Spend(Character dealer, string id, float grace)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (dealer.IsPhotonPlayerLocal && Object.op_Implicit((Object)(object)CustomEffectsPlugin.Instance))
			{
				UID uID = dealer.UID;
				string text = ((UID)(ref uID)).Value + "|" + id;
				if (s_spending.Add(text))
				{
					((MonoBehaviour)CustomEffectsPlugin.Instance).StartCoroutine(SpendAfter(dealer, text, id, grace));
				}
			}
		}

		private static IEnumerator SpendAfter(Character dealer, string key, string id, float grace)
		{
			if (grace > 0f)
			{
				yield return (object)new WaitForSeconds(grace);
			}
			s_spending.Remove(key);
			if (Object.op_Implicit((Object)(object)dealer) && Object.op_Implicit((Object)(object)dealer.StatusEffectMngr) && Object.op_Implicit((Object)(object)dealer.StatusEffectMngr.GetStatusEffectOfName(id)))
			{
				dealer.StatusEffectMngr.RemoveStatusWithIdentifierName(id);
				CustomEffectsPlugin.Log.LogMessage((object)("SL_Blind: " + dealer.Name + "'s " + id + " is spent"));
			}
		}

		private static void Cue(Character dealer, StatusEffect status, BlindEffect blind)
		{
			//IL_0001: 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_0111: 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_0124: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			UID uID = dealer.UID;
			string value = ((UID)(ref uID)).Value;
			if (s_lastCue.TryGetValue(value, out var value2) && Time.time - value2 < 0.5f)
			{
				return;
			}
			s_lastCue[value] = Time.time;
			Transform val = (Object.op_Implicit((Object)(object)blind.CueVFX) ? blind.CueVFX : status.SpecialFXPrefab);
			if (Object.op_Implicit((Object)(object)val) && blind.PlayCue != BlindCue.Sound)
			{
				Transform val2 = ((Component)status).transform.Find("SL_BlindCue");
				if (!Object.op_Implicit((Object)(object)val2))
				{
					val2 = Object.Instantiate<Transform>(val, ((Component)status).transform);
					((Object)val2).name = "SL_BlindCue";
				}
				((Component)val2).gameObject.SetActive(true);
				VFXSystem component = ((Component)val2).GetComponent<VFXSystem>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.Play(dealer, (Character)null);
				}
				else
				{
					ParticleSystem[] componentsInChildren = ((Component)val2).GetComponentsInChildren<ParticleSystem>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].Play(false);
					}
				}
				StopAfterOneCycle(val2);
			}
			Sounds val3 = ((blind.CueSounds != null && blind.CueSounds.Length != 0) ? CharacterSoundManager.FindSound(blind.CueSounds) : status.SpecialSFX);
			if ((int)val3 != 0 && blind.PlayCue != BlindCue.Visual)
			{
				Global.AudioManager.PlaySoundAtPosition(val3, ((Component)dealer).transform, 0f, 1f, 1f, 1f, 1f);
			}
		}

		private static void StopAfterOneCycle(Transform cue)
		{
			//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)
			float num = 0f;
			ParticleSystem[] componentsInChildren = ((Component)cue).GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val in componentsInChildren)
			{
				float num2 = num;
				MainModule main = val.main;
				num = Mathf.Max(num2, ((MainModule)(ref main)).duration);
			}
			if (!(num <= 0f) && Object.op_Implicit((Object)(object)CustomEffectsPlugin.Instance))
			{
				int instanceID = ((Object)cue).GetInstanceID();
				s_cuePlays.TryGetValue(instanceID, out var value);
				value = (s_cuePlays[instanceID] = value + 1);
				((MonoBehaviour)CustomEffectsPlugin.Instance).StartCoroutine(StopAfter(cue, instanceID, value, num));
			}
		}

		private static IEnumerator StopAfter(Transform cue, int id, int play, float cycle)
		{
			yield return (object)new WaitForSeconds(cycle);
			if (!s_cuePlays.TryGetValue(id, out var value) || value != play)
			{
				yield break;
			}
			s_cuePlays.Remove(id);
			if (Object.op_Implicit((Object)(object)cue))
			{
				ParticleSystem[] componentsInChildren = ((Component)cue).GetComponentsInChildren<ParticleSystem>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].Stop(false, (ParticleSystemStopBehavior)1);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character), "ReceiveHit", new Type[]
	{
		typeof(Object),
		typeof(DamageList),
		typeof(Vector3),
		typeof(Vector3),
		typeof(float),
		typeof(float),
		typeof(Character),
		typeof(float),
		typeof(bool)
	})]
	public class Character_ReceiveHit_Blind
	{
		[HarmonyPrefix]
		public static bool Prefix(Character __instance, Object _damageSource, DamageList _damage, Character _dealerChar, ref DamageList __result)
		{
			try
			{
				if (_damageSource is StatusEffect || !BlindEffect.Misses(_dealerChar, __instance))
				{
					return true;
				}
				DamageList val = _damage.Clone();
				for (int i = 0; i < val.Count; i++)
				{
					val[i].Damage = 0f;
				}
				__result = val;
				return false;
			}
			catch (Exception ex)
			{
				CustomEffectsPlugin.Log.LogError((object)("SL_Blind: ReceiveHit prefix threw: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(Character), "ReceiveHit", new Type[]
	{
		typeof(Weapon),
		typeof(float),
		typeof(Vector3),
		typeof(Vector3),
		typeof(float),
		typeof(float),
		typeof(Character),
		typeof(float)
	})]
	public class Character_ReceiveHitPlain_Blind
	{
		[HarmonyPrefix]
		public static bool Prefix(Character __instance, Character _dealerChar)
		{
			try
			{
				return !BlindEffect.Misses(_dealerChar, __instance);
			}
			catch (Exception ex)
			{
				CustomEffectsPlugin.Log.LogError((object)("SL_Blind: ReceiveHit (plain) prefix threw: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(Character), "ReceiveBlock", new Type[]
	{
		typeof(Weapon),
		typeof(DamageList),
		typeof(Vector3),
		typeof(float),
		typeof(float),
		typeof(Character),
		typeof(float)
	})]
	public class Character_ReceiveBlock_Blind
	{
		[HarmonyPrefix]
		public static bool Prefix(Character __instance, Character _dealerChar)
		{
			try
			{
				return !BlindEffect.Misses(_dealerChar, __instance);
			}
			catch (Exception ex)
			{
				CustomEffectsPlugin.Log.LogError((object)("SL_Blind: ReceiveBlock prefix threw: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(Character), "ReceiveBlock", new Type[]
	{
		typeof(MonoBehaviour),
		typeof(float),
		typeof(Vector3),
		typeof(float),
		typeof(float),
		typeof(Character),
		typeof(float)
	})]
	public class Character_ReceiveBlockPlain_Blind
	{
		[HarmonyPrefix]
		public static bool Prefix(Character __instance, Character _dealerChar)
		{
			try
			{
				return !BlindEffect.Misses(_dealerChar, __instance);
			}
			catch (Exception ex)
			{
				CustomEffectsPlugin.Log.LogError((object)("SL_Blind: ReceiveBlock (plain) prefix threw: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(StatusEffectManager), "AddStatusEffect", new Type[]
	{
		typeof(StatusEffect),
		typeof(Character),
		typeof(string[])
	})]
	public class StatusEffectManager_AddStatusEffect_Blind
	{
		[HarmonyPrefix]
		public static bool Prefix(Character ___m_character, Character _dealer, string[] _loadData, ref StatusEffect __result)
		{
			try
			{
				if (_loadData != null || !Object.op_Implicit((Object)(object)___m_character) || !___m_character.IsPhotonPlayerLocal || !BlindEffect.Misses(_dealer, ___m_character))
				{
					return true;
				}
				__result = null;
				return false;
			}
			catch (Exception ex)
			{
				CustomEffectsPlugin.Log.LogError((object)("SL_Blind: AddStatusEffect prefix threw: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(Weapon), "HasHit", new Type[]
	{
		typeof(RaycastHit),
		typeof(Vector3)
	})]
	public class Weapon_HasHit_Blind
	{
		[HarmonyPrefix]
		public static void Prefix(Weapon __instance)
		{
			BlindEffect.BeginHit(__instance);
		}

		[HarmonyPostfix]
		public static void Postfix()
		{
			BlindEffect.EndHit();
		}
	}
	[HarmonyPatch(typeof(Item), "ReduceDurability", new Type[] { typeof(float) })]
	public class Item_ReduceDurability_Blind
	{
		[HarmonyPrefix]
		public static bool Prefix(Item __instance)
		{
			try
			{
				return !BlindEffect.SparesDurability(__instance);
			}
			catch (Exception ex)
			{
				CustomEffectsPlugin.Log.LogError((object)("SL_Blind: ReduceDurability prefix threw: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(StatusEffectManager), "AddStatusEffectBuildUp", new Type[]
	{
		typeof(StatusEffect),
		typeof(float),
		typeof(Character)
	})]
	public class StatusEffectManager_AddStatusEffectBuildUp_Blind
	{
		[HarmonyPrefix]
		public static bool Prefix(Character ___m_character, Character _dealerChar)
		{
			try
			{
				if (!Object.op_Implicit((Object)(object)___m_character) || !___m_character.IsPhotonPlayerLocal)
				{
					return true;
				}
				return !BlindEffect.Misses(_dealerChar, ___m_character);
			}
			catch (Exception ex)
			{
				CustomEffectsPlugin.Log.LogError((object)("SL_Blind: AddStatusEffectBuildUp prefix threw: " + ex));
				return true;
			}
		}
	}
	public enum ItemVFXSet
	{
		Obsidian,
		Meteoric,
		Palladium,
		Hailfrost,
		Astral,
		Smoke,
		Calygrey,
		AncientCalygrey,
		JadeLich,
		Blood,
		Brand,
		Maelstrom,
		Sunfall,
		ButcherCleaver,
		Skycrown,
		MaceOfSeasons,
		Starchild,
		Kelvin,
		Challenger,
		Werlig,
		ThriceWrought,
		Dreamer,
		GhostReaper,
		ScholarsStaff,
		MagesPokingStick,
		Sandrose,
		SealedMace,
		CruelPriest,
		Grind,
		Shriek,
		Frostburn,
		Duty,
		Tokebakicit,
		Murmure,
		RedLady,
		Manticore,
		FrozenChakram,
		MysteriousChakram,
		ExperimentalChakram,
		DistortedExperiment,
		GildedShiver,
		LionmanMace,
		LionmanStaff,
		GiantArchPriest,
		MilitiaAxe,
		MilitiaClaymore,
		MilitiaSpear
	}
	public enum ItemVFXFit
	{
		Stretch,
		Original,
		Mesh,
		Bounds,
		Auto,
		Blade
	}
	public class SL_ItemVFX : SL_ItemExtension, ICustomModel
	{
		[XmlArrayItem("VFX")]
		public ItemVFXSet[] VFX;

		public ItemVFXFit Fit = ItemVFXFit.Auto;

		public Vector3 Offset = Vector3.zero;

		public Vector3 Rotation = Vector3.zero;

		public float Scale = 1f;

		public float SizeMultiplier = 1f;

		public bool ShowInHand = true;

		public bool ShowSheathed = true;

		public bool ShowOnGround = true;

		public bool ShowOnBag;

		public Type SLTemplateModel => typeof(SL_ItemVFX);

		public Type GameModel => typeof(ItemVFX);

		public override void ApplyToComponent<T>(T component)
		{
			//IL_0040: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			ItemVFX itemVFX = component as ItemVFX;
			itemVFX.VFX = ((VFX == null) ? new ItemVFXSet[0] : ((ItemVFXSet[])VFX.Clone()));
			itemVFX.Fit = Fit;
			itemVFX.Offset = Offset;
			itemVFX.Rotation = Rotation;
			itemVFX.Scale = Scale;
			itemVFX.SizeMultiplier = SizeMultiplier;
			itemVFX.ShowInHand = ShowInHand;
			itemVFX.ShowSheathed = ShowSheathed;
			itemVFX.ShowOnGround = ShowOnGround;
			itemVFX.ShowOnBag = ShowOnBag;
			if (itemVFX.VFX.Length == 0)
			{
				CustomEffectsPlugin.Log.LogWarning((object)("SL_ItemVFX (" + ((Object)((Component)(object)component).gameObject).name + "): no VFX were read - nothing will show. Each entry must be a <VFX> element inside <VFX>."));
				return;
			}
			CustomEffectsPlugin.Log.LogMessage((object)("SL_ItemVFX (" + ((Object)((Component)(object)component).gameObject).name + "): " + string.Join(", ", Array.ConvertAll(itemVFX.VFX, (ItemVFXSet s) => s.ToString())) + ", Fit=" + Fit.ToString() + "."));
		}

		public override void SerializeComponent<T>(T extension)
		{
			//IL_0040: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			ItemVFX itemVFX = extension as ItemVFX;
			VFX = ((itemVFX.VFX == null) ? new ItemVFXSet[0] : ((ItemVFXSet[])itemVFX.VFX.Clone()));
			Fit = itemVFX.Fit;
			Offset = itemVFX.Offset;
			Rotation = itemVFX.Rotation;
			Scale = itemVFX.Scale;
			SizeMultiplier = itemVFX.SizeMultiplier;
			ShowInHand = itemVFX.ShowInHand;
			ShowSheathed = itemVFX.ShowSheathed;
			ShowOnGround = itemVFX.ShowOnGround;
			ShowOnBag = itemVFX.ShowOnBag;
		}
	}
	public class ItemVFX : ItemExtension
	{
		public ItemVFXSet[] VFX = new ItemVFXSet[0];

		public ItemVFXFit Fit = ItemVFXFit.Auto;

		public Vector3 Offset = Vector3.zero;

		public Vector3 Rotation = Vector3.zero;

		public float Scale = 1f;

		public float SizeMultiplier = 1f;

		public bool ShowInHand = true;

		public bool ShowSheathed = true;

		public bool ShowOnGround = true;

		public bool ShowOnBag;

		private ItemVisual m_host;

		private bool m_built;

		private bool m_shown;

		private bool m_subscribed;

		private readonly List<GameObject> m_copies = new List<GameObject>();

		private int m_anchored;

		private static readonly HashSet<string> s_logged = new HashSet<string>();

		private const string LeftHandModel = "LeftHandModel";

		protected override void StartInit()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			((ItemExtension)this).StartInit();
			if (Object.op_Implicit((Object)(object)base.m_item) && !m_subscribed)
			{
				base.m_item.OnProcessVisual += new ProcessVisual(OnProcessVisual);
				m_subscribed = true;
			}
		}

		private void OnProcessVisual(Item _item)
		{
			Refresh();
		}

		private void LateUpdate()
		{
			Refresh();
		}

		private void Refresh()
		{
			ItemVisual val = null;
			bool flag = false;
			if (Object.op_Implicit((Object)(object)base.m_item) && !base.m_item.IsPendingDestroy && VFX != null && VFX.Length != 0)
			{
				val = GetHostVisual();
				if (Object.op_Implicit((Object)(object)val))
				{
					flag = ShouldShow();
				}
			}
			if ((Object)(object)val != (Object)(object)m_host)
			{
				DestroyCopies();
				m_host = val;
			}
			if (flag && !m_built && Object.op_Implicit((Object)(object)m_host))
			{
				Build(m_host);
			}
			if (flag == m_shown)
			{
				return;
			}
			m_shown = flag;
			for (int i = 0; i < m_copies.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)m_copies[i]))
				{
					m_copies[i].SetActive(flag);
				}
			}
		}

		private ItemVisual GetHostVisual()
		{
			Item item = base.m_item;
			Equipment val = (Equipment)(object)((item is Equipment) ? item : null);
			ItemVisual val2 = ((!Object.op_Implicit((Object)(object)val) || !base.m_item.IsEquipped) ? base.m_item.CurrentVisual : val.EquippedVisuals);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return null;
			}
			if (Object.op_Implicit((Object)(object)val) && (Object)(object)val2 == (Object)(object)val.SpecialVisuals)
			{
				return val2;
			}
			if (!val2.IsLinkedToItem(base.m_item))
			{
				return null;
			}
			return val2;
		}

		private bool ShouldShow()
		{
			if (base.m_item.IsEquipped)
			{
				Character ownerCharacter = ((EffectSynchronizer)base.m_item).OwnerCharacter;
				if (base.m_item is Weapon && Object.op_Implicit((Object)(object)ownerCharacter) && ownerCharacter.Sheathed)
				{
					return ShowSheathed;
				}
				return ShowInHand;
			}
			if (base.m_item.DisplayedOnBag)
			{
				return ShowOnBag;
			}
			if (base.m_item.IsInWorld)
			{
				return ShowOnGround;
			}
			return false;
		}

		private void Build(ItemVisual host)
		{
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Invalid comparison between Unknown and I4
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: 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)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0619: Unknown result type (might be due to invalid IL or missing references)
			//IL_061e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			m_built = true;
			ItemVFXCopy[] componentsInChildren = ((Component)host).GetComponentsInChildren<ItemVFXCopy>(true);
			foreach (ItemVFXCopy itemVFXCopy in componentsInChildren)
			{
				if ((Object)(object)itemVFXCopy.Owner != (Object)(object)this)
				{
					Object.Destroy((Object)(object)((Component)itemVFXCopy).gameObject);
				}
			}
			Item item = base.m_item;
			Equipment val = (Equipment)(object)((item is Equipment) ? item : null);
			bool flag = Object.op_Implicit((Object)(object)val) && (Object)(object)host == (Object)(object)val.SpecialVisuals;
			Renderer val2 = ItemVFXSources.ModelRenderer(((Component)host).transform);
			Bounds bounds;
			bool flag2 = ItemVFXSources.ModelBounds(((Component)host).transform, out bounds);
			float num = ItemVFXSources.TipX(((Component)host).transform);
			ItemVFXSources.Profile profile = ItemVFXSources.ProfileOf(((Component)host).transform, "item:" + base.m_item.ItemID + (flag ? "|special" : "|regular"));
			List<ItemVFXSet> list = new List<ItemVFXSet>();
			ItemVFXSet[] vFX = VFX;
			for (int i = 0; i < vFX.Length; i++)
			{
				ItemVFXSet itemVFXSet = vFX[i];
				if (list.Contains(itemVFXSet))
				{
					continue;
				}
				list.Add(itemVFXSet);
				bool fallback;
				ItemVFXSources.Source source = ItemVFXSources.Get(itemVFXSet, base.m_item, flag, out fallback);
				if (source == null)
				{
					continue;
				}
				ItemVFXFit itemVFXFit = Fit;
				string text = "";
				float ratio = 1f;
				Renderer val3 = null;
				Mesh val4 = null;
				if (itemVFXFit == ItemVFXFit.Auto)
				{
					bool flag3 = ItemVFXSources.BladeUnderAuto(itemVFXSet);
					itemVFXFit = ((fallback || flag3) ? ItemVFXFit.Blade : ItemVFXFit.Stretch);
					text = (fallback ? " (fallback: Blade)" : (flag3 ? " (Blade for this entry)" : " (Stretch)"));
				}
				Item item2 = base.m_item;
				Weapon val5 = (Weapon)(object)((item2 is Weapon) ? item2 : null);
				if (itemVFXFit == ItemVFXFit.Blade && Object.op_Implicit((Object)(object)val5) && (int)val5.Type == 100)
				{
					itemVFXFit = ItemVFXFit.Mesh;
					text += " (shield: Mesh)";
				}
				if (itemVFXFit == ItemVFXFit.Blade)
				{
					val4 = ItemVFXSources.BladeOf(((Component)host).transform, "item:" + base.m_item.ItemID + (flag ? "|special" : "|regular"));
					if (!Object.op_Implicit((Object)(object)val4))
					{
						itemVFXFit = ItemVFXFit.Mesh;
						text += " (no blade or head found: Mesh)";
					}
				}
				switch (itemVFXFit)
				{
				case ItemVFXFit.Stretch:
					if (num < -0.01f && source.TipX < -0.01f)
					{
						ratio = num / source.TipX;
					}
					if (flag2 && (num >= -0.01f || (fallback && !ItemVFXSources.IsBladeShaped(bounds))))
					{
						itemVFXFit = ItemVFXFit.Bounds;
						text += " (not blade-shaped: Bounds)";
					}
					break;
				case ItemVFXFit.Mesh:
					val3 = val2;
					if (!Object.op_Implicit((Object)(object)val3))
					{
						itemVFXFit = ((!flag2) ? ItemVFXFit.Original : ItemVFXFit.Bounds);
						text = text + " (no readable mesh: " + itemVFXFit.ToString() + ")";
					}
					break;
				}
				if (itemVFXFit == ItemVFXFit.Bounds && !flag2)
				{
					itemVFXFit = ItemVFXFit.Original;
					text += " (no model found: Original)";
				}
				float baseX = 0f;
				float baseX2 = 0f;
				Item item3 = base.m_item;
				Weapon val6 = (Weapon)(object)((item3 is Weapon) ? item3 : null);
				bool fromBase = itemVFXFit == ItemVFXFit.Stretch && Object.op_Implicit((Object)(object)val6) && ItemVFXSources.AnchorsAtBladeBase(val6.Type) && source.AnchorsAtBladeBase && ItemVFXSources.BladeBaseOf(((Component)host).transform, "item:" + base.m_item.ItemID + (flag ? "|special" : "|regular"), out baseX) && ItemVFXSources.BladeBaseOf(source.Prefab, "source:" + source.Key, out baseX2);
				m_anchored = 0;
				foreach (Transform root in source.Roots)
				{
					m_copies.Add(Attach(((Component)host).transform, source, root, itemVFXSet, itemVFXFit, ratio, val3, val2, bounds, profile, val4, num, fromBase, baseX, baseX2));
				}
				string text2 = BuildLeftFist(source, itemVFXSet, itemVFXFit, flag);
				string item4 = base.m_item.ItemID + "|" + itemVFXSet.ToString() + "|" + flag;
				if (s_logged.Add(item4))
				{
					ManualLogSource log = CustomEffectsPlugin.Log;
					string[] obj = new string[22]
					{
						"SL_ItemVFX: ",
						base.m_item.Name,
						" (",
						base.m_item.ItemID.ToString(),
						") - ",
						itemVFXSet.ToString(),
						" from ",
						source.ItemID.ToString(),
						flag ? " (special visual)" : "",
						fallback ? " (the set has no weapon of this type)" : "",
						", ",
						source.Roots.Count.ToString(),
						" emitters, Fit=",
						Fit.ToString(),
						text,
						(itemVFXFit == ItemVFXFit.Stretch) ? (" ratio=" + ratio.ToString("F2")) : "",
						(m_anchored > 0) ? (", " + m_anchored + " emitters from the blade base at x " + baseX.ToString("F2") + " (source's at " + baseX2.ToString("F2") + ")") : "",
						(itemVFXFit == ItemVFXFit.Mesh) ? (" mesh=" + ((Object)val3).name) : "",
						null,
						null,
						null,
						null
					};
					object obj2;
					Vector3 val7;
					if (itemVFXFit != ItemVFXFit.Bounds)
					{
						obj2 = "";
					}
					else
					{
						val7 = ((Bounds)(ref bounds)).size;
						obj2 = " box=" + ((Vector3)(ref val7)).ToString("F2");
					}
					obj[18] = (string)obj2;
					object obj3;
					if (itemVFXFit != ItemVFXFit.Blade)
					{
						obj3 = "";
					}
					else
					{
						string[] obj4 = new string[7] { " blade x ", null, null, null, null, null, null };
						Bounds bounds2 = val4.bounds;
						val7 = ((Bounds)(ref bounds2)).min;
						obj4[1] = val7.x.ToString("F2");
						obj4[2] = " to ";
						bounds2 = val4.bounds;
						val7 = ((Bounds)(ref bounds2)).max;
						obj4[3] = val7.x.ToString("F2");
						obj4[4] = ", ";
						obj4[5] = (val4.triangles.Length / 3).ToString();
						obj4[6] = " triangles";
						obj3 = string.Concat(obj4);
					}
					obj[19] = (string)obj3;
					obj[20] = text2;
					obj[21] = ".";
					log.LogMessage((object)string.Concat(obj));
				}
			}
			m_shown = true;
		}

		private string BuildLeftFist(ItemVFXSources.Source source, ItemVFXSet set, ItemVFXFit fit, bool special)
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			Item item = base.m_item;
			DualMeleeWeapon val = (DualMeleeWeapon)(object)((item is DualMeleeWeapon) ? item : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.LeftHandFollow))
			{
				return "";
			}
			if (fit != ItemVFXFit.Blade && fit != ItemVFXFit.Mesh && fit != ItemVFXFit.Bounds)
			{
				return "";
			}
			Transform leftHandFollow = val.LeftHandFollow;
			ItemVFXCopy[] componentsInChildren = ((Component)leftHandFollow).GetComponentsInChildren<ItemVFXCopy>(true);
			foreach (ItemVFXCopy itemVFXCopy in componentsInChildren)
			{
				if ((Object)(object)itemVFXCopy.Owner != (Object)(object)this)
				{
					Object.Destroy((Object)(object)((Component)itemVFXCopy).gameObject);
				}
			}
			Renderer val2 = ItemVFXSources.ModelRenderer(leftHandFollow, includeLeftHand: true);
			Bounds bounds;
			bool flag = ItemVFXSources.ModelBounds(leftHandFollow, out bounds, includeLeftHand: true);
			ItemVFXFit itemVFXFit = fit;
			Mesh val3 = null;
			Renderer val4 = null;
			if (itemVFXFit == ItemVFXFit.Blade)
			{
				val3 = ItemVFXSources.BladeOf(leftHandFollow, "item:" + base.m_item.ItemID + (special ? "|special" : "|regular") + "|left", includeLeftHand: true);
				if (!Object.op_Implicit((Object)(object)val3))
				{
					itemVFXFit = ItemVFXFit.Mesh;
				}
			}
			if (itemVFXFit == ItemVFXFit.Mesh)
			{
				val4 = val2;
				if (!Object.op_Implicit((Object)(object)val4))
				{
					itemVFXFit = ((!flag) ? ItemVFXFit.Original : ItemVFXFit.Bounds);
				}
			}
			if (itemVFXFit == ItemVFXFit.Bounds && !flag)
			{
				itemVFXFit = ItemVFXFit.Original;
			}
			if (itemVFXFit == ItemVFXFit.Original)
			{
				return " (left fist: no model found, skipped)";
			}
			foreach (Transform root in source.Roots)
			{
				m_copies.Add(Attach(leftHandFollow, source, root, set, itemVFXFit, 1f, val4, val2, bounds, null, val3, 0f, fromBase: false, 0f, 0f));
			}
			return " + left fist (Fit=" + itemVFXFit.ToString() + ")";
		}

		private GameObject Attach(Transform host, ItemVFXSources.Source source, Transform root, ItemVFXSet set, ItemVFXFit fit, float ratio, Renderer meshRenderer, Renderer modelRenderer, Bounds model, ItemVFXSources.Profile profile, Mesh blade, float tip, bool fromBase, float itemBase, float sourceBase)
		{
			//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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: 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_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: 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_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05df: 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)
			//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0789: Unknown result type (might be due to invalid IL or missing references)
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Invalid comparison between Unknown and I4
			//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c3: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0761: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_076f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_0645: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0680: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Invalid comparison between Unknown and I4
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			Transform anchor;
			Transform val = ResolveAnchor(host, source.Prefab, root.parent, out anchor);
			GameObject val2 = Object.Instantiate<GameObject>(((Component)root).gameObject, val, false);
			((Object)val2).name = "ItemVFX_" + set.ToString() + "_" + ((Object)root).name;
			val2.AddComponent<ItemVFXCopy>().Owner = this;
			Transform transform = val2.transform;
			transform.localPosition = anchor.InverseTransformPoint(root.position);
			transform.localRotation = Quaternion.Inverse(anchor.rotation) * root.rotation;
			transform.localScale = root.localScale;
			ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>(true);
			bool flag = fit == ItemVFXFit.Stretch && (Object)(object)val == (Object)(object)host;
			Vector3[] array = null;
			if (flag)
			{
				ItemVFXSources.Profile profile2 = ItemVFXSources.ProfileOf(source);
				Quaternion val3 = Quaternion.Inverse(host.rotation);
				Vector3[] array2 = (Vector3[])(object)new Vector3[componentsInChildren.Length];
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					array2[i] = host.InverseTransformPoint(((Component)componentsInChildren[i]).transform.position);
				}
				Vector3 val4 = Vector3.zero;
				int num = 0;
				EmissionModule emission;
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					emission = componentsInChildren[j].emission;
					if (((EmissionModule)(ref emission)).enabled)
					{
						val4 += array2[j];
						num++;
					}
				}
				if (num > 0)
				{
					val4 /= (float)num;
				}
				bool flag2 = num > 0 && tip < -0.01f && ItemVFXSources.AtTip(set);
				array = (Vector3[])(object)new Vector3[componentsInChildren.Length];
				for (int k = 0; k < componentsInChildren.Length; k++)
				{
					ShapeModule shape = componentsInChildren[k].shape;
					Quaternion shapeRot = val3 * ((Component)componentsInChildren[k]).transform.rotation * Quaternion.Euler(((ShapeModule)(ref shape)).rotation);
					float num2 = ItemVFXSources.HalfLengthAlongX(shape, shapeRot);
					Vector3 val5 = array2[k];
					float num3 = (flag2 ? (tip + 0.05f + (val5.x - val4.x) * ratio) : (val5.x * ratio));
					float num4 = ratio;
					float num5 = sourceBase - source.TipX;
					if (fromBase && !flag2 && num5 > 0.05f)
					{
						emission = componentsInChildren[k].emission;
						if (((EmissionModule)(ref emission)).enabled)
						{
							ShapeModule shape2 = componentsInChildren[k].shape;
							if (((ShapeModule)(ref shape2)).enabled)
							{
								float num6 = val5.x + num2;
								float num7 = val5.x - num2;
								float num8 = num7 * ratio;
								if (sourceBase - num6 <= num5 / 3f && num6 - num7 >= num5 / 3f && itemBase > num6 * ratio && itemBase > num8)
								{
									num3 = (itemBase + num8) * 0.5f;
									num4 = (itemBase - num8) * 0.5f / num2;
									m_anchored++;
								}
							}
						}
					}
					float num9 = 1f;
					float num10 = 1f;
					if (num > 0 && profile2 != null && profile != null && profile2.Across(val5.x - num2, val5.x + num2, out var y, out var z) && profile.Across(num3 - num2 * num4, num3 + num2 * num4, out var y2, out var z2))
					{
						num9 = ItemVFXSources.WidthRatio(y, y2);
						num10 = ItemVFXSources.WidthRatio(z, z2);
						val5.y = (y2.x + y2.y) * 0.5f + (val5.y - val4.y) * num9;
						val5.z = (z2.x + z2.y) * 0.5f + (val5.z - val4.z) * num10;
					}
					val5.x = num3;
					((Component)componentsInChildren[k]).transform.position = host.TransformPoint(val5);
					array[k] = ItemVFXSources.AxisFactors(shapeRot, num4, num9, num10);
				}
			}
			bool flag3 = fit == ItemVFXFit.Bounds;
			if (flag3)
			{
				if ((Object)(object)transform.parent != (Object)(object)host)
				{
					transform.SetParent(host, false);
				}
				transform.localPosition = ((Bounds)(ref model)).center;
				transform.localRotation = Quaternion.identity;
				ParticleSystem[] array3 = componentsInChildren;
				foreach (ParticleSystem val6 in array3)
				{
					if ((Object)(object)((Component)val6).transform != (Object)(object)transform)
					{
						((Component)val6).transform.localPosition = Vector3.zero;
						((Component)val6).transform.localRotation = Quaternion.identity;
					}
				}
			}
			bool flag4 = fit == ItemVFXFit.Blade && Object.op_Implicit((Object)(object)blade);
			if (flag4)
			{
				if ((Object)(object)transform.parent != (Object)(object)host)
				{
					transform.SetParent(host, false);
				}
				transform.localPosition = Vector3.zero;
				transform.localRotation = Quaternion.identity;
				transform.localScale = Vector3.one;
				ParticleSystem[] array3 = componentsInChildren;
				foreach (ParticleSystem val7 in array3)
				{
					if ((Object)(object)((Component)val7).transform != (Object)(object)transform)
					{
						((Component)val7).transform.localPosition = Vector3.zero;
						((Component)val7).transform.localRotation = Quaternion.identity;
						((Component)val7).transform.localScale = Vector3.one;
					}
				}
			}
			transform.localPosition += Offset;
			transform.localRotation = Quaternion.Euler(Rotation) * transform.localRotation;
			for (int m = 0; m < componentsInChildren.Length; m++)
			{
				ParticleSystem val8 = componentsInChildren[m];
				ShapeModule shape3 = val8.shape;
				if (Object.op_Implicit((Object)(object)meshRenderer))
				{
					EmitFrom(shape3, meshRenderer);
					((ShapeModule)(ref shape3)).position = Vector3.zero;
					((ShapeModule)(ref shape3)).rotation = Vector3.zero;
					((ShapeModule)(ref shape3)).scale = Vector3.one;
				}
				else if (flag4 && ((ShapeModule)(ref shape3)).enabled)
				{
					((ShapeModule)(ref shape3)).shapeType = (ParticleSystemShapeType)6;
					((ShapeModule)(ref shape3)).mesh = blade;
					((ShapeModule)(ref shape3)).meshShapeType = (ParticleSystemMeshShapeType)2;
					((ShapeModule)(ref shape3)).position = Vector3.zero;
					((ShapeModule)(ref shape3)).rotation = Vector3.zero;
					((ShapeModule)(ref shape3)).scale = Vector3.one;
				}
				else if (flag3 && ((ShapeModule)(ref shape3)).enabled)
				{
					if ((int)((ShapeModule)(ref shape3)).shapeType != 15 && (int)((ShapeModule)(ref shape3)).shapeType != 16)
					{
						((ShapeModule)(ref shape3)).shapeType = (ParticleSystemShapeType)5;
					}
					((ShapeModule)(ref shape3)).position = Vector3.zero;
					((ShapeModule)(ref shape3)).rotation = Vector3.zero;
					((ShapeModule)(ref shape3)).scale = new Vector3(SafeDiv(((Bounds)(ref model)).size.x, ((Component)val8).transform.lossyScale.x, host.lossyScale.x), SafeDiv(((Bounds)(ref model)).size.y, ((Component)val8).transform.lossyScale.y, host.lossyScale.y), SafeDiv(((Bounds)(ref model)).size.z, ((Component)val8).transform.lossyScale.z, host.lossyScale.z));
				}
				else if (EmitsFromForeignRenderer(shape3, val2.transform))
				{
					if (Object.op_Implicit((Object)(object)modelRenderer))
					{
						EmitFrom(shape3, modelRenderer);
					}
					else
					{
						((ShapeModule)(ref shape3)).enabled = false;
						CustomEffectsPlugin.Log.LogWarning((object)("SL_ItemVFX (" + base.m_item.Name + "): " + ((Object)val8).name + " emits from its source weapon's mesh and this item has no readable one - it emits from a point instead."));
					}
				}
				else if (flag)
				{
					((ShapeModule)(ref shape3)).scale = Vector3.Scale(((ShapeModule)(ref shape3)).scale, array[m]);
				}
				if (Scale != 1f)
				{
					((ShapeModule)(ref shape3)).scale = ((ShapeModule)(ref shape3)).scale * Scale;
				}
				if (SizeMultiplier != 1f)
				{
					MainModule main = val8.main;
					((MainModule)(ref main)).startSize = ScaleCurve(((MainModule)(ref main)).startSize, SizeMultiplier);
				}
			}
			return val2;
		}

		private Transform ResolveParent(Transform host, string path)
		{
			if (string.IsNullOrEmpty(path))
			{
				return host;
			}
			Transform val = host.Find(path);
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			Item item = base.m_item;
			DualMeleeWeapon val2 = (DualMeleeWeapon)(object)((item is DualMeleeWeapon) ? item : null);
			if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.LeftHandFollow))
			{
				if (path == "LeftHandModel")
				{
					return val2.LeftHandFollow;
				}
				if (path.StartsWith("LeftHandModel/"))
				{
					return val2.LeftHandFollow.Find(path.Substring("LeftHandModel".Length + 1));
				}
			}
			return null;
		}

		private Transform ResolveAnchor(Transform host, Transform sourceRoot, Transform start, out Transform anchor)
		{
			Transform val = start;
			while (Object.op_Implicit((Object)(object)val))
			{
				Transform val2 = ResolveParent(host, ItemVFXSources.PathFrom(sourceRoot, val));
				if (Object.op_Implicit((Object)(object)val2))
				{
					anchor = val;
					return val2;
				}
				if ((Object)(object)val == (Object)(object)sourceRoot)
				{
					break;
				}
				val = val.parent;
			}
			anchor = sourceRoot;
			return host;
		}

		private static float SafeDiv(float size, float emitterScale, float hostScale)
		{
			float num = ((hostScale != 0f) ? Mathf.Abs(emitterScale / hostScale) : 0f);
			if (!(num > 0.0001f))
			{
				return size;
			}
			return size / num;
		}

		private static void EmitFrom(ShapeModule shape, Renderer renderer)
		{
			MeshRenderer val = (MeshRenderer)(object)((renderer is MeshRenderer) ? renderer : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)13;
				((ShapeModule)(ref shape)).meshRenderer = val;
			}
			else
			{
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)14;
				((ShapeModule)(ref shape)).skinnedMeshRenderer = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null);
			}
		}

		private static bool EmitsFromForeignRenderer(ShapeModule shape, Transform copy)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			if (!((ShapeModule)(ref shape)).enabled)
			{
				return false;
			}
			Renderer val;
			if ((int)((ShapeModule)(ref shape)).shapeType == 13)
			{
				val = (Renderer)(object)((ShapeModule)(ref shape)).meshRenderer;
			}
			else
			{
				if ((int)((ShapeModule)(ref shape)).shapeType != 14)
				{
					return false;
				}
				val = (Renderer)(object)((ShapeModule)(ref shape)).skinnedMeshRenderer;
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				return !((Component)val).transform.IsChildOf(copy);
			}
			return true;
		}

		private static MinMaxCurve ScaleCurve(MinMaxCurve curve, float factor)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystemCurveMode mode = ((MinMaxCurve)(ref curve)).mode;
			if ((int)mode != 0)
			{
				if ((int)mode == 3)
				{
					((MinMaxCurve)(ref curve)).constantMin = ((MinMaxCurve)(ref curve)).constantMin * factor;
					((MinMaxCurve)(ref curve)).constantMax = ((MinMaxCurve)(ref curve)).constantMax * factor;
				}
				else
				{
					((MinMaxCurve)(ref curve)).curveMultiplier = ((MinMaxCurve)(ref curve)).curveMultiplier * factor;
				}
			}
			else
			{
				((MinMaxCurve)(ref curve)).constant = ((MinMaxCurve)(ref curve)).constant * factor;
			}
			return curve;
		}

		private void DestroyCopies()
		{
			for (int i = 0; i < m_copies.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)m_copies[i]))
				{
					Object.Destroy((Object)(object)m_copies[i]);
				}
			}
			m_copies.Clear();
			m_built = false;
			m_shown = false;
		}

		public override void OnItemParentBeingDestroyed()
		{
			((ItemExtension)this).OnItemParentBeingDestroyed();
			DestroyCopies();
		}

		private void OnDestroy()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (m_subscribed && Object.op_Implicit((Object)(object)base.m_item))
			{
				base.m_item.OnProcessVisual -= new ProcessVisual(OnProcessVisual);
			}
			m_subscribed = false;
			DestroyCopies();
		}
	}
	public class ItemVFXCopy : MonoBehaviour
	{
		public ItemVFX Owner;
	}
	internal static class ItemVFXSources
	{
		internal class Source
		{
			public int ItemID;

			public Transform Prefab;

			public List<Transform> Roots = new List<Transform>();

			public float TipX;

			public string Key;

			public bool Oversized;

			public bool AnchorsAtBladeBase;
		}

		internal class Profile
		{
			private const float Bin = 0.1f;

			private readonly Dictionary<int, Vector4> m_bins = new Dictionary<int, Vector4>();

			internal static Profile Build(Transform visual)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: 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_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_009b: 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_00a2: 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_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0135: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: 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_00f1: 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_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				Profile profile = new Profile();
				Matrix4x4 worldToLocalMatrix = visual.worldToLocalMatrix;
				MeshFilter[] componentsInChildren = ((Component)visual).GetComponentsInChildren<MeshFilter>(true);
				foreach (MeshFilter val in componentsInChildren)
				{
					Mesh sharedMesh = val.sharedMesh;
					if (!Object.op_Implicit((Object)(object)sharedMesh) || !sharedMesh.isReadable || Object.op_Implicit((Object)(object)((Component)val).GetComponent<WeaponTrail>()) || ((Object)val).name.Contains("LeftHand"))
					{
						continue;
					}
					Matrix4x4 val2 = worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix;
					Vector3[] vertices = sharedMesh.vertices;
					foreach (Vector3 val3 in vertices)
					{
						Vector3 val4 = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(val3);
						int key = Mathf.FloorToInt(val4.x / 0.1f);
						if (profile.m_bins.TryGetValue(key, out var value))
						{
							((Vector4)(ref value))..ctor(Mathf.Min(value.x, val4.y), Mathf.Max(value.y, val4.y), Mathf.Min(value.z, val4.z), Mathf.Max(value.w, val4.z));
						}
						else
						{
							((Vector4)(ref value))..ctor(val4.y, val4.y, val4.z, val4.z);
						}
						profile.m_bins[key] = value;
					}
				}
				if (profile.m_bins.Count <= 0)
				{
					return null;
				}
				return profile;
			}

			internal bool Across(float xa, float xb, out Vector2 y, out Vector2 z)
			{
				//IL_0001: 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_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: 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_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				y = Vector2.zero;
				z = Vector2.zero;
				int num = Mathf.FloorToInt(Mathf.Min(xa, xb) / 0.1f);
				int num2 = Mathf.FloorToInt(Mathf.Max(xa, xb) / 0.1f);
				List<Vector4> list = new List<Vector4>();
				for (int i = num; i <= num2; i++)
				{
					if (m_bins.TryGetValue(i, out var value))
					{
						list.Add(value);
					}
				}
				if (list.Count == 0)
				{
					return false;
				}
				y = Range(list, yAxis: true);
				z = Range(list, yAxis: false);
				return true;
			}

			private static Vector2 Range(List<Vector4> hits, bool yAxis)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: 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_001d: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0135: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: 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_014a: Unknown result type (might be due to invalid IL or missing references)
				List<float> list = new List<float>();
				foreach (Vector4 hit in hits)
				{
					list.Add(yAxis ? (hit.y - hit.x) : (hit.w - hit.z));
				}
				list.Sort();
				float num = Mathf.Max(list[list.Count / 2], 0.01f) * 2.5f;
				List<float> list2 = new List<float>();
				foreach (Vector4 hit2 in hits)
				{
					float num2 = (yAxis ? hit2.x : hit2.z);
					float num3 = (yAxis ? hit2.y : hit2.w);
					if (num3 - num2 <= num)
					{
						list2.Add((num2 + num3) * 0.5f);
					}
				}
				if (list2.Count == 0)
				{
					return Vector2.zero;
				}
				list2.Sort();
				float num4 = list2[list2.Count / 2];
				float num5 = 0f;
				foreach (Vector4 hit3 in hits)
				{
					float num6 = (yAxis ? hit3.x : hit3.z);
					float num7 = (yAxis ? hit3.y : hit3.w);
					if (!(num7 - num6 > num))
					{
						num5 = Mathf.Max(num5, Mathf.Max(num4 - num6, num7 - num4));
					}
				}
				return new Vector2(num4 - num5, num4 + num5);
			}
		}

		internal const float MaxSourceExtent = 5f;

		private static readonly Dictionary<string, Profile> s_profiles = new Dictionary<string, Profile>();

		private static readonly Dictionary<string, Mesh> s_blades = new Dictionary<string, Mesh>();

		private static readonly Dictionary<string, float> s_bladeBases = new Dictionary<string, float>();

		private const float SliceBin = 0.1f;

		private static readonly Dictionary<ItemVFXSet, int[]> s_sources = new Dictionary<ItemVFXSet, int[]>
		{
			{
				ItemVFXSet.Obsidian,
				new int[13]
				{
					2000260, 2010230, 2020110, 2100250, 2110210, 2120120, 2130260, 2150090, 2160180, 2200180,
					5110101, 2300310, 5110013
				}
			},
			{
				ItemVFXSet.Meteoric,
				new int[12]
				{
					2000265, 2010235, 2020115, 2100255, 2110215, 2120125, 2130265, 2150095, 2160185, 2200185,
					5110108, 5110019
				}
			},
			{
				ItemVFXSet.Palladium,
				new int[8] { 2000140, 2010110, 2020100, 2100120, 2110080, 2120110, 2130140, 2140100 }
			},
			{
				ItemVFXSet.Hailfrost,
				new int[13]
				{
					2000280, 2010250, 2020290, 2100270, 2110230, 2120240, 2130280, 2150110, 2160200, 2200160,
					5110015, 5110270, 5110103
				}
			},
			{
				ItemVFXSet.Astral,
				new int[15]
				{
					2000240, 2010210, 2020250, 2100230, 2110190, 2120210, 2130240, 2150070, 2150140, 2160160,
					2200110, 2300290, 5110011, 5110099, 5110230
				}
			},
			{
				ItemVFXSet.Smoke,
				new int[11]
				{
					2000290, 2010260, 2020300, 2100280, 2110240, 2120250, 2130290, 2150120, 2160210, 2200140,
					2300340
				}
			},
			{
				ItemVFXSet.Calygrey,
				new int[2] { 2020320, 2150160 }
			},
			{
				ItemVFXSet.AncientCalygrey,
				new int[2] { 2020325, 2150165 }
			},
			{
				ItemVFXSet.JadeLich,
				new int[2] { 2020030, 2150010 }
			},
			{
				ItemVFXSet.Blood,
				new int[3] { 2000221, 2100221, 2130230 }
			},
			{
				ItemVFXSet.Brand,
				new int[1] { 2000150 }
			},
			{
				ItemVFXSet.Maelstrom,
				new int[1] { 2000170 }
			},
			{
				ItemVFXSet.Sunfall,
				new int[1] { 2010070 }
			},
			{
				ItemVFXSet.ButcherCleaver,
				new int[1] { 2010140 }
			},
			{
				ItemVFXSet.Skycrown,
				new int[1] { 2020140 }
			},
			{
				ItemVFXSet.MaceOfSeasons,
				new int[1] { 2020160 }
			},
			{
				ItemVFXSet.Starchild,
				new int[1] { 2100100 }
			},
			{
				ItemVFXSet.Kelvin,
				new int[1] { 2110110 }
			},
			{
				ItemVFXSet.Challenger,
				new int[1] { 2120140 }
			},
			{
				ItemVFXSet.Werlig,
				new int[1] { 2130021 }
			},
			{
				ItemVFXSet.ThriceWrought,
				new int[1] { 2140060 }
			},
			{
				ItemVFXSet.Dreamer,
				new int[1] { 2140120 }
			},
			{
				ItemVFXSet.GhostReaper,
				new int[1] { 2140130 }
			},
			{
				ItemVFXSet.ScholarsStaff,
				new int[1] { 2150000 }
			},
			{
				ItemVFXSet.MagesPokingStick,
				new int[1] { 2150001 }
			},
			{
				ItemVFXSet.Sandrose,
				new int[1] { 2010285 }
			},
			{
				ItemVFXSet.SealedMace,
				new int[1] { 2020330 }
			},
			{
				ItemVFXSet.CruelPriest,
				new int[1] { 2020335 }
			},
			{
				ItemVFXSet.Grind,
				new int[1] { 2110265 }
			},
			{
				ItemVFXSet.Shriek,
				new int[1] { 2130315 }
			},
			{
				ItemVFXSet.Frostburn,
				new int[1] { 2150150 }
			},
			{
				ItemVFXSet.Duty,
				new int[1] { 2150175 }
			},
			{
				ItemVFXSet.Tokebakicit,
				new int[1] { 2160235 }
			},
			{
				ItemVFXSet.Murmure,
				new int[1] { 2200191 }
			},
			{
				ItemVFXSet.RedLady,
				new int[1] { 5110002 }
			},
			{
				ItemVFXSet.Manticore,
				new int[1] { 5110004 }
			},
			{
				ItemVFXSet.FrozenChakram,
				new int[1] { 5110060 }
			},
			{
				ItemVFXSet.MysteriousChakram,
				new int[1] { 5110070 }
			},
			{
				ItemVFXSet.ExperimentalChakram,
				new int[1] { 5110112 }
			},
			{
				ItemVFXSet.DistortedExperiment,
				new int[1] { 5110111 }
			},
			{
				ItemVFXSet.GildedShiver,
				new int[1] { 5110345 }
			},
			{
				ItemVFXSet.LionmanMace,
				new int[1] { 2400460 }
			},
			{
				ItemVFXSet.LionmanStaff,
				new int[1] { 2400461 }
			},
			{
				ItemVFXSet.GiantArchPriest,
				new int[1] { 2400121 }
			},
			{
				ItemVFXSet.MilitiaAxe,
				new int[1] { 2010271 }
			},
			{
				ItemVFXSet.MilitiaClaymore,
				new int[1] { 2100291 }
			},
			{
				ItemVFXSet.MilitiaSpear,
				new int[1] { 2130301 }
			}
		};

		private static readonly HashSet<ItemVFXSet> s_atTip = new HashSet<ItemVFXSet>
		{
			ItemVFXSet.ScholarsStaff,
			ItemVFXSet.MagesPokingStick
		};

		internal const float TipInset = 0.05f;

		private static readonly HashSet<ItemVFXSet> s_bladeUnderAuto = new HashSet<ItemVFXSet> { ItemVFXSet.Hailfrost };

		private static readonly Dictionary<ItemVFXSet, Dictionary<WeaponType, int>> s_byType = new Dictionary<ItemVFXSet, Dictionary<WeaponType, int>>();

		private static readonly Dictionary<string, Source> s_cache = new Dictionary<string, Source>();

		internal static bool AnchorsAtBladeBase(WeaponType type)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			if ((int)type != 0 && (int)type != 51)
			{
				return (int)type == 30;
			}
			return true;
		}

		internal static Mesh BladeOf(Transform visual, string key, bool includeLeftHand = false)
		{
			if (s_blades.TryGetValue(key, out var value))
			{
				if (value == null)
				{
					return null;
				}
				if (Object.op_Implicit((Object)(object)value))
				{
					return value;
				}
			}
			float baseX;
			Mesh val = BuildBlade(visual, includeLeftHand, out baseX);
			s_blades[key] = val;
			if (Object.op_Implicit((Object)(object)val))
			{
				s_bladeBases[key] = baseX;
			}
			return val;
		}

		internal static bool BladeBaseOf(Transform visual, string key, out float baseX)
		{
			baseX = 0f;
			if (Object.op_Implicit((Object)(object)BladeOf(visual, key)))
			{
				return s_bladeBases.TryGetValue(key, out baseX);
			}
			return false;
		}

		private static Mesh BuildBlade(Transform visual, bool includeLeftHand, out float baseX)
		{
			//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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_0114: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: 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_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a3: Expected O, but got Unknown
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			baseX = 0f;
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			Matrix4x4 worldToLocalMatrix = visual.worldToLocalMatrix;
			foreach (Renderer item in ModelRenderers(visual, includeLeftHand))
			{
				Mesh val = MeshOf(item);
				if (item is MeshRenderer && val.isReadable)
				{
					Matrix4x4 val2 = worldToLocalMatrix * ((Component)item).transform.localToWorldMatrix;
					int count = list.Count;
					Vector3[] vertices = val.vertices;
					foreach (Vector3 val3 in vertices)
					{
						list.Add(((Matrix4x4)(ref val2)).MultiplyPoint3x4(val3));
					}
					int[] triangles = val.triangles;
					foreach (int num in triangles)
					{
						list2.Add(count + num);
					}
				}
			}
			if (list2.Count == 0)
			{
				return null;
			}
			Dictionary<int, Vector4> dictionary = new Dictionary<int, Vector4>();
			foreach (Vector3 item2 in list)
			{
				AddToSlice(dictionary, Mathf.FloorToInt(item2.x / 0.1f), item2);
			}
			for (int j = 0; j < list2.Count; j += 3)
			{
				for (int k = 0; k < 3; k++)
				{
					Vector3 val4 = list[list2[j + k]];
					Vector3 val5 = list[list2[j + (k + 1) % 3]];
					int num2 = Mathf.FloorToInt(Mathf.Min(val4.x, val5.x) / 0.1f);
					int num3 = Mathf.FloorToInt(Mathf.Max(val4.x, val5.x) / 0.1f);
					for (int l = num2; l <= num3; l++)
					{
						float num4 = ((float)l + 0.5f) * 0.1f;
						if (!(num4 < Mathf.Min(val4.x, val5.x)) && !(num4 > Mathf.Max(val4.x, val5.x)) && !Mathf.Approximately(val4.x, val5.x))
						{
							AddToSlice(dictionary, l, Vector3.Lerp(val4, val5, (num4 - val4.x) / (val5.x - val4.x)));
						}
					}
				}
			}
			List<float> list3 = new List<float>();
			float num5 = float.MaxValue;
			foreach (KeyValuePair<int, Vector4> item3 in dictionary)
			{
				float num6 = Mathf.Max(item3.Value.y - item3.Value.x, item3.Value.w - item3.Value.z);
				num5 = Mathf.Min(num5, num6);
				float num7 = ((float)item3.Key + 0.5f) * 0.1f;
				if (num7 >= -0.05f && num7 <= 0.15f)
				{
					list3.Add(num6);
				}
			}
			float num8 = num5;
			if (list3.Count > 0)
			{
				list3.Sort();
				num8 = list3[list3.Count / 2];
			}
			HashSet<int> hashSet = new HashSet<int>();
			foreach (KeyValuePair<int, Vector4> item4 in dictionary)
			{
				if (!(((float)item4.Key + 0.5f) * 0.1f > -0.05f))
				{
					float num9 = item4.Value.y - item4.Value.x;
					float num10 = item4.Value.w - item4.Value.z;
					bool num11 = (num10 >= 1.8f * num9 && num10 > 0.01f) || (num9 >= 1.8f * num10 && num9 > 0.01f);
					bool flag = Mathf.Max(num9, num10) >= 2f * num8;
					if (num11 || flag)
					{
						hashSet.Add(item4.Key);
					}
				}
			}
			if (hashSet.Count == 0)
			{
				return null;
			}
			int guard = int.MinValue;
			float num12 = 0f;
			foreach (int item5 in hashSet)
			{
				if (!(((float)item5 + 0.5f) * 0.1f < -0.35f))
				{
					float num13 = SliceWidth(dictionary[item5]);
					if (num13 > num12)
					{
						guard = item5;
						num12 = num13;
					}
				}
			}
			if (guard != int.MinValue && hashSet.Contains(guard - 1) && SliceWidth(dictionary[guard - 1]) >= 0.6f * num12)
			{
				guard--;
			}
			if (guard != int.MinValue && dictionary.TryGetValue(guard - 1, out var value) && SliceWidth(value) < 0.6f * num12)
			{
				hashSet.RemoveWhere((int s) => s >= guard);
				if (hashSet.Count == 0)
				{
					return null;
				}
			}
			int num14 = int.MinValue;
			foreach (int item6 in hashSet)
			{
				num14 = Mathf.Max(num14, item6);
			}
			baseX = (float)(num14 + 1) * 0.1f;
			List<Vector3> list4 = new List<Vector3>();
			List<int> list5 = new List<int>();
			Dictionary<int, int> dictionary2 = new Dictionary<int, int>();
			for (int num15 = 0; num15 < list2.Count; num15 += 3)
			{
				float num16 = (list[list2[num15]].x + list[list2[num15 + 1]].x + list[list2[num15 + 2]].x) / 3f;
				if (!hashSet.Contains(Mathf.FloorToInt(num16 / 0.1f)))
				{
					continue;
				}
				for (int num17 = 0; num17 < 3; num17++)
				{
					int num18 = list2[num15 + num17];
					if (!dictionary2.TryGetValue(num18, out var value2))
					{
						value2 = list4.Count;
						list4.Add(list[num18]);
						dictionary2.Add(num18, value2);
					}
					list5.Add(value2);
				}
			}
			if (list5.Count == 0)
			{
				return null;
			}
			Mesh val6 = new Mesh();
			((Object)val6).name = "ItemVFX_Blade";
			((Object)val6).hideFlags = (HideFlags)32;
			if (list4.Count > 65000)
			{
				val6.indexFormat = (IndexFormat)1;
			}
			val6.SetVertices(list4);
			val6.SetTriangles(list5, 0);
			val6.RecalculateNormals();
			val6.RecalculateBounds();
			return val6;
		}

		private static float SliceWidth(Vector4 slice)
		{
			//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_000d: 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)
			return Mathf.Max(slice.y - slice.x, slice.w - slice.z);
		}

		private static void AddToSlice(Dictionary<int, Vector4> slices, int s, Vector3 p)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (slices.TryGetValue(s, out var value))
			{
				((Vector4)(ref value))..ctor(Mathf.Min(value.x, p.y), Mathf.Max(value.y, p.y), Mathf.Min(value.z, p.z), Mathf.Max(value.w, p.z));
			}
			else
			{
				((Vector4)(ref value))..ctor(p.y, p.y, p.z, p.z);
			}
			slices[s] = value;
		}

		internal static Profile ProfileOf(Transform visual, string key)
		{
			if (!s_profiles.TryGetValue(key, out var value))
			{
				value = Profile.Build(visual);
				s_profiles[key] = value;
			}
			return value;
		}

		internal static Profile ProfileOf(Source source)
		{
			if (source.Oversized)
			{
				return null;
			}
			return ProfileOf(source.Prefab, "source:" + source.Key);
		}

		internal static float WidthRatio(Vector2 a, Vector2 b)
		{
			//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_0016: 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)
			float num = a.y - a.x;
			if (!(num < 0.001f))
			{
				return (b.y - b.x) / num;
			}
			return 1f;
		}

		internal static Vector3 AxisFactors(Quaternion shapeRot, float ratio, float ky, float kz)
		{
			//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_0006: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0027: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(Blend(shapeRot * Vector3.right, ratio, ky, kz), Blend(shapeRot * Vector3.up, ratio, ky, kz), Blend(shapeRot * Vector3.forward, ratio, ky, kz));
		}

		private static float Blend(Vector3 d, float kx, float ky, float kz)
		{
			//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_000f: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			return d.x * d.x * kx + d.y * d.y * ky + d.z * d.z * kz;
		}

		internal static float HalfLengthAlongX(ShapeModule shape, Quaternion shapeRot)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//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_0069: Expected I4, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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)
			//IL_00cc: 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_00d5: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			if (!((ShapeModule)(ref shape)).enabled)
			{
				return 0.05f;
			}
			ParticleSystemShapeType shapeType = ((ShapeModule)(ref shape)).shapeType;
			Vector3 val;
			switch ((int)shapeType)
			{
			case 5:
			case 15:
			case 16:
			case 18:
				val = ((ShapeModule)(ref shape)).scale * 0.5f;
				break;
			case 0:
			case 2:
			case 4:
			case 10:
			case 12:
			case 17:
				val = ((ShapeModule)(ref shape)).scale * ((ShapeModule)(ref shape)).radius;
				break;
			default:
				return 0.05f;
			}
			return Mathf.Max(Mathf.Abs((shapeRot * Vector3.right).x) * val.x + Mathf.Abs((shapeRot * Vector3.up).x) * val.y + Mathf.Abs((shapeRot * Vector3.forward).x) * val.z, 0.05f);
		}

		internal static bool IsBladeShaped(Bounds model)
		{
			//IL_0002: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			if (((Bounds)(ref model)).min.x < -0.01f)
			{
				return ((Bounds)(ref model)).max.x < 0.5f * (0f - ((Bounds)(ref model)).min.x);
			}
			return false;
		}

		internal static bool AtTip(ItemVFXSet set)
		{
			return s_atTip.Contains(set);
		}

		internal static bool BladeUnderAuto(ItemVFXSet set)
		{
			return s_bladeUnderAuto.Contains(set);
		}

		internal static Source Get(ItemVFXSet set, Item target, bool special, out bool fallback)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			fallback = false;
			if (!s_sources.TryGetValue(set, out var value) || value.Length == 0)
			{
				return null;
			}
			Dictionary<WeaponType, int> dictionary = TypesOf(set, value);
			Weapon val = (Weapon)(object)((target is Weapon) ? target : null);
			if (!Object.op_Implicit((Object)(object)val) || !dictionary.TryGetValue(val.Type, out var value2))
			{
				value2 = value[0];
				fallback = true;
			}
			string key = value2 + (special ? "|special" : "|regular");
			if (s_cache.TryGetValue(key, out var value3))
			{
				return value3;
			}
			value3 = Load(value2, special);
			if (value3 != null)
			{
				value3.Key = key;
			}
			s_cache[key] = value3;
			return value3;
		}

		private static Dictionary<WeaponType, int> TypesOf(ItemVFXSet set, int[] ids)
		{
			//IL_0049: 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)
			if (s_byType.TryGetValue(set, out var value))
			{
				return value;
			}
			value = new Dictionary<WeaponType, int>();
			ResourcesPrefabManager instance = ResourcesPrefabManager.Instance;
			foreach (int num in ids)
			{
				Weapon val = (Weapon)((instance != null)