using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Samples.RebindUI;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.Localization.Settings;
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("SkinCollection")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+8264aeb2766a81fc055ca7c80c51a8e91779a2da")]
[assembly: AssemblyProduct("SkinCollection")]
[assembly: AssemblyTitle("SkinCollection")]
[assembly: AssemblyVersion("1.1.1.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 SkinCollection
{
public class SkinCollectionRow : MonoBehaviour
{
public Transform Source;
}
public static class ControlsMenu
{
private struct RowSpec
{
public string Label;
public InputAction Action;
public Guid KeyboardId;
public Guid ControllerId;
}
private const string TemplateAction = "PlayerTab";
private static readonly FieldInfo ActionField = AccessTools.Field(typeof(RebindActionUI), "m_Action");
private static readonly FieldInfo BindingIdField = AccessTools.Field(typeof(RebindActionUI), "m_BindingId");
private static readonly HashSet<RebindActionUI> Pending = new HashSet<RebindActionUI>();
private static readonly Dictionary<RebindActionUI, (TextMeshProUGUI Label, string Key)> Labels = new Dictionary<RebindActionUI, (TextMeshProUGUI, string)>();
private static ModInput _input;
private static bool _loggedLayout;
public static void Init(ModInput input)
{
_input = input;
Strings.LanguageChanged += OnLanguageChanged;
}
public static void Notice(RebindActionUI ui)
{
if (_input != null && ActionName(ui) == "PlayerTab")
{
Pending.Add(ui);
}
}
public static void ProcessPending()
{
if (Pending.Count == 0)
{
return;
}
List<RebindActionUI> list = Pending.ToList();
Pending.Clear();
foreach (RebindActionUI item in list)
{
try
{
if ((Object)(object)item == (Object)null || ActionName(item) != "PlayerTab" || (Object)(object)((Component)item).GetComponentInParent<SkinCollectionRow>(true) != (Object)null)
{
continue;
}
Transform val = FindRow(((Component)item).transform);
if (!((Object)(object)val.parent == (Object)null))
{
Transform column = FindTargetColumn(val);
if (!AlreadyInjected(column, val))
{
Inject(val, column);
}
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Could not add Skin Collection rows to the Controls menu: {arg}");
}
}
}
private static Transform FindRow(Transform t)
{
Transform val = t;
while ((Object)(object)val.parent != (Object)null && !((Component)val.parent).GetComponentsInChildren<RebindActionUI>(true).Any((RebindActionUI u) => ActionName(u) != "PlayerTab"))
{
val = val.parent;
}
return val;
}
private static Transform FindTargetColumn(Transform row)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
Transform parent = row.parent;
if ((Object)(object)parent.parent == (Object)null)
{
return parent;
}
Transform result = parent;
int num = RowCount(parent);
foreach (Transform item in parent.parent)
{
Transform val = item;
if (!((Object)(object)val == (Object)(object)parent) && !((Object)(object)((Component)val).GetComponent<LayoutGroup>() == (Object)null))
{
int num2 = RowCount(val);
if (num2 > 0 && num2 < num)
{
result = val;
num = num2;
}
}
}
return result;
}
private static int RowCount(Transform column)
{
return ((IEnumerable)column).Cast<Transform>().Count((Transform c) => (Object)(object)((Component)c).GetComponentInChildren<RebindActionUI>(true) != (Object)null);
}
private static bool AlreadyInjected(Transform column, Transform row)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
foreach (Transform item in column)
{
SkinCollectionRow component = ((Component)item).GetComponent<SkinCollectionRow>();
if ((Object)(object)component != (Object)null && (Object)(object)component.Source == (Object)(object)row)
{
return true;
}
}
return false;
}
private static void Inject(Transform row, Transform column)
{
if (!_loggedLayout)
{
_loggedLayout = true;
LogHierarchy(row);
}
RowSpec[] obj = new RowSpec[2]
{
new RowSpec
{
Label = "Title",
Action = _input.Open,
KeyboardId = ModInput.OpenKeyboardId,
ControllerId = ModInput.OpenControllerId
},
new RowSpec
{
Label = "ShowUnobtainableRow",
Action = _input.ToggleUnobtainable,
KeyboardId = ModInput.ToggleKeyboardId,
ControllerId = ModInput.ToggleControllerId
}
};
Transform val = ((IEnumerable)column).Cast<Transform>().LastOrDefault((Func<Transform, bool>)((Transform c) => (Object)(object)((Component)c).GetComponentInChildren<RebindActionUI>(true) != (Object)null)) ?? row;
List<Transform> list = new List<Transform>();
int num = (((Object)(object)val.parent == (Object)(object)column) ? val.GetSiblingIndex() : (column.childCount - 1));
RowSpec[] array = obj;
for (int num2 = 0; num2 < array.Length; num2++)
{
RowSpec spec = array[num2];
GameObject val2 = Object.Instantiate<GameObject>(((Component)row).gameObject, column, false);
((Object)val2).name = "SkinCollection_" + spec.Action.name;
val2.transform.SetSiblingIndex(++num);
val2.AddComponent<SkinCollectionRow>().Source = row;
Retarget(val2.transform, spec);
list.Add(val2.transform);
}
ChainNavigation(val, list);
Plugin.Log.LogInfo((object)$"Added {list.Count} Skin Collection rows to the Controls menu under '{((Object)column).name}'");
}
private static void Retarget(Transform clone, RowSpec spec)
{
//IL_0046: 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_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_005c: Unknown result type (might be due to invalid IL or missing references)
HashSet<TextMeshProUGUI> excluded = new HashSet<TextMeshProUGUI>();
List<Transform> overlays = new List<Transform>();
TextMeshProUGUI val = null;
RebindActionUI[] componentsInChildren = ((Component)clone).GetComponentsInChildren<RebindActionUI>(true);
InputAction val3 = default(InputAction);
int num = default(int);
foreach (RebindActionUI val2 in componentsInChildren)
{
int num2;
if (val2.ResolveActionAndBinding(ref val3, ref num))
{
InputBinding val4 = InputBinding.MaskByGroup("Controller");
num2 = (((InputBinding)(ref val4)).Matches(val3.bindings[num]) ? 1 : 0);
}
else
{
num2 = 0;
}
bool flag = (byte)num2 != 0;
ActionField.SetValue(val2, InputActionReference.Create(spec.Action));
BindingIdField.SetValue(val2, (flag ? spec.ControllerId : spec.KeyboardId).ToString());
val2.UpdateBindingDisplay();
TextMeshProUGUI[] array = (TextMeshProUGUI[])(object)new TextMeshProUGUI[3] { val2.bindingText, val2.rebindPrompt, val2.rebindInfo };
foreach (TextMeshProUGUI val5 in array)
{
if ((Object)(object)val5 != (Object)null)
{
excluded.Add(val5);
}
}
if ((Object)(object)val2.rebindOverlay != (Object)null)
{
overlays.Add(val2.rebindOverlay.transform);
}
if ((Object)(object)val == (Object)null && (Object)(object)val2.actionLabel != (Object)null && ((TMP_Text)val2.actionLabel).transform.IsChildOf(clone))
{
val = val2.actionLabel;
}
}
if ((Object)(object)val == (Object)null)
{
val = ((IEnumerable<TextMeshProUGUI>)((Component)clone).GetComponentsInChildren<TextMeshProUGUI>(true)).FirstOrDefault((Func<TextMeshProUGUI, bool>)((TextMeshProUGUI t) => !excluded.Contains(t) && !overlays.Any((Transform o) => ((TMP_Text)t).transform.IsChildOf(o))));
}
if ((Object)(object)val == (Object)null)
{
Plugin.Log.LogWarning((object)("No label found in the cloned Controls row for '" + spec.Label + "'"));
return;
}
LocalizeStringEvent component = ((Component)val).GetComponent<LocalizeStringEvent>();
if ((Object)(object)component != (Object)null)
{
((Behaviour)component).enabled = false;
}
((TMP_Text)val).text = Strings.Get(spec.Label);
componentsInChildren = ((Component)clone).GetComponentsInChildren<RebindActionUI>(true);
foreach (RebindActionUI val6 in componentsInChildren)
{
Labels[val6] = (val, spec.Label);
val6.UpdateBindingDisplay();
}
}
private static void ChainNavigation(Transform anchor, List<Transform> clones)
{
//IL_004f: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Invalid comparison between Unknown and I4
//IL_0090: 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_00b9: 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_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Invalid comparison between Unknown and I4
//IL_00f7: 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_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//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_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
Selectable[] original = ((Component)anchor).GetComponentsInChildren<Selectable>(true);
List<Selectable[]> list = clones.Select((Transform c) => ((Component)c).GetComponentsInChildren<Selectable>(true)).ToList();
for (int num = 0; num < original.Length; num++)
{
Selectable val = original[num];
Navigation navigation = val.navigation;
if ((int)((Navigation)(ref navigation)).mode != 4 || list.Any((Selectable[] c) => c.Length != original.Length))
{
continue;
}
navigation = val.navigation;
Selectable selectOnDown = ((Navigation)(ref navigation)).selectOnDown;
Selectable val2 = val;
for (int num2 = 0; num2 < list.Count; num2++)
{
Selectable val3 = list[num2][num];
Navigation navigation2 = val3.navigation;
((Navigation)(ref navigation2)).mode = (Mode)4;
((Navigation)(ref navigation2)).selectOnUp = val2;
((Navigation)(ref navigation2)).selectOnDown = ((num2 + 1 < list.Count) ? list[num2 + 1][num] : selectOnDown);
navigation = val.navigation;
((Navigation)(ref navigation2)).selectOnLeft = MapWithinRow(((Navigation)(ref navigation)).selectOnLeft, original, list[num2]);
navigation = val.navigation;
((Navigation)(ref navigation2)).selectOnRight = MapWithinRow(((Navigation)(ref navigation)).selectOnRight, original, list[num2]);
val3.navigation = navigation2;
Navigation navigation3 = val2.navigation;
((Navigation)(ref navigation3)).selectOnDown = val3;
val2.navigation = navigation3;
val2 = val3;
}
if (!((Object)(object)selectOnDown != (Object)null))
{
continue;
}
navigation = selectOnDown.navigation;
if ((int)((Navigation)(ref navigation)).mode == 4)
{
navigation = selectOnDown.navigation;
if ((Object)(object)((Navigation)(ref navigation)).selectOnUp == (Object)(object)val)
{
Navigation navigation4 = selectOnDown.navigation;
((Navigation)(ref navigation4)).selectOnUp = val2;
selectOnDown.navigation = navigation4;
}
}
}
}
private static Selectable MapWithinRow(Selectable target, Selectable[] original, Selectable[] clone)
{
int num = Array.IndexOf(original, target);
if (num < 0)
{
return target;
}
return clone[num];
}
public static void DecorateBinding(RebindActionUI ui)
{
//IL_005a: 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)
if (_input != null && Labels.TryGetValue(ui, out (TextMeshProUGUI, string) value) && !((Object)(object)value.Item1 == (Object)null))
{
object? value2 = ActionField.GetValue(ui);
object? obj = ((value2 is InputActionReference) ? value2 : null);
InputAction val = ((obj != null) ? ((InputActionReference)obj).action : null);
int num = ((val != null) ? InputActionExtensions.FindBindingById(val, ui.bindingId) : (-1));
bool flag = num >= 0 && ModInput.IsHold(val.bindings[num]);
string text = Strings.Get(value.Item2);
((TMP_Text)value.Item1).text = (flag ? (text + " <size=75%>" + Strings.Get("HoldTag") + "</size>") : text);
}
}
private static void OnLanguageChanged()
{
foreach (RebindActionUI item in Labels.Keys.ToList())
{
if ((Object)(object)item == (Object)null)
{
Labels.Remove(item);
}
else
{
DecorateBinding(item);
}
}
}
private static string ActionName(RebindActionUI ui)
{
object? value = ActionField.GetValue(ui);
InputActionReference val = (InputActionReference)((value is InputActionReference) ? value : null);
if (!((Object)(object)val != (Object)null) || val.action == null)
{
return null;
}
return val.action.name;
}
private static void LogHierarchy(Transform row)
{
StringBuilder stringBuilder = new StringBuilder("Controls row template '" + ((Object)row).name + "' (parent '" + ((Object)row.parent).name + "'):\n");
Append(stringBuilder, row, 0);
Plugin.Log.LogInfo((object)stringBuilder.ToString());
}
private static void Append(StringBuilder sb, Transform t, int depth)
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
if (depth > 5)
{
return;
}
string value = string.Join(", ", from c in ((Component)t).GetComponents<Component>()
where (Object)(object)c != (Object)null && !(c is Transform)
select ((object)c).GetType().Name);
sb.Append(' ', depth * 2).Append(((Object)t).name).Append(" [")
.Append(value)
.Append("]\n");
foreach (Transform item in t)
{
Transform t2 = item;
Append(sb, t2, depth + 1);
}
}
}
[HarmonyPatch(typeof(RebindActionUI), "OnEnable")]
internal static class RebindActionUIOnEnablePatch
{
private static void Postfix(RebindActionUI __instance)
{
ControlsMenu.Notice(__instance);
}
}
[HarmonyPatch(typeof(RebindActionUI), "UpdateBindingDisplay")]
internal static class RebindActionUIUpdateBindingDisplayPatch
{
private static void Postfix(RebindActionUI __instance)
{
ControlsMenu.DecorateBinding(__instance);
}
}
public sealed class ModInput
{
public const string KeyboardGroup = "Keyboard";
public const string ControllerGroup = "Controller";
public static readonly Guid OpenKeyboardId = new Guid("5b1f0c1e-6a43-4f7e-9d0a-1c2e3f405161");
public static readonly Guid OpenControllerId = new Guid("5b1f0c1e-6a43-4f7e-9d0a-1c2e3f405162");
public static readonly Guid ToggleKeyboardId = new Guid("5b1f0c1e-6a43-4f7e-9d0a-1c2e3f405163");
public static readonly Guid ToggleControllerId = new Guid("5b1f0c1e-6a43-4f7e-9d0a-1c2e3f405164");
private const string HoldInteraction = "hold(duration=0.5)";
private const string TapInteraction = "tap(duration=0.5)";
private readonly InputActionAsset _asset;
private readonly InputActionMap _map;
private readonly ConfigEntry<string> _overrides;
private bool _tapDirty = true;
public InputAction Open { get; }
public InputAction ToggleUnobtainable { get; }
public static ModInput Instance { get; private set; }
public ModInput(ConfigEntry<string> overrides)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
Instance = this;
_overrides = overrides;
_asset = ScriptableObject.CreateInstance<InputActionAsset>();
((Object)_asset).name = "SkinCollectionInput";
Object.DontDestroyOnLoad((Object)(object)_asset);
_map = new InputActionMap("SkinCollection");
InputActionSetupExtensions.AddActionMap(_asset, _map);
Open = InputActionSetupExtensions.AddAction(_map, "OpenSkinMenu", (InputActionType)1, (string)null, (string)null, (string)null, (string)null, (string)null);
AddBinding(Open, OpenKeyboardId, "<Keyboard>/k", "Keyboard");
AddBinding(Open, OpenControllerId, "<Gamepad>/select", "Controller", "hold(duration=0.5)");
ToggleUnobtainable = InputActionSetupExtensions.AddAction(_map, "ToggleUnobtainableSkins", (InputActionType)1, (string)null, (string)null, (string)null, (string)null, (string)null);
AddBinding(ToggleUnobtainable, ToggleKeyboardId, "<Keyboard>/u", "Keyboard");
AddBinding(ToggleUnobtainable, ToggleControllerId, "<Gamepad>/dpad/up", "Controller");
Load();
InputSystem.onActionChange += OnActionChange;
_map.Enable();
}
private void AddBinding(InputAction action, Guid id, string path, string group, string interactions = null)
{
//IL_0008: 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)
InputActionMap map = _map;
InputBinding val = default(InputBinding);
((InputBinding)(ref val)).id = id;
((InputBinding)(ref val)).path = path;
((InputBinding)(ref val)).groups = group;
((InputBinding)(ref val)).action = action.name;
((InputBinding)(ref val)).interactions = interactions;
InputActionSetupExtensions.AddBinding(map, val);
}
public static string Display(InputAction action)
{
try
{
return SpriteManager.InputToSpriteName(action, (InputSchemeSelection)0, -1) ?? "";
}
catch (Exception)
{
return InputActionRebindingExtensions.GetBindingDisplayString(action, (DisplayStringOptions)0, (string)null);
}
}
private void Load()
{
if (string.IsNullOrEmpty(_overrides.Value))
{
return;
}
try
{
InputActionRebindingExtensions.LoadBindingOverridesFromJson((IInputActionCollection2)(object)_asset, _overrides.Value, true);
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Ignoring invalid saved bindings: " + ex.Message));
}
}
private void OnActionChange(object obj, InputActionChange change)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
if ((int)change != 8)
{
return;
}
_tapDirty = true;
object obj2 = ((obj is InputAction) ? obj : null);
if ((((obj2 != null) ? ((InputAction)obj2).actionMap : null) ?? ((obj is InputActionMap) ? obj : null)) == _map || obj == _asset)
{
string text = InputActionRebindingExtensions.SaveBindingOverridesAsJson((IInputActionCollection2)(object)_asset);
if (text != _overrides.Value)
{
_overrides.Value = text;
}
}
}
public static bool IsHold(InputBinding binding)
{
string effectiveInteractions = ((InputBinding)(ref binding)).effectiveInteractions;
if (!string.IsNullOrEmpty(effectiveInteractions))
{
return effectiveInteractions.Contains("hold");
}
return false;
}
public void MarkDirty()
{
_tapDirty = true;
}
public void Update()
{
if (_tapDirty)
{
SyncTapOverrides();
}
}
private static InputActionAsset GameAsset()
{
try
{
return ((Object)(object)GameInfo.Input != (Object)null) ? GameInfo.Input.actions : null;
}
catch (Exception)
{
return null;
}
}
private void SyncTapOverrides()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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_0030: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
InputActionAsset val = GameAsset();
if ((Object)(object)val == (Object)null)
{
return;
}
_tapDirty = false;
HashSet<string> hashSet = new HashSet<string>();
Enumerator<InputBinding> enumerator = _map.bindings.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
InputBinding current = enumerator.Current;
if (IsHold(current) && !string.IsNullOrEmpty(((InputBinding)(ref current)).effectivePath))
{
hashSet.Add(((InputBinding)(ref current)).effectivePath);
}
}
}
finally
{
((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
foreach (InputAction item in val)
{
for (int i = 0; i < item.bindings.Count; i++)
{
InputBinding val2 = item.bindings[i];
if (!((InputBinding)(ref val2)).isComposite && !((InputBinding)(ref val2)).isPartOfComposite)
{
bool flag = hashSet.Contains(((InputBinding)(ref val2)).effectivePath);
bool flag2 = ((InputBinding)(ref val2)).overrideInteractions == "tap(duration=0.5)";
if (flag != flag2)
{
SetTap(item, i, flag);
}
}
}
}
}
public void StripTapOverrides(InputActionAsset asset)
{
//IL_0050: 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_001f: 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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)asset == (Object)null)
{
return;
}
foreach (InputAction item in asset)
{
for (int i = 0; i < item.bindings.Count; i++)
{
InputBinding val = item.bindings[i];
if (((InputBinding)(ref val)).overrideInteractions == "tap(duration=0.5)")
{
SetTap(item, i, on: false);
}
}
}
_tapDirty = true;
}
private static void SetTap(InputAction action, int index, bool on)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
InputBinding val = action.bindings[index];
InputBinding val2 = default(InputBinding);
((InputBinding)(ref val2)).overridePath = ((InputBinding)(ref val)).overridePath;
((InputBinding)(ref val2)).overrideProcessors = ((InputBinding)(ref val)).overrideProcessors;
((InputBinding)(ref val2)).overrideInteractions = (on ? "tap(duration=0.5)" : null);
InputActionRebindingExtensions.ApplyBindingOverride(action, index, val2);
}
}
[HarmonyPatch(typeof(RebindSaveLoad), "Save")]
internal static class RebindSaveLoadSavePatch
{
private static void Prefix(RebindSaveLoad __instance)
{
ModInput.Instance?.StripTapOverrides(__instance.actions);
}
private static void Postfix()
{
ModInput.Instance?.MarkDirty();
}
}
[HarmonyPatch(typeof(RebindSaveLoad), "Load")]
internal static class RebindSaveLoadLoadPatch
{
private static void Postfix()
{
ModInput.Instance?.MarkDirty();
}
}
[HarmonyPatch(typeof(PlayerUI), "ScrollThinkingPage")]
internal static class ScrollThinkingPagePatch
{
private static bool Prefix(int input)
{
if (!SkinMenu.IsOpen || (Object)(object)SkinMenu.Instance == (Object)null)
{
return true;
}
SkinMenu.Instance.Scroll(input);
return false;
}
}
[HarmonyPatch(typeof(PlayerThinking), "ThinkingInput")]
internal static class ThinkingInputPatch
{
private static bool Prefix()
{
if (!SkinMenu.IsOpen || (Object)(object)SkinMenu.Instance == (Object)null || PauseManager.IsPaused)
{
return true;
}
SkinMenu.Instance.SwitchToJournal();
return false;
}
}
[BepInPlugin("avidkaos.howtofish.skincollection", "Skin Collection", "1.1.1")]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "avidkaos.howtofish.skincollection";
public const string PluginName = "Skin Collection";
public const string PluginVersion = "1.1.1";
internal static ManualLogSource Log;
private ConfigEntry<bool> _missingAsSilhouette;
private ConfigEntry<bool> _logOnOpen;
private ConfigEntry<string> _bindings;
private ModInput _input;
private SkinMenu _menu;
private SkinHint _hint;
private void Awake()
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
_missingAsSilhouette = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "MissingAsSilhouette", true, "Draw skins you don't own as black silhouettes, like undiscovered fish in the journal. If false they are dimmed instead.");
ConfigEntry<bool> showUnobtainable = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowUnobtainable", false, "Show skins the slot machine can't give. They never count toward the totals. Remembered from the in-menu toggle.");
_bindings = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "BindingOverrides", "", "Keybinds changed in the game's Controls menu (Skin collection rows). Managed by the game menu; clear to reset.");
ConfigEntry<bool> enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TutorialHint", true, "Show a one-time tip in the game's tutorial style explaining how to open the skin menu. Turns itself off the first time you open the menu; set back to true to see it again.");
_logOnOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogCatalogOnOpen", false, "Also write the full skin list to the log when the menu opens.");
_menu = ((Component)this).gameObject.AddComponent<SkinMenu>();
_menu.ShowUnobtainable = showUnobtainable;
_hint = ((Component)this).gameObject.AddComponent<SkinHint>();
_hint.Enabled = enabled;
new Harmony("avidkaos.howtofish.skincollection").PatchAll(typeof(Plugin).Assembly);
Log.LogInfo((object)"Skin Collection 1.1.1 loaded");
}
private void Start()
{
_input = new ModInput(_bindings);
_input.Open.performed += delegate
{
ToggleMenu();
};
_input.ToggleUnobtainable.performed += delegate
{
_menu.ToggleUnobtainable();
};
_menu.Input = _input;
_hint.Input = _input;
ControlsMenu.Init(_input);
}
private void ToggleMenu()
{
_menu.MissingAsSilhouette = _missingAsSilhouette.Value;
if (_logOnOpen.Value && !SkinMenu.IsOpen)
{
SkinCatalog.LogSummary(Log);
}
_menu.Toggle();
}
private void Update()
{
_input?.Update();
ControlsMenu.ProcessPending();
}
}
public sealed class SkinEntry
{
public byte Index;
public string Name;
public Rarity Rarity;
public bool Owned;
public bool Unobtainable
{
get
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
if (Index != 0)
{
return (int)Rarity == 0;
}
return false;
}
}
}
public sealed class SkinGroup
{
public string Name;
public byte ItemId;
public bool IsBoat;
public List<int> Islands = new List<int>();
public List<SkinEntry> Skins = new List<SkinEntry>();
public int OwnedCount => Skins.Count((SkinEntry s) => s.Owned && !s.Unobtainable);
public int TotalCount => Skins.Count((SkinEntry s) => !s.Unobtainable);
}
public static class SkinCatalog
{
public const byte BoatItemId = byte.MaxValue;
private static readonly byte[] DisplayOrder = new byte[10] { 255, 61, 57, 63, 66, 68, 69, 70, 54, 86 };
public const int BowIsland = 0;
private static readonly (int Island, byte[] Prizes)[] SlotMachines = new(int, byte[])[6]
{
(1, new byte[2] { 57, 63 }),
(2, new byte[5] { 63, 66, 61, 68, 255 }),
(3, new byte[5] { 66, 69, 61, 68, 255 }),
(4, new byte[4] { 61, 69, 70, 255 }),
(5, new byte[4] { 61, 54, 70, 255 }),
(0, new byte[1] { 86 })
};
private static readonly FieldInfo CurLocalSaveField = AccessTools.Field(typeof(SaveManager), "_curLocalSave");
private static readonly FieldInfo BoatPrefabField = AccessTools.Field(typeof(SpawnManager), "_boatPrefab");
public static LocalSaveObject GetLocalSave()
{
object? obj = CurLocalSaveField?.GetValue(null);
return (LocalSaveObject)((obj is LocalSaveObject) ? obj : null);
}
public static List<SkinGroup> Build()
{
LocalSaveObject localSave = GetLocalSave();
List<SkinGroup> list = new List<SkinGroup>();
Item[] array = null;
try
{
array = GameInfo.ItemWithSkinsforCommands;
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("GameInfo.ItemWithSkinsforCommands unavailable: " + ex.Message));
}
if (array != null)
{
Item[] array2 = array;
foreach (Item item in array2)
{
if (!((Object)(object)item == (Object)null) && !((Object)(object)item.SkinPreset == (Object)null))
{
List<byte> unlocked = localSave?.UnlockedItemSkins?.FirstOrDefault((Func<SavedItemSkin, bool>)((SavedItemSkin s) => s.ID == item.ID))?.SkinsUnlocked;
list.Add(MakeGroup(GetItemName(item), item.ID, isBoat: false, item.SkinPreset, unlocked));
}
}
}
Boat val = FindBoat();
if ((Object)(object)val != (Object)null && (Object)(object)val.SkinPreset != (Object)null)
{
list.Add(MakeGroup(GetBoatName(), byte.MaxValue, isBoat: true, val.SkinPreset, localSave?.UnlockedBoatSkins));
}
return list.OrderBy(delegate(SkinGroup g)
{
int num = Array.IndexOf(DisplayOrder, g.ItemId);
return (num >= 0) ? num : int.MaxValue;
}).ToList();
}
private static SkinGroup MakeGroup(string name, byte itemId, bool isBoat, SkinPreset preset, ICollection<byte> unlocked)
{
//IL_007f: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
SkinGroup skinGroup = new SkinGroup
{
Name = name,
ItemId = itemId,
IsBoat = isBoat,
Islands = (from m in SlotMachines
where m.Prizes.Contains(itemId)
select m.Island).ToList()
};
IReadOnlyList<ItemSkin> skins = preset.Skins;
for (int num = 0; num < skins.Count; num++)
{
ItemSkin val = skins[num];
skinGroup.Skins.Add(new SkinEntry
{
Index = (byte)num,
Name = ((ItemSkin)(ref val)).Name,
Rarity = ((ItemSkin)(ref val)).Rarity,
Owned = (num == 0 || (unlocked?.Contains((byte)num) ?? false))
});
}
skinGroup.Skins = skinGroup.Skins.OrderBy(RarityOrder).ThenBy((SkinEntry s) => s.Index).ToList();
return skinGroup;
}
private static int RarityOrder(SkinEntry skin)
{
//IL_000b: 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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected I4, but got Unknown
if (skin.Index == 0)
{
return 0;
}
Rarity rarity = skin.Rarity;
return (rarity - 1) switch
{
0 => 1,
1 => 2,
2 => 3,
_ => 4,
};
}
private static string GetItemName(Item item)
{
try
{
string name = item.GetName();
if (!string.IsNullOrEmpty(name))
{
return name;
}
}
catch (Exception)
{
}
return ((Object)item).name;
}
private static string GetBoatName()
{
try
{
LocalizedString boatLocalized = LocalizationManager.BoatLocalized;
string text = ((boatLocalized != null) ? boatLocalized.GetLocalizedString() : null);
if (!string.IsNullOrEmpty(text))
{
return text;
}
}
catch (Exception)
{
}
return "Boat";
}
public static Boat FindBoat()
{
if ((Object)(object)BoatManager.Boat != (Object)null)
{
return BoatManager.Boat;
}
SpawnManager val = Object.FindAnyObjectByType<SpawnManager>();
if ((Object)(object)val != (Object)null)
{
object? obj = BoatPrefabField?.GetValue(val);
Boat val2 = (Boat)((obj is Boat) ? obj : null);
if (val2 != null && (Object)(object)val2 != (Object)null)
{
return val2;
}
}
return Resources.FindObjectsOfTypeAll<Boat>().FirstOrDefault();
}
public static void LogSummary(ManualLogSource log)
{
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
LocalSaveObject localSave = GetLocalSave();
if (localSave == null)
{
log.LogWarning((object)"Local save not loaded (SaveManager._curLocalSave is null)");
}
else
{
log.LogInfo((object)("Raw save: " + string.Join(" | ", localSave.UnlockedItemSkins.Select((SavedItemSkin s) => string.Format("{0}:[{1}]", s.ID, string.Join(",", s.SkinsUnlocked)))) + " | boat:[" + string.Join(",", localSave.UnlockedBoatSkins) + "]"));
}
List<SkinGroup> list = Build();
int num = 0;
int num2 = 0;
foreach (SkinGroup item in list)
{
num += item.OwnedCount;
num2 += item.TotalCount;
log.LogInfo((object)string.Format("{0} (id {1}{2}): {3}/{4}, islands [{5}]", item.Name, item.ItemId, item.IsBoat ? ", boat" : "", item.OwnedCount, item.TotalCount, string.Join(",", item.Islands)));
foreach (SkinEntry skin in item.Skins)
{
log.LogInfo((object)string.Format(" [{0}] {1,2} {2} ({3}){4}", skin.Owned ? "x" : " ", skin.Index, skin.Name, skin.Rarity, skin.Unobtainable ? " - unobtainable" : ""));
}
}
log.LogInfo((object)$"Total: {num}/{num2} obtainable skins in {list.Count} groups");
}
}
public class SkinHint : MonoBehaviour
{
private const float QuietTime = 5f;
private static readonly FieldInfo TutorialToBoxField = AccessTools.Field(typeof(PlayerTutorial), "_tutorialToBox");
private static readonly FieldInfo BoxPrefabField = AccessTools.Field(typeof(PlayerTutorial), "_box");
private static readonly FieldInfo HolderField = AccessTools.Field(typeof(PlayerTutorial), "_tutorialHolder");
private static readonly FieldInfo RectParentField = AccessTools.Field(typeof(TutorialBox), "_rectParent");
public ConfigEntry<bool> Enabled;
public ModInput Input;
private TutorialBox _box;
private TextMeshProUGUI _title;
private TextMeshProUGUI _description;
private PlayerInput _subscribedInput;
private float _quietSince = -1f;
private bool _failed;
private bool _finishPending;
private float _finishAt = -1f;
private const float FinishedHoldTime = 0.4f;
public static SkinHint Instance { get; private set; }
private void Awake()
{
Instance = this;
Strings.LanguageChanged += OnLanguageChanged;
}
private void OnDestroy()
{
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
Strings.LanguageChanged -= OnLanguageChanged;
Unsubscribe();
}
private void OnLanguageChanged()
{
if ((Object)(object)_box != (Object)null && !_finishPending)
{
RefreshText();
}
}
public void Complete()
{
if (Enabled != null && Enabled.Value)
{
Enabled.Value = false;
}
if ((Object)(object)_box != (Object)null)
{
_finishPending = true;
}
}
private void Update()
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
if (_finishPending)
{
if ((Object)(object)_box == (Object)null)
{
_finishPending = false;
}
else if (SkinMenu.IsOpen || PlayerThinking.IsThinking)
{
_finishAt = -1f;
}
else if (_finishAt < 0f)
{
Image val = Get<Image>(_box, "_image");
if ((Object)(object)val != (Object)null)
{
((Graphic)val).color = Get<Color>(_box, "_finishedColor");
}
_finishAt = Time.unscaledTime + 0.4f;
}
else if (Time.unscaledTime >= _finishAt)
{
_finishPending = false;
_finishAt = -1f;
Unsubscribe();
_box.Finish();
_box = null;
}
}
else
{
if (_failed || Enabled == null || !Enabled.Value || Input == null || (Object)(object)_box != (Object)null)
{
return;
}
PlayerTutorial instance = PlayerTutorial.Instance;
if (!((Object)(object)instance == (Object)null) && !PlayerThinking.IsThinking && SkinMenu.CanUse() && TutorialToBoxField?.GetValue(instance) is IDictionary { Count: <=0 })
{
if (_quietSince < 0f)
{
_quietSince = Time.unscaledTime;
}
if (Time.unscaledTime - _quietSince >= 5f)
{
Show(instance);
}
}
else
{
_quietSince = -1f;
}
}
}
private void Show(PlayerTutorial tutorial)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
try
{
object? obj = BoxPrefabField?.GetValue(tutorial);
TutorialBox val = (TutorialBox)((obj is TutorialBox) ? obj : null);
object? obj2 = HolderField?.GetValue(tutorial);
RectTransform val2 = (RectTransform)((obj2 is RectTransform) ? obj2 : null);
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
{
throw new InvalidOperationException("PlayerTutorial has no box prefab or holder");
}
GameObject val3 = new GameObject("SkinHintStaging");
val3.SetActive(false);
val3.transform.SetParent((Transform)(object)val2, false);
_box = Object.Instantiate<TutorialBox>(val, val3.transform);
((Object)_box).name = "SkinCollectionHint";
LocalizeStringEvent[] componentsInChildren = ((Component)_box).GetComponentsInChildren<LocalizeStringEvent>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Behaviour)componentsInChildren[i]).enabled = false;
}
_title = Get<TextMeshProUGUI>(_box, "_titleText");
_description = Get<TextMeshProUGUI>(_box, "_descriptionText");
RectParentField?.SetValue(_box, val2);
RefreshText();
((Component)_box).transform.SetParent((Transform)(object)val2, false);
Object.Destroy((Object)(object)val3);
_subscribedInput = GameInfo.Input;
if ((Object)(object)_subscribedInput != (Object)null)
{
_subscribedInput.onControlsChanged += OnControlsChanged;
}
}
catch (Exception ex)
{
_failed = true;
if ((Object)(object)_box != (Object)null)
{
Object.Destroy((Object)(object)((Component)_box).gameObject);
}
_box = null;
Plugin.Log.LogWarning((object)("Could not show the Skin Collection tip: " + ex.Message));
}
}
private void OnControlsChanged(PlayerInput input)
{
if ((Object)(object)_box == (Object)null)
{
Unsubscribe();
}
else
{
RefreshText();
}
}
private void RefreshText()
{
if ((Object)(object)_title != (Object)null)
{
((TMP_Text)_title).text = Strings.Get("Title");
}
if (!((Object)(object)_description == (Object)null))
{
string text = ModInput.Display(Input.Open);
if (string.IsNullOrEmpty(text))
{
((TMP_Text)_description).text = Strings.Get("HintUnbound", Strings.Get("Title"));
}
else
{
((TMP_Text)_description).text = Strings.Get(CurrentBindingIsHold() ? "HintHold" : "HintPress", text);
}
}
}
private bool CurrentBindingIsHold()
{
//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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_0044: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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)
string text = (((Object)(object)GameInfo.Input != (Object)null) ? GameInfo.Input.currentControlScheme : null);
if (string.IsNullOrEmpty(text))
{
return false;
}
InputBinding val = InputBinding.MaskByGroup(text);
Enumerator<InputBinding> enumerator = Input.Open.bindings.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
InputBinding current = enumerator.Current;
if (((InputBinding)(ref val)).Matches(current))
{
return ModInput.IsHold(current);
}
}
}
finally
{
((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
return false;
}
private void Unsubscribe()
{
if ((Object)(object)_subscribedInput != (Object)null)
{
_subscribedInput.onControlsChanged -= OnControlsChanged;
}
_subscribedInput = null;
}
private static T Get<T>(object obj, string field)
{
object obj2 = AccessTools.Field(obj.GetType(), field)?.GetValue(obj);
if (obj2 is T)
{
return (T)obj2;
}
return default(T);
}
}
public class SkinMenu : MonoBehaviour
{
private sealed class Page
{
public SkinGroup Group;
public List<SkinEntry> Visible;
public int Start;
public int PageInGroup;
public int PagesInGroup;
}
private sealed class SlotView
{
public JournalSlot Slot;
public TextMeshProUGUI Name;
public TextMeshProUGUI Worth;
public TextMeshProUGUI Bait;
public MeshFilter Filter;
public Renderer Renderer;
public RawImage Image;
public DripText Drip;
public Material BaseMaterial;
}
private struct SkinSource
{
public Mesh Mesh;
public Vector3 Pos;
public Vector3 Rot;
public float Scale;
public SkinPreset Preset;
}
private const float FadeTime = 0.5f;
private static readonly FieldInfo PlayerUIInstanceField = AccessTools.Field(typeof(PlayerUI), "_instance");
private static readonly FieldInfo ThinkingUIField = AccessTools.Field(typeof(PlayerUI), "_thinkingUI");
private static readonly MethodInfo IsThinkingSetter = AccessTools.PropertySetter(typeof(PlayerThinking), "IsThinking");
private static readonly FieldInfo ItemSlotsField = AccessTools.Field(typeof(PlayerInventory), "_itemSlots");
private static readonly FieldInfo InventorySlotRendererField = AccessTools.Field(typeof(InventorySlot), "_renderer");
private static readonly FieldInfo BoatSkinRendererField = AccessTools.Field(typeof(Boat), "_skinRenderer");
private static readonly FieldInfo ShaderManagerInstanceField = AccessTools.Field(typeof(ShaderManager), "_instance");
private static readonly FieldInfo ThinkingAlphaField = AccessTools.Field(typeof(ThinkingUI), "_thinkingAlpha");
public bool MissingAsSilhouette = true;
public ModInput Input;
public ConfigEntry<bool> ShowUnobtainable;
private ThinkingUI _sourceUI;
private GameObject _canvasRoot;
private GameObject _cameraRoot;
private CanvasGroup _canvas;
private CanvasGroup _holder;
private Camera _camera;
private RenderTexture _texture;
private TextMeshProUGUI _progressText;
private TextMeshProUGUI _totalText;
private TextMeshProUGUI _pageText;
private TextMeshProUGUI _closeText;
private TextMeshProUGUI _toggleText;
private TextMeshProUGUI _titleText;
private float _slotAnimDelay = 0.1f;
private readonly List<SlotView> _slots = new List<SlotView>();
private readonly Dictionary<TextMeshProUGUI, float> _baseFontSizes = new Dictionary<TextMeshProUGUI, float>();
private const float MinFontScale = 0.7f;
private bool _buildFailed;
private Material _itemMaterial;
private Material _boatMaterial;
private readonly List<Transform> _cloudy = new List<Transform>();
private AnimationCurve _cloudyCurveX;
private AnimationCurve _cloudyCurveY;
private float _animSpeed = 1f;
private float _offsetStrength = 1f;
private float _animStrength = 1f;
private float _animTime;
private List<SkinGroup> _groups = new List<SkinGroup>();
private List<Page> _pages = new List<Page>();
private int _curPage;
private int _ownedTotal;
private int _skinTotal;
private float _alpha;
private Coroutine _showRoutine;
public static SkinMenu Instance { get; private set; }
public static bool IsOpen { get; private set; }
private bool ShowingUnobtainable
{
get
{
if (ShowUnobtainable != null)
{
return ShowUnobtainable.Value;
}
return false;
}
}
private void Awake()
{
Instance = this;
Strings.LanguageChanged += OnLanguageChanged;
}
private void OnDestroy()
{
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
Strings.LanguageChanged -= OnLanguageChanged;
DestroyClones();
}
private void OnLanguageChanged()
{
if ((Object)(object)_titleText != (Object)null)
{
SetText(_titleText, Strings.Get("Title"));
}
if (IsOpen)
{
UpdateCloseText();
ShowPage();
}
}
public void Toggle()
{
if (IsOpen)
{
Close();
}
else
{
Open();
}
}
public static bool CanUse()
{
if ((Object)(object)Player.LocalPlayer == (Object)null || MainMenuManager.IsInMenu || PauseManager.IsPaused || ChatManager.IsTyping)
{
return false;
}
if (PlayerUI.UIDisabled || EndGameUI.IsShowingEndGame || EndGameEffects.IsShowingEndGame)
{
return false;
}
if (LoadingManager.IsLoadingIn || IslandManager.IsLoading || SelfDrivingBoat.IsDriving)
{
return false;
}
return true;
}
private void Open()
{
if (!CanUse())
{
return;
}
bool isThinking = PlayerThinking.IsThinking;
if (!EnsureBuilt())
{
return;
}
_groups = SkinCatalog.Build();
if (_groups.Count == 0)
{
Plugin.Log.LogWarning((object)"No skinnable items found; not opening the menu");
return;
}
BuildPages();
IsOpen = true;
if (isThinking)
{
HideJournalInstantly();
_alpha = 1f;
_holder.alpha = 1f;
ShaderManager.SetThinkingAlpha(1f);
}
else
{
IsThinkingSetter.Invoke(null, new object[1] { true });
PlayerCamera.ToggleMouse(true);
PlayerUI.ToggleMainCanvas(false);
PlayerUI.ToggleFXCanvas(false);
PlayerUI.ToggleBossCanvas(false);
}
_canvasRoot.SetActive(true);
_cameraRoot.SetActive(true);
_canvas.alpha = 1f;
UpdateCloseText();
ShowPage();
SkinHint.Instance?.Complete();
}
public void SwitchToJournal()
{
if (IsOpen)
{
IsOpen = false;
if (_showRoutine != null)
{
((MonoBehaviour)this).StopCoroutine(_showRoutine);
}
_showRoutine = null;
_alpha = 0f;
_holder.alpha = 0f;
_canvas.alpha = 0f;
_canvasRoot.SetActive(false);
_cameraRoot.SetActive(false);
ThinkingAlphaField?.SetValue(_sourceUI, 1f);
PlayerUI.OnToggleThinking();
}
}
private void HideJournalInstantly()
{
CanvasGroup val = Get<CanvasGroup>(_sourceUI, "_thinkingCanvas");
CanvasGroup val2 = Get<CanvasGroup>(_sourceUI, "_thinkingHolderGroup");
if ((Object)(object)val != (Object)null)
{
LeanTween.cancel(((Component)val).gameObject);
val.alpha = 0f;
}
if ((Object)(object)val2 != (Object)null)
{
val2.alpha = 0f;
}
ThinkingAlphaField?.SetValue(_sourceUI, 0f);
}
public void ToggleUnobtainable()
{
if (IsOpen && ShowUnobtainable != null)
{
ShowUnobtainable.Value = !ShowUnobtainable.Value;
BuildPages();
ShowPage();
}
}
private void UpdateToggleText()
{
if (!((Object)(object)_toggleText == (Object)null))
{
string text = ((Input != null) ? ModInput.Display(Input.ToggleUnobtainable) : "");
SetText(_toggleText, Strings.Get(ShowingUnobtainable ? "HideUnobtainable" : "ShowUnobtainable", text).TrimEnd());
}
}
private void UpdateCloseText()
{
if (!((Object)(object)_closeText == (Object)null))
{
bool flag = (Object)(object)GameInfo.Input != (Object)null && GameInfo.Input.currentControlScheme == "Controller";
string text = ((Input != null && !flag) ? ModInput.Display(Input.Open) : "");
if (string.IsNullOrEmpty(text))
{
InputAction val = (((Object)(object)GameInfo.Input != (Object)null) ? GameInfo.Input.actions.FindAction("Pause", false) : null);
text = ((val != null) ? ModInput.Display(val) : "");
}
string text2 = null;
try
{
LocalizedString closeLocalized = LocalizationManager.CloseLocalized;
text2 = ((closeLocalized != null) ? closeLocalized.GetLocalizedString(new object[1] { text }) : null);
}
catch (Exception)
{
}
SetText(_closeText, string.IsNullOrEmpty(text2) ? ("Close " + text) : text2);
}
}
private void Close()
{
if (IsOpen)
{
IsOpen = false;
if (PlayerThinking.IsThinking)
{
IsThinkingSetter.Invoke(null, new object[1] { false });
PlayerCamera.ToggleMouse(false);
PlayerUI.ToggleMainCanvas(true);
PlayerUI.ToggleFXCanvas(true);
PlayerUI.ToggleBossCanvas(true);
}
}
}
public void Scroll(int direction)
{
if (IsOpen && _pages.Count != 0)
{
_curPage = (_curPage + direction + _pages.Count) % _pages.Count;
ShowPage();
}
}
private void Update()
{
if (IsOpen && !PlayerThinking.IsThinking)
{
Close();
}
if (IsOpen && !PauseManager.IsPaused && !CanUse())
{
Close();
}
if ((Object)(object)_canvasRoot == (Object)null)
{
IsOpen = false;
return;
}
if (IsOpen)
{
CloudyAnimations();
}
float num = (IsOpen ? 1f : 0f);
if (!Mathf.Approximately(_alpha, num))
{
_alpha = Mathf.MoveTowards(_alpha, num, Time.unscaledDeltaTime / 0.5f);
float num2 = (IsOpen ? Mathf.Sin(_alpha * MathF.PI / 2f) : (1f - Mathf.Cos(_alpha * MathF.PI / 2f)));
_holder.alpha = num2;
ShaderManager.SetThinkingAlpha(num2);
if (!IsOpen && _alpha <= 0f)
{
_canvas.alpha = 0f;
_canvasRoot.SetActive(false);
_cameraRoot.SetActive(false);
}
}
}
private void CloudyAnimations()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
if (_cloudyCurveX == null || _cloudyCurveY == null)
{
return;
}
foreach (Transform item in _cloudy)
{
if (!((Object)(object)item == (Object)null))
{
Vector3 position = item.parent.position;
float num = Mathf.Repeat(_animTime + (position.x + position.y) * _offsetStrength, 1f);
item.localPosition = new Vector3(_cloudyCurveX.Evaluate(num), _cloudyCurveY.Evaluate(num), 0f) * _animStrength;
}
}
_animTime += Time.deltaTime * _animSpeed;
}
private void BuildPages()
{
Page previous = ((_pages.Count > 0) ? _pages[_curPage] : null);
int count = _slots.Count;
_pages = new List<Page>();
_ownedTotal = 0;
_skinTotal = 0;
foreach (SkinGroup group in _groups)
{
_ownedTotal += group.OwnedCount;
_skinTotal += group.TotalCount;
List<SkinEntry> list = (ShowingUnobtainable ? group.Skins : group.Skins.Where((SkinEntry s) => !s.Unobtainable).ToList());
int num = Mathf.Max(1, Mathf.CeilToInt((float)list.Count / (float)count));
for (int num2 = 0; num2 < num; num2++)
{
_pages.Add(new Page
{
Group = group,
Visible = list,
Start = num2 * count,
PageInGroup = num2,
PagesInGroup = num
});
}
}
_curPage = 0;
if (previous != null)
{
int num3 = _pages.FindIndex((Page p) => p.Group.ItemId == previous.Group.ItemId && p.PageInGroup == Mathf.Min(previous.PageInGroup, p.PagesInGroup - 1));
if (num3 >= 0)
{
_curPage = num3;
}
}
}
private void ShowPage()
{
//IL_0112: 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_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
Page page = _pages[_curPage];
SkinGroup skinGroup = page.Group;
SkinSource skinSource = GetSkinSource(skinGroup);
for (int i = 0; i < _slots.Count; i++)
{
int num = page.Start + i;
FillSlot(_slots[i], (num < page.Visible.Count) ? page.Visible[num] : null, skinGroup, skinSource);
}
RenderSlots();
string text = ((page.PagesInGroup > 1) ? $" ({page.PageInGroup + 1}/{page.PagesInGroup})" : "");
SetText(_progressText, $"{skinGroup.Name}{text}: {skinGroup.OwnedCount} / {skinGroup.TotalCount}");
((Graphic)_progressText).color = ((skinGroup.OwnedCount == skinGroup.TotalCount) ? GameInfo.OrangeColor : Color.white);
SetText(_totalText, Strings.Get("TotalSkins", _ownedTotal, _skinTotal));
((Graphic)_totalText).color = ((_ownedTotal == _skinTotal) ? GameInfo.OrangeColor : Color.white);
SetText(_pageText, Strings.Get("Page", _curPage + 1, _pages.Count));
UpdateToggleText();
if (_showRoutine != null)
{
((MonoBehaviour)this).StopCoroutine(_showRoutine);
}
_showRoutine = ((MonoBehaviour)this).StartCoroutine(ShowSlots());
}
private IEnumerator ShowSlots()
{
foreach (SlotView slot in _slots)
{
slot.Slot.ShowSlot();
yield return (object)new WaitForSecondsRealtime(_slotAnimDelay);
}
_showRoutine = null;
}
private static SkinSource GetSkinSource(SkinGroup group)
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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)
if (group.IsBoat)
{
Boat val = SkinCatalog.FindBoat();
return new SkinSource
{
Mesh = val.Mesh,
Pos = val.SkinMeshPos,
Rot = val.SkinMeshRot,
Scale = val.SkinMeshScale,
Preset = val.SkinPreset
};
}
Item val2 = GameInfo.IDToItem(group.ItemId);
return new SkinSource
{
Mesh = val2.Mesh,
Pos = val2.InventoryMeshPos,
Rot = val2.InventoryMeshRot,
Scale = val2.InventoryMeshScale,
Preset = val2.SkinPreset
};
}
private void FillSlot(SlotView view, SkinEntry entry, SkinGroup group, SkinSource source)
{
//IL_0076: 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_0099: 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_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
view.Slot.SetCreature((Creature)null);
if ((Object)(object)view.Drip != (Object)null)
{
view.Drip.SetDrip(false);
}
if (entry == null)
{
return;
}
((Component)view.Name).gameObject.SetActive(true);
SetText(view.Name, entry.Name);
((Graphic)view.Name).color = (Color)(entry.Owned ? Color.white : new Color(1f, 1f, 1f, 0.5f));
SetText(view.Worth, RarityLabel(entry));
((Graphic)view.Worth).color = RarityColor(entry);
if ((Object)(object)view.Bait != (Object)null)
{
SetText(view.Bait, IslandsLabel(entry, group));
}
((Graphic)view.Image).color = (Color)(entry.Owned ? Color.white : (MissingAsSilhouette ? Color.black : new Color(0.35f, 0.35f, 0.35f, 1f)));
view.Filter.mesh = source.Mesh;
((Component)view.Filter).transform.localPosition = source.Pos;
((Component)view.Filter).transform.localEulerAngles = source.Rot;
((Component)view.Filter).transform.localScale = Vector3.one * source.Scale;
if ((Object)(object)view.Renderer == (Object)null || (Object)(object)source.Preset == (Object)null || entry.Index >= source.Preset.Skins.Count)
{
return;
}
bool flag = group.IsBoat && (Object)(object)_boatMaterial != (Object)null;
Material val = (flag ? _boatMaterial : _itemMaterial);
if ((Object)(object)val == (Object)null)
{
return;
}
if ((Object)(object)view.BaseMaterial != (Object)(object)val)
{
if ((Object)(object)view.BaseMaterial != (Object)null && (Object)(object)view.Renderer.sharedMaterial != (Object)(object)view.BaseMaterial)
{
Object.Destroy((Object)(object)view.Renderer.sharedMaterial);
}
view.Renderer.sharedMaterial = val;
view.BaseMaterial = val;
}
ShaderManager.ApplyItemSkin(source.Preset.Skins[entry.Index], view.Renderer, flag);
}
private static string RarityLabel(SkinEntry entry)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected I4, but got Unknown
if (entry.Index == 0)
{
return Strings.Get("Default");
}
if (entry.Unobtainable)
{
return Strings.Get("Unobtainable");
}
Rarity rarity = entry.Rarity;
return (rarity - 1) switch
{
0 => Strings.Get("Common"),
1 => Strings.Get("Rare"),
2 => Strings.Get("Legendary"),
_ => ((object)Unsafe.As<Rarity, Rarity>(ref entry.Rarity)/*cast due to .constrained prefix*/).ToString(),
};
}
private static string IslandsLabel(SkinEntry entry, SkinGroup group)
{
if (entry.Index == 0 || entry.Unobtainable || group.Islands.Count == 0)
{
return "-";
}
string separator = Strings.Get("ListSeparator");
List<string> list = new List<string>();
List<int> list2 = group.Islands.Where((int i) => i != 0).ToList();
if (list2.Count > 0)
{
list.Add(Strings.Get((list2.Count == 1) ? "Island" : "Islands", string.Join(separator, list2)));
}
if (group.Islands.Contains(0))
{
list.Add(Strings.Get("BowIsland"));
}
return string.Join(separator, list);
}
private static Color RarityColor(SkinEntry entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_001b: Expected I4, but got Unknown
//IL_001d: 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_0043: Unknown result type (might be due to invalid IL or missing references)
Rarity rarity = entry.Rarity;
return (Color)((rarity - 1) switch
{
0 => GameInfo.CommonColor,
1 => GameInfo.RareColor,
2 => GameInfo.LegendaryColor,
_ => new Color(1f, 1f, 1f, 0.6f),
});
}
private void RenderSlots()
{
List<Renderer> list = new List<Renderer>();
foreach (JournalSlot item in Get<List<JournalSlot>>(_sourceUI, "_slots") ?? new List<JournalSlot>())
{
MeshFilter val = Get<MeshFilter>(item, "_filter");
Renderer val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Renderer>() : null);
if ((Object)(object)val2 != (Object)null && val2.enabled)
{
val2.enabled = false;
list.Add(val2);
}
}
try
{
_camera.Render();
}
finally
{
foreach (Renderer item2 in list)
{
item2.enabled = true;
}
}
}
private bool EnsureBuilt()
{
//IL_060b: Unknown result type (might be due to invalid IL or missing references)
//IL_0610: Unknown result type (might be due to invalid IL or missing references)
//IL_0615: Unknown result type (might be due to invalid IL or missing references)
//IL_0625: Expected O, but got Unknown
if ((Object)(object)_canvasRoot != (Object)null && (Object)(object)_cameraRoot != (Object)null)
{
return true;
}
if (_buildFailed)
{
return false;
}
DestroyClones();
object? value = PlayerUIInstanceField.GetValue(null);
PlayerUI val = (PlayerUI)((value is PlayerUI) ? value : null);
_sourceUI = (ThinkingUI)(((Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
if ((Object)(object)_sourceUI == (Object)null)
{
Plugin.Log.LogWarning((object)"PlayerUI/ThinkingUI not ready yet");
return false;
}
try
{
CanvasGroup val2 = Get<CanvasGroup>(_sourceUI, "_thinkingCanvas");
Camera val3 = Get<Camera>(_sourceUI, "_journalCamera");
if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
{
return Fail("ThinkingUI has no _thinkingCanvas or _journalCamera");
}
if ((Object)(object)((Component)val2).GetComponent<ThinkingUI>() != (Object)null || (Object)(object)((Component)val3).GetComponent<ThinkingUI>() != (Object)null)
{
return Fail("Journal canvas/camera share a GameObject with ThinkingUI");
}
Transform srcCanvasT = ((Component)val2).transform;
Transform transform = ((Component)val3).transform;
_cameraRoot = Object.Instantiate<GameObject>(((Component)val3).gameObject, transform.parent, false);
((Object)_cameraRoot).name = "SkinCollectionCamera";
_cameraRoot.SetActive(false);
_camera = _cameraRoot.GetComponent<Camera>();
((Behaviour)_camera).enabled = false;
_canvasRoot = Object.Instantiate<GameObject>(((Component)val2).gameObject, srcCanvasT.parent, false);
((Object)_canvasRoot).name = "SkinCollectionCanvas";
_canvasRoot.SetActive(false);
_canvasRoot.transform.SetAsLastSibling();
_canvas = _canvasRoot.GetComponent<CanvasGroup>();
Transform obj = InCanvas((Component)(object)Get<CanvasGroup>(_sourceUI, "_thinkingHolderGroup"));
_holder = ((obj != null) ? ((Component)obj).GetComponent<CanvasGroup>() : null);
Transform obj2 = InCanvas((Component)(object)Get<TextMeshProUGUI>(_sourceUI, "_progressText"));
_progressText = ((obj2 != null) ? ((Component)obj2).GetComponent<TextMeshProUGUI>() : null);
Transform obj3 = InCanvas((Component)(object)Get<TextMeshProUGUI>(_sourceUI, "_dripProgressText"));
_totalText = ((obj3 != null) ? ((Component)obj3).GetComponent<TextMeshProUGUI>() : null);
Transform obj4 = InCanvas((Component)(object)Get<TextMeshProUGUI>(_sourceUI, "_dripChanceText"));
_pageText = ((obj4 != null) ? ((Component)obj4).GetComponent<TextMeshProUGUI>() : null);
Transform obj5 = InCanvas((Component)(object)Get<LocalizeStringEvent>(_sourceUI, "_closeEvent"));
_closeText = ((obj5 != null) ? ((Component)obj5).GetComponent<TextMeshProUGUI>() : null);
_slotAnimDelay = Get<float>(_sourceUI, "_slotAnimDelay");
if ((Object)(object)_holder == (Object)null || (Object)(object)_progressText == (Object)null || (Object)(object)_totalText == (Object)null || (Object)(object)_pageText == (Object)null)
{
return Fail("Journal holder/progress texts are not inside ThinkingCanvas");
}
_cloudyCurveX = Get<AnimationCurve>(_sourceUI, "_cloudyCurveX");
_cloudyCurveY = Get<AnimationCurve>(_sourceUI, "_cloudyCurveY");
_animSpeed = Get<float>(_sourceUI, "_animSpeed");
_offsetStrength = Get<float>(_sourceUI, "_offsetStrength");
_animStrength = Get<float>(_sourceUI, "_animStrength");
foreach (Transform item in Get<List<Transform>>(_sourceUI, "_cloudlyTransforms") ?? new List<Transform>())
{
Transform val4 = MapPath(item, srcCanvasT, _canvasRoot.transform);
if ((Object)(object)val4 != (Object)null)
{
_cloudy.Add(val4);
}
}
FindSkinMaterials();
foreach (JournalSlot item2 in Get<List<JournalSlot>>(_sourceUI, "_slots") ?? new List<JournalSlot>())
{
Transform obj6 = InCanvas((Component)(object)item2);
JournalSlot val5 = ((obj6 != null) ? ((Component)obj6).GetComponent<JournalSlot>() : null);
if ((Object)(object)val5 == (Object)null)
{
return Fail("A JournalSlot is not inside ThinkingCanvas");
}
MeshFilter val6 = Get<MeshFilter>(item2, "_filter");
Transform obj7 = MapPath(((Object)(object)val6 != (Object)null) ? ((Component)val6).transform : null, transform, _cameraRoot.transform);
MeshFilter val7 = ((obj7 != null) ? ((Component)obj7).GetComponent<MeshFilter>() : null);
if ((Object)(object)val7 == (Object)null)
{
return Fail("JournalSlot._filter is not under JournalCamera");
}
AccessTools.Field(typeof(JournalSlot), "_filter").SetValue(val5, val7);
SlotView slotView = new SlotView
{
Slot = val5,
Name = Get<TextMeshProUGUI>(val5, "_nameText"),
Worth = Get<TextMeshProUGUI>(val5, "_worthText"),
Bait = Get<TextMeshProUGUI>(val5, "_baitText"),
Filter = val7,
Renderer = ((Component)val7).GetComponent<Renderer>(),
Image = Get<RawImage>(val5, "_image"),
Drip = Get<DripText>(val5, "_dripText")
};
if ((Object)(object)slotView.Name == (Object)null || (Object)(object)slotView.Worth == (Object)null || (Object)(object)slotView.Image == (Object)null || !((TMP_Text)slotView.Name).transform.IsChildOf(_canvasRoot.transform) || !((Component)slotView.Image).transform.IsChildOf(_canvasRoot.transform))
{
return Fail("JournalSlot texts/image are not inside ThinkingCanvas");
}
_slots.Add(slotView);
}
if (_slots.Count == 0)
{
return Fail("ThinkingUI has no journal slots");
}
RenderTexture val8 = (((Object)(object)val3.targetTexture != (Object)null) ? val3.targetTexture : GameInfo.JournalTexture);
_texture = new RenderTexture(val8.descriptor)
{
name = "SkinCollectionTexture"
};
_texture.Create();
_camera.targetTexture = _texture;
RawImage[] componentsInChildren = _canvasRoot.GetComponentsInChildren<RawImage>(true);
foreach (RawImage val9 in componentsInChildren)
{
if ((Object)(object)val9.texture == (Object)(object)val8)
{
val9.texture = (Texture)(object)_texture;
}
}
SetupStaticTexts();
SetupArrows();
CreateToggleButton();
_canvas.alpha = 0f;
_holder.alpha = 0f;
Plugin.Log.LogInfo((object)($"Skin menu built ({_slots.Count} slots per page, {_cloudy.Count} cloud parts, " + "item material: " + (((Object)(object)_itemMaterial != (Object)null) ? ((Object)_itemMaterial).name : "none") + ", boat material: " + (((Object)(object)_boatMaterial != (Object)null) ? ((Object)_boatMaterial).name : "none") + ")"));
return true;
Transform InCanvas(Component c)
{
return MapPath(((Object)(object)c != (Object)null) ? c.transform : null, srcCanvasT, _canvasRoot.transform);
}
}
catch (Exception ex)
{
return Fail(ex.ToString());
}
}
private void SetupStaticTexts()
{
LocalizeStringEvent[] componentsInChildren = _canvasRoot.GetComponentsInChildren<LocalizeStringEvent>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Behaviour)componentsInChildren[i]).enabled = false;
}
_titleText = ((IEnumerable<TextMeshProUGUI>)_canvasRoot.GetComponentsInChildren<TextMeshProUGUI>(true)).FirstOrDefault((Func<TextMeshProUGUI, bool>)((TextMeshProUGUI t) => ((Object)t).name == "ThinkingText"));
if ((Object)(object)_titleText != (Object)null)
{
SetText(_titleText, Strings.Get("Title"));
}
}
private void SetupArrows()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
Button[] componentsInChildren = _canvasRoot.GetComponentsInChildren<Button>(true);
foreach (Button val in componentsInChildren)
{
int direction = (((Object)val).name.StartsWith("Prev") ? (-1) : (((Object)val).name.StartsWith("Next") ? 1 : 0));
if (direction != 0)
{
val.onClick = new ButtonClickedEvent();
((UnityEvent)val.onClick).AddListener((UnityAction)delegate
{
Scroll(direction);
});
}
}
}
private void CreateToggleButton()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected O, but got Unknown
if (!((Object)(object)_closeText == (Object)null))
{
GameObject val = Object.Instantiate<GameObject>(((Component)_closeText).gameObject, ((TMP_Text)_closeText).transform.parent, false);
((Object)val).name = "UnobtainableToggle";
_toggleText = val.GetComponent<TextMeshProUGUI>();
((Graphic)_toggleText).raycastTarget = true;
RectTransform rectTransform = ((TMP_Text)_toggleText).rectTransform;
Vector2 anchoredPosition = rectTransform.anchoredPosition;
Rect rect = ((TMP_Text)_closeText).rectTransform.rect;
rectTransform.anchoredPosition = anchoredPosition + new Vector2(0f, ((Rect)(ref rect)).height * 1.1f);
Button obj = val.AddComponent<Button>();
((Selectable)obj).targetGraphic = (Graphic)(object)_toggleText;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)obj).navigation = navigation;
((UnityEvent)obj.onClick).AddListener(new UnityAction(ToggleUnobtainable));
}
}
private bool Fail(string reason)
{
Plugin.Log.LogError((object)("Could not build the skin menu: " + reason));
if ((Object)(object)_sourceUI != (Object)null)
{
CanvasGroup val = Get<CanvasGroup>(_sourceUI, "_thinkingCanvas");
if ((Object)(object)val != (Object)null)
{
LogHierarchy(((Component)val).transform);
}
}
DestroyClones();
_buildFailed = true;
return false;
}
private void DestroyClones()
{
if ((Object)(object)_canvasRoot != (Object)null)
{
Object.Destroy((Object)(object)_canvasRoot);
}
if ((Object)(object)_cameraRoot != (Object)null)
{
Object.Destroy((Object)(object)_cameraRoot);
}
if ((Object)(object)_texture != (Object)null)
{
_texture.Release();
}
foreach (SlotView slot in _slots)
{
if ((Object)(object)slot.Renderer != (Object)null && (Object)(object)slot.BaseMaterial != (Object)null && (Object)(object)slot.Renderer.sharedMaterial != (Object)(object)slot.BaseMaterial)
{
Object.Destroy((Object)(object)slot.Renderer.sharedMaterial);
}
}
if ((Object)(object)_itemMaterial != (Object)null)
{
Object.Destroy((Object)(object)_itemMaterial);
}
if ((Object)(object)_boatMaterial != (Object)null)
{
Object.Destroy((Object)(object)_boatMaterial);
}
_canvasRoot = null;
_cameraRoot = null;
_texture = null;
_itemMaterial = null;
_boatMaterial = null;
_slots.Clear();
_cloudy.Clear();
_baseFontSizes.Clear();
}
private void SetText(TextMeshProUGUI label, string text)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)label == (Object)null)
{
return;
}
if (!_baseFontSizes.TryGetValue(label, out var value))
{
value = (_baseFontSizes[label] = ((TMP_Text)label).fontSize);
}
((TMP_Text)label).fontSize = value;
((TMP_Text)label).text = text;
if (!string.IsNullOrEmpty(text) && (int)((TMP_Text)label).textWrappingMode != 0)
{
Rect rect = ((TMP_Text)label).rectTransform.rect;
float num = ((Rect)(ref rect)).width - ((TMP_Text)label).margin.x - ((TMP_Text)label).margin.z;
float x = ((TMP_Text)label).GetPreferredValues(text, float.PositiveInfinity, float.PositiveInfinity).x;
if (num > 0f && x > num)
{
((TMP_Text)label).fontSize = Mathf.Max(value * 0.7f, value * num / x);
}
}
}
private static Transform MapPath(Transform original, Transform originalRoot, Transform cloneRoot)
{
if ((Object)(object)original == (Object)null)
{
return null;
}
List<int> list = new List<int>();
Transform val = original;
while ((Object)(object)val != (Object)(object)originalRoot)
{
if ((Object)(object)val == (Object)null)
{
return null;
}
list.Add(val.GetSiblingIndex());
val = val.parent;
}
Transform val2 = cloneRoot;
for (int num = list.Count - 1; num >= 0; num--)
{
if (list[num] >= val2.childCount)
{
return null;
}
val2 = val2.GetChild(list[num]);
}
return val2;
}
private void FindSkinMaterials()
{
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Expected O, but got Unknown
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Expected O, but got Unknown
object obj = ShaderManagerInstanceField?.GetValue(null);
Shader val = ((obj != null) ? Get<Shader>(obj, "_defaultShader") : null);
Shader val2 = ((obj != null) ? Get<Shader>(obj, "_boatShader") : null);
_itemMaterial = null;
PlayerInventory val3 = (((Object)(object)Player.LocalPlayer != (Object)null) ? Player.LocalPlayer.Inventory : null);
if ((Object)(object)val3 != (Object)null && ItemSlotsField?.GetValue(val3) is List<InventorySlot> list)
{
foreach (InventorySlot item in list)
{
object? obj2 = InventorySlotRendererField?.GetValue(item);
object? obj3 = ((obj2 is Renderer) ? obj2 : null);
Material val4 = ((obj3 != null) ? ((Renderer)obj3).sharedMaterial : null);
if ((Object)(object)val4 != (Object)null && (((Object)(object)val != (Object)null) ? ((Object)(object)val4.shader == (Object)(object)val) : val4.HasProperty(ShaderManager.UseSkinID)))
{
_itemMaterial = CleanCopy(val4, "SkinCollectionItem");
break;
}
}
}
if ((Object)(object)_itemMaterial == (Object)null && (Object)(object)val != (Object)null)
{
_itemMaterial = new Material(val)
{
name = "SkinCollectionItem"
};
}
_boatMaterial = null;
Boat val5 = SkinCatalog.FindBoat();
object obj4;
if (!((Object)(object)val5 != (Object)null))
{
obj4 = null;
}
else
{
object? obj5 = BoatSkinRendererField?.GetValue(val5);
object? obj6 = ((obj5 is Renderer) ? obj5 : null);
obj4 = ((obj6 != null) ? ((Renderer)obj6).sharedMaterial : null);
}
Material val6 = (Material)obj4;
if ((Object)(object)val6 != (Object)null && ((Object)(object)val2 == (Object)null || (Object)(object)val6.shader == (Object)(object)val2))
{
_boatMaterial = CleanCopy(val6, "SkinCollectionBoat");
}
else if ((Object)(object)val2 != (Object)null)
{
_boatMaterial = new Material(val2)
{
name = "SkinCollectionBoat"
};
}
if ((Object)(object)_itemMaterial == (Object)null)
{
Plugin.Log.LogWarning((object)"No item skin material found; skins will not render");
}
}
private static Material CleanCopy(Material source, string name)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
Material val = new Material(source)
{
name = name
};
if (val.HasProperty(ShaderManager.CooknessID))
{
val.SetFloat(ShaderManager.CooknessID, 0f);
}
return val;
}
private static T Get<T>(object obj, string field)
{
object obj2 = AccessTools.Field(obj.GetType(), field)?.GetValue(obj);
if (obj2 is T)
{
return (T)obj2;
}
return default(T);
}
private static void LogHierarchy(Transform root)
{
StringBuilder stringBuilder = new StringBuilder("Hierarchy of " + ((Object)root).name + ":\n");
Append(stringBuilder, root, 0);
Plugin.Log.LogInfo((object)stringBuilder.ToString());
}
private static void Append(StringBuilder sb, Transform t, int depth)
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
if (depth > 8)
{
return;
}
string value = string.Join(", ", from c in ((Component)t).GetComponents<Component>()
where (Object)(object)c != (Object)null && !(c is Transform)
select ((object)c).GetType().Name);
sb.Append(' ', depth * 2).Append(((Object)t).name).Append(" [")
.Append(value)
.Append("]\n");
foreach (Transform item in t)
{
Transform t2 = item;
Append(sb, t2, depth + 1);
}
}
}
public static class Strings
{
public const string Title = "Title";
public const string ShowUnobtainableRow = "ShowUnobtainableRow";
public const string HoldTag = "HoldTag";
public const string TotalSkins = "TotalSkins";
public const string Page = "Page";
public const string Default = "Default";
public const string Common = "Common";
public const string Rare = "Rare";
public const string Legendary = "Legendary";
public const string Unobtainable = "Unobtainable";
public const string ShowUnobtainable = "ShowUnobtainable";
public const string HideUnobtainable = "HideUnobtainable";
public const string HintPress = "HintPress";
public const string HintHold = "HintHold";
public const string HintUnbound = "HintUnbound";
public const string Island = "Island";
public const string Islands = "Islands";
public const string BowIsland = "BowIsland";
public const string ListSeparator = "ListSeparator";
private static bool _subscribed;
private static readonly Dictionary<string, Dictionary<string, string>> Table = new Dictionary<string, Dictionary<string, string>>
{
["Title"] = new Dictionary<string, string>
{
["en"] = "Skin Collection",
["zh-CN"] = "皮肤收藏",
["zh-TW"] = "外觀收藏",
["fr"] = "Collection d’apparences",
["de"] = "Skin-Sammlung",
["it"] = "Collezione skin",
["ja"] = "スキンコレクション",
["ko"] = "스킨 컬렉션",
["pl"] = "Kolekcja skórek",
["pt-BR"] = "Coleção de visuais",
["ru"] = "Коллекция образов",
["es-MX"] = "Colección de aspectos",
["es-ES"] = "Colección de diseños",
["sv"] = "Utseendesamling",
["tr"] = "Görünüm Koleksiyonu",
["uk"] = "Колекція образів"
},
["ShowUnobtainableRow"] = new Dictionary<string, string>
{
["en"] = "Show Unobtainable",
["zh-CN"] = "显示无法获得",
["zh-TW"] = "顯示無法取得",
["fr"] = "Afficher les inobtenables",
["de"] = "Nicht erhältliche anzeigen",
["it"] = "Mostra non ottenibili",
["ja"] = "入手不可を表示",
["ko"] = "획득 불가 표시",
["pl"] = "Pokaż nieosiągalne",
["pt-BR"] = "Mostrar indisponíveis",
["ru"] = "Показать недоступные",
["es-MX"] = "Mostrar inobtenibles",
["es-ES"] = "Mostrar inobtenibles",
["sv"] = "Visa ej tillgängliga",
["tr"] = "Elde Edilemezleri Göster",
["uk"] = "Показ недоступних"
},
["HoldTag"] = new Dictionary<string, string>
{
["en"] = "(Hold)",
["zh-CN"] = "(长按)",
["zh-TW"] = "(長按)",
["fr"] = "(Maintenir)",
["de"] = "(halten)",
["it"] = "(Tieni premuto)",
["ja"] = "(長押し)",
["ko"] = "(길게 누르기)",
["pl"] = "(przytrzymaj)",
["pt-BR"] = "(Segure)",
["ru"] = "(удерживайте)",
["es-MX"] = "(Mantener presionado)",
["es-ES"] = "(mantén)",
["sv"] = "(Håll)",
["tr"] = "(Basılı Tut)",
["uk"] = "(Утрим.)"
},
["TotalSkins"] = new Dictionary<string, string>
{
["en"] = "{0} / {1} Skins",
["zh-CN"] = "{0} / {1} 皮肤",
["zh-TW"] = "{0} / {1} 外觀",
["fr"] = "{0} / {1} Apparences",
["de"] = "{0} / {1} Skins",
["it"] = "{0} / {1} Skin",
["ja"] = "{0} / {1} スキン",
["ko"] = "{0} / {1} 스킨",
["pl"] = "{0} / {1} Skórki",
["pt-BR"] = "{0} / {1} Visuais",
["ru"] = "{0} / {1} Образы",
["es-MX"] = "{0} / {1} Aspectos",
["es-ES"] = "{0} / {1} Diseños",
["sv"] = "{0} / {1} Utseenden",
["tr"] = "{0} / {1} Görünümler",
["uk"] = "{0} / {1} Образи"
},
["Page"] = new Dictionary<string, string>
{
["en"] = "Page {0} / {1}",
["zh-CN"] = "第 {0} / {1} 页",
["zh-TW"] = "第 {0} / {1} 頁",
["fr"] = "Page {0} / {1}",
["de"] = "Seite {0} / {1}",
["it"] = "Pagina {0} / {1}",
["ja"] = "ページ {0} / {1}",
["ko"] = "페이지 {0} / {1}",
["pl"] = "Strona {0} / {1}",
["pt-BR"] = "Página {0} / {1}",
["ru"] = "Страница {0} / {1}",
["es-MX"] = "Página {0} / {1}",
["es-ES"] = "Página {0} / {1}",
["sv"] = "Sida {0} / {1}",
["tr"] = "Sayfa {0} / {1}",
["uk"] = "Сторінка {0} / {1}"
},
["Default"] = new Dictionary<string, string>
{
["en"] = "Default",
["zh-CN"] = "默认",
["zh-TW"] = "預設",
["fr"] = "Normale",
["de"] = "Standard",
["it"] = "Predefinita",
["ja"] = "ノーマル",
["ko"] = "기본",
["pl"] = "Domyślna",
["pt-BR"] = "Padrão",
["ru"] = "Стандартный",
["es-MX"] = "Predeterminado",
["es-ES"] = "Por defecto",
["sv"] = "Standard",
["tr"] = "Varsayılan",
["uk"] = "Стандартний"
},
["Common"] = new Dictionary<string, string>
{
["en"] = "Common",
["zh-CN"] = "普通",
["zh-TW"] = "普通",
["fr"] = "Commune",
["de"] = "Gewöhnlich",
["it"] = "Comune",
["ja"] = "コモン",
["ko"] = "일반",
["pl"] = "Pospolita",
["pt-BR"] = "Comum",
["ru"] = "Обычный",
["es-MX"] = "Común",
["es-ES"] = "Común",
["sv"] = "Vanlig",
["tr"] = "Sıradan",
["uk"] = "Звичайний"
},
["Rare"] = new Dictionary<string, string>
{
["en"] = "Rare",
["zh-CN"] = "稀有",
["zh-TW"] = "稀有",
["fr"] = "Rare",
["de"] = "Selten",
["it"] = "Rara",
["ja"] = "レア",
["ko"] = "희귀",
["pl"] = "Rzadka",
["pt-BR"] = "Raro",
["ru"] = "Редкий",
["es-MX"] = "Raro",
["es-ES"] = "Raro",
["sv"] = "Sällsynt",
["tr"] = "Nadir",
["uk"] = "Рідкісний"
},
["Legendary"] = new Dictionary<string, string>
{
["en"] = "Legendary",
["zh-CN"] = "传说",
["zh-TW"] = "傳說",
["fr"] = "Légendaire",
["de"] = "Legendär",
["it"] = "Leggendaria",
["ja"] = "レジェンダリー",
["ko"] = "전설",
["pl"] = "Legendarna",
["pt-BR"] = "Lendário",
["ru"] = "Легендарный",
["es-MX"] = "Legendario",
["es-ES"] = "Legendario",
["sv"] = "Legendarisk",
["tr"] = "Efsanevi",
["uk"] = "Легендарний"
},
["Unobtainable"] = new Dictionary<string, string>
{
["en"] = "Unobtainable",
["zh-CN"] = "无法获得",
["zh-TW"] = "無法取得",
["fr"] = "Inobtenable",
["de"] = "Nicht erhältlich",
["it"] = "Non ottenibile",
["ja"] = "入手不可",
["ko"] = "획득 불가",
["pl"] = "Nieosiągalna",
["pt-BR"] = "Indisponível",
["ru"] = "Недоступный",
["es-MX"] = "Inobtenible",
["es-ES"] = "Inobtenible",
["sv"] = "Ej tillgänglig",
["tr"] = "Elde Edilemez",
["uk"] = "Недоступний"
},
["ShowUnobtainable"] = new Dictionary<string, string>
{
["en"] = "Show unobtainable {0}",
["zh-CN"] = "显示无法获得 {0}",
["zh-TW"] = "顯示無法取得 {0}",
["fr"] = "Afficher les inobtenables {0}",
["de"] = "Nicht erhältliche anzeigen {0}",
["it"] = "Mostra non ottenibili {0}",
["ja"] = "入手不可を表示 {0}",
["ko"] = "획득 불가 표시 {0}",
["pl"] = "Pokaż nieosiągalne {0}",
["pt-BR"] = "Mostrar indisponíveis {0}",
["ru"] = "Показать недоступные {0}",
["es-MX"] = "Mostrar inobtenibles {0}",
["es-ES"] = "Mostrar inobtenibles {0}",
["sv"] = "Visa ej tillgängliga {0}",
["tr"] = "Elde Edilemezleri Göster {0}",
["uk"] = "Показати недоступні {0}"
},
["HideUnobtainable"] = new Dictionary<string, string>
{
["en"] = "Hide unobtainable {0}",
["zh-CN"] = "隐藏无法获得 {0}",
["zh-TW"] = "隱藏無法取得 {0}",
["fr"] = "Masquer les inobtenables {0}",
["de"] = "Nicht erhältliche ausblenden {0}",
["it"] = "Nascondi non ottenibili {0}",
["ja"] = "入手不可を非表示 {0}",
["ko"] = "획득 불가 숨기기 {0}",
["pl"] = "Ukryj nieosiągalne {0}",
["pt-BR"] = "Ocultar indisponíveis {0}",
["ru"] = "Скрыть недоступные {0}",
["es-MX"] = "Ocultar inobtenibles {0}",
["es-ES"] = "Ocultar inobtenibles {0}",
["sv"] = "Dölj ej tillgängliga {0}",
["tr"] = "Elde Edilemezleri Gizle {0}",
["uk"] = "Сховати недоступні {0}"
},
["HintPress"] = new Dictionary<string, string>
{
["en"] = "Press {0} to see which skins you have and which are still missing.",
["zh-CN"] = "按{0}查看你已拥有和尚未获得的皮肤。",
["zh-TW"] = "按下 {0} 查看你已擁有和尚未取得的外觀。",
["fr"] = "Appuyez sur {0} pour voir les apparences que vous possédez et celles qui vous manquent.",
["de"] = "Drücke {0}, um zu sehen, welche Skins du hast und welche dir noch fehlen.",
["it"] = "Premi {0} per vedere quali skin hai e quali ti mancano ancora.",
["ja"] = "{0}を押すと、持っているスキンとまだ持っていないスキンを確認できる",
["ko"] = "{0} 누르기로 보유한 스킨과 아직 없는 스킨을 확인할 수 있습니다",
["pl"] = "Naciśnij {0}, aby zobaczyć, które skórki już masz, a których ci jeszcze brakuje.",
["pt-BR"] = "Aperte {0} para ver quais visuais você tem e quais ainda faltam.",
["ru"] = "Нажмите {0}, чтобы увидеть, какие образы у вас есть, а каких ещё не хватает.",
["es-MX"] = "Presiona {0} para ver qué aspectos tienes y cuáles te faltan.",
["es-ES"] = "Pulsa {0} para ver qué diseños tienes y cuáles te faltan.",
["sv"] = "Tryck på {0} för att se vilka utseenden du har och vilka du fortfarande saknar.",
["tr"] = "Hangi görünümlere sahip olduğunu ve hangilerinin eksik olduğunu görmek için {0} tuşuna bas.",
["uk"] = "Натисніть {0}, щоб побачити, які образи у вас є, а яких ще бракує."
},
["HintHold"] = new Dictionary<string, string>
{
["en"] = "Hold {0} to see which skins you have and which are still missing.",
["zh-CN"] = "长按{0}查看你已拥有和尚未获得的皮肤。",
["zh-TW"] = "長按 {0} 查看你已擁有和尚未取得的外觀。",
["fr"] = "Maintenez {0} pour voir les apparences que vous possédez et celles qui vous manquent.",
["de"] = "Halte {0} gedrückt, um zu sehen, welche Skins du hast und welche dir noch fehlen.",
["it"] = "Tieni premuto {0} per vedere quali skin hai e quali ti mancano ancora.",
["ja"] = "{0}を長押しすると、持っているスキンとまだ持っていないスキンを確認できる",
["ko"] = "{0} 길게 누르기로 보유한 스킨과 아직 없는 스킨을 확인할 수 있습니다",
["pl"] = "Przytrzymaj {0}, aby zobaczyć, które skórki już masz, a których ci jeszcze brakuje.",
["pt-BR"] = "Segure {0} para ver quais visuais você tem e quais ainda faltam.",
["ru"] = "Удерживайте {0}, чтобы увидеть, какие образы у вас есть, а каких ещё не хватает.",
["es-MX"] = "Mantén presionado {0} para ver qué aspectos tienes y cuáles te faltan.",
["es-ES"] = "Mantén {0} para ver qué diseños tienes y cuáles te faltan.",
["sv"] = "Håll ner {0} för att se vilka utseenden du har och vilka du fortfarande saknar.",
["tr"] = "Hangi görünümlere sahip olduğunu ve hangilerinin eksik olduğunu görmek için {0} tuşunu basılı tut.",
["uk"] = "Утримуйте {0}, щоб побачити, які образи у вас є, а яких ще бракує."
},
["HintUnbound"] = new Dictionary<string, string>
{
["en"] = "Pick a button for \"{0}\" in the controls settings to see which skins you have.",
["zh-CN"] = "在按键设置中为“{0}”分配一个按键,即可查看你拥有的皮肤。",
["zh-TW"] = "在按鍵設定中為「{0}」指定一個按鍵,即可查看你擁有的外觀。",
["fr"] = "Choisissez une touche pour « {0} » dans les paramètres des commandes pour voir vos apparences.",
["de"] = "Lege in den Steuerungseinstellungen eine Taste für „{0}“ fest, um deine Skins zu sehen.",
["it"] = "Assegna un tasto a \"{0}\" nelle impostazioni dei comandi per vedere le tue skin.",
["ja"] = "操作設定で「{0}」にボタンを割り当てると、スキンを確認できる",
["ko"] = "조작 설정에서 '{0}'에 버튼을 지정하면 보유한 스킨을 확인할 수 있습니다.",
["pl"] = "Przypisz przycisk do „{0}” w ustawieniach sterowania, aby zobaczyć swoje skórki.",
["pt-BR"] = "Defina um botão para \"{0}\" nas configurações de controles para ver seus visuais.",
["ru"] = "Назначьте кнопку для «{0}» в настройках управления, чтобы увидеть свои образы.",
["es-MX"] = "Asigna un botón a \"{0}\" en la configuración de controles para ver tus aspectos.",
["es-ES"] = "Asigna un botón a «{0}» en los ajustes de controles para ver tus diseños.",
["sv"] = "Välj en knapp för \"{0}\" i kontrollinställningarna för att se dina utseenden.",
["tr"] = "Görünümlerini görmek için kontrol ayarlarından \"{0}\" için bir tuş ata.",
["uk"] = "Призначте кнопку для «{0}» у налаштуваннях керування, щоб побачити свої образи."
},
["Island"] = new Dictionary<string, string>
{
["en"] = "Island {0}",
["zh-CN"] = "{0}号岛",
["zh-TW"] = "{0}號島",
["fr"] = "Île {0}",
["de"] = "Insel {0}",
["it"] = "Isola {0}",
["ja"] = "島{0}",
["ko"] = "섬 {0}",
["pl"] = "Wyspa {0}",
["pt-BR"] = "Ilha {0}",
["ru"] = "Остров {0}",
["es-MX"] = "Isla {0}",
["es-ES"] = "Isla {0}",
["sv"] = "Ö {0}",
["tr"] = "Ada {0}",
["uk"] = "Острів {0}"
},
["Islands"] = new Dictionary<string, string>
{
["en"] = "Islands {0}",
["zh-CN"] = "{0}号岛",
["zh-TW"] = "{0}號島",
["fr"] = "Îles {0}",
["de"] = "Inseln {0}",
["it"] = "Isole {0}",
["ja"] = "島{0}",
["ko"] = "섬 {0}",
["pl"] = "Wyspy {0}",
["pt-BR"] = "Ilhas {0}",
["ru"] = "Острова {0}",
["es-MX"] = "Islas {0}",
["es-ES"] = "Islas {0}",
["sv"] = "Öar {0}",
["tr"] = "Adalar {0}",
["uk"] = "Острови {0}"
},
["BowIsland"] = new Dictionary<string, string>
{
["en"] = "Bow island",
["zh-CN"] = "弓之岛",
["zh-TW"] = "弓之島",
["fr"] = "Île de l’arc",
["de"] = "Bogeninsel",
["it"] = "Isola dell’arco",
["ja"] = "弓の島",
["ko"] = "활의 섬",
["pl"] = "Wyspa z łukiem",
["pt-BR"] = "Ilha do arco",
["ru"] = "Остров с луком",
["es-MX"] = "Isla del arco",
["es-ES"] = "Isla del arco",
["sv"] = "Pilbågsön",
["tr"] = "Yay adası",
["uk"] = "Острів з луком"
},
["ListSeparator"] = new Dictionary<string, string>
{
["en"] = ", ",
["zh-CN"] = "、",
["zh-TW"] = "、",
["ja"] = "・"
}
};
public static event Action LanguageChanged;
public static string Get(string key, params object[] args)
{
EnsureSubscribed();
if (!Table.TryGetValue(key, out var value))
{
return key;
}
string value2 = null;
string text = CurrentCode();
if (text != null && !value.TryGetValue(text, out value2))
{
string value3 = text.Split('-')[0];
foreach (KeyValuePair<string, string> item in value)
{
if (item.Key.Split('-')[0].Equals(value3, StringComparison.OrdinalIgnoreCase))
{
value2 = item.Value;
break;
}
}
}
if (value2 == null)
{
value2 = value["en"];
}
if (args.Length == 0)
{
return value2;
}
return string.Format(value2, args);
}
private static string CurrentCode()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
try
{
Locale selectedLocale = LocalizationSettings.SelectedLocale;
object obj;
if (selectedLocale == null)
{
obj = null;
}
else
{
LocaleIdentifier identifier = selectedLocale.Identifier;
obj = ((LocaleIdentifier)(ref identifier)).Code;
}
string text = (string)obj;
if (string.IsNullOrEmpty(text))
{
return null;
}
string[] array = text.Split('-');
return (array.Length == 2) ? (array[0].ToLowerInvariant() + "-" + array[1].ToUpperInvariant()) : text.ToLowerInvariant();
}
catch (Exception)
{
return null;
}
}
private static void EnsureSubscribed()
{
if (_subscribed)
{
return;
}
try
{
LocalizationSettings.SelectedLocaleChanged += delegate
{
Strings.LanguageChanged?.Invoke();
};
_subscribed = true;
}
catch (Exception)
{
}
}
}
internal static class PluginInfo
{
public const string Version = "1.1.1";
}
}