Decompiled source of SketchbookPlus v1.4.3

Mods/SketchbookPlus.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
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.Text;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRUMBLE.CharacterCreation.Interactable;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Utilities;
using MelonLoader;
using MelonLoader.Preferences;
using RumbleModdingAPI.RMAPI;
using SketchbookPlus;
using UIFramework;
using UIFramework.UiExtensions;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(main), "SketchbookPlus", "1.4.3", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 6, true)]
[assembly: MelonAdditionalDependencies(new string[] { "UIFramework" })]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3b03f008-9dbb-4382-a110-b59ee8b632ca")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SketchbookPlus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f6de3d790784d9f601574e417b9619d6c4e92bfc")]
[assembly: AssemblyProduct("SketchbookPlus")]
[assembly: AssemblyTitle("SketchbookPlus")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SketchbookPlus;

public static class BuildInfo
{
	public const string ModName = "SketchbookPlus";

	public const string ModVersion = "1.4.3";

	public const string Author = "UlvakSkillz";
}
public class main : MelonMod
{
	private static Random random = new Random(DateTime.Now.Millisecond * DateTime.Now.Second * DateTime.Now.Minute);

	private static List<string> acceptedFiles = new List<string>();

	private static List<string> failedFiles = new List<string>();

	private static List<string> pendingFiles = new List<string>();

	private static List<string> acceptedFilesTexts = new List<string>();

	private static List<string> pendingFilesTexts = new List<string>();

	private static List<List<int>> acceptedItems = new List<List<int>>();

	private bool randomizerInit = false;

	private static int lastOutfit = -1;

	private static DressingRoom dressingRoom = null;

	private static void Log(string msg)
	{
		MelonLogger.Msg(msg);
	}

	private static void debugLog(string msg)
	{
		if (Preferences.PrefDebugging.Value)
		{
			MelonLogger.Msg("-" + msg);
		}
	}

	public override void OnLateInitializeMelon()
	{
		if (!Directory.Exists("UserData\\SketchbookPlus"))
		{
			Directory.CreateDirectory("UserData\\SketchbookPlus");
		}
		if (!Directory.Exists("UserData\\SketchbookPlus\\Stored"))
		{
			Directory.CreateDirectory("UserData\\SketchbookPlus\\Stored");
		}
		if (!File.Exists("UserData\\SketchbookPlus\\BlackListedItems.txt"))
		{
			saveFile("", "UserData\\SketchbookPlus\\BlackListedItems.txt", addAcceptedFile: false);
		}
		Actions.onMapInitialized += mapInit;
		Actions.onPlayerSpawned += playerJoined;
		pendingFiles.Clear();
		acceptedFiles.Clear();
		failedFiles.Clear();
	}

	public override void OnInitializeMelon()
	{
		Preferences.InitPrefs();
		UI.RegisterMelon((MelonBase)(object)this, (MelonPreferences_Category[])(object)new MelonPreferences_Category[3]
		{
			Preferences.SketchbookPlusCategory,
			Preferences.SaveLoadCategory,
			Preferences.RandomizerCategory
		});
	}

	internal static void UpdateFiles()
	{
		debugLog("Clearing Known Files");
		pendingFiles.Clear();
		acceptedFiles.Clear();
		failedFiles.Clear();
		pendingFilesTexts.Clear();
		acceptedFilesTexts.Clear();
		while (Preferences.loadOutfitList.Count > 0)
		{
			Preferences.loadOutfitList.RemoveAt(0);
		}
		debugLog("Rechecking Files");
		recheckFiles();
	}

	internal static void SaveOutfit()
	{
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Expected O, but got Unknown
		if (!Preferences.PrefSavedOutfitName.EditedValue.ToLower().EndsWith(".txt"))
		{
			MelonPreferences_Entry<string> prefSavedOutfitName = Preferences.PrefSavedOutfitName;
			prefSavedOutfitName.EditedValue += ".txt";
		}
		Preferences.PrefSavedOutfitName.Value = Preferences.PrefSavedOutfitName.EditedValue;
		debugLog("Saving Outfit: UserData\\SketchbookPlus\\" + Preferences.PrefSavedOutfitName.EditedValue);
		string outfitString = getOutfitString(dressingRoom.VisualData);
		debugLog("File Text: " + outfitString);
		bool flag = !File.Exists("UserData\\SketchbookPlus\\" + Preferences.PrefSavedOutfitName.EditedValue);
		saveFile(outfitString, "UserData\\SketchbookPlus\\" + Preferences.PrefSavedOutfitName.EditedValue);
		if (flag)
		{
			acceptedFiles.Add("UserData\\SketchbookPlus\\" + Preferences.PrefSavedOutfitName.EditedValue);
			acceptedFilesTexts.Add(outfitString);
			Preferences.loadOutfitList.Add(new DropdownItem(Preferences.PrefSavedOutfitName.EditedValue.Replace("UserData\\SketchbookPlus\\", string.Empty).Replace(".txt", string.Empty), (object)Preferences.PrefSavedOutfitName.EditedValue.Replace("UserData\\SketchbookPlus\\", string.Empty).Replace(".txt", string.Empty)));
		}
	}

	internal static void LoadFileOutfit()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		Scene activeScene = SceneManager.GetActiveScene();
		if (!(((Scene)(ref activeScene)).name != "Gym"))
		{
			PlayerVisualData visualData = dressingRoom.VisualData;
			debugLog("Loading Outfit: " + Preferences.PrefOutfitNameToLoad.EditedValue);
			LoadOutfit("UserData\\SketchbookPlus\\" + ((Preferences.PrefOutfitNameToLoad.EditedValue != null && Preferences.PrefOutfitNameToLoad.EditedValue != "") ? Preferences.PrefOutfitNameToLoad.EditedValue : Preferences.PrefOutfitNameToLoad.Value) + ".txt");
		}
	}

	internal static void LoadRandomFileOutfit()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		Scene activeScene = SceneManager.GetActiveScene();
		if (!(((Scene)(ref activeScene)).name != "Gym"))
		{
			PlayerVisualData visualData = dressingRoom.VisualData;
			int num = random.Next(0, acceptedFiles.Count);
			while (num == lastOutfit && acceptedFiles.Count > 1)
			{
				num = random.Next(0, acceptedFiles.Count);
			}
			debugLog("Loading Random: " + acceptedFiles[num]);
			LoadOutfit(acceptedFiles[num]);
			lastOutfit = num;
		}
	}

	internal static void LoadRandomOutfit()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		Scene activeScene = SceneManager.GetActiveScene();
		if (((Scene)(ref activeScene)).name != "Gym")
		{
			return;
		}
		PlayerVisualData visualData = dressingRoom.VisualData;
		debugLog("Starting Randomizer");
		string[] array = getOutfitString(visualData).Split(",");
		debugLog("Got Original Outfit");
		int[] array2 = new int[20]
		{
			0, 1, 2, 28, 29, 30, 31, 32, 33, 34,
			35, 36, 37, 58, 59, 60, 61, 62, 63, 64
		};
		int[] array3 = new int[6] { 3, 4, 5, 6, 7, 8 };
		int[] array4 = new int[30]
		{
			9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
			38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
			48, 49, 50, 51, 52, 53, 54, 55, 56, 57
		};
		int[] array5 = new int[9] { 19, 20, 21, 22, 23, 24, 25, 26, 27 };
		string[] array6 = new string[array2.Length + array3.Length + array4.Length + array5.Length + 1];
		debugLog("Set PVD Variable Spots");
		for (int i = 0; i < array.Length; i++)
		{
			array6[i] = array[i];
		}
		debugLog("Updated New PVD Variables");
		for (int j = 0; j < array2.Length + array3.Length + array4.Length + array5.Length; j++)
		{
			if ((Preferences.PrefRandomizerIdentity.EditedValue && array2.Contains(j)) || (Preferences.PrefRandomizerArmorColors.EditedValue && array3.Contains(j)) || (Preferences.PrefArmorItems.EditedValue && array5.Contains(j)) || (Preferences.PrefRandomizerMarkings.EditedValue && array4.Contains(j)))
			{
				array6[j] = acceptedItems[j][random.Next(0, acceptedItems[j].Count)].ToString();
			}
		}
		array6[^1] = (Preferences.PrefRandomizerGender.EditedValue ? random.Next(1, 3).ToString() : array[^1]);
		debugLog("Outfit Ready to Set");
		setPVD(visualData, array6);
		Log("Randomizer Outfit Set: " + getOutfitString(visualData));
		dressingRoom.UpdatePlayerVisuals(true);
	}

	private static void recheckFiles()
	{
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Expected O, but got Unknown
		string[] files = Directory.GetFiles("UserData\\SketchbookPlus");
		string[] array = files;
		foreach (string text in array)
		{
			if (!(text == "UserData\\SketchbookPlus\\config.cfg") && !(text == "UserData\\SketchbookPlus\\BlackListedItems.txt") && !failedFiles.Contains(text) && !acceptedFiles.Contains(text))
			{
				debugLog("Pending File: " + text);
				pendingFiles.Add(text);
			}
		}
		loadFileTexts();
		while (pendingFiles.Count > 0)
		{
			if (!CheckFileValidity(pendingFiles[0]))
			{
				Log("Removing Bad File: " + pendingFiles[0]);
				Log("Removing Bad File's Text: " + pendingFilesTexts[0]);
				failedFiles.Add(pendingFiles[0]);
				pendingFiles.Remove(pendingFiles[0]);
				pendingFilesTexts.RemoveAt(0);
			}
			else
			{
				debugLog("Accepting file: " + pendingFiles[0]);
				acceptedFiles.Add(pendingFiles[0]);
				acceptedFilesTexts.Add(pendingFilesTexts[0]);
				Preferences.loadOutfitList.Add(new DropdownItem(pendingFiles[0].Replace("UserData\\SketchbookPlus\\", string.Empty).Replace(".txt", string.Empty), (object)pendingFiles[0].Replace("UserData\\SketchbookPlus\\", string.Empty).Replace(".txt", string.Empty)));
				pendingFiles.Remove(pendingFiles[0]);
				pendingFilesTexts.RemoveAt(0);
			}
		}
		debugLog("Done Rechecking Files");
	}

	private static void saveFile(string textToSave, string file, bool addAcceptedFile = true)
	{
		if (!File.Exists(file))
		{
			acceptedFiles.Add(file);
		}
		FileStream fileStream = File.Create(file);
		byte[] bytes = Encoding.UTF8.GetBytes(textToSave);
		fileStream.Write(bytes);
		fileStream.Close();
		fileStream.Dispose();
		Log("Saving " + file + " Complete");
	}

	private void playerJoined(Player player)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Invalid comparison between Unknown and I4
		if (Preferences.PrefStoreOthersOutfits.Value && (int)player.Controller.controllerType == 2)
		{
			MelonCoroutines.Start(checkPlayer(player));
		}
	}

	private IEnumerator checkPlayer(Player player)
	{
		debugLog("Storing Player");
		yield return (object)new WaitForSeconds(1f);
		string visuals = getOutfitString(player.Data.VisualData);
		string name = player.Data.GeneralData.PublicUsername;
		if (name.Contains("<") || name.Contains(">") || name.Contains(":"))
		{
			name = name.Replace("<", "_");
			name = name.Replace(">", "_");
			name = name.Replace(":", "_");
		}
		if (!File.Exists("UserData\\SketchbookPlus\\Stored\\" + name + ".txt"))
		{
			debugLog("Saving " + name + "'s Model");
		}
		else
		{
			debugLog("Found Existing " + name + "'s Model, Overriding Text");
		}
		saveFile(visuals, "UserData\\SketchbookPlus\\Stored\\" + name + ".txt");
	}

	private void setupRandomizer()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		debugLog("Setting Up Randomizer");
		int num = 50;
		PlayerVisualData visualData = dressingRoom.VisualData;
		PlayerVisualData val = new PlayerVisualData(visualData);
		setPVD(val, visualData);
		string outfitString = getOutfitString(visualData);
		string[] array = outfitString.Split(",");
		int[] array2 = new int[array.Length];
		for (int i = 0; i < array.Length; i++)
		{
			array2[i] = int.Parse(array[i]);
		}
		for (int j = 0; j < array.Length - 1; j++)
		{
			List<int> list = new List<int>();
			string text = "Spot " + j + ": ";
			for (int k = 0; k <= num; k++)
			{
				array2[j] = k;
				string[] array3 = new string[array2.Length];
				for (int l = 0; l < array3.Length; l++)
				{
					array3[l] = array2[l].ToString();
				}
				setPVD(val, array3);
				if (checkItems(val.ToPlayfabDataString(), isSilent: true))
				{
					list.Add(k);
					text = text + k + ", ";
				}
			}
			acceptedItems.Add(list);
			debugLog(text);
			for (int m = 0; m < array.Length; m++)
			{
				array2[m] = int.Parse(array[m]);
			}
		}
		setupBlackList();
		debugLog("Randomizer Setup");
		randomizerInit = true;
	}

	private void setupBlackList()
	{
		string[] array = File.ReadAllLines("UserData\\SketchbookPlus\\BlackListedItems.txt");
		try
		{
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split(",");
				if (acceptedItems[int.Parse(array3[0])].Remove(int.Parse(array3[1])))
				{
					Log("Removed Item: " + text);
				}
			}
		}
		catch
		{
			MelonLogger.Error("Error Reading BlackList File");
		}
	}

	private static string getOutfitString(PlayerVisualData pvd)
	{
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Invalid comparison between Unknown and I4
		string text = "";
		for (int i = 0; i < ((Il2CppArrayBase<short>)(object)pvd.ColorationIndexes).Count; i++)
		{
			text = text + ((Il2CppArrayBase<short>)(object)pvd.ColorationIndexes)[i] + ",";
		}
		for (int j = 0; j < ((Il2CppArrayBase<short>)(object)pvd.CustomizationPartIndexes).Count; j++)
		{
			text = text + ((Il2CppArrayBase<short>)(object)pvd.CustomizationPartIndexes)[j] + ",";
		}
		for (int k = 0; k < ((Il2CppArrayBase<short>)(object)pvd.OtherCustomizationIndexes).Count; k++)
		{
			text = text + ((Il2CppArrayBase<short>)(object)pvd.OtherCustomizationIndexes)[k] + ",";
		}
		for (int l = 0; l < ((Il2CppArrayBase<short>)(object)pvd.TextureCustomizationIndexes).Count; l++)
		{
			text = text + ((Il2CppArrayBase<short>)(object)pvd.TextureCustomizationIndexes)[l] + ",";
		}
		for (int m = 0; m < ((Il2CppArrayBase<short>)(object)pvd.TextureOpacityIndexes).Count; m++)
		{
			text = text + ((Il2CppArrayBase<short>)(object)pvd.TextureOpacityIndexes)[m] + ",";
		}
		for (int n = 0; n < ((Il2CppArrayBase<short>)(object)pvd.WeightAdjustementIndexes).Count; n++)
		{
			text = text + ((Il2CppArrayBase<short>)(object)pvd.WeightAdjustementIndexes)[n] + ",";
		}
		return text + (((int)pvd.Identity == 1) ? "1" : "2");
	}

	private static void LoadOutfit(string fileName)
	{
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		if (acceptedFiles.IndexOf(fileName) == -1)
		{
			MelonLogger.Error("Not An Accepted File: " + fileName);
			return;
		}
		Log("Text: " + acceptedFilesTexts[acceptedFiles.IndexOf(fileName)]);
		string[] data = acceptedFilesTexts[acceptedFiles.IndexOf(fileName)].Split(',');
		PlayerVisualData visualData = dressingRoom.VisualData;
		PlayerVisualData val = new PlayerVisualData(visualData);
		setPVD(val, data);
		if (checkItems(val.ToPlayfabDataString()))
		{
			debugLog("Setting PVD Now");
			setPVD(visualData, val);
			dressingRoom.UpdatePlayerVisuals(true);
			Log("Loaded Outfit: " + fileName);
		}
	}

	private static bool CheckFileValidity(string fileName)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		string[] data = pendingFilesTexts[pendingFiles.IndexOf(fileName)].Split(',');
		PlayerVisualData val = new PlayerVisualData(Singleton<PlayerManager>.instance.localPlayer.Data.VisualData);
		try
		{
			setPVD(val, data);
		}
		catch
		{
			Log("Invalid File Text");
			return false;
		}
		return checkItems(val.ToPlayfabDataString());
	}

	private static void setPVD(PlayerVisualData pvd, string[] data)
	{
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: 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)
		int num = 0;
		for (int i = 0; i < ((Il2CppArrayBase<short>)(object)pvd.ColorationIndexes).Count; i++)
		{
			((Il2CppArrayBase<short>)(object)pvd.ColorationIndexes)[i] = short.Parse(data[num]);
			num++;
		}
		for (int j = 0; j < ((Il2CppArrayBase<short>)(object)pvd.CustomizationPartIndexes).Count; j++)
		{
			((Il2CppArrayBase<short>)(object)pvd.CustomizationPartIndexes)[j] = short.Parse(data[num]);
			num++;
		}
		for (int k = 0; k < ((Il2CppArrayBase<short>)(object)pvd.OtherCustomizationIndexes).Count; k++)
		{
			((Il2CppArrayBase<short>)(object)pvd.OtherCustomizationIndexes)[k] = short.Parse(data[num]);
			num++;
		}
		for (int l = 0; l < ((Il2CppArrayBase<short>)(object)pvd.TextureCustomizationIndexes).Count; l++)
		{
			((Il2CppArrayBase<short>)(object)pvd.TextureCustomizationIndexes)[l] = short.Parse(data[num]);
			num++;
		}
		for (int m = 0; m < ((Il2CppArrayBase<short>)(object)pvd.TextureOpacityIndexes).Count; m++)
		{
			((Il2CppArrayBase<short>)(object)pvd.TextureOpacityIndexes)[m] = short.Parse(data[num]);
			num++;
		}
		for (int n = 0; n < ((Il2CppArrayBase<short>)(object)pvd.WeightAdjustementIndexes).Count; n++)
		{
			((Il2CppArrayBase<short>)(object)pvd.WeightAdjustementIndexes)[n] = short.Parse(data[num]);
			num++;
		}
		Gender val = (Gender)((data[num] == "1") ? 1 : 2);
		if (pvd.Identity != val)
		{
			pvd.Identity = val;
			SetGenderTo(val);
		}
	}

	private static void SetGenderTo(Gender gender)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		PlayerVisualData visualData = dressingRoom.VisualData;
		visualData.Identity = gender;
		dressingRoom.VisualData = visualData;
	}

	private static void setPVD(PlayerVisualData pvdTo, PlayerVisualData pvdFrom)
	{
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < ((Il2CppArrayBase<short>)(object)pvdTo.ColorationIndexes).Count; i++)
		{
			((Il2CppArrayBase<short>)(object)pvdTo.ColorationIndexes)[i] = ((Il2CppArrayBase<short>)(object)pvdFrom.ColorationIndexes)[i];
		}
		for (int j = 0; j < ((Il2CppArrayBase<short>)(object)pvdTo.CustomizationPartIndexes).Count; j++)
		{
			((Il2CppArrayBase<short>)(object)pvdTo.CustomizationPartIndexes)[j] = ((Il2CppArrayBase<short>)(object)pvdFrom.CustomizationPartIndexes)[j];
		}
		for (int k = 0; k < ((Il2CppArrayBase<short>)(object)pvdTo.OtherCustomizationIndexes).Count; k++)
		{
			((Il2CppArrayBase<short>)(object)pvdTo.OtherCustomizationIndexes)[k] = ((Il2CppArrayBase<short>)(object)pvdFrom.OtherCustomizationIndexes)[k];
		}
		for (int l = 0; l < ((Il2CppArrayBase<short>)(object)pvdTo.TextureCustomizationIndexes).Count; l++)
		{
			((Il2CppArrayBase<short>)(object)pvdTo.TextureCustomizationIndexes)[l] = ((Il2CppArrayBase<short>)(object)pvdFrom.TextureCustomizationIndexes)[l];
		}
		for (int m = 0; m < ((Il2CppArrayBase<short>)(object)pvdTo.TextureOpacityIndexes).Count; m++)
		{
			((Il2CppArrayBase<short>)(object)pvdTo.TextureOpacityIndexes)[m] = ((Il2CppArrayBase<short>)(object)pvdFrom.TextureOpacityIndexes)[m];
		}
		for (int n = 0; n < ((Il2CppArrayBase<short>)(object)pvdTo.WeightAdjustementIndexes).Count; n++)
		{
			((Il2CppArrayBase<short>)(object)pvdTo.WeightAdjustementIndexes)[n] = ((Il2CppArrayBase<short>)(object)pvdFrom.WeightAdjustementIndexes)[n];
		}
		pvdTo.Identity = pvdFrom.Identity;
	}

	private static bool checkItems(string tempPVDEconomyDataString, bool isSilent = false)
	{
		string[] array = tempPVDEconomyDataString.Split(':');
		bool flag = true;
		for (int i = 0; i < array.Length; i++)
		{
			if (i == 0 || i == 5)
			{
				continue;
			}
			string[] array2 = array[i].Split(",");
			string[] array3 = array2;
			foreach (string text in array3)
			{
				if (!Singleton<PlayerManager>.instance.localPlayer.Data.EconomyData.ReceivedItems.Contains(text))
				{
					flag = false;
					if (!isSilent)
					{
						Log("Item Not Redeemed");
					}
					break;
				}
			}
			if (!flag)
			{
				break;
			}
		}
		if (flag)
		{
			return true;
		}
		return false;
	}

	private void mapInit(string map)
	{
		debugLog("RMAPI triggered MapInit");
		if (map == "Gym")
		{
			debugLog("Map is Gym");
			dressingRoom = DressingRoom.GetGameObject().GetComponent<DressingRoom>();
			recheckFiles();
			if (!randomizerInit)
			{
				debugLog("Setting up Randomizer");
				setupRandomizer();
			}
			PlayerVisualData visualData = dressingRoom.VisualData;
			if (Preferences.PrefOutfitTypeToRandomize.EditedValue == OutfitTypes.RandomFromFilesOutfit)
			{
				LoadRandomFileOutfit();
			}
			else if (Preferences.PrefOutfitTypeToRandomize.EditedValue == OutfitTypes.RandomizerOutfit)
			{
				LoadRandomOutfit();
			}
		}
	}

	private static void loadFileTexts()
	{
		foreach (string pendingFile in pendingFiles)
		{
			string text = File.ReadAllText(pendingFile);
			if (text.Split(",").Length == 65)
			{
				text += ",1";
			}
			pendingFilesTexts.Add(text);
		}
	}
}
public enum OutfitTypes
{
	[Display(Name = "None")]
	None,
	[Display(Name = "Random Outfit From Files")]
	RandomFromFilesOutfit,
	[Display(Name = "Randomizer Outfit")]
	RandomizerOutfit
}
public class Preferences
{
	private const string CONFIG_FILE = "config.cfg";

	private const string USER_DATA = "UserData/SketchbookPlus/";

	internal static Dictionary<MelonPreferences_Entry, object> LastSavedValues = new Dictionary<MelonPreferences_Entry, object>();

	internal static MelonPreferences_Category SketchbookPlusCategory;

	internal static MelonPreferences_Entry<bool> PrefStoreOthersOutfits;

	internal static MelonPreferences_Entry<bool> PrefDebugging;

	internal static MelonPreferences_Category SaveLoadCategory;

	internal static MelonPreferences_Entry<string> PrefSavedOutfitName;

	internal static List<DropdownItem> loadOutfitList = new List<DropdownItem>();

	internal static DynamicDropdownDescriptor PrefOutfitNameToLoadDescriptor = new DynamicDropdownDescriptor(loadOutfitList);

	internal static MelonPreferences_Entry<string> PrefOutfitNameToLoad;

	internal static MelonPreferences_Category RandomizerCategory;

	internal static MelonPreferences_Entry<OutfitTypes> PrefOutfitTypeToRandomize;

	internal static MelonPreferences_Entry<bool> PrefRandomizerIdentity;

	internal static MelonPreferences_Entry<bool> PrefRandomizerArmorColors;

	internal static MelonPreferences_Entry<bool> PrefArmorItems;

	internal static MelonPreferences_Entry<bool> PrefRandomizerMarkings;

	internal static MelonPreferences_Entry<bool> PrefRandomizerGender;

	internal static void InitPrefs()
	{
		if (!Directory.Exists("UserData/SketchbookPlus/"))
		{
			Directory.CreateDirectory("UserData/SketchbookPlus/");
		}
		SketchbookPlusCategory = MelonPreferences.CreateCategory("SketchbookPlus", "Settings");
		SketchbookPlusCategory.SetFilePath(Path.Combine("UserData/SketchbookPlus/", "config.cfg"));
		PrefStoreOthersOutfits = SketchbookPlusCategory.CreateEntry<bool>("StoreOthersOutfits", false, "Store Others Outfits", "Set to True to Store Other Player's Cosmetics to UserData/SketchBookPlus/Stored", false, false, (ValueValidator)null, (string)null);
		UI.CreateButtonEntry(SketchbookPlusCategory, "Update Files", "Updates the Files List", "", (Action)delegate
		{
			main.UpdateFiles();
		});
		PrefDebugging = SketchbookPlusCategory.CreateEntry<bool>("Debugging", false, "Enable Debugging Logs", "Set to True to Show Logs", false, false, (ValueValidator)null, (string)null);
		SaveLoadCategory = MelonPreferences.CreateCategory("SaveAndLoad", "Save & Load");
		SaveLoadCategory.SetFilePath(Path.Combine("UserData/SketchbookPlus/", "config.cfg"));
		PrefSavedOutfitName = SaveLoadCategory.CreateEntry<string>("SavedOutfitName", "DefaultName", "Saved Outfit Name", "File Name To Save Under", false, false, (ValueValidator)null, (string)null);
		UI.CreateButtonEntry(SaveLoadCategory, "Save", "Save Outfit", "", (Action)delegate
		{
			main.SaveOutfit();
		});
		PrefOutfitNameToLoad = SaveLoadCategory.CreateEntry<string>("OutfitNameToLoad", "", "Outfit to Load from File", "File Name To Load", false, false, (ValueValidator)(object)PrefOutfitNameToLoadDescriptor);
		UI.CreateButtonEntry(SaveLoadCategory, "Load", "Load Outfit", "", (Action)delegate
		{
			main.LoadFileOutfit();
		});
		UI.CreateButtonEntry(SaveLoadCategory, "File Randomize", "Select Random File Outfit", "", (Action)delegate
		{
			main.LoadRandomFileOutfit();
		});
		UI.CreateButtonEntry(SaveLoadCategory, "Randomizer Randomize", "Select Random Outfit from Randomizer", "", (Action)delegate
		{
			main.LoadRandomOutfit();
		});
		RandomizerCategory = MelonPreferences.CreateCategory("GymLoadRandomizer", "Randomizer Settings");
		RandomizerCategory.SetFilePath(Path.Combine("UserData/SketchbookPlus/", "config.cfg"));
		PrefOutfitTypeToRandomize = RandomizerCategory.CreateEntry<OutfitTypes>("OutfitTypeToRandomize", OutfitTypes.None, "Outfit Type to Randomize", "Selects what type of Outfit type to randomize with", false, false, (ValueValidator)null, (string)null);
		PrefRandomizerIdentity = RandomizerCategory.CreateEntry<bool>("RandomizerIdentity", false, "Identity", "(Sets in Gym) Sets the Player's Identity to a Randomized Selection", false, false, (ValueValidator)null, (string)null);
		PrefRandomizerArmorColors = RandomizerCategory.CreateEntry<bool>("RandomizerArmorColors", true, "Armor Colors", "(Sets in Gym) Sets the Player's Armor Colors to a Randomized Selection", false, false, (ValueValidator)null, (string)null);
		PrefArmorItems = RandomizerCategory.CreateEntry<bool>("RandomizerArmorItems", false, "Armor Items", "(Sets in Gym) Sets the Player's Armor Items to a Randomized Selection", false, false, (ValueValidator)null, (string)null);
		PrefRandomizerMarkings = RandomizerCategory.CreateEntry<bool>("RandomizerMarkings", false, "Markings", "(Sets in Gym) Sets the Player's Markings to a Randomized Selection", false, false, (ValueValidator)null, (string)null);
		PrefRandomizerGender = RandomizerCategory.CreateEntry<bool>("RandomizerGender", false, "Gender", "(Sets in Gym) Sets the Player's Gender to a Randomized Selection", false, false, (ValueValidator)null, (string)null);
	}
}