Decompiled source of WeaponEditor v1.0.0

WeaponEditor.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WeaponEditor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeaponEditor")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("db735d8f-e8cb-41bd-8587-017047ecb2be")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("test.weaponeditor.menu", "WeaponEditor", "1.3.27")]
public class WeaponEditor : BaseUnityPlugin
{
	[Serializable]
	private class WeaponSettings
	{
		public string colorHex = "FFFFFF";

		public bool applyGlobalColor = false;

		public List<WeaponEditorPartColor> partColors = new List<WeaponEditorPartColor>();

		public List<WeaponEditorPartVisibility> partVisibilities = new List<WeaponEditorPartVisibility>();

		public List<WeaponEditorModelPart> modelParts = new List<WeaponEditorModelPart>();

		public float damage = 80f;

		public float cooldown = 1f;

		public float meleeForce = 100f;

		public bool overrideMeleeForce = false;

		public float projectileDamage = 80f;

		public float projectileSpeed = 30f;

		public float projectileGravity = 15f;

		public float projectileDrag = 0f;

		public bool applyProjectileSettings = false;

		public string originalProjectileName = string.Empty;

		public string replacementProjectileName = string.Empty;

		public string projectileColorHex = "FFFFFF";

		public float projectileColorBrightness = 1f;

		public bool applyProjectileColor = false;

		public bool projectileModelInvisible = false;

		public bool projectileParticleInvisible = false;

		public int projectileCount = 1;

		public float projectileSize = 1f;

		public string replacementEffectName = string.Empty;

		public string replacementExplosionName = string.Empty;

		public string effectColorHex = "FFFFFF";

		public float effectColorBrightness = 1f;

		public bool applyEffectColor = false;

		public bool effectModeAlways = false;

		public int invisibleMode = 0;

		public float weaponScale = 1f;

		public float effectScale = 1f;

		public int schemaVersion = 13;
	}

	private class ColorPartChoice
	{
		public Renderer renderer;

		public string rendererPath;

		public int materialIndex;

		public string colorProperty;

		public string displayName;
	}

	private class ProjectileReference
	{
		public Component owner;

		public FieldInfo field;

		public GameObject projectile;
	}

	[Serializable]
	private class SavedWeaponRecord
	{
		public string displayName;

		public string sourceName;

		public int id;

		public int modId;

		public WeaponSettings settings = new WeaponSettings();
	}

	[Serializable]
	private class WeaponSettingsPreset
	{
		public string name = string.Empty;

		public WeaponSettings settings = new WeaponSettings();
	}

	[Serializable]
	private class WeaponDraftRecord
	{
		public string key = string.Empty;

		public WeaponSettings settings = new WeaponSettings();

		public Vector3 rootPositionOffset = Vector3.zero;

		public Vector3 rootEulerAngles = Vector3.zero;

		public Vector3 rootLocalScale = Vector3.one;

		public bool hasRootTransform = false;
	}

	private static WeaponEditor Instance;

	private static Sprite uiRoundedCornerSprite;

	private Harmony harmony;

	private Coroutine savedWeaponRegistrationRoutine;

	private const int PreviewLayer = 30;

	private const string MenuButtonName = "WeaponEditorButton";

	private GameObject editorCanvas;

	private GameObject previewStage;

	private GameObject previewModel;

	private GameObject previewCameraObject;

	private GameObject previewLightObject;

	private Camera previewCamera;

	private RenderTexture previewTexture;

	private RawImage previewImage;

	private int previewTextureWidth;

	private int previewTextureHeight;

	private Text statusText;

	private Text selectedModelText;

	private ScrollRect weaponListScroll;

	private Scrollbar weaponListScrollbar;

	private Transform weaponListContent;

	private RectTransform weaponListContentRect;

	private readonly List<Button> weaponListButtons = new List<Button>();

	private Coroutine weaponListBuildRoutine;

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

	private readonly List<int> visibleWeaponCandidateIndices = new List<int>();

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

	private readonly Dictionary<string, Type> cachedTypes = new Dictionary<string, Type>();

	private InputField saveWeaponNameInput;

	private InputField weaponSearchInput;

	private InputField presetNameInput;

	private InputField colorHexInput;

	private GameObject colorPickerBackdrop;

	private GameObject colorPickerPanel;

	private Transform colorPickerPartsContent;

	private RectTransform colorPickerPartsContentRect;

	private ScrollRect colorPickerPartsScroll;

	private Transform colorPaletteContainer;

	private RectTransform colorPaletteContainerRect;

	private Slider colorBrightnessSlider;

	private Text colorBrightnessValueText;

	private Image colorPickerSwatch;

	private Text colorPickerHexText;

	private Text colorPickerPartText;

	private readonly List<ColorPartChoice> colorPartChoices = new List<ColorPartChoice>();

	private readonly List<WeaponEditorPartColor> workingPartColors = new List<WeaponEditorPartColor>();

	private readonly List<Color> colorPaletteColors = new List<Color>();

	private readonly List<Button> colorPaletteButtons = new List<Button>();

	private int selectedColorPartIndex = -1;

	private int selectedPaletteIndex = -1;

	private Color selectedBaseColor = Color.white;

	private float selectedColorBrightness = 1f;

	private bool refreshingColorPicker;

	private bool overrideMeleeForce;

	private bool previewDragging;

	private Vector2 previewLastMousePosition;

	private float previewYaw;

	private float previewPitch;

	private static Sprite colorPaletteHexSprite;

	private static Texture2D colorPaletteHexTexture;

	private bool applyGlobalColor;

	private InputField damageInput;

	private InputField cooldownInput;

	private InputField meleeForceInput;

	private InputField projectileDamageInput;

	private InputField projectileSpeedInput;

	private InputField projectileGravityInput;

	private InputField projectileDragInput;

	private InputField projectileCountInput;

	private InputField projectileSizeInput;

	private InputField replacementEffectInput;

	private InputField replacementExplosionInput;

	private InputField replacementProjectileInput;

	private Text projectileColorSummaryText;

	private InputField effectColorHexInput;

	private bool applyEffectColor;

	private bool effectModeAlways;

	private int currentInvisibleMode;

	private readonly List<WeaponEditorPartVisibility> workingPartVisibilities = new List<WeaponEditorPartVisibility>();

	private readonly Dictionary<Renderer, bool> invisibleOriginalRendererStates = new Dictionary<Renderer, bool>();

	private bool rangeWindUpGuardInstalled;

	private string currentSettingsTab = "STATS";

	private GameObject effectColorPickerBackdrop;

	private Slider effectHueSlider;

	private Slider effectSaturationSlider;

	private Slider effectBrightnessSlider;

	private Text effectBrightnessValueText;

	private Color selectedEffectBaseColor = Color.white;

	private float selectedEffectBrightness = 1f;

	private Image effectColorSwatch;

	private Text effectColorHexLabel;

	private readonly List<Color> effectPaletteColors = new List<Color>();

	private readonly List<Button> effectPaletteButtons = new List<Button>();

	private int selectedEffectPaletteIndex = -1;

	private bool isPopulatingSettings;

	private bool applyProjectileSettings;

	private bool applyProjectileColor;

	private bool projectileModelInvisible;

	private bool projectileParticleInvisible;

	private Color selectedProjectileBaseColor = Color.white;

	private float selectedProjectileBrightness = 1f;

	private GameObject projectileColorPickerBackdrop;

	private Slider projectileBrightnessSlider;

	private Text projectileBrightnessValueText;

	private Image projectileColorSwatch;

	private Text projectileColorHexLabel;

	private readonly List<Color> projectilePaletteColors = new List<Color>();

	private readonly List<Button> projectilePaletteButtons = new List<Button>();

	private int selectedProjectilePaletteIndex = -1;

	private GameObject projectilePickerBackdrop;

	private Transform projectilePickerContent;

	private RectTransform projectilePickerContentRect;

	private ScrollRect projectilePickerScroll;

	private InputField projectilePickerSearchInput;

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

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

	private Coroutine projectilePickerBuildRoutine;

	private bool projectileCatalogScanned;

	private Slider weaponScaleSlider;

	private Slider effectScaleSlider;

	private InputField weaponScaleValueText;

	private InputField effectScaleValueText;

	private float customWeaponScale = 1f;

	private float customEffectScale = 1f;

	private bool updatingScaleControls;

	private float previewFitScale = 1f;

	private Vector3 previewFitCenter = Vector3.zero;

	private Vector3 previewRootPositionOffset = Vector3.zero;

	private GameObject prefabPickerBackdrop;

	private Transform prefabPickerContent;

	private RectTransform prefabPickerContentRect;

	private ScrollRect prefabPickerScroll;

	private InputField prefabPickerSearchInput;

	private bool prefabPickerShowsExplosions;

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

	private Coroutine prefabPickerBuildRoutine;

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

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

	private bool prefabCatalogScanned;

	private bool weaponCatalogScanned;

	private GameObject modelPartPickerBackdrop;

	private Transform modelPartPickerContent;

	private RectTransform modelPartPickerContentRect;

	private ScrollRect modelPartPickerScroll;

	private InputField modelPartPickerSearchInput;

	private Text modelPartPickerCountLabel;

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

	private readonly Dictionary<string, GameObject> modelPartPrefabCache = new Dictionary<string, GameObject>(StringComparer.OrdinalIgnoreCase);

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

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

	private readonly HashSet<string> missingModelPartPrefabNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

	private bool modelPartCatalogScanned;

	private const int MaxModelPartCandidates = 6000;

	private const int MaxVisibleModelPartRows = 2000;

	private const int MaxVisibleWeaponRows = 2000;

	private const int MaxVisiblePrefabRows = 2000;

	private const int MaxAttachedModelParts = 80;

	private const int MaxSavedWeaponRecords = 150;

	private readonly List<WeaponEditorModelPart> workingModelParts = new List<WeaponEditorModelPart>();

	private Transform selectedModelPartTransform;

	private Transform selectedTransformTarget;

	private GameObject transformExplorerPanel;

	private Transform transformExplorerContent;

	private RectTransform transformExplorerContentRect;

	private ScrollRect transformExplorerScroll;

	private readonly List<Button> transformExplorerButtons = new List<Button>();

	private readonly List<InputField> transformPositionFields = new List<InputField>();

	private readonly List<InputField> transformRotationFields = new List<InputField>();

	private readonly List<InputField> transformScaleFields = new List<InputField>();

	private GameObject transformInspectorPanel;

	private Button transformDeletePartButton;

	private bool refreshingTransformInspector;

	private Coroutine modelPartPickerRowsRoutine;

	private int modelPartPickerBuildVersion;

	private GameObject modelPartGizmoRoot;

	private readonly Dictionary<Collider, Vector3> modelPartGizmoAxes = new Dictionary<Collider, Vector3>();

	private Vector3 activeModelPartAxis = Vector3.zero;

	private bool draggingModelPartAxis;

	private string modelPartGizmoMode = "MOVE";

	private readonly List<SavedWeaponRecord> savedWeapons = new List<SavedWeaponRecord>();

	private readonly List<WeaponSettingsPreset> settingsPresets = new List<WeaponSettingsPreset>();

	private readonly HashSet<string> registeredSavedWeaponKeys = new HashSet<string>();

	private readonly Dictionary<string, WeaponDraftRecord> weaponDrafts = new Dictionary<string, WeaponDraftRecord>(StringComparer.OrdinalIgnoreCase);

	private Coroutine weaponDraftSaveRoutine;

	private int selectedWeaponIndex = -1;

	private const float MinimumEditableScale = 0.0001f;

	private const float MaximumEditableScale = 1000000f;

	private static readonly string[] MaterialColorPropertyNames = new string[16]
	{
		"_Color", "_BaseColor", "_TintColor", "_MainColor", "_CoreColor", "_AddColor", "_MultiplyColor", "_Color1", "_Color2", "_ColorA",
		"_ColorB", "_ParticleColor", "_OutlineColor", "_RimColor", "_SpecColor", "_EmissionColor"
	};

	private string SavedWeaponsPath => Path.Combine(Paths.ConfigPath, "WeaponEditorSavedWeapons.txt");

	private string SavedPresetsPath => Path.Combine(Paths.ConfigPath, "WeaponEditorPresets.txt");

	private string WeaponDraftsPath => Path.Combine(Paths.ConfigPath, "WeaponEditorDrafts.txt");

	private void Awake()
	{
		Instance = this;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"WeaponEditor 1.3.24 loaded (per-shot ranged projectile settings; avoids unnecessary child projectile clones).");
		((MonoBehaviour)this).StartCoroutine(InstallProjectilePatchWhenReady());
		SceneManager.sceneLoaded += OnSceneLoaded;
		LoadSavedWeaponRecords();
		LoadSavedPresets();
		LoadWeaponDrafts();
		((MonoBehaviour)this).StartCoroutine(TryCreateButton());
		StartSavedWeaponRegistration();
	}

	private void OnApplicationQuit()
	{
		SaveCurrentWeaponDraftNow();
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
		CloseWeaponBuilder();
		if ((Object)(object)colorPaletteHexSprite != (Object)null)
		{
			Object.Destroy((Object)(object)colorPaletteHexSprite);
		}
		if ((Object)(object)colorPaletteHexTexture != (Object)null)
		{
			Object.Destroy((Object)(object)colorPaletteHexTexture);
		}
		colorPaletteHexSprite = null;
		colorPaletteHexTexture = null;
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
	}

	private IEnumerator InstallProjectilePatchWhenReady()
	{
		for (int attempt = 0; attempt < 60; attempt++)
		{
			Type rangeWeaponType = FindType("RangeWeapon");
			if (rangeWeaponType != null)
			{
				MethodInfo target = null;
				MethodInfo[] methods = rangeWeaponType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				MethodInfo[] array = methods;
				foreach (MethodInfo method in array)
				{
					if (!(method.Name != "SetProjectileStats"))
					{
						ParameterInfo[] parameters = method.GetParameters();
						if (parameters.Length >= 1 && parameters[0].ParameterType == typeof(GameObject))
						{
							target = method;
							break;
						}
					}
				}
				try
				{
					if (harmony == null)
					{
						harmony = new Harmony("test.weaponeditor.menu.projectiles");
					}
					InstallRangeWeaponWindUpGuard();
					if (target != null)
					{
						MethodInfo postfix = typeof(WeaponEditor).GetMethod("RangeWeaponSetProjectileStatsPostfix", BindingFlags.Static | BindingFlags.NonPublic);
						if (postfix == null)
						{
							throw new MissingMethodException("RangeWeaponSetProjectileStatsPostfix");
						}
						harmony.Patch((MethodBase)target, (HarmonyMethod)null, new HarmonyMethod(postfix), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Projectile stats postfix installed on RangeWeapon.SetProjectileStats(" + string.Join(", ", Array.ConvertAll(target.GetParameters(), (ParameterInfo x) => x.ParameterType.Name)) + ")."));
						yield break;
					}
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("Could not install projectile / ranged safety patches: " + ex));
					yield break;
				}
			}
			yield return (object)new WaitForSecondsRealtime(1f);
		}
		((BaseUnityPlugin)this).Logger.LogWarning((object)"RangeWeapon.SetProjectileStats was not found; projectile edits will not be applied during firing.");
	}

	private void InstallRangeWeaponWindUpGuard()
	{
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Expected O, but got Unknown
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Expected O, but got Unknown
		if (rangeWindUpGuardInstalled || harmony == null)
		{
			return;
		}
		Type type = FindType("RangeWeaponWindUp");
		if (type == null)
		{
			return;
		}
		MethodInfo method = type.GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		MethodInfo method2 = type.GetMethod("Update", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		MethodInfo method3 = typeof(WeaponEditor).GetMethod("RangeWeaponWindUpStartPrefix", BindingFlags.Static | BindingFlags.NonPublic);
		MethodInfo method4 = typeof(WeaponEditor).GetMethod("RangeWeaponWindUpUpdatePrefix", BindingFlags.Static | BindingFlags.NonPublic);
		if (method2 == null || method4 == null)
		{
			return;
		}
		try
		{
			if (method != null && method3 != null)
			{
				harmony.Patch((MethodBase)method, new HarmonyMethod(method3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			harmony.Patch((MethodBase)method2, new HarmonyMethod(method4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			rangeWindUpGuardInstalled = true;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Safe RangeWeaponWindUp.Start/Update guards installed.");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not install RangeWeaponWindUp guard: " + ex.Message));
		}
	}

	private static bool RangeWeaponWindUpStartPrefix(object __instance)
	{
		if ((Object)(object)Instance == (Object)null)
		{
			return true;
		}
		Component val = (Component)((__instance is Component) ? __instance : null);
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		try
		{
			Type type = Instance.FindType("RangeWeapon");
			if (type == null || (Object)(object)val.GetComponent(type) == (Object)null)
			{
				return false;
			}
			FieldInfo field = ((object)val).GetType().GetField("fireRateCurve", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			AnimationCurve val2 = (AnimationCurve)((field != null) ? /*isinst with value type is only supported in some contexts*/: null);
			if (val2 == null || val2.length == 0 || val2.keys == null || val2.keys.Length == 0)
			{
				return false;
			}
			FieldInfo field2 = ((object)val).GetType().GetField("rotationTransform", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 == null || field2.GetValue(val) == null)
			{
				return false;
			}
			return true;
		}
		catch
		{
			return false;
		}
	}

	private static bool RangeWeaponWindUpUpdatePrefix(object __instance)
	{
		if ((Object)(object)Instance == (Object)null)
		{
			return true;
		}
		Component val = (Component)((__instance is Component) ? __instance : null);
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		try
		{
			Type type = (((Object)(object)Instance != (Object)null) ? Instance.FindType("RangeWeapon") : null);
			Type type2 = (((Object)(object)Instance != (Object)null) ? Instance.FindType("WeaponHandler") : null);
			if (type == null || type2 == null)
			{
				return false;
			}
			if ((Object)(object)val.GetComponent(type) == (Object)null)
			{
				return false;
			}
			Transform root = val.transform.root;
			if ((Object)(object)root == (Object)null || (Object)(object)((Component)root).GetComponentInChildren(type2, true) == (Object)null)
			{
				return false;
			}
			FieldInfo field = ((object)val).GetType().GetField("rotationTransform", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null || field.GetValue(val) == null)
			{
				return false;
			}
			FieldInfo field2 = ((object)val).GetType().GetField("fireRateCurve", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			AnimationCurve val2 = (AnimationCurve)((field2 != null) ? /*isinst with value type is only supported in some contexts*/: null);
			if (val2 == null || val2.length == 0)
			{
				return false;
			}
			return true;
		}
		catch
		{
			return false;
		}
	}

	private static void RangeWeaponSetProjectileStatsPostfix(object __instance, GameObject __0)
	{
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Instance == (Object)null || __instance == null || (Object)(object)__0 == (Object)null)
		{
			return;
		}
		try
		{
			Component val = (Component)((__instance is Component) ? __instance : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			WeaponEditorSettingsMarker componentInParent = val.GetComponentInParent<WeaponEditorSettingsMarker>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return;
			}
			if (componentInParent.applyProjectileSettings)
			{
				WeaponSettings weaponSettings = new WeaponSettings();
				weaponSettings.colorHex = componentInParent.colorHex;
				weaponSettings.damage = componentInParent.damage;
				weaponSettings.cooldown = componentInParent.cooldown;
				weaponSettings.meleeForce = componentInParent.meleeForce;
				weaponSettings.projectileDamage = componentInParent.projectileDamage;
				weaponSettings.projectileSpeed = componentInParent.projectileSpeed;
				weaponSettings.projectileGravity = componentInParent.projectileGravity;
				weaponSettings.projectileDrag = componentInParent.projectileDrag;
				weaponSettings.applyProjectileSettings = true;
				Instance.ApplyProjectileSettingsToSpawnedObject(__0, weaponSettings);
			}
			if (!componentInParent.effectModeAlways && !string.IsNullOrEmpty(componentInParent.replacementEffectName))
			{
				Instance.AttachSelectedFxToShot(__0, componentInParent);
			}
			float num = Mathf.Clamp(componentInParent.projectileSize, 0.1f, 10f);
			if (Mathf.Abs(num - 1f) > 0.001f)
			{
				Transform transform = __0.transform;
				transform.localScale *= num;
			}
			Instance.ApplyProjectileAppearanceToSpawnedObject(__0, componentInParent);
			int num2 = Mathf.Clamp(componentInParent.projectileCount, 1, 20) - 1;
			if (num2 <= 0)
			{
				return;
			}
			Rigidbody componentInChildren = __0.GetComponentInChildren<Rigidbody>();
			for (int i = 0; i < num2; i++)
			{
				Vector3 val2 = __0.transform.right * (((float)i - (float)(num2 - 1) * 0.5f) * 0.035f);
				GameObject val3 = Object.Instantiate<GameObject>(__0, __0.transform.position + val2, __0.transform.rotation);
				((Object)val3).name = ((Object)__0).name + "__WeaponEditorExtraShot";
				Rigidbody componentInChildren2 = val3.GetComponentInChildren<Rigidbody>();
				if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren2 != (Object)null)
				{
					componentInChildren2.velocity = componentInChildren.velocity;
					componentInChildren2.angularVelocity = componentInChildren.angularVelocity;
				}
			}
		}
		catch (Exception ex)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)Instance).Logger.LogWarning((object)("Projectile property/FX patch skipped: " + ex.Message));
			}
		}
	}

	private void AttachSelectedFxToShot(GameObject spawnedProjectile, WeaponEditorSettingsMarker marker)
	{
		//IL_0139: 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_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)spawnedProjectile == (Object)null || (Object)(object)marker == (Object)null || string.IsNullOrEmpty(marker.replacementEffectName))
		{
			return;
		}
		Transform[] componentsInChildren = spawnedProjectile.GetComponentsInChildren<Transform>(true);
		Transform[] array = componentsInChildren;
		foreach (Transform val in array)
		{
			if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)spawnedProjectile.transform && ((Object)val).name.StartsWith("__WeaponEditor_ShotFX__", StringComparison.Ordinal))
			{
				return;
			}
		}
		GameObject val2 = FindCatalogPrefab(marker.replacementEffectName, explosionOnly: false);
		if ((Object)(object)val2 == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Shot FX not found in the visual-effects catalog: " + marker.replacementEffectName));
			return;
		}
		if (IsSkillPrefab(val2) || !HasVisualEffect(val2))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Selected item is not a visual-only FX prefab: " + marker.replacementEffectName + ". Choose an entry from PARTICLES / VISUAL EFFECTS."));
			return;
		}
		GameObject val3 = null;
		try
		{
			val3 = Object.Instantiate<GameObject>(val2, spawnedProjectile.transform, false);
			((Object)val3).name = "__WeaponEditor_ShotFX__" + ((Object)val2).name;
			val3.transform.localPosition = Vector3.zero;
			val3.transform.localRotation = Quaternion.identity;
			float num = ClampUserScale(marker.effectScale);
			val3.transform.localScale = val2.transform.localScale * num;
			val3.SetActive(true);
			if (marker.applyEffectColor && TryParseHexColor(marker.effectColorHex, out var color))
			{
				TintVfxObject(val3, color, marker.effectColorBrightness);
			}
			ParticleSystem[] componentsInChildren2 = val3.GetComponentsInChildren<ParticleSystem>(true);
			ParticleSystem[] array2 = componentsInChildren2;
			foreach (ParticleSystem val4 in array2)
			{
				if (!((Object)(object)val4 == (Object)null))
				{
					((Component)val4).gameObject.SetActive(true);
					try
					{
						val4.Play(true);
					}
					catch
					{
					}
				}
			}
			TrailRenderer[] componentsInChildren3 = val3.GetComponentsInChildren<TrailRenderer>(true);
			TrailRenderer[] array3 = componentsInChildren3;
			foreach (TrailRenderer val5 in array3)
			{
				if ((Object)(object)val5 != (Object)null)
				{
					val5.emitting = true;
				}
			}
			LineRenderer[] componentsInChildren4 = val3.GetComponentsInChildren<LineRenderer>(true);
			LineRenderer[] array4 = componentsInChildren4;
			foreach (LineRenderer val6 in array4)
			{
				if ((Object)(object)val6 != (Object)null)
				{
					((Renderer)val6).enabled = true;
				}
			}
		}
		catch (Exception ex)
		{
			if ((Object)(object)val3 != (Object)null)
			{
				Object.Destroy((Object)(object)val3);
			}
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not attach selected shot FX '" + marker.replacementEffectName + "': " + ex.Message));
		}
	}

	private void ApplyProjectileAppearanceToSpawnedObject(GameObject spawnedProjectile, WeaponEditorSettingsMarker marker)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)spawnedProjectile == (Object)null || (Object)(object)marker == (Object)null)
		{
			return;
		}
		if (marker.applyProjectileColor && TryParseHexColor(marker.projectileColorHex, out var color))
		{
			TintVfxObject(spawnedProjectile, color, NormalizeColorBrightness(marker.projectileColorBrightness));
		}
		if (marker.projectileModelInvisible)
		{
			Renderer[] componentsInChildren = spawnedProjectile.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.enabled = false;
				}
			}
		}
		if (!marker.projectileParticleInvisible)
		{
			return;
		}
		ParticleSystemRenderer[] componentsInChildren2 = spawnedProjectile.GetComponentsInChildren<ParticleSystemRenderer>(true);
		ParticleSystemRenderer[] array2 = componentsInChildren2;
		foreach (ParticleSystemRenderer val2 in array2)
		{
			if ((Object)(object)val2 != (Object)null)
			{
				((Renderer)val2).enabled = false;
			}
		}
		TrailRenderer[] componentsInChildren3 = spawnedProjectile.GetComponentsInChildren<TrailRenderer>(true);
		TrailRenderer[] array3 = componentsInChildren3;
		foreach (TrailRenderer val3 in array3)
		{
			if ((Object)(object)val3 != (Object)null)
			{
				((Renderer)val3).enabled = false;
			}
		}
		LineRenderer[] componentsInChildren4 = spawnedProjectile.GetComponentsInChildren<LineRenderer>(true);
		LineRenderer[] array4 = componentsInChildren4;
		foreach (LineRenderer val4 in array4)
		{
			if ((Object)(object)val4 != (Object)null)
			{
				((Renderer)val4).enabled = false;
			}
		}
	}

	private void ApplyProjectileSettingsToSpawnedObject(GameObject spawnedObject, WeaponSettings settings)
	{
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)spawnedObject == (Object)null) && settings != null && settings.applyProjectileSettings)
		{
			Component componentByTypeNameInChildren = GetComponentByTypeNameInChildren(spawnedObject, "CollisionWeapon");
			SetNumericMember(componentByTypeNameInChildren, "damage", settings.projectileDamage);
			Component componentByTypeNameInChildren2 = GetComponentByTypeNameInChildren(spawnedObject, "MoveTransform");
			SetNumericMember(componentByTypeNameInChildren2, "gravity", settings.projectileGravity);
			SetNumericMember(componentByTypeNameInChildren2, "drag", settings.projectileDrag);
			if (TryReadVector3Member(componentByTypeNameInChildren2, "selfImpulse", out var value) && ((Vector3)(ref value)).sqrMagnitude > 0.0001f)
			{
				Vector3 normalized = ((Vector3)(ref value)).normalized;
				SetMemberValue(componentByTypeNameInChildren2, "selfImpulse", normalized * Mathf.Max(0f, settings.projectileSpeed));
			}
		}
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		CloseWeaponBuilder();
		weaponCandidates.Clear();
		weaponDisplayNameCache.Clear();
		weaponCatalogScanned = false;
		cachedEffectPrefabCandidates.Clear();
		cachedExplosionPrefabCandidates.Clear();
		prefabPickerCandidates.Clear();
		prefabCatalogScanned = false;
		cachedProjectilePrefabCandidates.Clear();
		projectilePickerCandidates.Clear();
		projectileCatalogScanned = false;
		modelPartCandidates.Clear();
		modelPartCandidateLabels.Clear();
		modelPartCandidateSearchTerms.Clear();
		modelPartPrefabCache.Clear();
		missingModelPartPrefabNames.Clear();
		modelPartCatalogScanned = false;
		selectedWeaponIndex = -1;
		registeredSavedWeaponKeys.Clear();
		((MonoBehaviour)this).StartCoroutine(TryCreateButton());
		StartSavedWeaponRegistration();
	}

	private IEnumerator TryCreateButton()
	{
		for (int i = 0; i < 40; i++)
		{
			if (TryCreateMenuButton())
			{
				yield break;
			}
			yield return (object)new WaitForSeconds(1f);
		}
		((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find the TABS main menu button container.");
	}

	private Type FindType(string typeName)
	{
		if (string.IsNullOrEmpty(typeName))
		{
			return null;
		}
		if (cachedTypes.TryGetValue(typeName, out var value))
		{
			return value;
		}
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			try
			{
				Type type = assembly.GetType(typeName, throwOnError: false);
				if (type != null)
				{
					cachedTypes[typeName] = type;
					return type;
				}
				Type[] types = assembly.GetTypes();
				foreach (Type type2 in types)
				{
					if (type2 != null && type2.Name == typeName)
					{
						cachedTypes[typeName] = type2;
						return type2;
					}
				}
			}
			catch
			{
			}
		}
		return null;
	}

	private bool TryCreateMenuButton()
	{
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Expected O, but got Unknown
		//IL_034c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Expected O, but got Unknown
		try
		{
			Type type = FindType("MainMenuButtons");
			if (type == null)
			{
				return false;
			}
			Object obj = Object.FindObjectOfType(type);
			Component val = (Component)(object)((obj is Component) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			FieldInfo field = type.GetField("m_ButtonsContainer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				return false;
			}
			object? value = field.GetValue(val);
			Transform val2 = (Transform)((value is Transform) ? value : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return false;
			}
			Transform val3 = null;
			List<GameObject> list = new List<GameObject>();
			for (int i = 0; i < val2.childCount; i++)
			{
				Transform child = val2.GetChild(i);
				if (!((Object)(object)child == (Object)null) && !(((Object)child).name != "WeaponEditorButton"))
				{
					if ((Object)(object)val3 == (Object)null)
					{
						val3 = child;
					}
					else
					{
						list.Add(((Component)child).gameObject);
					}
				}
			}
			foreach (GameObject item in list)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(object)item);
				}
			}
			if ((Object)(object)val3 != (Object)null)
			{
				Button componentInChildren = ((Component)val3).GetComponentInChildren<Button>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((UnityEventBase)componentInChildren.onClick).RemoveAllListeners();
					((UnityEvent)componentInChildren.onClick).AddListener(new UnityAction(OpenWeaponBuilder));
				}
				DisableButtonLocalization(((Component)val3).gameObject);
				SetButtonLabel(((Component)val3).gameObject, "WeaponEditor");
				PlaceButtonAboveSettings(val2, val3);
				((MonoBehaviour)this).StartCoroutine(ForceButtonLabel(((Component)val3).gameObject));
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Existing WeaponEditor button reused and positioned above Settings when detected.");
				return true;
			}
			Button val4 = null;
			Transform val5 = null;
			Button[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Button>(true);
			Button[] array = componentsInChildren;
			foreach (Button val6 in array)
			{
				if (!((Object)(object)val6 == (Object)null))
				{
					Transform val7 = ((Component)val6).transform;
					while ((Object)(object)val7.parent != (Object)null && (Object)(object)val7.parent != (Object)(object)val2)
					{
						val7 = val7.parent;
					}
					if (!((Object)(object)val7.parent != (Object)(object)val2) && ((Object)val7).name.IndexOf("weaponeditor", StringComparison.OrdinalIgnoreCase) < 0)
					{
						val4 = val6;
						val5 = val7;
						break;
					}
				}
			}
			if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null)
			{
				return false;
			}
			GameObject val8 = Object.Instantiate<GameObject>(((Component)val5).gameObject, val2, false);
			((Object)val8).name = "WeaponEditorButton";
			Button componentInChildren2 = val8.GetComponentInChildren<Button>(true);
			if ((Object)(object)componentInChildren2 == (Object)null)
			{
				Object.Destroy((Object)(object)val8);
				return false;
			}
			DisableButtonLocalization(val8);
			SetButtonLabel(val8, "WeaponEditor");
			((UnityEventBase)componentInChildren2.onClick).RemoveAllListeners();
			((UnityEvent)componentInChildren2.onClick).AddListener(new UnityAction(OpenWeaponBuilder));
			PlaceButtonAboveSettings(val2, val8.transform);
			((MonoBehaviour)this).StartCoroutine(ForceButtonLabel(val8));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"WeaponEditor button created and positioned above Settings when detected.");
			return true;
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Menu button error: " + ex));
			return false;
		}
	}

	private void PlaceButtonAboveSettings(Transform container, Transform weaponEditorRoot)
	{
		if ((Object)(object)container == (Object)null || (Object)(object)weaponEditorRoot == (Object)null)
		{
			return;
		}
		Transform val = null;
		for (int i = 0; i < container.childCount; i++)
		{
			Transform child = container.GetChild(i);
			if (!((Object)(object)child == (Object)null) && !((Object)(object)child == (Object)(object)weaponEditorRoot) && !(((Object)child).name == "WeaponEditorButton") && ((Object)child).name.IndexOf("setting", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				val = child;
				break;
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			for (int j = 0; j < container.childCount; j++)
			{
				Transform child2 = container.GetChild(j);
				if (!((Object)(object)child2 == (Object)null) && !((Object)(object)child2 == (Object)(object)weaponEditorRoot) && !(((Object)child2).name == "WeaponEditorButton") && HasSettingsLabel(((Component)child2).gameObject))
				{
					val = child2;
					break;
				}
			}
		}
		if ((Object)(object)val != (Object)null)
		{
			weaponEditorRoot.SetSiblingIndex(val.GetSiblingIndex());
			((BaseUnityPlugin)this).Logger.LogInfo((object)"WeaponEditor menu entry placed immediately above Settings.");
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Settings entry was not identifiable in MainMenuButtons; WeaponEditor keeps the default menu order.");
		}
	}

	private bool HasSettingsLabel(GameObject root)
	{
		if ((Object)(object)root == (Object)null)
		{
			return false;
		}
		Text[] componentsInChildren = root.GetComponentsInChildren<Text>(true);
		foreach (Text val in componentsInChildren)
		{
			if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(val.text) && val.text.IndexOf("setting", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return true;
			}
		}
		Component[] componentsInChildren2 = root.GetComponentsInChildren<Component>(true);
		foreach (Component val2 in componentsInChildren2)
		{
			if ((Object)(object)val2 == (Object)null || ((object)val2).GetType().FullName == null || ((object)val2).GetType().FullName.IndexOf("TMPro", StringComparison.OrdinalIgnoreCase) < 0)
			{
				continue;
			}
			PropertyInfo property = ((object)val2).GetType().GetProperty("text", BindingFlags.Instance | BindingFlags.Public);
			if (property == null || !property.CanRead || property.PropertyType != typeof(string))
			{
				continue;
			}
			try
			{
				string text = property.GetValue(val2, null) as string;
				if (!string.IsNullOrEmpty(text) && text.IndexOf("setting", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			catch
			{
			}
		}
		return false;
	}

	private void SetButtonLabel(GameObject root, string label)
	{
		if ((Object)(object)root == (Object)null)
		{
			return;
		}
		Text[] componentsInChildren = root.GetComponentsInChildren<Text>(true);
		foreach (Text val in componentsInChildren)
		{
			if ((Object)(object)val != (Object)null)
			{
				val.text = label;
			}
		}
		Component[] componentsInChildren2 = root.GetComponentsInChildren<Component>(true);
		foreach (Component val2 in componentsInChildren2)
		{
			if ((Object)(object)val2 == (Object)null)
			{
				continue;
			}
			Type type = ((object)val2).GetType();
			if (type.FullName == null || !type.FullName.Contains("TMPro"))
			{
				continue;
			}
			PropertyInfo property = type.GetProperty("text", BindingFlags.Instance | BindingFlags.Public);
			if (!(property == null) && property.CanWrite && !(property.PropertyType != typeof(string)))
			{
				try
				{
					property.SetValue(val2, label, null);
				}
				catch
				{
				}
			}
		}
	}

	private void DisableButtonLocalization(GameObject root)
	{
		if ((Object)(object)root == (Object)null)
		{
			return;
		}
		MonoBehaviour[] componentsInChildren = root.GetComponentsInChildren<MonoBehaviour>(true);
		foreach (MonoBehaviour val in componentsInChildren)
		{
			if (!((Object)(object)val == (Object)null))
			{
				string text = ((object)val).GetType().Name.ToLowerInvariant();
				if (text.Contains("localiz") || text.Contains("translation") || text.Contains("translator"))
				{
					((Behaviour)val).enabled = false;
				}
			}
		}
	}

	private IEnumerator ForceButtonLabel(GameObject root)
	{
		for (int i = 0; i < 30; i++)
		{
			if ((Object)(object)root == (Object)null)
			{
				break;
			}
			SetButtonLabel(root, "WeaponEditor");
			yield return null;
		}
	}

	private void OpenWeaponBuilder()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: 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_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Expected O, but got Unknown
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0321: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ab: Expected O, but got Unknown
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_041c: Unknown result type (might be due to invalid IL or missing references)
		//IL_044b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0452: Expected O, but got Unknown
		//IL_047c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0493: Unknown result type (might be due to invalid IL or missing references)
		//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0501: Unknown result type (might be due to invalid IL or missing references)
		//IL_0508: Expected O, but got Unknown
		//IL_0532: Unknown result type (might be due to invalid IL or missing references)
		//IL_0549: Unknown result type (might be due to invalid IL or missing references)
		//IL_0560: Unknown result type (might be due to invalid IL or missing references)
		//IL_0577: Unknown result type (might be due to invalid IL or missing references)
		//IL_058e: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fa: Expected O, but got Unknown
		//IL_061a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0627: Unknown result type (might be due to invalid IL or missing references)
		//IL_0634: Unknown result type (might be due to invalid IL or missing references)
		//IL_0641: Unknown result type (might be due to invalid IL or missing references)
		//IL_066b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0712: Unknown result type (might be due to invalid IL or missing references)
		//IL_0721: Unknown result type (might be due to invalid IL or missing references)
		//IL_072d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0746: Unknown result type (might be due to invalid IL or missing references)
		//IL_075a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0764: Expected O, but got Unknown
		//IL_0781: Unknown result type (might be due to invalid IL or missing references)
		//IL_0790: Unknown result type (might be due to invalid IL or missing references)
		//IL_0795: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0800: Unknown result type (might be due to invalid IL or missing references)
		//IL_0819: Unknown result type (might be due to invalid IL or missing references)
		//IL_082d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0837: Expected O, but got Unknown
		//IL_0853: Unknown result type (might be due to invalid IL or missing references)
		//IL_0862: Unknown result type (might be due to invalid IL or missing references)
		//IL_086e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0887: Unknown result type (might be due to invalid IL or missing references)
		//IL_089b: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a5: Expected O, but got Unknown
		//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0913: Unknown result type (might be due to invalid IL or missing references)
		//IL_0952: Unknown result type (might be due to invalid IL or missing references)
		//IL_0961: Unknown result type (might be due to invalid IL or missing references)
		//IL_096d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0974: Unknown result type (might be due to invalid IL or missing references)
		//IL_097a: Unknown result type (might be due to invalid IL or missing references)
		//IL_097e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0984: Unknown result type (might be due to invalid IL or missing references)
		//IL_098b: Expected O, but got Unknown
		//IL_09a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e0: Expected O, but got Unknown
		//IL_09fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a17: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a1e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a24: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a28: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a2e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a35: Expected O, but got Unknown
		if ((Object)(object)editorCanvas != (Object)null)
		{
			CloseWeaponBuilder();
			return;
		}
		GameObject val = new GameObject("WeaponEditorCanvas");
		Canvas val2 = val.AddComponent<Canvas>();
		val2.renderMode = (RenderMode)0;
		val2.overrideSorting = true;
		val2.sortingOrder = 32000;
		CanvasScaler val3 = val.AddComponent<CanvasScaler>();
		val3.uiScaleMode = (ScaleMode)1;
		val3.referenceResolution = new Vector2(1280f, 720f);
		val3.matchWidthOrHeight = 0.5f;
		val.AddComponent<GraphicRaycaster>();
		editorCanvas = val;
		GameObject val4 = new GameObject("WeaponPreviewImage");
		val4.transform.SetParent(val.transform, false);
		previewImage = val4.AddComponent<RawImage>();
		((Graphic)previewImage).color = Color.white;
		((Graphic)previewImage).raycastTarget = false;
		RectTransform component = val4.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.575f, 0f);
		component.anchorMax = new Vector2(1f, 1f);
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		CreatePanel(val.transform, "LeftPanelBG", new Vector2(0f, 0f), new Vector2(0.575f, 1f), Vector2.zero, Vector2.zero, new Color(0.79f, 0.8f, 0.81f, 0.94f));
		CreateLabel(val.transform, "Title", "WEAPON EDITOR", new Vector2(0.135f, 0.94f), new Vector2(0.135f, 0.94f), Vector2.zero, new Vector2(290f, 42f), 28, new Color(0.08f, 0.085f, 0.09f, 1f), (TextAnchor)4);
		CreateLabel(val.transform, "WeaponListTitle", "LIBRARY", new Vector2(0.135f, 0.855f), new Vector2(0.135f, 0.855f), Vector2.zero, new Vector2(235f, 28f), 17, new Color(0.92f, 0.94f, 0.97f), (TextAnchor)4);
		weaponSearchInput = CreateInputField(val.transform, "WeaponSearchInput", "Search weapons...", new Vector2(0.135f, 0.812f), new Vector2(235f, 24f));
		((UnityEvent<string>)(object)weaponSearchInput.onValueChanged).AddListener((UnityAction<string>)delegate
		{
			RebuildWeaponList();
		});
		GameObject val5 = CreatePanel(val.transform, "WeaponListPanel", new Vector2(0.018f, 0.625f), new Vector2(0.255f, 0.787f), Vector2.zero, Vector2.zero, new Color(0.88f, 0.89f, 0.9f, 1f));
		GameObject val6 = new GameObject("WeaponListScroll");
		val6.transform.SetParent(val5.transform, false);
		RectTransform val7 = val6.AddComponent<RectTransform>();
		val7.anchorMin = Vector2.zero;
		val7.anchorMax = Vector2.one;
		val7.offsetMin = new Vector2(8f, 8f);
		val7.offsetMax = new Vector2(-18f, -8f);
		weaponListScroll = val6.AddComponent<ScrollRect>();
		weaponListScroll.horizontal = false;
		weaponListScroll.vertical = true;
		weaponListScroll.movementType = (MovementType)2;
		weaponListScroll.scrollSensitivity = 30f;
		GameObject val8 = new GameObject("Viewport");
		val8.transform.SetParent(val6.transform, false);
		RectTransform val9 = val8.AddComponent<RectTransform>();
		val9.anchorMin = Vector2.zero;
		val9.anchorMax = Vector2.one;
		val9.offsetMin = Vector2.zero;
		val9.offsetMax = Vector2.zero;
		Image val10 = val8.AddComponent<Image>();
		((Graphic)val10).color = new Color(0.96f, 0.96f, 0.96f, 1f);
		((Graphic)val10).raycastTarget = true;
		val8.AddComponent<RectMask2D>();
		weaponListScroll.viewport = val9;
		GameObject val11 = new GameObject("Content");
		val11.transform.SetParent(val8.transform, false);
		RectTransform val12 = val11.AddComponent<RectTransform>();
		val12.anchorMin = new Vector2(0f, 1f);
		val12.anchorMax = new Vector2(1f, 1f);
		val12.pivot = new Vector2(0.5f, 1f);
		val12.anchoredPosition = Vector2.zero;
		val12.sizeDelta = new Vector2(0f, 0f);
		weaponListContent = val11.transform;
		weaponListContentRect = val12;
		weaponListScroll.content = val12;
		GameObject val13 = new GameObject("WeaponListScrollbar");
		val13.transform.SetParent(val5.transform, false);
		RectTransform val14 = val13.AddComponent<RectTransform>();
		val14.anchorMin = new Vector2(1f, 0f);
		val14.anchorMax = new Vector2(1f, 1f);
		val14.pivot = new Vector2(1f, 0.5f);
		val14.sizeDelta = new Vector2(7f, -18f);
		val14.anchoredPosition = new Vector2(-4f, 0f);
		Image val15 = val13.AddComponent<Image>();
		((Graphic)val15).color = new Color(0.84f, 0.85f, 0.86f, 1f);
		weaponListScrollbar = val13.AddComponent<Scrollbar>();
		weaponListScrollbar.direction = (Direction)2;
		weaponListScrollbar.size = 1f;
		GameObject val16 = new GameObject("Handle");
		val16.transform.SetParent(val13.transform, false);
		RectTransform val17 = val16.AddComponent<RectTransform>();
		val17.anchorMin = Vector2.zero;
		val17.anchorMax = Vector2.one;
		val17.offsetMin = Vector2.zero;
		val17.offsetMax = Vector2.zero;
		Image val18 = val16.AddComponent<Image>();
		((Graphic)val18).color = new Color(0.62f, 0.64f, 0.66f, 1f);
		weaponListScrollbar.handleRect = val17;
		((Selectable)weaponListScrollbar).targetGraphic = (Graphic)(object)val18;
		weaponListScroll.verticalScrollbar = weaponListScrollbar;
		weaponListScroll.verticalScrollbarVisibility = (ScrollbarVisibility)1;
		saveWeaponNameInput = CreateInputField(val.transform, "SaveWeaponNameInput", "Name to save", new Vector2(0.135f, 0.182f), new Vector2(220f, 27f));
		presetNameInput = saveWeaponNameInput;
		CreateButton(val.transform, "Save", "SAVE", new Vector2(0.135f, 0.14f), new Vector2(220f, 27f), new UnityAction(SaveCurrentSettings), new Color(0.98f, 0.72f, 0.2f, 1f), new Color(0.08f, 0.09f, 0.11f));
		statusText = CreateLabel(val.transform, "Status", "Scanning...", new Vector2(0.135f, 0.103f), new Vector2(0.135f, 0.103f), Vector2.zero, new Vector2(235f, 22f), 10, new Color(0.2f, 0.4f, 0.2f), (TextAnchor)4);
		CreateButton(val.transform, "AddModelPart", "ADD MODEL PART", new Vector2(0.135f, 0.064f), new Vector2(220f, 25f), new UnityAction(OpenModelPartPicker), new Color(0.82f, 0.85f, 0.87f, 1f), new Color(0.08f, 0.09f, 0.11f));
		CreateButton(val.transform, "Close", "EXIT", new Vector2(0.135f, 0.022f), new Vector2(220f, 25f), new UnityAction(CloseWeaponBuilder), new Color(0.95f, 0.95f, 0.95f, 1f), new Color(0.8f, 0.2f, 0.2f));
		Create3DPreview();
		CreateTransformExplorer(val.transform);
		Text val19 = CreateLabel(val.transform, "PreviewRotateHint", "LEFT-DRAG: ORBIT  •  AXIS-DRAG: EDIT  •  RIGHT-DRAG: ORBIT", new Vector2(0.79f, 0.968f), new Vector2(0.79f, 0.968f), Vector2.zero, new Vector2(310f, 20f), 10, new Color(0.12f, 0.13f, 0.14f, 0.88f), (TextAnchor)4);
		if ((Object)(object)val19 != (Object)null)
		{
			((Graphic)val19).raycastTarget = false;
		}
		CreateButton(val.transform, "GizmoModeMove", "MOVE", new Vector2(0.735f, 0.925f), new Vector2(58f, 22f), (UnityAction)delegate
		{
			SetModelPartGizmoMode("MOVE");
		});
		CreateButton(val.transform, "GizmoModeRotate", "ROTATE", new Vector2(0.815f, 0.925f), new Vector2(68f, 22f), (UnityAction)delegate
		{
			SetModelPartGizmoMode("ROTATE");
		});
		CreateButton(val.transform, "GizmoModeScale", "SCALE", new Vector2(0.9f, 0.925f), new Vector2(58f, 22f), (UnityAction)delegate
		{
			SetModelPartGizmoMode("SCALE");
		});
		CreateTransformInspector(val.transform);
		CreateSettingsPanel(val.transform);
		HookSettingsDraftAutosave();
		ApplyDarkTheme();
		UpdateGizmoModeButtonStates();
		SetSettingsTab("STATS");
		UpdateSelectedModelLabel("None");
		UpdateStatus("Status: Loading weapons...");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"WeaponEditor opened.");
		if (weaponCatalogScanned && weaponCandidates.Count > 0)
		{
			if (selectedWeaponIndex < 0 || selectedWeaponIndex >= weaponCandidates.Count)
			{
				selectedWeaponIndex = 0;
			}
			RebuildWeaponList();
			ShowSelectedWeapon();
			UpdateStatus("Status: Reused cached weapon catalog (" + weaponCandidates.Count + ")");
		}
		else
		{
			((MonoBehaviour)this).StartCoroutine(AutoScanWhenEditorReady());
		}
	}

	private void ApplyDarkTheme()
	{
		//IL_06fe: 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_0740: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_078e: Unknown result type (might be due to invalid IL or missing references)
		//IL_077f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b03: Unknown result type (might be due to invalid IL or missing references)
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b28: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_089e: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_08dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_08fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_091b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0952: Unknown result type (might be due to invalid IL or missing references)
		//IL_0973: Unknown result type (might be due to invalid IL or missing references)
		//IL_0994: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d6: 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_0459: Unknown result type (might be due to invalid IL or missing references)
		//IL_047d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a5b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0523: Unknown result type (might be due to invalid IL or missing references)
		//IL_051c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0585: Unknown result type (might be due to invalid IL or missing references)
		//IL_05af: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0624: Unknown result type (might be due to invalid IL or missing references)
		//IL_0604: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)editorCanvas == (Object)null)
		{
			return;
		}
		Color color = default(Color);
		((Color)(ref color))..ctor(0.91f, 0.93f, 0.96f, 1f);
		Color color2 = default(Color);
		((Color)(ref color2))..ctor(0.68f, 0.72f, 0.78f, 1f);
		Color color3 = default(Color);
		((Color)(ref color3))..ctor(0.025f, 0.03f, 0.04f, 0.99f);
		Color color4 = default(Color);
		((Color)(ref color4))..ctor(0.018f, 0.022f, 0.03f, 1f);
		Color color5 = default(Color);
		((Color)(ref color5))..ctor(0.01f, 0.014f, 0.021f, 1f);
		Color val = default(Color);
		((Color)(ref val))..ctor(0.07f, 0.082f, 0.102f, 1f);
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(0.047f, 0.057f, 0.073f, 1f);
		Color val3 = default(Color);
		((Color)(ref val3))..ctor(0.075f, 0.205f, 0.315f, 1f);
		Color color6 = default(Color);
		((Color)(ref color6))..ctor(0.006f, 0.008f, 0.013f, 0.98f);
		Image[] componentsInChildren = editorCanvas.GetComponentsInChildren<Image>(true);
		Image[] array = componentsInChildren;
		foreach (Image val4 in array)
		{
			if ((Object)(object)val4 == (Object)null)
			{
				continue;
			}
			string name = ((Object)((Component)val4).gameObject).name;
			if (!name.StartsWith("EffectPaletteColor_", StringComparison.Ordinal) && !name.StartsWith("ProjectilePaletteColor_", StringComparison.Ordinal) && !name.StartsWith("MaterialChoice_Palette_", StringComparison.Ordinal))
			{
				switch (name)
				{
				default:
					if (name == "ColorPickerSwatch")
					{
						break;
					}
					if (name == "LeftPanelBG")
					{
						((Graphic)val4).color = new Color(0.012f, 0.016f, 0.023f, 0.99f);
					}
					else if (name.EndsWith("Backdrop", StringComparison.Ordinal))
					{
						((Graphic)val4).color = new Color(0.003f, 0.005f, 0.009f, 0.88f);
					}
					else
					{
						switch (name)
						{
						default:
							if (!(name == "ModelPartPickerPanel"))
							{
								if (name == "WeaponListPanel")
								{
									((Graphic)val4).color = color4;
								}
								else
								{
									if (name.StartsWith("ExplorerRow_", StringComparison.Ordinal) || name.StartsWith("WeaponItem_", StringComparison.Ordinal))
									{
										break;
									}
									switch (name)
									{
									default:
										if (!(name == "TransformExplorerScroll"))
										{
											switch (name)
											{
											case "WeaponListScrollbar":
												((Graphic)val4).color = new Color(0.025f, 0.032f, 0.044f, 1f);
												break;
											case "Handle":
												((Graphic)val4).color = new Color(0.22f, 0.27f, 0.34f, 1f);
												break;
											case "Fill":
												((Graphic)val4).color = val3;
												break;
											case "TransformDeletePart":
												((Graphic)val4).color = new Color(0.3f, 0.075f, 0.085f, 1f);
												break;
											default:
												if (name.StartsWith("MaterialChoice_", StringComparison.Ordinal) || name.StartsWith("ModelPartChoice_", StringComparison.Ordinal) || name.StartsWith("PrefabChoice_", StringComparison.Ordinal))
												{
													((Graphic)val4).color = (Color)((((Component)val4).transform.GetSiblingIndex() % 2 == 0) ? val2 : new Color(0.1f, 0.125f, 0.16f, 1f));
												}
												else if ((Object)(object)((Component)val4).gameObject.GetComponent<InputField>() != (Object)null)
												{
													((Graphic)val4).color = color5;
												}
												else if ((Object)(object)((Component)val4).gameObject.GetComponent<Slider>() != (Object)null)
												{
													((Graphic)val4).color = new Color(0.055f, 0.07f, 0.09f, 1f);
												}
												else if ((Object)(object)((Component)val4).gameObject.GetComponent<Button>() != (Object)null)
												{
													((Graphic)val4).color = val;
												}
												else if (name.IndexOf("Panel", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Window", StringComparison.OrdinalIgnoreCase) >= 0)
												{
													((Graphic)val4).color = color3;
												}
												else if (name == "WeaponPreviewBorder")
												{
													((Graphic)val4).color = color6;
												}
												else
												{
													((Graphic)val4).color = new Color(0.035f, 0.043f, 0.058f, 1f);
												}
												break;
											}
											break;
										}
										goto case "Viewport";
									case "Viewport":
									case "ColorPickerPartsViewport":
									case "PrefabPickerViewport":
									case "ModelPartPickerViewport":
									case "ProjectilePickerViewport":
									case "ProjectilePickerContent":
									case "ColorPickerPartsContent":
									case "TransformExplorerListFrame":
										((Graphic)val4).color = new Color(0.014f, 0.018f, 0.025f, 1f);
										break;
									}
								}
								break;
							}
							goto case "WeaponSettingsPanel";
						case "WeaponSettingsPanel":
						case "ColorPickerWindow":
						case "EffectColorPickerPanel":
						case "ProjectileColorPickerPanel":
						case "ProjectilePickerPanel":
						case "PrefabPickerPanel":
							((Graphic)val4).color = color3;
							break;
						}
					}
					if (ShouldUseRoundedCorners(name) || (Object)(object)((Component)val4).gameObject.GetComponent<Button>() != (Object)null || (Object)(object)((Component)val4).gameObject.GetComponent<InputField>() != (Object)null || (Object)(object)((Component)val4).gameObject.GetComponent<Slider>() != (Object)null)
					{
						ApplyRoundedCorners(val4);
					}
					continue;
				case "EffectPaletteSwatch":
				case "PaletteSwatch":
				case "EffectColorSwatch":
				case "ProjectileColorSwatch":
				case "ProjectilePaletteSwatch":
					break;
				}
			}
			if (name == "EffectColorSwatch" || name == "ProjectileColorSwatch" || name == "ColorPickerSwatch")
			{
				ApplyRoundedCorners(val4);
			}
		}
		Text[] componentsInChildren2 = editorCanvas.GetComponentsInChildren<Text>(true);
		Text[] array2 = componentsInChildren2;
		foreach (Text val5 in array2)
		{
			if (!((Object)(object)val5 == (Object)null))
			{
				if (((Object)((Component)val5).gameObject).name == "TransformXHeader")
				{
					((Graphic)val5).color = new Color(0.95f, 0.43f, 0.4f, 1f);
				}
				else if (((Object)((Component)val5).gameObject).name == "TransformYHeader")
				{
					((Graphic)val5).color = new Color(0.42f, 0.82f, 0.5f, 1f);
				}
				else if (((Object)((Component)val5).gameObject).name == "TransformZHeader")
				{
					((Graphic)val5).color = new Color(0.42f, 0.63f, 1f, 1f);
				}
				else
				{
					((Graphic)val5).color = Color.white;
				}
			}
		}
		Button[] componentsInChildren3 = editorCanvas.GetComponentsInChildren<Button>(true);
		Button[] array3 = componentsInChildren3;
		foreach (Button val6 in array3)
		{
			if ((Object)(object)val6 == (Object)null)
			{
				continue;
			}
			string name2 = ((Object)((Component)val6).gameObject).name;
			if (!name2.StartsWith("EffectPaletteColor_", StringComparison.Ordinal) && !name2.StartsWith("ProjectilePaletteColor_", StringComparison.Ordinal) && !name2.StartsWith("MaterialChoice_Palette_", StringComparison.Ordinal) && !name2.StartsWith("ExplorerRow_", StringComparison.Ordinal) && !name2.StartsWith("WeaponItem_", StringComparison.Ordinal))
			{
				Image component = ((Component)val6).GetComponent<Image>();
				Color val7 = ((name2.StartsWith("MaterialChoice_", StringComparison.Ordinal) || name2.StartsWith("ModelPartChoice_", StringComparison.Ordinal) || name2.StartsWith("PrefabChoice_", StringComparison.Ordinal) || name2.StartsWith("ProjectileChoice_", StringComparison.Ordinal)) ? val2 : val);
				ColorBlock colors = ((Selectable)val6).colors;
				((ColorBlock)(ref colors)).normalColor = val7;
				((ColorBlock)(ref colors)).highlightedColor = new Color(0.105f, 0.125f, 0.155f, 1f);
				((ColorBlock)(ref colors)).pressedColor = val3;
				((ColorBlock)(ref colors)).selectedColor = new Color(0.075f, 0.19f, 0.285f, 1f);
				((ColorBlock)(ref colors)).disabledColor = new Color(0.035f, 0.04f, 0.05f, 0.75f);
				if (name2 == "TransformDeletePart")
				{
					((ColorBlock)(ref colors)).normalColor = new Color(0.3f, 0.075f, 0.085f, 1f);
					((ColorBlock)(ref colors)).highlightedColor = new Color(0.43f, 0.1f, 0.12f, 1f);
					((ColorBlock)(ref colors)).pressedColor = new Color(0.2f, 0.045f, 0.055f, 1f);
					((ColorBlock)(ref colors)).selectedColor = new Color(0.35f, 0.075f, 0.09f, 1f);
					((ColorBlock)(ref colors)).disabledColor = new Color(0.1f, 0.055f, 0.06f, 0.7f);
				}
				((Selectable)val6).colors = colors;
				if ((Object)(object)component != (Object)null && name2 != "TransformDeletePart" && !name2.StartsWith("WeaponItem_", StringComparison.Ordinal) && !name2.StartsWith("MaterialChoice_", StringComparison.Ordinal) && !name2.StartsWith("ModelPartChoice_", StringComparison.Ordinal) && !name2.StartsWith("PrefabChoice_", StringComparison.Ordinal) && !name2.StartsWith("ProjectileChoice_", StringComparison.Ordinal))
				{
					((Graphic)component).color = val7;
				}
				if ((Object)(object)component != (Object)null)
				{
					ApplyRoundedCorners(component);
				}
			}
		}
		InputField[] componentsInChildren4 = editorCanvas.GetComponentsInChildren<InputField>(true);
		InputField[] array4 = componentsInChildren4;
		foreach (InputField val8 in array4)
		{
			if (!((Object)(object)val8 == (Object)null))
			{
				Image component2 = ((Component)val8).GetComponent<Image>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Graphic)component2).color = color5;
					ApplyRoundedCorners(component2);
				}
				if ((Object)(object)val8.textComponent != (Object)null)
				{
					((Graphic)val8.textComponent).color = color;
				}
				Graphic placeholder = val8.placeholder;
				Text val9 = (Text)(object)((placeholder is Text) ? placeholder : null);
				if ((Object)(object)val9 != (Object)null)
				{
					((Graphic)val9).color = color2;
				}
			}
		}
		ApplyDarkUiOutlines();
	}

	private void CreateSettingsPanel(Transform parent)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Expected O, but got Unknown
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Expected O, but got Unknown
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Expected O, but got Unknown
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: 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_0186: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Expected O, but got Unknown
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: 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_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04df: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0502: Expected O, but got Unknown
		//IL_0519: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Unknown result type (might be due to invalid IL or missing references)
		//IL_052d: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0552: Unknown result type (might be due to invalid IL or missing references)
		//IL_0574: Unknown result type (might be due to invalid IL or missing references)
		//IL_0583: Unknown result type (might be due to invalid IL or missing references)
		//IL_0588: Unknown result type (might be due to invalid IL or missing references)
		//IL_0597: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05df: Unknown result type (might be due to invalid IL or missing references)
		//IL_062e: Unknown result type (might be due to invalid IL or missing references)
		//IL_063d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0649: Unknown result type (might be due to invalid IL or missing references)
		//IL_0650: Unknown result type (might be due to invalid IL or missing references)
		//IL_0656: Unknown result type (might be due to invalid IL or missing references)
		//IL_0659: Unknown result type (might be due to invalid IL or missing references)
		//IL_065f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0665: Expected O, but got Unknown
		//IL_067c: Unknown result type (might be due to invalid IL or missing references)
		//IL_068b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0690: Unknown result type (might be due to invalid IL or missing references)
		//IL_069f: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0702: Unknown result type (might be due to invalid IL or missing references)
		//IL_0708: Unknown result type (might be due to invalid IL or missing references)
		//IL_070e: Expected O, but got Unknown
		//IL_0742: Unknown result type (might be due to invalid IL or missing references)
		//IL_0751: Unknown result type (might be due to invalid IL or missing references)
		//IL_0756: Unknown result type (might be due to invalid IL or missing references)
		//IL_0765: Unknown result type (might be due to invalid IL or missing references)
		//IL_077b: Unknown result type (might be due to invalid IL or missing references)
		//IL_079e: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0803: Unknown result type (might be due to invalid IL or missing references)
		//IL_0809: Expected O, but got Unknown
		//IL_0820: Unknown result type (might be due to invalid IL or missing references)
		//IL_082f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0834: Unknown result type (might be due to invalid IL or missing references)
		//IL_0843: Unknown result type (might be due to invalid IL or missing references)
		//IL_0859: Unknown result type (might be due to invalid IL or missing references)
		//IL_087b: Unknown result type (might be due to invalid IL or missing references)
		//IL_088a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0896: Unknown result type (might be due to invalid IL or missing references)
		//IL_089d: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b2: Expected O, but got Unknown
		//IL_08c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_08eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f1: 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_08fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0900: Expected O, but got Unknown
		//IL_0918: Unknown result type (might be due to invalid IL or missing references)
		//IL_0927: Unknown result type (might be due to invalid IL or missing references)
		//IL_092c: Unknown result type (might be due to invalid IL or missing references)
		//IL_093b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0951: Unknown result type (might be due to invalid IL or missing references)
		//IL_0977: Unknown result type (might be due to invalid IL or missing references)
		//IL_0986: Unknown result type (might be due to invalid IL or missing references)
		//IL_098b: Unknown result type (might be due to invalid IL or missing references)
		//IL_099a: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a18: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a27: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a3b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a51: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a74: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a83: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ac8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b06: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b10: Expected O, but got Unknown
		//IL_0b27: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b36: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b42: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b49: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b52: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b58: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b5e: Expected O, but got Unknown
		CreatePanel(parent, "WeaponSettingsPanel", new Vector2(0.275f, 0.025f), new Vector2(0.575f, 0.635f), Vector2.zero, Vector2.zero, new Color(0.88f, 0.89f, 0.9f, 0.97f));
		CreateButton(parent, "TabStats", "STATS", new Vector2(0.325f, 0.602f), new Vector2(60f, 28f), (UnityAction)delegate
		{
			SetSettingsTab("STATS");
		});
		CreateButton(parent, "TabColor", "COLOR", new Vector2(0.375f, 0.602f), new Vector2(60f, 28f), (UnityAction)delegate
		{
			SetSettingsTab("COLOR");
			OpenColorPicker();
		});
		CreateButton(parent, "TabFX", "FX", new Vector2(0.425f, 0.602f), new Vector2(60f, 28f), (UnityAction)delegate
		{
			SetSettingsTab("FX");
		});
		CreateButton(parent, "TabSkill", "SKILL", new Vector2(0.475f, 0.602f), new Vector2(60f, 28f), (UnityAction)delegate
		{
			SetSettingsTab("SKILL");
		});
		CreateButton(parent, "TabShot", "SHOT", new Vector2(0.525f, 0.602f), new Vector2(60f, 28f), (UnityAction)delegate
		{
			SetSettingsTab("SHOT");
		});
		colorHexInput = CreateSettingRow(parent, "ColorHex", "Color #", 0.515f, "FFFFFF");
		if ((Object)(object)colorHexInput != (Object)null)
		{
			((Component)colorHexInput).gameObject.SetActive(false);
		}
		Transform val = parent.Find("ColorHexLabel");
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(false);
		}
		CreateLabel(parent, "ColorPickerHint", "Pick a model part and tune its color.", new Vector2(0.425f, 0.485f), new Vector2(0.425f, 0.485f), Vector2.zero, new Vector2(250f, 58f), 13, new Color(0.25f, 0.27f, 0.29f), (TextAnchor)4);
		damageInput = CreateSettingRow(parent, "Damage", "Damage", 0.515f, "80");
		cooldownInput = CreateSettingRow(parent, "Cooldown", "Cooldown", 0.477f, "1");
		meleeForceInput = CreateSettingRow(parent, "MeleeForce", "Force", 0.439f, "100");
		if ((Object)(object)meleeForceInput != (Object)null)
		{
			((UnityEvent<string>)(object)meleeForceInput.onValueChanged).AddListener((UnityAction<string>)delegate
			{
				if (!isPopulatingSettings)
				{
					overrideMeleeForce = true;
				}
			});
		}
		projectileDamageInput = CreateSettingRow(parent, "ProjectileDamage", "Shot Dmg", 0.401f, "80");
		projectileSpeedInput = CreateSettingRow(parent, "ProjectileSpeed", "Shot Speed", 0.363f, "30");
		projectileGravityInput = CreateSettingRow(parent, "ProjectileGravity", "Gravity", 0.325f, "15");
		projectileDragInput = CreateSettingRow(parent, "ProjectileDrag", "Drag", 0.287f, "0");
		weaponScaleSlider = CreateScaleSliderRow(parent, "WeaponScale", "Weapon Scale", 0.238f);
		effectScaleSlider = CreateScaleSliderRow(parent, "EffectScale", "Particle/Skill", 0.188f);
		((UnityEvent<float>)(object)weaponScaleSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float value)
		{
			if (!isPopulatingSettings && !updatingScaleControls)
			{
				customWeaponScale = ScaleFromSlider(value);
				UpdateScaleValueLabels();
				if ((Object)(object)previewModel != (Object)null)
				{
					ApplyPreviewScale(customWeaponScale);
					UpdateStatus("Weapon scale " + FormatFloat(customWeaponScale) + "x — press APPLY, then SAVE");
				}
				ScheduleCurrentWeaponDraftSave();
			}
		});
		((UnityEvent<float>)(object)effectScaleSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float value)
		{
			if (!isPopulatingSettings && !updatingScaleControls)
			{
				customEffectScale = ScaleFromSlider(value);
				UpdateScaleValueLabels();
				UpdateStatus("Particle/Skill scale " + FormatFloat(customEffectScale) + "x — press APPLY, then SAVE");
				ScheduleCurrentWeaponDraftSave();
			}
		});
		UnityAction<string> val2 = delegate
		{
			if (!isPopulatingSettings)
			{
				applyProjectileSettings = true;
			}
		};
		((UnityEvent<string>)(object)projectileDamageInput.onValueChanged).AddListener(val2);
		((UnityEvent<string>)(object)projectileSpeedInput.onValueChanged).AddListener(val2);
		((UnityEvent<string>)(object)projectileGravityInput.onValueChanged).AddListener(val2);
		((UnityEvent<string>)(object)projectileDragInput.onValueChanged).AddListener(val2);
		CreateEffectPickerRow(parent, "ReplacementEffect", "Hit FX", 0.505f, "Particle / effect / skill", explosions: false);
		CreateButton(parent, "EffectModeToggle", "HIT", new Vector2(0.49f, 0.455f), new Vector2(125f, 26f), new UnityAction(ToggleEffectMode), new Color(0.8f, 0.82f, 0.84f, 1f), new Color(0.16f, 0.18f, 0.2f, 1f));
		CreateLabel(parent, "EffectModeHint", "Trigger mode: Hit or Always", new Vector2(0.385f, 0.455f), new Vector2(0.385f, 0.455f), Vector2.zero, new Vector2(95f, 28f), 10, new Color(0.25f, 0.27f, 0.29f), (TextAnchor)3);
		CreateLabel(parent, "EffectColorLabel", "FX / SKILL Color", new Vector2(0.335f, 0.405f), new Vector2(0.335f, 0.405f), Vector2.zero, new Vector2(90f, 23f), 12, new Color(0.25f, 0.27f, 0.29f), (TextAnchor)3);
		effectColorHexInput = CreateInputField(parent, "EffectColorHexInput", "FFFFFF", new Vector2(0.465f, 0.405f), new Vector2(82f, 24f));
		effectColorHexInput.characterLimit = 6;
		((UnityEvent<string>)(object)effectColorHexInput.onEndEdit).AddListener((UnityAction<string>)delegate(string value)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			if (TryParseHexColor(value, out var color))
			{
				selectedEffectBaseColor = color;
				string textWithoutNotify = ColorToHex(color);
				effectColorHexInput.SetTextWithoutNotify(textWithoutNotify);
				if ((Object)(object)effectColorPickerBackdrop != (Object)null)
				{
					UpdateEffectColorPickerPreview(color);
					RefreshEffectColorPaletteHighlight();
					UpdateEffectBrightnessLabel();
				}
				applyEffectColor = true;
				Transform val3 = (((Object)(object)editorCanvas != (Object)null) ? editorCanvas.transform.Find("EffectTintToggle") : null);
				Text val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponentInChildren<Text>(true) : null);
				if ((Object)(object)val4 != (Object)null)
				{
					val4.text = "ON";
				}
				if ((Object)(object)previewModel != (Object)null)
				{
					ApplySettingsToPreview();
				}
				ScheduleCurrentWeaponDraftSave();
			}
		});
		CreateButton(parent, "EffectColorPickerButton", "PALETTE", new Vector2(0.548f, 0.405f), new Vector2(44f, 24f), new UnityAction(OpenEffectColorPicker));
		CreateLabel(parent, "EffectTintStateLabel", "Tint", new Vector2(0.335f, 0.36f), new Vector2(0.335f, 0.36f), Vector2.zero, new Vector2(90f, 23f), 12, new Color(0.25f, 0.27f, 0.29f), (TextAnchor)3);
		CreateButton(parent, "EffectTintToggle", "OFF", new Vector2(0.49f, 0.36f), new Vector2(125f, 24f), new UnityAction(ToggleEffectColor));
		CreateEffectPickerRow(parent, "SkillEffect", "Skill / Burst", 0.505f, "Game or mod skill", explosions: true);
		CreateLabel(parent, "ReplacementProjectileLabel", "Projectile", new Vector2(0.335f, 0.515f), new Vector2(0.335f, 0.515f), Vector2.zero, new Vector2(112f, 24f), 12, new Color(0.91f, 0.93f, 0.96f), (TextAnchor)3);
		replacementProjectileInput = CreateInputField(parent, "ReplacementProjectileInput", "Original projectile", new Vector2(0.455f, 0.515f), new Vector2(112f, 25f));
		CreateButton(parent, "ReplacementProjectileBrowse", "BROWSE", new Vector2(0.575f, 0.515f), new Vector2(66f, 25f), new UnityAction(OpenProjectilePicker));
		CreateLabel(parent, "ProjectileColorLabel", "Projectile Color", new Vector2(0.335f, 0.445f), new Vector2(0.335f, 0.445f), Vector2.zero, new Vector2(112f, 24f), 12, new Color(0.91f, 0.93f, 0.96f), (TextAnchor)3);
		CreateButton(parent, "ProjectileTintToggle", "OFF", new Vector2(0.465f, 0.445f), new Vector2(58f, 24f), new UnityAction(ToggleProjectileColor));
		CreateButton(parent, "ProjectileColorPickerButton", "PALETTE", new Vector2(0.54f, 0.445f), new Vector2(66f, 24f), new UnityAction(OpenProjectileColorPicker));
		projectileColorSummaryText = CreateLabel(parent, "ProjectileColorSummary", "#FFFFFF  •  1.00×", new Vector2(0.415f, 0.395f), new Vector2(0.415f, 0.395f), Vector2.zero, new Vector2(205f, 24f), 12, new Color(0.76f, 0.82f, 0.89f), (TextAnchor)4);
		CreateLabel(parent, "ProjectileCountLabel", "Amount", new Vector2(0.335f, 0.355f), new Vector2(0.335f, 0.355f), Vector2.zero, new Vector2(112f, 24f), 12, new Color(0.91f, 0.93f, 0.96f), (TextAnchor)3);
		projectileCountInput = CreateInputField(parent, "ProjectileCountInput", "1 - 20", new Vector2(0.49f, 0.355f), new Vector2(70f, 25f));
		projectileCountInput.text = "1";
		CreateLabel(parent, "ProjectileSizeLabel", "Shot Size (x)", new Vector2(0.335f, 0.315f), new Vector2(0.335f, 0.315f), Vector2.zero, new Vector2(112f, 24f), 12, new Color(0.91f, 0.93f, 0.96f), (TextAnchor)3);
		projectileSizeInput = CreateInputField(parent, "ProjectileSizeInput", "0.1 - 10", new Vector2(0.49f, 0.315f), new Vector2(70f, 25f));
		projectileSizeInput.text = "1";
		CreateButton(parent, "ApplyProperties", "APPLY", new Vector2(0.39f, 0.105f), new Vector2(95f, 30f), new UnityAction(ApplySettingsToPreview), new Color(0.78f, 0.81f, 0.83f, 1f), new Color(0.13f, 0.15f, 0.17f, 1f));
		CreateButton(parent, "ReloadProperties", "LOAD", new Vector2(0.49f, 0.105f), new Vector2(95f, 30f), new UnityAction(ReloadSelectedSettings));
	}

	private void HookSettingsDraftAutosave()
	{
		UnityAction<string> val = delegate
		{
			if (!isPopulatingSettings && !((Object)(object)previewModel == (Object)null) && !((Object)(object)editorCanvas == (Object)null))
			{
				ScheduleCurrentWeaponDraftSave();
			}
		};
		InputField[] array = (InputField[])(object)new InputField[13]
		{
			damageInput, cooldownInput, meleeForceInput, projectileDamageInput, projectileSpeedInput, projectileGravityInput, projectileDragInput, replacementEffectInput, replacementExplosionInput, replacementProjectileInput,
			effectColorHexInput, projectileCountInput, projectileSizeInput
		};
		InputField[] array2 = array;
		foreach (InputField val2 in array2)
		{
			if ((Object)(object)val2 != (Object)null)
			{
				((UnityEvent<string>)(object)val2.onEndEdit).AddListener(val);
			}
		}
	}

	private Slider CreateScaleSliderRow(Transform parent, string key, string labelText, float y)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: 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: Expected O, but got Unknown
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Expected O, but got Unknown
		//IL_0142: 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_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Expected O, but got Unknown
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: 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_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Expected O, but got Unknown
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Expected O, but got Unknown
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: 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_0324: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03da: Unknown result type (might be due to invalid IL or missing references)
		CreateLabel(parent, key + "Label", labelText, new Vector2(0.335f, y), new Vector2(0.335f, y), Vector2.zero, new Vector2(104f, 23f), 12, new Color(0.12f, 0.13f, 0.14f, 1f), (TextAnchor)3);
		GameObject val = new GameObject(key + "Slider");
		val.transform.SetParent(parent, false);
		RectTransform val2 = val.AddComponent<RectTransform>();
		val2.anchorMin = new Vector2(0.485f, y);
		val2.anchorMax = new Vector2(0.485f, y);
		val2.anchoredPosition = Vector2.zero;
		val2.sizeDelta = new Vector2(122f, 18f);
		Image val3 = val.AddComponent<Image>();
		((Graphic)val3).color = new Color(0.76f, 0.78f, 0.8f, 1f);
		ApplyRoundedCorners(val3);
		GameObject val4 = new GameObject("FillArea");
		val4.transform.SetParent(val.transform, false);
		RectTransform val5 = val4.AddComponent<RectTransform>();
		val5.anchorMin = Vector2.zero;
		val5.anchorMax = Vector2.one;
		val5.offsetMin = new Vector2(4f, 4f);
		val5.offsetMax = new Vector2(-4f, -4f);
		GameObject val6 = new GameObject("Fill");
		val6.transform.SetParent(val4.transform, false);
		RectTransform val7 = val6.AddComponent<RectTransform>();
		val7.anchorMin = Vector2.zero;
		val7.anchorMax = Vector2.one;
		val7.offsetMin = Vector2.zero;
		val7.offsetMax = Vector2.zero;
		Image val8 = val6.AddComponent<Image>();
		((Graphic)val8).color = new Color(0.27f, 0.34f, 0.39f, 1f);
		ApplyRoundedCorners(val8);
		GameObject val9 = new GameObject("HandleArea");
		val9.transform.SetParent(val.transform, false);
		RectTransform val10 = val9.AddComponent<RectTransform>();
		val10.anchorMin = Vector2.zero;
		val10.anchorMax = Vector2.one;
		val10.offsetMin = new Vector2(4f, 0f);
		val10.offsetMax = new Vector2(-4f, 0f);
		GameObject val11 = new GameObject("Handle");
		val11.transform.SetParent(val9.transform, false);
		RectTransform val12 = val11.AddComponent<RectTransform>();
		val12.anchorMin = new Vector2(0f, 0.5f);
		val12.anchorMax = new Vector2(0f, 0.5f);
		val12.anchoredPosition = Vector2.zero;
		val12.sizeDelta = new Vector2(12f, 18f);
		Image val13 = val11.AddComponent<Image>();
		((Graphic)val13).color = new Color(0.08f, 0.09f, 0.1f, 1f);
		ApplyRoundedCorners(val13);
		Slider val14 = val.AddComponent<Slider>();
		((Selectable)val14).interactable = true;
		((Selectable)val14).transition = (Transition)1;
		((Selectable)val14).targetGraphic = (Graphic)(object)val3;
		val14.fillRect = val7;
		val14.handleRect = val12;
		val14.direction = (Direction)0;
		val14.minValue = 0f;
		val14.maxValue = 1f;
		val14.wholeNumbers = false;
		val14.value = ScaleToSliderValue(1f);
		InputField val15 = CreateInputField(parent, key + "Value", "1", new Vector2(0.552f, y), new Vector2(48f, 22f));
		val15.characterLimit = 20;
		val15.contentType = (ContentType)3;
		((UnityEvent<string>)(object)val15.onEndEdit).AddList