Decompiled source of MorePalette v1.0.6

MorePalette.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using FhpSLib;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MorePalette")]
[assembly: AssemblyDescription("More Palette for TABS")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("MorePalette")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("MorePalette")]
[assembly: ComVisible(false)]
[assembly: Guid("3a45c3cf-230c-4310-952f-0887d4266a22")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.6.0")]
[module: UnverifiableCode]
namespace MorePalette;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("GeeztJeez.MorePalette", "MorePalette", "1.0.6")]
internal class Loader : BaseUnityPlugin
{
	public static string modName;

	private Sprite mainIcon;

	private AssetBundle bundle;

	private static HashSet<int> usedIDs;

	private Material sharedDynamicMaterial;

	public static string shortModName;

	private void Awake()
	{
		((MonoBehaviour)this).StartCoroutine(Call());
	}

	private IEnumerator Call()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
		yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
		new Harmony("MorePalette").PatchAll();
		bundle = LoadBundle("morepaletteassetsbundle");
		if ((Object)(object)bundle != (Object)null)
		{
			mainIcon = bundle.LoadAsset<Sprite>("placeholder_paintpalette");
			Init();
		}
	}

	public AssetBundle LoadBundle(string name)
	{
		Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
		if (manifestResourceStream == null)
		{
			return null;
		}
		return AssetBundle.LoadFromStream(manifestResourceStream);
	}

	private void Init()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Expected O, but got Unknown
		//IL_00a4: 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_0114: Expected O, but got Unknown
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Expected O, but got Unknown
		//IL_01c8: 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_0238: Expected O, but got Unknown
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0404: Unknown result type (might be due to invalid IL or missing references)
		//IL_0418: Unknown result type (might be due to invalid IL or missing references)
		//IL_041d: Unknown result type (might be due to invalid IL or missing references)
		//IL_042a: Unknown result type (might be due to invalid IL or missing references)
		//IL_042c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_0465: Unknown result type (might be due to invalid IL or missing references)
		//IL_0497: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
		sharedDynamicMaterial = new Material(Shader.Find("Standard"));
		sharedDynamicMaterial.enableInstancing = true;
		SetOpaque(sharedDynamicMaterial);
		Material mat = bundle.LoadAsset<Material>("MPT_AuraMaterial");
		Material material = bundle.LoadAsset<Material>("InvisibleMaterial");
		Material mat2 = bundle.LoadAsset<Material>("FlatMaterial");
		Material material2 = bundle.LoadAsset<Material>("FlatBlackMaterial");
		Material val = new Material(Shader.Find("Standard"));
		((Object)val).name = "MP-Grey-Transparent";
		val.color = new Color(0.5f, 0.5f, 0.5f, 0.5f);
		val.SetOverrideTag("RenderType", "Transparent");
		val.SetFloat("_Mode", 3f);
		val.SetInt("_SrcBlend", 5);
		val.SetInt("_DstBlend", 10);
		val.EnableKeyword("_ALPHABLEND_ON");
		val.renderQueue = 3000;
		Material val2 = new Material(Shader.Find("Standard"));
		((Object)val2).name = "MP-Black-Transparent";
		val2.color = new Color(0f, 0f, 0f, 0.5f);
		val2.SetOverrideTag("RenderType", "Transparent");
		val2.SetFloat("_Mode", 3f);
		val2.SetInt("_SrcBlend", 5);
		val2.SetInt("_DstBlend", 10);
		val2.EnableKeyword("_ALPHABLEND_ON");
		val2.renderQueue = 3000;
		Material val3 = new Material(Shader.Find("Standard"));
		((Object)val3).name = "MP-White-Transparent";
		val3.color = new Color(1f, 1f, 1f, 0.5f);
		val3.SetOverrideTag("RenderType", "Transparent");
		val3.SetFloat("_Mode", 3f);
		val3.SetInt("_SrcBlend", 5);
		val3.SetInt("_DstBlend", 10);
		val3.EnableKeyword("_ALPHABLEND_ON");
		val3.renderQueue = 3000;
		Material val4 = new Material(Shader.Find("Standard"));
		((Object)val4).name = "MP-Glow-White";
		val4.color = new Color(2f, 2f, 2f, 2f);
		List<ColorPaletteCatagory> list = new List<ColorPaletteCatagory>();
		list.Add(new ColorPaletteCatagory
		{
			name = shortModName + " Miscs & Old",
			shardImage = mainIcon,
			Cataogry = (CatagoryType)0,
			Colors = (ColorPaletteData[])(object)new ColorPaletteData[6]
			{
				new ColorPaletteData
				{
					ColorIndex = 7544323,
					m_color = new Color(0.5f, 0.5f, 0.5f, 0.5f),
					m_material = material
				},
				new ColorPaletteData
				{
					ColorIndex = 3423223,
					m_color = new Color(0.5f, 0.5f, 0.5f, 0.5f),
					m_material = val
				},
				new ColorPaletteData
				{
					ColorIndex = 34232112,
					m_color = new Color(0.1f, 0.1f, 0.1f, 0.5f),
					m_material = val2
				},
				new ColorPaletteData
				{
					ColorIndex = 6435322,
					m_color = new Color(0.9f, 0.9f, 0.9f, 0.5f),
					m_material = val3
				},
				new ColorPaletteData
				{
					ColorIndex = 5663424,
					m_color = new Color(2f, 2f, 2f),
					m_material = val4
				},
				new ColorPaletteData
				{
					ColorIndex = 6435211,
					m_color = Color.black,
					m_material = material2
				}
			}
		});
		list.Add(GenerateOthersVariant("Aura Rainbow", 15000000, mat, 180, 1f, 1f, 1f));
		list.Add(GenerateOthersVariant("Aura Greyscale", 15100000, mat, 180, 0f, 1f, 1f, isGreyscale: true));
		list.Add(GenerateOthersVariant("Flat Rainbow", 15200000, mat2, 180, 1f, 1f, 1f));
		list.Add(GenerateOthersVariant("Flat Greyscale", 15300000, mat2, 180, 0f, 1f, 1f, isGreyscale: true));
		InsertToGame(shortModName + " Others", mainIcon, list.ToArray());
		ColorPaletteCatagory[] kids = GenerateSurfaceBrightVariants(1000000, 180, 2, 3, 4, 1f);
		InsertToGame(shortModName + " Bright Opaque", mainIcon, kids);
		ColorPaletteCatagory[] kids2 = GenerateSurfaceBrightnessVariants(2000000, 360, 2, 2, 1, 6, 0.1f, 0.9f);
		InsertToGame(shortModName + " Dark Opaque", mainIcon, kids2);
		ColorPaletteCatagory[] kids3 = GenerateUniqueVariants(4000000, 360, 5, 0.15f, 0.45f, 0.9f, 2, 2);
		InsertToGame(shortModName + " Unique Opaque", mainIcon, kids3);
		float[] transparentAlphas = new float[6] { 0.9f, 0.75f, 0.6f, 0.45f, 0.3f, 0.15f };
		float[] transparentAlphas2 = new float[12]
		{
			0.95f, 0.9f, 0.82f, 0.75f, 0.68f, 0.6f, 0.52f, 0.45f, 0.38f, 0.3f,
			0.22f, 0.15f
		};
		ColorPaletteCatagory[] kids4 = GenerateTransparentNormal(5000000, 180, 4, 0.3f, 1f, transparentAlphas);
		InsertToGame(shortModName + " Transparent Normal", mainIcon, kids4);
		ColorPaletteCatagory[] kids5 = GenerateTransparentPastel(6000000, 180, 5, 0.15f, 0.45f, 0.9f, transparentAlphas);
		InsertToGame(shortModName + " Transparent Pastel", mainIcon, kids5);
		ColorPaletteCatagory[] kids6 = GenerateTransparentGreyscale(7000000, 180, transparentAlphas2);
		InsertToGame(shortModName + " Transparent Greyscale", mainIcon, kids6);
		float[] alphaSteps = new float[3] { 0.8f, 0.5f, 0.2f };
		InsertToGame(shortModName + " Team Normal", mainIcon, GenerateTeamVariants(10000000, 180, 2, 0.5f, 1f, 0.8f, alphaSteps, greyscale: false, emissive: false));
		InsertToGame(shortModName + " Team Classic", mainIcon, GenerateTeamVariants(16000000, 180, 2, 0.65f, 0.85f, 0.9f, alphaSteps, greyscale: false, emissive: false));
		InsertToGame(shortModName + " Team Shades", mainIcon, GenerateTeamVariants(8000000, 180, 2, 1f, 1f, 1f, alphaSteps, greyscale: false, emissive: false));
		InsertToGame(shortModName + " Team Pastel", mainIcon, GenerateTeamVariants(9000000, 180, 2, 0.4f, 0.4f, 0.95f, alphaSteps, greyscale: false, emissive: false));
		InsertToGame(shortModName + " Team Greyscale", mainIcon, GenerateTeamVariants(14000000, 180, 2, 0f, 0f, 1f, alphaSteps, greyscale: true, emissive: false));
		InsertToGame(shortModName + " Team Neon", mainIcon, GenerateTeamVariants(11000000, 180, 2, 1f, 1f, 1f, alphaSteps, greyscale: false, emissive: true));
		InsertToGame(shortModName + " Team Complementary", mainIcon, GenerateTeamVariantsExtended(12000000, 180, 0.5f, 1f, 1f, alphaSteps, emissive: false));
		InsertToGame(shortModName + " Team Analogous", mainIcon, GenerateTeamVariantsExtended(13000000, 180, 0.1f, 0.8f, 1f, alphaSteps, emissive: false));
	}

	static Loader()
	{
		modName = "More Palette";
		shortModName = "MPT";
		usedIDs = new HashSet<int>();
	}

	public static int GetSafeColorID(int requestedID)
	{
		int i;
		for (i = requestedID; usedIDs.Contains(i); i++)
		{
		}
		usedIDs.Add(i);
		return i;
	}

	private void SetOpaque(Material mat)
	{
		mat.SetFloat("_Mode", 0f);
		mat.SetInt("_SrcBlend", 1);
		mat.SetInt("_DstBlend", 0);
		mat.SetInt("_ZWrite", 1);
		mat.DisableKeyword("_ALPHATEST_ON");
		mat.DisableKeyword("_ALPHABLEND_ON");
		mat.DisableKeyword("_ALPHAPREMULTIPLY_ON");
		mat.SetFloat("_Metallic", 0f);
		mat.SetFloat("_Glossiness", 0f);
		mat.renderQueue = -1;
	}

	public void InsertToGame(string name, Sprite icon, ColorPaletteCatagory[] kids)
	{
		//IL_0026: 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)
		UnitEditorColorPalette[] array = Resources.FindObjectsOfTypeAll<UnitEditorColorPalette>();
		foreach (UnitEditorColorPalette obj in array)
		{
			List<ParentCatagories> list = ((ParentCatagories[])OtherLibrary.GetField<UnitEditorColorPalette>(obj, "m_ColorPalleteParentCatagories")).ToList();
			list.Add(new ParentCatagories
			{
				name = name,
				colorWheelSprite = icon,
				colorPaletteCatagories = kids
			});
			OtherLibrary.SetField<UnitEditorColorPalette>(obj, "m_ColorPalleteParentCatagories", (object)list.ToArray());
			obj.Initialize();
		}
	}

	private ColorPaletteCatagory[] GenerateSurfaceBrightVariants(int baseID, int hueSteps, int metallicVariants, int smoothnessVariants, int emissionVariants, float value)
	{
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		List<ColorPaletteCatagory> list = new List<ColorPaletteCatagory>();
		int num = baseID;
		for (int i = 0; i < metallicVariants; i++)
		{
			float num2 = ((metallicVariants <= 1) ? 0f : ((float)i / (float)(metallicVariants - 1)));
			for (int j = 0; j < smoothnessVariants; j++)
			{
				float num3 = ((smoothnessVariants <= 1) ? 0f : ((float)j / (float)(smoothnessVariants - 1)));
				for (int k = 0; k < emissionVariants; k++)
				{
					float num4 = (float)k + 1f;
					string name = $"V{value:F2} M{num2:F2} S{num3:F2} E{num4:F2}";
					list.Add(GenerateRainbowSurface(name, num, hueSteps, num2, num3, num4, value));
					num += hueSteps;
				}
			}
		}
		return list.ToArray();
	}

	private ColorPaletteCatagory GenerateRainbowSurface(string name, int idStart, int hueSteps, float metallic, float smoothness, float emission, float value)
	{
		//IL_001b: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		List<ColorPaletteData> list = new List<ColorPaletteData>();
		int num = 0;
		for (int i = 0; i < hueSteps; i++)
		{
			Color val = Color.HSVToRGB((float)i / (float)hueSteps, 1f, value);
			Material val2 = new Material(sharedDynamicMaterial);
			val2.enableInstancing = true;
			SetOpaque(val2);
			val2.SetColor("_Color", val);
			val2.SetFloat("_Metallic", metallic);
			val2.SetFloat("_Glossiness", smoothness);
			if (emission > 0f)
			{
				val2.EnableKeyword("_EMISSION");
				val2.SetColor("_EmissionColor", val * emission);
			}
			list.Add(new ColorPaletteData
			{
				ColorIndex = GetSafeColorID(idStart + num),
				m_color = val,
				m_material = val2
			});
			num++;
		}
		ColorPaletteCatagory result = default(ColorPaletteCatagory);
		result.name = name;
		result.shardImage = mainIcon;
		result.Cataogry = (CatagoryType)0;
		result.Colors = list.ToArray();
		return result;
	}

	private ColorPaletteCatagory[] GenerateSurfaceBrightnessVariants(int baseID, int hueSteps, int metallicVariants, int smoothnessVariants, int emissionVariants, int brightnessSteps, float minValue, float maxValue)
	{
		List<ColorPaletteCatagory> list = new List<ColorPaletteCatagory>();
		int num = baseID;
		int num2 = 500000;
		for (int i = 0; i < brightnessSteps; i++)
		{
			_ = (float)i / (float)(brightnessSteps - 1);
			float value = ((brightnessSteps <= 1) ? maxValue : Mathf.Lerp(maxValue, minValue, (float)i / (float)(brightnessSteps - 1)));
			ColorPaletteCatagory[] collection = GenerateSurfaceBrightVariants(num, hueSteps, metallicVariants, smoothnessVariants, emissionVariants, value);
			list.AddRange(collection);
			num += num2;
		}
		return list.ToArray();
	}

	internal static float SafeFactor(int index, int steps)
	{
		if (steps > 1)
		{
			return (float)index / ((float)steps - 1f);
		}
		return 0f;
	}

	private ColorPaletteCatagory[] GenerateUniqueVariants(int baseID, int hueSteps, int pastelVariants, float pastelMinSat, float pastelMaxSat, float pastelValue, int metallic, int smoothness)
	{
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		//IL_00b4: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Expected O, but got Unknown
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		List<ColorPaletteCatagory> list = new List<ColorPaletteCatagory>();
		int num = baseID;
		int num2 = 300000;
		float[] array = new float[2] { 0f, 1f };
		float[] array2 = new float[2] { 0f, 1f };
		for (int i = 0; i < pastelVariants; i++)
		{
			float num3 = ((pastelVariants <= 1) ? 0f : ((float)i / (float)(pastelVariants - 1)));
			float num4 = Mathf.Lerp(pastelMinSat, pastelMaxSat, num3);
			for (int j = 0; j < 4; j++)
			{
				float num5 = array[j % 2];
				float num6 = array2[j / 2];
				List<ColorPaletteData> list2 = new List<ColorPaletteData>();
				for (int k = 0; k < hueSteps; k++)
				{
					Color val = Color.HSVToRGB((float)k / (float)hueSteps, num4, pastelValue);
					Material val2 = new Material(sharedDynamicMaterial);
					val2.enableInstancing = true;
					SetOpaque(val2);
					val2.SetColor("_Color", val);
					val2.SetFloat("_Metallic", num5);
					val2.SetFloat("_Glossiness", num6);
					list2.Add(new ColorPaletteData
					{
						ColorIndex = GetSafeColorID(num + k),
						m_color = val,
						m_material = val2
					});
				}
				list.Add(new ColorPaletteCatagory
				{
					name = $"Pastel Sat{num4:F2} M{num5:F0} G{num6:F0}",
					shardImage = mainIcon,
					Cataogry = (CatagoryType)0,
					Colors = list2.ToArray()
				});
				num += num2;
			}
		}
		Color val3 = default(Color);
		for (int l = 0; l < 4; l++)
		{
			float num7 = array[l % 2];
			float num8 = array2[l / 2];
			List<ColorPaletteData> list3 = new List<ColorPaletteData>();
			for (int m = 0; m < hueSteps; m++)
			{
				float num9 = ((hueSteps <= 1) ? 0f : ((float)m / (float)(hueSteps - 1)));
				((Color)(ref val3))..ctor(num9, num9, num9);
				Material val4 = new Material(sharedDynamicMaterial);
				val4.enableInstancing = true;
				SetOpaque(val4);
				val4.SetColor("_Color", val3);
				val4.SetFloat("_Metallic", num7);
				val4.SetFloat("_Glossiness", num8);
				list3.Add(new ColorPaletteData
				{
					ColorIndex = GetSafeColorID(num + m),
					m_color = val3,
					m_material = val4
				});
			}
			list.Add(new ColorPaletteCatagory
			{
				name = $"Gray M{num7:F0} G{num8:F0}",
				shardImage = mainIcon,
				Cataogry = (CatagoryType)0,
				Colors = list3.ToArray()
			});
			num += num2;
		}
		return list.ToArray();
	}

	private ColorPaletteCatagory[] GenerateTransparentPastel(int baseID, int hueSteps, int pastelVariants, float pastelMinSat, float pastelMaxSat, float pastelValue, float[] transparentAlphas)
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Expected O, but got Unknown
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: 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_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		List<ColorPaletteCatagory> list = new List<ColorPaletteCatagory>();
		int num = baseID;
		int num2 = 300000;
		for (int i = 0; i < pastelVariants; i++)
		{
			float num3 = ((pastelVariants <= 1) ? 0f : ((float)i / (float)(pastelVariants - 1)));
			float num4 = Mathf.Lerp(pastelMinSat, pastelMaxSat, num3);
			foreach (float num5 in transparentAlphas)
			{
				List<ColorPaletteData> list2 = new List<ColorPaletteData>();
				for (int k = 0; k < hueSteps; k++)
				{
					Color val = Color.HSVToRGB((float)k / (float)hueSteps, num4, pastelValue);
					val.a = num5;
					Material val2 = new Material(sharedDynamicMaterial);
					val2.enableInstancing = true;
					SetTransparent(val2);
					val2.SetColor("_Color", val);
					list2.Add(new ColorPaletteData
					{
						ColorIndex = GetSafeColorID(num + k),
						m_color = val,
						m_material = val2
					});
				}
				list.Add(new ColorPaletteCatagory
				{
					name = $"Pastel S{num4:F2} A{num5:F2}",
					shardImage = mainIcon,
					Cataogry = (CatagoryType)0,
					Colors = list2.ToArray()
				});
				num += num2;
			}
		}
		return list.ToArray();
	}

	private ColorPaletteCatagory[] GenerateTransparentGreyscale(int baseID, int valueSteps, float[] transparentAlphas)
	{
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		//IL_0075: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		List<ColorPaletteCatagory> list = new List<ColorPaletteCatagory>();
		int num = baseID;
		int num2 = 300000;
		Color val = default(Color);
		foreach (float num3 in transparentAlphas)
		{
			List<ColorPaletteData> list2 = new List<ColorPaletteData>();
			for (int j = 0; j < valueSteps; j++)
			{
				float num4 = ((valueSteps <= 1) ? 0f : ((float)j / (float)(valueSteps - 1)));
				((Color)(ref val))..ctor(num4, num4, num4, num3);
				Material val2 = new Material(sharedDynamicMaterial);
				val2.enableInstancing = true;
				SetTransparent(val2);
				val2.SetColor("_Color", val);
				list2.Add(new ColorPaletteData
				{
					ColorIndex = GetSafeColorID(num + j),
					m_color = val,
					m_material = val2
				});
			}
			list.Add(new ColorPaletteCatagory
			{
				name = $"Gray A{num3:F2}",
				shardImage = mainIcon,
				Cataogry = (CatagoryType)0,
				Colors = list2.ToArray()
			});
			num += num2;
		}
		return list.ToArray();
	}

	private ColorPaletteCatagory[] GenerateTransparentNormal(int baseID, int hueSteps, int brightnessSteps, float minValue, float maxValue, float[] transparentAlphas)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Expected O, but got Unknown
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		List<ColorPaletteCatagory> list = new List<ColorPaletteCatagory>();
		int num = baseID;
		int num2 = 300000;
		for (int i = 0; i < brightnessSteps; i++)
		{
			float num3 = ((brightnessSteps <= 1) ? 0f : ((float)i / (float)(brightnessSteps - 1)));
			float num4 = Mathf.Lerp(maxValue, minValue, num3);
			foreach (float num5 in transparentAlphas)
			{
				List<ColorPaletteData> list2 = new List<ColorPaletteData>();
				for (int k = 0; k < hueSteps; k++)
				{
					Color val = Color.HSVToRGB((float)k / (float)hueSteps, 1f, num4);
					val.a = num5;
					Material val2 = new Material(sharedDynamicMaterial);
					val2.enableInstancing = true;
					SetTransparent(val2);
					val2.SetColor("_Color", val);
					list2.Add(new ColorPaletteData
					{
						ColorIndex = GetSafeColorID(num + k),
						m_color = val,
						m_material = val2
					});
				}
				list.Add(new ColorPaletteCatagory
				{
					name = $"Normal V{num4:F2} A{num5:F2}",
					shardImage = mainIcon,
					Cataogry = (CatagoryType)0,
					Colors = list2.ToArray()
				});
				num += num2;
			}
		}
		return list.ToArray();
	}

	private void SetTransparent(Material mat)
	{
		mat.SetFloat("_Mode", 3f);
		mat.SetInt("_SrcBlend", 5);
		mat.SetInt("_DstBlend", 10);
		mat.SetInt("_ZWrite", 0);
		mat.DisableKeyword("_ALPHATEST_ON");
		mat.EnableKeyword("_ALPHABLEND_ON");
		mat.DisableKeyword("_ALPHAPREMULTIPLY_ON");
		mat.SetFloat("_Metallic", 0f);
		mat.SetFloat("_Glossiness", 0f);
		mat.renderQueue = 3000;
	}

	private ColorPaletteCatagory[] GenerateTeamVariants(int baseID, int hueSteps, int styleSteps, float minSat, float maxSat, float value, float[] alphaSteps, bool greyscale, bool emissive)
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		List<ColorPaletteCatagory> list = new List<ColorPaletteCatagory>();
		int num = baseID;
		int num2 = 300000;
		for (int i = 0; i < styleSteps; i++)
		{
			float num3 = ((styleSteps <= 1) ? 0f : ((float)i / (float)(styleSteps - 1)));
			float num4 = Mathf.Lerp(minSat, maxSat, num3);
			list.Add(GenerateTeamCategory($"Opaque S{num4:F2}", num, hueSteps, num4, value, 1f, transparent: false, greyscale, emissive));
			num += num2;
			foreach (float num5 in alphaSteps)
			{
				list.Add(GenerateTeamCategory($"Transparent S{num4:F2} A{num5:F2}", num, hueSteps, num4, value, num5, transparent: true, greyscale, emissive));
				num += num2;
			}
		}
		return list.ToArray();
	}

	private ColorPaletteCatagory GenerateTeamCategory(string name, int idStart, int shadeSteps, float saturation, float value, float alpha, bool transparent, bool greyscale, bool emissive, float secondaryHueOffset = 0.66f)
	{
		//IL_01aa: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Expected O, but got Unknown
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		List<TeamColorPaletteData> list = new List<TeamColorPaletteData>();
		float num = 0f;
		float num2 = 0.66f;
		Color val = default(Color);
		Color val2 = default(Color);
		for (int i = 0; i < shadeSteps; i++)
		{
			float num3 = ((shadeSteps <= 1) ? value : Mathf.Lerp(0.2f, value, (float)i / (float)(shadeSteps - 1)));
			if (greyscale)
			{
				float num4 = ((shadeSteps <= 1) ? 0.5f : ((float)i / ((float)shadeSteps - 1f)));
				((Color)(ref val))..ctor(num4, num4, num4, alpha);
				((Color)(ref val2))..ctor(1f - num4, 1f - num4, 1f - num4, alpha);
			}
			else
			{
				val = Color.HSVToRGB(num, saturation, num3);
				val2 = Color.HSVToRGB(num2, saturation, num3);
				val.a = alpha;
				val2.a = alpha;
			}
			Material val3 = new Material(sharedDynamicMaterial);
			Material val4 = new Material(sharedDynamicMaterial);
			if (transparent)
			{
				SetTransparent(val3);
				SetTransparent(val4);
			}
			else
			{
				SetOpaque(val3);
				SetOpaque(val4);
			}
			val3.SetColor("_Color", val);
			val4.SetColor("_Color", val2);
			if (emissive)
			{
				val3.EnableKeyword("_EMISSION");
				val4.EnableKeyword("_EMISSION");
				val3.SetColor("_EmissionColor", val * 3f);
				val4.SetColor("_EmissionColor", val2 * 3f);
			}
			int safeColorID = GetSafeColorID(idStart + i);
			list.Add(new TeamColorPaletteData
			{
				ColorIndex = safeColorID,
				m_colorRed = val,
				m_colorBlue = val2,
				m_materialRed = val3,
				m_materialBlue = val4
			});
		}
		ColorPaletteCatagory result = default(ColorPaletteCatagory);
		result.name = name;
		result.shardImage = mainIcon;
		result.Cataogry = (CatagoryType)1;
		result.TeamColors = list.ToArray();
		result.Colors = (ColorPaletteData[])(object)new ColorPaletteData[0];
		return result;
	}

	private ColorPaletteCatagory[] GenerateTeamVariantsExtended(int baseID, int hueSteps, float hueOffset, float sat, float val, float[] alphaSteps, bool emissive)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		List<ColorPaletteCatagory> list = new List<ColorPaletteCatagory>();
		int num = 100000;
		list.Add(GenerateTeamCategory("Opaque Line", baseID, hueSteps, sat, val, 1f, transparent: false, greyscale: false, emissive, hueOffset));
		int num2 = baseID + num;
		foreach (float num3 in alphaSteps)
		{
			list.Add(GenerateTeamCategory($"Alpha {num3:F2}", num2, hueSteps, sat, val, num3, transparent: true, greyscale: false, emissive, hueOffset));
			num2 += num;
		}
		return list.ToArray();
	}

	private ColorPaletteCatagory GenerateOthersVariant(string catName, int baseID, Material mat, int steps, float saturation, float value, float alpha, bool isGreyscale = false, float emissionIntensity = 0f)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		List<ColorPaletteData> list = new List<ColorPaletteData>();
		Color val = default(Color);
		for (int i = 0; i < steps; i++)
		{
			float num = ((steps <= 1) ? 0f : ((float)i / (float)(steps - 1)));
			if (isGreyscale)
			{
				((Color)(ref val))..ctor(num, num, num, alpha);
			}
			else
			{
				val = Color.HSVToRGB(num, saturation, value);
				val.a = alpha;
			}
			Material val2 = new Material(mat);
			val2.SetColor("_Color", val);
			list.Add(new ColorPaletteData
			{
				ColorIndex = GetSafeColorID(baseID + i),
				m_color = val,
				m_material = val2
			});
		}
		ColorPaletteCatagory result = default(ColorPaletteCatagory);
		result.name = catName;
		result.shardImage = mainIcon;
		result.Cataogry = (CatagoryType)0;
		result.Colors = list.ToArray();
		return result;
	}
}