Decompiled source of QuickGunFx v1.0.0

Mods/QuickGunFX.dll

Decompiled 9 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib.BoneMenu;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using QuickGunFX;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(GunFXMod), "QuickGunFX", "1.0.0", "nontendo", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("QuickGunFX")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("QuickGunFX")]
[assembly: AssemblyTitle("QuickGunFX")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace QuickGunFX
{
	[HarmonyPatch(typeof(Gun), "Fire")]
	public static class Gun_Fire_Patch
	{
		private static readonly Dictionary<Gun, int> _lastAmmo = new Dictionary<Gun, int>();

		public static void Postfix(Gun __instance)
		{
			try
			{
				int num;
				try
				{
					num = __instance.AmmoCount();
				}
				catch
				{
					return;
				}
				int value;
				bool flag = _lastAmmo.TryGetValue(__instance, out value);
				bool flag2;
				try
				{
					flag2 = __instance.isTriggerPressed;
				}
				catch
				{
					flag2 = true;
				}
				bool flag3 = flag && num < value && flag2;
				_lastAmmo[__instance] = num;
				if (GunFXSettings.DebugLog && (flag3 || !flag || num != value))
				{
					MelonLogger.Msg($"[QuickGunFX] ammo {(flag ? value : (-1))}->{num}  trigger={flag2}  fired={flag3}");
				}
				if (GunFXSettings.Enabled && flag3)
				{
					GunFX.OnShot(__instance);
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[QuickGunFX] shot fx failed: " + ex.Message);
			}
		}
	}
	public static class GunFX
	{
		private struct Pending
		{
			public Gun gun;

			public float emitTime;

			public int chamberN;

			public int barrelN;

			public int chamberRep;

			public int barrelRep;

			public int gen;
		}

		private struct Impact
		{
			public Vector3 pos;

			public Vector3 dir;

			public float emitTime;

			public int repeats;

			public int gen;
		}

		private static ParticleSystem? _chamber;

		private static ParticleSystem? _barrel;

		private static ParticleSystem? _impact;

		private static Material? _mat;

		private static Texture2D? _tex;

		private static readonly Dictionary<Gun, float> _heat = new Dictionary<Gun, float>();

		private static readonly List<Gun> _heatKeys = new List<Gun>();

		private static readonly List<Pending> _pending = new List<Pending>();

		private static readonly List<Impact> _impacts = new List<Impact>();

		private static int Buildup(int n, int gen)
		{
			if (!GunFXSettings.RepeatBuildup)
			{
				return n;
			}
			return Mathf.RoundToInt((float)n * (1f + (float)gen * 0.5f));
		}

		public static void OnShot(Gun gun)
		{
			if (GunFXSettings.RecoilEnabled)
			{
				ApplyRecoil(gun, gun.firePointTransform);
			}
			if (GunFXSettings.ImpactEnabled)
			{
				TryQueueImpact(gun);
			}
			float value;
			float num = (_heat.TryGetValue(gun, out value) ? value : 0f);
			int num2 = (GunFXSettings.ChamberEnabled ? Mathf.RoundToInt(GunFXSettings.ChamberAmount * (0.1f + 0.9f * num)) : 0);
			int num3 = (GunFXSettings.BarrelEnabled ? Mathf.RoundToInt(GunFXSettings.BarrelAmount * (0.15f + 0.85f * num)) : 0);
			_heat[gun] = Mathf.Min(1f, num + GunFXSettings.Buildup);
			if (num2 > 0 || num3 > 0)
			{
				_pending.Add(new Pending
				{
					gun = gun,
					emitTime = Time.time + Mathf.Max(0f, GunFXSettings.Delay),
					chamberN = num2,
					barrelN = num3,
					chamberRep = Mathf.Clamp(Mathf.RoundToInt(GunFXSettings.ChamberRepeat), 0, 50),
					barrelRep = Mathf.Clamp(Mathf.RoundToInt(GunFXSettings.BarrelRepeat), 0, 50)
				});
			}
		}

		public static void Update()
		{
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: 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)
			float time = Time.time;
			float deltaTime = Time.deltaTime;
			if (_heat.Count > 0)
			{
				_heatKeys.Clear();
				foreach (Gun key in _heat.Keys)
				{
					_heatKeys.Add(key);
				}
				float num = GunFXSettings.Fade * deltaTime;
				foreach (Gun heatKey in _heatKeys)
				{
					if ((Object)(object)heatKey == (Object)null)
					{
						_heat.Remove(heatKey);
						continue;
					}
					float num2 = _heat[heatKey] - num;
					if (num2 <= 0.01f)
					{
						_heat.Remove(heatKey);
					}
					else
					{
						_heat[heatKey] = num2;
					}
				}
			}
			for (int num3 = _pending.Count - 1; num3 >= 0; num3--)
			{
				if (!(time < _pending[num3].emitTime))
				{
					Pending p = _pending[num3];
					_pending.RemoveAt(num3);
					if (!((Object)(object)p.gun == (Object)null))
					{
						try
						{
							EnsureBuilt();
							EmitShot(p);
							if (p.chamberRep > 0 || p.barrelRep > 0)
							{
								_pending.Add(new Pending
								{
									gun = p.gun,
									emitTime = time + Mathf.Max(0.02f, GunFXSettings.RepeatDelay),
									chamberN = ((p.chamberRep > 0) ? p.chamberN : 0),
									barrelN = ((p.barrelRep > 0) ? p.barrelN : 0),
									chamberRep = Mathf.Max(0, p.chamberRep - 1),
									barrelRep = Mathf.Max(0, p.barrelRep - 1),
									gen = p.gen + 1
								});
							}
						}
						catch (Exception ex)
						{
							MelonLogger.Warning("[QuickGunFX] emit failed: " + ex.Message);
						}
					}
				}
			}
			for (int num4 = _impacts.Count - 1; num4 >= 0; num4--)
			{
				if (!(time < _impacts[num4].emitTime))
				{
					Impact impact = _impacts[num4];
					_impacts.RemoveAt(num4);
					try
					{
						EnsureBuilt();
						if ((Object)(object)_impact != (Object)null)
						{
							Emit(_impact, impact.pos, impact.dir, Buildup((int)GunFXSettings.ImpactAmount, impact.gen), GunFXSettings.ImpactSize, GunFXSettings.ImpactLifetime, GunFXSettings.ImpactOpacity, GunFXSettings.ImpactRise, GunFXSettings.ImpactRise * 0.3f);
						}
						if (impact.repeats > 0)
						{
							_impacts.Add(new Impact
							{
								pos = impact.pos,
								dir = impact.dir,
								emitTime = time + Mathf.Max(0.02f, GunFXSettings.RepeatDelay),
								repeats = impact.repeats - 1,
								gen = impact.gen + 1
							});
						}
					}
					catch (Exception ex2)
					{
						MelonLogger.Warning("[QuickGunFX] impact emit failed: " + ex2.Message);
					}
				}
			}
		}

		private static void TryQueueImpact(Gun gun)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			Transform firePointTransform = gun.firePointTransform;
			RaycastHit val = default(RaycastHit);
			if (!((Object)(object)firePointTransform == (Object)null) && Physics.Raycast(firePointTransform.position, firePointTransform.forward, ref val, GunFXSettings.ImpactRange, -1, (QueryTriggerInteraction)1))
			{
				Vector3 val2 = ((RaycastHit)(ref val)).normal * 0.6f + Vector3.up * 0.4f;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				float num = Mathf.Clamp(((RaycastHit)(ref val)).distance / 250f, 0f, 0.25f);
				_impacts.Add(new Impact
				{
					pos = ((RaycastHit)(ref val)).point + ((RaycastHit)(ref val)).normal * 0.02f,
					dir = normalized,
					emitTime = Time.time + num,
					repeats = Mathf.Clamp(Mathf.RoundToInt(GunFXSettings.ImpactRepeat), 0, 50)
				});
			}
		}

		private static void EmitShot(Pending p)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			Gun gun = p.gun;
			Transform firePointTransform = gun.firePointTransform;
			Transform shellSpawnTransform = gun.shellSpawnTransform;
			Transform val = (((Object)(object)firePointTransform != (Object)null) ? firePointTransform : ((Component)gun).transform);
			int num = Buildup(p.chamberN, p.gen);
			int num2 = Buildup(p.barrelN, p.gen);
			if (num > 0 && (Object)(object)_chamber != (Object)null)
			{
				Vector3 pos = (((Object)(object)shellSpawnTransform != (Object)null) ? shellSpawnTransform.position : (((Object)(object)firePointTransform != (Object)null) ? (firePointTransform.position - firePointTransform.forward * 0.12f + firePointTransform.up * 0.03f) : ((Component)gun).transform.position));
				Vector3 dir = val.right * GunFXSettings.ChamberDirSide + val.up * GunFXSettings.ChamberDirUp + val.forward * GunFXSettings.ChamberDirForward;
				if (((Vector3)(ref dir)).sqrMagnitude < 0.0001f)
				{
					dir = Vector3.up;
				}
				dir = ((Vector3)(ref dir)).normalized;
				Emit(_chamber, pos, dir, num, GunFXSettings.ChamberSize, GunFXSettings.ChamberLifetime, GunFXSettings.ChamberOpacity, GunFXSettings.ChamberRise, GunFXSettings.ChamberDrift);
			}
			if (num2 > 0 && (Object)(object)_barrel != (Object)null && (Object)(object)firePointTransform != (Object)null)
			{
				Emit(_barrel, firePointTransform.position, firePointTransform.forward, num2, GunFXSettings.BarrelSize, GunFXSettings.BarrelLifetime, GunFXSettings.BarrelOpacity, GunFXSettings.BarrelPush, GunFXSettings.ChamberDrift);
			}
		}

		private static void Emit(ParticleSystem ps, Vector3 pos, Vector3 dir, int count, float size, float life, float opacity, float rise, float drift)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			if (count > 0)
			{
				float gray = GunFXSettings.Gray;
				Color val = default(Color);
				((Color)(ref val))..ctor(gray, gray, gray, opacity);
				for (int i = 0; i < count; i++)
				{
					Vector3 val2 = Random.insideUnitSphere * drift;
					val2.y *= 0.3f;
					EmitParams val3 = default(EmitParams);
					((EmitParams)(ref val3)).position = pos + Random.insideUnitSphere * 0.008f;
					((EmitParams)(ref val3)).velocity = dir * (rise * Random.Range(0.8f, 1.2f)) + val2;
					((EmitParams)(ref val3)).startSize = size * Random.Range(0.75f, 1.25f);
					((EmitParams)(ref val3)).startLifetime = life * Random.Range(0.6f, 1.15f);
					((EmitParams)(ref val3)).startColor = Color32.op_Implicit(val);
					ps.Emit(val3, 1);
				}
			}
		}

		private static void ApplyRecoil(Gun gun, Transform? fire)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0079: 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)
			try
			{
				Rigidbody componentInParent = ((Component)gun).GetComponentInParent<Rigidbody>();
				if (!((Object)(object)componentInParent == (Object)null) && !componentInParent.isKinematic)
				{
					object obj = (((Object)(object)fire != (Object)null) ? ((object)fire) : ((object)((Component)gun).transform));
					Vector3 forward = ((Transform)obj).forward;
					Vector3 up = ((Transform)obj).up;
					Vector3 val = Random.insideUnitSphere * GunFXSettings.RecoilRandom;
					componentInParent.AddForce((-forward + val) * GunFXSettings.RecoilKick, (ForceMode)2);
					Vector3 val2 = Vector3.Cross(forward, up);
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					componentInParent.AddTorque(normalized * GunFXSettings.RecoilRise, (ForceMode)2);
				}
			}
			catch
			{
			}
		}

		private static void EnsureBuilt()
		{
			if ((Object)(object)_chamber == (Object)null)
			{
				_chamber = BuildSystem("[QuickGunFX] ChamberVapor");
			}
			if ((Object)(object)_barrel == (Object)null)
			{
				_barrel = BuildSystem("[QuickGunFX] MuzzleVapor");
			}
			if ((Object)(object)_impact == (Object)null)
			{
				_impact = BuildSystem("[QuickGunFX] ImpactSmoke");
			}
		}

		private static ParticleSystem BuildSystem(string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			Object.DontDestroyOnLoad((Object)(object)val);
			ParticleSystem obj = val.AddComponent<ParticleSystem>();
			MainModule main = obj.main;
			main.loop = true;
			main.playOnAwake = false;
			main.maxParticles = 800;
			main.simulationSpace = (ParticleSystemSimulationSpace)1;
			main.startSpeed = new MinMaxCurve(0f);
			main.startSize = new MinMaxCurve(0.03f);
			main.startLifetime = new MinMaxCurve(0.6f);
			main.gravityModifier = MinMaxCurve.op_Implicit(0f);
			main.startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			EmissionModule emission = obj.emission;
			emission.enabled = true;
			emission.rateOverTime = MinMaxCurve.op_Implicit(0f);
			ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
			colorOverLifetime.enabled = true;
			Gradient val2 = new Gradient();
			val2.SetKeys(new Il2CppStructArray<GradientColorKey>(2L)
			{
				[0] = new GradientColorKey(Color.white, 0f),
				[1] = new GradientColorKey(Color.white, 1f)
			}, new Il2CppStructArray<GradientAlphaKey>(3L)
			{
				[0] = new GradientAlphaKey(0f, 0f),
				[1] = new GradientAlphaKey(1f, 0.25f),
				[2] = new GradientAlphaKey(0f, 1f)
			});
			colorOverLifetime.color = new MinMaxGradient(val2);
			SizeOverLifetimeModule sizeOverLifetime = obj.sizeOverLifetime;
			sizeOverLifetime.enabled = true;
			AnimationCurve val3 = new AnimationCurve();
			val3.AddKey(0f, 0.7f);
			val3.AddKey(0.3f, 1f);
			val3.AddKey(1f, 1.6f);
			sizeOverLifetime.size = new MinMaxCurve(1f, val3);
			RotationOverLifetimeModule rotationOverLifetime = obj.rotationOverLifetime;
			rotationOverLifetime.enabled = true;
			rotationOverLifetime.z = new MinMaxCurve(-0.6f, 0.6f);
			NoiseModule noise = obj.noise;
			noise.enabled = true;
			noise.strength = new MinMaxCurve(0.04f);
			noise.frequency = 0.8f;
			noise.scrollSpeed = new MinMaxCurve(0.25f);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				((Renderer)component).material = SmokeMaterial();
				component.renderMode = (ParticleSystemRenderMode)0;
				component.sortMode = (ParticleSystemSortMode)1;
				((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)component).receiveShadows = false;
			}
			obj.Play();
			return obj;
		}

		private static Material SmokeMaterial()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if ((Object)(object)_mat != (Object)null)
			{
				return _mat;
			}
			_mat = new Material(Shader.Find("Sprites/Default"));
			_mat.mainTexture = (Texture)(object)SmokeTexture();
			return _mat;
		}

		private static Texture2D SmokeTexture()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_tex != (Object)null)
			{
				return _tex;
			}
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			float num = Random.value * 100f;
			float num2 = Random.value * 100f;
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num3 = ((float)j + 0.5f) / 128f - 0.5f;
					float num4 = ((float)i + 0.5f) / 128f - 0.5f;
					float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4) * 2f;
					float num6 = Mathf.Clamp01(1f - num5);
					num6 = num6 * num6 * num6;
					float num7 = 0.85f + 0.15f * Mathf.PerlinNoise((float)j * 0.03f + num, (float)i * 0.03f + num2);
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num6 * num7));
				}
			}
			val.Apply();
			_tex = val;
			return val;
		}
	}
	public class GunFXMod : MelonMod
	{
		public override void OnInitializeMelon()
		{
			GunFXSettings.Initialize();
			QuickModsTheme.Initialize();
			SetupMenu();
			((MelonBase)this).LoggerInstance.Msg("QuickGunFX loaded!");
		}

		public override void OnUpdate()
		{
			GunFX.Update();
		}

		private static Page GetOrCreateQuickModsPage()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			object? data = AppDomain.CurrentDomain.GetData("QuickMods.RootPage");
			Page val = (Page)((data is Page) ? data : null);
			if (val != null)
			{
				return val;
			}
			Page val2 = Page.Root.CreatePage("Quick Mods", new Color(0.35f, 0.27f, 0.9f), 0, true);
			AppDomain.CurrentDomain.SetData("QuickMods.RootPage", val2);
			return val2;
		}

		private static void SetupMenu()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: 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_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: 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_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0706: Unknown result type (might be due to invalid IL or missing references)
			//IL_0759: Unknown result type (might be due to invalid IL or missing references)
			//IL_076b: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0828: Unknown result type (might be due to invalid IL or missing references)
			//IL_086c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0937: Unknown result type (might be due to invalid IL or missing references)
			//IL_0989: Unknown result type (might be due to invalid IL or missing references)
			//IL_099b: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a14: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a57: Unknown result type (might be due to invalid IL or missing references)
			Page orCreateQuickModsPage = GetOrCreateQuickModsPage();
			QuickModsTheme.BuildMenu(orCreateQuickModsPage);
			Page obj = orCreateQuickModsPage.CreatePage("QuickGunFX", new Color(0.82f, 0.82f, 0.88f), 0, true);
			obj.CreateBool("Enabled", Color.white, GunFXSettings.Enabled, (Action<bool>)delegate(bool v)
			{
				GunFXSettings.Enabled = v;
			});
			obj.CreateFloat("Delay (s)", Color.white, GunFXSettings.Delay, 0.02f, 0f, 0.5f, (Action<float>)delegate(float v)
			{
				GunFXSettings.Delay = v;
			});
			obj.CreateFloat("Buildup / Shot", Color.white, GunFXSettings.Buildup, 0.02f, 0.02f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.Buildup = v;
			});
			obj.CreateFloat("Fade / Sec", Color.white, GunFXSettings.Fade, 0.1f, 0.1f, 6f, (Action<float>)delegate(float v)
			{
				GunFXSettings.Fade = v;
			});
			obj.CreateFloat("Repeat Delay (s)", Color.white, GunFXSettings.RepeatDelay, 0.02f, 0.02f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.RepeatDelay = v;
			});
			obj.CreateBool("Repeat Buildup", Color.white, GunFXSettings.RepeatBuildup, (Action<bool>)delegate(bool v)
			{
				GunFXSettings.RepeatBuildup = v;
			});
			obj.CreateBool("Debug Logging", new Color(0.6f, 0.6f, 0.6f), GunFXSettings.DebugLog, (Action<bool>)delegate(bool v)
			{
				GunFXSettings.DebugLog = v;
			});
			Page obj2 = obj.CreatePage("Chamber Vapor", new Color(0.75f, 0.78f, 0.85f), 0, true);
			obj2.CreateBool("Enabled", Color.white, GunFXSettings.ChamberEnabled, (Action<bool>)delegate(bool v)
			{
				GunFXSettings.ChamberEnabled = v;
			});
			obj2.CreateFloat("Amount / Shot (max)", Color.white, GunFXSettings.ChamberAmount, 1f, 0f, 20f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberAmount = v;
			});
			obj2.CreateFloat("Size", Color.white, GunFXSettings.ChamberSize, 0.005f, 0.01f, 0.15f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberSize = v;
			});
			obj2.CreateFloat("Lifetime (s)", Color.white, GunFXSettings.ChamberLifetime, 0.05f, 0.1f, 2f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberLifetime = v;
			});
			obj2.CreateFloat("Opacity", Color.white, GunFXSettings.ChamberOpacity, 0.02f, 0f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberOpacity = v;
			});
			obj2.CreateFloat("Rise Speed", Color.white, GunFXSettings.ChamberRise, 0.05f, 0f, 3f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberRise = v;
			});
			obj2.CreateFloat("Drift", Color.white, GunFXSettings.ChamberDrift, 0.02f, 0f, 0.6f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberDrift = v;
			});
			obj2.CreateFloat("Repeat x", Color.white, GunFXSettings.ChamberRepeat, 1f, 0f, 50f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberRepeat = v;
			});
			obj2.CreateFloat("Gray (1=white)", Color.white, GunFXSettings.Gray, 0.02f, 0f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.Gray = v;
			});
			obj2.CreateFloat("Dir Side (+R/-L)", new Color(1f, 0.8f, 0.3f), GunFXSettings.ChamberDirSide, 0.1f, -1f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberDirSide = v;
			});
			obj2.CreateFloat("Dir Up", new Color(1f, 0.8f, 0.3f), GunFXSettings.ChamberDirUp, 0.1f, -1f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberDirUp = v;
			});
			obj2.CreateFloat("Dir Forward", new Color(1f, 0.8f, 0.3f), GunFXSettings.ChamberDirForward, 0.1f, -1f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ChamberDirForward = v;
			});
			Page obj3 = obj.CreatePage("Muzzle Vapor (optional)", new Color(0.7f, 0.7f, 0.75f), 0, true);
			obj3.CreateBool("Enabled", Color.white, GunFXSettings.BarrelEnabled, (Action<bool>)delegate(bool v)
			{
				GunFXSettings.BarrelEnabled = v;
			});
			obj3.CreateFloat("Amount / Shot (max)", Color.white, GunFXSettings.BarrelAmount, 1f, 0f, 20f, (Action<float>)delegate(float v)
			{
				GunFXSettings.BarrelAmount = v;
			});
			obj3.CreateFloat("Size", Color.white, GunFXSettings.BarrelSize, 0.005f, 0.01f, 0.15f, (Action<float>)delegate(float v)
			{
				GunFXSettings.BarrelSize = v;
			});
			obj3.CreateFloat("Lifetime (s)", Color.white, GunFXSettings.BarrelLifetime, 0.05f, 0.1f, 2f, (Action<float>)delegate(float v)
			{
				GunFXSettings.BarrelLifetime = v;
			});
			obj3.CreateFloat("Opacity", Color.white, GunFXSettings.BarrelOpacity, 0.02f, 0f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.BarrelOpacity = v;
			});
			obj3.CreateFloat("Forward Push", Color.white, GunFXSettings.BarrelPush, 0.05f, 0f, 2f, (Action<float>)delegate(float v)
			{
				GunFXSettings.BarrelPush = v;
			});
			obj3.CreateFloat("Repeat x", Color.white, GunFXSettings.BarrelRepeat, 1f, 0f, 50f, (Action<float>)delegate(float v)
			{
				GunFXSettings.BarrelRepeat = v;
			});
			Page obj4 = obj.CreatePage("Bullet-Hole Smoke", new Color(0.8f, 0.75f, 0.7f), 0, true);
			obj4.CreateBool("Enabled", Color.white, GunFXSettings.ImpactEnabled, (Action<bool>)delegate(bool v)
			{
				GunFXSettings.ImpactEnabled = v;
			});
			obj4.CreateFloat("Amount / Hit", Color.white, GunFXSettings.ImpactAmount, 1f, 0f, 20f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ImpactAmount = v;
			});
			obj4.CreateFloat("Size", Color.white, GunFXSettings.ImpactSize, 0.005f, 0.01f, 0.15f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ImpactSize = v;
			});
			obj4.CreateFloat("Lifetime (s)", Color.white, GunFXSettings.ImpactLifetime, 0.05f, 0.1f, 2f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ImpactLifetime = v;
			});
			obj4.CreateFloat("Opacity", Color.white, GunFXSettings.ImpactOpacity, 0.02f, 0f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ImpactOpacity = v;
			});
			obj4.CreateFloat("Rise Speed", Color.white, GunFXSettings.ImpactRise, 0.05f, 0f, 3f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ImpactRise = v;
			});
			obj4.CreateFloat("Range (m)", Color.white, GunFXSettings.ImpactRange, 10f, 10f, 300f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ImpactRange = v;
			});
			obj4.CreateFloat("Repeat x", Color.white, GunFXSettings.ImpactRepeat, 1f, 0f, 50f, (Action<float>)delegate(float v)
			{
				GunFXSettings.ImpactRepeat = v;
			});
			Page obj5 = obj.CreatePage("Recoil", new Color(1f, 0.4f, 0.2f), 0, true);
			obj5.CreateBool("Enabled", Color.white, GunFXSettings.RecoilEnabled, (Action<bool>)delegate(bool v)
			{
				GunFXSettings.RecoilEnabled = v;
			});
			obj5.CreateFloat("Kick", Color.white, GunFXSettings.RecoilKick, 0.1f, 0f, 10f, (Action<float>)delegate(float v)
			{
				GunFXSettings.RecoilKick = v;
			});
			obj5.CreateFloat("Muzzle Rise", Color.white, GunFXSettings.RecoilRise, 0.1f, 0f, 15f, (Action<float>)delegate(float v)
			{
				GunFXSettings.RecoilRise = v;
			});
			obj5.CreateFloat("Randomness", Color.white, GunFXSettings.RecoilRandom, 0.02f, 0f, 1f, (Action<float>)delegate(float v)
			{
				GunFXSettings.RecoilRandom = v;
			});
		}
	}
	public static class GunFXSettings
	{
		private const int ConfigVersion = 9;

		private const bool DEF_Enabled = true;

		private const bool DEF_DebugLog = false;

		private const float DEF_Delay = 0.05f;

		private const float DEF_Buildup = 0.34f;

		private const float DEF_Fade = 1.6f;

		private const float DEF_RepeatDelay = 0.12f;

		private const bool DEF_RepeatBuildup = false;

		private const bool DEF_ChamberEnabled = true;

		private const float DEF_ChamberAmount = 6f;

		private const float DEF_ChamberSize = 0.03f;

		private const float DEF_ChamberLifetime = 0.6f;

		private const float DEF_ChamberOpacity = 0.25f;

		private const float DEF_ChamberRise = 0.6f;

		private const float DEF_ChamberDrift = 0.12f;

		private const float DEF_ChamberRepeat = 0f;

		private const float DEF_ChamberDirSide = 0f;

		private const float DEF_ChamberDirUp = 1f;

		private const float DEF_ChamberDirForward = 0f;

		private const float DEF_Gray = 0.85f;

		private const bool DEF_BarrelEnabled = false;

		private const float DEF_BarrelAmount = 5f;

		private const float DEF_BarrelSize = 0.04f;

		private const float DEF_BarrelLifetime = 0.7f;

		private const float DEF_BarrelOpacity = 0.25f;

		private const float DEF_BarrelPush = 0.5f;

		private const float DEF_BarrelRepeat = 0f;

		private const bool DEF_ImpactEnabled = true;

		private const float DEF_ImpactAmount = 5f;

		private const float DEF_ImpactSize = 0.025f;

		private const float DEF_ImpactLifetime = 0.7f;

		private const float DEF_ImpactOpacity = 0.3f;

		private const float DEF_ImpactRise = 0.45f;

		private const float DEF_ImpactRange = 120f;

		private const float DEF_ImpactRepeat = 0f;

		private const bool DEF_RecoilEnabled = true;

		private const float DEF_RecoilKick = 2f;

		private const float DEF_RecoilRise = 2.5f;

		private const float DEF_RecoilRandom = 0.2f;

		private static MelonPreferences_Category _cat;

		private static MelonPreferences_Entry<int> _ver;

		private static MelonPreferences_Entry<bool> _enabled;

		private static MelonPreferences_Entry<bool> _debugLog;

		private static MelonPreferences_Entry<float> _delay;

		private static MelonPreferences_Entry<float> _buildup;

		private static MelonPreferences_Entry<float> _fade;

		private static MelonPreferences_Entry<float> _repeatDelay;

		private static MelonPreferences_Entry<bool> _repeatBuildup;

		private static MelonPreferences_Entry<bool> _chamberEnabled;

		private static MelonPreferences_Entry<float> _chamberAmount;

		private static MelonPreferences_Entry<float> _chamberSize;

		private static MelonPreferences_Entry<float> _chamberLifetime;

		private static MelonPreferences_Entry<float> _chamberOpacity;

		private static MelonPreferences_Entry<float> _chamberRise;

		private static MelonPreferences_Entry<float> _chamberDrift;

		private static MelonPreferences_Entry<float> _chamberRepeat;

		private static MelonPreferences_Entry<float> _chamberDirSide;

		private static MelonPreferences_Entry<float> _chamberDirUp;

		private static MelonPreferences_Entry<float> _chamberDirForward;

		private static MelonPreferences_Entry<float> _gray;

		private static MelonPreferences_Entry<bool> _barrelEnabled;

		private static MelonPreferences_Entry<float> _barrelAmount;

		private static MelonPreferences_Entry<float> _barrelSize;

		private static MelonPreferences_Entry<float> _barrelLifetime;

		private static MelonPreferences_Entry<float> _barrelOpacity;

		private static MelonPreferences_Entry<float> _barrelPush;

		private static MelonPreferences_Entry<float> _barrelRepeat;

		private static MelonPreferences_Entry<bool> _impactEnabled;

		private static MelonPreferences_Entry<float> _impactAmount;

		private static MelonPreferences_Entry<float> _impactSize;

		private static MelonPreferences_Entry<float> _impactLifetime;

		private static MelonPreferences_Entry<float> _impactOpacity;

		private static MelonPreferences_Entry<float> _impactRise;

		private static MelonPreferences_Entry<float> _impactRange;

		private static MelonPreferences_Entry<float> _impactRepeat;

		private static MelonPreferences_Entry<bool> _recoilEnabled;

		private static MelonPreferences_Entry<float> _recoilKick;

		private static MelonPreferences_Entry<float> _recoilRise;

		private static MelonPreferences_Entry<float> _recoilRandom;

		public static bool Enabled
		{
			get
			{
				return _enabled.Value;
			}
			set
			{
				_enabled.Value = value;
				Save();
			}
		}

		public static bool DebugLog
		{
			get
			{
				return _debugLog.Value;
			}
			set
			{
				_debugLog.Value = value;
				Save();
			}
		}

		public static float Delay
		{
			get
			{
				return _delay.Value;
			}
			set
			{
				_delay.Value = value;
				Save();
			}
		}

		public static float Buildup
		{
			get
			{
				return _buildup.Value;
			}
			set
			{
				_buildup.Value = value;
				Save();
			}
		}

		public static float Fade
		{
			get
			{
				return _fade.Value;
			}
			set
			{
				_fade.Value = value;
				Save();
			}
		}

		public static float RepeatDelay
		{
			get
			{
				return _repeatDelay.Value;
			}
			set
			{
				_repeatDelay.Value = value;
				Save();
			}
		}

		public static bool RepeatBuildup
		{
			get
			{
				return _repeatBuildup.Value;
			}
			set
			{
				_repeatBuildup.Value = value;
				Save();
			}
		}

		public static bool ChamberEnabled
		{
			get
			{
				return _chamberEnabled.Value;
			}
			set
			{
				_chamberEnabled.Value = value;
				Save();
			}
		}

		public static float ChamberAmount
		{
			get
			{
				return _chamberAmount.Value;
			}
			set
			{
				_chamberAmount.Value = value;
				Save();
			}
		}

		public static float ChamberSize
		{
			get
			{
				return _chamberSize.Value;
			}
			set
			{
				_chamberSize.Value = value;
				Save();
			}
		}

		public static float ChamberLifetime
		{
			get
			{
				return _chamberLifetime.Value;
			}
			set
			{
				_chamberLifetime.Value = value;
				Save();
			}
		}

		public static float ChamberOpacity
		{
			get
			{
				return _chamberOpacity.Value;
			}
			set
			{
				_chamberOpacity.Value = value;
				Save();
			}
		}

		public static float ChamberRise
		{
			get
			{
				return _chamberRise.Value;
			}
			set
			{
				_chamberRise.Value = value;
				Save();
			}
		}

		public static float ChamberDrift
		{
			get
			{
				return _chamberDrift.Value;
			}
			set
			{
				_chamberDrift.Value = value;
				Save();
			}
		}

		public static float ChamberRepeat
		{
			get
			{
				return _chamberRepeat.Value;
			}
			set
			{
				_chamberRepeat.Value = value;
				Save();
			}
		}

		public static float ChamberDirSide
		{
			get
			{
				return _chamberDirSide.Value;
			}
			set
			{
				_chamberDirSide.Value = value;
				Save();
			}
		}

		public static float ChamberDirUp
		{
			get
			{
				return _chamberDirUp.Value;
			}
			set
			{
				_chamberDirUp.Value = value;
				Save();
			}
		}

		public static float ChamberDirForward
		{
			get
			{
				return _chamberDirForward.Value;
			}
			set
			{
				_chamberDirForward.Value = value;
				Save();
			}
		}

		public static float Gray
		{
			get
			{
				return _gray.Value;
			}
			set
			{
				_gray.Value = value;
				Save();
			}
		}

		public static bool BarrelEnabled
		{
			get
			{
				return _barrelEnabled.Value;
			}
			set
			{
				_barrelEnabled.Value = value;
				Save();
			}
		}

		public static float BarrelAmount
		{
			get
			{
				return _barrelAmount.Value;
			}
			set
			{
				_barrelAmount.Value = value;
				Save();
			}
		}

		public static float BarrelSize
		{
			get
			{
				return _barrelSize.Value;
			}
			set
			{
				_barrelSize.Value = value;
				Save();
			}
		}

		public static float BarrelLifetime
		{
			get
			{
				return _barrelLifetime.Value;
			}
			set
			{
				_barrelLifetime.Value = value;
				Save();
			}
		}

		public static float BarrelOpacity
		{
			get
			{
				return _barrelOpacity.Value;
			}
			set
			{
				_barrelOpacity.Value = value;
				Save();
			}
		}

		public static float BarrelPush
		{
			get
			{
				return _barrelPush.Value;
			}
			set
			{
				_barrelPush.Value = value;
				Save();
			}
		}

		public static float BarrelRepeat
		{
			get
			{
				return _barrelRepeat.Value;
			}
			set
			{
				_barrelRepeat.Value = value;
				Save();
			}
		}

		public static bool ImpactEnabled
		{
			get
			{
				return _impactEnabled.Value;
			}
			set
			{
				_impactEnabled.Value = value;
				Save();
			}
		}

		public static float ImpactAmount
		{
			get
			{
				return _impactAmount.Value;
			}
			set
			{
				_impactAmount.Value = value;
				Save();
			}
		}

		public static float ImpactSize
		{
			get
			{
				return _impactSize.Value;
			}
			set
			{
				_impactSize.Value = value;
				Save();
			}
		}

		public static float ImpactLifetime
		{
			get
			{
				return _impactLifetime.Value;
			}
			set
			{
				_impactLifetime.Value = value;
				Save();
			}
		}

		public static float ImpactOpacity
		{
			get
			{
				return _impactOpacity.Value;
			}
			set
			{
				_impactOpacity.Value = value;
				Save();
			}
		}

		public static float ImpactRise
		{
			get
			{
				return _impactRise.Value;
			}
			set
			{
				_impactRise.Value = value;
				Save();
			}
		}

		public static float ImpactRange
		{
			get
			{
				return _impactRange.Value;
			}
			set
			{
				_impactRange.Value = value;
				Save();
			}
		}

		public static float ImpactRepeat
		{
			get
			{
				return _impactRepeat.Value;
			}
			set
			{
				_impactRepeat.Value = value;
				Save();
			}
		}

		public static bool RecoilEnabled
		{
			get
			{
				return _recoilEnabled.Value;
			}
			set
			{
				_recoilEnabled.Value = value;
				Save();
			}
		}

		public static float RecoilKick
		{
			get
			{
				return _recoilKick.Value;
			}
			set
			{
				_recoilKick.Value = value;
				Save();
			}
		}

		public static float RecoilRise
		{
			get
			{
				return _recoilRise.Value;
			}
			set
			{
				_recoilRise.Value = value;
				Save();
			}
		}

		public static float RecoilRandom
		{
			get
			{
				return _recoilRandom.Value;
			}
			set
			{
				_recoilRandom.Value = value;
				Save();
			}
		}

		public static void Initialize()
		{
			_cat = MelonPreferences.CreateCategory("QuickGunFX");
			_ver = _cat.CreateEntry<int>("ConfigVersion", 0, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_enabled = _cat.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_debugLog = _cat.CreateEntry<bool>("DebugLog", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_delay = _cat.CreateEntry<float>("Delay", 0.05f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_buildup = _cat.CreateEntry<float>("Buildup", 0.34f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_fade = _cat.CreateEntry<float>("Fade", 1.6f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_repeatDelay = _cat.CreateEntry<float>("RepeatDelay", 0.12f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_repeatBuildup = _cat.CreateEntry<bool>("RepeatBuildup", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberEnabled = _cat.CreateEntry<bool>("ChamberEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberAmount = _cat.CreateEntry<float>("ChamberAmount", 6f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberSize = _cat.CreateEntry<float>("ChamberSize", 0.03f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberLifetime = _cat.CreateEntry<float>("ChamberLifetime", 0.6f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberOpacity = _cat.CreateEntry<float>("ChamberOpacity", 0.25f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberRise = _cat.CreateEntry<float>("ChamberRise", 0.6f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberDrift = _cat.CreateEntry<float>("ChamberDrift", 0.12f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberRepeat = _cat.CreateEntry<float>("ChamberRepeat", 0f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberDirSide = _cat.CreateEntry<float>("ChamberDirSide", 0f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberDirUp = _cat.CreateEntry<float>("ChamberDirUp", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_chamberDirForward = _cat.CreateEntry<float>("ChamberDirForward", 0f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_gray = _cat.CreateEntry<float>("Gray", 0.85f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_barrelEnabled = _cat.CreateEntry<bool>("BarrelEnabled", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_barrelAmount = _cat.CreateEntry<float>("BarrelAmount", 5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_barrelSize = _cat.CreateEntry<float>("BarrelSize", 0.04f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_barrelLifetime = _cat.CreateEntry<float>("BarrelLifetime", 0.7f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_barrelOpacity = _cat.CreateEntry<float>("BarrelOpacity", 0.25f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_barrelPush = _cat.CreateEntry<float>("BarrelPush", 0.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_barrelRepeat = _cat.CreateEntry<float>("BarrelRepeat", 0f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_impactEnabled = _cat.CreateEntry<bool>("ImpactEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_impactAmount = _cat.CreateEntry<float>("ImpactAmount", 5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_impactSize = _cat.CreateEntry<float>("ImpactSize", 0.025f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_impactLifetime = _cat.CreateEntry<float>("ImpactLifetime", 0.7f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_impactOpacity = _cat.CreateEntry<float>("ImpactOpacity", 0.3f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_impactRise = _cat.CreateEntry<float>("ImpactRise", 0.45f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_impactRange = _cat.CreateEntry<float>("ImpactRange", 120f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_impactRepeat = _cat.CreateEntry<float>("ImpactRepeat", 0f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_recoilEnabled = _cat.CreateEntry<bool>("RecoilEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_recoilKick = _cat.CreateEntry<float>("RecoilKick", 2f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_recoilRise = _cat.CreateEntry<float>("RecoilRise", 2.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_recoilRandom = _cat.CreateEntry<float>("RecoilRandom", 0.2f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			if (_ver.Value < 9)
			{
				_debugLog.Value = false;
				_delay.Value = 0.05f;
				_buildup.Value = 0.34f;
				_fade.Value = 1.6f;
				_repeatDelay.Value = 0.12f;
				_repeatBuildup.Value = false;
				_chamberEnabled.Value = true;
				_chamberAmount.Value = 6f;
				_chamberSize.Value = 0.03f;
				_chamberLifetime.Value = 0.6f;
				_chamberOpacity.Value = 0.25f;
				_chamberRise.Value = 0.6f;
				_chamberDrift.Value = 0.12f;
				_chamberRepeat.Value = 0f;
				_chamberDirSide.Value = 0f;
				_chamberDirUp.Value = 1f;
				_chamberDirForward.Value = 0f;
				_gray.Value = 0.85f;
				_barrelEnabled.Value = false;
				_barrelAmount.Value = 5f;
				_barrelSize.Value = 0.04f;
				_barrelLifetime.Value = 0.7f;
				_barrelOpacity.Value = 0.25f;
				_barrelPush.Value = 0.5f;
				_barrelRepeat.Value = 0f;
				_impactEnabled.Value = true;
				_impactAmount.Value = 5f;
				_impactSize.Value = 0.025f;
				_impactLifetime.Value = 0.7f;
				_impactOpacity.Value = 0.3f;
				_impactRise.Value = 0.45f;
				_impactRange.Value = 120f;
				_impactRepeat.Value = 0f;
				_recoilKick.Value = 2f;
				_recoilRise.Value = 2.5f;
				_recoilRandom.Value = 0.2f;
				_ver.Value = 9;
				_cat.SaveToFile(false);
			}
		}

		private static void Save()
		{
			_cat.SaveToFile(false);
		}
	}
	public static class QuickModsTheme
	{
		private const string ShareKey = "QuickMods.GlobalTheme";

		private const string MenuKey = "QuickMods.GlobalThemeMenuBuilt";

		private static MelonPreferences_Category _cat;

		private static MelonPreferences_Entry<bool> _useGlobal;

		private static MelonPreferences_Entry<float> _hue;

		private static MelonPreferences_Entry<float> _sat;

		private static MelonPreferences_Entry<bool> _forceQB;

		private static MelonPreferences_Entry<bool> _rainbow;

		private static MelonPreferences_Entry<float> _rainbowSpeed;

		public static bool UseGlobalTheme
		{
			get
			{
				return _useGlobal.Value;
			}
			set
			{
				_useGlobal.Value = value;
				Save();
			}
		}

		public static float Hue
		{
			get
			{
				return _hue.Value;
			}
			set
			{
				_hue.Value = value;
				Save();
			}
		}

		public static float Saturation
		{
			get
			{
				return _sat.Value;
			}
			set
			{
				_sat.Value = value;
				Save();
			}
		}

		public static bool ForceQuickBeatsSync
		{
			get
			{
				return _forceQB.Value;
			}
			set
			{
				_forceQB.Value = value;
				Save();
			}
		}

		public static Color GlobalColor => Color.HSVToRGB(Hue / 360f, Saturation, 1f);

		public static bool RainbowMode
		{
			get
			{
				return _rainbow.Value;
			}
			set
			{
				_rainbow.Value = value;
				Save();
			}
		}

		public static float RainbowSpeed
		{
			get
			{
				return _rainbowSpeed.Value;
			}
			set
			{
				_rainbowSpeed.Value = value;
				Save();
			}
		}

		public static Color RainbowColor => Color.HSVToRGB(Time.time * RainbowSpeed % 1f, 0.85f, 1f);

		public static Color ResolveAccent(Color modDefault, bool modThemeToSong, Func<Color?> qbGetter)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			if (RainbowMode)
			{
				return RainbowColor;
			}
			if (ForceQuickBeatsSync)
			{
				Color? val = SafeGet(qbGetter);
				if (val.HasValue)
				{
					return val.Value;
				}
			}
			if (UseGlobalTheme)
			{
				return GlobalColor;
			}
			if (modThemeToSong)
			{
				Color? val2 = SafeGet(qbGetter);
				if (val2.HasValue)
				{
					return val2.Value;
				}
			}
			return modDefault;
		}

		private static Color? SafeGet(Func<Color?> getter)
		{
			try
			{
				return getter?.Invoke();
			}
			catch
			{
				return null;
			}
		}

		public static void Initialize()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (AppDomain.CurrentDomain.GetData("QuickMods.GlobalTheme") is object[] array)
			{
				_cat = (MelonPreferences_Category)array[0];
				_useGlobal = (MelonPreferences_Entry<bool>)array[1];
				_hue = (MelonPreferences_Entry<float>)array[2];
				_sat = (MelonPreferences_Entry<float>)array[3];
				_forceQB = (MelonPreferences_Entry<bool>)array[4];
				_rainbow = (MelonPreferences_Entry<bool>)array[5];
				_rainbowSpeed = (MelonPreferences_Entry<float>)array[6];
				return;
			}
			_cat = MelonPreferences.CreateCategory("QuickModsTheme");
			_useGlobal = _cat.CreateEntry<bool>("UseGlobalTheme", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_hue = _cat.CreateEntry<float>("Hue", 200f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_sat = _cat.CreateEntry<float>("Saturation", 0.72f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_forceQB = _cat.CreateEntry<bool>("ForceQuickBeatsSync", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_rainbow = _cat.CreateEntry<bool>("RainbowMode", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_rainbowSpeed = _cat.CreateEntry<float>("RainbowSpeed", 0.15f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			AppDomain.CurrentDomain.SetData("QuickMods.GlobalTheme", new object[7] { _cat, _useGlobal, _hue, _sat, _forceQB, _rainbow, _rainbowSpeed });
		}

		public static void BuildMenu(Page rootPage)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			object data = AppDomain.CurrentDomain.GetData("QuickMods.GlobalThemeMenuBuilt");
			bool flag = default(bool);
			int num;
			if (data is bool)
			{
				flag = (bool)data;
				num = 1;
			}
			else
			{
				num = 0;
			}
			if (((uint)num & (flag ? 1u : 0u)) == 0)
			{
				AppDomain.CurrentDomain.SetData("QuickMods.GlobalThemeMenuBuilt", true);
				Page obj = rootPage.CreatePage("Global Theme", new Color(1f, 0.55f, 0.85f), 0, true);
				obj.CreateBool("Use Global Theme", Color.white, UseGlobalTheme, (Action<bool>)delegate(bool v)
				{
					UseGlobalTheme = v;
				});
				obj.CreateFloat("Hue", Color.white, Hue, 5f, 0f, 360f, (Action<float>)delegate(float v)
				{
					Hue = v;
				});
				obj.CreateFloat("Saturation", Color.white, Saturation, 0.05f, 0.1f, 1f, (Action<float>)delegate(float v)
				{
					Saturation = v;
				});
				obj.CreateBool("Force QuickBeats (All Mods)", Color.magenta, ForceQuickBeatsSync, (Action<bool>)delegate(bool v)
				{
					ForceQuickBeatsSync = v;
				});
				obj.CreateBool("Rainbow Mode (All Mods)", Color.red, RainbowMode, (Action<bool>)delegate(bool v)
				{
					RainbowMode = v;
				});
				obj.CreateFloat("Rainbow Speed", Color.red, RainbowSpeed, 0.02f, 0.02f, 1f, (Action<float>)delegate(float v)
				{
					RainbowSpeed = v;
				});
			}
		}

		private static void Save()
		{
			_cat.SaveToFile(false);
		}
	}
}