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.4.0.0")]
[assembly: AssemblyInformationalVersion("0.4.0+63e7f96e7a8b86ebf3481de1f25cc947d603dccd")]
[assembly: AssemblyProduct("com.github.Kirshoo.PersonalWardrobe")]
[assembly: AssemblyTitle("PersonalWardrobe")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.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.4.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.4.0";
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
try
{
WardrobeManager.Instance.LoadWardrobe();
}
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 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 SaveWardrobe(Loadout loadout)
{
Loadout loadout2 = loadout;
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;
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)
{
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 LoadoutAmount = 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_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Expected O, but got Unknown
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Expected O, but got Unknown
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_0391: Expected O, but got Unknown
//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
//IL_0419: Unknown result type (might be due to invalid IL or missing references)
//IL_041a: 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_0434: Unknown result type (might be due to invalid IL or missing references)
//IL_0440: Unknown result type (might be due to invalid IL or missing references)
//IL_045d: Unknown result type (might be due to invalid IL or missing references)
//IL_0464: Expected O, but got Unknown
//IL_0491: 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_04fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0513: 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;
Vector2 val17 = default(Vector2);
for (int i = 0; i < 3; i++)
{
GameObject val10 = new GameObject($"WardrobeButton{i}");
val10.transform.SetParent(val7.transform, false);
RectTransform val11 = val10.AddComponent<RectTransform>();
val11.sizeDelta = new Vector2(150f, 80f);
GameObject val12 = new GameObject("Background");
val12.transform.SetParent(val10.transform, false);
Image val13 = val12.AddComponent<Image>();
((Graphic)val13).color = Color.white;
((Graphic)val13).rectTransform.sizeDelta = new Vector2(150f, 80f);
val12.transform.SetAsFirstSibling();
Button val14 = val10.AddComponent<Button>();
string thisLoadout = manager.GetLoadout(i).Name;
((UnityEvent)val14.onClick).AddListener((UnityAction)delegate
{
Plugin.Log.LogDebug((object)("Loadout " + thisLoadout + " button pressed!"));
if (currentLoadout != null && Loadout.Equals(currentLoadout, thisLoadout))
{
Plugin.Log.LogWarning((object)"Selected current loadout. Do nothing.");
}
else
{
SwitchLoadout(thisLoadout);
}
});
GameObject val15 = new GameObject("ButtonText");
val15.transform.SetParent(val10.transform, false);
TextMeshProUGUI val16 = val15.AddComponent<TextMeshProUGUI>();
((TMP_Text)val16).text = thisLoadout;
((TMP_Text)val16).overflowMode = (TextOverflowModes)0;
((TMP_Text)val16).textWrappingMode = (TextWrappingModes)1;
((Graphic)val16).color = Color.black;
((TMP_Text)val16).fontSize = 28f;
((TMP_Text)val16).alignment = (TextAlignmentOptions)514;
RectTransform component3 = ((Component)val16).GetComponent<RectTransform>();
((Vector2)(ref val17))..ctor(0.5f, 0.5f);
component3.pivot = val17;
Vector2 anchorMin = (component3.anchorMax = val17);
component3.anchorMin = anchorMin;
component3.sizeDelta = new Vector2(150f, 40f);
component3.anchoredPosition = Vector2.zero;
}
GameObject val19 = new GameObject("WardrobeText");
val19.transform.SetParent(((Component)canvas).transform, false);
TextMeshProUGUI val20 = val19.AddComponent<TextMeshProUGUI>();
((TMP_Text)val20).text = $"In Wardrobe Menu - Press {Plugin.toggleMenuButton.Value} to exit";
TMP_FontAsset val21 = Resources.Load<TMP_FontAsset>("DarumaDropOne-Regular");
if ((Object)(object)val21 != (Object)null)
{
((TMP_Text)val20).font = val21;
}
((Graphic)val20).color = Color.white;
((TMP_Text)val20).fontSize = 28f;
((TMP_Text)val20).alignment = (TextAlignmentOptions)514;
RectTransform component4 = ((Component)val20).GetComponent<RectTransform>();
component4.sizeDelta = new Vector2(600f, 100f);
component4.anchoredPosition = new Vector2(0f, 200f);
}
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)
{
}
}
}