Decompiled source of EquipmentAndQuickSlots v1.0.0
EquipmentAndQuickSlots.dll
Decompiled a year ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Auga; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Common; using CreatureLevelControl; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: AssemblyFileVersion("2.1.6")] [assembly: AssemblyCompany("Randy Knapp Mods")] [assembly: AssemblyProduct("EquipmentAndQuickSlots")] [assembly: AssemblyCopyright("Copyright © Randy Knapp 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyTitle("EquipmentAndQuickSlots")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: ComVisible(false)] [assembly: Guid("08ed5bc9-9e0c-4343-90a5-92497be6e216")] [assembly: AssemblyDescription("")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyConfiguration("")] [assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.6.0")] [module: UnverifiableCode] public static class PlayerExtensions { public static ZDO GetZDO(this Player player) { return ((Character)player).m_nview.GetZDO(); } } namespace Common { public class ConfigPositionedElement : MonoBehaviour { public ConfigEntry<TextAnchor> AnchorConfig; public ConfigEntry<Vector2> PositionConfig; protected RectTransform _rt; protected TextAnchor _currentAnchor; public virtual void Awake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown _rt = (RectTransform)((Component)this).transform; EnsureCorrectPosition(); } public virtual void Update() { EnsureCorrectPosition(); } public virtual void EnsureCorrectPosition() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected I4, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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) //IL_0145: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020b: 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_0241: 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_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: 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) if (AnchorConfig != null && PositionConfig != null && (_currentAnchor != AnchorConfig.Value || !(_rt.anchoredPosition == PositionConfig.Value))) { _currentAnchor = AnchorConfig.Value; TextAnchor currentAnchor = _currentAnchor; TextAnchor val = currentAnchor; Vector2 val2 = default(Vector2); switch ((int)val) { case 0: { RectTransform rt25 = _rt; RectTransform rt26 = _rt; RectTransform rt27 = _rt; ((Vector2)(ref val2))..ctor(0f, 1f); rt27.anchorMax = val2; Vector2 pivot = (rt26.anchorMin = val2); rt25.pivot = pivot; break; } case 1: { RectTransform rt22 = _rt; RectTransform rt23 = _rt; RectTransform rt24 = _rt; ((Vector2)(ref val2))..ctor(0.5f, 1f); rt24.anchorMax = val2; Vector2 pivot = (rt23.anchorMin = val2); rt22.pivot = pivot; break; } case 2: { RectTransform rt19 = _rt; RectTransform rt20 = _rt; RectTransform rt21 = _rt; ((Vector2)(ref val2))..ctor(1f, 1f); rt21.anchorMax = val2; Vector2 pivot = (rt20.anchorMin = val2); rt19.pivot = pivot; break; } case 3: { RectTransform rt16 = _rt; RectTransform rt17 = _rt; RectTransform rt18 = _rt; ((Vector2)(ref val2))..ctor(0f, 0.5f); rt18.anchorMax = val2; Vector2 pivot = (rt17.anchorMin = val2); rt16.pivot = pivot; break; } case 4: { RectTransform rt13 = _rt; RectTransform rt14 = _rt; RectTransform rt15 = _rt; ((Vector2)(ref val2))..ctor(0.5f, 0.5f); rt15.anchorMax = val2; Vector2 pivot = (rt14.anchorMin = val2); rt13.pivot = pivot; break; } case 5: { RectTransform rt10 = _rt; RectTransform rt11 = _rt; RectTransform rt12 = _rt; ((Vector2)(ref val2))..ctor(1f, 0.5f); rt12.anchorMax = val2; Vector2 pivot = (rt11.anchorMin = val2); rt10.pivot = pivot; break; } case 6: { RectTransform rt7 = _rt; RectTransform rt8 = _rt; RectTransform rt9 = _rt; ((Vector2)(ref val2))..ctor(0f, 0f); rt9.anchorMax = val2; Vector2 pivot = (rt8.anchorMin = val2); rt7.pivot = pivot; break; } case 7: { RectTransform rt4 = _rt; RectTransform rt5 = _rt; RectTransform rt6 = _rt; ((Vector2)(ref val2))..ctor(0.5f, 0f); rt6.anchorMax = val2; Vector2 pivot = (rt5.anchorMin = val2); rt4.pivot = pivot; break; } case 8: { RectTransform rt = _rt; RectTransform rt2 = _rt; RectTransform rt3 = _rt; ((Vector2)(ref val2))..ctor(1f, 0f); rt3.anchorMax = val2; Vector2 pivot = (rt2.anchorMin = val2); rt.pivot = pivot; break; } } _rt.anchoredPosition = PositionConfig.Value; } } } [Serializable] public class RecipeRequirementConfig { public string item = ""; public int amount = 1; } [Serializable] public class RecipeConfig { public string name = ""; public string item = ""; public int amount = 1; public string craftingStation = ""; public int minStationLevel = 1; public bool enabled = true; public string repairStation = ""; public List<RecipeRequirementConfig> resources = new List<RecipeRequirementConfig>(); } [Serializable] public class RecipesConfig { public List<RecipeConfig> recipes = new List<RecipeConfig>(); } public static class GameObjectExtensions { public static RectTransform RectTransform(this GameObject go) { Transform transform = go.transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); } public static T RequireComponent<T>(this GameObject go) where T : Component { T component = go.GetComponent<T>(); return ((Object)(object)component == (Object)null) ? go.AddComponent<T>() : component; } } public class GotDestroyed : MonoBehaviour { public void OnDisable() { Debug.LogError((object)("I got destroyed! (" + ((Object)((Component)this).gameObject).name + ")")); Debug.Log((object)Environment.StackTrace); } } public class MultiValueDictionary<TKey, TValue> : Dictionary<TKey, List<TValue>> { public void Add(TKey key, TValue value) { if (!TryGetValue(key, out var value2)) { value2 = new List<TValue>(); Add(key, value2); } value2.Add(value); } public bool ContainsValue(TKey key, TValue value) { if (TryGetValue(key, out var value2)) { return value2.Contains(value); } return false; } public void Remove(TKey key, TValue value) { if (TryGetValue(key, out var value2)) { value2.Remove(value); if (value2.Count <= 0) { Remove(key); } } } public void Merge(MultiValueDictionary<TKey, TValue> toMergeWith) { if (toMergeWith == null) { return; } foreach (KeyValuePair<TKey, List<TValue>> item in toMergeWith) { foreach (TValue item2 in item.Value) { Add(item.Key, item2); } } } public List<TValue> GetValues(TKey key, bool returnEmptySet = false) { if (!TryGetValue(key, out var value) && returnEmptySet) { return new List<TValue>(); } return value; } } public static class PrefabCreator { public static ManualLogSource Logger; public static Dictionary<string, CraftingStation> CraftingStations; public static T RequireComponent<T>(GameObject go) where T : Component { T val = go.GetComponent<T>(); if ((Object)(object)val == (Object)null) { val = go.AddComponent<T>(); } return val; } public static void Reset() { CraftingStations = null; } private static void InitCraftingStations() { if (CraftingStations != null) { return; } CraftingStations = new Dictionary<string, CraftingStation>(); foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if ((Object)(object)recipe.m_craftingStation != (Object)null && !CraftingStations.ContainsKey(((Object)recipe.m_craftingStation).name)) { CraftingStations.Add(((Object)recipe.m_craftingStation).name, recipe.m_craftingStation); } } } public static Recipe CreateRecipe(string name, string itemId, RecipeConfig recipeConfig) { //IL_024b: 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_025d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Expected O, but got Unknown InitCraftingStations(); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemId); if ((Object)(object)itemPrefab == (Object)null) { ManualLogSource logger = Logger; if (logger != null) { logger.LogWarning((object)("[PrefabCreator] Could not find item prefab (" + itemId + ")")); } return null; } Recipe val = ScriptableObject.CreateInstance<Recipe>(); ((Object)val).name = name; val.m_amount = recipeConfig.amount; val.m_minStationLevel = recipeConfig.minStationLevel; val.m_item = itemPrefab.GetComponent<ItemDrop>(); val.m_enabled = recipeConfig.enabled; if (!string.IsNullOrEmpty(recipeConfig.craftingStation)) { if (!CraftingStations.ContainsKey(recipeConfig.craftingStation)) { ManualLogSource logger2 = Logger; if (logger2 != null) { logger2.LogWarning((object)("[PrefabCreator] Could not find crafting station (" + itemId + "): " + recipeConfig.craftingStation)); } string text = string.Join(", ", CraftingStations.Keys); ManualLogSource logger3 = Logger; if (logger3 != null) { logger3.LogInfo((object)("[PrefabCreator] Available Stations: " + text)); } } else { val.m_craftingStation = CraftingStations[recipeConfig.craftingStation]; } } if (!string.IsNullOrEmpty(recipeConfig.repairStation)) { if (!CraftingStations.ContainsKey(recipeConfig.repairStation)) { ManualLogSource logger4 = Logger; if (logger4 != null) { logger4.LogWarning((object)("[PrefabCreator] Could not find repair station (" + itemId + "): " + recipeConfig.repairStation)); } string text2 = string.Join(", ", CraftingStations.Keys); ManualLogSource logger5 = Logger; if (logger5 != null) { logger5.LogInfo((object)("[PrefabCreator] Available Stations: " + text2)); } } else { val.m_repairStation = CraftingStations[recipeConfig.repairStation]; } } List<Requirement> list = new List<Requirement>(); foreach (RecipeRequirementConfig resource in recipeConfig.resources) { GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(resource.item); if ((Object)(object)itemPrefab2 == (Object)null) { ManualLogSource logger6 = Logger; if (logger6 != null) { logger6.LogError((object)("[PrefabCreator] Could not find requirement item (" + itemId + "): " + resource.item)); } } else { list.Add(new Requirement { m_amount = resource.amount, m_resItem = itemPrefab2.GetComponent<ItemDrop>() }); } } val.m_resources = list.ToArray(); return val; } public static Recipe AddNewRecipe(string name, string itemId, RecipeConfig recipeConfig) { Recipe val = CreateRecipe(name, itemId, recipeConfig); if ((Object)(object)val == (Object)null) { ManualLogSource logger = Logger; if (logger != null) { logger.LogError((object)("[PrefabCreator] Failed to create recipe (" + name + ")")); } return null; } return AddNewRecipe(val); } public static Recipe AddNewRecipe(Recipe recipe) { int num = ObjectDB.instance.m_recipes.RemoveAll((Recipe x) => ((Object)x).name == ((Object)recipe).name); if (num > 0) { ManualLogSource logger = Logger; if (logger != null) { logger.LogInfo((object)$"[PrefabCreator] Removed recipe ({((Object)recipe).name}): {num}"); } } ObjectDB.instance.m_recipes.Add(recipe); ManualLogSource logger2 = Logger; if (logger2 != null) { logger2.LogInfo((object)("[PrefabCreator] Added recipe: " + ((Object)recipe).name)); } return recipe; } } [Serializable] public struct SerializableVector3 { public float x; public float y; public float z; public SerializableVector3(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } public void ToPackage(ZPackage pkg) { pkg.Write(x); pkg.Write(y); pkg.Write(z); } public static SerializableVector3 FromPackage(ZPackage pkg) { SerializableVector3 result = default(SerializableVector3); result.x = pkg.ReadSingle(); result.y = pkg.ReadSingle(); result.z = pkg.ReadSingle(); return result; } public override string ToString() { return $"[{x}, {y}, {z}]"; } public static implicit operator Vector3(SerializableVector3 s) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(s.x, s.y, s.z); } public static implicit operator SerializableVector3(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new SerializableVector3(v.x, v.y, v.z); } public static SerializableVector3 operator +(SerializableVector3 a, SerializableVector3 b) { return new SerializableVector3(a.x + b.x, a.y + b.y, a.z + b.z); } public static SerializableVector3 operator -(SerializableVector3 a, SerializableVector3 b) { return new SerializableVector3(a.x - b.x, a.y - b.y, a.z - b.z); } public static SerializableVector3 operator -(SerializableVector3 a) { return new SerializableVector3(0f - a.x, 0f - a.y, 0f - a.z); } public static SerializableVector3 operator *(SerializableVector3 a, float m) { return new SerializableVector3(a.x * m, a.y * m, a.z * m); } public static SerializableVector3 operator *(float m, SerializableVector3 a) { return new SerializableVector3(a.x * m, a.y * m, a.z * m); } public static SerializableVector3 operator /(SerializableVector3 a, float d) { return new SerializableVector3(a.x / d, a.y / d, a.z / d); } } public static class Utils { public static void PrintObject(object o) { if (o == null) { Debug.Log((object)"null"); } else { Debug.Log((object)(o?.ToString() + ":\n" + GetObjectString(o, " "))); } } public static string GetObjectString(object obj, string indent) { string text = ""; Type type = obj.GetType(); IEnumerable<FieldInfo> enumerable = from f in type.GetFields() where f.IsPublic select f; foreach (FieldInfo item in enumerable) { object value = item.GetValue(obj); string text2 = ((value == null) ? "null" : value.ToString()); text = text + "\n" + indent + item.Name + ": " + text2; } return text; } public static Sprite LoadSpriteFromFile(string spritePath) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) spritePath = Path.Combine(Paths.PluginPath, spritePath); if (File.Exists(spritePath)) { byte[] array = File.ReadAllBytes(spritePath); Texture2D val = new Texture2D(20, 20); if (ImageConversion.LoadImage(val, array)) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), default(Vector2), 100f); } } return null; } public static Sprite LoadSpriteFromFile(string modFolder, string iconName) { string spritePath = Path.Combine(modFolder, iconName); return LoadSpriteFromFile(spritePath); } public static string RemoveBetween(string s, string from, string to) { int num = 0; while (num >= 0) { num = s.IndexOf(from, StringComparison.InvariantCulture); if (num < 0) { break; } int num2 = s.IndexOf(to, num, StringComparison.InvariantCulture); if (num2 < 0) { break; } s = s.Remove(num, num2 - num + to.Length); } return s; } public static void CopyFields(object originalObject, object cloneObject, Type typeToReflect, BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public) { FieldInfo[] fields = typeToReflect.GetFields(bindingFlags); foreach (FieldInfo fieldInfo in fields) { object value = fieldInfo.GetValue(originalObject); fieldInfo.SetValue(cloneObject, value); } } public static bool IsServer() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 return ZNet.instance.IsServer() || ZNet.instance.IsDedicated() || (int)SystemInfo.graphicsDeviceType == 4; } } public static class ArrayUtils { public static bool IsNullOrEmpty<T>(T[] a) { return a == null || a.Length == 0; } public static T[] Copy<T>(T[] other) { return other?.ToArray(); } } public static class ListExtensions { public static bool TryFind<T>(this List<T> list, Predicate<T> predicate, out T result) { int num = list.FindIndex(predicate); if (num != -1) { result = list[num]; return true; } result = default(T); return false; } } public class WeightedRandomCollection<T> { private readonly Random _random; private List<T> _list; private Func<T, float> _weightSelector; private bool _removeOnSelect; public float TotalWeight { get; private set; } public WeightedRandomCollection(Random random) { _random = random; } public WeightedRandomCollection(Random random, IEnumerable<T> collection, Func<T, float> weightSelector, bool removeOnSelect = false) { _random = random ?? new Random(); Setup(collection, weightSelector, removeOnSelect); } public void Setup(IEnumerable<T> collection, Func<T, float> weightSelector, bool removeOnSelect = false) { _list = collection.ToList(); _weightSelector = weightSelector; _removeOnSelect = removeOnSelect; TotalWeight = _list.Sum(_weightSelector); } public T Roll() { if (_list == null) { return default(T); } float num = (float)_random.NextDouble() * TotalWeight; float num2 = 0f; T val = default(T); foreach (var item in _list.Select((T weightedItem) => new { Value = weightedItem, Weight = _weightSelector(weightedItem) })) { num2 += item.Weight; if (num2 >= num) { val = item.Value; break; } } if (_removeOnSelect) { _list.Remove(val); TotalWeight = _list.Sum(_weightSelector); } return val; } public List<T> Roll(int numberOfRolls) { if (_list == null) { return null; } List<T> list = new List<T>(); for (int i = 0; i < numberOfRolls; i++) { T x = Roll(); if (!EqualityComparer<T>.Default.Equals(x, default(T))) { list.Add(Roll()); } } return list; } public void Reset() { _list = null; _weightSelector = null; _removeOnSelect = false; TotalWeight = 0f; } } } namespace EquipmentAndQuickSlots { [HarmonyPatch(typeof(Terminal), "InitTerminal")] public static class Terminal_Patch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Action<Inventory> <>9__0_5; public static ConsoleEvent <>9__0_0; public static ConsoleEvent <>9__0_1; public static Action<Inventory> <>9__0_6; public static ConsoleEvent <>9__0_2; public static Action<Inventory> <>9__0_8; public static ConsoleEvent <>9__0_3; public static Action<Inventory> <>9__0_9; public static ConsoleEvent <>9__0_4; internal void <Postfix>b__0_0(ConsoleEventArgs args) { Player.m_localPlayer.GetAllInventories().ForEach(delegate(Inventory x) { x.RemoveAll(); }); } internal void <Postfix>b__0_5(Inventory x) { x.RemoveAll(); } internal void <Postfix>b__0_1(ConsoleEventArgs args) { foreach (Inventory allInventory in Player.m_localPlayer.GetAllInventories()) { foreach (ItemData item in allInventory.m_inventory) { if (item.m_equipped && item.m_shared.m_useDurability) { item.m_durability = 0f; } } } } internal void <Postfix>b__0_2(ConsoleEventArgs args) { Player.m_localPlayer.GetAllInventories().ForEach(delegate(Inventory inv) { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) EquipmentAndQuickSlots.LogWarning($"Fixing inventory: {inv.m_name} ({inv.m_width}, {inv.m_height})"); List<Vector2i> list = new List<Vector2i>(); using List<ItemData>.Enumerator enumerator = inv.m_inventory.GetEnumerator(); while (enumerator.MoveNext()) { <>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0 { itemData = enumerator.Current }; if (list.Exists((Vector2i pos) => pos == CS$<>8__locals0.itemData.m_gridPos)) { EquipmentAndQuickSlots.LogWarning($"Found item overlapping other item: {CS$<>8__locals0.itemData.m_shared.m_name} ({CS$<>8__locals0.itemData.m_gridPos.x}, {CS$<>8__locals0.itemData.m_gridPos.y}), dropping to ground..."); ((Humanoid)Player.m_localPlayer).DropItem(inv, CS$<>8__locals0.itemData, CS$<>8__locals0.itemData.m_stack); } if (CS$<>8__locals0.itemData.m_gridPos.x < 0 || CS$<>8__locals0.itemData.m_gridPos.x >= inv.m_width || CS$<>8__locals0.itemData.m_gridPos.y < 0 || CS$<>8__locals0.itemData.m_gridPos.y >= inv.m_height) { EquipmentAndQuickSlots.LogWarning($"Found item outside grid: {CS$<>8__locals0.itemData.m_shared.m_name} ({CS$<>8__locals0.itemData.m_gridPos.x}, {CS$<>8__locals0.itemData.m_gridPos.y}), dropping to ground..."); ((Humanoid)Player.m_localPlayer).DropItem(inv, CS$<>8__locals0.itemData, CS$<>8__locals0.itemData.m_stack); } list.Add(CS$<>8__locals0.itemData.m_gridPos); } }); } internal void <Postfix>b__0_6(Inventory inv) { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) EquipmentAndQuickSlots.LogWarning($"Fixing inventory: {inv.m_name} ({inv.m_width}, {inv.m_height})"); List<Vector2i> list = new List<Vector2i>(); using List<ItemData>.Enumerator enumerator = inv.m_inventory.GetEnumerator(); while (enumerator.MoveNext()) { <>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0 { itemData = enumerator.Current }; if (list.Exists((Vector2i pos) => pos == CS$<>8__locals0.itemData.m_gridPos)) { EquipmentAndQuickSlots.LogWarning($"Found item overlapping other item: {CS$<>8__locals0.itemData.m_shared.m_name} ({CS$<>8__locals0.itemData.m_gridPos.x}, {CS$<>8__locals0.itemData.m_gridPos.y}), dropping to ground..."); ((Humanoid)Player.m_localPlayer).DropItem(inv, CS$<>8__locals0.itemData, CS$<>8__locals0.itemData.m_stack); } if (CS$<>8__locals0.itemData.m_gridPos.x < 0 || CS$<>8__locals0.itemData.m_gridPos.x >= inv.m_width || CS$<>8__locals0.itemData.m_gridPos.y < 0 || CS$<>8__locals0.itemData.m_gridPos.y >= inv.m_height) { EquipmentAndQuickSlots.LogWarning($"Found item outside grid: {CS$<>8__locals0.itemData.m_shared.m_name} ({CS$<>8__locals0.itemData.m_gridPos.x}, {CS$<>8__locals0.itemData.m_gridPos.y}), dropping to ground..."); ((Humanoid)Player.m_localPlayer).DropItem(inv, CS$<>8__locals0.itemData, CS$<>8__locals0.itemData.m_stack); } list.Add(CS$<>8__locals0.itemData.m_gridPos); } } internal void <Postfix>b__0_3(ConsoleEventArgs args) { Player.m_localPlayer.GetAllInventories().ForEach(delegate(Inventory inv) { List<ItemData> list = new List<ItemData>(inv.m_inventory); foreach (ItemData item in list) { EquipmentAndQuickSlots.LogWarning($"Dropping item: {item.m_shared.m_name} ({item.m_gridPos.x}, {item.m_gridPos.y}), dropping to ground..."); ((Humanoid)Player.m_localPlayer).DropItem(inv, item, item.m_stack); } }); } internal void <Postfix>b__0_8(Inventory inv) { List<ItemData> list = new List<ItemData>(inv.m_inventory); foreach (ItemData item in list) { EquipmentAndQuickSlots.LogWarning($"Dropping item: {item.m_shared.m_name} ({item.m_gridPos.x}, {item.m_gridPos.y}), dropping to ground..."); ((Humanoid)Player.m_localPlayer).DropItem(inv, item, item.m_stack); } } internal void <Postfix>b__0_4(ConsoleEventArgs args) { Player.m_localPlayer.GetAllInventories().ForEach(delegate(Inventory inv) { EquipmentAndQuickSlots.LogWarning($"inv: {inv.m_name}, ({inv.m_width}, {inv.m_height})"); List<ItemData> list = new List<ItemData>(inv.m_inventory); foreach (ItemData item in list) { EquipmentAndQuickSlots.LogWarning($"- {item.m_shared.m_name} ({item.m_gridPos.x}, {item.m_gridPos.y})"); } }); } internal void <Postfix>b__0_9(Inventory inv) { EquipmentAndQuickSlots.LogWarning($"inv: {inv.m_name}, ({inv.m_width}, {inv.m_height})"); List<ItemData> list = new List<ItemData>(inv.m_inventory); foreach (ItemData item in list) { EquipmentAndQuickSlots.LogWarning($"- {item.m_shared.m_name} ({item.m_gridPos.x}, {item.m_gridPos.y})"); } } } [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public ItemData itemData; internal bool <Postfix>b__7(Vector2i pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return pos == itemData.m_gridPos; } } public static void Postfix() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate { Player.m_localPlayer.GetAllInventories().ForEach(delegate(Inventory x) { x.RemoveAll(); }); }; <>c.<>9__0_0 = val; obj = (object)val; } ConsoleCommand val2 = new ConsoleCommand("resetinventory", "Remove everything from every inventory", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleEvent val3 = delegate { foreach (Inventory allInventory in Player.m_localPlayer.GetAllInventories()) { foreach (ItemData item in allInventory.m_inventory) { if (item.m_equipped && item.m_shared.m_useDurability) { item.m_durability = 0f; } } } }; <>c.<>9__0_1 = val3; obj2 = (object)val3; } ConsoleCommand val4 = new ConsoleCommand("breakequipment", "Break all the equipment in your inventory", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__0_2; if (obj3 == null) { ConsoleEvent val5 = delegate { Player.m_localPlayer.GetAllInventories().ForEach(delegate(Inventory inv) { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) EquipmentAndQuickSlots.LogWarning($"Fixing inventory: {inv.m_name} ({inv.m_width}, {inv.m_height})"); List<Vector2i> list3 = new List<Vector2i>(); foreach (ItemData itemData in inv.m_inventory) { if (list3.Exists((Vector2i pos) => pos == itemData.m_gridPos)) { EquipmentAndQuickSlots.LogWarning($"Found item overlapping other item: {itemData.m_shared.m_name} ({itemData.m_gridPos.x}, {itemData.m_gridPos.y}), dropping to ground..."); ((Humanoid)Player.m_localPlayer).DropItem(inv, itemData, itemData.m_stack); } if (itemData.m_gridPos.x < 0 || itemData.m_gridPos.x >= inv.m_width || itemData.m_gridPos.y < 0 || itemData.m_gridPos.y >= inv.m_height) { EquipmentAndQuickSlots.LogWarning($"Found item outside grid: {itemData.m_shared.m_name} ({itemData.m_gridPos.x}, {itemData.m_gridPos.y}), dropping to ground..."); ((Humanoid)Player.m_localPlayer).DropItem(inv, itemData, itemData.m_stack); } list3.Add(itemData.m_gridPos); } }); }; <>c.<>9__0_2 = val5; obj3 = (object)val5; } ConsoleCommand val6 = new ConsoleCommand("fixinventory", "Fix the bug where items are not visible in your inventory (drops them to the ground)", (ConsoleEvent)obj3, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj4 = <>c.<>9__0_3; if (obj4 == null) { ConsoleEvent val7 = delegate { Player.m_localPlayer.GetAllInventories().ForEach(delegate(Inventory inv) { List<ItemData> list2 = new List<ItemData>(inv.m_inventory); foreach (ItemData item2 in list2) { EquipmentAndQuickSlots.LogWarning($"Dropping item: {item2.m_shared.m_name} ({item2.m_gridPos.x}, {item2.m_gridPos.y}), dropping to ground..."); ((Humanoid)Player.m_localPlayer).DropItem(inv, item2, item2.m_stack); } }); }; <>c.<>9__0_3 = val7; obj4 = (object)val7; } ConsoleCommand val8 = new ConsoleCommand("dropall", "Drop every item in your inventory", (ConsoleEvent)obj4, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj5 = <>c.<>9__0_4; if (obj5 == null) { ConsoleEvent val9 = delegate { Player.m_localPlayer.GetAllInventories().ForEach(delegate(Inventory inv) { EquipmentAndQuickSlots.LogWarning($"inv: {inv.m_name}, ({inv.m_width}, {inv.m_height})"); List<ItemData> list = new List<ItemData>(inv.m_inventory); foreach (ItemData item3 in list) { EquipmentAndQuickSlots.LogWarning($"- {item3.m_shared.m_name} ({item3.m_gridPos.x}, {item3.m_gridPos.y})"); } }); }; <>c.<>9__0_4 = val9; obj5 = (object)val9; } ConsoleCommand val10 = new ConsoleCommand("invcheck", "List every item in your inventory", (ConsoleEvent)obj5, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } public static class InventoryExtensions { public static bool IsExtended(this Inventory inventory) { return inventory is ExtendedInventory; } public static ExtendedInventory Extended(this Inventory inventory) { return (inventory is ExtendedInventory extendedInventory) ? extendedInventory : null; } public static bool DoExtendedCall(this Inventory inventory) { return inventory.Extended() != null && !inventory.Extended().CallBase; } public static bool CountAsEmptySlots(this Inventory inventory, Player player) { return inventory != player.GetEquipmentSlotInventory(); } } public class ExtendedInventory : Inventory { private readonly Player _player; private List<Inventory> _inventories; public bool CallBase { get; set; } public ExtendedInventory(Player player, string name, Sprite bkg, int w, int h) : base(name, bkg, w, h) { _player = player; } public void OverrideAwake() { _player.InitializeExtendedPlayer(); _inventories = _player.GetAllInventories(); OverrideUpdateTotalWeight(); } public bool OverrideCanAddItem(GameObject prefab, int stack) { CallBase = true; bool result = _inventories.Any((Inventory x) => x.CountAsEmptySlots(_player) && x.CanAddItem(prefab, stack)); CallBase = false; return result; } public bool OverrideCanAddItem(ItemData item, int stack) { CallBase = true; bool result = _inventories.Any((Inventory x) => x.CountAsEmptySlots(_player) && x.CanAddItem(item, stack)); CallBase = false; return result; } public bool OverrideAddItem(ItemData item) { CallBase = true; bool result = false; foreach (Inventory inventory in _inventories) { if (!inventory.CountAsEmptySlots(_player) || !inventory.AddItem(item)) { continue; } OverrideUpdateTotalWeight(); result = true; break; } CallBase = false; return result; } public Vector2i OverrideFindEmptySlot(bool topFirst) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) CallBase = true; Vector2i val = default(Vector2i); ((Vector2i)(ref val))..ctor(-1, -1); foreach (Inventory inventory in _inventories) { if (inventory.CountAsEmptySlots(_player)) { val = inventory.FindEmptySlot(topFirst); if (val.x != -1) { break; } } } CallBase = false; return val; } public ItemData OverrideFindFreeStackItem(string name, int quality, float worldLevel) { ItemData val = null; foreach (Inventory inventory in _inventories) { if (inventory.CountAsEmptySlots(_player)) { val = inventory.FindFreeStackItem(name, quality, worldLevel); if (val != null) { break; } } } return val; } public bool OverrideContainsItem(ItemData item) { CallBase = true; bool result = _inventories.Any((Inventory x) => x.ContainsItem(item)); CallBase = false; return result; } public List<ItemData> OverrideGetEquipedItems() { CallBase = true; List<ItemData> result = new List<ItemData>(); _inventories.ForEach(delegate(Inventory x) { result.AddRange(x.GetEquippedItems()); }); CallBase = false; return result; } public void OverrideGetWornItems(List<ItemData> worn) { CallBase = true; _inventories.ForEach(delegate(Inventory x) { x.GetWornItems(worn); }); CallBase = false; } public void OverrideGetValuableItems(List<ItemData> items) { CallBase = true; _inventories.ForEach(delegate(Inventory x) { x.GetValuableItems(items); }); CallBase = false; } public List<ItemData> OverrideGetAllItems() { CallBase = true; List<ItemData> result = new List<ItemData>(); _inventories.ForEach(delegate(Inventory x) { result.AddRange(x.m_inventory); }); CallBase = false; return result; } public void OverrideGetAllItems(string name, List<ItemData> items) { CallBase = true; _inventories.ForEach(delegate(Inventory x) { x.GetAllItems(name, items); }); CallBase = false; } public void OverrideGetAllItems(ItemType type, List<ItemData> items) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) CallBase = true; _inventories.ForEach(delegate(Inventory x) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) x.GetAllItems(type, items); }); CallBase = false; } public int OverrideGetEmptySlots() { CallBase = true; int result = _inventories.Sum((Inventory x) => x.CountAsEmptySlots(_player) ? x.GetEmptySlots() : 0); CallBase = false; return result; } public bool OverrideHaveEmptySlot() { CallBase = true; bool result = _inventories.Any((Inventory x) => x.CountAsEmptySlots(_player) && x.HaveEmptySlot()); CallBase = false; return result; } public bool OverrideRemoveOneItem(ItemData item) { CallBase = true; bool result = _inventories.Any((Inventory x) => x.RemoveOneItem(item)); OverrideUpdateTotalWeight(); CallBase = false; return result; } public bool OverrideRemoveItem(ItemData item) { CallBase = true; bool result = _inventories.Any((Inventory x) => x.RemoveItem(item)); OverrideUpdateTotalWeight(); CallBase = false; return result; } public bool OverrideRemoveItem(ItemData item, int amount) { CallBase = true; bool result = _inventories.Any((Inventory x) => x.RemoveItem(item, amount)); OverrideUpdateTotalWeight(); CallBase = false; return result; } public void OverrideRemoveItem(string name, int amount, int itemQuality = -1, bool worldLevelBased = true) { CallBase = true; foreach (Inventory inventory in _inventories) { foreach (ItemData item in inventory.m_inventory) { if (item.m_shared.m_name == name && (itemQuality < 0 || item.m_quality == itemQuality) && (!worldLevelBased || item.m_worldLevel >= Game.m_worldLevel)) { int num = Mathf.Min(item.m_stack, amount); item.m_stack -= num; amount -= num; inventory.Changed(); if (amount <= 0) { break; } } } inventory.m_inventory.RemoveAll((ItemData x) => x.m_stack <= 0); OverrideUpdateTotalWeight(); } CallBase = false; } public bool OverrideHaveItem(string name, bool matchWorldLevel) { CallBase = true; bool result = _inventories.Any((Inventory x) => x.HaveItem(name, matchWorldLevel)); CallBase = false; return result; } public void OverrideGetAllPieceTables(List<PieceTable> tables) { CallBase = true; _inventories.ForEach(delegate(Inventory x) { x.GetAllPieceTables(tables); }); CallBase = false; } public int OverrideCountItems(string name, bool matchWorldLevel) { CallBase = true; int result = _inventories.Sum((Inventory x) => x.CountItems(name, -1, matchWorldLevel)); CallBase = false; return result; } public ItemData OverrideGetItem(string name, int quality = -1, bool isPrefabName = false) { CallBase = true; ItemData val = null; foreach (Inventory inventory in _inventories) { val = inventory.GetItem(name, quality, isPrefabName); if (val != null) { break; } } CallBase = false; return val; } public ItemData OverrideGetAmmoItem(string ammoName, string matchPrefabName = null) { CallBase = true; ItemData val = null; foreach (Inventory inventory in _inventories) { val = inventory.GetAmmoItem(ammoName, matchPrefabName); if (val != null) { break; } } CallBase = false; return val; } public int OverrideFindFreeStackSpace(string name, float worldLevel) { CallBase = true; int result = _inventories.Sum((Inventory x) => x.FindFreeStackSpace(name, worldLevel)); CallBase = false; return result; } public int OverrideNrOfItems() { CallBase = true; int result = _inventories.Sum((Inventory x) => x.NrOfItems()); CallBase = false; return result; } public float OverrideSlotsUsedPercentage() { float num = _inventories.Sum((Inventory x) => x.m_inventory.Count); float num2 = _inventories.Sum((Inventory x) => x.m_width * x.m_height); return num / num2 * 100f; } public void OverrideUpdateTotalWeight() { CallBase = true; base.m_totalWeight = 0f; float[] array = new float[_inventories.Count()]; for (int i = 0; i < _inventories.Count(); i++) { foreach (ItemData item in _inventories[i].m_inventory) { array[i] += item.GetWeight(); } base.m_totalWeight += array[i]; } CallBase = false; } public bool OverrideIsTeleportable() { CallBase = true; bool result = _inventories.All((Inventory x) => x.IsTeleportable()); CallBase = false; return result; } } public static class CustomHotkeyBar { [HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")] public static class HotkeyBar_UpdateIcons_Patch { public static void UpdateIcons(HotkeyBar instance, Player player, List<ItemData> m_items) { if (!(((Object)instance).name != "QuickSlotsHotkeyBar")) { player.GetQuickSlotInventory().GetBoundItems(m_items); } } public static int UpdateIconCount(int defaultCount, HotkeyBar instance) { if (((Object)instance).name != "QuickSlotsHotkeyBar") { return defaultCount; } return 3; } [UsedImplicitly] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> instrs = instructions.ToList(); int counter6 = 0; MethodInfo boundItemsMethod = AccessTools.DeclaredMethod(typeof(Inventory), "GetBoundItems", (Type[])null, (Type[])null); FieldInfo itemsListField = AccessTools.DeclaredField(typeof(HotkeyBar), "m_items"); AccessTools.PropertySetter(typeof(Text), "text"); int i = 0; while (i < instrs.Count) { yield return LogMessage(instrs[i]); counter6++; if (i > 6 && instrs[i].opcode == OpCodes.Callvirt && instrs[i].operand.Equals(boundItemsMethod)) { CodeInstruction ldArgInstruction = new CodeInstruction(OpCodes.Ldarg_0, (object)null); if (instrs[i].labels.Count > 0) { CodeInstructionExtensions.MoveLabelsTo(instrs[i], ldArgInstruction); } yield return LogMessage(ldArgInstruction); counter6++; yield return LogMessage(new CodeInstruction(OpCodes.Ldarg_1, (object)null)); counter6++; yield return LogMessage(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); counter6++; yield return LogMessage(new CodeInstruction(OpCodes.Ldfld, (object)itemsListField)); counter6++; yield return LogMessage(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(HotkeyBar_UpdateIcons_Patch), "UpdateIcons", (Type[])null, (Type[])null))); counter6++; } else if (i > 6 && instrs[i].opcode == OpCodes.Ldc_I4_0 && instrs[i + 1].opcode == OpCodes.Stloc_0) { yield return LogMessage(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); counter6++; yield return LogMessage(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(HotkeyBar_UpdateIcons_Patch), "UpdateIconCount", (Type[])null, (Type[])null))); counter6++; } int num = i + 1; i = num; } static CodeInstruction LogMessage(CodeInstruction instruction) { return instruction; } } } } [HarmonyPatch(typeof(Hud), "Awake")] public static class Hud_Awake_Patch { public static void Postfix(Hud __instance) { HotkeyBar componentInChildren = ((Component)__instance).GetComponentInChildren<HotkeyBar>(); if (EquipmentAndQuickSlots.QuickSlotsEnabled.Value && (Object)(object)((Component)componentInChildren).transform.parent.Find("QuickSlotsHotkeyBar") == (Object)null) { GameObject val = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject, __instance.m_rootObject.transform, true); HotkeyBar component = val.GetComponent<HotkeyBar>(); component.m_selected = -1; ((Object)val).name = "QuickSlotsHotkeyBar"; ConfigPositionedElement configPositionedElement = val.AddComponent<ConfigPositionedElement>(); configPositionedElement.PositionConfig = EquipmentAndQuickSlots.QuickSlotsPosition; configPositionedElement.AnchorConfig = EquipmentAndQuickSlots.QuickSlotsAnchor; configPositionedElement.EnsureCorrectPosition(); } } } public static class HotkeyBarController { [HarmonyPatch(typeof(Hud), "Update")] public static class Hud_Update_Patch { private static HotkeyBar _quickSlotsHotkeyBar; private static HotkeyBar HotkeyBar { get { if ((Object)(object)_quickSlotsHotkeyBar == (Object)null) { _quickSlotsHotkeyBar = GameObject.Find("QuickSlotsHotkeyBar").GetComponent<HotkeyBar>(); } return _quickSlotsHotkeyBar; } } public static void Postfix(Hud __instance) { Player localPlayer = Player.m_localPlayer; if (HotkeyBars == null) { HotkeyBars = ((Component)((Component)__instance).transform.parent).GetComponentsInChildren<HotkeyBar>().ToList(); } if ((Object)(object)localPlayer != (Object)null) { if (SelectedHotkeyBarIndex >= 0 && SelectedHotkeyBarIndex < HotkeyBars.Count) { HotkeyBar hotkeyBar = HotkeyBars[SelectedHotkeyBarIndex]; UpdateHotkeyBarInput(hotkeyBar); } else { UpdateInitialHotkeyBarInput(); } } foreach (HotkeyBar hotkeyBar2 in HotkeyBars) { if (hotkeyBar2.m_selected > hotkeyBar2.m_elements.Count - 1) { hotkeyBar2.m_selected = Mathf.Max(0, hotkeyBar2.m_elements.Count - 1); } hotkeyBar2.UpdateIcons(localPlayer); } UpdateIconBinding(); } public static void UpdateIconBinding() { if (!((Object)(object)HotkeyBar == (Object)null)) { for (int i = 0; i < ((Component)HotkeyBar).transform.childCount; i++) { Transform child = ((Component)HotkeyBar).transform.GetChild(i); TMP_Text component = ((Component)child.Find("binding")).GetComponent<TMP_Text>(); ((Behaviour)component).enabled = true; component.overflowMode = (TextOverflowModes)0; component.text = EquipmentAndQuickSlots.GetBindingLabel(i); } } } private static void UpdateInitialHotkeyBarInput() { if (ZInput.GetButtonDown("JoyDPadLeft") || ZInput.GetButtonDown("JoyDPadRight")) { SelectHotkeyBar(0, fromRight: false); } } public static void UpdateHotkeyBarInput(HotkeyBar hotkeyBar) { Player localPlayer = Player.m_localPlayer; if (hotkeyBar.m_selected >= 0 && (Object)(object)localPlayer != (Object)null && !InventoryGui.IsVisible() && !Menu.IsVisible() && !GameCamera.InFreeFly()) { if (ZInput.GetButtonDown("JoyDPadLeft")) { if (hotkeyBar.m_selected == 0) { GotoHotkeyBar(SelectedHotkeyBarIndex - 1); } else { hotkeyBar.m_selected = Mathf.Max(0, hotkeyBar.m_selected - 1); } } else if (ZInput.GetButtonDown("JoyDPadRight")) { if (hotkeyBar.m_selected == hotkeyBar.m_elements.Count - 1) { GotoHotkeyBar(SelectedHotkeyBarIndex + 1); } else { hotkeyBar.m_selected = Mathf.Min(hotkeyBar.m_elements.Count - 1, hotkeyBar.m_selected + 1); } } if (ZInput.GetButtonDown("JoyDPadUp")) { if (((Object)hotkeyBar).name == "QuickSlotsHotkeyBar") { Inventory quickSlotInventory = localPlayer.GetQuickSlotInventory(); ItemData itemAt = quickSlotInventory.GetItemAt(hotkeyBar.m_selected, 0); ((Humanoid)localPlayer).UseItem((Inventory)null, itemAt, false); } else { localPlayer.UseHotbarItem(hotkeyBar.m_selected + 1); } } } if (hotkeyBar.m_selected > hotkeyBar.m_elements.Count - 1) { hotkeyBar.m_selected = Mathf.Max(0, hotkeyBar.m_elements.Count - 1); } } public static void GotoHotkeyBar(int newIndex) { if (newIndex >= 0 && newIndex < HotkeyBars.Count) { bool fromRight = newIndex < SelectedHotkeyBarIndex; SelectHotkeyBar(newIndex, fromRight); } } public static void SelectHotkeyBar(int index, bool fromRight) { if (index < 0 || index >= HotkeyBars.Count) { return; } SelectedHotkeyBarIndex = index; for (int i = 0; i < HotkeyBars.Count; i++) { HotkeyBar val = HotkeyBars[i]; if (i == index) { val.m_selected = (fromRight ? (val.m_elements.Count - 1) : 0); } else { val.m_selected = -1; } } } public static void DeselectHotkeyBar() { SelectedHotkeyBarIndex = -1; foreach (HotkeyBar hotkeyBar in HotkeyBars) { hotkeyBar.m_selected = -1; } } } [HarmonyPatch(typeof(Hud), "OnDestroy")] public static class Hud_OnDestroy_Patch { public static void Postfix(Hud __instance) { HotkeyBars = null; SelectedHotkeyBarIndex = -1; } } public static List<HotkeyBar> HotkeyBars; public static int SelectedHotkeyBarIndex = -1; } [HarmonyPatch(typeof(HotkeyBar), "Update")] public static class HotkeyBar_Update_Patch { public static bool Prefix(HotkeyBar __instance) { return false; } } public static class EquipmentSlotHelper { public class SwapData { public Inventory InventoryA; public ItemData Item; public Inventory InventoryB; public Vector2i SlotB; public SwapData(Inventory inventoryA, ItemData item, Inventory inventoryB, Vector2i slotB) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) InventoryA = inventoryA; Item = item; InventoryB = inventoryB; SlotB = slotB; } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] public static class Humanoid_EquipItem_Patch { public static bool Prefix() { DoingEquip = true; return true; } public static void Postfix(Humanoid __instance, bool __result, ItemData item) { if (EquipmentAndQuickSlots.EquipmentSlotsEnabled.Value && AllowMove && (Object)(object)__instance != (Object)null && ((Character)__instance).IsPlayer() && ((Character)__instance).m_nview.IsValid()) { RefreshEquipmentInSlots((Player)(object)((__instance is Player) ? __instance : null)); } DoingEquip = false; } } [HarmonyPatch(typeof(Humanoid), "UnequipItem")] public static class Humanoid_UnequipItem_Patch { public static void Postfix(Humanoid __instance, ItemData item) { if (EquipmentAndQuickSlots.EquipmentSlotsEnabled.Value && AllowMove && !DoingEquip && (Object)(object)__instance != (Object)null && ((Character)__instance).IsPlayer() && ((Character)__instance).m_nview.IsValid() && item != null) { RefreshEquipmentInSlots((Player)(object)((__instance is Player) ? __instance : null)); } } } public static bool DoingEquip = false; public static bool AllowMove = true; public static void Swap(Inventory inventoryA, ItemData item, Inventory inventoryB, Vector2i slotB) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Vector2i gridPos = item.m_gridPos; if (inventoryA == inventoryB && item.m_gridPos == slotB) { EquipmentAndQuickSlots.Log("Item already in correct slot"); return; } ItemData itemAt = inventoryB.GetItemAt(slotB.x, slotB.y); if (itemAt != null) { EquipmentAndQuickSlots.Log("Item exists in other slot (" + itemAt.m_shared.m_name + ")"); inventoryB.m_inventory.Remove(itemAt); } inventoryA.m_inventory.Remove(item); inventoryB.m_inventory.Add(item); item.m_gridPos = slotB; if (itemAt != null) { itemAt.m_gridPos = gridPos; inventoryA.m_inventory.Add(itemAt); } inventoryA.Changed(); inventoryB.Changed(); } public static void RefreshEquipmentInSlots(Player player) { //IL_014e: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: 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_032e: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_036a: 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_0217: 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_022f: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) List<Inventory> allInventories = player.GetAllInventories(); Inventory equipmentSlotInventory = player.GetEquipmentSlotInventory(); List<SwapData> list = new List<SwapData>(); List<SwapData> list2 = new List<SwapData>(); foreach (Inventory item in allInventories) { if (item == equipmentSlotInventory) { continue; } foreach (ItemData item2 in item.m_inventory) { if (item2.m_equipped && EquipmentAndQuickSlots.IsSlotEquippable(item2)) { Vector2i equipmentSlotForType = EquipmentAndQuickSlots.GetEquipmentSlotForType(item2.m_shared.m_itemType); if (equipmentSlotForType.x >= 0 && equipmentSlotForType.y >= 0) { list.Add(new SwapData(item, item2, equipmentSlotInventory, equipmentSlotForType)); EquipmentAndQuickSlots.LogWarning("move (" + item2.m_shared.m_name + ") to equip slot"); } } } } foreach (SwapData item3 in list) { Swap(item3.InventoryA, item3.Item, item3.InventoryB, item3.SlotB); } list.Clear(); foreach (ItemData item4 in equipmentSlotInventory.m_inventory) { if (!item4.m_equipped || !EquipmentAndQuickSlots.IsSlotEquippable(item4)) { List<Inventory> allInventories2 = player.GetAllInventories(); bool flag = false; foreach (Inventory item5 in allInventories2) { if (item5.CountAsEmptySlots(player)) { ExtendedInventory extendedInventory = item5.Extended(); if (extendedInventory != null) { extendedInventory.CallBase = true; } Vector2i val = item5.FindEmptySlot(false); if (extendedInventory != null) { extendedInventory.CallBase = false; } if (val.x >= 0 && val.y >= 0) { flag = true; list.Add(new SwapData(equipmentSlotInventory, item4, item5, val)); break; } } } EquipmentAndQuickSlots.LogWarning("move (" + item4.m_shared.m_name + ") to main inventory"); if (!flag) { if (!CanEquip(item4, player)) { ((Character)player).Message((MessageType)2, "Item force unequipped, inventory full, dropped item", 0, (Sprite)null); list2.Add(new SwapData(equipmentSlotInventory, item4, null, default(Vector2i))); } else { ((Humanoid)player).EquipItem(item4, false); ((Character)player).Message((MessageType)2, "Could not unequip, inventory full", 0, (Sprite)null); } } } else { Vector2i equipmentSlotForType2 = EquipmentAndQuickSlots.GetEquipmentSlotForType(item4.m_shared.m_itemType); if (equipmentSlotForType2.x >= 0 && equipmentSlotForType2.y >= 0 && item4.m_gridPos != equipmentSlotForType2) { item4.m_gridPos = equipmentSlotForType2; EquipmentAndQuickSlots.LogWarning($"move ({item4.m_shared.m_name}) to correct slot ({equipmentSlotForType2})"); } } } foreach (SwapData item6 in list2) { ItemDrop.DropItem(item6.Item, item6.Item.m_stack, ((Component)player).transform.position, Quaternion.identity); item6.InventoryA.RemoveItem(item6.Item); } list2.Clear(); foreach (SwapData item7 in list) { Swap(item7.InventoryA, item7.Item, item7.InventoryB, item7.SlotB); } list.Clear(); } public static bool CanEquip(ItemData item, Player player) { if (((Humanoid)player).IsItemEquiped(item) || ((Character)player).InAttack() || ((Character)player).InDodge() || (((Character)player).IsPlayer() && !((Character)player).IsDead() && ((Character)player).IsSwimming() && !((Character)player).IsOnGround()) || (item.m_shared.m_useDurability && item.m_durability <= 0f)) { return false; } return true; } } [HarmonyPatch(typeof(GuiBar), "Awake")] public static class GuiBar_Awake_Patch { private static bool Prefix(GuiBar __instance) { //IL_0019: 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 (((Object)__instance).name == "durability" && __instance.m_bar.sizeDelta.x != 54f) { __instance.m_bar.sizeDelta = new Vector2(54f, 0f); } return true; } } [HarmonyPatch(typeof(InventoryGrid), "GetElement", new Type[] { typeof(int), typeof(int), typeof(int) })] public static class InventoryGrid_GetElement_Patch { private static bool Prefix(InventoryGrid __instance, ref Element __result, int x, int y, int width) { int num = y * width + x; if (num < 0 || num >= __instance.m_elements.Count) { EquipmentAndQuickSlots.LogError($"Tried to get element for item ({x}, {y}) in inventory ({__instance.m_inventory.m_name}) but that element is outside the bounds!"); __result = null; } else { __result = __instance.m_elements[num]; } return false; } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGui", new Type[] { typeof(Player), typeof(ItemData) })] public static class InventoryGrid_UpdateGui_Patch { private static void Postfix(InventoryGrid __instance) { //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_0104: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) if (((Object)__instance).name == "QuickSlotGrid") { for (int i = 0; i < 3; i++) { Element val = __instance.m_elements[i]; TMP_Text component = ((Component)val.m_go.transform.Find("binding")).GetComponent<TMP_Text>(); ((Behaviour)component).enabled = true; component.overflowMode = (TextOverflowModes)0; component.text = EquipmentAndQuickSlots.GetBindingLabel(i); } } else { if (!(((Object)__instance).name == "EquipmentSlotGrid")) { return; } float num = __instance.m_elementSpace + 10f; float num2 = __instance.m_elementSpace + 10f; string[] array = new string[5] { "Head", "Chest", "Legs", "Shoulders", "Utility" }; Vector2[] array2 = (Vector2[])(object)new Vector2[5] { default(Vector2), new Vector2(0f, 0f - num2), new Vector2(0f, -2f * num2), new Vector2(num, -0.5f * num2), new Vector2(num, -1.5f * num2) }; Vector2[] array3 = (Vector2[])(object)new Vector2[5] { default(Vector2), new Vector2(-0.45f * num, -0.9f * num2), new Vector2(0f, -1.8f * num2), new Vector2(0.45f * num, -0.9f * num2), new Vector2(1.3f * num, 0f) }; Vector2 val3 = default(Vector2); for (int j = 0; j < EquipmentAndQuickSlots.EquipSlotCount; j++) { Element val2 = __instance.m_elements[j]; TMP_Text component2 = ((Component)val2.m_go.transform.Find("binding")).GetComponent<TMP_Text>(); ((Behaviour)component2).enabled = !EquipmentAndQuickSlots.HasAuga; if (!EquipmentAndQuickSlots.HasAuga) { component2.overflowMode = (TextOverflowModes)0; component2.textWrappingMode = (TextWrappingModes)0; component2.text = array[j]; component2.rectTransform.anchoredPosition = new Vector2(32f, 5f); } ((Vector2)(ref val3))..ctor(-20f, 79f); if (EquipmentAndQuickSlots.HasAuga) { val2.m_go.RectTransform().anchoredPosition = val3 + array3[j]; } else { val2.m_go.RectTransform().anchoredPosition = val3 + array2[j]; } } } } } public static class InventoryGui_Patch { [HarmonyPatch(typeof(InventoryGui), "Awake")] public static class InventoryGui_Awake_Patch { public static void Postfix(InventoryGui __instance) { if (EquipmentAndQuickSlots.QuickSlotsEnabled.Value) { BuildQuickSlotGrid(__instance); } if (EquipmentAndQuickSlots.EquipmentSlotsEnabled.Value) { BuildEquipmentSlotGrid(__instance); } } private static void BuildQuickSlotGrid(InventoryGui inventoryGui) { //IL_0023: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Vector2 position = (EquipmentAndQuickSlots.HasAuga ? new Vector2(3f, -108f) : new Vector2(3f, -160f)); BuildInventoryGrid(ref QuickSlotGrid, "QuickSlotGrid", position, new Vector2(232f, 90f), inventoryGui); } private static void BuildEquipmentSlotGrid(InventoryGui inventoryGui) { //IL_0023: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Vector2 position = (EquipmentAndQuickSlots.HasAuga ? new Vector2(3f, 40f) : new Vector2(3f, 20f)); BuildInventoryGrid(ref EquipmentSlotGrid, "EquipmentSlotGrid", position, new Vector2(210f, 270f), inventoryGui); } private static void BuildInventoryGrid(ref InventoryGrid grid, string name, Vector2 position, Vector2 size, InventoryGui inventoryGui) { //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Expected O, but got Unknown //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Expected O, but got Unknown //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Expected O, but got Unknown //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Expected O, but got Unknown //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)grid != (Object)null) { Object.Destroy((Object)(object)grid); grid = null; } if ((Object)(object)EAQSPanel == (Object)null) { if (EquipmentAndQuickSlots.HasAuga) { EAQSPanel = Auga.API.Panel_Create((Transform)(object)inventoryGui.m_player, new Vector2(255f, 352f), "EAQS", withCornerDecoration: false); RectTransform val = (RectTransform)EAQSPanel.transform; val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(0f, 1f); val.anchoredPosition = new Vector2(752f, -166f); val.SetSizeWithCurrentAnchors((Axis)0, 255f); val.SetSizeWithCurrentAnchors((Axis)1, 352f); GameObject val2 = Object.Instantiate<GameObject>(EquipmentAndQuickSlots.Paperdolls, EAQSPanel.transform, false); ((Object)val2).name = "Paperdolls"; GameObject val3 = Auga.API.Divider_CreateSmall(EAQSPanel.transform, "Divider", 215f); val = (RectTransform)val3.transform; val.anchoredPosition = new Vector2(0f, -157f); } else { EAQSPanel = new GameObject("EAQS", new Type[1] { typeof(RectTransform) }); EAQSPanel.transform.SetParent((Transform)(object)inventoryGui.m_player); RectTransform val4 = (RectTransform)EAQSPanel.transform; val4.anchorMin = new Vector2(0f, 1f); val4.anchorMax = new Vector2(0f, 1f); val4.anchoredPosition = new Vector2(752f, -166f); val4.SetSizeWithCurrentAnchors((Axis)0, 255f); val4.SetSizeWithCurrentAnchors((Axis)1, 352f); } } GameObject val5 = new GameObject(name, new Type[1] { typeof(RectTransform) }); val5.transform.SetParent(EAQSPanel.transform, false); grid = val5.AddComponent<InventoryGrid>(); GameObject val6 = new GameObject("Root", new Type[1] { typeof(RectTransform) }); val6.transform.SetParent(val5.transform, false); RectTransform val7 = (RectTransform)val5.transform; val7.anchoredPosition = position; grid.m_elementPrefab = inventoryGui.m_playerGrid.m_elementPrefab; ref RectTransform gridRoot = ref grid.m_gridRoot; Transform transform = val6.transform; gridRoot = (RectTransform)(object)((transform is RectTransform) ? transform : null); grid.m_elementSpace = inventoryGui.m_playerGrid.m_elementSpace; grid.ResetView(); if (name == "EquipmentSlotGrid") { InventoryGrid obj = grid; obj.m_onSelected = (Action<InventoryGrid, ItemData, Vector2i, Modifier>)Delegate.Combine(obj.m_onSelected, OnEquipmentSelected(inventoryGui)); InventoryGrid obj2 = grid; obj2.m_onRightClick = (Action<InventoryGrid, ItemData, Vector2i>)Delegate.Combine(obj2.m_onRightClick, OnEquipmentRightClicked(inventoryGui)); } else { InventoryGrid obj3 = grid; obj3.m_onSelected = (Action<InventoryGrid, ItemData, Vector2i, Modifier>)Delegate.Combine(obj3.m_onSelected, OnSelected(inventoryGui)); InventoryGrid obj4 = grid; obj4.m_onRightClick = (Action<InventoryGrid, ItemData, Vector2i>)Delegate.Combine(obj4.m_onRightClick, OnRightClicked(inventoryGui)); } grid.m_uiGroup = ((Component)grid).gameObject.AddComponent<UIGroupHandler>(); grid.m_uiGroup.m_groupPriority = 1; grid.m_uiGroup.m_active = true; if (!EquipmentAndQuickSlots.HasAuga) { GameObject val8 = new GameObject("SelectedFrame", new Type[1] { typeof(RectTransform) }); val8.transform.SetParent(val5.transform, false); ((Graphic)val8.AddComponent<Image>()).color = Color.yellow; RectTransform val9 = (RectTransform)val8.transform; ((Transform)val9).SetAsFirstSibling(); val9.anchoredPosition = new Vector2(0f, 0f); val9.SetSizeWithCurrentAnchors((Axis)0, size.x + 2f); val9.SetSizeWithCurrentAnchors((Axis)1, size.y + 2f); ((Transform)val9).localScale = new Vector3(1f, 1f, 1f); grid.m_uiGroup.m_enableWhenActiveAndGamepad = val8; GameObject gameObject = ((Component)((Transform)inventoryGui.m_player).Find("Bkg")).gameObject; GameObject val10 = Object.Instantiate<GameObject>(gameObject, val5.transform); ((Object)val10).name = name + "Bkg"; RectTransform val11 = (RectTransform)val10.transform; ((Transform)val11).SetSiblingIndex(1); val11.anchoredPosition = new Vector2(0f, 0f); val11.SetSizeWithCurrentAnchors((Axis)0, size.x); val11.SetSizeWithCurrentAnchors((Axis)1, size.y); ((Transform)val11).localScale = new Vector3(1f, 1f, 1f); } List<UIGroupHandler> list = inventoryGui.m_uiGroups.ToList(); list.Insert(2, grid.m_uiGroup); inventoryGui.m_uiGroups = list.ToArray(); } private static Action<InventoryGrid, ItemData, Vector2i, Modifier> OnSelected(InventoryGui inventoryGui) { return delegate(InventoryGrid inventoryGrid, ItemData item, Vector2i pos, Modifier mod) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_004b: Unknown result type (might be due to invalid IL or missing references) EquipmentAndQuickSlots.Log($"OnSelected: inventoryGrid={inventoryGrid}, item={item?.m_shared.m_name}, pos={pos}, mod={mod}"); inventoryGui.OnSelectedItem(inventoryGrid, item, pos, mod); }; } private static Action<InventoryGrid, ItemData, Vector2i> OnRightClicked(InventoryGui inventoryGui) { return delegate(InventoryGrid inventoryGrid, ItemData item, Vector2i pos) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) EquipmentAndQuickSlots.Log($"OnRightClicked: inventoryGrid={inventoryGrid}, item={item?.m_shared.m_name}, pos={pos}"); if (item != null && !((Object)(object)Player.m_localPlayer == (Object)null)) { ((Humanoid)Player.m_localPlayer).UseItem((Inventory)(object)((Humanoid)Player.m_localPlayer).m_inventory.Extended(), item, true); } }; } private static Action<InventoryGrid, ItemData, Vector2i, Modifier> OnEquipmentSelected(InventoryGui inventoryGui) { return delegate(InventoryGrid inventoryGrid, ItemData item, Vector2i pos, Modifier mod) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0086: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; EquipmentAndQuickSlots.Log($"OnEquipmentSelected: inventoryGrid={inventoryGrid}, item={item?.m_shared.m_name}, pos={pos}, mod={mod}"); if ((Object)(object)localPlayer != (Object)null && inventoryGui.m_dragItem != null && EquipmentAndQuickSlots.IsSlotEquippable(inventoryGui.m_dragItem) && pos == EquipmentAndQuickSlots.GetEquipmentSlotForType(inventoryGui.m_dragItem.m_shared.m_itemType)) { localPlayer.QueueEquipAction(inventoryGui.m_dragItem); inventoryGui.SetupDragItem((ItemData)null, (Inventory)null, 0); } }; } private static Action<InventoryGrid, ItemData, Vector2i> OnEquipmentRightClicked(InventoryGui inventoryGui) { return delegate(InventoryGrid inventoryGrid, ItemData item, Vector2i pos) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; EquipmentAndQuickSlots.Log($"OnEquipmentRightClicked: inventoryGrid={inventoryGrid}, item={item?.m_shared.m_name}, pos={pos}"); if (item != null && (Object)(object)localPlayer != (Object)null && item.m_equipped && ((Humanoid)localPlayer).IsItemEquiped(item) && inventoryGui.m_dragItem == null) { Player.m_localPlayer.QueueUnequipAction(item); } }; } } [HarmonyPatch(typeof(InventoryGui), "UpdateInventory")] public static class InventoryGui_UpdateInventory_Patch { public static bool Prefix(InventoryGui __instance, Player player) { ((Humanoid)player).m_inventory.Extended().CallBase = true; __instance.m_playerGrid.UpdateInventory(((Humanoid)player).m_inventory, player, __instance.m_dragItem); ((Humanoid)player).m_inventory.Extended().CallBase = false; if ((Object)(object)QuickSlotGrid != (Object)null) { Inventory quickSlotInventory = player.GetQuickSlotInventory(); if (quickSlotInventory != null) { QuickSlotGrid.UpdateInventory(quickSlotInventory, player, __instance.m_dragItem); } } if ((Object)(object)EquipmentSlotGrid != (Object)null) { Inventory equipmentSlotInventory = player.GetEquipmentSlotInventory(); if (equipmentSlotInventory != null) { EquipmentSlotGrid.UpdateInventory(equipmentSlotInventory, player, __instance.m_dragItem); } } if (EquipmentAndQuickSlots.HasAuga && (Object)(object)EAQSPanel != (Object)null) { Transform val = EAQSPanel.transform.Find("Paperdolls"); if (((Humanoid)player).m_visEquipment.GetModelIndex() == 1) { ((Component)((Component)val).transform.Find("Male")).gameObject.SetActive(false); } else { ((Component)((Component)val).transform.Find("Female")).gameObject.SetActive(false); } } return false; } } [HarmonyPatch(typeof(InventoryGui), "UpdateGamepad")] public static class InventoryGui_UpdateGamepad_Patch { [UsedImplicitly] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator ilGenerator) { FieldInfo activeGroupField = AccessTools.DeclaredField(typeof(InventoryGui), "m_activeGroup"); List<CodeInstruction> instrs = instructions.ToList(); int counter = 0; int skipLines2 = 0; int i = 0; while (i < instrs.Count) { if (i > 5 && instrs[i].opcode == OpCodes.Ldfld && instrs[i].operand.Equals(activeGroupField) && instrs[i + 1].opcode == OpCodes.Ldc_I4_3 && instrs[i + 2].opcode == OpCodes.Bne_Un) { yield return EquipmentAndQuickSlots.LogMessage(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(InventoryGui_UpdateGamepad_Patch), "GetMaxUiGroups", (Type[])null, (Type[])null)), counter); counter++; skipLines2++; yield return EquipmentAndQuickSlots.LogMessage(new CodeInstruction(OpCodes.Brtrue, instrs[i + 2].operand), counter); skipLines2++; i += skipLines2; } else { yield return EquipmentAndQuickSlots.LogMessage(instrs[i], counter); counter++; } int num = i + 1; i = num; } } public static bool GetMaxUiGroups(InventoryGui instance) { return instance.m_activeGroup != instance.m_uiGroups.Length - 1; } } public static InventoryGrid QuickSlotGrid; public static InventoryGrid EquipmentSlotGrid; public static GameObject EAQSPanel; } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] public static class InventoryGui_DoCrafting_Patch { public static bool Prefix(InventoryGui __instance, Player player, bool __runOriginal) { //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) if (!__runOriginal) { return false; } if ((Object)(object)__instance.m_craftRecipe == (Object)null || __instance.m_craftRecipe.m_requireOnlyOneIngredient) { return true; } ItemData craftUpgradeItem = __instance.m_craftUpgradeItem; int num = ((craftUpgradeItem == null) ? 1 : (craftUpgradeItem.m_quality + 1)); if (num > __instance.m_craftRecipe.m_item.m_itemData.m_shared.m_maxQuality || (!player.HaveRequirements(__instance.m_craftRecipe, false, num) && !player.NoCostCheat()) || (__instance.m_craftUpgradeItem != null && !((Humanoid)player).GetInventory().ContainsItem(__instance.m_craftUpgradeItem)) || (__instance.m_craftUpgradeItem == null && !((Humanoid)player).GetInventory().HaveEmptySlot())) { return false; } if (__instance.m_craftRecipe.m_item.m_itemData.m_shared.m_dlc.Length > 0 && !DLCMan.instance.IsDLCInstalled(__instance.m_craftRecipe.m_item.m_itemData.m_shared.m_dlc)) { return false; } ItemData craftUpgradeItem2 = __instance.m_craftUpgradeItem; if (craftUpgradeItem2 != null) { craftUpgradeItem2.m_quality = num; craftUpgradeItem2.m_durability = craftUpgradeItem2.GetMaxDurability(); if (!player.NoCostCheat()) { player.ConsumeResources(__instance.m_craftRecipe.m_resources, num, -1); } __instance.UpdateCraftingPanel(false); CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation(); if ((Object)(object)currentCraftingStation != (Object)null) { currentCraftingStation.m_craftItemDoneEffects.Create(((Component)player).transform.position, Quaternion.identity, (Transform)null, 1f, -1); } else { __instance.m_craftItemDoneEffects.Create(((Component)player).transform.position, Quaternion.identity, (Transform)null, 1f, -1); } Dictionary<PlayerStatType, float> stats = Game.instance.GetPlayerProfile().m_playerStats.m_stats; float value = stats[(PlayerStatType)13] + 1f; stats[(PlayerStatType)13] = value; Gogan.LogEvent("Game", "Crafted", __instance.m_craftRecipe.m_item.m_itemData.m_shared.m_name, (long)num); return false; } return true; } } [HarmonyPatch] public static class InventoryGui_UpdateContainer_Patch { public static int InUpdateContainerCall; [HarmonyPatch(typeof(InventoryGui), "UpdateContainer")] [HarmonyPrefix] public static void InventoryGui_UpdateContainer_Prefix() { InUpdateContainerCall++; } [HarmonyPatch(typeof(InventoryGui), "UpdateContainer")] [HarmonyPostfix] public static void InventoryGui_UpdateContainer_Postfix() { InUpdateContainerCall--; } [HarmonyPatch(typeof(InventoryGui), "SetupDragItem")] [HarmonyPrefix] public static bool InventoryGui_SetupDragItem_Prefix(InventoryGui __instance, ItemData item) { if (InUpdateContainerCall > 0 && item == null && __instance.m_dragInventory != null && IsOneOfPlayersInventory(__instance.m_dragInventory)) { return false; } return true; } public static bool IsOneOfPlayersInventory(Inventory inventory) { foreach (Inventory allInventory in Player.m_localPlayer.GetAllInventories()) { if (inventory == allInventory) { return true; } } return false; } } [HarmonyPatch(typeof(Inventory), "CanAddItem", new Type[] { typeof(GameObject), typeof(int) })] public static class Inventory_CanAddItem_Patch { public static bool Prefix(Inventory __instance, ref bool __result, GameObject prefab, int stack) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideCanAddItem(prefab, stack); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "CanAddItem", new Type[] { typeof(ItemData), typeof(int) })] public static class Inventory_CanAddItem2_Patch { public static bool Prefix(Inventory __instance, ref bool __result, ItemData item, int stack) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideCanAddItem(item, stack); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })] public static class Inventory_AddItem2_Patch { public static bool CallingExtended; public static bool Prefix(Inventory __instance, ref bool __result, ItemData item, out bool __state) { __state = false; if (__instance.DoExtendedCall()) { CallingExtended = true; __state = true; __result = __instance.Extended().OverrideAddItem(item); return false; } return true; } public static void Postfix(bool __state) { if (__state) { CallingExtended = false; } } } [HarmonyPatch(typeof(Inventory), "FindEmptySlot")] public static class Inventory_FindEmptySlot_Patch { public static bool Prefix(Inventory __instance, bool topFirst, ref Vector2i __result) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideFindEmptySlot(topFirst); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "FindFreeStackItem")] public static class Inventory_FindFreeStackItem_Patch { private static bool DoExtended = true; public static bool Prefix(Inventory __instance, string name, int quality, float worldLevel, ref ItemData __result, out bool __state) { __state = false; if (DoExtended && Inventory_AddItem2_Patch.CallingExtended && __instance.IsExtended()) { __state = true; DoExtended = false; __result = __instance.Extended().OverrideFindFreeStackItem(name, quality, worldLevel); return false; } return true; } public static void Postfix(bool __state) { if (__state) { DoExtended = true; } } } [HarmonyPatch(typeof(Inventory), "ContainsItem")] public static class Inventory_ContainsItem_Patch { public static bool Prefix(Inventory __instance, ref bool __result, ItemData item) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideContainsItem(item); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "RemoveOneItem")] public static class Inventory_RemoveOneItem_Patch { public static bool Prefix(Inventory __instance, ref bool __result, ItemData item) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideRemoveOneItem(item); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[] { typeof(ItemData) })] public static class Inventory_RemoveItem2_Patch { public static bool Prefix(Inventory __instance, ref bool __result, ItemData item) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideRemoveItem(item); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[] { typeof(ItemData), typeof(int) })] public static class Inventory_RemoveItem3_Patch { public static bool Prefix(Inventory __instance, ref bool __result, ItemData item, int amount) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideRemoveItem(item, amount); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[] { typeof(string), typeof(int), typeof(int), typeof(bool) })] public static class Inventory_RemoveItem4_Patch { public static bool Prefix(Inventory __instance, string name, int amount, int itemQuality, bool worldLevelBased) { if (__instance.DoExtendedCall()) { __instance.Extended().OverrideRemoveItem(name, amount, itemQuality, worldLevelBased); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "HaveItem")] public static class Inventory_HaveItem_Patch { public static bool Prefix(Inventory __instance, ref bool __result, string name, bool matchWorldLevel = true) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideHaveItem(name, matchWorldLevel); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetAllPieceTables")] public static class Inventory_GetAllPieceTables_Patch { public static bool Prefix(Inventory __instance, List<PieceTable> tables) { if (__instance.DoExtendedCall()) { __instance.Extended().OverrideGetAllPieceTables(tables); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "CountItems")] public static class Inventory_CountItems_Patch { public static bool Prefix(Inventory __instance, ref int __result, string name, bool matchWorldLevel = true) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideCountItems(name, matchWorldLevel); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetItem", new Type[] { typeof(string), typeof(int), typeof(bool) })] public static class Inventory_GetItem2_Patch { public static bool Prefix(Inventory __instance, ref ItemData __result, string name, int quality, bool isPrefabName) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideGetItem(name, quality, isPrefabName); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetAmmoItem", new Type[] { typeof(string), typeof(string) })] public static class Inventory_GetAmmoItem_Patch { public static bool Prefix(Inventory __instance, ref ItemData __result, string ammoName, string matchPrefabName) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideGetAmmoItem(ammoName, matchPrefabName); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "FindFreeStackSpace")] public static class Inventory_FindFreeStackSpace_Patch { public static bool Prefix(Inventory __instance, ref int __result, string name, float worldLevel) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideFindFreeStackSpace(name, worldLevel); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "NrOfItems")] public static class Inventory_NrOfItems_Patch { public static bool Prefix(Inventory __instance, ref int __result) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideNrOfItems(); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "SlotsUsedPercentage")] public static class Inventory_SlotsUsedPercentage_Patch { public static bool Prefix(Inventory __instance, ref float __result) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideSlotsUsedPercentage(); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetEmptySlots")] public static class Inventory_GetEmptySlots_Patch { public static bool Prefix(Inventory __instance, ref int __result) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideGetEmptySlots(); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "HaveEmptySlot")] public static class Inventory_HaveEmptySlot_Patch { public static bool Prefix(Inventory __instance, ref bool __result) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideHaveEmptySlot(); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetEquippedItems")] public static class Inventory_GetEquipedtems_Patch { public static bool Prefix(Inventory __instance, ref List<ItemData> __result) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideGetEquipedItems(); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetWornItems")] public static class Inventory_GetWornItems_Patch { public static bool Prefix(Inventory __instance, List<ItemData> worn) { if (__instance.DoExtendedCall()) { __instance.Extended().OverrideGetWornItems(worn); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetValuableItems")] public static class Inventory_GetValuableItems_Patch { public static bool Prefix(Inventory __instance, List<ItemData> items) { if (__instance.DoExtendedCall()) { __instance.Extended().OverrideGetValuableItems(items); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetAllItems", new Type[] { })] public static class Inventory_GetAllItems_Patch { public static bool Prefix(Inventory __instance, ref List<ItemData> __result) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideGetAllItems(); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetAllItems", new Type[] { typeof(string), typeof(List<ItemData>) })] public static class Inventory_GetAllItems2_Patch { public static bool Prefix(Inventory __instance, string name, List<ItemData> items) { if (__instance.DoExtendedCall()) { __instance.Extended().OverrideGetAllItems(name, items); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetAllItems", new Type[] { typeof(ItemType), typeof(List<ItemData>) })] public static class Inventory_GetAllItems3_Patch { public static bool Prefix(Inventory __instance, ItemType type, List<ItemData> items) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (__instance.DoExtendedCall()) { __instance.Extended().OverrideGetAllItems(type, items); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "UpdateTotalWeight")] public static class Inventory_UpdateTotalWeight_Patch { public static bool Prefix(Inventory __instance) { if (__instance.DoExtendedCall()) { __instance.Extended().OverrideUpdateTotalWeight(); return false; } return true; } } [HarmonyPatch(typeof(Inventory), "IsTeleportable")] public static class Inventory_IsTeleportable_Patch { public static bool Prefix(Inventory __instance, ref bool __result) { if (__instance.DoExtendedCall()) { __result = __instance.Extended().OverrideIsTeleportable(); return false; } return true; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("randyknapp.mods.equipmentandquickslots", "Equipment and Quick Slots", "1.0.0")] public class EquipmentAndQuickSlots : BaseUnityPlugin { public const string PluginId = "randyknapp.mods.equipmentandquickslots"; public const int QuickSlotCount = 3; public static readonly ConfigEntry<KeyboardShortcut>[] KeyCodes = new ConfigEntry<KeyboardShortcut>[3]; public static readonly ConfigEntry<string>[] HotkeyLabels = new ConfigEntry<string>[3]; public static readonly List<ItemType> EquipSlotTypes = new List<ItemType> { (ItemType)6, (ItemType)7, (ItemType)11, (ItemType)17, (ItemType)18 }; public static ConfigEntry<bool> EquipmentSlotsEnabled; public static ConfigEntry<bool> QuickSlotsEnabled; public static ConfigEntry<bool> ViewDebugSaveData; private static ConfigEntry<bool> _loggingEnabled; public static ConfigEntry<TextAnchor> QuickSlotsAnchor; public static ConfigEntry<Vector2> QuickSlotsPosition; public static ConfigEntry<bool> DontDropEquipmentOnDeath; public static ConfigEntry<bool> DontDropQuickslotsOnDeath; public static ConfigEntry<bool> InstantlyReequipArmorOnPickup; public static ConfigEntry<bool> InstantlyReequipQuickslotsOnPickup; public static Sprite PaperdollMale; pub