using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.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 SkinChecklistMod
{
[BepInPlugin("ponyfisher.howtofish.skinchecklist", "Skin Checklist", "1.1.0")]
[DefaultExecutionOrder(29620)]
public sealed class Plugin : BaseUnityPlugin
{
public const string Guid = "ponyfisher.howtofish.skinchecklist";
public const string Name = "Skin Checklist";
public const string Version = "1.1.0";
public static Plugin Instance;
private Harmony harmony;
private bool checklistOpen;
private int selectedTab;
private Rect windowRect;
private Vector2 tabScroll;
private Vector2 listScroll;
private string search = "";
private int filter;
private GUIStyle pauseButton;
private GUIStyle titleStyle;
private GUIStyle subTitleStyle;
private GUIStyle tabStyle;
private GUIStyle activeTabStyle;
private GUIStyle rowStyle;
private GUIStyle ownedStyle;
private GUIStyle missingStyle;
private GUIStyle rarityStyle;
private GUIStyle closeStyle;
private GUIStyle summaryStyle;
private GUIStyle applyStyle;
private GUIStyle selectedApplyStyle;
private Texture2D gold;
private Texture2D goldHover;
private Texture2D black;
private Texture2D charcoal;
private Texture2D darkRed;
private Texture2D silver;
private Texture2D gray;
private Texture2D selectedRed;
private Texture2D selectedTeal;
private string applyStatus = "";
private float applyStatusUntil;
internal bool ChecklistOpen => checklistOpen;
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
Instance = this;
harmony = new Harmony("ponyfisher.howtofish.skinchecklist");
harmony.PatchAll(typeof(Plugin).Assembly);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Skin Checklist 1.1.0 loaded.");
}
private void Update()
{
if (checklistOpen && !PauseManager.IsPaused)
{
CloseChecklist(restore: false);
}
}
private void OnDestroy()
{
if (harmony != null)
{
harmony.UnpatchSelf();
}
Instance = null;
}
internal void Warn(string message)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)message);
}
private Texture2D Solid(Color color)
{
//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_000c: 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_0019: Expected O, but got Unknown
Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
val.SetPixel(0, 0, color);
val.Apply();
return val;
}
private void BuildStyles()
{
//IL_001f: 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_0069: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Expected O, but got Unknown
//IL_01ce: 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)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Expected O, but got Unknown
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Expected O, but got Unknown
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Expected O, but got Unknown
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Expected O, but got Unknown
//IL_0352: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Expected O, but got Unknown
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d6: Expected O, but got Unknown
//IL_03db: Expected O, but got Unknown
//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0409: Unknown result type (might be due to invalid IL or missing references)
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_041c: Expected O, but got Unknown
//IL_0427: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_0449: Unknown result type (might be due to invalid IL or missing references)
//IL_0450: Unknown result type (might be due to invalid IL or missing references)
//IL_045c: Expected O, but got Unknown
//IL_0476: Unknown result type (might be due to invalid IL or missing references)
//IL_048b: Unknown result type (might be due to invalid IL or missing references)
//IL_0490: Unknown result type (might be due to invalid IL or missing references)
//IL_0498: Unknown result type (might be due to invalid IL or missing references)
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Expected O, but got Unknown
//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
//IL_04e4: Expected O, but got Unknown
//IL_051b: Unknown result type (might be due to invalid IL or missing references)
//IL_0530: Unknown result type (might be due to invalid IL or missing references)
//IL_0535: Unknown result type (might be due to invalid IL or missing references)
//IL_053d: Unknown result type (might be due to invalid IL or missing references)
//IL_0544: Unknown result type (might be due to invalid IL or missing references)
//IL_0550: Expected O, but got Unknown
//IL_0587: Unknown result type (might be due to invalid IL or missing references)
//IL_059c: Unknown result type (might be due to invalid IL or missing references)
//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
//IL_05b7: Expected O, but got Unknown
//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0603: Unknown result type (might be due to invalid IL or missing references)
if (pauseButton == null)
{
gold = Solid(new Color(0.98f, 0.68f, 0.04f, 0.99f));
goldHover = Solid(new Color(1f, 0.84f, 0.18f, 0.99f));
black = Solid(new Color(0.025f, 0.025f, 0.03f, 0.99f));
charcoal = Solid(new Color(0.105f, 0.11f, 0.125f, 0.99f));
darkRed = Solid(new Color(0.3f, 0.045f, 0.055f, 0.98f));
silver = Solid(new Color(0.62f, 0.65f, 0.69f, 1f));
gray = Solid(new Color(0.2f, 0.21f, 0.23f, 0.98f));
selectedRed = Solid(new Color(0.62f, 0.075f, 0.09f, 0.99f));
selectedTeal = Solid(new Color(0.03f, 0.52f, 0.52f, 0.99f));
pauseButton = new GUIStyle(GUI.skin.button)
{
fontSize = 15,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
pauseButton.normal.background = gold;
pauseButton.hover.background = goldHover;
pauseButton.active.background = silver;
pauseButton.normal.textColor = Color.black;
pauseButton.hover.textColor = Color.black;
pauseButton.active.textColor = Color.black;
titleStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 27,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
titleStyle.normal.textColor = new Color(0.98f, 0.78f, 0.15f);
subTitleStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 15,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)3
};
subTitleStyle.normal.textColor = new Color(0.88f, 0.89f, 0.91f);
summaryStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 14,
alignment = (TextAnchor)4
};
summaryStyle.normal.textColor = new Color(0.78f, 0.8f, 0.83f);
tabStyle = new GUIStyle(GUI.skin.button)
{
fontSize = 13,
fontStyle = (FontStyle)1
};
tabStyle.normal.background = gray;
tabStyle.hover.background = darkRed;
tabStyle.normal.textColor = new Color(0.78f, 0.8f, 0.83f);
activeTabStyle = new GUIStyle(tabStyle);
activeTabStyle.normal.background = selectedRed;
activeTabStyle.hover.background = selectedRed;
activeTabStyle.normal.textColor = Color.white;
rowStyle = new GUIStyle(GUI.skin.box)
{
alignment = (TextAnchor)3,
padding = new RectOffset(14, 12, 7, 7)
};
rowStyle.normal.background = charcoal;
ownedStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 15,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)3
};
ownedStyle.normal.textColor = Color.white;
missingStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 15,
fontStyle = (FontStyle)2,
alignment = (TextAnchor)3
};
missingStyle.normal.textColor = new Color(0.45f, 0.46f, 0.49f);
rarityStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 12,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
rarityStyle.normal.textColor = Color.white;
closeStyle = new GUIStyle(GUI.skin.button)
{
fontSize = 15,
fontStyle = (FontStyle)1
};
closeStyle.normal.background = darkRed;
closeStyle.hover.background = selectedRed;
closeStyle.normal.textColor = Color.white;
applyStyle = new GUIStyle(GUI.skin.button)
{
fontSize = 12,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
applyStyle.normal.background = gold;
applyStyle.hover.background = goldHover;
applyStyle.normal.textColor = Color.black;
applyStyle.hover.textColor = Color.black;
selectedApplyStyle = new GUIStyle(applyStyle);
selectedApplyStyle.normal.background = selectedTeal;
selectedApplyStyle.hover.background = selectedTeal;
selectedApplyStyle.normal.textColor = Color.white;
selectedApplyStyle.hover.textColor = Color.white;
}
}
private void OnGUI()
{
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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)
BuildStyles();
DrawPauseButton();
if (checklistOpen)
{
float num = Mathf.Min(1040f, (float)Screen.width - 30f);
float num2 = Mathf.Min(760f, (float)Screen.height - 30f);
if (((Rect)(ref windowRect)).width < 1f)
{
windowRect = new Rect(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2);
}
((Rect)(ref windowRect)).width = num;
((Rect)(ref windowRect)).height = num2;
((Rect)(ref windowRect)).x = Mathf.Clamp(((Rect)(ref windowRect)).x, 0f, Mathf.Max(0f, (float)Screen.width - num));
((Rect)(ref windowRect)).y = Mathf.Clamp(((Rect)(ref windowRect)).y, 0f, Mathf.Max(0f, (float)Screen.height - num2));
GUI.depth = -31000;
windowRect = GUI.ModalWindow(918274, windowRect, new WindowFunction(DrawWindow), "", GUI.skin.window);
}
}
private void DrawPauseButton()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if (PauseManager.IsPaused && !checklistOpen && !OtherCustomMenuOpen())
{
float num = 330f;
GUI.depth = -20010;
if (GUI.Button(new Rect(((float)Screen.width - num) / 2f, 120f, num, 42f), "SKIN CHECKLIST", pauseButton))
{
OpenChecklist();
}
}
}
private bool OtherCustomMenuOpen()
{
try
{
Type type = AccessTools.TypeByName("FishmenInvasionMod.Plugin");
object obj = ((type == null) ? null : AccessTools.Field(type, "Instance").GetValue(null));
PropertyInfo propertyInfo = ((type == null) ? null : AccessTools.Property(type, "OptionsOpen"));
return obj != null && propertyInfo != null && (bool)propertyInfo.GetValue(obj, null);
}
catch
{
return false;
}
}
private void OpenChecklist()
{
//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)
Catalog.Rebuild();
selectedTab = 0;
listScroll = Vector2.zero;
checklistOpen = true;
SetVanillaPauseVisible(visible: false);
}
internal void CloseChecklist(bool restore = true)
{
checklistOpen = false;
if (restore)
{
SetVanillaPauseVisible(visible: true);
}
}
private void SetVanillaPauseVisible(bool visible)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
try
{
PauseManager val = Object.FindAnyObjectByType<PauseManager>();
if (!((Object)(object)val == (Object)null))
{
GameObject val2 = (GameObject)AccessTools.Field(typeof(PauseManager), "_mainScreen").GetValue(val);
GameObject val3 = (GameObject)AccessTools.Field(typeof(PauseManager), "_optionsScreen").GetValue(val);
if ((Object)(object)val2 != (Object)null)
{
val2.SetActive(visible && !MainMenuManager.IsInMenu);
}
if ((Object)(object)val3 != (Object)null)
{
val3.SetActive(visible && MainMenuManager.IsInMenu);
}
}
}
catch (Exception ex)
{
Warn("Could not toggle the pause-menu background: " + ex.Message);
}
}
private void DrawWindow(int id)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0563: Unknown result type (might be due to invalid IL or missing references)
//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0539: Unknown result type (might be due to invalid IL or missing references)
GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height), (Texture)(object)black);
GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, 7f), (Texture)(object)selectedRed);
GUI.DrawTexture(new Rect(0f, 55f, ((Rect)(ref windowRect)).width, 2f), (Texture)(object)silver);
GUI.Label(new Rect(20f, 12f, ((Rect)(ref windowRect)).width - 40f, 38f), "SKIN CHECKLIST", titleStyle);
if (GUI.Button(new Rect(((Rect)(ref windowRect)).width - 49f, 14f, 34f, 30f), "X", closeStyle))
{
CloseChecklist();
return;
}
IList<SkinCategory> categories = Catalog.Categories;
int num = 0;
int num2 = 0;
foreach (SkinCategory item in categories)
{
foreach (SkinEntry skin in item.skins)
{
num++;
if (Catalog.IsOwned(skin))
{
num2++;
}
}
}
string text = ((Time.unscaledTime < applyStatusUntil && !string.IsNullOrEmpty(applyStatus)) ? applyStatus : ((categories.Count == 0) ? "Load a player profile to read the game's skin catalog." : (num2 + " / " + num + " SKINS COLLECTED")));
GUI.Label(new Rect(24f, 62f, ((Rect)(ref windowRect)).width - 48f, 26f), text, summaryStyle);
float num3 = Mathf.Max(((Rect)(ref windowRect)).width - 48f, (float)categories.Count * 146f);
tabScroll = GUI.BeginScrollView(new Rect(24f, 92f, ((Rect)(ref windowRect)).width - 48f, 55f), tabScroll, new Rect(0f, 0f, num3, 36f), false, false);
for (int i = 0; i < categories.Count; i++)
{
if (GUI.Button(new Rect((float)(i * 146), 0f, 138f, 36f), categories[i].name, (i == selectedTab) ? activeTabStyle : tabStyle))
{
selectedTab = i;
listScroll = Vector2.zero;
}
}
GUI.EndScrollView();
GUI.Label(new Rect(28f, 157f, 64f, 26f), "SEARCH", subTitleStyle);
search = GUI.TextField(new Rect(92f, 155f, Mathf.Min(330f, ((Rect)(ref windowRect)).width * 0.34f), 30f), search ?? "");
float num4 = ((Rect)(ref windowRect)).width - 337f;
if (GUI.Button(new Rect(num4, 155f, 98f, 30f), "ALL", (filter == 0) ? activeTabStyle : tabStyle))
{
filter = 0;
}
if (GUI.Button(new Rect(num4 + 104f, 155f, 108f, 30f), "COLLECTED", (filter == 1) ? activeTabStyle : tabStyle))
{
filter = 1;
}
if (GUI.Button(new Rect(num4 + 218f, 155f, 104f, 30f), "MISSING", (filter == 2) ? activeTabStyle : tabStyle))
{
filter = 2;
}
if (categories.Count > 0)
{
selectedTab = Mathf.Clamp(selectedTab, 0, categories.Count - 1);
SkinCategory skinCategory = categories[selectedTab];
int num5 = 0;
foreach (SkinEntry skin2 in skinCategory.skins)
{
if (Catalog.IsOwned(skin2))
{
num5++;
}
}
GUI.Label(new Rect(28f, 197f, ((Rect)(ref windowRect)).width - 56f, 28f), skinCategory.name.ToUpperInvariant() + " • " + num5 + " / " + skinCategory.skins.Count, subTitleStyle);
DrawSkinList(skinCategory, new Rect(24f, 230f, ((Rect)(ref windowRect)).width - 48f, ((Rect)(ref windowRect)).height - 252f));
}
GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width - 55f, 58f));
}
private void DrawSkinList(SkinCategory category, Rect area)
{
//IL_004c: 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_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_00a6: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: 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_0133: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
for (int i = 0; i < category.skins.Count; i++)
{
if (Show(category.skins[i]))
{
num++;
}
}
float num2 = Mathf.Max(((Rect)(ref area)).height - 4f, (float)num * 62f);
listScroll = GUI.BeginScrollView(area, listScroll, new Rect(0f, 0f, ((Rect)(ref area)).width - 20f, num2));
float num3 = 0f;
for (int j = 0; j < category.skins.Count; j++)
{
SkinEntry skinEntry = category.skins[j];
if (!Show(skinEntry))
{
continue;
}
ItemSkin skin = skinEntry.skin;
bool flag = Catalog.IsOwned(skinEntry);
GUI.Box(new Rect(0f, num3, ((Rect)(ref area)).width - 25f, 54f), GUIContent.none, rowStyle);
Color val = RarityColor(((ItemSkin)(ref skin)).Rarity);
Color color = GUI.color;
GUI.color = (Color)(flag ? val : new Color(0.22f, 0.22f, 0.24f, 1f));
GUI.DrawTexture(new Rect(9f, num3 + 9f, 36f, 36f), (Texture)(object)Texture2D.whiteTexture);
GUI.color = color;
GUI.Label(new Rect(12f, num3 + 8f, 30f, 36f), flag ? "X" : "", rarityStyle);
string text = (string.IsNullOrWhiteSpace(((ItemSkin)(ref skin)).Name) ? ("Skin " + (j + 1)) : ((ItemSkin)(ref skin)).Name);
GUI.Label(new Rect(58f, num3 + 5f, ((Rect)(ref area)).width - 390f, 44f), text, flag ? ownedStyle : missingStyle);
GUI.Label(new Rect(((Rect)(ref area)).width - 330f, num3 + 7f, 102f, 38f), ((object)((ItemSkin)(ref skin)).Rarity/*cast due to .constrained prefix*/).ToString().ToUpperInvariant(), rarityStyle);
GUI.Label(new Rect(((Rect)(ref area)).width - 222f, num3 + 7f, 82f, 38f), flag ? "OWNED" : "MISSING", flag ? ownedStyle : missingStyle);
if (flag)
{
bool flag2 = Catalog.IsSelected(skinEntry);
if (GUI.Button(new Rect(((Rect)(ref area)).width - 132f, num3 + 10f, 96f, 34f), flag2 ? "SELECTED" : "APPLY", flag2 ? selectedApplyStyle : applyStyle) && !flag2)
{
Catalog.TryApply(skinEntry, out var result);
applyStatus = result;
applyStatusUntil = Time.unscaledTime + 3.5f;
}
}
num3 += 62f;
}
if (num == 0)
{
GUI.Label(new Rect(20f, 18f, ((Rect)(ref area)).width - 60f, 30f), "No skins match this search and filter.", missingStyle);
}
GUI.EndScrollView();
}
private bool Show(SkinEntry entry)
{
bool flag = Catalog.IsOwned(entry);
if (filter == 1 && !flag)
{
return false;
}
if (filter == 2 && flag)
{
return false;
}
string text = ((ItemSkin)(ref entry.skin)).Name ?? "";
if (!string.IsNullOrWhiteSpace(search))
{
return text.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0;
}
return true;
}
private Color RarityColor(Rarity rarity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
//IL_0013: 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_0034: Invalid comparison between Unknown and I4
//IL_002c: 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_0045: Unknown result type (might be due to invalid IL or missing references)
if ((int)rarity == 3)
{
return new Color(1f, 0.62f, 0.08f);
}
if ((int)rarity == 2)
{
return new Color(0.28f, 0.48f, 1f);
}
if ((int)rarity == 1)
{
return new Color(0.55f, 0.58f, 0.62f);
}
return new Color(0.72f, 0.15f, 0.17f);
}
}
internal sealed class SkinReference
{
public byte id;
public int index;
public bool boat;
}
internal sealed class SkinEntry
{
public string key;
public ItemSkin skin;
public readonly List<SkinReference> references = new List<SkinReference>();
}
internal sealed class SkinCategory
{
public string name;
public readonly List<SkinEntry> skins = new List<SkinEntry>();
}
internal static class Catalog
{
private static readonly List<SkinCategory> categories = new List<SkinCategory>();
private static object localSave;
private static float nextRefresh;
public static IList<SkinCategory> Categories => categories;
public static void Rebuild()
{
categories.Clear();
Dictionary<byte, Item> dictionary = new Dictionary<byte, Item>();
try
{
Item[] itemWithSkinsforCommands = GameInfo.ItemWithSkinsforCommands;
if (itemWithSkinsforCommands != null)
{
Item[] array = itemWithSkinsforCommands;
foreach (Item item in array)
{
AddItem(dictionary, item);
}
}
}
catch
{
}
try
{
FieldInfo fieldInfo = AccessTools.Field(typeof(GameInfo), "_allItems");
IDictionary dictionary2 = ((fieldInfo == null) ? null : (fieldInfo.GetValue(null) as IDictionary));
if (dictionary2 != null)
{
foreach (DictionaryEntry item2 in dictionary2)
{
object? value = item2.Value;
AddItem(dictionary, (Item)((value is Item) ? value : null));
}
}
}
catch (Exception ex)
{
Plugin.Instance.Warn("Could not scan the complete item skin catalog: " + ex.Message);
}
Dictionary<string, SkinCategory> dictionary3 = new Dictionary<string, SkinCategory>(StringComparer.OrdinalIgnoreCase);
foreach (Item value2 in dictionary.Values)
{
string name;
try
{
name = value2.GetName();
}
catch
{
name = ((Object)value2).name;
}
if (string.IsNullOrWhiteSpace(name))
{
name = ((Object)value2).name;
}
AddPreset(dictionary3, name, value2.ID, value2.SkinPreset, boat: false);
}
try
{
Boat val = BoatManager.Boat;
if ((Object)(object)val == (Object)null)
{
val = ((IEnumerable<Boat>)Resources.FindObjectsOfTypeAll<Boat>()).FirstOrDefault((Func<Boat, bool>)((Boat x) => (Object)(object)x != (Object)null && (Object)(object)x.SkinPreset != (Object)null && x.SkinPreset.Skins.Count > 0));
}
if ((Object)(object)val != (Object)null)
{
AddPreset(dictionary3, "Boat", byte.MaxValue, val.SkinPreset, boat: true);
}
}
catch
{
}
categories.AddRange(dictionary3.Values.Where((SkinCategory x) => x.skins.Count > 0));
categories.Sort(delegate(SkinCategory a, SkinCategory b)
{
int num = Priority(a.name);
int num2 = Priority(b.name);
return (num == num2) ? string.Compare(a.name, b.name, StringComparison.OrdinalIgnoreCase) : num.CompareTo(num2);
});
RefreshSave(force: true);
}
private static void AddPreset(Dictionary<string, SkinCategory> grouped, string displayName, byte id, SkinPreset preset, bool boat)
{
//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_00fa: 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)
if ((Object)(object)preset == (Object)null || preset.Skins == null || preset.Skins.Count == 0)
{
return;
}
string key = Normalize(displayName);
if (!grouped.TryGetValue(key, out var value))
{
value = new SkinCategory
{
name = (string.IsNullOrWhiteSpace(displayName) ? "Unknown Item" : displayName.Trim())
};
grouped.Add(key, value);
}
int index;
for (index = 0; index < preset.Skins.Count; index++)
{
ItemSkin skin = preset.Skins[index];
string skinKey = Normalize(string.IsNullOrWhiteSpace(((ItemSkin)(ref skin)).Name) ? ("skin " + index) : ((ItemSkin)(ref skin)).Name);
SkinEntry skinEntry = value.skins.FirstOrDefault((SkinEntry x) => x.key == skinKey);
if (skinEntry == null)
{
skinEntry = new SkinEntry
{
key = skinKey,
skin = skin
};
value.skins.Add(skinEntry);
}
if (!skinEntry.references.Any((SkinReference x) => x.id == id && x.index == index && x.boat == boat))
{
skinEntry.references.Add(new SkinReference
{
id = id,
index = index,
boat = boat
});
}
}
}
private static string Normalize(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
return "unknown";
}
return string.Join(" ", value.Trim().Split(new char[4] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)).ToLowerInvariant();
}
private static void AddItem(Dictionary<byte, Item> found, Item item)
{
if ((Object)(object)item != (Object)null && (Object)(object)item.SkinPreset != (Object)null && item.SkinPreset.Skins != null && item.SkinPreset.Skins.Count > 0)
{
found[item.ID] = item;
}
}
private static int Priority(string value)
{
string text = (value ?? "").ToLowerInvariant();
if (text.Contains("knife"))
{
return 0;
}
if (text.Contains("rod"))
{
return 1;
}
if (text.Contains("pistol"))
{
return 2;
}
if (text.Contains("shotgun"))
{
return 3;
}
if (text.Contains("smg"))
{
return 4;
}
if (text.Contains("sniper"))
{
return 5;
}
if (text == "ar" || text.Contains("assault"))
{
return 6;
}
if (text.Contains("boat"))
{
return 7;
}
return 100;
}
private static void RefreshSave(bool force)
{
if (!force && Time.unscaledTime < nextRefresh)
{
return;
}
nextRefresh = Time.unscaledTime + 0.35f;
try
{
FieldInfo fieldInfo = AccessTools.Field(typeof(SaveManager), "_curLocalSave");
localSave = ((fieldInfo == null) ? null : fieldInfo.GetValue(null));
}
catch
{
localSave = null;
}
}
public static bool IsOwned(SkinEntry skin)
{
if (skin.references.Any((SkinReference x) => x.index == 0))
{
return true;
}
RefreshSave(force: false);
object obj = localSave;
LocalSaveObject val = (LocalSaveObject)((obj is LocalSaveObject) ? obj : null);
if (val == null)
{
return false;
}
foreach (SkinReference reference in skin.references)
{
if (reference.boat)
{
if (val.UnlockedBoatSkins != null && val.UnlockedBoatSkins.Contains((byte)reference.index))
{
return true;
}
}
else if (val.UnlockedItemSkins != null)
{
SavedItemSkin val2 = ((IEnumerable<SavedItemSkin>)val.UnlockedItemSkins).FirstOrDefault((Func<SavedItemSkin, bool>)((SavedItemSkin x) => x != null && x.ID == reference.id));
if (val2 != null && val2.SkinsUnlocked != null && val2.SkinsUnlocked.Contains((byte)reference.index))
{
return true;
}
}
}
return false;
}
private static IEnumerable<Item> LocalItems()
{
Player player = Player.LocalPlayer;
if ((Object)(object)player == (Object)null)
{
yield break;
}
HashSet<Item> seen = new HashSet<Item>();
Item val = (((Object)(object)player.Holding == (Object)null) ? null : player.Holding.HeldItem);
if ((Object)(object)val != (Object)null && seen.Add(val))
{
yield return val;
}
if ((Object)(object)player.Inventory == (Object)null || player.Inventory._items == null)
{
yield break;
}
foreach (KeyValuePair<byte, Item> item in player.Inventory._items)
{
Item value = item.Value;
if ((Object)(object)value != (Object)null && seen.Add(value))
{
yield return value;
}
}
}
public static bool IsSelected(SkinEntry entry)
{
if (entry == null)
{
return false;
}
foreach (SkinReference reference in entry.references)
{
if (reference.boat)
{
Boat boat = BoatManager.Boat;
if ((Object)(object)boat != (Object)null && boat.CurSkin == reference.index)
{
return true;
}
continue;
}
foreach (Item item in LocalItems())
{
if (item.ID == reference.id && item.CurSkin == reference.index)
{
return true;
}
}
}
return false;
}
public static bool TryApply(SkinEntry entry, out string result)
{
result = "Skin could not be applied.";
if (entry == null || !IsOwned(entry))
{
result = "That skin has not been collected yet.";
return false;
}
if ((Object)(object)Server.Instance == (Object)null)
{
result = "The game server is not ready.";
return false;
}
bool flag = false;
foreach (SkinReference reference in entry.references)
{
if (reference.boat)
{
if ((Object)(object)BoatManager.Boat != (Object)null)
{
Server.Instance.SetBoatSkin((byte)reference.index);
flag = true;
}
continue;
}
foreach (Item item in LocalItems())
{
if (item.ID == reference.id)
{
Server.Instance.SetItemSkin(item, (byte)reference.index);
flag = true;
}
}
}
if (flag)
{
result = "Selected " + (string.IsNullOrWhiteSpace(((ItemSkin)(ref entry.skin)).Name) ? "skin" : ((ItemSkin)(ref entry.skin)).Name) + ".";
return true;
}
result = "Put this item in your inventory before applying its skin.";
return false;
}
}
[HarmonyPatch(typeof(PauseManager), "PauseInput")]
internal static class CloseChecklistWithEscape
{
private static bool Prefix(CallbackContext context)
{
if ((Object)(object)Plugin.Instance == (Object)null || !Plugin.Instance.ChecklistOpen)
{
return true;
}
if (((CallbackContext)(ref context)).performed)
{
Plugin.Instance.CloseChecklist();
}
return false;
}
}
}