using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
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("TrinketAndBindingFramework")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TrinketAndBindingFramework")]
[assembly: AssemblyTitle("TrinketAndBindingFramework")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TrinketAndBindingFramework
{
[BepInPlugin("com.cicismods.trinketandbindingframework", "CiCi's Trinket & Binding Framework", "1.3.0")]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "com.cicismods.trinketandbindingframework";
public const string NAME = "CiCi's Trinket & Binding Framework";
public const string VERSION = "1.3.0";
public static ManualLogSource Log;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
new Harmony("com.cicismods.trinketandbindingframework").PatchAll();
Log.LogInfo((object)"CiCi's Trinket & Binding Framework 1.3.0 loaded");
}
}
public static class TrinketRegistry
{
public enum Bucket
{
Vanilla,
Parasite,
Chimney
}
public enum Category
{
Consumable,
Tool,
Other,
Artifact,
Perk
}
internal class Entry
{
public string id;
public string title;
public string description;
public string flavorText;
public bool isBinding;
public int cost;
public float scoreMultiplierBonus;
public float scoreBonus;
public Sprite icon;
public Func<List<Item_Object>> itemsToGrantFactory;
public Func<List<Perk>> perksToGrantFactory;
public int pouchesToGrant;
public Trinket runtime;
public int stackCount = 1;
public int maxStacks = 1;
public string titleColor;
public Bucket bucket;
public Category category = Category.Other;
public int tier;
public bool isFrameworkRegistered;
public bool pinToVanilla;
public bool disablesLeaderboards = true;
}
internal static readonly Dictionary<string, Entry> _registry = new Dictionary<string, Entry>();
internal static readonly Dictionary<string, List<string>> _mutexGroups = new Dictionary<string, List<string>>();
internal static Bucket BucketFromColor(string colorHex)
{
if (string.IsNullOrEmpty(colorHex))
{
return Bucket.Vanilla;
}
string text = colorHex.TrimStart('#').ToUpperInvariant();
if (text == "18420F")
{
return Bucket.Parasite;
}
if (text == "8DDDF5")
{
return Bucket.Chimney;
}
return Bucket.Vanilla;
}
internal static bool IsGrey(string colorHex)
{
if (string.IsNullOrEmpty(colorHex))
{
return true;
}
return colorHex.TrimStart('#').ToUpperInvariant() == "D3D3D3";
}
internal static Entry FindEntryForTrinket(Trinket t)
{
if ((Object)(object)t == (Object)null)
{
return null;
}
foreach (KeyValuePair<string, Entry> item in _registry)
{
if ((Object)(object)item.Value.runtime == (Object)(object)t)
{
return item.Value;
}
}
return null;
}
public static void RegisterMutexGroup(string groupId, params string[] entryIds)
{
if (!string.IsNullOrEmpty(groupId) && entryIds != null)
{
List<string> value = new List<string>(entryIds);
_mutexGroups[groupId] = value;
}
}
public static Trinket GetRuntimeTrinket(string id)
{
if (string.IsNullOrEmpty(id))
{
return null;
}
if (!_registry.TryGetValue(id, out var value))
{
return null;
}
return value.runtime;
}
public static void RegisterTrinket(string id, string title, string description, string flavorText = "", int cost = 1, float scoreMultiplierBonus = 0f, float scoreBonus = 0f, Sprite icon = null, Func<List<Item_Object>> itemsToGrantFactory = null, Func<List<Perk>> perksToGrantFactory = null, int pouchesToGrant = 0)
{
Register(id, title, description, flavorText, isBinding: false, cost, scoreMultiplierBonus, scoreBonus, icon, itemsToGrantFactory, perksToGrantFactory, pouchesToGrant);
}
public static void RegisterBinding(string id, string title, string description, string flavorText = "", int cost = 1, float scoreMultiplierBonus = 0f, float scoreBonus = 0f, Sprite icon = null, Func<List<Item_Object>> itemsToGrantFactory = null, Func<List<Perk>> perksToGrantFactory = null, int pouchesToGrant = 0)
{
Register(id, title, description, flavorText, isBinding: true, cost, scoreMultiplierBonus, scoreBonus, icon, itemsToGrantFactory, perksToGrantFactory, pouchesToGrant);
}
private static void Register(string id, string title, string description, string flavorText, bool isBinding, int cost, float scoreMultiplierBonus, float scoreBonus, Sprite icon, Func<List<Item_Object>> itemsToGrantFactory, Func<List<Perk>> perksToGrantFactory, int pouchesToGrant)
{
if (string.IsNullOrEmpty(id))
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogWarning((object)"[Registry] empty id, skipped");
}
return;
}
_registry[id] = new Entry
{
id = id,
title = title,
description = description,
flavorText = (flavorText ?? ""),
isBinding = isBinding,
cost = cost,
scoreMultiplierBonus = scoreMultiplierBonus,
scoreBonus = scoreBonus,
icon = icon,
itemsToGrantFactory = itemsToGrantFactory,
perksToGrantFactory = perksToGrantFactory,
pouchesToGrant = pouchesToGrant
};
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)("[Registry] " + (isBinding ? "binding" : "trinket") + ": " + id));
}
}
}
[HarmonyPatch(typeof(Trinket), "IsUnlocked")]
public static class TrinketUnlockBypassPatch
{
[HarmonyPostfix]
public static void Postfix(ref bool __result)
{
__result = true;
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "SelectTrinket")]
public static class MutexEnforcePatch
{
[HarmonyPrefix]
public static void Prefix(UI_TrinketPicker __instance, Trinket t)
{
if ((Object)(object)__instance == (Object)null || __instance.selectedTrinkets == null || (Object)(object)t == (Object)null || TrinketRegistry._mutexGroups.Count == 0)
{
return;
}
string text = null;
foreach (KeyValuePair<string, TrinketRegistry.Entry> item in TrinketRegistry._registry)
{
if ((Object)(object)item.Value.runtime == (Object)(object)t)
{
text = item.Value.id;
break;
}
}
if (text == null)
{
return;
}
List<string> list = null;
foreach (KeyValuePair<string, List<string>> mutexGroup in TrinketRegistry._mutexGroups)
{
if (mutexGroup.Value.Contains(text))
{
list = mutexGroup.Value;
break;
}
}
if (list == null || __instance.selectedTrinkets.Contains(t))
{
return;
}
for (int num = __instance.selectedTrinkets.Count - 1; num >= 0; num--)
{
Trinket val = __instance.selectedTrinkets[num];
foreach (KeyValuePair<string, TrinketRegistry.Entry> item2 in TrinketRegistry._registry)
{
if ((Object)(object)item2.Value.runtime == (Object)(object)val && list.Contains(item2.Value.id))
{
__instance.selectedTrinkets.RemoveAt(num);
break;
}
}
}
}
}
[HarmonyPatch(typeof(Trinket), "GetDescription")]
public static class TrinketCustomColorPatch
{
[HarmonyPostfix]
public static void Postfix(Trinket __instance, ref string __result)
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
TrinketRegistry.Entry entry = null;
foreach (KeyValuePair<string, TrinketRegistry.Entry> item in TrinketRegistry._registry)
{
if ((Object)(object)item.Value.runtime == (Object)(object)__instance)
{
entry = item.Value;
break;
}
}
if (entry != null && !string.IsNullOrEmpty(entry.titleColor))
{
string text = (__instance.isBinding ? "Binding" : "Trinket");
string text2 = (__instance.isBinding ? ("<shake a=0.01>" + __instance.description + "</shake>") : __instance.description);
__result = "<color=grey>" + text + ":</color> <color=" + entry.titleColor + "><shimmer s=0.1>" + __instance.title + "</shimmer></color>. " + text2 + "\n<color=grey>" + __instance.flavorText + "</color>";
}
}
}
[HarmonyPatch(typeof(Trinket), "GetLockedDescription")]
public static class LockedDescriptionNullGuardPatch
{
[HarmonyPrefix]
public static bool Prefix(Trinket __instance, ref string __result)
{
if ((Object)(object)__instance == (Object)null)
{
return true;
}
if ((Object)(object)__instance.progressionUnlock == (Object)null && !__instance.comingSoon)
{
__result = __instance.GetDescription() + "\n<color=grey>(Locked by current selection.)</color>";
return false;
}
return true;
}
}
[HarmonyPatch(typeof(CL_AssetManager), "GetTrinketAsset")]
public static class TrinketAssetLookupPatch
{
[HarmonyPostfix]
public static void Postfix(string id, ref Trinket __result)
{
if ((Object)(object)__result != (Object)null || string.IsNullOrEmpty(id))
{
return;
}
string value = id.ToLowerInvariant();
foreach (KeyValuePair<string, TrinketRegistry.Entry> item in TrinketRegistry._registry)
{
TrinketRegistry.Entry value2 = item.Value;
if (!((Object)(object)value2.runtime == (Object)null) && ((Object)value2.runtime).name != null && ((Object)value2.runtime).name.ToLowerInvariant().Contains(value))
{
__result = value2.runtime;
break;
}
}
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "ReloadTrinkets")]
public static class TrinketInjectionPatch
{
private static readonly FieldInfoCache CurrentGamemodeField = new FieldInfoCache(typeof(UI_TrinketPicker), "currentGamemode");
private static List<Trinket> _orderedTrinkets;
private static List<Trinket> _orderedBindings;
private static int _cachedRegistryCount = -1;
[HarmonyPrefix]
public static void Prefix(UI_TrinketPicker __instance)
{
object obj = CurrentGamemodeField.Get(__instance);
InjectInto((M_Gamemode)(((obj is M_Gamemode) ? obj : null) ?? CL_GameManager.GetBaseGamemode()));
}
internal static void InjectInto(M_Gamemode gamemode)
{
if ((Object)(object)gamemode == (Object)null)
{
return;
}
PerkBindingAutoRegistrar.TryRun();
ItemTrinketAutoRegistrar.TryRun();
ArtifactTrinketAutoRegistrar.TryRun();
ConsumableTrinketAutoRegistrar.TryRun();
ClimbingItemTrinketAutoRegistrar.TryRun();
MiscTrinketAutoRegistrar.TryRun();
UnusedVanillaTrinketAutoRegistrar.TryRun();
NoHammerBindingRegistrar.TryRun();
if (TrinketRegistry._registry.Count == 0)
{
return;
}
if ((Object)(object)gamemode.availableTrinkets == (Object)null)
{
TrinketList val = ScriptableObject.CreateInstance<TrinketList>();
((Object)val).name = "TrinketList_CiCi_Auto_" + (gamemode.gamemodeName ?? "unknown");
val.trinkets = new List<Trinket>();
val.bindings = new List<Trinket>();
Object.DontDestroyOnLoad((Object)(object)val);
gamemode.availableTrinkets = val;
}
if (gamemode.availableTrinkets.trinkets == null)
{
gamemode.availableTrinkets.trinkets = new List<Trinket>();
}
if (gamemode.availableTrinkets.bindings == null)
{
gamemode.availableTrinkets.bindings = new List<Trinket>();
}
gamemode.useGamemodeSettings = true;
BuildRegistryRuntimes(gamemode);
RebuildMasterListsIfStale();
List<Trinket> trinkets = gamemode.availableTrinkets.trinkets;
List<Trinket> bindings = gamemode.availableTrinkets.bindings;
trinkets.Clear();
bindings.Clear();
foreach (Trinket orderedTrinket in _orderedTrinkets)
{
trinkets.Add(orderedTrinket);
}
foreach (Trinket orderedBinding in _orderedBindings)
{
bindings.Add(orderedBinding);
}
foreach (KeyValuePair<string, TrinketRegistry.Entry> item in TrinketRegistry._registry)
{
TrinketRegistry.Entry value = item.Value;
if (!((Object)(object)value.runtime == (Object)null) && value.pinToVanilla)
{
List<Trinket> list = (value.isBinding ? bindings : trinkets);
if (!list.Contains(value.runtime))
{
list.Add(value.runtime);
}
}
}
List<Trinket> list2 = new List<Trinket>();
List<Trinket> list3 = new List<Trinket>();
foreach (KeyValuePair<string, TrinketRegistry.Entry> item2 in TrinketRegistry._registry)
{
TrinketRegistry.Entry value2 = item2.Value;
if (!((Object)(object)value2.runtime == (Object)null) && !value2.pinToVanilla)
{
(value2.isBinding ? list3 : list2).Add(value2.runtime);
}
}
list2.Sort(CompareTrinkets);
list3.Sort(CompareTrinkets);
foreach (Trinket item3 in list2)
{
if (!trinkets.Contains(item3))
{
trinkets.Add(item3);
}
}
foreach (Trinket item4 in list3)
{
if (!bindings.Contains(item4))
{
bindings.Add(item4);
}
}
}
internal static int CompareTrinkets(Trinket a, Trinket b)
{
TrinketRegistry.Entry entry = TrinketRegistry.FindEntryForTrinket(a);
TrinketRegistry.Entry entry2 = TrinketRegistry.FindEntryForTrinket(b);
bool flag = entry?.isFrameworkRegistered ?? false;
bool flag2 = entry2?.isFrameworkRegistered ?? false;
if (flag != flag2)
{
if (!flag)
{
return -1;
}
return 1;
}
int num = (int)(entry?.bucket ?? TrinketRegistry.Bucket.Vanilla);
int num2 = (int)(entry2?.bucket ?? TrinketRegistry.Bucket.Vanilla);
if (num != num2)
{
return num - num2;
}
int num3 = (int)(entry?.category ?? TrinketRegistry.Category.Other);
int num4 = (int)(entry2?.category ?? TrinketRegistry.Category.Other);
if (num3 != num4)
{
return num3 - num4;
}
bool flag3 = TrinketRegistry.IsGrey(entry?.titleColor);
bool flag4 = TrinketRegistry.IsGrey(entry2?.titleColor);
if (flag3 != flag4)
{
if (!flag3)
{
return 1;
}
return -1;
}
int num5 = entry?.tier ?? 0;
int num6 = entry2?.tier ?? 0;
if (num5 != num6)
{
return num5 - num6;
}
return string.Compare(a?.title ?? "", b?.title ?? "", StringComparison.OrdinalIgnoreCase);
}
private static void BuildRegistryRuntimes(M_Gamemode gamemode)
{
Sprite val = FindBorrowableIcon(gamemode.availableTrinkets?.trinkets);
Sprite val2 = FindBorrowableIcon(gamemode.availableTrinkets?.bindings);
foreach (KeyValuePair<string, TrinketRegistry.Entry> item in TrinketRegistry._registry)
{
TrinketRegistry.Entry value = item.Value;
if ((Object)(object)value.runtime == (Object)null)
{
value.runtime = BuildTrinketSO(value);
}
if ((Object)(object)value.runtime == (Object)null)
{
continue;
}
if ((Object)(object)value.runtime.icon == (Object)null)
{
Sprite val3 = (value.isBinding ? val2 : val);
value.runtime.icon = value.icon ?? val3;
value.runtime.lockIcon = value.runtime.icon;
}
if (value.itemsToGrantFactory != null)
{
try
{
value.runtime.itemsToGrant = value.itemsToGrantFactory() ?? new List<Item_Object>();
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogWarning((object)("[Registry] " + value.id + " items factory: " + ex.Message));
}
}
}
if (value.perksToGrantFactory == null)
{
continue;
}
try
{
value.runtime.perksToGrant = value.perksToGrantFactory() ?? new List<Perk>();
}
catch (Exception ex2)
{
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogWarning((object)("[Registry] " + value.id + " perks factory: " + ex2.Message));
}
}
}
}
private static void RebuildMasterListsIfStale()
{
if (_orderedTrinkets != null && _orderedBindings != null && _cachedRegistryCount == TrinketRegistry._registry.Count)
{
return;
}
List<Trinket> list = new List<Trinket>();
List<Trinket> list2 = new List<Trinket>();
HashSet<Trinket> hashSet = new HashSet<Trinket>();
M_Gamemode val = FindOrderingSourceGamemode();
if ((Object)(object)val != (Object)null && (Object)(object)val.availableTrinkets != (Object)null)
{
if (val.availableTrinkets.trinkets != null)
{
foreach (Trinket trinket in val.availableTrinkets.trinkets)
{
if (!((Object)(object)trinket == (Object)null) && hashSet.Add(trinket) && TrinketRegistry.FindEntryForTrinket(trinket) == null)
{
list.Add(trinket);
}
}
}
if (val.availableTrinkets.bindings != null)
{
foreach (Trinket binding in val.availableTrinkets.bindings)
{
if (!((Object)(object)binding == (Object)null) && hashSet.Add(binding) && TrinketRegistry.FindEntryForTrinket(binding) == null)
{
list2.Add(binding);
}
}
}
}
Trinket[] array = Resources.FindObjectsOfTypeAll<Trinket>();
if (array != null)
{
foreach (Trinket val2 in array)
{
if (!((Object)(object)val2 == (Object)null) && hashSet.Add(val2) && TrinketRegistry.FindEntryForTrinket(val2) == null)
{
if (val2.isBinding)
{
list2.Add(val2);
}
else
{
list.Add(val2);
}
}
}
}
_orderedTrinkets = list;
_orderedBindings = list2;
_cachedRegistryCount = TrinketRegistry._registry.Count;
}
private static M_Gamemode FindOrderingSourceGamemode()
{
M_Gamemode[] array = Resources.FindObjectsOfTypeAll<M_Gamemode>();
if (array == null)
{
return null;
}
foreach (M_Gamemode val in array)
{
if ((Object)(object)val != (Object)null && (Object)(object)val.availableTrinkets != (Object)null && val.gamemodeName == "Campaign")
{
return val;
}
}
M_Gamemode result = null;
int num = -1;
foreach (M_Gamemode val2 in array)
{
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.availableTrinkets == (Object)null))
{
int num2 = (val2.availableTrinkets.trinkets?.Count ?? 0) + (val2.availableTrinkets.bindings?.Count ?? 0);
if (num2 > num)
{
num = num2;
result = val2;
}
}
}
return result;
}
private static Sprite FindBorrowableIcon(List<Trinket> source)
{
if (source == null)
{
return null;
}
foreach (Trinket item in source)
{
if (!((Object)(object)item == (Object)null) && !((Object)(object)item.icon == (Object)null) && !item.comingSoon && item.IsUnlocked())
{
return item.icon;
}
}
foreach (Trinket item2 in source)
{
if ((Object)(object)item2 != (Object)null && (Object)(object)item2.icon != (Object)null)
{
return item2.icon;
}
}
return null;
}
private static Trinket BuildTrinketSO(TrinketRegistry.Entry e)
{
Trinket obj = ScriptableObject.CreateInstance<Trinket>();
((Object)obj).name = "Trinket_" + e.id;
obj.title = e.title;
obj.description = e.description;
obj.flavorText = e.flavorText;
obj.isBinding = e.isBinding;
obj.cost = e.cost;
obj.scoreMultiplierBonus = e.scoreMultiplierBonus;
obj.scoreBonus = e.scoreBonus;
obj.comingSoon = false;
obj.settingBlacklist = new List<string>();
obj.itemsToGrant = new List<Item_Object>();
obj.perksToGrant = new List<Perk>();
obj.pouchesToGrant = e.pouchesToGrant;
obj.progressionUnlock = null;
obj.icon = e.icon;
obj.lockIcon = e.icon;
Object.DontDestroyOnLoad((Object)(object)obj);
return obj;
}
}
[HarmonyPatch(typeof(UI_GamemodeScreen), "Initialize")]
public static class GamemodeScreenInitInjectPatch
{
[HarmonyPrefix]
public static void Prefix(M_Gamemode mode)
{
if (!((Object)(object)mode == (Object)null))
{
TrinketInjectionPatch.InjectInto(mode);
}
}
[HarmonyPostfix]
public static void Postfix(UI_GamemodeScreen __instance)
{
if (__instance?.activePanels == null)
{
return;
}
foreach (KeyValuePair<string, UI_GamemodeScreen_Panel> activePanel in __instance.activePanels)
{
UI_GamemodeScreen_Panel value = activePanel.Value;
if ((Object)(object)value == (Object)null)
{
continue;
}
UI_TrinketPicker[] componentsInChildren = ((Component)value).GetComponentsInChildren<UI_TrinketPicker>(true);
foreach (UI_TrinketPicker val in componentsInChildren)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
if ((Object)(object)val.parentPanel == (Object)null)
{
val.parentPanel = value;
}
try
{
val.Initialize();
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogWarning((object)("picker init failed on " + ((Object)value).name + ": " + ex.Message));
}
}
}
}
}
}
internal sealed class FieldInfoCache
{
private readonly FieldInfo _field;
public FieldInfoCache(Type type, string name)
{
_field = AccessTools.Field(type, name);
}
public object Get(object instance)
{
return _field?.GetValue(instance);
}
}
internal static class PickerReflection
{
public static readonly FieldInfoCache DescriptionTextField = new FieldInfoCache(typeof(UI_TrinketPicker), "descriptionText");
public static readonly FieldInfoCache ParentPickerField = new FieldInfoCache(typeof(UI_TrinketPicker_Icon), "parentPicker");
public static bool HasDescriptionText(UI_TrinketPicker picker)
{
if ((Object)(object)picker == (Object)null)
{
return false;
}
object obj = DescriptionTextField.Get(picker);
Object val = (Object)((obj is Object) ? obj : null);
if (val != null)
{
return val != (Object)null;
}
return false;
}
public static UI_TrinketPicker GetParentPicker(UI_TrinketPicker_Icon icon)
{
if (!((Object)(object)icon == (Object)null))
{
object obj = ParentPickerField.Get(icon);
return (UI_TrinketPicker)((obj is UI_TrinketPicker) ? obj : null);
}
return null;
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "HideDescription")]
public static class HideDescriptionNullGuardPatch
{
[HarmonyPrefix]
public static bool Prefix(UI_TrinketPicker __instance)
{
return PickerReflection.HasDescriptionText(__instance);
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "ShowDescription")]
public static class ShowDescriptionNullGuardPatch
{
[HarmonyPrefix]
public static bool Prefix(UI_TrinketPicker __instance)
{
return PickerReflection.HasDescriptionText(__instance);
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "ShowTrinketDescription")]
public static class ShowTrinketDescriptionNullGuardPatch
{
[HarmonyPrefix]
public static bool Prefix(UI_TrinketPicker __instance, Trinket t)
{
if ((Object)(object)t != (Object)null)
{
return PickerReflection.HasDescriptionText(__instance);
}
return false;
}
}
[HarmonyPatch(typeof(UI_TrinketPicker_Icon), "OnPointerEnter")]
public static class IconPointerEnterNullGuardPatch
{
[HarmonyPrefix]
public static bool Prefix(UI_TrinketPicker_Icon __instance)
{
if ((Object)(object)PickerReflection.GetParentPicker(__instance) != (Object)null)
{
return (Object)(object)__instance.trinket != (Object)null;
}
return false;
}
}
[HarmonyPatch(typeof(UI_TrinketPicker_Icon), "OnPointerExit")]
public static class IconPointerExitNullGuardPatch
{
[HarmonyPrefix]
public static bool Prefix(UI_TrinketPicker_Icon __instance)
{
return (Object)(object)PickerReflection.GetParentPicker(__instance) != (Object)null;
}
}
[HarmonyPatch(typeof(UI_TrinketPicker_Icon), "OnSelect")]
public static class IconSelectNullGuardPatch
{
[HarmonyPrefix]
public static bool Prefix(UI_TrinketPicker_Icon __instance)
{
if ((Object)(object)PickerReflection.GetParentPicker(__instance) != (Object)null)
{
return (Object)(object)__instance.trinket != (Object)null;
}
return false;
}
}
[HarmonyPatch(typeof(UI_TrinketPicker_Icon), "OnDeselect")]
public static class IconDeselectNullGuardPatch
{
[HarmonyPrefix]
public static bool Prefix(UI_TrinketPicker_Icon __instance)
{
return (Object)(object)PickerReflection.GetParentPicker(__instance) != (Object)null;
}
}
[HarmonyPatch(typeof(UI_TrinketPicker_Icon), "OnClick")]
public static class IconClickNullGuardPatch
{
[HarmonyPrefix]
public static bool Prefix(UI_TrinketPicker_Icon __instance)
{
if ((Object)(object)PickerReflection.GetParentPicker(__instance) != (Object)null)
{
return (Object)(object)__instance.trinket != (Object)null;
}
return false;
}
}
public class PerkBindingClickOverride : MonoBehaviour, IPointerDownHandler, IEventSystemHandler
{
public string bindingId;
public TextMeshProUGUI stackText;
private int _lastProcessedFrame = -1;
private static readonly MethodInfo _updateTrinketActivation = AccessTools.Method(typeof(UI_TrinketPicker), "UpdateTrinketActivation", (Type[])null, (Type[])null);
public void OnPointerDown(PointerEventData eventData)
{
int frameCount = Time.frameCount;
if (frameCount == _lastProcessedFrame)
{
return;
}
_lastProcessedFrame = frameCount;
bool mouseButtonDown = Input.GetMouseButtonDown(0);
bool mouseButtonDown2 = Input.GetMouseButtonDown(1);
bool flag = mouseButtonDown2 && !mouseButtonDown;
bool flag2 = mouseButtonDown && !mouseButtonDown2;
if ((!flag && !flag2) || !TrinketRegistry._registry.TryGetValue(bindingId, out var value))
{
return;
}
UI_TrinketPicker_Icon component = ((Component)this).GetComponent<UI_TrinketPicker_Icon>();
if ((Object)(object)component == (Object)null || (Object)(object)component.trinket == (Object)null)
{
return;
}
UI_TrinketPicker parentPicker = PickerReflection.GetParentPicker(component);
if ((Object)(object)parentPicker == (Object)null)
{
return;
}
bool flag3 = parentPicker.selectedTrinkets != null && parentPicker.selectedTrinkets.Contains(component.trinket);
bool flag4 = false;
if (flag2)
{
if (!flag3)
{
value.stackCount = 1;
parentPicker.SelectTrinket(component.trinket);
}
else if (value.stackCount < value.maxStacks)
{
value.stackCount++;
flag4 = true;
}
}
else if (flag && flag3)
{
if (value.stackCount > 1)
{
value.stackCount--;
flag4 = true;
}
else
{
value.stackCount = 1;
parentPicker.SelectTrinket(component.trinket);
}
}
if (flag4)
{
try
{
_updateTrinketActivation?.Invoke(parentPicker, null);
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogWarning((object)("[Stack] activation refresh failed: " + ex.Message));
}
}
}
if ((Object)(object)value.runtime != (Object)null)
{
if (value.perksToGrantFactory != null)
{
try
{
value.runtime.perksToGrant = value.perksToGrantFactory();
}
catch (Exception ex2)
{
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogWarning((object)("[Stack] perksToGrant rebuild failed for " + value.id + ": " + ex2.Message));
}
}
}
if (value.itemsToGrantFactory != null)
{
try
{
value.runtime.itemsToGrant = value.itemsToGrantFactory();
}
catch (Exception ex3)
{
ManualLogSource log3 = Plugin.Log;
if (log3 != null)
{
log3.LogWarning((object)("[Stack] itemsToGrant rebuild failed for " + value.id + ": " + ex3.Message));
}
}
}
}
UpdateStackVisual(value);
}
private void UpdateStackVisual(TrinketRegistry.Entry entry)
{
if (!((Object)(object)stackText == (Object)null))
{
((TMP_Text)stackText).text = ((entry.stackCount > 1) ? $"x{entry.stackCount}" : "");
}
}
}
[HarmonyPatch(typeof(UI_TrinketPicker_Icon), "SetTrinket")]
public static class PerkBindingIconAttachPatch
{
[HarmonyPostfix]
public static void Postfix(UI_TrinketPicker_Icon __instance, Trinket t)
{
if ((Object)(object)__instance == (Object)null || (Object)(object)t == (Object)null || string.IsNullOrEmpty(((Object)t).name))
{
return;
}
TrinketRegistry.Entry entry = null;
foreach (KeyValuePair<string, TrinketRegistry.Entry> item in TrinketRegistry._registry)
{
if ((Object)(object)item.Value.runtime == (Object)(object)t)
{
entry = item.Value;
break;
}
}
if (entry != null && entry.maxStacks > 1)
{
Button component = ((Component)__instance).GetComponent<Button>();
if ((Object)(object)component != (Object)null)
{
((UnityEventBase)component.onClick).RemoveAllListeners();
}
PerkBindingClickOverride perkBindingClickOverride = ((Component)__instance).GetComponent<PerkBindingClickOverride>() ?? ((Component)__instance).gameObject.AddComponent<PerkBindingClickOverride>();
perkBindingClickOverride.bindingId = entry.id;
if (entry.maxStacks > 1)
{
perkBindingClickOverride.stackText = EnsureStackText(((Component)__instance).transform);
((TMP_Text)perkBindingClickOverride.stackText).text = ((entry.stackCount > 1) ? $"x{entry.stackCount}" : "");
}
}
}
private static TextMeshProUGUI EnsureStackText(Transform iconRoot)
{
//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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
Transform val = iconRoot.Find("CiCi_StackCount");
if ((Object)(object)val != (Object)null)
{
TextMeshProUGUI component = ((Component)val).GetComponent<TextMeshProUGUI>();
if ((Object)(object)component != (Object)null)
{
return component;
}
}
GameObject val2 = new GameObject("CiCi_StackCount", new Type[1] { typeof(RectTransform) });
RectTransform val3 = (RectTransform)val2.transform;
((Transform)val3).SetParent(iconRoot, false);
val3.anchorMin = new Vector2(1f, 1f);
val3.anchorMax = new Vector2(1f, 1f);
val3.pivot = new Vector2(1f, 1f);
val3.anchoredPosition = new Vector2(-2f, -2f);
val3.sizeDelta = new Vector2(40f, 20f);
TextMeshProUGUI obj = val2.AddComponent<TextMeshProUGUI>();
((TMP_Text)obj).alignment = (TextAlignmentOptions)260;
((TMP_Text)obj).fontSize = 16f;
((Graphic)obj).color = Color.white;
((Graphic)obj).raycastTarget = false;
((TMP_Text)obj).text = "";
return obj;
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "UpdatePips")]
public static class PipsStackInflatePatch
{
[HarmonyPrefix]
public static void Prefix(UI_TrinketPicker __instance, int totalBudget, ref int usedBudget)
{
if ((Object)(object)__instance == (Object)null || __instance.selectedTrinkets == null)
{
return;
}
int num = 0;
foreach (Trinket selectedTrinket in __instance.selectedTrinkets)
{
if (!((Object)(object)selectedTrinket == (Object)null) && !selectedTrinket.isBinding)
{
TrinketRegistry.Entry entry = TrinketRegistry.FindEntryForTrinket(selectedTrinket);
num += ((entry == null) ? 1 : Mathf.Max(1, entry.stackCount));
}
}
usedBudget = num;
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "UpdatePips")]
public static class PipsOverflowPatch
{
private const int VisibleCap = 5;
private const string OverflowName = "CiCi_PipOverflow";
private static readonly FieldInfo PipsField = AccessTools.Field(typeof(UI_TrinketPicker), "pips");
[HarmonyPostfix]
public static void Postfix(UI_TrinketPicker __instance, int totalBudget, int usedBudget)
{
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.pipHolder == (Object)null || !(PipsField?.GetValue(__instance) is List<Image> list))
{
return;
}
for (int i = 0; i < list.Count; i++)
{
if (!((Object)(object)list[i] == (Object)null))
{
bool flag = i < 5;
if (((Component)list[i]).gameObject.activeSelf != flag)
{
((Component)list[i]).gameObject.SetActive(flag);
}
}
}
int num = Mathf.Max(totalBudget, usedBudget) - 5;
TextMeshProUGUI val = EnsureOverflowText(__instance.pipHolder);
if ((Object)(object)val == (Object)null)
{
return;
}
Transform parent = ((TMP_Text)val).transform.parent;
if ((Object)(object)parent != (Object)null)
{
parent.SetAsLastSibling();
}
if (num > 0)
{
((TMP_Text)val).text = $"[+{num}]";
((Graphic)val).color = ((usedBudget > totalBudget) ? Color.red : Color.white);
if ((Object)(object)parent != (Object)null && !((Component)parent).gameObject.activeSelf)
{
((Component)parent).gameObject.SetActive(true);
}
if (!((Component)val).gameObject.activeSelf)
{
((Component)val).gameObject.SetActive(true);
}
RectTransform rectTransform = ((TMP_Text)val).rectTransform;
if ((Object)(object)rectTransform != (Object)null)
{
rectTransform.anchoredPosition = new Vector2(8f, -5f);
}
}
else if ((Object)(object)parent != (Object)null && ((Component)parent).gameObject.activeSelf)
{
((Component)parent).gameObject.SetActive(false);
}
}
private static TextMeshProUGUI EnsureOverflowText(Transform pipHolder)
{
//IL_0045: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: 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)
Transform obj = pipHolder.Find("CiCi_PipOverflow");
RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
TextMeshProUGUI componentInChildren;
if ((Object)(object)val != (Object)null)
{
componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
return componentInChildren;
}
}
else
{
GameObject val2 = new GameObject("CiCi_PipOverflow", new Type[1] { typeof(RectTransform) });
val = (RectTransform)val2.transform;
((Transform)val).SetParent(pipHolder, false);
val.sizeDelta = new Vector2(50f, 22f);
LayoutElement obj2 = val2.AddComponent<LayoutElement>();
obj2.preferredWidth = 50f;
obj2.preferredHeight = 22f;
obj2.flexibleWidth = 0f;
obj2.flexibleHeight = 0f;
}
GameObject val3 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
RectTransform val4 = (RectTransform)val3.transform;
((Transform)val4).SetParent((Transform)(object)val, false);
val4.anchorMin = Vector2.zero;
val4.anchorMax = Vector2.one;
val4.pivot = new Vector2(0.5f, 0.5f);
val4.anchoredPosition = Vector2.zero;
val4.sizeDelta = Vector2.zero;
componentInChildren = val3.AddComponent<TextMeshProUGUI>();
((TMP_Text)componentInChildren).fontSize = 18f;
((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)4097;
((Graphic)componentInChildren).color = Color.white;
((TMP_Text)componentInChildren).fontStyle = (FontStyles)1;
((Graphic)componentInChildren).raycastTarget = false;
((TMP_Text)componentInChildren).text = "";
UI_TrinketPicker componentInParent = ((Component)pipHolder).GetComponentInParent<UI_TrinketPicker>();
TMP_Text val5 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.costText : null);
if ((Object)(object)val5 != (Object)null && (Object)(object)val5.font != (Object)null)
{
((TMP_Text)componentInChildren).font = val5.font;
}
return componentInChildren;
}
}
public static class ItemTrinketAutoRegistrar
{
private struct ItemDef
{
public string title;
public string prefabName;
public string color;
public string description;
public string flavor;
}
private static bool _done;
private const string LightGrey = "#D3D3D3";
private const string MutexGroup = "tools";
private static readonly ItemDef[] _tools = new ItemDef[5]
{
new ItemDef
{
title = "Cryo-Gun",
prefabName = "Item_Cryogun",
color = "#8DDDF5",
description = "Start with a cryo-gun.",
flavor = ""
},
new ItemDef
{
title = "Flare Gun",
prefabName = "Item_Flaregun",
color = "#D3D3D3",
description = "Start with a flare gun.",
flavor = ""
},
new ItemDef
{
title = "Flashlight",
prefabName = "Item_Flashlight",
color = "#D3D3D3",
description = "Start with a flashlight.",
flavor = ""
},
new ItemDef
{
title = "Wrench",
prefabName = "Item_Hammer_Cosmetic_Wrench",
color = "#18420F",
description = "Start with a wrench.",
flavor = ""
},
new ItemDef
{
title = "Scanner",
prefabName = "Item_EntityScanner",
color = "#18420F",
description = "Start with an entity scanner.",
flavor = ""
}
};
internal static void TryRun()
{
if (_done)
{
return;
}
List<(ItemDef, Item_Object)> list = new List<(ItemDef, Item_Object)>();
ItemDef[] tools = _tools;
for (int i = 0; i < tools.Length; i++)
{
ItemDef item = tools[i];
Item_Object val = null;
try
{
GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(item.prefabName, "");
val = (((Object)(object)assetGameObject != (Object)null) ? assetGameObject.GetComponent<Item_Object>() : null);
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)("[AutoTools] '" + item.prefabName + "' not yet loaded — deferring"));
}
return;
}
list.Add((item, val));
}
Sprite val2 = FindContortionIcon();
List<string> list2 = new List<string>();
foreach (var item4 in list)
{
ItemDef item2 = item4.Item1;
Item_Object item3 = item4.Item2;
string text = "cici_tool_" + item2.prefabName;
if (TrinketRegistry._registry.ContainsKey(text))
{
list2.Add(text);
continue;
}
Sprite icon = val2 ?? item3.itemData?.normalSprite;
Item_Object ioRef = item3;
TrinketRegistry.RegisterTrinket(text, item2.title, item2.description, item2.flavor, 1, 0f, 0f, icon, () => new List<Item_Object> { ioRef });
if (TrinketRegistry._registry.TryGetValue(text, out var value))
{
value.titleColor = item2.color;
value.category = TrinketRegistry.Category.Tool;
value.bucket = TrinketRegistry.BucketFromColor(item2.color);
value.isFrameworkRegistered = true;
}
list2.Add(text);
}
TrinketRegistry.RegisterMutexGroup("tools", list2.ToArray());
_done = true;
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)string.Format("[AutoTools] Registered {0} tool trinkets in mutex group '{1}'", list2.Count, "tools"));
}
}
private static Sprite FindContortionIcon()
{
Trinket[] array = Resources.FindObjectsOfTypeAll<Trinket>();
if (array == null)
{
return null;
}
foreach (Trinket val in array)
{
if (!((Object)(object)val == (Object)null) && ((Object)val).name == "Trinket_Totem" && (Object)(object)val.icon != (Object)null)
{
return val.icon;
}
}
foreach (Trinket val2 in array)
{
if ((Object)(object)val2 != (Object)null && val2.title != null && val2.title.IndexOf("Contortion", StringComparison.OrdinalIgnoreCase) >= 0 && (Object)(object)val2.icon != (Object)null)
{
return val2.icon;
}
}
return null;
}
}
public static class NoHammerBindingRegistrar
{
private static bool _done;
public const string BindingId = "cici_nohammer";
public static bool Active
{
get
{
try
{
M_Gamemode currentGamemode = CL_GameManager.GetCurrentGamemode();
if ((Object)(object)currentGamemode == (Object)null)
{
return false;
}
SaveData saveData = StatManager.saveData;
List<string> list = ((saveData != null) ? saveData.GetGamemodeTrinkets(currentGamemode.GetGamemodeName(true)) : null);
if (list == null)
{
return false;
}
foreach (string item in list)
{
if (!string.IsNullOrEmpty(item) && item.ToLowerInvariant().Contains("cici_nohammer"))
{
return true;
}
}
}
catch
{
}
return false;
}
}
internal static void TryRun()
{
if (_done)
{
return;
}
if (TrinketRegistry._registry.ContainsKey("cici_nohammer"))
{
_done = true;
return;
}
TrinketRegistry.RegisterBinding("cici_nohammer", "No Hammer", "Start the run without a hammer.", "", 1, 0f, 0f, FindContortionIcon(), () => new List<Item_Object>());
if (TrinketRegistry._registry.TryGetValue("cici_nohammer", out var value))
{
value.titleColor = "#D3D3D3";
value.category = TrinketRegistry.Category.Perk;
value.bucket = TrinketRegistry.Bucket.Vanilla;
value.isFrameworkRegistered = true;
}
_done = true;
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)"[NoHammer] Registered binding");
}
}
private static Sprite FindContortionIcon()
{
Trinket[] array = Resources.FindObjectsOfTypeAll<Trinket>();
if (array == null)
{
return null;
}
foreach (Trinket val in array)
{
if ((Object)(object)val != (Object)null && ((Object)val).name == "Trinket_Totem" && (Object)(object)val.icon != (Object)null)
{
return val.icon;
}
}
return null;
}
}
[HarmonyPatch(typeof(Item_Object), "Start")]
public static class NoHammerBanItemSpawnPatch
{
[HarmonyPostfix]
public static void Postfix(Item_Object __instance)
{
if (NoHammerBindingRegistrar.Active && __instance?.itemData != null && __instance.itemData.prefabName == "Item_Hammer")
{
((Component)__instance).gameObject.SetActive(false);
}
}
}
public static class ConsumableTrinketAutoRegistrar
{
private struct ConsumableDef
{
public string title;
public string prefabName;
public string color;
public string description;
}
private static bool _done;
private const string LightGrey = "#D3D3D3";
private const int MaxStacks = 12;
private static readonly ConsumableDef[] _items = new ConsumableDef[13]
{
new ConsumableDef
{
title = "Blink Eye",
prefabName = "Item_BlinkEye",
color = "#ED4040",
description = "Start with Blink Eye(s)."
},
new ConsumableDef
{
title = "Canned Food",
prefabName = "Item_Beans",
color = "#D3D3D3",
description = "Start with canned food."
},
new ConsumableDef
{
title = "Delta-0052",
prefabName = "Item_Beans_Periphery",
color = "#8EF6DD",
description = "Start with Delta-0052."
},
new ConsumableDef
{
title = "Food Bar",
prefabName = "Item_Food_Bar",
color = "#D3D3D3",
description = "Start with food bars."
},
new ConsumableDef
{
title = "Grub",
prefabName = "Denizen_SlugGrub",
color = "#D3D3D3",
description = "Start with grubs."
},
new ConsumableDef
{
title = "Injector",
prefabName = "Item_Injector",
color = "#D3D3D3",
description = "Start with injectors."
},
new ConsumableDef
{
title = "Inoculator",
prefabName = "Item_Inoculator",
color = "#18420F",
description = "Start with inoculators."
},
new ConsumableDef
{
title = "Lemon Roach",
prefabName = "Denizen_Roach_Lemon",
color = "#FDED56",
description = "Start with lemon roaches."
},
new ConsumableDef
{
title = "Milk",
prefabName = "Item_Milk",
color = "#8DDDF5",
description = "Start with milk cartons."
},
new ConsumableDef
{
title = "Pills",
prefabName = "Item_Pillbottle",
color = "#D3D3D3",
description = "Start with pill bottles."
},
new ConsumableDef
{
title = "Hot Cocoa",
prefabName = "Item_Cocoa_Full",
color = "#8DDDF5",
description = "Start with hot cocoa."
},
new ConsumableDef
{
title = "Cookie",
prefabName = "Item_Food_Cookie",
color = "#8DDDF5",
description = "Start with cookies."
},
new ConsumableDef
{
title = "Candy Cauldron",
prefabName = "Item_CandyCauldron",
color = "#FFD454",
description = "Start with candy cauldrons."
}
};
internal static void TryRun()
{
if (_done)
{
return;
}
Sprite val = ItemTrinketAutoRegistrar_FindContortionIcon();
bool flag = false;
bool flag2 = true;
ConsumableDef[] items = _items;
for (int i = 0; i < items.Length; i++)
{
ConsumableDef consumableDef = items[i];
string text = "cici_consumable_" + consumableDef.prefabName;
if (TrinketRegistry._registry.ContainsKey(text))
{
flag = true;
continue;
}
Item_Object val2 = null;
try
{
GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(consumableDef.prefabName, "");
val2 = (((Object)(object)assetGameObject != (Object)null) ? assetGameObject.GetComponent<Item_Object>() : null);
}
catch
{
}
if ((Object)(object)val2 == (Object)null)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)("[AutoConsumables] '" + consumableDef.prefabName + "' not yet loaded — skipping"));
}
flag2 = false;
continue;
}
flag = true;
Sprite icon = val ?? val2.itemData?.normalSprite;
Item_Object ioRef = val2;
string idCopy = text;
TrinketRegistry.RegisterTrinket(text, consumableDef.title, consumableDef.description, "", 1, 0f, 0f, icon, delegate
{
TrinketRegistry.Entry value2;
int num = ((!TrinketRegistry._registry.TryGetValue(idCopy, out value2)) ? 1 : Mathf.Max(1, value2.stackCount));
List<Item_Object> list = new List<Item_Object>(num);
for (int j = 0; j < num; j++)
{
list.Add(ioRef);
}
return list;
});
if (TrinketRegistry._registry.TryGetValue(text, out var value))
{
value.titleColor = consumableDef.color;
value.maxStacks = 12;
value.stackCount = 1;
value.category = TrinketRegistry.Category.Consumable;
value.bucket = TrinketRegistry.BucketFromColor(consumableDef.color);
value.isFrameworkRegistered = true;
}
}
if (flag2)
{
_done = true;
}
if (flag)
{
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"[AutoConsumables] Pass complete — allResolved={flag2}");
}
}
}
private static Sprite ItemTrinketAutoRegistrar_FindContortionIcon()
{
Trinket[] array = Resources.FindObjectsOfTypeAll<Trinket>();
if (array == null)
{
return null;
}
foreach (Trinket val in array)
{
if ((Object)(object)val != (Object)null && ((Object)val).name == "Trinket_Totem" && (Object)(object)val.icon != (Object)null)
{
return val.icon;
}
}
return null;
}
}
public static class ClimbingItemTrinketAutoRegistrar
{
private struct ClimbingItemDef
{
public string title;
public string prefabName;
public string color;
public string description;
}
private static bool _done;
private const string LightGrey = "#D3D3D3";
private const int MaxStacks = 12;
private static readonly ClimbingItemDef[] _items = new ClimbingItemDef[10]
{
new ClimbingItemDef
{
title = "Rope Rebar",
prefabName = "Item_RebarRope",
color = "#D3D3D3",
description = "Start with rope rebar."
},
new ClimbingItemDef
{
title = "Explosive Rebar",
prefabName = "Item_Rebar_Explosive",
color = "#D3D3D3",
description = "Start with explosive rebar."
},
new ClimbingItemDef
{
title = "Rope",
prefabName = "Item_Rope",
color = "#D3D3D3",
description = "Start with rope."
},
new ClimbingItemDef
{
title = "Auto Piton",
prefabName = "Item_AutoPiton",
color = "#D3D3D3",
description = "Start with auto pitons."
},
new ClimbingItemDef
{
title = "Brick",
prefabName = "Item_Rubble",
color = "#D3D3D3",
description = "Start with bricks."
},
new ClimbingItemDef
{
title = "Piton",
prefabName = "Item_Piton",
color = "#D3D3D3",
description = "Start with pitons."
},
new ClimbingItemDef
{
title = "Rebar",
prefabName = "Item_Rebar",
color = "#D3D3D3",
description = "Start with rebar."
},
new ClimbingItemDef
{
title = "Holiday Piton",
prefabName = "Item_Piton_Holiday",
color = "#8DDDF5",
description = "Start with holiday pitons."
},
new ClimbingItemDef
{
title = "Holiday Rebar",
prefabName = "Item_Rebar_Holiday",
color = "#8DDDF5",
description = "Start with holiday rebar."
},
new ClimbingItemDef
{
title = "Holiday Rope Rebar",
prefabName = "Item_RebarRope_Holiday",
color = "#8DDDF5",
description = "Start with holiday rope rebar."
}
};
internal static void TryRun()
{
if (_done)
{
return;
}
Sprite val = FindContortionIcon();
bool flag = false;
bool flag2 = true;
ClimbingItemDef[] items = _items;
for (int i = 0; i < items.Length; i++)
{
ClimbingItemDef climbingItemDef = items[i];
string text = "cici_climb_" + climbingItemDef.prefabName;
if (TrinketRegistry._registry.ContainsKey(text))
{
flag = true;
continue;
}
Item_Object val2 = null;
try
{
GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(climbingItemDef.prefabName, "");
val2 = (((Object)(object)assetGameObject != (Object)null) ? assetGameObject.GetComponent<Item_Object>() : null);
}
catch
{
}
if ((Object)(object)val2 == (Object)null)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)("[AutoClimb] '" + climbingItemDef.prefabName + "' not yet loaded — skipping"));
}
flag2 = false;
continue;
}
flag = true;
Sprite icon = val ?? val2.itemData?.normalSprite;
Item_Object ioRef = val2;
string idCopy = text;
TrinketRegistry.RegisterTrinket(text, climbingItemDef.title, climbingItemDef.description, "", 1, 0f, 0f, icon, delegate
{
TrinketRegistry.Entry value2;
int num = ((!TrinketRegistry._registry.TryGetValue(idCopy, out value2)) ? 1 : Mathf.Max(1, value2.stackCount));
List<Item_Object> list = new List<Item_Object>(num);
for (int j = 0; j < num; j++)
{
list.Add(ioRef);
}
return list;
});
if (TrinketRegistry._registry.TryGetValue(text, out var value))
{
value.titleColor = climbingItemDef.color;
value.maxStacks = 12;
value.stackCount = 1;
value.category = TrinketRegistry.Category.Other;
value.bucket = TrinketRegistry.BucketFromColor(climbingItemDef.color);
value.isFrameworkRegistered = true;
}
}
if (flag2)
{
_done = true;
}
if (flag)
{
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"[AutoClimb] Pass complete — allResolved={flag2}");
}
}
}
private static Sprite FindContortionIcon()
{
Trinket[] array = Resources.FindObjectsOfTypeAll<Trinket>();
if (array == null)
{
return null;
}
foreach (Trinket val in array)
{
if ((Object)(object)val != (Object)null && ((Object)val).name == "Trinket_Totem" && (Object)(object)val.icon != (Object)null)
{
return val.icon;
}
}
return null;
}
}
public static class UnusedVanillaTrinketAutoRegistrar
{
private struct UnusedDef
{
public string title;
public string prefabName;
public string description;
}
private static bool _done;
private static readonly UnusedDef[] _items = new UnusedDef[1]
{
new UnusedDef
{
title = "Calming Buddy",
prefabName = "Item_Trinket_CalmingBuddy",
description = "Start with the Calming Buddy trinket."
}
};
internal static void TryRun()
{
if (_done)
{
return;
}
bool flag = false;
bool flag2 = true;
UnusedDef[] items = _items;
for (int i = 0; i < items.Length; i++)
{
UnusedDef unusedDef = items[i];
string text = "cici_unused_" + unusedDef.prefabName;
if (TrinketRegistry._registry.ContainsKey(text))
{
flag = true;
continue;
}
Item_Object val = null;
try
{
GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(unusedDef.prefabName, "");
val = (((Object)(object)assetGameObject != (Object)null) ? assetGameObject.GetComponent<Item_Object>() : null);
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)("[AutoUnused] '" + unusedDef.prefabName + "' not yet loaded — skipping"));
}
flag2 = false;
continue;
}
flag = true;
Sprite icon = val.itemData?.normalSprite;
Item_Object ioRef = val;
TrinketRegistry.RegisterTrinket(text, unusedDef.title, unusedDef.description, "", 1, 0f, 0f, icon, () => new List<Item_Object> { ioRef });
if (TrinketRegistry._registry.TryGetValue(text, out var value))
{
value.pinToVanilla = true;
value.isFrameworkRegistered = true;
}
}
if (flag2)
{
_done = true;
}
if (flag)
{
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"[AutoUnused] Pass complete — allResolved={flag2}");
}
}
}
}
public static class MiscTrinketAutoRegistrar
{
private struct MiscDef
{
public string title;
public string prefabName;
public string color;
public int tier;
public string description;
}
private static bool _done;
private const string LightGrey = "#D3D3D3";
private const int MaxStacks = 12;
private static readonly MiscDef[] _items = new MiscDef[7]
{
new MiscDef
{
title = "Flare",
prefabName = "Item_Flaregun_Ammo",
color = "#D3D3D3",
tier = 0,
description = "Start with flare(s)."
},
new MiscDef
{
title = "Gold Roach",
prefabName = "Denizen_Roach_Gold",
color = "#FFD700",
tier = 0,
description = "Start with gold roaches."
},
new MiscDef
{
title = "Platinum Roach",
prefabName = "Denizen_Roach_Platinum",
color = "#C0C0C0",
tier = 0,
description = "Start with platinum roaches."
},
new MiscDef
{
title = "Ruby Roach",
prefabName = "Denizen_Roach_Flying_Ruby",
color = "#ED4040",
tier = 0,
description = "Start with ruby roaches."
},
new MiscDef
{
title = "Tier 1 Floppy Disk",
prefabName = "Item_Floppy_T1",
color = "#D3D3D3",
tier = 1,
description = "Start with tier 1 floppy disks."
},
new MiscDef
{
title = "Tier 2 Floppy Disk",
prefabName = "Item_Floppy_T2",
color = "#662E1C",
tier = 2,
description = "Start with tier 2 floppy disks."
},
new MiscDef
{
title = "Tier 3 Floppy Disk",
prefabName = "Item_Floppy_T3",
color = "#493D06",
tier = 3,
description = "Start with tier 3 floppy disks."
}
};
internal static void TryRun()
{
if (_done)
{
return;
}
Sprite val = FindContortionIcon();
bool flag = false;
bool flag2 = true;
MiscDef[] items = _items;
for (int i = 0; i < items.Length; i++)
{
MiscDef miscDef = items[i];
string text = "cici_misc_" + miscDef.prefabName;
if (TrinketRegistry._registry.ContainsKey(text))
{
flag = true;
continue;
}
Item_Object val2 = null;
try
{
GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(miscDef.prefabName, "");
val2 = (((Object)(object)assetGameObject != (Object)null) ? assetGameObject.GetComponent<Item_Object>() : null);
}
catch
{
}
if ((Object)(object)val2 == (Object)null)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)("[AutoMisc] '" + miscDef.prefabName + "' not yet loaded — skipping"));
}
flag2 = false;
continue;
}
flag = true;
Sprite icon = val ?? val2.itemData?.normalSprite;
Item_Object ioRef = val2;
string idCopy = text;
TrinketRegistry.RegisterTrinket(text, miscDef.title, miscDef.description, "", 1, 0f, 0f, icon, delegate
{
TrinketRegistry.Entry value2;
int num = ((!TrinketRegistry._registry.TryGetValue(idCopy, out value2)) ? 1 : Mathf.Max(1, value2.stackCount));
List<Item_Object> list = new List<Item_Object>(num);
for (int j = 0; j < num; j++)
{
list.Add(ioRef);
}
return list;
});
if (TrinketRegistry._registry.TryGetValue(text, out var value))
{
value.titleColor = miscDef.color;
value.maxStacks = 12;
value.stackCount = 1;
value.category = TrinketRegistry.Category.Other;
value.bucket = TrinketRegistry.BucketFromColor(miscDef.color);
value.tier = miscDef.tier;
value.isFrameworkRegistered = true;
}
}
if (flag2)
{
_done = true;
}
if (flag)
{
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"[AutoMisc] Pass complete — allResolved={flag2}");
}
}
}
private static Sprite FindContortionIcon()
{
Trinket[] array = Resources.FindObjectsOfTypeAll<Trinket>();
if (array == null)
{
return null;
}
foreach (Trinket val in array)
{
if ((Object)(object)val != (Object)null && ((Object)val).name == "Trinket_Totem" && (Object)(object)val.icon != (Object)null)
{
return val.icon;
}
}
return null;
}
}
public static class ArtifactTrinketAutoRegistrar
{
private struct ArtifactDef
{
public string title;
public string prefabName;
public string color;
public string description;
public string flavor;
}
private static bool _done;
private const string MutexGroup = "artifacts";
private static readonly ArtifactDef[] _artifacts = new ArtifactDef[5]
{
new ArtifactDef
{
title = "Glove",
prefabName = "Item_Artifact_EVAGlove",
color = "#6DFDFD",
description = "Start with the EVA Glove artifact.",
flavor = ""
},
new ArtifactDef
{
title = "Remote",
prefabName = "Item_Artifact_Remote",
color = "#C0C0C0",
description = "Start with the Remote artifact.",
flavor = ""
},
new ArtifactDef
{
title = "Spear",
prefabName = "Item_Artifact_Rebar_Return",
color = "#ED4040",
description = "Start with the Returning Spear artifact.",
flavor = ""
},
new ArtifactDef
{
title = "Timepiece",
prefabName = "Item_Artifact_Timepiece",
color = "#8EF6DD",
description = "Start with the Timepiece artifact.",
flavor = ""
},
new ArtifactDef
{
title = "Translocator",
prefabName = "Item_Artifact_Translocator",
color = "#ED4040",
description = "Start with the Translocator artifact.",
flavor = ""
}
};
internal static void TryRun()
{
if (_done)
{
return;
}
List<(ArtifactDef, Item_Object)> list = new List<(ArtifactDef, Item_Object)>();
ArtifactDef[] artifacts = _artifacts;
for (int i = 0; i < artifacts.Length; i++)
{
ArtifactDef item = artifacts[i];
Item_Object val = null;
try
{
GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(item.prefabName, "");
val = (((Object)(object)assetGameObject != (Object)null) ? assetGameObject.GetComponent<Item_Object>() : null);
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)("[AutoArtifacts] '" + item.prefabName + "' not yet loaded — deferring"));
}
return;
}
list.Add((item, val));
}
Sprite val2 = ItemTrinketAutoRegistrar_FindContortionIcon();
List<string> list2 = new List<string>();
foreach (var item4 in list)
{
ArtifactDef item2 = item4.Item1;
Item_Object item3 = item4.Item2;
string text = "cici_artifact_" + item2.prefabName;
if (TrinketRegistry._registry.ContainsKey(text))
{
list2.Add(text);
continue;
}
Sprite icon = val2 ?? item3.itemData?.normalSprite;
Item_Object ioRef = item3;
TrinketRegistry.RegisterTrinket(text, item2.title, item2.description, item2.flavor, 1, 0f, 0f, icon, () => new List<Item_Object> { ioRef });
if (TrinketRegistry._registry.TryGetValue(text, out var value))
{
value.titleColor = item2.color;
value.category = TrinketRegistry.Category.Artifact;
value.bucket = TrinketRegistry.BucketFromColor(item2.color);
value.isFrameworkRegistered = true;
}
list2.Add(text);
}
TrinketRegistry.RegisterMutexGroup("artifacts", list2.ToArray());
_done = true;
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)string.Format("[AutoArtifacts] Registered {0} artifact trinkets in mutex group '{1}'", list2.Count, "artifacts"));
}
}
private static Sprite ItemTrinketAutoRegistrar_FindContortionIcon()
{
Trinket[] array = Resources.FindObjectsOfTypeAll<Trinket>();
if (array == null)
{
return null;
}
foreach (Trinket val in array)
{
if ((Object)(object)val != (Object)null && ((Object)val).name == "Trinket_Totem" && (Object)(object)val.icon != (Object)null)
{
return val.icon;
}
}
foreach (Trinket val2 in array)
{
if ((Object)(object)val2 != (Object)null && val2.title != null && val2.title.IndexOf("Contortion", StringComparison.OrdinalIgnoreCase) >= 0 && (Object)(object)val2.icon != (Object)null)
{
return val2.icon;
}
}
return null;
}
}
public static class PerkBindingAutoRegistrar
{
private struct Classification
{
public bool isTrinket;
public string color;
}
private static bool _done;
private const string LightGrey = "#D3D3D3";
private static readonly Dictionary<string, Classification> _byTitle = BuildClassificationTable();
private static Dictionary<string, Classification> BuildClassificationTable()
{
Dictionary<string, Classification> dictionary = new Dictionary<string, Classification>(StringComparer.OrdinalIgnoreCase);
Add(dictionary, "Adoption Day", isTrinket: true, "#E77BAA");
Add(dictionary, "Peripheral Binding", isTrinket: true, "#4BC6A6");
Add(dictionary, "Teleporter Malfunction", isTrinket: true, "#E77BAA");
Add(dictionary, "Physics Graduate", isTrinket: true, "#E77BAA");
Add(dictionary, "Disk Jockey", isTrinket: true, "#D3D3D3");
Add(dictionary, "Piton Enthusiast", isTrinket: true, "#E77BAA");
Add(dictionary, "Pulse Blader", isTrinket: true, "#E77BAA");
Add(dictionary, "Pulse Bladder", isTrinket: true, "#E77BAA");
Add(dictionary, "Slow and Steady", isTrinket: true, "#E77BAA");
Add(dictionary, "Bad Parent", isTrinket: true, "#E77BAA");
Add(dictionary, "BulletProof", isTrinket: true, "#E77BAA");
Add(dictionary, "Bulletproof", isTrinket: true, "#E77BAA");
Add(dictionary, "Metabolic Overdrive", isTrinket: true, "#E77BAA");
Add(dictionary, "Regular Painkillers", isTrinket: true, "#E77BAA");
Add(dictionary, "Friend Upstairs", isTrinket: true, "#E77BAA");
Add(dictionary, "Friends Upstairs", isTrinket: true, "#E77BAA");
Add(dictionary, "Hang Tight", isTrinket: true, "#E77BAA");
Add(dictionary, "Martial Patch", isTrinket: true, "#E77BAA");
Add(dictionary, "Unstoppable Conviction", isTrinket: true, "#F5E2AA");
Add(dictionary, "Profit Motive", isTrinket: true, "#F5E2AA");
Add(dictionary, "Rabbit DNA", isTrinket: true, "#F5E2AA");
Add(dictionary, "System Reorganization", isTrinket: true, "#F5E2AA");
Add(dictionary, "Metabolic Stasis", isTrinket: true, "#F5E2AA");
Add(dictionary, "Muscle Relaxants", isTrinket: true, "#F5E2AA");
Add(dictionary, "Pheromone Glands", isTrinket: true, "#F5E2AA");
Add(dictionary, "Elastic Limbs", isTrinket: true, "#F5E2AA");
Add(dictionary, "Heavy Strike", isTrinket: true, "#D3D3D3");
Add(dictionary, "Ligament Restructure", isTrinket: true, "#F5E2AA");
Add(dictionary, "Autotomous Skeleton", isTrinket: true, "#F5E2AA");
Add(dictionary, "Autonomous Skeleton", isTrinket: true, "#F5E2AA");
Add(dictionary, "Consumptive Reflex", isTrinket: true, "#F5E2AA");
Add(dictionary, "Pulse Organ", isTrinket: true, "#EBC452");
Add(dictionary, "Tissue Restoratives", isTrinket: true, "#D3D3D3");
Add(dictionary, "Velocity Augments", isTrinket: true, "#D3D3D3");
Add(dictionary, "Anomalous Bonds", isTrinket: true, "#D3D3D3");
Add(dictionary, "Regenerative Pads", isTrinket: true, "#D3D3D3");
Add(dictionary, "Somatic Painkillers", isTrinket: true, "#D3D3D3");
Add(dictionary, "Steadied Stance", isTrinket: true, "#D3D3D3");
Add(dictionary, "Back Strengtheners", isTrinket: true, "#D3D3D3");
Add(dictionary, "Latissimus Optimization", isTrinket: true, "#D3D3D3");
Add(dictionary, "Portable Bank", isTrinket: true, "#D3D3D3");
Add(dictionary, "Adrenaline Pumps", isTrinket: true, "#D3D3D3");
Add(dictionary, "Armored Plating", isTrinket: true, "#D3D3D3");
Add(dictionary, "Insulated Organs", isTrinket: true, "#8DDDF5");
Add(dictionary, "Nice List", isTrinket: true, "#8DDDF5");
Add(dictionary, "Cryogenic Touch", isTrinket: true, "#8DDDF5");
Add(dictionary, "Fetal Heating", isTrinket: true, "#8DDDF5");
Add(dictionary, "Freezing Catabolism", isTrinket: true, "#8DDDF5");
Add(dictionary, "Judgement", isTrinket: true, "#C60000");
Add(dictionary, "Needles", isTrinket: true, "#C60000");
Add(dictionary, "Terror", isTrinket: true, "#C60000");
Add(dictionary, "Overwhelmed", isTrinket: true, "#C60000");
Add(dictionary, "Paranoia", isTrinket: true, "#C60000");
Add(dictionary, "Infected", isTrinket: false, "#18420F");
return dictionary;
}
private static void Add(Dictionary<string, Classification> d, string title, bool isTrinket, string color)
{
d[title] = new Classification
{
isTrinket = isTrinket,
color = color
};
}
internal static void TryRun()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Invalid comparison between Unknown and I4
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Invalid comparison between Unknown and I4
if (_done)
{
return;
}
Perk[] array = Resources.FindObjectsOfTypeAll<Perk>();
if (array == null || array.Length == 0)
{
return;
}
int num = 0;
int num2 = 0;
Perk[] array2 = array;
foreach (Perk val in array2)
{
if ((Object)(object)val == (Object)null || (int)val.perkType == 8 || (int)val.perkType == 9 || string.IsNullOrEmpty(val.id))
{
continue;
}
string text = "cici_perk_" + val.id;
if (TrinketRegistry._registry.ContainsKey(text))
{
continue;
}
bool flag = false;
string text2 = null;
string text3 = val.title ?? val.id;
if (_byTitle.TryGetValue(text3.Trim(), out var value))
{
flag = value.isTrinket;
text2 = value.color;
}
else
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)("[AutoPerks] No classification for title='" + text3 + "' id='" + val.id + "' — defaulting to binding"));
}
}
Perk perkRef = val;
Func<List<Perk>> perksToGrantFactory = () => new List<Perk> { perkRef };
if (flag)
{
TrinketRegistry.RegisterTrinket(text, text3, val.description ?? "", val.flavorText ?? "", (val.cost <= 0) ? 1 : val.cost, 0f, 0f, val.icon, null, perksToGrantFactory);
num++;
}
else
{
TrinketRegistry.RegisterBinding(text, text3, val.description ?? "", val.flavorText ?? "", (val.cost <= 0) ? 1 : val.cost, 0f, 0f, val.icon, null, perksToGrantFactory);
num2++;
}
if (TrinketRegistry._registry.TryGetValue(text, out var value2))
{
value2.titleColor = text2;
value2.category = TrinketRegistry.Category.Perk;
value2.bucket = TrinketRegistry.BucketFromColor(text2);
value2.isFrameworkRegistered = true;
}
}
_done = true;
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"[AutoPerks] Registered {num} trinkets + {num2} bindings (out of {array.Length} Perk SOs)");
}
}
private static int ComputeMaxStacks(Perk perk)
{
int num = ((perk.stackMax > 0) ? perk.stackMax : 99);
if (perk.buff?.buffs == null || perk.buff.buffs.Count == 0)
{
return num;
}
float num2 = perk.buff.buffs[0].maxAmount * 100f;
if (num2 <= 0f)
{
return num;
}
if (num2 >= 100f)
{
return Mathf.Min(1, num);
}
return Mathf.Min(Mathf.CeilToInt(100f / num2), num);
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "ReloadTrinkets")]
public static class TrinketPickerScrollPatch
{
private const string ScrollViewportName = "CiCi_ScrollViewport";
private const float ViewportTopInset = 25f;
private const float ViewportBottomInset = 70f;
private const float SmoothWheelStep = 80f;
private const float SmoothTime = 0.18f;
private static readonly Color TrinketPulseColor = HexToColor("#FD44FF");
private static readonly Color BindingPulseColor = HexToColor("#E03434");
private const float ScrollbarWidth = 6f;
private const float ScrollbarHandleWidth = 6f;
[HarmonyPostfix]
public static void Postfix(UI_TrinketPicker __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
EnsureScroll(__instance.trinketIconRoot, TrinketPulseColor);
EnsureScroll(__instance.bindingIconRoot, BindingPulseColor);
}
private static Color HexToColor(string hex)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
Color result = default(Color);
ColorUtility.TryParseHtmlString(hex, ref result);
return result;
}
private static void EnsureScroll(Transform iconRoot, Color pulseColor)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_0072: 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)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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_00e9: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: 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_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: 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)
if ((Object)(object)iconRoot == (Object)null)
{
return;
}
RectTransform val = (RectTransform)(object)((iconRoot is RectTransform) ? iconRoot : null);
if (!((Object)(object)val == (Object)null) && (!((Object)(object)iconRoot.parent != (Object)null) || !(((Object)iconRoot.parent).name == "CiCi_ScrollViewport")))
{
Transform parent = iconRoot.parent;
RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null);
if (!((Object)(object)val2 == (Object)null))
{
Canvas.ForceUpdateCanvases();
Rect rect = val.rect;
Vector2 size = ((Rect)(ref rect)).size;
Vector2 anchorMin = val.anchorMin;
Vector2 anchorMax = val.anchorMax;
Vector2 pivot = val.pivot;
Vector2 anchoredPosition = val.anchoredPosition;
Vector2 sizeDelta = val.sizeDelta;
GameObject val3 = new GameObject("CiCi_ScrollViewport", new Type[1] { typeof(RectTransform) });
RectTransform val4 = (RectTransform)val3.transform;
((Transform)val4).SetParent((Transform)(object)val2, false);
val4.anchorMin = anchorMin;
val4.anchorMax = anchorMax;
val4.pivot = pivot;
float num = 22.5f;
val4.anchoredPosition = anchoredPosition + new Vector2(0f, num);
val4.sizeDelta = sizeDelta + new Vector2(0f, -95f);
((Transform)val4).SetSiblingIndex(((Transform)val).GetSiblingIndex());
((Transform)val).SetParent((Transform)(object)val4, false);
val.anchorMin = new Vector2(0f, 1f);
val.anchorMax = new Vector2(1f, 1f);
val.pivot = new Vector2(0.5f, 1f);
val.anchoredPosition = Vector2.zero;
val.sizeDelta = new Vector2(0f, size.y);
val3.AddComponent<RectMask2D>();
Image obj = val3.AddComponent<Image>();
((Graphic)obj).color = new Color(0f, 0f, 0f, 0f);
((Graphic)obj).raycastTarget = true;
ContentSizeFitter obj2 = ((Component)val).GetComponent<ContentSizeFitter>() ?? ((Component)val).gameObject.AddComponent<ContentSizeFitter>();
obj2.horizontalFit = (FitMode)0;
obj2.verticalFit = (FitMode)2;
ScrollRect val5 = val3.AddComponent<ScrollRect>();
val5.content = val;
val5.viewport = val4;
val5.horizontal = false;
val5.vertical = true;
val5.movementType = (MovementType)1;
val5.elasticity = 0.2f;
val5.scrollSensitivity = 0f;
val5.inertia = true;
val5.decelerationRate = 0.93f;
BuildScrollbar(val4, val5, pulseColor);
SmoothScrollDriver smoothScrollDriver = val3.AddComponent<SmoothScrollDriver>();
smoothScrollDriver.scrollRect = val5;
smoothScrollDriver.wheelStep = 80f;
smoothScrollDriver.smoothTime = 0.18f;
}
}
}
private static void BuildScrollbar(RectTransform viewportRt, ScrollRect scroll, Color pulseColor)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_003d: 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_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: 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_00f4: Expected O, but got Unknown
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Expected O, but got Unknown
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: 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_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("CiCi_Scrollbar", new Type[1] { typeof(RectTransform) });
RectTransform val2 = (RectTransform)val.transform;
((Transform)val2).SetParent((Transform)(object)viewportRt, false);
val2.anchorMin = new Vector2(1f, 0f);
val2.anchorMax = new Vector2(1f, 1f);
val2.pivot = new Vector2(1f, 0.5f);
val2.anchoredPosition = new Vector2(-4f, 0f);
val2.sizeDelta = new Vector2(6f, 0f);
((Transform)val2).SetAsLastSibling();
Image obj = val.AddComponent<Image>();
((Graphic)obj).color = new Color(0f, 0f, 0f, 0.35f);
((Graphic)obj).raycastTarget = true;
RectTransform val3 = (RectTransform)new GameObject("SlidingArea", new Type[1] { typeof(RectTransform) }).transform;
((Transform)val3).SetParent((Transform)(object)val2, false);
val3.anchorMin = Vector2.zero;
val3.anchorMax = Vector2.one;
val3.pivot = new Vector2(0.5f, 0.5f);
val3.anchoredPosition = Vector2.zero;
val3.sizeDelta = Vector2.zero;
GameObject val4 = new GameObject("Handle", new Type[1] { typeof(RectTransform) });
RectTransform val5 = (RectTransform)val4.transform;
((Transform)val5).SetParent((Transform)(object)val3, false);
val5.anchorMin = Vector2.zero;
val5.anchorMax = Vector2.one;
val5.pivot = new Vector2(0.5f, 0.5f);
val5.anchoredPosition = Vector2.zero;
val5.sizeDelta = new Vector2(0f, 0f);
Image val6 = val4.AddComponent<Image>();
((Graphic)val6).color = pulseColor;
((Graphic)val6).raycastTarget = true;
Scrollbar val7 = val.AddComponent<Scrollbar>();
val7.handleRect = val5;
((Selectable)val7).targetGraphic = (Graphic)(object)val6;
val7.direction = (Direction)2;
((Selectable)val7).transition = (Transition)0;
ScrollbarPulse scrollbarPulse = val4.AddComponent<ScrollbarPulse>();
scrollbarPulse.handleImage = val6;
scrollbarPulse.colorA = Color.black;
scrollbarPulse.colorB = pulseColor;
scrollbarPulse.period = 1.6f;
scroll.verticalScrollbar = val7;
scroll.verticalScrollbarVisibility = (ScrollbarVisibility)1;
}
}
public class SmoothScrollDriver : MonoBehaviour
{
public ScrollRect scrollRect;
public float wheelStep = 80f;
public float smoothTime = 0.18f;
private float _targetY;
private float _velocity;
private float _lastDrivenY;
private Camera _eventCam;
private bool _initialized;
private void OnEnable()
{
TryInit();
}
private void TryInit()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
if (!_initialized)
{
if ((Object)(object)scrollRect == (Object)null)
{
scrollRect = ((Component)this).GetComponent<ScrollRect>();
}
if (!((Object)(object)scrollRect == (Object)null) && !((Object)(object)scrollRect.content == (Object)null))
{
_targetY = scrollRect.content.anchoredPosition.y;
_lastDrivenY = _targetY;
Canvas componentInParent = ((Component)scrollRect).GetComponentInParent<Canvas>();
_eventCam = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
_initialized = true;
}
}
}
private void Update()
{
//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_0072: Unknown result type (might be due to invalid IL or missing references)
if (!_initialized)
{
TryInit();
}
if ((Object)(object)scrollRect == (Object)null || (Object)(object)scrollRect.content == (Object)null || (Object)(object)scrollRect.viewport == (Object)null)
{
return;
}
RectTransform viewport = scrollRect.viewport;
if (!((Object)(object)viewport == (Object)null) && RectTransformUtility.RectangleContainsScreenPoint(viewport, Vector2.op_Implicit(Input.mousePosition), _eventCam))
{
float y = Input.mouseScrollDelta.y;
if (!(Mathf.Abs(y) < 0.01f))
{
_targetY += (0f - y) * wheelStep;
ClampTarget();
}
}
}
private void LateUpdate()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)scrollRect == (Object)null) && !((Object)(object)scrollRect.content == (Object)null))
{
float y = scrollRect.content.anchoredPosition.y;
if (Mathf.Abs(y - _lastDrivenY) > 0.5f)
{
_targetY = y;
_velocity = 0f;
}
if (Mathf.Abs(scrollRect.velocity.y) > 0.5f)
{
_targetY = y;
_velocity = 0f;
_lastDrivenY = y;
}
else if (Mathf.Approximately(y, _targetY) && Mathf.Approximately(_velocity, 0f))
{
_lastDrivenY = y;
}
else
{
float num = Mathf.SmoothDamp(y, _targetY, ref _velocity, smoothTime);
Vector2 anchoredPosition = scrollRect.content.anchoredPosition;
anchoredPosition.y = num;
scrollRect.content.anchoredPosition = anchoredPosition;
_lastDrivenY = num;
}
}
}
private void ClampTarget()
{
//IL_0021: 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_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)
RectTransform viewport = scrollRect.viewport;
if (!((Object)(object)viewport == (Object)null))
{
Rect rect = scrollRect.content.rect;
float height = ((Rect)(ref rect)).height;
rect = viewport.rect;
float height2 = ((Rect)(ref rect)).height;
float num = Mathf.Max(0f, height - height2);
_targetY = Mathf.Clamp(_targetY, 0f, num);
}
}
}
public static class LeaderboardGate
{
private static bool _lastApplied;
private static readonly FieldInfoCache PickerCurrentGamemodeField = new FieldInfoCache(typeof(UI_TrinketPicker), "currentGamemode");
private static readonly string[] VanillaDisablingNames = new string[1] { "Trinket_Totem" };
public static bool IsTrinketNativeGamemode(M_Gamemode gm)
{
if ((Object)(object)gm == (Object)null)
{
return false;
}
if (gm.isEndless)
{
return true;
}
string text = gm.gamemodeName ?? "";
if (text == "Campaign")
{
return true;
}
return text.IndexOf("Chimney", StringComparison.OrdinalIgnoreCase) >= 0;
}
private static M_Gamemode GetPickerGamemode(UI_TrinketPicker picker)
{
if ((Object)(object)picker == (Object)null)
{
return null;
}
object obj = PickerCurrentGamemodeField.Get(picker);
return (M_Gamemode)(((obj is M_Gamemode) ? obj : null) ?? CL_GameManager.GetBaseGamemode());
}
private static bool MatchesVanillaDisabling(string savedNameLower)
{
if (string.IsNullOrEmpty(savedNameLower))
{
return false;
}
string[] vanillaDisablingNames = VanillaDisablingNames;
foreach (string text in vanillaDisablingNames)
{
if (savedNameLower.Contains(text.ToLowerInvariant()))
{
return true;
}
}
return false;
}
private static bool IsVanillaDisablingTrinket(Trinket t)
{
if ((Object)(object)t == (Object)null || string.IsNullOrEmpty(((Object)t).name))
{
return false;
}
string text = ((Object)t).name.ToLowerInvariant();
string[] vanillaDisablingNames = VanillaDisablingNames;
foreach (string text2 in vanillaDisablingNames)
{
if (text.Contains(text2.ToLowerInvariant()))
{
return true;
}
}
return false;
}
public static bool ShouldDisableForGamemode(M_Gamemode gm)
{
if ((Object)(object)gm == (Object)null)
{
return false;
}
List<string> list;
try
{
SaveData saveData = StatManager.saveData;
list = ((saveData != null) ? saveData.GetGamemodeTrinkets(gm.GetGamemodeName(true)) : null);
}
catch
{
return false;
}
if (list == null || list.Count == 0)
{
return false;
}
if (!IsTrinketNativeGamemode(gm))
{
foreach (string item in list)
{
if (!string.IsNullOrEmpty(item))
{
return true;
}
}
return false;
}
foreach (string item2 in list)
{
if (string.IsNullOrEmpty(item2))
{
continue;
}
string text = item2.ToLowerInvariant();
if (MatchesVanillaDisabling(text))
{
return true;
}
foreach (KeyValuePair<string, TrinketRegistry.Entry> item3 in TrinketRegistry._registry)
{
TrinketRegistry.Entry value = item3.Value;
if (value.disablesLeaderboards)
{
if (text.Contains(value.id.ToLowerInvariant()))
{
return true;
}
if ((Object)(object)value.runtime != (Object)null && !string.IsNullOrEmpty(((Object)value.runtime).name) && text.Contains(((Object)value.runtime).name.ToLowerInvariant()))
{
return true;
}
}
}
}
return false;
}
public static bool ShouldDisableForPicker(UI_TrinketPicker picker)
{
if ((Object)(object)picker == (Object)null || picker.selectedTrinkets == null)
{
return false;
}
if (!IsTrinketNativeGamemode(GetPickerGamemode(picker)))
{
return picker.selectedTrinkets.Count > 0;
}
foreach (Trinket selectedTrinket in picker.selectedTrinkets)
{
if (IsVanillaDisablingTrinket(selectedTrinket))
{
return true;
}
TrinketRegistry.Entry entry = TrinketRegistry.FindEntryForTrinket(selectedTrinket);
if (entry != null && entry.disablesLeaderboards)
{
return true;
}
}
return false;
}
public static void Apply(bool disable)
{
try
{
WK_Leaderboard_Core.disableLeaderboards = disable;
if (disable != _lastApplied)
{
_lastApplied = disable;
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)$"[LeaderboardGate] disableLeaderboards -> {disable}");
}
}
}
catch (Exception ex)
{
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogWarning((object)("[LeaderboardGate] apply failed: " + ex.Message));
}
}
}
}
[HarmonyPatch(typeof(M_Gamemode), "StartFreshGamemode")]
public static class LeaderboardGateStartPatch
{
[HarmonyPostfix]
public static void Postfix(M_Gamemode __instance)
{
LeaderboardGate.Apply(LeaderboardGate.ShouldDisableForGamemode(__instance));
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "SelectTrinket")]
public static class LeaderboardGateSelectPatch
{
[HarmonyPostfix]
public static void Postfix(UI_TrinketPicker __instance)
{
LeaderboardGate.Apply(LeaderboardGate.ShouldDisableForPicker(__instance));
LeaderboardWarning.Refresh(__instance);
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "Initialize")]
public static class LeaderboardGateInitPatch
{
[HarmonyPostfix]
public static void Postfix(UI_TrinketPicker __instance)
{
LeaderboardWarning.Ensure(__instance);
LeaderboardGate.Apply(LeaderboardGate.ShouldDisableForPicker(__instance));
LeaderboardWarning.Refresh(__instance);
}
}
[HarmonyPatch(typeof(UI_TrinketPicker), "ReloadTrinkets")]
public static class LeaderboardGateReloadPatch
{
[HarmonyPostfix]
public static void Postfix(UI_TrinketPicker __instance)
{
LeaderboardWarning.Ensure(__instance);
LeaderboardWarning.Refresh(__instance);
}
}
internal static class LeaderboardWarning
{
private const string ObjectName = "CiCi_LeaderboardWarning";
private static readonly Dictionary<UI_TrinketPicker, TextMeshProUGUI> _byPicker = new Dictionary<UI_TrinketPicker, TextMeshProUGUI>();
public static void Ensure(UI_TrinketPicker picker)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_0089: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)picker == (Object)null || (_byPicker.TryGetValue(picker, out var value) && (Object)(object)value != (Object)null))
{
return;
}
Transform transform = ((Component)picker).transform;
RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
if (!((Object)(object)val == (Object)null))
{
Transform obj = ((Transform)val).Find("CiCi_LeaderboardWarning");
RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null);
TextMeshProUGUI val3;
if ((Object)(object)val2 != (Object)null)
{
val3 = ((Component)val2).GetComponent<TextMeshProUGUI>();
}
else
{
GameObject val4 = new GameObject("CiCi_LeaderboardWarning", new Type[1] { typeof(RectTransform) });
RectTransform val5 = (RectTransform)val4.transform;
((Transform)val5).SetParent((Transform)(object)val, false);
val5.anchorMin = new Vector2(0.5f, 1f);
val5.anchorMax = new Vector2(0.5f, 1f);
val5.pivot = new Vector2(0.5f, 1f);
val5.anchoredPosition = new Vector2(-16f, -10f);
val5.sizeDelta = new Vector2(560f, 28f);
val3 = val4.AddComponent<TextMeshProUGUI>();
((TMP_Text)val3).text = "LEADERBOARDS DISABLED";
((TMP_Text)val3).fontSize = 22f;
((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
((Graphic)val3).color = new Color(1f, 0.25f, 0.25f, 1f);
((TMP_Text)val3).fontStyle = (FontStyles)1;
((Graphic)val3).raycastTarget = false;
((Transform)val5).SetAsLastSibling();
val4.SetActive(false);
}
if ((Object)(object)val3 != (Object)null && (Object)(object)picker.costText != (Object)null && (Object)(object)picker.costText.font != (Object)null)
{
((TMP_Text)val3).font = picker.costText.font;
}
if ((Object)(object)val3 != (Object)null)
{
_byPicker[picker] = val3;
}
}
}
public static void Refresh(UI_TrinketPicker picker)
{
if ((Object)(object)picker == (Object)null)
{
return;
}
if (!_byPicker.TryGetValue(picker, out var value) || (Object)(object)value == (Object)null)
{
Ensure(picker);
_byPicker.TryGetValue(picker, out value);
if ((Object)(object)value == (Object)null)
{
return;
}
}
bool flag = LeaderboardGate.ShouldDisableForPicker(picker);
if (((Component)value).gameObject.activeSelf != flag)
{
((Component)value).gameObject.SetActive(flag);
}
}
}
public class ScrollbarPulse : MonoBehaviour
{
public Image handleImage;
public Color colorA = Color.black;
public Color colorB = Color.white;
public float period = 1.6f;
private void Update()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)handleImage == (Object)null))
{
float num = (Mathf.Sin(Time.unscaledTime * 2f * MathF.PI / period) + 1f) * 0.5f;
((Graphic)handleImage).color = Color.Lerp(colorA, colorB, num);
}
}
}
}