Decompiled source of AtlyssAttackSounds v1.1.1

plugins/Scrithor_AtlyssAttackSounds/AtlyssAttackSounds.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AtlyssAttackSounds
{
	public enum SoundCategory
	{
		Fast,
		Medium,
		Slow
	}
	public class JiggleController : MonoBehaviour
	{
		private const float DURATION = 0.5f;

		private Transform[] bones;

		private Dictionary<Transform, Vector3> originalScales;

		private float elapsed;

		private float intensity;

		private Vector3 currentScaleOffset;

		public void Init(Transform[] assBones, float jiggleIntensity)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (bones != null && originalScales != null)
			{
				ResetBones();
			}
			bones = assBones;
			intensity = jiggleIntensity;
			elapsed = 0f;
			originalScales = new Dictionary<Transform, Vector3>(bones.Length);
			Transform[] array = bones;
			foreach (Transform val in array)
			{
				if ((Object)(object)val != (Object)null && !originalScales.ContainsKey(val))
				{
					originalScales[val] = val.localScale;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_00c5: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			if (bones == null || bones.Length == 0)
			{
				return;
			}
			elapsed += Time.deltaTime;
			if (elapsed >= 0.5f)
			{
				ResetBones();
				Object.Destroy((Object)(object)this);
				return;
			}
			float num = elapsed / 0.5f;
			float num2 = Mathf.Sin(num * (float)Math.PI * 4f) * (1f - num) * (0.25f * intensity);
			currentScaleOffset.x = num2;
			currentScaleOffset.y = num2;
			currentScaleOffset.z = num2;
			foreach (KeyValuePair<Transform, Vector3> originalScale in originalScales)
			{
				if ((Object)(object)originalScale.Key != (Object)null)
				{
					originalScale.Key.localScale = originalScale.Value + currentScaleOffset;
				}
			}
		}

		public void ResetBones()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (originalScales == null)
			{
				return;
			}
			foreach (KeyValuePair<Transform, Vector3> originalScale in originalScales)
			{
				if ((Object)(object)originalScale.Key != (Object)null)
				{
					originalScale.Key.localScale = originalScale.Value;
				}
			}
		}

		private void OnDestroy()
		{
			ResetBones();
		}
	}
	public class AttackAudioPool : MonoBehaviour
	{
		private const int DEFAULT_POOL_SIZE = 6;

		private readonly List<AudioSource> sources = new List<AudioSource>();

		private int nextIndex;

		public AudioSource GetSource()
		{
			EnsureInitialized();
			foreach (AudioSource source in sources)
			{
				if ((Object)(object)source != (Object)null && !source.isPlaying)
				{
					return source;
				}
			}
			AudioSource result = sources[nextIndex % sources.Count];
			nextIndex = (nextIndex + 1) % sources.Count;
			return result;
		}

		private void Awake()
		{
			EnsureInitialized();
		}

		private void EnsureInitialized()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (sources.Count <= 0)
			{
				for (int i = 0; i < 6; i++)
				{
					GameObject val = new GameObject($"AttackSoundSource_{i + 1}");
					val.transform.SetParent(((Component)this).transform, false);
					AudioSource val2 = val.AddComponent<AudioSource>();
					val2.playOnAwake = false;
					val2.loop = false;
					val2.spatialBlend = 0f;
					val2.dopplerLevel = 0f;
					val2.rolloffMode = (AudioRolloffMode)1;
					sources.Add(val2);
				}
			}
		}
	}
	[BepInPlugin("scrithor_Atlyss.Attack.Sounds", "AtlyssAttackSounds", "1.1.1")]
	public class AtlyssAttackSoundsMod : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerCombat), "Init_Attack")]
		public static class AttackDetector
		{
			[HarmonyPostfix]
			private static void Postfix(PlayerCombat __instance)
			{
				try
				{
					Player component = ((Component)__instance).GetComponent<Player>();
					if (!((Object)(object)component == (Object)null) && !((Object)(object)component != (Object)(object)Player._mainPlayer) && (Object)(object)Instance != (Object)null)
					{
						((MonoBehaviour)Instance).StartCoroutine(ProcessAttackWithCustomDelay(component));
					}
				}
				catch (Exception arg)
				{
					logger.LogError((object)$"[ERRO HOOK]: {arg}");
				}
			}
		}

		public const string GUID = "scrithor_Atlyss.Attack.Sounds";

		public const string NAME = "AtlyssAttackSounds";

		public const string VERSION = "1.1.1";

		public const float COOLDOWN_BUFFER = 0.2f;

		private const float MIN_SOUND_INTERVAL = 0.03f;

		public static bool FORCE_SLOW_TEST_MODE = false;

		public static ManualLogSource logger;

		public static ConfigEntry<float> volumeFastConfig;

		public static ConfigEntry<float> volumeMediumConfig;

		public static ConfigEntry<float> volumeSlowConfig;

		public static ConfigEntry<float> chanceFastConfig;

		public static ConfigEntry<float> chanceMediumConfig;

		public static ConfigEntry<float> chanceSlowConfig;

		public static ConfigEntry<float> jiggleIntensityConfig;

		public static ConfigEntry<float> particleSizeConfig;

		public static ConfigEntry<string> particleStartColorsConfig;

		private static ConfigEntry<KeyboardShortcut> toggleMenuKeyConfig;

		public static ConfigEntry<float> delayScepterGrounded;

		public static ConfigEntry<float> delayScepterAir;

		public static ConfigEntry<float> delayBowGrounded;

		public static ConfigEntry<float> delayBowAir;

		public static ConfigEntry<float> delayGreatbladeGrounded;

		public static ConfigEntry<float> delayGreatbladeAir;

		public static ConfigEntry<float> delayBladeGrounded;

		public static ConfigEntry<float> delayBladeAir;

		public static ConfigEntry<float> delayPolearmGrounded;

		public static ConfigEntry<float> delayPolearmAir;

		public static ConfigEntry<float> delayBellGrounded;

		public static ConfigEntry<float> delayBellAir;

		public static ConfigEntry<float> delayKatarGrounded;

		public static ConfigEntry<float> delayKatarAir;

		public static ConfigEntry<float> delayDefaultGrounded;

		public static ConfigEntry<float> delayDefaultAir;

		private static readonly Dictionary<SoundCategory, List<AudioClip>> categoryClips = new Dictionary<SoundCategory, List<AudioClip>>
		{
			{
				SoundCategory.Fast,
				new List<AudioClip>()
			},
			{
				SoundCategory.Medium,
				new List<AudioClip>()
			},
			{
				SoundCategory.Slow,
				new List<AudioClip>()
			}
		};

		private static readonly string[] EXACT_BONE_NAMES = new string[16]
		{
			"assbase.l", "assbase.r", "butt.l", "butt.r", "butt_l", "butt_r", "glute.l", "glute.r", "cheek.l", "cheek.r",
			"ass.l", "ass.r", "b_ass_L", "b_ass_R", "b_butt_L", "b_butt_R"
		};

		private static readonly string[] FORBIDDEN_BONE_KEYWORDS = new string[11]
		{
			"root", "master", "pelvis", "hip", "body", "chassis", "armature", "player", "spine", "torso",
			"thigh"
		};

		private static GameObject particlePrefab;

		private static readonly Random random = new Random();

		private static readonly FieldInfo playerCombatField = AccessTools.Field(typeof(Player), "_pCombat");

		private static readonly FieldInfo playerVisualField = AccessTools.Field(typeof(Player), "_pVisual");

		private static readonly FieldInfo playerActionField = AccessTools.Field(typeof(Player), "_currentPlayerAction");

		private static readonly FieldInfo currentSwingStateField = AccessTools.Field(typeof(PlayerCombat), "_currentSwingState");

		private static readonly FieldInfo visualAnimatorField = AccessTools.Field(typeof(PlayerVisual), "_visualAnimator");

		private static readonly FieldInfo equippedWeaponField = AccessTools.Field(typeof(PlayerCombat), "_equippedWeapon");

		private static float nextAllowedTime;

		private static float lastAttackTriggerTime;

		private static float currentAttackCooldown;

		private Harmony harmony;

		private bool wasToggleKeyPressed;

		public static AtlyssAttackSoundsMod Instance { get; private set; }

		private void Awake()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			Instance = this;
			logger = ((BaseUnityPlugin)this).Logger;
			InitConfiguration();
			string? directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "sounds");
			string bundlePath = Path.Combine(directoryName, "Assets", "atlyss");
			LoadAssetBundle(bundlePath);
			if (Directory.Exists(text))
			{
				((MonoBehaviour)this).StartCoroutine(LoadAudioFiles(text));
			}
			harmony = new Harmony("scrithor_Atlyss.Attack.Sounds");
			harmony.PatchAll(typeof(AtlyssAttackSoundsMod).Assembly);
			logger.LogInfo((object)"AtlyssAttackSounds v1.1.1 initialized.");
		}

		private void Start()
		{
			SettingsUI.Initialize(volumeFastConfig, volumeMediumConfig, volumeSlowConfig, chanceFastConfig, chanceMediumConfig, chanceSlowConfig, jiggleIntensityConfig, particleSizeConfig);
		}

		private void Update()
		{
			HandleSettingsToggle();
		}

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

		private void HandleSettingsToggle()
		{
			//IL_001a: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut val = (KeyboardShortcut)(((??)toggleMenuKeyConfig?.Value) ?? new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()));
			bool flag = ((KeyboardShortcut)(ref val)).IsDown();
			if (flag && !wasToggleKeyPressed)
			{
				wasToggleKeyPressed = true;
				SettingsUI.ToggleVisible();
			}
			else if (!flag)
			{
				wasToggleKeyPressed = false;
			}
		}

		private void InitConfiguration()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			volumeFastConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Audio Volumes", "Volume_Fast", 1f, new ConfigDescription("Fast audio volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			volumeMediumConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Audio Volumes", "Volume_Medium", 0.85f, new ConfigDescription("Medium audio volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			volumeSlowConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Audio Volumes", "Volume_Slow", 0.3f, new ConfigDescription("Slow audio volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			chanceFastConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Proc Chances", "Chance_Fast", 84f, new ConfigDescription("Relative weight for Fast sounds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			chanceMediumConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Proc Chances", "Chance_Medium", 12f, new ConfigDescription("Relative weight for Medium sounds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			chanceSlowConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Proc Chances", "Chance_Slow", 4f, new ConfigDescription("Relative weight for Slow sounds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			jiggleIntensityConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Effects", "JiggleIntensity", 1.5f, new ConfigDescription("Intensity of physical bone deformation.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			particleSizeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Effects", "ParticleSize", 0.2f, new ConfigDescription("Particle size distribution.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 2f), Array.Empty<object>()));
			particleStartColorsConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Effects", "ParticleStartColors", "CFFF4E, 77F131, 349300", "Initial colors in Hexadecimal.");
			toggleMenuKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Settings Menu", "ToggleMenuKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Key to open/close the settings menu.");
			delayScepterGrounded = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Scepter_Grounded", 0.533f, "Delay para Scepter no chão");
			delayScepterAir = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Scepter_Air", 0.533f, "Delay para Scepter no ar");
			delayBowGrounded = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Bow_Grounded", 0.366f, "Delay para Bow no chão");
			delayBowAir = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Bow_Air", 0.366f, "Delay para Bow no ar");
			delayGreatbladeGrounded = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Greatblade_Grounded", 0.78f, "Delay para Greatblade no chão");
			delayGreatbladeAir = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Greatblade_Air", 0.993f, "Delay para Greatblade no ar");
			delayBladeGrounded = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Blade_Grounded", 0.46f, "Delay para Blade no chão");
			delayBladeAir = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Blade_Air", 0.98f, "Delay para Blade no ar");
			delayPolearmGrounded = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Polearm_Grounded", 0.49f, "Delay para Polearm no chão");
			delayPolearmAir = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Polearm_Air", 0.85f, "Delay para Polearm no ar");
			delayBellGrounded = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Bell_Grounded", 0.98f, "Delay para Bell no chão");
			delayBellAir = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Bell_Air", 0.633f, "Delay para Bell no ar");
			delayKatarGrounded = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Katar_Grounded", 0.266f, "Delay para Katar no chão");
			delayKatarAir = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Katar_Air", 0.72f, "Delay para Katar no ar");
			delayDefaultGrounded = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Default_Grounded", 0.4f, "Delay padrão para outras armas no chão");
			delayDefaultAir = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Delays", "Default_Air", 0.5f, "Delay padrão para outras armas no ar");
		}

		private void LoadAssetBundle(string bundlePath)
		{
			if (!File.Exists(bundlePath))
			{
				logger.LogError((object)("[ERRO ASSETBUNDLE] File missing in: " + bundlePath));
				return;
			}
			AssetBundle val = AssetBundle.LoadFromFile(bundlePath);
			if ((Object)(object)val == (Object)null)
			{
				logger.LogError((object)"[ERRO ASSETBUNDLE] Unable to load the asset package.");
				return;
			}
			GameObject[] array = val.LoadAllAssets<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val2 in array2)
			{
				if ((Object)(object)val2.GetComponentInChildren<ParticleSystem>(true) != (Object)null)
				{
					particlePrefab = val2;
					break;
				}
			}
			if ((Object)(object)particlePrefab == (Object)null && array.Length != 0)
			{
				particlePrefab = array[0];
			}
			if ((Object)(object)particlePrefab != (Object)null)
			{
				logger.LogInfo((object)("[ASSETBUNDLE SUCESSO] Prefab de partícula identificado: " + ((Object)particlePrefab).name));
			}
		}

		private IEnumerator LoadAudioFiles(string directoryPath)
		{
			UnloadAudioClips();
			string[] files = Directory.GetFiles(directoryPath, "*.*", SearchOption.AllDirectories);
			string[] array = files;
			foreach (string filePath in array)
			{
				AudioType val = (AudioType)(Path.GetExtension(filePath).ToLower() switch
				{
					".wav" => 20, 
					".ogg" => 14, 
					".mp3" => 13, 
					_ => 0, 
				});
				if ((int)val == 0)
				{
					continue;
				}
				string absoluteUri = new Uri(filePath).AbsoluteUri;
				UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, val);
				try
				{
					yield return www.SendWebRequest();
					if ((int)www.result == 1)
					{
						AudioClip content = DownloadHandlerAudioClip.GetContent(www);
						((Object)content).name = Path.GetFileNameWithoutExtension(filePath);
						SoundCategory key = DetermineCategory(filePath);
						categoryClips[key].Add(content);
					}
				}
				finally
				{
					((IDisposable)www)?.Dispose();
				}
			}
		}

		private void UnloadAudioClips()
		{
			foreach (List<AudioClip> value in categoryClips.Values)
			{
				foreach (AudioClip item in value)
				{
					if ((Object)(object)item != (Object)null)
					{
						Object.Destroy((Object)(object)item);
					}
				}
				value.Clear();
			}
		}

		private static SoundCategory DetermineCategory(string filePath)
		{
			string text = Path.GetFileName(Path.GetDirectoryName(filePath))?.ToLower() ?? "";
			if (text.Contains("medium"))
			{
				return SoundCategory.Medium;
			}
			if (text.Contains("slow"))
			{
				return SoundCategory.Slow;
			}
			return SoundCategory.Fast;
		}

		private static IEnumerator ProcessAttackWithCustomDelay(Player player)
		{
			if (!((Object)(object)player == (Object)null) && !(Time.time - lastAttackTriggerTime < currentAttackCooldown))
			{
				bool isAirAttack = !GetIsGrounded(player);
				float animationDuration = GetAnimationDuration(GetEquippedWeaponName(player), isAirAttack);
				lastAttackTriggerTime = Time.time;
				currentAttackCooldown = animationDuration;
				yield return (object)new WaitForSeconds(animationDuration);
				if ((Object)(object)player != (Object)null && (Object)(object)player == (Object)(object)Player._mainPlayer)
				{
					TryTriggerResolvedAttackEffect(player);
				}
			}
		}

		private static float GetAnimationDuration(string weaponName, bool isAirAttack)
		{
			string text = weaponName.ToLower();
			if (text.Contains("scepter"))
			{
				if (!isAirAttack)
				{
					return delayScepterGrounded.Value;
				}
				return delayScepterAir.Value;
			}
			if (text.Contains("bow"))
			{
				if (!isAirAttack)
				{
					return delayBowGrounded.Value;
				}
				return delayBowAir.Value;
			}
			if (text.Contains("greatblade"))
			{
				if (!isAirAttack)
				{
					return delayGreatbladeGrounded.Value;
				}
				return delayGreatbladeAir.Value;
			}
			if (text.Contains("blade"))
			{
				if (!isAirAttack)
				{
					return delayBladeGrounded.Value;
				}
				return delayBladeAir.Value;
			}
			if (text.Contains("polearm"))
			{
				if (!isAirAttack)
				{
					return delayPolearmGrounded.Value;
				}
				return delayPolearmAir.Value;
			}
			if (text.Contains("bell"))
			{
				if (!isAirAttack)
				{
					return delayBellGrounded.Value;
				}
				return delayBellAir.Value;
			}
			if (text.Contains("katar"))
			{
				if (!isAirAttack)
				{
					return delayKatarGrounded.Value;
				}
				return delayKatarAir.Value;
			}
			if (!isAirAttack)
			{
				return delayDefaultGrounded.Value;
			}
			return delayDefaultAir.Value;
		}

		private static bool GetIsGrounded(Player player)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return true;
			}
			CharacterController component = ((Component)player).GetComponent<CharacterController>();
			if ((Object)(object)component != (Object)null)
			{
				return component.isGrounded;
			}
			Rigidbody component2 = ((Component)player).GetComponent<Rigidbody>();
			if ((Object)(object)component2 != (Object)null)
			{
				return Mathf.Abs(component2.velocity.y) < 0.01f;
			}
			return true;
		}

		private static string GetEquippedWeaponName(Player player)
		{
			if ((Object)(object)player == (Object)null || playerCombatField == null || equippedWeaponField == null)
			{
				return string.Empty;
			}
			object? value = playerCombatField.GetValue(player);
			PlayerCombat val = (PlayerCombat)((value is PlayerCombat) ? value : null);
			if ((Object)(object)val == (Object)null)
			{
				return string.Empty;
			}
			object value2 = equippedWeaponField.GetValue(val);
			if (value2 != null)
			{
				return value2.ToString();
			}
			return string.Empty;
		}

		private static bool TryTriggerResolvedAttackEffect(Player player)
		{
			if ((Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player._mainPlayer)
			{
				return false;
			}
			if (Time.time < nextAllowedTime)
			{
				return false;
			}
			if (TriggerSoundEffect(player) <= 0f)
			{
				return false;
			}
			nextAllowedTime = Time.time + 0.03f;
			return true;
		}

		private static float TriggerSoundEffect(Player player)
		{
			if (categoryClips.Values.Sum((List<AudioClip> l) => l.Count) == 0)
			{
				return 0f;
			}
			SoundCategory soundCategory = (FORCE_SLOW_TEST_MODE ? SoundCategory.Slow : SelectCategoryByRarity());
			List<AudioClip> pool = categoryClips[soundCategory];
			if (pool.Count == 0)
			{
				List<KeyValuePair<SoundCategory, List<AudioClip>>> list = categoryClips.Where((KeyValuePair<SoundCategory, List<AudioClip>> kv) => kv.Value.Count > 0).ToList();
				if (list.Count == 0)
				{
					return 0f;
				}
				pool = list[random.Next(list.Count)].Value;
				soundCategory = categoryClips.First((KeyValuePair<SoundCategory, List<AudioClip>> kv) => kv.Value == pool).Key;
			}
			AudioClip val = pool[random.Next(pool.Count)];
			AttackAudioPool audioPool = GetAudioPool(player);
			if ((Object)(object)audioPool == (Object)null)
			{
				return 0f;
			}
			AudioSource source = audioPool.GetSource();
			if ((Object)(object)source == (Object)null)
			{
				return 0f;
			}
			float volumeForCategory = GetVolumeForCategory(soundCategory);
			source.PlayOneShot(val, volumeForCategory);
			TriggerJiggleEffect(player);
			if (soundCategory == SoundCategory.Slow)
			{
				TriggerParticleEffect(player);
			}
			return val.length;
		}

		private static AttackAudioPool GetAudioPool(Player player)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			AttackAudioPool componentInChildren = ((Component)player).GetComponentInChildren<AttackAudioPool>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				return componentInChildren;
			}
			GameObject val = new GameObject("AttackSoundsAudioPool");
			val.transform.SetParent(((Component)player).transform, false);
			((Object)val).hideFlags = (HideFlags)61;
			return val.AddComponent<AttackAudioPool>();
		}

		private static void TriggerJiggleEffect(Player player)
		{
			Transform[] array = FindAssBones(((Component)player).transform);
			if (array.Length != 0)
			{
				JiggleController jiggleController = ((Component)player).gameObject.GetComponent<JiggleController>();
				if ((Object)(object)jiggleController == (Object)null)
				{
					jiggleController = ((Component)player).gameObject.AddComponent<JiggleController>();
				}
				jiggleController.Init(array, jiggleIntensityConfig.Value);
			}
		}

		private static void TriggerParticleEffect(Player player)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			Transform[] array = FindAssBones(((Component)player).transform);
			if ((Object)(object)particlePrefab != (Object)null)
			{
				Vector3 val = ((Component)player).transform.position + ((Component)player).transform.up * 0.4f;
				if (array.Length != 0)
				{
					val = array[0].position;
				}
				GameObject val2 = Object.Instantiate<GameObject>(particlePrefab, val, Quaternion.identity);
				val2.transform.localScale = Vector3.one * particleSizeConfig.Value;
				val2.transform.SetParent(((Component)player).transform, true);
				val2.SetActive(true);
				ParticleSystem componentInChildren = val2.GetComponentInChildren<ParticleSystem>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.Stop(true, (ParticleSystemStopBehavior)0);
					MainModule main = componentInChildren.main;
					((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0;
					((MainModule)(ref main)).duration = 1.7f;
					((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.7f);
					((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(1f);
					((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
					((MainModule)(ref main)).loop = false;
					((MainModule)(ref main)).playOnAwake = false;
					Color val3 = ParseColor(particleStartColorsConfig.Value.Split(new char[1] { ',' })[0], Color.green);
					((MainModule)(ref main)).startColor = new MinMaxGradient(val3);
					ColorOverLifetimeModule colorOverLifetime = componentInChildren.colorOverLifetime;
					((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
					Gradient val4 = new Gradient();
					float num = 0.52941173f;
					val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
					{
						new GradientColorKey(Color.white, 0f),
						new GradientColorKey(Color.white, 1f)
					}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
					{
						new GradientAlphaKey(1f, 0f),
						new GradientAlphaKey(1f, num),
						new GradientAlphaKey(0f, 1f)
					});
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val4);
					SizeOverLifetimeModule sizeOverLifetime = componentInChildren.sizeOverLifetime;
					((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
					AnimationCurve val5 = new AnimationCurve();
					val5.AddKey(0f, 1f);
					val5.AddKey(num, 1f);
					val5.AddKey(1f, 0.2f);
					((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, val5);
					componentInChildren.Clear(true);
					componentInChildren.Play();
					componentInChildren.Emit(30);
					logger.LogInfo((object)$"[PARTICLE] Emitted with fade: dur={((MainModule)(ref main)).duration}, lifetime={((MainModule)(ref main)).startLifetime}, fadeStart={num}");
				}
				Object.Destroy((Object)(object)val2, 1.8f);
			}
		}

		private static Color ParseColor(string hex, Color defaultColor)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			hex = hex.Trim().Replace("#", "");
			Color result = default(Color);
			if (!ColorUtility.TryParseHtmlString("#" + hex, ref result))
			{
				return defaultColor;
			}
			return result;
		}

		private static Transform[] FindAssBones(Transform root)
		{
			List<Transform> list = new List<Transform>();
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if ((Object)(object)val == (Object)(object)root)
				{
					continue;
				}
				string lowerName = ((Object)val).name.ToLower();
				if (FORBIDDEN_BONE_KEYWORDS.Any((string keyword) => lowerName.Contains(keyword)))
				{
					continue;
				}
				string[] eXACT_BONE_NAMES = EXACT_BONE_NAMES;
				foreach (string value in eXACT_BONE_NAMES)
				{
					if (lowerName.Equals(value, StringComparison.OrdinalIgnoreCase) && !list.Contains(val))
					{
						list.Add(val);
					}
				}
			}
			return list.ToArray();
		}

		private static SoundCategory SelectCategoryByRarity()
		{
			float num = Mathf.Max(0f, chanceFastConfig.Value);
			float num2 = Mathf.Max(0f, chanceMediumConfig.Value);
			float num3 = Mathf.Max(0f, chanceSlowConfig.Value);
			float num4 = num + num2 + num3;
			if (num4 <= 0f)
			{
				return SoundCategory.Fast;
			}
			double num5 = random.NextDouble() * (double)num4;
			if (num5 < (double)num)
			{
				return SoundCategory.Fast;
			}
			if (num5 < (double)(num + num2))
			{
				return SoundCategory.Medium;
			}
			return SoundCategory.Slow;
		}

		private static float GetVolumeForCategory(SoundCategory category)
		{
			return category switch
			{
				SoundCategory.Medium => Mathf.Clamp(volumeMediumConfig.Value, 0f, 1f), 
				SoundCategory.Slow => Mathf.Clamp(volumeSlowConfig.Value, 0f, 1f), 
				_ => Mathf.Clamp(volumeFastConfig.Value, 0f, 1f), 
			};
		}
	}
	public static class SettingsUI
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__6_0;

			public static UnityAction <>9__17_0;

			internal void <CreateBackgroundOverlay>b__6_0()
			{
				SetVisible(visible: false);
			}

			internal void <CreateCloseButton>b__17_0()
			{
				SetVisible(visible: false);
			}
		}

		private static GameObject canvasObject;

		private static GameObject panelObject;

		private static bool isVisible;

		private static bool initialized;

		public static bool IsVisible => isVisible;

		public static void Initialize(ConfigEntry<float> volumeFast, ConfigEntry<float> volumeMedium, ConfigEntry<float> volumeSlow, ConfigEntry<float> chanceFast, ConfigEntry<float> chanceMedium, ConfigEntry<float> chanceSlow, ConfigEntry<float> jiggleIntensity, ConfigEntry<float> particleSize)
		{
			if (!initialized)
			{
				CreateCanvas();
				CreateBackgroundOverlay();
				CreateMainPanel(volumeFast, volumeMedium, volumeSlow, chanceFast, chanceMedium, chanceSlow, jiggleIntensity, particleSize);
				canvasObject.SetActive(false);
				isVisible = false;
				initialized = true;
				AtlyssAttackSoundsMod.logger.LogInfo((object)"[SettingsUI] Custom settings menu created. Press F7 to toggle.");
			}
		}

		private static void CreateCanvas()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			canvasObject = new GameObject("AttackSoundsSettingsCanvas", new Type[3]
			{
				typeof(Canvas),
				typeof(CanvasScaler),
				typeof(GraphicRaycaster)
			});
			Object.DontDestroyOnLoad((Object)(object)canvasObject);
			Canvas component = canvasObject.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.sortingOrder = 200;
			CanvasScaler component2 = canvasObject.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			component2.screenMatchMode = (ScreenMatchMode)0;
			component2.matchWidthOrHeight = 0.5f;
		}

		private static void CreateBackgroundOverlay()
		{
			//IL_001b: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			GameObject obj = CreateUIObject("BackgroundOverlay", canvasObject.transform);
			RectTransform component = obj.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			((Graphic)obj.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.65f);
			Button obj2 = obj.AddComponent<Button>();
			ButtonClickedEvent onClick = obj2.onClick;
			object obj3 = <>c.<>9__6_0;
			if (obj3 == null)
			{
				UnityAction val = delegate
				{
					SetVisible(visible: false);
				};
				<>c.<>9__6_0 = val;
				obj3 = (object)val;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj3);
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)obj2).navigation = navigation;
		}

		private static void CreateMainPanel(ConfigEntry<float> volumeFast, ConfigEntry<float> volumeMedium, ConfigEntry<float> volumeSlow, ConfigEntry<float> chanceFast, ConfigEntry<float> chanceMedium, ConfigEntry<float> chanceSlow, ConfigEntry<float> jiggleIntensity, ConfigEntry<float> particleSize)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			panelObject = new GameObject("SettingsPanel", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(VerticalLayoutGroup)
			});
			panelObject.transform.SetParent(canvasObject.transform, false);
			RectTransform component = panelObject.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(540f, 0f);
			component.anchoredPosition = Vector2.zero;
			Image component2 = panelObject.GetComponent<Image>();
			((Graphic)component2).color = new Color(0.1f, 0.1f, 0.1f, 0.97f);
			component2.type = (Type)1;
			VerticalLayoutGroup component3 = panelObject.GetComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component3).spacing = 6f;
			((LayoutGroup)component3).padding = new RectOffset(22, 22, 16, 16);
			((LayoutGroup)component3).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = false;
			CreateTitle("⚔ Attack Sounds Settings");
			CreateSeparator();
			CreateSectionHeader("Audio Volumes");
			CreateSliderRow("Volume - Fast", volumeFast, "%", "F2", wholeNumbers: false);
			CreateSliderRow("Volume - Medium", volumeMedium, "%", "F2", wholeNumbers: false);
			CreateSliderRow("Volume - Slow", volumeSlow, "%", "F2", wholeNumbers: false);
			CreateSeparator();
			CreateSectionHeader("Proc Chances (Weights)");
			CreateSliderRow("Chance - Fast", chanceFast, "", "F0", wholeNumbers: false);
			CreateSliderRow("Chance - Medium", chanceMedium, "", "F0", wholeNumbers: false);
			CreateSliderRow("Chance - Slow", chanceSlow, "", "F0", wholeNumbers: false);
			CreateSeparator();
			CreateSectionHeader("Visual & Physical Effects");
			CreateSliderRow("Jiggle Intensity", jiggleIntensity, "", "F2", wholeNumbers: false);
			CreateSliderRow("Particle Size", particleSize, "", "F2", wholeNumbers: false);
			CreateSeparator();
			CreateCloseButton();
		}

		public static void SetVisible(bool visible)
		{
			isVisible = visible;
			if ((Object)(object)canvasObject != (Object)null)
			{
				canvasObject.SetActive(visible);
			}
		}

		public static void ToggleVisible()
		{
			SetVisible(!isVisible);
		}

		private static GameObject CreateUIObject(string name, Transform parent)
		{
			//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_0027: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			return val;
		}

		private static void CreateTitle(string text)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = CreateUIObject("Title", panelObject.transform);
			Text obj2 = obj.AddComponent<Text>();
			obj2.text = text;
			obj2.fontSize = 22;
			obj2.fontStyle = (FontStyle)1;
			((Graphic)obj2).color = new Color(1f, 0.85f, 0.15f);
			obj2.alignment = (TextAnchor)4;
			AssignFont(obj2);
			LayoutElement obj3 = obj.AddComponent<LayoutElement>();
			obj3.minHeight = 38f;
			obj3.flexibleWidth = 1f;
		}

		private static void CreateSeparator()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = CreateUIObject("Separator", panelObject.transform);
			((Graphic)obj.AddComponent<Image>()).color = new Color(1f, 1f, 1f, 0.12f);
			LayoutElement obj2 = obj.AddComponent<LayoutElement>();
			obj2.minHeight = 2f;
			obj2.flexibleWidth = 1f;
		}

		private static void CreateSectionHeader(string text)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = CreateUIObject("Header", panelObject.transform);
			Text obj2 = obj.AddComponent<Text>();
			obj2.text = text;
			obj2.fontSize = 16;
			obj2.fontStyle = (FontStyle)1;
			((Graphic)obj2).color = new Color(0.55f, 0.8f, 1f);
			obj2.alignment = (TextAnchor)3;
			AssignFont(obj2);
			LayoutElement obj3 = obj.AddComponent<LayoutElement>();
			obj3.minHeight = 26f;
			obj3.flexibleWidth = 1f;
		}

		private static void CreateSliderRow(string label, ConfigEntry<float> configEntry, string displaySuffix, string format, bool wholeNumbers)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject("Row_" + ((ConfigEntryBase)configEntry).Definition.Key, panelObject.transform);
			HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 10f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			LayoutElement obj2 = val.AddComponent<LayoutElement>();
			obj2.minHeight = 32f;
			obj2.flexibleWidth = 1f;
			GameObject obj3 = CreateUIObject("Label", val.transform);
			Text val2 = obj3.AddComponent<Text>();
			float value = configEntry.Value;
			val2.text = label + ":  " + value.ToString(format) + displaySuffix;
			val2.fontSize = 14;
			((Graphic)val2).color = Color.white;
			val2.alignment = (TextAnchor)3;
			AssignFont(val2);
			LayoutElement obj4 = obj3.AddComponent<LayoutElement>();
			obj4.minWidth = 200f;
			obj4.flexibleWidth = 0.55f;
			GameObject val3 = CreateUIObject("Slider", val.transform);
			Slider obj5 = val3.AddComponent<Slider>();
			float minValue = 0f;
			float maxValue = 1f;
			if (((ConfigEntryBase)configEntry).Description.AcceptableValues is AcceptableValueRange<float> val4)
			{
				minValue = val4.MinValue;
				maxValue = val4.MaxValue;
			}
			obj5.minValue = minValue;
			obj5.maxValue = maxValue;
			obj5.value = configEntry.Value;
			obj5.wholeNumbers = wholeNumbers;
			GameObject obj6 = CreateUIObject("Background", val3.transform);
			((Graphic)obj6.AddComponent<Image>()).color = new Color(0.22f, 0.22f, 0.22f, 1f);
			RectTransform component = obj6.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			GameObject val5 = CreateUIObject("Fill Area", val3.transform);
			RectTransform component2 = val5.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.sizeDelta = new Vector2(-8f, -4f);
			component2.anchoredPosition = Vector2.zero;
			GameObject obj7 = CreateUIObject("Fill", val5.transform);
			((Graphic)obj7.AddComponent<Image>()).color = new Color(0.3f, 0.65f, 1f, 1f);
			RectTransform component3 = obj7.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(0f, 1f);
			component3.sizeDelta = Vector2.zero;
			GameObject val6 = CreateUIObject("Handle Slide Area", val3.transform);
			RectTransform component4 = val6.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 0f);
			component4.anchorMax = new Vector2(1f, 1f);
			component4.sizeDelta = new Vector2(-8f, 0f);
			component4.anchoredPosition = Vector2.zero;
			GameObject obj8 = CreateUIObject("Handle", val6.transform);
			Image val7 = obj8.AddComponent<Image>();
			((Graphic)val7).color = Color.white;
			RectTransform component5 = obj8.GetComponent<RectTransform>();
			component5.sizeDelta = new Vector2(14f, 14f);
			((Selectable)obj5).targetGraphic = (Graphic)(object)val7;
			obj5.fillRect = component3;
			obj5.handleRect = component5;
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)obj5).navigation = navigation;
			LayoutElement obj9 = val3.AddComponent<LayoutElement>();
			obj9.flexibleWidth = 0.45f;
			obj9.minHeight = 26f;
			Text capturedLabel = val2;
			((UnityEvent<float>)(object)obj5.onValueChanged).AddListener((UnityAction<float>)delegate(float newVal)
			{
				configEntry.Value = newVal;
				capturedLabel.text = label + ":  " + newVal.ToString(format) + displaySuffix;
			});
		}

		private static void CreateCloseButton()
		{
			//IL_0031: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			GameObject val = CreateUIObject("CloseButton", panelObject.transform);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.45f, 0.15f, 0.15f, 1f);
			val2.type = (Type)1;
			Button obj = val.AddComponent<Button>();
			((Selectable)obj).targetGraphic = (Graphic)(object)val2;
			ButtonClickedEvent onClick = obj.onClick;
			object obj2 = <>c.<>9__17_0;
			if (obj2 == null)
			{
				UnityAction val3 = delegate
				{
					SetVisible(visible: false);
				};
				<>c.<>9__17_0 = val3;
				obj2 = (object)val3;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj2);
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)obj).navigation = navigation;
			GameObject obj3 = CreateUIObject("Text", val.transform);
			Text obj4 = obj3.AddComponent<Text>();
			obj4.text = "Close  [F7]";
			obj4.fontSize = 15;
			obj4.fontStyle = (FontStyle)1;
			((Graphic)obj4).color = Color.white;
			obj4.alignment = (TextAnchor)4;
			AssignFont(obj4);
			RectTransform component = obj3.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			LayoutElement obj5 = val.AddComponent<LayoutElement>();
			obj5.minHeight = 36f;
			obj5.flexibleWidth = 1f;
		}

		private static void AssignFont(Text text)
		{
			Font val = Resources.GetBuiltinResource<Font>("Arial.ttf");
			if ((Object)(object)val == (Object)null)
			{
				val = Font.CreateDynamicFontFromOSFont("Arial", 14);
			}
			if ((Object)(object)val != (Object)null)
			{
				text.font = val;
			}
		}

		public static void Destroy()
		{
			if ((Object)(object)canvasObject != (Object)null)
			{
				Object.Destroy((Object)(object)canvasObject);
				canvasObject = null;
				panelObject = null;
				initialized = false;
				isVisible = false;
			}
		}
	}
}