using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using OnTogetherMods.Shared;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OutfitSlots")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+d07ddc22554e044db913d8ad82d4d9bc4f17c746")]
[assembly: AssemblyProduct("OutfitSlots")]
[assembly: AssemblyTitle("OutfitSlots")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 OnTogetherMods.Shared
{
internal static class PanelStack
{
private const string TableKey = "OnTogetherMods.PanelStack.Panels";
private const string HiddenKey = "OnTogetherMods.PanelStack.Hidden";
private const string IconBarKey = "OnTogetherMods.IconBar.Rect";
private const float Margin = 20f;
private const float FromRight = 0.15f;
private const float Gap = 10f;
private const int WorldScene = 2;
public const int PhotoModeOrder = 0;
public const int EmoteSyncOrder = 10;
public const int TeleportSpotsOrder = 20;
public const int SongPlayerOrder = 30;
public const int TraceOverlayOrder = 40;
public const int NameDesignerOrder = 50;
public const int OutfitSlotsOrder = 60;
public const string CanvasPrefix = "OnTogetherMods ";
private static int _deskFrame = -1;
private static bool _desk;
public static float Width => (float)Screen.width * 1080f / (float)Screen.height;
public static bool Hidden
{
get
{
if (!(AppDomain.CurrentDomain.GetData("OnTogetherMods.PanelStack.Hidden") is int num) || Time.frameCount > num)
{
return InDeskMode;
}
return true;
}
}
public static bool InDeskMode
{
get
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Invalid comparison between Unknown and I4
int frameCount = Time.frameCount;
if (_deskFrame != frameCount)
{
_deskFrame = frameCount;
_desk = false;
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).buildIndex == 2)
{
OverlayManager i = MonoSingleton<OverlayManager>.I;
_desk = (Object)(object)i != (Object)null && (int)i.ResolutionMode == 3;
}
}
return _desk;
}
}
public static bool IsModCanvas(Canvas canvas)
{
Canvas val = canvas;
Transform parent = ((Component)canvas).transform.parent;
while ((Object)(object)parent != (Object)null)
{
Canvas component = ((Component)parent).GetComponent<Canvas>();
val = (((Object)(object)component != (Object)null) ? component : val);
parent = parent.parent;
}
return ((Object)((Component)val).gameObject).name.StartsWith("OnTogetherMods ", StringComparison.Ordinal);
}
public static void HideForCapture()
{
AppDomain.CurrentDomain.SetData("OnTogetherMods.PanelStack.Hidden", Time.frameCount + 1);
}
public static Rect Place(string id, int order, Vector2 size)
{
//IL_001b: 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_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: 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)
Hashtable hashtable = Panels();
int frameCount = Time.frameCount;
hashtable[id] = new double[3] { order, size.y, frameCount };
float width = Width;
float num = Mathf.Max(20f, width * 0.85f - size.x);
float num2 = Bottom(num + size.x, frameCount) - size.y;
foreach (DictionaryEntry item in hashtable)
{
string text = (string)item.Key;
double[] array = (double[])item.Value;
bool flag = (double)frameCount - array[2] <= 2.0;
bool flag2 = array[0] < (double)order || (array[0] == (double)order && string.CompareOrdinal(text, id) < 0);
if (text != id && flag && flag2)
{
num2 -= (float)array[1] + 10f;
}
}
return new Rect(num, num2, size.x, size.y);
}
private static float Bottom(float windowRight, int frame)
{
float num = 1060f;
if (AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array && (double)frame - array[4] <= 2.0)
{
float num2 = 1080f / (float)Screen.height;
if (array[0] * (double)num2 < (double)(windowRight + 10f))
{
num = Mathf.Min(num, (float)array[1] * num2 - 10f);
}
}
return num;
}
public static Matrix4x4 Begin(out float width)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
float num = (float)Screen.height / 1080f;
Matrix4x4 matrix = GUI.matrix;
GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
width = (float)Screen.width / num;
return matrix;
}
public static void End(Matrix4x4 previous)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
GUI.matrix = previous;
}
public static GUIStyle MakeStyle(TextAnchor alignment)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
GUIStyle val = new GUIStyle(GUI.skin.box)
{
alignment = alignment,
fontSize = 15,
richText = true,
wordWrap = false,
padding = new RectOffset(12, 12, 10, 10)
};
val.normal.textColor = Color.white;
return val;
}
private static Hashtable Panels()
{
Hashtable hashtable = AppDomain.CurrentDomain.GetData("OnTogetherMods.PanelStack.Panels") as Hashtable;
if (hashtable == null)
{
hashtable = new Hashtable();
AppDomain.CurrentDomain.SetData("OnTogetherMods.PanelStack.Panels", hashtable);
}
return hashtable;
}
}
internal static class IconBar
{
public enum State
{
Plain,
Open,
On,
Off
}
public enum Click
{
None,
Left,
Right
}
private struct Metrics
{
public float Unit;
public int Art;
public int Button;
public int Gap;
public int Margin;
}
private static class Patches
{
private static Action<InputManager, bool> _setMouse0Down;
private static Action<InputManager, bool> _setMouse1;
private static Action<InputManager, bool> _setMouse1Up;
private static FieldRef<QuadPainterGPU, Vector2> _previousUV;
private static bool _leftOnBar;
private static bool _rightOnBar;
public static void Apply(Harmony harmony)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
_setMouse0Down = Setter("IsMouseButton0Down");
_setMouse1 = Setter("IsMouseButton1");
_setMouse1Up = Setter("IsMouseButton1Up");
harmony.Patch((MethodBase)AccessTools.Method(typeof(InputManager), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "InputPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
_previousUV = AccessTools.FieldRefAccess<QuadPainterGPU, Vector2>("previousUV");
harmony.Patch((MethodBase)AccessTools.Method(typeof(QuadPainterGPU), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "PaintPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
private static void InputPostfix(InputManager __instance)
{
bool mouseOver = MouseOver;
if (Input.GetMouseButtonDown(0))
{
_leftOnBar = mouseOver;
}
if (Input.GetMouseButtonDown(1))
{
_rightOnBar = mouseOver;
}
if (mouseOver)
{
_setMouse0Down(__instance, arg2: false);
}
if (_rightOnBar)
{
_setMouse1(__instance, arg2: false);
_setMouse1Up(__instance, arg2: false);
}
if (!Input.GetMouseButton(0))
{
_leftOnBar = false;
}
if (!Input.GetMouseButton(1))
{
_rightOnBar = false;
}
}
private static bool PaintPrefix(QuadPainterGPU __instance)
{
if (__instance.IsActive && (_leftOnBar || MouseOver))
{
_previousUV.Invoke(__instance).x = -1f;
return false;
}
return true;
}
private static Action<InputManager, bool> Setter(string property)
{
return (Action<InputManager, bool>)Delegate.CreateDelegate(typeof(Action<InputManager, bool>), AccessTools.PropertySetter(typeof(InputManager), property));
}
}
public const int PhotoModeOrder = 0;
public const int EmoteSyncOrder = 10;
public const int TeleportSpotsOrder = 20;
public const int NameDesignerOrder = 30;
public const int OutfitSlotsOrder = 35;
public const int DeskSnapOrder = 40;
public const int FocusAnywhereOrder = 50;
public const int SongPlayerOrder = 60;
public const int TraceOverlayOrder = 70;
public const int ChatRangeOrder = 80;
private const string RectKey = "OnTogetherMods.IconBar.Rect";
private const string TableKey = "OnTogetherMods.IconBar.Icons";
private const string PatchedKey = "OnTogetherMods.IconBar.Patched";
private const string BlockerKey = "OnTogetherMods.IconBar.Blocker";
private const string BlockerFrameKey = "OnTogetherMods.IconBar.BlockerFrame";
private const string HiddenKey = "OnTogetherMods.IconBar.HiddenUntil";
private const int WorldScene = 2;
private const int TooltipDepth = -100;
private static readonly Dictionary<char, Color32> Palette = new Dictionary<char, Color32>
{
{
'K',
new Color32((byte)42, (byte)36, (byte)51, byte.MaxValue)
},
{
'W',
new Color32((byte)247, (byte)243, (byte)234, byte.MaxValue)
},
{
'G',
new Color32((byte)201, (byte)198, (byte)207, byte.MaxValue)
},
{
'g',
new Color32((byte)143, (byte)138, (byte)153, byte.MaxValue)
},
{
'D',
new Color32((byte)87, (byte)82, (byte)95, byte.MaxValue)
},
{
'B',
new Color32((byte)168, (byte)107, (byte)60, byte.MaxValue)
},
{
'b',
new Color32((byte)217, (byte)160, (byte)102, byte.MaxValue)
},
{
'd',
new Color32((byte)110, (byte)67, (byte)37, byte.MaxValue)
},
{
'R',
new Color32((byte)224, (byte)90, (byte)90, byte.MaxValue)
},
{
'r',
new Color32((byte)168, (byte)58, (byte)70, byte.MaxValue)
},
{
'p',
new Color32((byte)246, (byte)165, (byte)165, byte.MaxValue)
},
{
'Y',
new Color32((byte)245, (byte)208, (byte)97, byte.MaxValue)
},
{
'y',
new Color32((byte)201, (byte)150, (byte)50, byte.MaxValue)
},
{
'O',
new Color32((byte)232, (byte)146, (byte)74, byte.MaxValue)
},
{
'L',
new Color32((byte)159, (byte)214, (byte)245, byte.MaxValue)
},
{
'U',
new Color32((byte)74, (byte)143, (byte)217, byte.MaxValue)
},
{
'u',
new Color32((byte)47, (byte)90, (byte)158, byte.MaxValue)
},
{
'N',
new Color32((byte)116, (byte)192, (byte)105, byte.MaxValue)
},
{
'n',
new Color32((byte)63, (byte)138, (byte)74, byte.MaxValue)
},
{
'P',
new Color32((byte)246, (byte)207, (byte)174, byte.MaxValue)
},
{
'V',
new Color32((byte)154, (byte)114, (byte)214, byte.MaxValue)
},
{
'v',
new Color32((byte)105, (byte)72, (byte)160, byte.MaxValue)
},
{
'S',
new Color32((byte)233, (byte)139, (byte)181, byte.MaxValue)
},
{
'H',
new Color32((byte)60, (byte)48, (byte)56, byte.MaxValue)
}
};
private static readonly Color32 ButtonFill = new Color32((byte)28, (byte)26, (byte)34, (byte)200);
private static readonly Color32 ButtonEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)30);
private static readonly Color32 HoverFill = new Color32((byte)48, (byte)45, (byte)58, (byte)225);
private static readonly Color32 HoverEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)80);
private static readonly Color32 OpenFill = new Color32((byte)70, (byte)64, (byte)88, (byte)235);
private static readonly Color32 OpenEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)150);
private static readonly Color32 DotFill = new Color32((byte)140, (byte)220, (byte)120, byte.MaxValue);
private static readonly Color32 DotEdge = new Color32((byte)20, (byte)40, (byte)20, byte.MaxValue);
private static readonly Dictionary<string[], Texture2D[]> Icons = new Dictionary<string[], Texture2D[]>();
private static Texture2D _buttonTexture;
private static Texture2D _hoverTexture;
private static Texture2D _openTexture;
private static Texture2D _dotTexture;
private static GUIStyle _buttonStyle;
private static GUIStyle _tipStyle;
private static int _builtFor;
private static int _cachedFrame = -1;
private static bool _inWorld;
private static bool _visible;
private static int _pressedButton;
private static bool RowHidden
{
get
{
if (AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.HiddenUntil") is int num)
{
return Time.frameCount <= num;
}
return false;
}
}
public static bool MouseOver
{
get
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if (!(AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array) || array[5] < 0.5 || (double)Time.frameCount - array[4] > 2.0)
{
return false;
}
Vector3 mousePosition = Input.mousePosition;
Rect val = default(Rect);
((Rect)(ref val))..ctor((float)array[0], (float)array[1], (float)array[2], (float)array[3]);
return ((Rect)(ref val)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y));
}
}
public static Click Draw(string id, int order, string[] pixels, State state, string name, KeyCode key, string hint = null)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
int controlID = GUIUtility.GetControlID((FocusType)2);
Event current = Event.current;
Refresh();
if (!_inWorld)
{
Hide(controlID, current);
UpdateBlocker(shown: false, default(Rect));
return Click.None;
}
Rect bar;
Metrics m;
Rect icon = Place(id, order, out bar, out m);
Share(bar);
UpdateBlocker(_visible, bar);
if (!_visible)
{
Hide(controlID, current);
return Click.None;
}
Matrix4x4 matrix = GUI.matrix;
GUI.matrix = Matrix4x4.identity;
try
{
return Handle(controlID, current, icon, m, pixels, state, name, key, hint);
}
finally
{
GUI.matrix = matrix;
}
}
public static void HideRow()
{
AppDomain.CurrentDomain.SetData("OnTogetherMods.IconBar.HiddenUntil", Time.frameCount + 1);
}
public static string KeyText(KeyCode key)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
if ((int)key != 0)
{
return $" ({key})";
}
return "";
}
private static Click Handle(int control, Event e, Rect icon, Metrics m, string[] pixels, State state, string name, KeyCode key, string hint)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected I4, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
bool flag = ((Rect)(ref icon)).Contains(e.mousePosition);
EventType typeForControl = e.GetTypeForControl(control);
switch ((int)typeForControl)
{
default:
{
if ((int)typeForControl != 7)
{
break;
}
BuildStyles(m);
bool flag2 = GUIUtility.hotControl == control;
_buttonStyle.normal.background = ((state == State.Open || (flag2 && flag)) ? _openTexture : (flag ? _hoverTexture : _buttonTexture));
_buttonStyle.Draw(icon, false, false, false, false);
Texture2D[] array = IconTextures(pixels);
GUI.DrawTexture(new Rect(((Rect)(ref icon)).x + (((Rect)(ref icon)).width - (float)m.Art) / 2f, ((Rect)(ref icon)).y + (((Rect)(ref icon)).height - (float)m.Art) / 2f, (float)m.Art, (float)m.Art), (Texture)(object)((state == State.Off) ? array[1] : array[0]));
if (state == State.On)
{
float num = Mathf.Max(1, Mathf.RoundToInt(2f * m.Unit));
float num2 = ((Texture)_dotTexture).width;
GUI.DrawTexture(new Rect(((Rect)(ref icon)).xMax - num - num2, ((Rect)(ref icon)).yMax - num - num2, num2, num2), (Texture)(object)_dotTexture);
}
int num3;
if (flag)
{
num3 = ((GUIUtility.hotControl == 0 || flag2) ? 1 : 0);
if (num3 != 0)
{
DrawTooltip(icon, m, Tooltip(state, name, key, hint));
}
}
else
{
num3 = 0;
}
GUI.depth = ((num3 != 0) ? (-100) : 0);
break;
}
case 0:
if (flag && (e.button == 0 || e.button == 1))
{
GUIUtility.hotControl = control;
_pressedButton = e.button;
e.Use();
}
break;
case 3:
if (GUIUtility.hotControl == control)
{
e.Use();
}
break;
case 1:
if (GUIUtility.hotControl != control)
{
break;
}
GUIUtility.hotControl = 0;
e.Use();
if (flag && e.button == _pressedButton)
{
if (e.button != 0)
{
return Click.Right;
}
return Click.Left;
}
break;
case 2:
break;
}
return Click.None;
}
private static string Tooltip(State state, string name, KeyCode key, string hint)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
string text = name + KeyText(key);
switch (state)
{
case State.On:
text += ": on";
break;
case State.Off:
text += ": off";
break;
}
if (hint == null)
{
return text;
}
return text + "\n" + hint;
}
private static void DrawTooltip(Rect icon, Metrics m, string text)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
GUIContent val = new GUIContent(text);
Vector2 val2 = _tipStyle.CalcSize(val);
float num = Mathf.Clamp(((Rect)(ref icon)).center.x - val2.x / 2f, (float)m.Margin, Mathf.Max((float)m.Margin, (float)(Screen.width - m.Margin) - val2.x));
float num2 = ((Rect)(ref icon)).y - (float)m.Gap - val2.y;
_tipStyle.Draw(new Rect(Mathf.Round(num), Mathf.Round(num2), val2.x, val2.y), val, false, false, false, false);
}
private static void Hide(int control, Event e)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
if (GUIUtility.hotControl == control)
{
GUIUtility.hotControl = 0;
}
if ((int)e.type == 7)
{
GUI.depth = 0;
}
}
private static Metrics Measure()
{
float num = (float)Screen.height / 1080f;
int num2 = Mathf.Max(1, Mathf.RoundToInt(2f * num));
int num3 = Mathf.Max(2, Mathf.RoundToInt(4f * num));
return new Metrics
{
Unit = num,
Art = 16 * num2,
Button = 16 * num2 + 2 * num3,
Gap = Mathf.Max(2, Mathf.RoundToInt(6f * num)),
Margin = Mathf.RoundToInt(20f * num)
};
}
private static Rect Place(string id, int order, out Rect bar, out Metrics m)
{
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
Hashtable hashtable = Table();
int frameCount = Time.frameCount;
if (hashtable[id] is double[] array)
{
array[0] = order;
array[1] = frameCount;
}
else
{
hashtable[id] = new double[2] { order, frameCount };
}
int num = 0;
int num2 = 0;
foreach (DictionaryEntry item in hashtable)
{
string text = (string)item.Key;
double[] array2 = (double[])item.Value;
if (!((double)frameCount - array2[1] > 2.0))
{
num2++;
if (text != id && (array2[0] < (double)order || (array2[0] == (double)order && string.CompareOrdinal(text, id) < 0)))
{
num++;
}
}
}
m = Measure();
int num3 = num2 * m.Button + (num2 - 1) * m.Gap;
int num4 = Screen.width - m.Margin - num3;
int num5 = Screen.height - m.Margin - m.Button;
bar = new Rect((float)num4, (float)num5, (float)num3, (float)m.Button);
return new Rect((float)(num4 + num * (m.Button + m.Gap)), (float)num5, (float)m.Button, (float)m.Button);
}
private static void Share(Rect bar)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
int frameCount = Time.frameCount;
if (!(currentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array) || (int)array[4] != frameCount || !(array[2] >= (double)((Rect)(ref bar)).width))
{
currentDomain.SetData("OnTogetherMods.IconBar.Rect", new double[6]
{
((Rect)(ref bar)).x,
((Rect)(ref bar)).y,
((Rect)(ref bar)).width,
((Rect)(ref bar)).height,
frameCount,
_visible ? 1 : 0
});
}
}
private static Hashtable Table()
{
Hashtable hashtable = AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Icons") as Hashtable;
if (hashtable == null)
{
hashtable = new Hashtable();
AppDomain.CurrentDomain.SetData("OnTogetherMods.IconBar.Icons", hashtable);
}
return hashtable;
}
private static void Refresh()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Invalid comparison between Unknown and I4
int frameCount = Time.frameCount;
if (_cachedFrame != frameCount)
{
_cachedFrame = frameCount;
Scene activeScene = SceneManager.GetActiveScene();
_inWorld = ((Scene)(ref activeScene)).buildIndex == 2;
_visible = false;
if (_inWorld && !PanelStack.Hidden && !RowHidden)
{
TaskManager i = MonoSingleton<TaskManager>.I;
_visible = (Object)(object)i != (Object)null && ((int)i.LockState == 0 || (int)i.LockState == 5);
}
}
}
private static void UpdateBlocker(bool shown, Rect bar)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
AppDomain currentDomain = AppDomain.CurrentDomain;
int frameCount = Time.frameCount;
if (currentDomain.GetData("OnTogetherMods.IconBar.BlockerFrame") is int num && num == frameCount)
{
return;
}
currentDomain.SetData("OnTogetherMods.IconBar.BlockerFrame", frameCount);
object? data = currentDomain.GetData("OnTogetherMods.IconBar.Blocker");
GameObject val = (GameObject)((data is GameObject) ? data : null);
if ((Object)(object)val == (Object)null)
{
if (!shown)
{
return;
}
val = CreateBlocker();
currentDomain.SetData("OnTogetherMods.IconBar.Blocker", val);
}
if (shown)
{
RectTransform val2 = (RectTransform)val.transform.GetChild(0);
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(((Rect)(ref bar)).x, (float)Screen.height - ((Rect)(ref bar)).yMax);
if (val2.anchoredPosition != val3)
{
val2.anchoredPosition = val3;
}
if (val2.sizeDelta != ((Rect)(ref bar)).size)
{
val2.sizeDelta = ((Rect)(ref bar)).size;
}
}
if (val.activeSelf != shown)
{
val.SetActive(shown);
}
}
private static GameObject CreateBlocker()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_009d: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("OnTogetherMods IconBar ClickBlocker");
Object.DontDestroyOnLoad((Object)(object)val);
Canvas obj = val.AddComponent<Canvas>();
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 32767;
val.AddComponent<GraphicRaycaster>();
GameObject val2 = new GameObject("Area", new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(Image)
});
val2.transform.SetParent(val.transform, false);
((Graphic)val2.GetComponent<Image>()).color = Color.clear;
RectTransform val3 = (RectTransform)val2.transform;
val3.anchorMin = Vector2.zero;
val3.anchorMax = Vector2.zero;
val3.pivot = Vector2.zero;
val.SetActive(false);
return val;
}
public static void Patch()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
AppDomain currentDomain = AppDomain.CurrentDomain;
if (currentDomain.GetData("OnTogetherMods.IconBar.Patched") != null)
{
return;
}
currentDomain.SetData("OnTogetherMods.IconBar.Patched", true);
try
{
Patches.Apply(new Harmony("nelphei.ontogether.iconbar"));
}
catch (Exception arg)
{
Debug.LogError((object)$"[OnTogetherMods] Icon bar patches failed, so clicks on it may reach the game: {arg}");
}
}
private static Texture2D[] IconTextures(string[] pixels)
{
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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_00a6: 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)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
if (Icons.TryGetValue(pixels, out var value) && (Object)(object)value[0] != (Object)null && (Object)(object)value[1] != (Object)null)
{
return value;
}
Color32[] array = (Color32[])(object)new Color32[256];
Color32[] array2 = (Color32[])(object)new Color32[256];
for (int i = 0; i < 16; i++)
{
string text = ((i < pixels.Length) ? pixels[i] : "");
for (int j = 0; j < 16; j++)
{
char key = ((j < text.Length) ? text[j] : '.');
Color32 value2;
Color32 val = (Color32)(Palette.TryGetValue(key, out value2) ? value2 : new Color32((byte)0, (byte)0, (byte)0, (byte)0));
int num = (15 - i) * 16 + j;
array[num] = val;
byte b = (byte)Mathf.RoundToInt(0.3f * (float)(int)val.r + 0.59f * (float)(int)val.g + 0.11f * (float)(int)val.b);
array2[num] = new Color32(b, b, b, (byte)((float)(int)val.a * 0.45f));
}
}
value = (Texture2D[])(object)new Texture2D[2]
{
NewTexture(16, 16, array, (FilterMode)0),
NewTexture(16, 16, array2, (FilterMode)0)
};
Icons[pixels] = value;
return value;
}
private static void BuildStyles(Metrics m)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_0093: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_0105: Expected O, but got Unknown
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: 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)
//IL_019f: Expected O, but got Unknown
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
if (_builtFor != Screen.height || _buttonStyle == null || !((Object)(object)_buttonTexture != (Object)null) || !((Object)(object)_dotTexture != (Object)null))
{
_builtFor = Screen.height;
int num = Mathf.Max(2, Mathf.RoundToInt(6f * m.Unit));
Destroy(_buttonTexture);
Destroy(_hoverTexture);
Destroy(_openTexture);
Destroy(_dotTexture);
_buttonTexture = RoundedBox(num, ButtonFill, ButtonEdge);
_hoverTexture = RoundedBox(num, HoverFill, HoverEdge);
_openTexture = RoundedBox(num, OpenFill, OpenEdge);
int num2 = Mathf.Max(2, Mathf.RoundToInt(3f * m.Unit));
_dotTexture = RoundedBox(num2, DotFill, DotEdge, 2 * num2);
int num3 = num + 1;
_buttonStyle = new GUIStyle
{
border = new RectOffset(num3, num3, num3, num3)
};
_tipStyle = new GUIStyle
{
border = new RectOffset(num3, num3, num3, num3),
padding = new RectOffset(Mathf.RoundToInt(10f * m.Unit), Mathf.RoundToInt(10f * m.Unit), Mathf.RoundToInt(6f * m.Unit), Mathf.RoundToInt(6f * m.Unit)),
fontSize = Mathf.Max(8, Mathf.RoundToInt(15f * m.Unit)),
alignment = (TextAnchor)3,
wordWrap = false,
richText = false
};
_tipStyle.normal.background = _hoverTexture;
_tipStyle.normal.textColor = Color.white;
}
}
private static Texture2D RoundedBox(int radius, Color32 fill, Color32 edge, int size = 0)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_00a5: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
if (size <= 0)
{
size = 2 * radius + 4;
}
Color32[] array = (Color32[])(object)new Color32[size * size];
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
float num = (float)j + 0.5f;
float num2 = (float)i + 0.5f;
float num3 = Mathf.Max(Mathf.Max((float)radius - num, num - (float)(size - radius)), 0f);
float num4 = Mathf.Max(Mathf.Max((float)radius - num2, num2 - (float)(size - radius)), 0f);
float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4) - (float)radius;
float num6 = Mathf.Clamp01(0.5f - num5);
Color val = Color.Lerp(Color32.op_Implicit(fill), Color32.op_Implicit(edge), Mathf.Clamp01(num5 + 1.5f));
val.a *= num6;
array[i * size + j] = Color32.op_Implicit(val);
}
}
return NewTexture(size, size, array, (FilterMode)1);
}
private static Texture2D NewTexture(int width, int height, Color32[] pixels, FilterMode filter)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
Texture2D val = new Texture2D(width, height, (TextureFormat)4, false)
{
filterMode = filter,
wrapMode = (TextureWrapMode)1,
hideFlags = (HideFlags)61
};
val.SetPixels32(pixels);
val.Apply(false, true);
return val;
}
private static void Destroy(Texture2D texture)
{
if ((Object)(object)texture != (Object)null)
{
Object.Destroy((Object)(object)texture);
}
}
}
internal sealed class ClickBlocker
{
private readonly GameObject _root;
private readonly RectTransform _area;
public ClickBlocker(string name)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_009a: 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_00b5: Expected O, but got Unknown
//IL_00bb: 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_00db: Unknown result type (might be due to invalid IL or missing references)
_root = new GameObject(name);
Object.DontDestroyOnLoad((Object)(object)_root);
Canvas obj = _root.AddComponent<Canvas>();
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 32767;
_root.AddComponent<GraphicRaycaster>();
GameObject val = new GameObject("Area", new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(Image)
});
val.transform.SetParent(_root.transform, false);
((Graphic)val.GetComponent<Image>()).color = Color.clear;
_area = (RectTransform)val.transform;
_area.anchorMin = Vector2.zero;
_area.anchorMax = Vector2.zero;
_area.pivot = Vector2.zero;
_root.SetActive(false);
}
public void Update(bool shown, Rect screenRect)
{
//IL_002d: 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)
if (!((Object)(object)_root == (Object)null))
{
if (shown)
{
_area.anchoredPosition = new Vector2(((Rect)(ref screenRect)).x, (float)Screen.height - ((Rect)(ref screenRect)).yMax);
_area.sizeDelta = ((Rect)(ref screenRect)).size;
}
if (_root.activeSelf != shown)
{
_root.SetActive(shown);
}
}
}
public void Destroy()
{
if ((Object)(object)_root != (Object)null)
{
Object.Destroy((Object)(object)_root);
}
}
public static bool MouseIn(Rect screenRect)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
Vector3 mousePosition = Input.mousePosition;
return ((Rect)(ref screenRect)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y));
}
}
}
namespace OutfitSlots
{
internal static class Dropdown
{
private const string RowPrefix = "OutfitSlots Row ";
private static readonly FieldRef<CustomizationUIController, List<TextMeshProUGUI>> TextsField = AccessTools.FieldRefAccess<CustomizationUIController, List<TextMeshProUGUI>>("_styleTexts");
private static readonly FieldRef<CustomizationUIController, List<GameObject>> BgsField = AccessTools.FieldRefAccess<CustomizationUIController, List<GameObject>>("_styleSelectedBgs");
private static readonly FieldRef<CustomizationUIController, GameObject> PanelField = AccessTools.FieldRefAccess<CustomizationUIController, GameObject>("_styleDropdownPanel");
private static CustomizationUIController _described;
public static void Prepare(CustomizationUIController screen)
{
List<TextMeshProUGUI> list = TextsField.Invoke(screen);
List<GameObject> list2 = BgsField.Invoke(screen);
if (list == null || list2 == null)
{
return;
}
if (list.Count < 9 || list2.Count < 9)
{
bool flag = false;
try
{
flag = AddRows(screen, list, list2);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)ex);
}
if (!flag)
{
AddStandIns(screen, list, list2);
}
}
foreach (GameObject item in list2)
{
if ((Object)(object)item != (Object)null)
{
item.SetActive(false);
}
}
DataManager data = Game.Data;
if ((Object)(object)data != (Object)null)
{
Slots.EnsureNames(data.PlayerDataZip);
}
}
public static void Opened(CustomizationUIController screen)
{
GameObject val = PanelField.Invoke(screen);
if ((Object)(object)val == (Object)null || !val.activeInHierarchy)
{
return;
}
Transform transform = val.transform;
RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
if (val2 != null)
{
Canvas.ForceUpdateCanvases();
KeepOnScreen(val2);
if (Plugin.Settings.DebugLog.Value && (Object)(object)_described != (Object)(object)screen)
{
_described = screen;
Plugin.Log.LogInfo((object)("The outfit screen's style list:\n" + Describe(val.transform)));
}
}
}
private static bool AddRows(CustomizationUIController screen, List<TextMeshProUGUI> texts, List<GameObject> bgs)
{
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
if (texts.Count != 3 || bgs.Count != 3 || (Object)(object)texts[0] == (Object)null || (Object)(object)texts[1] == (Object)null || (Object)(object)texts[2] == (Object)null || (Object)(object)bgs[1] == (Object)null || (Object)(object)bgs[2] == (Object)null)
{
Plugin.Log.LogWarning((object)($"The outfit screen's style list has {texts.Count} rows, not the 3 this mod expects, " + "so slots 4-9 are only in the quick-swap window."));
return false;
}
Transform val = FindRow(((TMP_Text)texts[2]).transform, bgs[2].transform, ((TMP_Text)texts[1]).transform);
if ((Object)(object)val == (Object)null || (Object)(object)val.parent == (Object)null)
{
Plugin.Log.LogWarning((object)"Couldn't find row 3 of the outfit screen's style list, so slots 4-9 are only in the quick-swap window.");
return false;
}
Transform parent = val.parent;
Transform val2 = FindRow(((TMP_Text)texts[1]).transform, bgs[1].transform, ((TMP_Text)texts[0]).transform);
string path = PathBelow(val, ((TMP_Text)texts[2]).transform);
string path2 = PathBelow(val, bgs[2].transform);
bool flag = (Object)(object)((Component)parent).GetComponent<LayoutGroup>() != (Object)null;
RectTransform val3 = (RectTransform)(object)((val is RectTransform) ? val : null);
Vector2 val4 = RowStep(val3, (RectTransform)(object)((val2 is RectTransform) ? val2 : null), parent);
List<TextMeshProUGUI> list = new List<TextMeshProUGUI>();
List<GameObject> list2 = new List<GameObject>();
List<GameObject> list3 = new List<GameObject>();
for (int i = 3; i < 9; i++)
{
GameObject val5 = Object.Instantiate<GameObject>(((Component)val).gameObject, parent, false);
list3.Add(val5);
((Object)val5).name = "OutfitSlots Row " + (i + 1);
val5.transform.SetSiblingIndex(val.GetSiblingIndex() + i - 2);
if (!flag && (Object)(object)val3 != (Object)null)
{
Transform transform = val5.transform;
RectTransform val6 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
if (val6 != null)
{
val6.anchoredPosition = val3.anchoredPosition + val4 * (float)(i - 2);
}
}
Transform val7 = Find(val5.transform, path2);
Transform obj = Find(val5.transform, path);
TextMeshProUGUI val8 = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
if ((Object)(object)val8 == (Object)null || (Object)(object)val7 == (Object)null || !Rewire(val5, screen, i))
{
foreach (GameObject item in list3)
{
Object.Destroy((Object)(object)item);
}
Plugin.Log.LogWarning((object)"Couldn't set up the copied rows in the outfit screen's style list, so slots 4-9 are only in the quick-swap window.");
return false;
}
SetNumber(val5, val8, i + 1);
((Component)val7).gameObject.SetActive(false);
list.Add(val8);
list2.Add(((Component)val7).gameObject);
}
texts.AddRange(list);
bgs.AddRange(list2);
float amount = Mathf.Abs(val4.y) * 6f;
string text = Grow(PanelField.Invoke(screen), parent, amount);
Plugin.Log.LogInfo((object)("Added rows 4-9 to the outfit screen's style list (copied '" + ((Object)val).name + "' in '" + ((Object)parent).name + "', " + (flag ? "laid out by the game" : "placed by the mod") + ", " + text + ")."));
return true;
}
private static Transform FindRow(Transform text, Transform bg, Transform otherRowText)
{
Transform val = text;
while ((Object)(object)val != (Object)null)
{
if ((Object)(object)otherRowText != (Object)null && otherRowText.IsChildOf(val))
{
return null;
}
if (bg.IsChildOf(val) && (Object)(object)val != (Object)(object)bg && ((Object)(object)((Component)val).GetComponentInChildren<Button>(true) != (Object)null || (Object)(object)((Component)val).GetComponentInChildren<EventTrigger>(true) != (Object)null))
{
return val;
}
val = val.parent;
}
return null;
}
private static Vector2 RowStep(RectTransform row, RectTransform rowAbove, Transform parent)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)row != (Object)null && (Object)(object)rowAbove != (Object)null && (Object)(object)((Transform)rowAbove).parent == (Object)(object)parent)
{
Vector2 result = row.anchoredPosition - rowAbove.anchoredPosition;
if (((Vector2)(ref result)).sqrMagnitude > 1f)
{
return result;
}
}
float num;
if (!((Object)(object)row != (Object)null))
{
num = 40f;
}
else
{
Rect rect = row.rect;
num = ((Rect)(ref rect)).height;
}
float num2 = num;
VerticalLayoutGroup component = ((Component)parent).GetComponent<VerticalLayoutGroup>();
return new Vector2(0f, 0f - (num2 + (((Object)(object)component != (Object)null) ? ((HorizontalOrVerticalLayoutGroup)component).spacing : 0f)));
}
private static bool Rewire(GameObject clone, CustomizationUIController screen, int slot)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_006b: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Expected O, but got Unknown
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Expected O, but got Unknown
bool flag = false;
Button[] componentsInChildren = clone.GetComponentsInChildren<Button>(true);
Button[] array = componentsInChildren;
UnityAction val2 = default(UnityAction);
foreach (Button val in array)
{
if (!CallsSelectStyle((UnityEventBase)(object)val.onClick))
{
continue;
}
val.onClick = new ButtonClickedEvent();
ButtonClickedEvent onClick = val.onClick;
UnityAction obj = val2;
if (obj == null)
{
UnityAction val3 = delegate
{
screen.ButtonSelectStyle(slot);
};
UnityAction val4 = val3;
val2 = val3;
obj = val4;
}
((UnityEvent)onClick).AddListener(obj);
flag = true;
}
EventTrigger[] componentsInChildren2 = clone.GetComponentsInChildren<EventTrigger>(true);
for (int i = 0; i < componentsInChildren2.Length; i++)
{
foreach (Entry trigger in componentsInChildren2[i].triggers)
{
if (CallsSelectStyle((UnityEventBase)(object)trigger.callback))
{
trigger.callback = new TriggerEvent();
((UnityEvent<BaseEventData>)(object)trigger.callback).AddListener((UnityAction<BaseEventData>)delegate
{
screen.ButtonSelectStyle(slot);
});
flag = true;
}
}
}
if (!flag && componentsInChildren.Length != 0)
{
componentsInChildren[0].onClick = new ButtonClickedEvent();
((UnityEvent)componentsInChildren[0].onClick).AddListener((UnityAction)delegate
{
screen.ButtonSelectStyle(slot);
});
flag = true;
}
return flag;
}
private static bool CallsSelectStyle(UnityEventBase clicked)
{
for (int i = 0; i < clicked.GetPersistentEventCount(); i++)
{
if (clicked.GetPersistentMethodName(i) == "ButtonSelectStyle")
{
return true;
}
}
return false;
}
private static void SetNumber(GameObject clone, TextMeshProUGUI nameText, int number)
{
TextMeshProUGUI[] componentsInChildren = clone.GetComponentsInChildren<TextMeshProUGUI>(true);
foreach (TextMeshProUGUI val in componentsInChildren)
{
string text = (((TMP_Text)val).text ?? "").Trim().TrimEnd('-', '.', ' ');
if ((Object)(object)val != (Object)(object)nameText && text == "3")
{
((TMP_Text)val).text = ((TMP_Text)val).text.Replace("3", number.ToString());
}
}
}
private static string Grow(GameObject panelObject, Transform list, float amount)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: 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)
RectTransform val = (RectTransform)(((Object)(object)panelObject != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
RectTransform val2 = (RectTransform)(object)((list is RectTransform) ? list : null);
if (amount < 1f)
{
return "not resized";
}
List<string> list2 = new List<string>();
Rect rect;
if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<ContentSizeFitter>() == (Object)null)
{
rect = val.rect;
float height = ((Rect)(ref rect)).height;
val.SetSizeWithCurrentAnchors((Axis)1, height + amount);
string name = ((Object)val).name;
object arg = height;
rect = val.rect;
list2.Add($"'{name}' {arg:0} to {((Rect)(ref rect)).height:0} tall");
}
bool flag = (Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && ((Transform)val2).IsChildOf((Transform)(object)val) && !Mathf.Approximately(val2.anchorMin.y, val2.anchorMax.y);
if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)val && !flag && (Object)(object)((Component)val2).GetComponent<ContentSizeFitter>() == (Object)null)
{
rect = val2.rect;
float height2 = ((Rect)(ref rect)).height;
val2.SetSizeWithCurrentAnchors((Axis)1, height2 + amount);
string name2 = ((Object)val2).name;
object arg2 = height2;
rect = val2.rect;
list2.Add($"'{name2}' {arg2:0} to {((Rect)(ref rect)).height:0} tall");
}
if ((Object)(object)val2 != (Object)null)
{
LayoutRebuilder.MarkLayoutForRebuild(val2);
}
if (list2.Count <= 0)
{
return "sizes itself";
}
return string.Join(", ", list2);
}
private static void KeepOnScreen(RectTransform rect)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: 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_0115: 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_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
Canvas componentInParent = ((Component)rect).GetComponentInParent<Canvas>();
if ((Object)(object)componentInParent == (Object)null)
{
return;
}
componentInParent = componentInParent.rootCanvas;
Camera val = (((int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera);
Vector3[] array = (Vector3[])(object)new Vector3[4];
rect.GetWorldCorners(array);
float num = float.MaxValue;
float num2 = float.MinValue;
Vector3[] array2 = array;
foreach (Vector3 val2 in array2)
{
float y = RectTransformUtility.WorldToScreenPoint(val, val2).y;
num = Mathf.Min(num, y);
num2 = Mathf.Max(num2, y);
}
float num3 = 0f;
if (num2 - num > (float)Screen.height - 16f)
{
num3 = (float)Screen.height - 8f - num2;
}
else if (num < 8f)
{
num3 = 8f - num;
}
else if (num2 > (float)Screen.height - 8f)
{
num3 = (float)Screen.height - 8f - num2;
}
if (Mathf.Abs(num3) < 0.5f)
{
return;
}
Transform parent = ((Transform)rect).parent;
RectTransform val3 = (RectTransform)(object)((parent is RectTransform) ? parent : null);
if (val3 != null)
{
Vector2 val4 = RectTransformUtility.WorldToScreenPoint(val, ((Transform)rect).position);
Vector3 position = default(Vector3);
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(val3, val4 + new Vector2(0f, num3), val, ref position))
{
((Transform)rect).position = position;
}
}
}
private static void AddStandIns(CustomizationUIController screen, List<TextMeshProUGUI> texts, List<GameObject> bgs)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
GameObject val = new GameObject("OutfitSlots Hidden Rows");
val.SetActive(false);
val.transform.SetParent(((Component)screen).transform, false);
while (texts.Count < 9)
{
GameObject val2 = new GameObject("Name " + (texts.Count + 1));
val2.transform.SetParent(val.transform, false);
texts.Add(val2.AddComponent<TextMeshProUGUI>());
}
while (bgs.Count < 9)
{
GameObject val3 = new GameObject("Highlight " + (bgs.Count + 1));
val3.transform.SetParent(val.transform, false);
bgs.Add(val3);
}
}
private static string PathBelow(Transform root, Transform child)
{
List<string> list = new List<string>();
Transform val = child;
while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root)
{
list.Add(((Object)val).name);
val = val.parent;
}
list.Reverse();
return string.Join("/", list);
}
private static Transform Find(Transform root, string path)
{
if (path.Length != 0)
{
return root.Find(path);
}
return root;
}
private static string Describe(Transform root)
{
StringBuilder stringBuilder = new StringBuilder();
Describe(root, 0, stringBuilder);
return stringBuilder.ToString();
}
private static void Describe(Transform t, int depth, StringBuilder text)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Expected O, but got Unknown
text.Append(' ', depth * 2).Append(((Object)t).name);
if (!((Component)t).gameObject.activeSelf)
{
text.Append(" (off)");
}
RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null);
if (val != null)
{
Rect rect = val.rect;
object arg = ((Rect)(ref rect)).width;
rect = val.rect;
text.Append($" {arg:0}x{((Rect)(ref rect)).height:0} at {val.anchoredPosition}");
}
Component[] components = ((Component)t).GetComponents<Component>();
foreach (Component val2 in components)
{
if ((Object)(object)val2 != (Object)null && !(val2 is Transform))
{
text.Append(" [").Append(((object)val2).GetType().Name).Append(']');
}
}
text.Append('\n');
foreach (Transform item in t)
{
Describe(item, depth + 1, text);
}
}
}
internal static class Game
{
private const int WorldScene = 2;
private static DataManager _data;
private static readonly FieldRef<CustomizationUIController, GameObject> PanelField = AccessTools.FieldRefAccess<CustomizationUIController, GameObject>("_customizationPanel");
public static CustomizationUIController Customization;
public static DataManager Data
{
get
{
if ((Object)(object)_data == (Object)null)
{
_data = MonoSingleton<DataManager>.I;
}
return _data;
}
set
{
_data = value;
}
}
public static bool InWorld
{
get
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
return ((Scene)(ref activeScene)).buildIndex == 2;
}
}
public static bool ScreenOpen
{
get
{
CustomizationUIController customization = Customization;
if ((Object)(object)customization != (Object)null)
{
return IsOpen(customization);
}
return false;
}
}
public static bool IsOpen(CustomizationUIController screen)
{
GameObject val = PanelField.Invoke(screen);
if ((Object)(object)val != (Object)null)
{
return val.activeInHierarchy;
}
return false;
}
}
internal static class Icon
{
public static readonly string[] Pixels = new string[16]
{
"................", "....KKKKKKKK....", "...KVVWWWWVVK...", "..KVVVVWWVVVVK..", ".KVVVVVVVVVVVvK.", "KVVVVVVVVVVVVVvK", "KVVVKVVVVVVKVvvK", ".KKKKVVVVVvKKKK.", "....KVVVVVvK....", "....KVVVVVvK....",
"....KVVVVVvK....", "....KVVVVVvK....", "....KVVVVvvK....", "....KKKKKKKK....", "................", "................"
};
}
internal sealed class OutfitStore
{
private sealed class OutfitFile
{
public int Version = 1;
public int SelectedSlot = 1;
public int GameSlot = 1;
public List<SavedSlot> Slots = new List<SavedSlot>();
}
private sealed class SavedSlot
{
public int Slot;
public string Name = "";
public CustomizationDataIDs3 Outfit;
}
private const int Count = 6;
private readonly string[] _names = new string[6];
private readonly CustomizationDataIDs3[] _outfits = (CustomizationDataIDs3[])(object)new CustomizationDataIDs3[6];
public int SelectedSlot;
public int GameSlot;
private string _written;
public string FilePath { get; } = Path.Combine(Paths.ConfigPath, "OutfitSlots.json");
public OutfitStore()
{
for (int i = 0; i < 6; i++)
{
_names[i] = "";
}
}
public string Name(int slot)
{
return _names[slot - 3] ?? "";
}
public void SetName(int slot, string name)
{
_names[slot - 3] = name ?? "";
}
public CustomizationDataIDs3 Outfit(int slot)
{
return _outfits[slot - 3];
}
public void SetOutfit(int slot, CustomizationDataIDs3 outfit)
{
_outfits[slot - 3] = outfit;
}
public void Load()
{
if (!File.Exists(FilePath))
{
int num = BlueSage.ImportSlots(this);
if (num > 0)
{
Plugin.Log.LogInfo((object)($"Copied {num} outfits from BlueSage QoL's style slots 4-9. " + "BlueSage's own file is left as it was."));
}
SaveIfChanged();
return;
}
try
{
string text = File.ReadAllText(FilePath);
OutfitFile outfitFile = JsonConvert.DeserializeObject<OutfitFile>(text);
if (outfitFile == null)
{
return;
}
SelectedSlot = Clamp(outfitFile.SelectedSlot - 1, 0, 8);
GameSlot = Clamp(outfitFile.GameSlot - 1, 0, 2);
foreach (SavedSlot item in outfitFile.Slots ?? new List<SavedSlot>())
{
int num2 = ((item != null) ? (item.Slot - 1) : (-1));
if (Slots.IsModSlot(num2))
{
SetName(num2, item.Name);
if (item.Outfit != null && !IsComplete(item.Outfit))
{
Plugin.Log.LogWarning((object)$"Slot {num2 + 1}'s outfit in {FilePath} is missing parts, so the slot starts empty.");
}
else
{
SetOutfit(num2, item.Outfit);
}
}
}
_written = text;
}
catch (Exception ex)
{
string text2 = FilePath + ".bad";
Plugin.Log.LogError((object)("Couldn't read " + FilePath + ", so it was copied to " + text2 + ": " + ex.Message));
try
{
File.Copy(FilePath, text2, overwrite: true);
}
catch (Exception ex2)
{
Plugin.Log.LogError((object)ex2);
}
}
}
public void SaveIfChanged()
{
try
{
OutfitFile outfitFile = new OutfitFile
{
SelectedSlot = SelectedSlot + 1,
GameSlot = GameSlot + 1
};
for (int i = 3; i < 9; i++)
{
outfitFile.Slots.Add(new SavedSlot
{
Slot = i + 1,
Name = Name(i),
Outfit = Outfit(i)
});
}
string text = JsonConvert.SerializeObject((object)outfitFile, (Formatting)1);
if (!(text == _written))
{
File.WriteAllText(FilePath, text);
_written = text;
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Couldn't save outfit slots to {FilePath}: {arg}");
}
}
public static bool IsComplete(CustomizationDataIDs3 outfit)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
if (outfit?.AppearanceToShapeAndColors == null || outfit.OutfitToShapeAndColors == null)
{
return false;
}
foreach (AppearanceType value3 in Enum.GetValues(typeof(AppearanceType)))
{
if (!outfit.AppearanceToShapeAndColors.TryGetValue(value3, out var value) || value.ColorIndexes == null)
{
return false;
}
}
foreach (OutfitType value4 in Enum.GetValues(typeof(OutfitType)))
{
if (!outfit.OutfitToShapeAndColors.TryGetValue(value4, out var value2) || value2.ColorIndexes == null)
{
return false;
}
}
return true;
}
private static int Clamp(int value, int min, int max)
{
if (value >= min)
{
if (value <= max)
{
return value;
}
return max;
}
return min;
}
}
internal static class BlueSage
{
private static readonly ConfigDefinition SlotsSetting = new ConfigDefinition("Avatar Styles", "EnableExtendedAvatarStyles");
public static string SettingsFile => Path.Combine(Paths.ConfigPath, "com.bluesage.ontogether.qoltweaks.beta.cfg");
private static string StylesFile => Path.Combine(Paths.ConfigPath, "com.bluesage.ontogether.qol-avatar-styles.cfg");
public static bool SlotsOn()
{
ConfigEntry<bool> val = default(ConfigEntry<bool>);
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
if (!((Object)(object)((value != null) ? value.Instance : null) == (Object)null) && value.Metadata != null && value.Metadata.GUID.StartsWith("com.bluesage.", StringComparison.Ordinal) && value.Instance.Config.TryGetEntry<bool>(SlotsSetting, ref val) && val.Value)
{
return true;
}
}
return false;
}
public static int ImportSlots(OutfitStore store)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
if (!File.Exists(StylesFile))
{
return 0;
}
int num = 0;
try
{
ConfigFile val = new ConfigFile(StylesFile, false)
{
SaveOnConfigSet = false
};
for (int i = 3; i < 9; i++)
{
string text = "Style " + (i + 1);
string text2 = val.Bind<string>(text, "Name", "", (ConfigDescription)null).Value ?? "";
string text3 = val.Bind<string>(text, "Payload", "", (ConfigDescription)null).Value ?? "";
CustomizationDataIDs3 val2 = ParsePayload(text3);
if (val2 == null && text3.Trim().Length > 0)
{
Plugin.Log.LogWarning((object)$"BlueSage's style slot {i + 1} couldn't be read, so only its name was copied.");
}
store.SetName(i, text2.Trim());
store.SetOutfit(i, val2);
if (val2 != null || text2.Trim().Length > 0)
{
num++;
}
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Couldn't read BlueSage's style slots from {StylesFile}: {arg}");
}
return num;
}
private static CustomizationDataIDs3 ParsePayload(string payload)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
string[] array = payload.Trim().Split(';');
if (array.Length != 4 || array[0] != "BSAS1")
{
return null;
}
CustomizationDataIDs3 val = new CustomizationDataIDs3
{
IsFullBody = (array[1] == "1")
};
if (!ParseParts<AppearanceType>(array[2], val.AppearanceToShapeAndColors) || !ParseParts<OutfitType>(array[3], val.OutfitToShapeAndColors))
{
return null;
}
if (!OutfitStore.IsComplete(val))
{
return null;
}
return val;
}
private static bool ParseParts<TPart>(string section, Dictionary<TPart, ShapeAndColorsData> into) where TPart : struct, Enum
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
int length = Enum.GetValues(typeof(TPart)).Length;
HashSet<int> hashSet = new HashSet<int>();
string[] array = section.Split('|');
for (int i = 0; i < array.Length; i++)
{
string[] array2 = array[i].Split(':');
if (array2.Length != 3 || !int.TryParse(array2[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || !int.TryParse(array2[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2) || result < 0 || result >= length)
{
return false;
}
List<int> list = new List<int>();
string[] array3 = array2[2].Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
for (int j = 0; j < array3.Length; j++)
{
if (!int.TryParse(array3[j], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result3))
{
return false;
}
list.Add(result3);
}
into[(TPart)Enum.ToObject(typeof(TPart), result)] = new ShapeAndColorsData(result2, list);
hashSet.Add(result);
}
return hashSet.Count == length;
}
}
internal sealed class OutfitWindow : MonoBehaviour
{
private const string PanelId = "OutfitSlots";
private const float Width = 300f;
private const float Pad = 10f;
private const float HeaderHeight = 24f;
private const float RowHeight = 28f;
private const float Gap = 3f;
private const float StatusHeight = 22f;
private const float NumberWidth = 26f;
private const float TagWidth = 62f;
private const float StatusSeconds = 4f;
private static OutfitWindow _instance;
private bool _open;
private bool _iconClicked;
private bool _iconRightClicked;
private int _picked = -1;
private bool _screenOpen;
private string _status;
private float _statusUntil;
private Rect _screenRect;
private int _drawnFrame = -100;
private ClickBlocker _blocker;
private GUIStyle _boxStyle;
private GUIStyle _titleStyle;
private GUIStyle _keyStyle;
private GUIStyle _rowStyle;
private GUIStyle _wearingStyle;
private GUIStyle _numberStyle;
private GUIStyle _nameStyle;
private GUIStyle _dimStyle;
private GUIStyle _tagStyle;
private GUIStyle _messageStyle;
private GUIStyle _statusStyle;
private GUIStyle _tipStyle;
internal static bool IsMouseOver { get; private set; }
private static Settings S => Plugin.Settings;
private void Awake()
{
_instance = this;
_blocker = new ClickBlocker("OnTogetherMods OutfitSlots ClickBlocker");
}
private void OnDestroy()
{
if ((Object)(object)_instance == (Object)(object)this)
{
_instance = null;
IsMouseOver = false;
}
_blocker?.Destroy();
}
private void Update()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
try
{
_screenOpen = Game.ScreenOpen;
bool iconClicked = _iconClicked;
bool iconRightClicked = _iconRightClicked;
int picked = _picked;
_iconClicked = false;
_iconRightClicked = false;
_picked = -1;
if ((Input.GetKeyDown(S.ToggleKey.Value) && !IsChatOpen()) || iconClicked)
{
_open = !_open;
_status = null;
}
if (iconRightClicked && Slots.Active)
{
Wear(Swap.NextSlot());
}
if (picked >= 0)
{
Wear(picked);
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)ex);
}
UpdateMouseOver();
}
private void Wear(int slot)
{
string text;
try
{
text = Swap.Wear(slot);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)ex);
text = "Couldn't change outfit. See the BepInEx log.";
}
Status(text);
if (_open && S.CloseAfterSwap.Value && text.StartsWith("Wearing", StringComparison.Ordinal))
{
_open = false;
}
}
private void UpdateMouseOver()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
bool flag = _open && Time.frameCount - _drawnFrame <= 2;
IsMouseOver = flag && ClickBlocker.MouseIn(_screenRect);
_blocker?.Update(flag, _screenRect);
}
private static bool IsChatOpen()
{
TaskManager i = MonoSingleton<TaskManager>.I;
if ((Object)(object)i != (Object)null)
{
return i.IsWriting;
}
return false;
}
private void Status(string text)
{
_status = text;
_statusUntil = Time.unscaledTime + 4f;
}
private void OnGUI()
{
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
if (S.ShowIcon.Value)
{
IconBar.State state = ((!Slots.Active) ? IconBar.State.Off : (_open ? IconBar.State.Open : IconBar.State.Plain));
switch (IconBar.Draw("OutfitSlots", 35, Icon.Pixels, state, "Outfit Slots", S.ToggleKey.Value, Slots.Active ? "Right-click: next outfit" : null))
{
case IconBar.Click.Left:
_iconClicked = true;
break;
case IconBar.Click.Right:
_iconRightClicked = true;
break;
}
}
if (!_open || PanelStack.Hidden || _screenOpen)
{
return;
}
if (_boxStyle == null)
{
MakeStyles();
}
float width;
Matrix4x4 previous = PanelStack.Begin(out width);
try
{
DrawWindow();
}
catch (Exception ex) when (!(ex is ExitGUIException))
{
Plugin.Log.LogError((object)ex);
}
finally
{
PanelStack.End(previous);
}
}
private void DrawWindow()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
float num = 276f;
float num2 = 37f + num + 3f + 22f + 10f;
Rect val = PanelStack.Place("OutfitSlots", 60, new Vector2(300f, num2));
float num3 = (float)Screen.height / 1080f;
_screenRect = new Rect(((Rect)(ref val)).x * num3, ((Rect)(ref val)).y * num3, ((Rect)(ref val)).width * num3, ((Rect)(ref val)).height * num3);
_drawnFrame = Time.frameCount;
GUI.Box(val, GUIContent.none, _boxStyle);
float num4 = ((Rect)(ref val)).x + 10f;
float num5 = ((Rect)(ref val)).width - 20f;
float num6 = ((Rect)(ref val)).y + 10f;
GUI.Label(new Rect(num4, num6, num5, 24f), "<b>OUTFIT SLOTS</b>", _titleStyle);
GUI.Label(new Rect(num4, num6, num5, 24f), $"{S.ToggleKey.Value} to close", _keyStyle);
num6 += 27f;
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(num4, num6, num5, num);
if (Slots.Active)
{
DrawList(val2);
}
else
{
GUI.Label(val2, "Outfit Slots is off, because BlueSage QoL's own style slots 4-9 are on and both change the same part of the game.\n\nTo use this mod, set EnableExtendedAvatarStyles = false in BepInEx\\config\\com.bluesage.ontogether.qoltweaks.beta.cfg (or switch BlueSage's avatar styles off in its menu), then restart the game.", _messageStyle);
}
num6 += num + 3f;
DrawStatus(new Rect(num4, num6, num5, 22f));
}
private void DrawList(Rect area)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
PlayerDataZip val = (((Object)(object)Game.Data != (Object)null) ? Game.Data.PlayerDataZip : null);
int num = val?.SelectedStyleIndex ?? (-1);
Rect val2 = default(Rect);
Rect val3 = default(Rect);
for (int i = 0; i < 9; i++)
{
((Rect)(ref val2))..ctor(((Rect)(ref area)).x, ((Rect)(ref area)).y + (float)i * 31f, ((Rect)(ref area)).width, 28f);
bool flag = i == num;
if (GUI.Button(val2, GUIContent.none, flag ? _wearingStyle : _rowStyle))
{
_picked = i;
}
GUI.Label(new Rect(((Rect)(ref val2)).x + 8f, ((Rect)(ref val2)).y, 26f, ((Rect)(ref val2)).height), (i + 1).ToString(), _numberStyle);
string text = Slots.Name(val, i).Trim();
((Rect)(ref val3))..ctor(((Rect)(ref val2)).x + 8f + 26f, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width - 8f - 26f - 62f, ((Rect)(ref val2)).height);
if (text.Length > 0)
{
GUI.Label(val3, text, _nameStyle);
}
else
{
GUI.Label(val3, Slots.IsEmpty(i) ? "empty" : "no name", _dimStyle);
}
if (flag)
{
GUI.Label(new Rect(((Rect)(ref val2)).xMax - 62f - 6f, ((Rect)(ref val2)).y, 62f, ((Rect)(ref val2)).height), "wearing", _tagStyle);
}
}
}
private void DrawStatus(Rect row)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (_status != null && Time.unscaledTime < _statusUntil)
{
GUI.Label(row, _status, _statusStyle);
}
else if (Slots.Active)
{
GUI.Label(row, "Click an outfit to put it on", _tipStyle);
}
}
private void MakeStyles()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Expected O, but got Unknown
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Expected O, but got Unknown
Color color = default(Color);
((Color)(ref color))..ctor(1f, 1f, 1f, 0.55f);
_boxStyle = PanelStack.MakeStyle((TextAnchor)0);
_titleStyle = Label(15, Color.white, (TextAnchor)3);
_titleStyle.richText = true;
_keyStyle = Label(13, new Color(1f, 1f, 1f, 0.65f), (TextAnchor)5);
_numberStyle = Label(15, new Color(1f, 1f, 1f, 0.65f), (TextAnchor)3);
_nameStyle = Label(15, Color.white, (TextAnchor)3);
_dimStyle = Label(15, color, (TextAnchor)3);
_tagStyle = Label(13, Color32.op_Implicit(new Color32((byte)140, (byte)220, (byte)120, byte.MaxValue)), (TextAnchor)5);
_tipStyle = Label(14, new Color(1f, 1f, 1f, 0.65f), (TextAnchor)3);
_statusStyle = Label(14, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)217, (byte)102, byte.MaxValue)), (TextAnchor)3);
_messageStyle = Label(14, Color.white, (TextAnchor)0);
_messageStyle.wordWrap = true;
_rowStyle = new GUIStyle(GUI.skin.button);
_wearingStyle = new GUIStyle(GUI.skin.button);
_wearingStyle.normal = GUI.skin.button.onNormal;
_wearingStyle.hover = GUI.skin.button.onHover;
_wearingStyle.active = GUI.skin.button.onActive;
}
private static GUIStyle Label(int size, Color color, TextAnchor alignment)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
GUIStyle val = new GUIStyle(GUI.skin.label)
{
fontSize = size,
alignment = alignment,
richText = false,
wordWrap = false,
clipping = (TextClipping)1,
padding = new RectOffset(0, 0, 0, 0),
margin = new RectOffset(0, 0, 0, 0)
};
val.normal.textColor = color;
return val;
}
}
[HarmonyPatch(typeof(DataManager), "LoadZipDataStatus")]
internal static class LoadSavePatch
{
private static void Postfix(ref PlayerDataZip playerData)
{
Slots.Inflate(playerData);
}
}
[HarmonyPatch(typeof(DataManager), "LoadPlayerData")]
internal static class LoadedPatch
{
private static void Postfix(DataManager __instance)
{
Game.Data = __instance;
PlayerDataZip playerDataZip = __instance.PlayerDataZip;
if (Slots.Active && playerDataZip != null)
{
Plugin.Log.LogInfo((object)("Wearing outfit " + Slots.Label(playerDataZip, playerDataZip.SelectedStyleIndex) + "."));
}
}
}
[HarmonyPatch]
internal static class WriteSavePatch
{
private static Slots.Saved _saved;
private static IEnumerable<MethodBase> TargetMethods()
{
yield return AccessTools.Method(typeof(DataManager), "SavePlayerZipData", (Type[])null, (Type[])null);
yield return AccessTools.Method(typeof(DataManager), "SaveOldPlayerZipData", (Type[])null, (Type[])null);
}
private static void Prefix(DataManager __instance)
{
_saved = Slots.Deflate(__instance.PlayerDataZip);
}
private static void Finalizer(DataManager __instance, MethodBase __originalMethod, Exception __exception)
{
Slots.Restore(_saved);
_saved = null;
if (__exception == null && __originalMethod.Name == "SavePlayerZipData")
{
Slots.SaveStore(__instance.PlayerDataZip);
}
}
}
[HarmonyPatch]
internal static class WriteBackupPatch
{
private static Slots.Saved _saved;
private static MethodBase TargetMethod()
{
return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(DataManager), "SaveBackupZipData", (Type[])null, (Type[])null));
}
private static void Prefix()
{
DataManager data = Game.Data;
_saved = (((Object)(object)data != (Object)null) ? Slots.Deflate(data.PlayerDataZip) : null);
}
private static void Finalizer()
{
Slots.Restore(_saved);
_saved = null;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal static class GetOutfitPatch
{
private static bool Prefix(PlayerDataZip __instance, ref CustomizationDataIDs3 __result)
{
int selectedStyleIndex = __instance.SelectedStyleIndex;
if (!Slots.Active || !Slots.IsModSlot(selectedStyleIndex))
{
return true;
}
__result = Slots.OutfitFor(__instance, selectedStyleIndex);
return false;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal static class SetOutfitPatch
{
private static bool Prefix(PlayerDataZip __instance, CustomizationDataIDs3 value)
{
int selectedStyleIndex = __instance.SelectedStyleIndex;
if (!Slots.Active || !Slots.IsModSlot(selectedStyleIndex))
{
return true;
}
Slots.SetOutfitFor(__instance, selectedStyleIndex, value);
return false;
}
}
[HarmonyPatch(typeof(CustomizationUIController), "Start")]
internal static class CustomizationStartPatch
{
private static void Postfix(CustomizationUIController __instance)
{
Game.Customization = __instance;
}
}
[HarmonyPatch(typeof(CustomizationUIController), "InitStyleDropdown")]
internal static class StyleListPatch
{
private static void Prefix(CustomizationUIController __instance)
{
if (!Slots.Active)
{
return;
}
try
{
Dropdown.Prepare(__instance);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)ex);
}
}
}
[HarmonyPatch(typeof(CustomizationUIController), "ButtonOpenStyleDropdown")]
internal static class OpenStyleListPatch
{
private static void Postfix(CustomizationUIController __instance)
{
if (!Slots.Active)
{
return;
}
try
{
Dropdown.Opened(__instance);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)ex);
}
}
}
[HarmonyPatch(typeof(InputManager), "Update")]
internal static class InputPatch
{
private static readonly Action<InputManager, bool> SetMouse0Down = (Action<InputManager, bool>)Delegate.CreateDelegate(typeof(Action<InputManager, bool>), AccessTools.PropertySetter(typeof(InputManager), "IsMouseButton0Down"));
private static void Postfix(InputManager __instance)
{
if (OutfitWindow.IsMouseOver)
{
SetMouse0Down(__instance, arg2: false);
}
}
}
[BepInPlugin("nelphei.ontogether.outfitslots", "Outfit Slots", "0.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "nelphei.ontogether.outfitslots";
public const string PluginName = "Outfit Slots";
public const string PluginVersion = "0.1.0";
internal static ManualLogSource Log;
internal static Settings Settings;
private Harmony _harmony;
private GameObject _host;
private void Awake()
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
Settings = new Settings(((BaseUnityPlugin)this).Config);
if (BlueSage.SlotsOn())
{
Log.LogWarning((object)("BlueSage QoL's own style slots 4-9 are on, so Outfit Slots stays off: both change the same part of the game. Set EnableExtendedAvatarStyles = false in " + BlueSage.SettingsFile + " (or switch them off in BlueSage's menu) and restart the game to use Outfit Slots."));
}
else
{
Slots.Store.Load();
Slots.Active = true;
}
_harmony = new Harmony("nelphei.ontogether.outfitslots");
try
{
_harmony.PatchAll();
}
catch (Exception arg)
{
Slots.Active = false;
_harmony.UnpatchSelf();
Log.LogError((object)$"Outfit Slots couldn't hook into the game (has it been updated?), so it's off: {arg}");
}
IconBar.Patch();
_host = new GameObject("OutfitSlots");
((Object)_host).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)_host);
_host.AddComponent<OutfitWindow>();
if (Slots.Active)
{
Log.LogInfo((object)("Outfit Slots 0.1.0 loaded. Slots 4-9 are in the outfit screen's style list, " + $"and {Settings.ToggleKey.Value} opens the quick-swap window. Saved in {Slots.Store.FilePath}."));
}
}
private void OnDestroy()
{
if ((Object)(object)_host != (Object)null)
{
Object.Destroy((Object)(object)_host);
}
}
}
internal sealed class Settings
{
public readonly ConfigEntry<KeyCode> ToggleKey;
public readonly ConfigEntry<bool> CloseAfterSwap;
public readonly ConfigEntry<bool> ShowIcon;
public readonly ConfigEntry<bool> DebugLog;
public Settings(ConfigFile config)
{
ToggleKey = config.Bind<KeyCode>("Keys", "ToggleKey", (KeyCode)283, "Opens and closes the quick-swap window.");
CloseAfterSwap = config.Bind<bool>("Display", "CloseAfterSwap", false, "Close the quick-swap window after you pick an outfit.");
ShowIcon = config.Bind<bool>("Display", "ShowIcon", true, "Show a shirt icon in the row of mod icons at the bottom-right (in a world). Clicking it opens and closes the quick-swap window, and right-clicking it puts on your next outfit.");
DebugLog = config.Bind<bool>("Debug", "DebugLog", false, "Write the layout of the outfit screen's style list to the BepInEx log the first time it opens, for fixing where the extra rows go.");
}
}
internal static class Slots
{
internal sealed class Saved
{
public PlayerDataZip Zip;
public int Selected;
public List<string> Names;
}
public const int GameSlots = 3;
public const int Total = 9;
public static readonly OutfitStore Store = new OutfitStore();
private static readonly ConditionalWeakTable<PlayerDataZip, StrongBox<int>> GameSlotOf = new ConditionalWeakTable<PlayerDataZip, StrongBox<int>>();
public static bool Active { get; set; }
public static bool IsModSlot(int slot)
{
if (slot >= 3)
{
return slot < 9;
}
return false;
}
public static void Inflate(PlayerDataZip zip)
{
if (Active && zip != null)
{
int num = zip.SelectedStyleIndex;
if (num < 0 || num >= 3)
{
Plugin.Log.LogWarning((object)$"The game's save said outfit slot {num + 1}, which it can't load, so it's on slot 1 instead.");
num = 0;
zip.SelectedStyleIndex = 0;
}
GameSlotOf.Remove(zip);
GameSlotOf.Add(zip, new StrongBox<int>(num));
zip.StyleNames = NineNames(zip.StyleNames);
int selectedSlot = Store.SelectedSlot;
if (IsModSlot(selectedSlot) && Store.GameSlot == num && Store.Outfit(selectedSlot) != null)
{
zip.SelectedStyleIndex = selectedSlot;
}
}
}
public static void EnsureNames(PlayerDataZip zip)
{
if (zip != null && (zip.StyleNames == null || zip.StyleNames.Count < 9))
{
zip.StyleNames = NineNames(zip.StyleNames);
}
}
private static List<string> NineNames(List<string> game)
{
List<string> list = new List<string>(9);
for (int i = 0; i < 3; i++)
{
list.Add((game != null && i < game.Count && game[i] != null) ? game[i] : "");
}
for (int j = 3; j < 9; j++)
{
list.Add(Store.Name(j));
}
return list;
}
public static CustomizationDataIDs3 OutfitFor(PlayerDataZip zip, int slot)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
CustomizationDataIDs3 val = Store.Outfit(slot);
if (val == null)
{
DataManager data = Game.Data;
val = (((Object)(object)data != (Object)null && data.CustomizationData != null) ? new CustomizationDataIDs3(data.CustomizationData) : new CustomizationDataIDs3());
Store.SetOutfit(slot, val);
SaveStore(zip);
}
return val;
}
public static void SetOutfitFor(PlayerDataZip zip, int slot, CustomizationDataIDs3 outfit)
{
if (outfit != null)
{
Store.SetOutfit(slot, outfit);
SaveStore(zip);
}
}
public static Saved Deflate(PlayerDataZip zip)
{
if (zip == null)
{
return null;
}
int selectedStyleIndex = GameSlot(zip);
bool flag = zip.SelectedStyleIndex >= 3;
bool flag2 = zip.StyleNames != null && zip.StyleNames.Count > 3;
if (!flag && !flag2)
{
return null;
}
Saved result = new Saved
{
Zip = zip,
Selected = zip.SelectedStyleIndex,
Names = zip.StyleNames
};
if (flag)
{
zip.SelectedStyleIndex = selectedStyleIndex;
}
if (flag2)
{
zip.StyleNames = zip.StyleNames.GetRange(0, 3);
}
return result;
}
public static void Restore(Saved saved)
{
if (saved != null)
{
saved.Zip.SelectedStyleIndex = saved.Selected;
saved.Zip.StyleNames = saved.Names;
}
}
private static int GameSlot(PlayerDataZip zip)
{
int selectedStyleIndex = zip.SelectedStyleIndex;
if (!GameSlotOf.TryGetValue(zip, out var value))
{
value = new StrongBox<int>((selectedStyleIndex >= 0 && selectedStyleIndex < 3) ? selectedStyleIndex : 0);
GameSlotOf.Add(zip, value);
}
if (selectedStyleIndex >= 0 && selectedStyleIndex < 3)
{
value.Value = selectedStyleIndex;
}
return value.Value;
}
public static void SaveStore(PlayerDataZip zip)
{
DataManager data = Game.Data;
if (!Active || zip == null || (Object)(object)data == (Object)null || data.PlayerDataZip != zip)
{
return;
}
Store.SelectedSlot = ((zip.SelectedStyleIndex >= 0 && zip.SelectedStyleIndex < 9) ? zip.SelectedStyleIndex : 0);
Store.GameSlot = GameSlot(zip);
if (zip.StyleNames != null && zip.StyleNames.Count >= 9)
{
for (int i = 3; i < 9; i++)
{
Store.SetName(i, zip.StyleNames[i]);
}
}
Store.SaveIfChanged();
}
public static string Name(PlayerDataZip zip, int slot)
{
if (zip?.StyleNames != null && slot < zip.StyleNames.Count)
{
return zip.StyleNames[slot] ?? "";
}
if (!IsModSlot(slot))
{
return "";
}
return Store.Name(slot);
}
public static string Label(PlayerDataZip zip, int slot)
{
string text = Name(zip, slot).Trim();
if (text.Length <= 0)
{
return $"slot {slot + 1}";
}
return $"{slot + 1} ({text})";
}
public static bool IsEmpty(int slot)
{
if (IsModSlot(slot))
{
return Store.Outfit(slot) == null;
}
return false;
}
}
internal static class Swap
{
public static string Wear(int slot)
{
if (!Slots.Active)
{
return "Outfit Slots is off";
}
DataManager data = Game.Data;
PlayerDataZip val = (((Object)(object)data != (Object)null) ? data.PlayerDataZip : null);
if (val == null || data.CustomizationData == null)
{
return "Your save hasn't loaded yet";
}
Slots.EnsureNames(val);
if (val.SelectedStyleIndex == slot)
{
return "You're already wearing " + Slots.Label(val, slot);
}
CustomizationUIController customization = Game.Customization;
if ((Object)(object)customization != (Object)null && Game.IsOpen(customization))
{
return "Pick it in the outfit screen's own list";
}
if ((Object)(object)customization != (Object)null && ((Behaviour)customization).isActiveAndEnabled)
{
customization.ButtonSelectStyle(slot);
customization.CloseAvatarPanel(true);
}
else
{
WearDirectly(data, val, customization, slot);
}
if (val.SelectedStyleIndex != slot)
{
return "Couldn't change outfit";
}
return "Wearing " + Slots.Label(val, slot);
}
private static void WearDirectly(DataManager data, PlayerDataZip zip, CustomizationUIController screen, int slot)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
zip.SelectedStyleIndex = slot;
data.CustomizationData = new CustomizationData(zip.CurrentCustomizationDataIDs);
if ((Object)(object)screen != (Object)null)
{
screen._customizationData = new CustomizationData(data.CustomizationData);
}
data.SavePlayerZipData();
if (Game.InWorld)
{
TextChannelManager i = NetworkSingleton<TextChannelManager>.I;
if ((Object)(object)i != (Object)null && (Object)(object)i.MainCustomizationController != (Object)null)
{
i.MainCustomizationController.ApplyCustomization(data.CustomizationData);
}
}
}
public static int NextSlot()
{
int num = (((Object)(object)Game.Data != (Object)null) ? Game.Data.PlayerDataZip : null)?.SelectedStyleIndex ?? 0;
for (int i = 1; i <= 9; i++)
{
int num2 = (num + i) % 9;
if (!Slots.IsEmpty(num2))
{
return num2;
}
}
return num;
}
}
}