using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.Kirshoo.PersonalWardrobe")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0+63e7f96e7a8b86ebf3481de1f25cc947d603dccd")]
[assembly: AssemblyProduct("com.github.Kirshoo.PersonalWardrobe")]
[assembly: AssemblyTitle("PersonalWardrobe")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.5.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace PersonalWardrobe
{
internal static class ColorUtil
{
public static Color FromRGB(int red, int green, int blue)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
return FromRGB(red, green, blue, 1f);
}
public static Color FromRGB(int red, int green, int blue, float alpha)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
red = Math.Clamp(red, 0, 255);
green = Math.Clamp(green, 0, 255);
blue = Math.Clamp(blue, 0, 255);
return new Color((float)red / 255f, (float)green / 255f, (float)blue / 255f, alpha);
}
}
public class Loadout
{
[JsonProperty("name")]
public string Name { get; set; } = string.Empty;
[JsonProperty("skin")]
public int SkinIndex { get; set; }
[JsonProperty("accessory")]
public int AccessoryIndex { get; set; }
[JsonProperty("hat")]
public int HatIndex { get; set; }
[JsonProperty("outfit")]
public int OutfitIndex { get; set; }
[JsonProperty("eyes")]
public int EyesIndex { get; set; }
[JsonProperty("mouth")]
public int MouthIndex { get; set; }
[JsonProperty("sash")]
public int SashIndex { get; set; }
public static bool Equals(Loadout lhs, Loadout rhs)
{
return lhs.Name == rhs.Name;
}
public static bool Equals(Loadout lhs, string name)
{
return lhs.Name == name;
}
}
public class Wardrobe
{
[JsonProperty("version")]
public int Version = 1;
[JsonProperty("wardrobe")]
public List<Loadout> Loadouts = new List<Loadout>();
}
[BepInPlugin("com.github.Kirshoo.PersonalWardrobe", "PersonalWardrobe", "0.5.0")]
public class Plugin : BaseUnityPlugin
{
public static readonly string configFolder = Path.Combine(Paths.ConfigPath, "PersonalWardrobe");
public static readonly string loadoutsPath = Path.Combine(configFolder, "wardrobe.json");
public static readonly string loadoutsBackupPath = Path.Combine(configFolder, "~wardrobe.json");
internal static ConfigEntry<KeyCode> toggleMenuButton = null;
private GameObject menuObj;
private WardrobeMenu menu;
public const string Id = "com.github.Kirshoo.PersonalWardrobe";
internal static ManualLogSource Log { get; private set; } = null;
private Wardrobe Wardrobe { get; set; }
public static string Name => "PersonalWardrobe";
public static string Version => "0.5.0";
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
try
{
WardrobeManager.Instance.EnsureWardrobe();
}
catch (Exception ex)
{
Log.LogError((object)("Wardrobe Load error: " + ex.Message));
throw;
}
toggleMenuButton = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ToggleMenu", (KeyCode)290, "Button to toggle Wardrobe UI");
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void OnApplicationQuit()
{
WardrobeManager.SaveWardrobeToFile();
}
private void Start()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
menuObj = new GameObject("Wardrobe");
Object.DontDestroyOnLoad((Object)(object)menuObj);
menu = menuObj.AddComponent<WardrobeMenu>();
}
private void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(toggleMenuButton.Value))
{
menu.ToggleOpen();
}
}
}
internal class WardrobeManager
{
private static WardrobeManager _instance;
private Wardrobe wardrobe;
public const string DefaultLoadoutName = "Loadout Template";
public static WardrobeManager Instance
{
get
{
if (_instance == null)
{
_instance = new WardrobeManager();
}
return _instance;
}
}
public Wardrobe Wardrobe
{
get
{
EnsureWardrobe();
return wardrobe;
}
}
public WardrobeManager()
{
if (_instance == null)
{
_instance = this;
LoadWardrobe();
}
}
public void LoadWardrobe()
{
Directory.CreateDirectory(Plugin.configFolder);
if (!File.Exists(Plugin.loadoutsPath))
{
Wardrobe wardrobe = new Wardrobe();
File.WriteAllText(Plugin.loadoutsPath, JsonConvert.SerializeObject((object)wardrobe, (Formatting)1));
Plugin.Log.LogInfo((object)"Created a default wardrobe file.");
}
string text = File.ReadAllText(Plugin.loadoutsPath);
this.wardrobe = JsonConvert.DeserializeObject<Wardrobe>(text);
if (this.wardrobe == null)
{
throw new FileLoadException("Deserialization returned null");
}
Plugin.Log.LogInfo((object)$"Loaded wardrobe: v{this.wardrobe.Version}.");
}
public void EnsureWardrobe()
{
if (wardrobe == null)
{
LoadWardrobe();
}
}
public void SaveWardrobe(Loadout loadout)
{
Loadout loadout2 = loadout;
EnsureWardrobe();
int num = wardrobe.Loadouts.FindIndex((Loadout other) => Loadout.Equals(other, loadout2));
if (num == -1)
{
wardrobe.Loadouts.Add(loadout2);
}
else
{
wardrobe.Loadouts[num] = loadout2;
}
File.WriteAllText(Plugin.loadoutsBackupPath, JsonConvert.SerializeObject((object)wardrobe, (Formatting)1));
Plugin.Log.LogInfo((object)"Wardrobe is saved.");
}
public static void SaveWardrobeToFile()
{
if (File.Exists(Plugin.loadoutsBackupPath))
{
string contents = File.ReadAllText(Plugin.loadoutsBackupPath);
File.WriteAllText(Plugin.loadoutsPath, contents);
File.Delete(Plugin.loadoutsBackupPath);
Plugin.Log.LogInfo((object)"Backup removed and main file is up to date.");
}
}
public Loadout GetLoadout(string name)
{
string name2 = name;
EnsureWardrobe();
Loadout loadout = wardrobe.Loadouts.Find((Loadout x) => Loadout.Equals(x, name2));
if (loadout == null)
{
Plugin.Log.LogWarning((object)("Unable to find \"" + name2 + "\" loadout. Returning default."));
return new Loadout
{
Name = name2
};
}
return loadout;
}
public Loadout GetLoadout(int index)
{
EnsureWardrobe();
if (index >= wardrobe.Loadouts.Count)
{
Plugin.Log.LogWarning((object)"Index is out of bounds. Returning default.");
return new Loadout
{
Name = "Loadout Template"
};
}
return wardrobe.Loadouts[index];
}
}
internal class WardrobeMenu : MenuWindow
{
public GameObject uiObject;
private Canvas canvas;
private WardrobeManager manager;
private Loadout currentLoadout;
private const int LoadoutCount = 3;
public override bool openOnStart => false;
public override bool closeOnPause => true;
public WardrobeMenu()
{
manager = WardrobeManager.Instance;
currentLoadout = manager.GetLoadout(0);
CreateUI();
}
public void CreateUI()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_00fc: 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_0128: 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_014c: 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_0162: Expected O, but got Unknown
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Expected O, but got Unknown
//IL_0210: 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_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Expected O, but got Unknown
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Expected O, but got Unknown
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_03fe: Expected O, but got Unknown
//IL_042b: Unknown result type (might be due to invalid IL or missing references)
//IL_0382: Unknown result type (might be due to invalid IL or missing references)
//IL_0389: Expected O, but got Unknown
//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
//IL_03f2: Expected O, but got Unknown
//IL_0460: 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_04ad: Unknown result type (might be due to invalid IL or missing references)
uiObject = new GameObject("WardrobeMenu");
canvas = uiObject.AddComponent<Canvas>();
canvas.renderMode = (RenderMode)0;
uiObject.AddComponent<CanvasScaler>();
uiObject.AddComponent<GraphicRaycaster>();
Object.DontDestroyOnLoad((Object)(object)uiObject);
GameObject val = new GameObject("WardrobeBackground");
val.transform.SetParent(((Component)canvas).transform, false);
RectTransform val2 = val.AddComponent<RectTransform>();
val2.anchorMin = new Vector2(0.5f, 0.5f);
val2.anchorMax = new Vector2(0.5f, 0.5f);
val2.pivot = new Vector2(0.5f, 0.5f);
val2.anchoredPosition = Vector2.zero;
GameObject val3 = new GameObject("WardrobeBackgroundDim");
val3.transform.SetParent(val.transform, false);
Image val4 = val3.AddComponent<Image>();
((Graphic)val4).color = new Color(0f, 0f, 0f, 0.8f);
RectTransform component = ((Component)val4).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
component.sizeDelta = new Vector2((float)Screen.width, (float)Screen.height);
GameObject val5 = new GameObject("WardrobeBackgroundImage");
val5.transform.SetParent(val.transform, false);
Image val6 = val5.AddComponent<Image>();
((Graphic)val6).color = ColorUtil.FromRGB(223, 218, 194);
RectTransform component2 = ((Component)val6).GetComponent<RectTransform>();
component2.sizeDelta = new Vector2(600f, 200f);
component2.anchoredPosition = Vector2.zero;
val3.transform.SetAsFirstSibling();
val5.transform.SetAsLastSibling();
GameObject val7 = new GameObject("ButtonContainer");
val7.transform.SetParent(val5.transform, false);
RectTransform val8 = val7.AddComponent<RectTransform>();
val8.anchorMin = new Vector2(0.5f, 0.5f);
val8.anchorMax = new Vector2(0.5f, 0.5f);
val8.sizeDelta = new Vector2(500f, 40f);
val8.anchoredPosition = Vector2.zero;
HorizontalLayoutGroup val9 = val7.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val9).spacing = 170f;
((LayoutGroup)val9).childAlignment = (TextAnchor)4;
((HorizontalOrVerticalLayoutGroup)val9).childForceExpandWidth = false;
((HorizontalOrVerticalLayoutGroup)val9).childForceExpandHeight = false;
val7.AddComponent<ContentSizeFitter>().horizontalFit = (FitMode)2;
for (int i = 0; i < manager.Wardrobe.Loadouts.Count; i++)
{
GameObject val10 = new GameObject($"WardrobeButton{i}");
val10.transform.SetParent(val7.transform, false);
RectTransform val11 = val10.AddComponent<RectTransform>();
val11.sizeDelta = new Vector2(150f, 80f);
string loadoutName = manager.GetLoadout(i).Name;
Button val12 = CreateWardrobeButton(val10, loadoutName);
((UnityEvent)val12.onClick).AddListener((UnityAction)delegate
{
Plugin.Log.LogDebug((object)("Loadout " + loadoutName + " button pressed!"));
if (currentLoadout != null && Loadout.Equals(currentLoadout, loadoutName))
{
Plugin.Log.LogWarning((object)"Selected current loadout. Do nothing.");
}
else
{
SwitchLoadout(loadoutName);
}
});
}
if (manager.Wardrobe.Loadouts.Count < 3)
{
GameObject val13 = new GameObject("AddLoadout");
val13.transform.SetParent(val7.transform, false);
RectTransform val14 = val13.AddComponent<RectTransform>();
val14.sizeDelta = new Vector2(150f, 80f);
string addLoadoutText = "Add Loadout";
Button val15 = CreateWardrobeButton(val13, addLoadoutText);
((UnityEvent)val15.onClick).AddListener((UnityAction)delegate
{
Plugin.Log.LogDebug((object)("Loadout " + addLoadoutText + " button pressed!"));
SaveLoadout(string.Format("{0} #{1}", "Loadout Template", manager.Wardrobe.Loadouts.Count + 1));
if (manager.Wardrobe.Loadouts.Count + 1 < 3)
{
currentLoadout = WardrobeManager.Instance.GetLoadout(string.Format("{0} #{1}", "Loadout Template", manager.Wardrobe.Loadouts.Count + 1));
}
Object.Destroy((Object)(object)uiObject);
CreateUI();
});
}
GameObject val16 = new GameObject("WardrobeText");
val16.transform.SetParent(((Component)canvas).transform, false);
TextMeshProUGUI val17 = val16.AddComponent<TextMeshProUGUI>();
((TMP_Text)val17).text = $"In Wardrobe Menu - Press {Plugin.toggleMenuButton.Value} to exit";
TMP_FontAsset val18 = Resources.Load<TMP_FontAsset>("DarumaDropOne-Regular");
if ((Object)(object)val18 != (Object)null)
{
((TMP_Text)val17).font = val18;
}
((Graphic)val17).color = Color.white;
((TMP_Text)val17).fontSize = 28f;
((TMP_Text)val17).alignment = (TextAlignmentOptions)514;
RectTransform component3 = ((Component)val17).GetComponent<RectTransform>();
component3.sizeDelta = new Vector2(600f, 100f);
component3.anchoredPosition = new Vector2(0f, 200f);
}
private Button CreateWardrobeButton(GameObject buttonObj, string loadoutName)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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_010c: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Background");
val.transform.SetParent(buttonObj.transform, false);
Image val2 = val.AddComponent<Image>();
((Graphic)val2).color = Color.white;
((Graphic)val2).rectTransform.sizeDelta = new Vector2(150f, 80f);
val.transform.SetAsFirstSibling();
Button result = buttonObj.AddComponent<Button>();
GameObject val3 = new GameObject("ButtonText");
val3.transform.SetParent(buttonObj.transform, false);
TextMeshProUGUI val4 = val3.AddComponent<TextMeshProUGUI>();
((TMP_Text)val4).text = loadoutName;
((TMP_Text)val4).overflowMode = (TextOverflowModes)0;
((TMP_Text)val4).textWrappingMode = (TextWrappingModes)1;
((Graphic)val4).color = Color.black;
((TMP_Text)val4).fontSize = 28f;
((TMP_Text)val4).alignment = (TextAlignmentOptions)514;
RectTransform component = ((Component)val4).GetComponent<RectTransform>();
Vector2 val5 = default(Vector2);
((Vector2)(ref val5))..ctor(0.5f, 0.5f);
component.pivot = val5;
Vector2 anchorMin = (component.anchorMax = val5);
component.anchorMin = anchorMin;
component.sizeDelta = new Vector2(150f, 40f);
component.anchoredPosition = Vector2.zero;
return result;
}
private void SaveLoadout(string loadoutName)
{
Plugin.Log.LogDebug((object)"Overriding saved loadout with current cosmetics.");
CharacterCustomizationData customizationData = CharacterCustomization.GetCustomizationData(PhotonNetwork.LocalPlayer);
if (customizationData == null)
{
Plugin.Log.LogError((object)"Unable to retreive current cosmetics data.");
return;
}
Loadout loadout = new Loadout
{
Name = loadoutName,
SkinIndex = customizationData.currentSkin,
AccessoryIndex = customizationData.currentAccessory,
EyesIndex = customizationData.currentEyes,
MouthIndex = customizationData.currentMouth,
HatIndex = customizationData.currentHat,
OutfitIndex = customizationData.currentOutfit,
SashIndex = customizationData.currentSash
};
manager.SaveWardrobe(loadout);
}
private void LoadLoadout(string loadoutName)
{
Plugin.Log.LogDebug((object)"Overriding current cosmetics with saved loadout.");
Loadout loadout = manager.GetLoadout(loadoutName);
if (loadout == null)
{
Plugin.Log.LogError((object)("Unable to find loadout with name " + loadoutName));
return;
}
CharacterCustomization.SetCharacterSkinColor(loadout.SkinIndex);
CharacterCustomization.SetCharacterAccessory(loadout.AccessoryIndex);
CharacterCustomization.SetCharacterEyes(loadout.EyesIndex);
CharacterCustomization.SetCharacterMouth(loadout.MouthIndex);
CharacterCustomization.SetCharacterHat(loadout.HatIndex);
CharacterCustomization.SetCharacterOutfit(loadout.OutfitIndex);
CharacterCustomization.SetCharacterSash(loadout.SashIndex);
currentLoadout = loadout;
}
public void SwitchLoadout(string newLayoutName)
{
SaveLoadout(currentLoadout.Name);
LoadLoadout(newLayoutName);
}
public void Awake()
{
uiObject.SetActive(false);
}
public void ToggleOpen()
{
if (!((MenuWindow)this).isOpen)
{
((MenuWindow)this).Open();
uiObject.SetActive(true);
}
else
{
((MenuWindow)this).Close();
}
}
public override void OnClose()
{
uiObject.SetActive(false);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}