using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using On.RoR2; using On.RoR2.Networking; using On.RoR2.UI; using R2API; using R2InventoryArtifact.Artifact; using R2InventoryArtifact.Hooks; using R2InventoryArtifact.Model; using R2InventoryArtifact.UI; using R2InventoryArtifact.UI.Builders; using R2InventoryArtifact.UI.Components; using R2InventoryArtifact.UI.Layouts; using R2InventoryArtifact.UI.Services; using R2InventoryArtifact.Util; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.ContentManagement; using RoR2.Networking; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("R2InventoryArtifact")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+50e1bc474e223961841d8b95e23b94b16b038033")] [assembly: AssemblyProduct("R2InventoryArtifact")] [assembly: AssemblyTitle("R2InventoryArtifact")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace R2InventoryArtifact { public class DebugManager : MonoBehaviour { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_OnClientConnect <>9__6_0; internal void b__6_0(orig_OnClientConnect s, NetworkManagerSystemSteam u, NetworkConnection t) { } } public static DebugManager Instance; public static Run currentRun; public static CharacterMaster PlayerMaster; public bool SetDecayValue = false; public static CharacterBody PlayerBody => PlayerMaster.GetBody(); private void Awake() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)Instance)) { Object.Destroy((Object)(object)Instance); } Instance = this; object obj = <>c.<>9__6_0; if (obj == null) { hook_OnClientConnect val = delegate { }; <>c.<>9__6_0 = val; obj = (object)val; } NetworkManagerSystemSteam.OnClientConnect += (hook_OnClientConnect)obj; Run.onRunStartGlobal += HandleRunStart; } private void HandleRunStart(Run run) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown currentRun = run; PlayerMaster = PlayerCharacterMasterController.instances[0].master; Inventory.SetItemDecayDurationServer += new hook_SetItemDecayDurationServer(Inventory_SetItemDecayDurationServer); } private void Inventory_SetItemDecayDurationServer(orig_SetItemDecayDurationServer orig, Inventory self, float duration) { if (!SetDecayValue) { self.SetItemDecayDurationServer(2f); SetDecayValue = true; } } private void Update() { //IL_006f: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown((KeyCode)49)) { CharacterBody playerBody = PlayerBody; if (playerBody != null) { playerBody.inventory.GiveItemPermanent(Items.BleedOnHit, 1); } } if (Input.GetKeyDown((KeyCode)50)) { CharacterBody playerBody2 = PlayerBody; if (playerBody2 != null) { playerBody2.inventory.GiveItemPermanent(Items.BleedOnHitVoid, 1); } } if (Input.GetKeyDown((KeyCode)51)) { CharacterBody playerBody3 = PlayerBody; if (playerBody3 != null) { playerBody3.inventory.GiveItemTemp(Items.HealingPotion.itemIndex, 1f); } } if (Input.GetKeyDown((KeyCode)52)) { CharacterBody playerBody4 = PlayerBody; if (playerBody4 != null) { playerBody4.inventory.GiveItemPermanent(Items.RegeneratingScrap, 1); } } if (Input.GetKeyDown((KeyCode)53)) { CharacterBody playerBody5 = PlayerBody; if (playerBody5 != null) { playerBody5.inventory.GiveRandomItems(1, (ItemTier[])(object)new ItemTier[2] { default(ItemTier), (ItemTier)1 }); } } if (Input.GetKeyDown((KeyCode)54)) { CharacterBody playerBody6 = PlayerBody; if (playerBody6 != null) { playerBody6.inventory.GiveRandomEquipment(); } } if (Input.GetKeyDown((KeyCode)55)) { CharacterMaster playerMaster = PlayerMaster; if (playerMaster != null) { playerMaster.GiveExperience(40uL); } } if (Input.GetKeyDown((KeyCode)257)) { CharacterBody playerBody7 = PlayerBody; if (playerBody7 != null) { playerBody7.inventory.RemoveItemPermanent(Items.AlienHead.itemIndex, 1); } } if (Input.GetKeyDown((KeyCode)258)) { CharacterBody playerBody8 = PlayerBody; if (playerBody8 != null) { playerBody8.inventory.RemoveItemTemp(Items.AlienHead.itemIndex, 1f); } } if (Input.GetKeyDown((KeyCode)258)) { CharacterBody playerBody9 = PlayerBody; if (playerBody9 != null) { playerBody9.inventory.RemoveEquipment(Equipment.BFG.equipmentIndex); } } } } internal static class Log { private static ManualLogSource _logSource; internal static void Initialize(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug((object)FormatLogMessage(data.ToString())); } internal static void Error(object data) { _logSource.LogError((object)FormatLogMessage(data.ToString())); } internal static void Fatal(object data) { _logSource.LogFatal((object)FormatLogMessage(data.ToString())); } internal static void Info(object data) { _logSource.LogInfo((object)FormatLogMessage(data.ToString())); } internal static void Message(object data) { _logSource.LogMessage((object)FormatLogMessage(data.ToString())); } internal static void Warning(object data) { _logSource.LogWarning((object)FormatLogMessage(data.ToString())); } private static string FormatLogMessage(string message) { StackTrace stackTrace = new StackTrace(1, fNeedFileInfo: false); StackFrame frame = stackTrace.GetFrame(1); List list = new List(1) { $"{DateTime.Now:yy-MM-dd HH::mm::ss}" }; if (frame != null) { list.Add(frame.GetMethod().DeclaringType.Name); list.Add(frame.GetMethod().Name); } list.Add(message); return string.Join(" | ", list); } } public enum InventoryShowType { ToggleShow, HoldToShow } public static class PluginConfig { private const int INVENTORY_WIDTH_MIN_VALUE = 15; private const int INVENTORY_WIDTH_MAX_VALUE = 25; private const int INVENTORY_HEIGHT_MIN_VALUE = 20; private const int INVENTORY_HEIGHT_MAX_VALUE = 40; public static ConfigEntry ShowInventoryKey { get; private set; } public static ConfigEntry RotateInventoryItemKey { get; private set; } public static ConfigEntry InventoryShowType { get; private set; } public static ConfigEntry InventoryHeight { get; private set; } public static ConfigEntry InventoryWidth { get; private set; } public static ConfigEntry UIScale { get; private set; } public static ConfigEntry UIVerticalPadding { get; private set; } public static ConfigEntry UIHorizontalPadding { get; private set; } public static void Initialize(ConfigFile config, PluginInfo pluginInfo) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0248: 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_0263: Expected O, but got Unknown //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Expected O, but got Unknown //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027e: 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_0299: Expected O, but got Unknown //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Expected O, but got Unknown InventoryShowType = config.Bind("Inventory", "Toggle Inventory", global::R2InventoryArtifact.InventoryShowType.ToggleShow, "Toggle or Show inventory"); InventoryWidth = config.Bind("Inventory", "Inventory Width", 20, new ConfigDescription("Number of cells for the width of the inventory", (AcceptableValueBase)(object)new AcceptableValueRange(15, 25), Array.Empty())); InventoryHeight = config.Bind("Inventory", "Inventory Height", 30, new ConfigDescription("Number of cells for the height of the inventory", (AcceptableValueBase)(object)new AcceptableValueRange(20, 40), Array.Empty())); ShowInventoryKey = config.Bind("Keybinds", "Show Inventory Keybind", new KeyboardShortcut((KeyCode)113, Array.Empty()), "Keybind for Showing and hiding the inventory"); RotateInventoryItemKey = config.Bind("Keybinds", "Rotate Inventory Item", new KeyboardShortcut((KeyCode)324, Array.Empty()), "Keybind for rotating the inventory"); UIScale = config.Bind("UI", "UI Scale", 1f, "Scale multiplier for the level-up selection UI (0.5=half size, 2.0=double)."); UIVerticalPadding = config.Bind("UI", "UI Vertical Padding", 2f, "Vertical UI Padding"); UIHorizontalPadding = config.Bind("UI", "UI Horizontal Padding", 2f, "Horizontal UI Padding"); try { string directoryName = Path.GetDirectoryName(pluginInfo.Location); string path = Path.Combine(directoryName, "Assets", "icon.png"); Sprite modIcon = R2InventoryArtifactUtil.LoadSprite(path); ModSettingsManager.SetModIcon(modIcon); } catch (Exception ex) { Log.Warning("Failed to load mod icon: " + ex.Message); } ModSettingsManager.SetModDescription("Artifact of Inventory - Manage your inventory"); ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)InventoryShowType)); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(ShowInventoryKey)); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(RotateInventoryItemKey)); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(InventoryWidth, new IntSliderConfig { min = 15, max = 25 })); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(InventoryHeight, new IntSliderConfig { min = 20, max = 40 })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(UIScale, new StepSliderConfig { min = 0.5f, max = 2f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(UIVerticalPadding, new StepSliderConfig { min = 1f, max = 10f, increment = 0.5f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(UIHorizontalPadding, new StepSliderConfig { min = 1f, max = 10f, increment = 0.5f })); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("foxfen64.R2InventoryArtifact", "R2InventoryArtifact", "1.1.0")] public class R2InventoryArtifact : BaseUnityPlugin { public const string PluginGUID = "foxfen64.R2InventoryArtifact"; public const string PluginAuthor = "foxfen64"; public const string PluginName = "R2InventoryArtifact"; public const string PluginVersion = "1.1.0"; public static R2InventoryArtifact Instance; public void Awake() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)Instance)) { Object.Destroy((Object)(object)Instance); } Instance = this; Log.Initialize(((BaseUnityPlugin)this).Logger); PluginConfig.Initialize(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Info); InventoryArtifactProvider.Initialize(((BaseUnityPlugin)this).Info); InventoryService.Initialize(((BaseUnityPlugin)this).Info); UIAssetService.Initialize(((BaseUnityPlugin)this).Info); GameObject val = new GameObject("R2InventoryArtifactPlugin"); Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent(); val.AddComponent(); val.AddComponent(); Log.Info("R2InventoryArtifactPlugin Initialized..."); } } } namespace R2InventoryArtifact.Util { public static class R2InventoryArtifactUtil { public static Sprite LoadSprite(string path) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (File.Exists(path)) { byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(256, 256, (TextureFormat)5, false, false); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = (FilterMode)0; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 1u, (SpriteMeshType)1, Vector4.zero, true); } return null; } } [Serializable] public struct IntRect { public int Width; public int Height; public IntRect(int width, int height) { Width = width; Height = height; } public bool Contains(GridPosition pos) { return Contains(pos.Row, pos.Col); } public bool Contains(int row, int col) { return col >= 0 && col < Width && row >= 0 && row < Height; } } [Serializable] public struct GridPosition { public int Row; public int Col; public GridPosition(int Col, int Row) { this.Row = Row; this.Col = Col; } public override string ToString() { return $"(Row:{Row},Col:{Col})"; } public static GridPosition operator +(GridPosition a, GridPosition b) { return new GridPosition(a.Col + b.Col, a.Row + b.Row); } public static GridPosition operator -(GridPosition a, GridPosition b) { return new GridPosition(a.Col - b.Col, a.Row - b.Row); } public static bool operator ==(GridPosition a, GridPosition b) { return a.Col == b.Col && a.Row == b.Row; } public static bool operator !=(GridPosition a, GridPosition b) { return a.Col != b.Col || a.Row != b.Row; } public override bool Equals(object obj) { return this == (GridPosition)obj; } public override int GetHashCode() { return HashCode.Combine(Col, Row); } } } namespace R2InventoryArtifact.Util.R2API { [Serializable] public struct R2Item { public string Name; public string Description; public R2ItemTier ItemTier; public ItemIndex ItemCode; } [Serializable] public enum R2ItemTier { NONE, T1, T2, T3, BOSS, LUNAR, VT1, VT2, VT3, VBOSS } public class R2ItemService { } [Serializable] public enum R2ItemCode { None = -1, Other = 2, AACannon = 0, AdaptiveArmor = 1, AlienHead = 2, RepulsionArmorPlate = 3, ShatteringJustice = 4, ArtifactKey = 5, Mocha = 6, PredatoryInstincts = 7, BolsteringLantern = 8, GestureoftheDrowned = 9, Bandolier = 10, WarBonds = 11, EclipseLite = 12, TopazBrooch = 13, Aegis = 14, TougherTimes = 15, SaferSpaces = 16, QueensGland = 17, BrilliantBehemoth = 18, TriTipDagger = 19, Shatterspleen = 20, Needletick = 21, GhorsTome = 22, QuickFix = 23, GrowthNectar = 24, ITEM_BOOSTATTACKSPEED_NAME = 25, ITEM_BOOSTDAMAGE_NAME = 26, ITEM_BOOSTEQUIPMENTRECHARGE_NAME = 27, ITEM_BOOSTHP_NAME = 28, ArmorPiercingRounds = 29, SentientMeatHook = 30, ITEM_BURNNEARBY_NAME = 31, DefensiveMicrobots = 32, Ukulele = 33, Polylute = 34, LeafClover57 = 35, BenthicBloom = 36, ITEM_CONVERTCRITCHANCETOCRITDAMAGE_NAME = 37, SearedSteak = 38, WickedRing = 39, ITEM_CRIPPLEWARDONLEVEL_NAME = 40, HikersBoots = 41, LaserScope = 42, LensMakersGlasses = 43, LostSeersLenses = 44, ITEM_CRITHEAL_NAME = 45, Crowbar = 46, ITEM_CUTHP_NAME = 47, CeremonialDagger = 48, DeathMark = 49, WarpedEcho = 50, ITEM_DESTRUCTIBLESPAWNER_NAME = 51, ITEM_DRIZZLEPLAYERHELPER_NAME = 52, ITEM_DRONEDYNAMITEDISPLAY_NAME = 53, SpareDroneParts = 55, ITEM_DRONEWEAPONSBOOST_NAME = 56, ITEM_DRONEWEAPONSDISPLAY1_NAME = 57, ITEM_DRONEWEAPONSDISPLAY2_NAME = 58, BoxofDynamite = 59, SubstandardDuplicator = 60, SingularityBand = 61, ITEM_EMPOWERALWAYS_NAME = 62, WarHorn = 63, FuelCell = 64, LysateCell = 65, OldGuillotine = 66, Willothewisp = 67, VoidsentFlame = 68, FunctionalCoupler = 69, DiosBestFriend = 70, DiosBestFriend_Consumed = 71, PluripotentLarva = 72, PluripotentLarva_Consumed = 73, ChanceDoll = 74, PrayerBeads = 75, H3AD5Tv2 = 76, HopooFeather = 77, KjarosBand = 78, MoltenPerforator = 79, BundleofFireworks = 80, BisonSteak = 81, FocusedConvergence = 82, DelicateWatch = 83, DelicateWatch_Broken = 84, ShippingRequestForm = 85, ITEM_GHOST_NAME = 86, HappiestMask = 87, BrittleCrown = 88, RollofPennies = 89, ITEM_GUMMYCLONEIDENTIFIER_NAME = 90, LightFluxPauldron = 91, StoneFluxPauldron = 92, WakeofVultures = 93, HarvestersScythe = 94, CautiousSlug = 95, PowerElixir = 96, EmptyBottle = 97, ITEM_HEALTHDECAY_NAME = 98, PaulsGoatHoof = 99, RunaldsBand = 100, FrostRelic = 101, Gasoline = 102, BensRaincoat = 103, ChronicExpansion = 104, RejuvenationRack = 105, LuminousShot = 106, AncestralIncubator = 107, Infusion = 108, ITEM_INVADINGDOPPELGANGER_NAME = 109, SonorousWhispers = 110, WaxQuail = 111, FaradaySpur = 112, Junk = 113, Brainstalks = 114, BreachingFin = 115, TitanicKnurl = 116, ResonanceDisc = 117, ITEM_LEMURIANHARNESS_NAME = 118, ITEM_LEVELBONUS_NAME = 119, ChargedPerforator = 120, SaleStar = 121, SaleStar_Consumed = 122, Purity = 123, ShapedGlass = 124, VisionsofHeresy = 125, HooksofHeresy = 126, EssenceofHeresy = 127, Egocentrism = 128, BeadsofFealty = 129, StridesofHeresy = 130, BlessingsofTerafirmae = 131, ITEM_MAGEATTUNEMENT_NAME = 132, EncryptedCerebellum = 133, ExposedCerebellum = 134, Medkit = 135, RunicLens = 136, ITEM_MINIONLEASH_NAME = 138, DefenseNucleus = 139, AtGMissileMk1 = 140, PlasmaShrimp = 141, OminousLoanNote = 142, ITEM_MONSOONPLAYERHELPER_NAME = 143, DefiantGouge = 144, PocketICBM = 145, HuntersHarpoon = 146, BustlingFungus = 147, WeepingFungus = 148, FocusCrystal = 149, NkuhanasOpinion = 150, GenesisLoop = 151, LongstandingSolitude = 152, OddlyshapedOpal = 153, Planula = 154, Pearl = 155, SymbioticScorpion = 156, PersonalShieldGenerator = 157, OldWarStealthkit = 158, OrphanedCore = 159, InterstellarDeskPlant = 160, ITEM_PLANTONHIT_NAME = 161, ITEM_PLASMACORE_NAME = 162, PrisonMatrix = 163, OcularBattery = 164, SentryKey = 165, Shuriken = 166, MercurialRachis = 167, BottledChaos = 168, EulogyZero = 169, RegeneratingScrap = 170, RegeneratingScrap_Consumed = 171, Corpsebloom = 172, EmpathyCores = 173, ItemScrap = 174, Green = 174, StrangeScrapGreen = 175, ItemScrapRed = 176, StrangeScrap = 177, Red = 177, ItemScrapWhite = 178, StrangeScrapWhite = 179, ItemScrapYellow = 180, BackupMagazine = 181, LeechingSeed = 182, NetworkedSuffering = 183, KineticDampener = 184, Transcendence = 185, IrradiantPearl = 186, FaultyConductor = 187, UnstableTeslaCoil = 188, MiredUrn = 189, SkullToken = 190, Chronobauble = 191, Tentabauble = 192, ElusiveAntlers = 193, CollectorsCompulsion = 194, RoseBuckler = 195, EnergyDrink = 196, RedWhip = 197, LittleDisciple = 198, SquidPolyp = 199, ITEM_STATSFROMSCRAP_NAME = 200, HeartyStew = 201, StickyBomb = 202, IgnitionTank = 203, ElectricBoomerang = 204, StunGrenade = 205, SoldiersSyringe = 206, LeptonDaisy = 207, SoulboundCatalyst = 208, UnstableTransmitter = 210, UnstableTransmitter_Consumed = 211, ITEM_TEMPESTONKILL_NAME = 213, Razorwire = 214, HalcyonSeed = 215, TonicAffliction = 216, MonsterTooth = 217, NeutroniumWeight = 218, RustedKey = 219, EncrustedKey = 220, NoxiousThorn = 221, UltimateMeal = 222, HardlightAfterburner = 224, NewlyHatchedZoea = 225, ITEM_WARCRYONCOMBAT_NAME = 227, BerzerkersPauldron = 228, Warbanner = 229, SautéedWorms = 230 } } namespace R2InventoryArtifact.Model { public enum InventoryEffectCode { None, BundleOfFireworks_BisonSteak_IgnitionTank } [Serializable] public class InventoryEffect { public string Name; public string Description; } public class InventoryEffectObserver { public Dictionary EffectFreqs = new Dictionary(); private Dictionary> _itemEffectMap = new Dictionary>(); private Dictionary> _adjList = new Dictionary>(); public event Action OnEffectAdd; public event Action OnEffectRemove; public void AddAdjacency(InventoryItem itemA, InventoryItem itemB) { _adjList[itemA] = _adjList.GetValueOrDefault(itemA, new HashSet()); _adjList[itemA].Add(itemB); _adjList[itemB] = _adjList.GetValueOrDefault(itemB, new HashSet()); _adjList[itemB].Add(itemA); ValidateAdjacency(itemA); ValidateAdjacency(itemB); } public void RemoveAdjacency(InventoryItem itemA, InventoryItem itemB) { _adjList[itemA].Remove(itemB); _adjList[itemB].Remove(itemA); ValidateAdjacency(itemA); ValidateAdjacency(itemB); } private void ValidateAdjacency(InventoryItem parent) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) HashSet adjacent = (from i in _adjList.GetValueOrDefault(parent, new HashSet()) select i.Pickup).ToHashSet(); Dictionary dictionary = (from kvPair in _itemEffectMap.GetValueOrDefault(parent, new Dictionary()) select new KeyValuePair(kvPair.Key, 0)).ToDictionary((KeyValuePair k) => k.Key, (KeyValuePair v) => v.Value); InventoryEffectCode inventoryEffectCode = InventoryService.GetInventoryEffectCode(parent.Pickup, adjacent); if (inventoryEffectCode != 0) { dictionary[inventoryEffectCode] = dictionary.GetValueOrDefault(inventoryEffectCode, 0) + 1; } List<(InventoryEffectCode, int)> list = new List<(InventoryEffectCode, int)>(); List<(InventoryEffectCode, int)> list2 = new List<(InventoryEffectCode, int)>(); foreach (KeyValuePair item in dictionary) { item.Deconstruct(out var key, out var value); InventoryEffectCode inventoryEffectCode2 = key; int num = value; int valueOrDefault = _itemEffectMap.GetValueOrDefault(parent, new Dictionary()).GetValueOrDefault(inventoryEffectCode2, 0); if (num != valueOrDefault) { int num2 = EffectFreqs.GetValueOrDefault(inventoryEffectCode2, 0) - (valueOrDefault - num); if (num > valueOrDefault) { list.Add((inventoryEffectCode2, num2)); } else if (valueOrDefault > num) { list2.Add((inventoryEffectCode2, num2)); } if (num2 > 0) { EffectFreqs[inventoryEffectCode2] = num2; } else { EffectFreqs.Remove(inventoryEffectCode2); } } } list.ForEach(delegate((InventoryEffectCode, int) set) { this.OnEffectAdd?.Invoke(set.Item1, set.Item2); }); list2.ForEach(delegate((InventoryEffectCode, int) set) { this.OnEffectRemove?.Invoke(set.Item1, set.Item2); }); _itemEffectMap[parent] = dictionary; } } public enum PickupType { None, Item, Equipment } [Serializable] public class InventoryItem { public UniquePickup Pickup; public PickupType PickupType = PickupType.None; private List _nodeOrigin; private List _activeOrigin; private int _orientation = 0; public List Nodes; public List ActiveNodes; private int _stackCount = 1; public int MaxStackCount = 4; public bool IsDroppable = true; public bool IsEquippable = true; public int StackCount { get { return _stackCount; } set { _stackCount = value; this.OnStackCountChanged(); } } public ItemTier ItemTier => ((PickupIndex)(ref Pickup.pickupIndex)).pickupDef.itemTier; public event Action OnStackCountChanged; public InventoryItem(UniquePickup pickup, List nodeOrigin, List activeOrigin) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 //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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Invalid comparison between Unknown and I4 //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Invalid comparison between Unknown and I4 Pickup = pickup; if ((int)((PickupIndex)(ref pickup.pickupIndex)).pickupDef.itemIndex != -1) { PickupType = PickupType.Item; } else if ((int)((PickupIndex)(ref pickup.pickupIndex)).pickupDef.equipmentIndex != -1) { PickupType = PickupType.Equipment; } ItemTier itemTier = ((PickupIndex)(ref pickup.pickupIndex)).pickupDef.itemTier; if (PickupType == PickupType.Item) { ItemTier val = itemTier; ItemTier val2 = val; if ((int)val2 == 3 || val2 - 5 <= 4) { IsDroppable = false; } } if (PickupType == PickupType.Item) { ItemDef itemDef = ItemCatalog.GetItemDef(((PickupIndex)(ref pickup.pickupIndex)).pickupDef.itemIndex); if (((UniquePickup)(ref pickup)).isTempItem || ((Object)(object)itemDef != (Object)null && itemDef.isConsumed)) { IsDroppable = false; } } _nodeOrigin = nodeOrigin; _activeOrigin = activeOrigin; Nodes = new List(_nodeOrigin); ActiveNodes = new List(_activeOrigin); } public void Rotate() { _orientation = (_orientation + 1) % 3; for (int i = 0; i < Nodes.Count; i++) { Nodes[i] = new GridPosition(-Nodes[i].Row, Nodes[i].Col); } for (int j = 0; j < ActiveNodes.Count; j++) { ActiveNodes[j] = new GridPosition(-ActiveNodes[j].Row, ActiveNodes[j].Col); } } public TooltipContent GetTooltipContent() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) TooltipContent result = default(TooltipContent); switch (PickupType) { case PickupType.Item: { ItemDef itemDef = ItemCatalog.GetItemDef(((PickupIndex)(ref Pickup.pickupIndex)).pickupDef.itemIndex); result.overrideTitleText = string.Format("{0}{1} [{2}/{3}]", Language.GetString(itemDef.nameToken), ((UniquePickup)(ref Pickup)).isTempItem ? " (Temp)" : "", StackCount, MaxStackCount); result.titleToken = itemDef.nameToken; result.bodyToken = itemDef.descriptionToken; result.bodyColor = ((PickupIndex)(ref Pickup.pickupIndex)).pickupDef.baseColor; result.titleColor = ((PickupIndex)(ref Pickup.pickupIndex)).pickupDef.darkColor; break; } case PickupType.Equipment: { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(((PickupIndex)(ref Pickup.pickupIndex)).pickupDef.equipmentIndex); result.titleToken = equipmentDef.nameToken; result.bodyToken = equipmentDef.descriptionToken; result.bodyColor = ((PickupIndex)(ref Pickup.pickupIndex)).pickupDef.baseColor; result.titleColor = ((PickupIndex)(ref Pickup.pickupIndex)).pickupDef.darkColor; break; } } return result; } } public enum InventoryResultCode { FAILED, GRID_INSERT, GRID_UPDATE, GRID_REMOVE, HOLD_INSERT, HOLD_UPDATE, HOLD_REMOVE, NONEQUIP_INSERT, NONEQUIP_UPDATE, NONEQUIP_REMOVE } public struct InventoryUpdateResult { public InventoryResultCode ResultCode; public InventoryItem InventoryItem; public GridPosition Pos; public InventoryUpdateResult(InventoryResultCode ResultCode, InventoryItem InventoryItem, GridPosition Pos = default(GridPosition)) { this.ResultCode = ResultCode; this.InventoryItem = InventoryItem; this.Pos = Pos; } } [Serializable] public class InventoryLock { public List Nodes; public int UnlockLevel; public bool IsLocked = true; } public static class InventoryModel { private static IntRect _grid; private static List _holdList; private static List _nonEquipList; private static InventoryItem[,] _inventory; public static List InventoryLocks; private static Dictionary _itemRoot; private static Dictionary> _activeMap; private static InventoryEffectObserver _effectObserver; public static event Action OnEffectAdd { add { _effectObserver.OnEffectAdd += value; } remove { _effectObserver.OnEffectAdd -= value; } } public static event Action OnEffectRemove { add { _effectObserver.OnEffectRemove += value; } remove { _effectObserver.OnEffectRemove -= value; } } public static void Initialize(IntRect grid, List locks) { _grid = grid; InventoryLocks = locks; _effectObserver = new InventoryEffectObserver(); Reset(); } public static bool SetItemAt(InventoryItem item, GridPosition pos) { if (!IsValidItemPosition(item, pos)) { return false; } foreach (GridPosition node in item.Nodes) { GridPosition key = node + pos; _inventory[key.Row, key.Col] = item; if (!_activeMap.ContainsKey(key)) { continue; } foreach (InventoryItem item2 in _activeMap[key]) { if (item != item2) { _effectObserver.AddAdjacency(item, item2); } } } foreach (GridPosition activeNode in item.ActiveNodes) { GridPosition gridPosition = activeNode + pos; if (_grid.Contains(gridPosition)) { if (_inventory[gridPosition.Row, gridPosition.Col] != null) { _effectObserver.AddAdjacency(item, _inventory[gridPosition.Row, gridPosition.Col]); } List valueOrDefault = _activeMap.GetValueOrDefault(gridPosition, new List()); valueOrDefault.Add(item); _activeMap[gridPosition] = valueOrDefault; } } _itemRoot[item] = pos; return true; } public static void UnsetItemAt(InventoryItem item, GridPosition pos) { if (item == null || _inventory[pos.Row, pos.Col] != item) { return; } foreach (GridPosition node in item.Nodes) { GridPosition key = node + pos; _inventory[key.Row, key.Col] = null; if (!_activeMap.ContainsKey(key)) { continue; } foreach (InventoryItem item2 in _activeMap[key]) { if (item != item2) { _effectObserver.RemoveAdjacency(item, item2); } } } foreach (GridPosition activeNode in item.ActiveNodes) { GridPosition gridPosition = activeNode + pos; if (_grid.Contains(gridPosition)) { if (_inventory[gridPosition.Row, gridPosition.Col] != null) { _effectObserver.RemoveAdjacency(item, _inventory[gridPosition.Row, gridPosition.Col]); } _activeMap[gridPosition].Remove(item); if (_activeMap[gridPosition].Count == 0) { _activeMap.Remove(gridPosition); } } } _itemRoot.Remove(item); } public static List GetEffectList() { return _effectObserver.EffectFreqs.Keys.ToList(); } public static InventoryLock GetLockAt(int row, int col) { foreach (InventoryLock inventoryLock in InventoryLocks) { foreach (GridPosition node in inventoryLock.Nodes) { if (node.Row == row && node.Col == col) { return inventoryLock; } } } return null; } public static InventoryItem GetItemAt(GridPosition pos) { return GetItemAt(pos.Row, pos.Col); } public static InventoryItem GetItemAt(int row, int col) { if (!_grid.Contains(row, col)) { return null; } return _inventory[row, col]; } public static GridPosition GetItemRoot(InventoryItem item) { return _itemRoot[item]; } public static InventoryUpdateResult AddToInventory(UniquePickup pickup, bool toNonEquip) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) InventoryItem inventoryItem = InventoryService.GetInventoryItem(pickup); if (toNonEquip) { foreach (InventoryItem nonEquip in _nonEquipList) { if (nonEquip.Pickup == inventoryItem.Pickup) { nonEquip.StackCount++; return new InventoryUpdateResult(InventoryResultCode.NONEQUIP_UPDATE, nonEquip); } } _nonEquipList.Add(inventoryItem); return new InventoryUpdateResult(InventoryResultCode.NONEQUIP_INSERT, inventoryItem); } for (int i = 0; i < _grid.Height; i++) { for (int j = 0; j < _grid.Width; j++) { if (_inventory[i, j] != null && _inventory[i, j].Pickup == inventoryItem.Pickup && _inventory[i, j].StackCount < _inventory[i, j].MaxStackCount) { _inventory[i, j].StackCount++; return new InventoryUpdateResult(InventoryResultCode.GRID_UPDATE, _inventory[i, j], new GridPosition(j, i)); } } } foreach (InventoryItem hold in _holdList) { if (hold.Pickup == inventoryItem.Pickup && hold.StackCount < hold.MaxStackCount) { hold.StackCount++; return new InventoryUpdateResult(InventoryResultCode.HOLD_UPDATE, hold); } } for (int k = 0; k < _grid.Height; k++) { for (int l = 0; l < _grid.Width; l++) { for (int m = 0; m < 4; m++) { GridPosition pos = new GridPosition(l, k); if (IsValidItemPosition(inventoryItem, pos)) { SetItemAt(inventoryItem, pos); return new InventoryUpdateResult(InventoryResultCode.GRID_INSERT, inventoryItem, pos); } inventoryItem.Rotate(); } } } AddToHold(inventoryItem); return new InventoryUpdateResult(InventoryResultCode.HOLD_INSERT, inventoryItem); } private static List RemoveFromNonEquip(UniquePickup pickup, int count) { //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) List list = new List(); InventoryItem inventoryItem = _nonEquipList.Find((InventoryItem ne) => ne.Pickup == pickup); if (inventoryItem == null) { return list; } InventoryUpdateResult inventoryUpdateResult = default(InventoryUpdateResult); inventoryUpdateResult.InventoryItem = inventoryItem; inventoryUpdateResult.Pos = default(GridPosition); inventoryUpdateResult.ResultCode = InventoryResultCode.NONEQUIP_UPDATE; InventoryUpdateResult item = inventoryUpdateResult; inventoryItem.StackCount = Math.Max(inventoryItem.StackCount - count, 0); if (inventoryItem.StackCount == 0) { _nonEquipList.Remove(inventoryItem); item.ResultCode = InventoryResultCode.NONEQUIP_REMOVE; } list.Add(item); return list; } public static List RemoveItems(UniquePickup pickup, bool fromNonEquip, int count = 1) { //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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (fromNonEquip || ((UniquePickup)(ref pickup)).isTempItem) { return RemoveFromNonEquip(pickup, count); } List list = new List(); List tmp = new List(); _holdList.ForEach(delegate(InventoryItem item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (item.Pickup == pickup) { tmp.Add(new InventoryUpdateResult { ResultCode = InventoryResultCode.HOLD_UPDATE, InventoryItem = item }); } }); foreach (InventoryItem key in _itemRoot.Keys) { if (key.Pickup == pickup) { tmp.Add(new InventoryUpdateResult { ResultCode = InventoryResultCode.GRID_UPDATE, InventoryItem = key, Pos = _itemRoot[key] }); } } tmp.Sort((InventoryUpdateResult item1, InventoryUpdateResult item2) => (item1.ResultCode == item2.ResultCode) ? (item1.InventoryItem.StackCount - item2.InventoryItem.StackCount) : (item1.ResultCode - item2.ResultCode)); int num = 0; for (int i = 0; i < tmp.Count; i++) { if (num >= count) { break; } InventoryUpdateResult item3 = tmp[i]; int num2 = count - num; if (item3.InventoryItem.StackCount > num2) { item3.InventoryItem.StackCount -= num2; list.Add(item3); break; } switch (item3.ResultCode) { case InventoryResultCode.GRID_UPDATE: UnsetItemAt(item3.InventoryItem, item3.Pos); item3.ResultCode = InventoryResultCode.GRID_REMOVE; break; case InventoryResultCode.HOLD_UPDATE: RemoveFromHold(item3.InventoryItem); item3.ResultCode = InventoryResultCode.HOLD_REMOVE; break; } list.Add(item3); num += item3.InventoryItem.StackCount; } return list; } public static void RemoveFromNonEquip(InventoryItem item) { _nonEquipList.Remove(item); } public static bool IsPositionLocked(GridPosition pos) { foreach (InventoryLock inventoryLock in InventoryLocks) { foreach (GridPosition node in inventoryLock.Nodes) { if (pos == node) { return inventoryLock.IsLocked; } } } return false; } public static List SetUnlocksAtLevel(int level) { List list = new List(); for (int i = 0; i < InventoryLocks.Count; i++) { if (InventoryLocks[i].IsLocked && InventoryLocks[i].UnlockLevel <= level) { InventoryLocks[i].IsLocked = false; list.Add(InventoryLocks[i]); } } return list; } public static bool IsValidItemPosition(InventoryItem item, GridPosition pos) { foreach (GridPosition node in item.Nodes) { GridPosition pos2 = pos + node; if (!_grid.Contains(pos2) || _inventory[pos2.Row, pos2.Col] != null || IsPositionLocked(pos2)) { return false; } } return true; } public static void AddToHold(InventoryItem item) { _holdList.Add(item); } public static void RemoveFromHold(InventoryItem item) { _holdList.Remove(item); } public new static string ToString() { List list = new List(); for (int i = 0; i < _inventory.GetLength(0); i++) { List list2 = new List(); for (int j = 0; j < _inventory.GetLength(1); j++) { list2.Add((_inventory[i, j] != null) ? "[x]" : "[ ]"); } list.Add(string.Join("\t", list2)); } return string.Join("\n", list); } internal static List DiscardHold() { if (_holdList.Count == 0) { return new List(); } List list = _holdList.Select((InventoryItem item) => new InventoryUpdateResult(InventoryResultCode.HOLD_REMOVE, item)).ToList(); list.ForEach(delegate(InventoryUpdateResult res) { RemoveFromHold(res.InventoryItem); }); return list; } internal static void Reset() { _inventory = new InventoryItem[_grid.Height, _grid.Width]; _activeMap = new Dictionary>(); _holdList = new List(); _nonEquipList = new List(); _itemRoot = new Dictionary(); for (int i = 0; i < InventoryLocks.Count; i++) { InventoryLocks[i].IsLocked = true; } } } } namespace R2InventoryArtifact.UI { public class InventoryUI : MonoBehaviour, IDropHandler, IEventSystemHandler { public static InventoryUI Instance; private CanvasGroup _canvasGroup; private InventoryGridComponent _inventoryGrid; private InventoryHoldComponent _inventoryHoldList; private InventoryNonEquipComponent _inventoryNonEquipList; private InventoryDropComponent _inventoryDropArea; public InventoryItemElement CursorElement; public int PlayerLevel; public bool IsVisible = true; public event Action OnInventoryItemDropped; public event Action OnUIVisibilityChanged; private void Awake() { Log.Debug("InventoryUI Awake...."); Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } public void Initialize(IntRect rect, List locks) { if (Object.op_Implicit((Object)(object)Instance)) { Object.Destroy((Object)(object)Instance); } Instance = this; InventoryModel.Initialize(rect, locks); _canvasGroup = ((Component)this).GetComponent(); _inventoryHoldList = ComponentBuilder.BuildInventoryHoldComponent(((Component)this).transform); _inventoryDropArea = ComponentBuilder.BuildInventoryDropComponent(((Component)this).transform); _inventoryGrid = ComponentBuilder.BuildInventoryGridComponent(((Component)this).transform); _inventoryNonEquipList = ComponentBuilder.BuildInventoryNonEquipComponent(((Component)this).transform); _inventoryGrid.Initialize(rect, locks); _inventoryDropArea.OnInventoryItemDropped += HandleItemDrop; } private void OnDestroy() { _inventoryDropArea.OnInventoryItemDropped -= HandleItemDrop; Log.Debug("destroyed inventoryui"); } public void SetUIVisibility(bool show) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown _canvasGroup.alpha = (show ? 1 : 0); _canvasGroup.blocksRaycasts = show; IsVisible = show; if (!show) { List list = InventoryModel.DiscardHold(); list.ForEach(delegate(InventoryUpdateResult res) { _inventoryHoldList.RemoveFromHold(res.InventoryItem); HandleItemDrop(res.InventoryItem); }); if ((Object)(object)CursorElement != (Object)null) { PointerEventData val = new PointerEventData(EventSystem.current); if (CursorElement.DragSource == DragSource.HOLD) { val.pointerDrag = ((Component)CursorElement).gameObject; ExecuteEvents.endDragHandler.Invoke((IEndDragHandler)(object)CursorElement, (BaseEventData)(object)val); _inventoryHoldList.OnDrop(val); } } } this.OnUIVisibilityChanged?.Invoke(show); } public void HandleItemDrop(InventoryItem item) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) this.OnInventoryItemDropped(item.Pickup, item.StackCount); } public InventoryResultCode AddToInventory(UniquePickup pickup, bool toNonEquip) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) InventoryUpdateResult inventoryUpdateResult = InventoryModel.AddToInventory(pickup, toNonEquip); switch (inventoryUpdateResult.ResultCode) { case InventoryResultCode.NONEQUIP_INSERT: _inventoryNonEquipList.AddItem(inventoryUpdateResult.InventoryItem); break; case InventoryResultCode.GRID_INSERT: _inventoryGrid.InsertItemAt(inventoryUpdateResult.InventoryItem, inventoryUpdateResult.Pos); break; case InventoryResultCode.HOLD_INSERT: _inventoryHoldList.AddToHold(inventoryUpdateResult.InventoryItem); break; } return inventoryUpdateResult.ResultCode; } public void AddToHold(InventoryItem item) { InventoryModel.AddToHold(item); _inventoryHoldList.AddToHold(item); } public void RemoveFromInventory(UniquePickup pickup, bool fromNonEquip, int count) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) List list = InventoryModel.RemoveItems(pickup, fromNonEquip, count); list.ForEach(delegate(InventoryUpdateResult result) { switch (result.ResultCode) { case InventoryResultCode.GRID_REMOVE: _inventoryGrid.RemoveAt(result.Pos); break; case InventoryResultCode.HOLD_REMOVE: _inventoryHoldList.RemoveFromHold(result.InventoryItem); break; case InventoryResultCode.NONEQUIP_REMOVE: _inventoryNonEquipList.RemoveFromNonEquip(result.InventoryItem); break; } }); _inventoryGrid.RepaintGrid(); } public void SetCursorElement(InventoryItemElement element) { CursorElement = element; _inventoryGrid.RepaintGrid(); } public void SetPlayerLevel(int playerLevel) { PlayerLevel = playerLevel; List locks = InventoryModel.SetUnlocksAtLevel(PlayerLevel); _inventoryGrid.UpdateGridLocks(locks); _inventoryGrid.RepaintGrid(); } public void ResetInventory() { InventoryModel.Reset(); _inventoryHoldList.Clear(); _inventoryNonEquipList.Clear(); _inventoryGrid.Clear(); _inventoryGrid.UpdateGridLocks(InventoryModel.InventoryLocks); _inventoryGrid.RepaintGrid(); PlayerLevel = 0; } public void RotateCursorItem() { if ((Object)(object)CursorElement != (Object)null) { CursorElement.Rotate(); _inventoryGrid.RepaintGrid(); } } public void OnDrop(PointerEventData eventData) { InventoryItemElement component = eventData.pointerDrag.GetComponent(); if ((Object)(object)component != (Object)null && component.DragSource == DragSource.HOLD) { AddToHold(component.Item); Object.Destroy((Object)(object)((Component)component).gameObject); } } } public static class UIConstants { public const int SPACING_SX = 2; public const int SPACING_SM = 4; public const int SPACING_MD = 8; public const int SPACING_LG = 12; public const int FONT_SM = 8; public const int FONT_MD = 12; public const int FONT_LG = 16; private const float ALPHA = 0.5f; public static readonly Color COLOR_ITEM_SLOT_NEUTRAL = ColorFromHex("#ffffff", 0.25f); public static readonly Color COLOR_ITEM_SLOT_ACTIVE = ColorFromHex("#daa520", 0.5f); public static readonly Color COLOR_ITEM_SLOT_ACTIVE_OUTLINE = ColorFromHex("#b8860b", 0.5f); public static readonly Color COLOR_ITEM_SLOT_HOVER_VALID = ColorFromHex("#008000", 0.5f); public static readonly Color COLOR_ITEM_SLOT_HOVER_INVALID = ColorFromHex("#FF0000", 0.5f); public static readonly Color COLOR_ITEM_SLOT_LOCKED = ColorFromHex("#414141", 0.5f); public static readonly Color COLOR_TOOLTIP_TITLE_SLOT_LOCKED = ColorFromHex("#414141", 0.5f); public static readonly Color COLOR_TOOLTIP_BODY_SLOT_LOCKED = ColorFromHex("#d6d6d6", 0.5f); public static (Color, Color) GetItemTeirColor(ItemTier tier) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected I4, but got Unknown //IL_0042: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0138: 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_015e: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) return (int)tier switch { 0 => (ColorFromHex("#6b6b6b", 0.5f), ColorFromHex("#6b6b6b", 0.5f)), 1 => (ColorFromHex("#a0ff9a", 0.5f), ColorFromHex("#2f7d32", 0.5f)), 2 => (ColorFromHex("#ff6b6b", 0.5f), ColorFromHex("#8b1a1a", 0.5f)), 4 => (ColorFromHex("#ffd966", 0.5f), ColorFromHex("#b38f00", 0.5f)), 3 => (ColorFromHex("#7fbfff", 0.5f), ColorFromHex("#1f4f99", 0.5f)), 6 => (ColorFromHex("#d98cff", 0.5f), ColorFromHex("#6b2f8f", 0.5f)), 7 => (ColorFromHex("#d98cff", 0.5f), ColorFromHex("#6b2f8f", 0.5f)), 8 => (ColorFromHex("#d98cff", 0.5f), ColorFromHex("#6b2f8f", 0.5f)), 9 => (ColorFromHex("#d98cff", 0.5f), ColorFromHex("#6b2f8f", 0.5f)), _ => (ColorFromHex("#6b6b6b", 0.5f), ColorFromHex("#6b6b6b", 0.5f)), }; } public static Color ColorFromHex(string hex, float alpha = 1f) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = 0f; float num3 = 0f; hex = hex.Trim().Replace("#", ""); num = (float)Convert.ToInt32(hex.Substring(0, 2), 16) / 256f; num2 = (float)Convert.ToInt32(hex.Substring(2, 2), 16) / 256f; num3 = (float)Convert.ToInt32(hex.Substring(4, 2), 16) / 256f; return new Color(num, num2, num3, alpha); } } } namespace R2InventoryArtifact.UI.Services { public class InventoryItemProps { public List NodeOrigin; public List ActiveOrigin; public int MaxStackCount; } public class InventoryService { private static string _ITEM_DATA_FILENAME = "item_data.json"; private static Dictionary _inventoryDict; public static void Initialize(PluginInfo pluginInfo) { _inventoryDict = new Dictionary(); string directoryName = Path.GetDirectoryName(pluginInfo.Location); if (string.IsNullOrEmpty(directoryName)) { return; } string text = Path.Combine(directoryName, "Assets", _ITEM_DATA_FILENAME); Log.Debug("try load file: " + text); try { using StreamReader streamReader = new StreamReader(text); string text2 = streamReader.ReadToEnd(); _inventoryDict = JsonConvert.DeserializeObject>(text2); } catch (Exception arg) { Log.Warning($"Unable to read file ({text}): {arg}"); } } public static InventoryItem GetInventoryItem(UniquePickup pickup) { //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Expected I4, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Invalid comparison between Unknown and I4 //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Expected I4, but got Unknown //IL_050c: Unknown result type (might be due to invalid IL or missing references) InventoryItemProps valueOrDefault = _inventoryDict.GetValueOrDefault(((PickupIndex)(ref pickup.pickupIndex)).pickupDef.nameToken, null); if (valueOrDefault != null) { return new InventoryItem(pickup, valueOrDefault.NodeOrigin, valueOrDefault.ActiveOrigin) { MaxStackCount = valueOrDefault.MaxStackCount }; } List> list = new List> { new List { new GridPosition(0, 0), new GridPosition(0, 1), new GridPosition(1, 0), new GridPosition(1, 1) }, new List { new GridPosition(-1, 0), new GridPosition(0, 0), new GridPosition(1, 0), new GridPosition(2, 0) }, new List { new GridPosition(0, 0), new GridPosition(0, -1), new GridPosition(-1, -1), new GridPosition(1, 0) }, new List { new GridPosition(0, 0), new GridPosition(-1, 0), new GridPosition(0, -1), new GridPosition(1, -1) }, new List { new GridPosition(0, 0), new GridPosition(1, 0), new GridPosition(0, 1), new GridPosition(0, 2) }, new List { new GridPosition(0, 0), new GridPosition(-1, 0), new GridPosition(0, 1), new GridPosition(0, 2) }, new List { new GridPosition(0, 0), new GridPosition(-1, 0), new GridPosition(1, 0), new GridPosition(0, -1) }, new List { new GridPosition(0, 0), new GridPosition(1, 0), new GridPosition(1, 1), new GridPosition(-1, 0), new GridPosition(-1, 1) }, new List { new GridPosition(0, 0), new GridPosition(-1, 0), new GridPosition(-2, 0), new GridPosition(1, 0), new GridPosition(2, 0) }, new List { new GridPosition(0, 0), new GridPosition(-1, 0), new GridPosition(1, 0), new GridPosition(0, -1), new GridPosition(0, -2) }, new List { new GridPosition(0, 0), new GridPosition(-1, 0), new GridPosition(-1, -1), new GridPosition(0, 1), new GridPosition(1, 1) }, new List { new GridPosition(0, 0), new GridPosition(0, 1), new GridPosition(1, 0), new GridPosition(1, 1), new GridPosition(1, 2) }, new List { new GridPosition(0, 0), new GridPosition(-1, 0), new GridPosition(1, 0), new GridPosition(0, -1), new GridPosition(0, 1) }, new List { new GridPosition(0, 0), new GridPosition(-1, 0), new GridPosition(-2, 0), new GridPosition(0, 1), new GridPosition(0, 2) } }; int maxStackCount = 2; ItemTier itemTier = ((PickupIndex)(ref pickup.pickupIndex)).pickupDef.itemTier; ItemTier val = itemTier; switch ((int)val) { case 0: case 6: case 10: maxStackCount = 5; break; case 1: case 7: maxStackCount = 4; break; case 2: case 8: maxStackCount = 3; break; } ItemIndex itemIndex = ((PickupIndex)(ref pickup.pickupIndex)).pickupDef.itemIndex; EquipmentIndex equipmentIndex = ((PickupIndex)(ref pickup.pickupIndex)).pickupDef.equipmentIndex; int val2 = (int)(((int)itemIndex != -1) ? itemIndex : equipmentIndex); val2 = Math.Max(val2, 0) % list.Count; return new InventoryItem(pickup, new List(list[val2]), new List()) { MaxStackCount = maxStackCount }; } public static InventoryEffectCode GetInventoryEffectCode(UniquePickup pickup, HashSet adjacent) { return InventoryEffectCode.None; } public static InventoryEffect GetInventoryEffectInfo(InventoryEffectCode effectCode) { if (effectCode == InventoryEffectCode.BundleOfFireworks_BisonSteak_IgnitionTank) { return new InventoryEffect { Name = "Cook-out", Description = "Bundle of Fireworks now ignite on it" }; } return null; } } public static class UIAssetService { public enum SpritePanelType { NONE, HEADER, PANEL, HANDLE, BACKDROP, DROP_ZONE, ELEMENT } public enum SpriteTileType { TILEx____ = 0, TILEx___R = 1, TILEx__L_ = 2, TILEx__LR = 3, TILEx_B__ = 4, TILEx_B_R = 5, TILEx_BL_ = 6, TILEx_BLR = 7, TILExT___ = 8, TILExT__R = 9, TILExT_L_ = 10, TILExT_LR = 11, TILExTB__ = 12, TILExTB_R = 13, TILExTBL_ = 14, TILExTBLR = 15, TILE = 15, DISABLED_TILE = 16 } private static Dictionary _spritePanelDict; private static Dictionary _spriteBaseTileDict; private static Dictionary _spriteLockedTileDict; private static AssetBundle _bundle; private const string _bundleName = "assetbundle"; public static void Initialize(PluginInfo pluginInfo) { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) _spritePanelDict = new Dictionary { { SpritePanelType.HEADER, Addressables.LoadAssetAsync((object)"RoR2/Base/UI/texUIHighlightHeader.png").WaitForCompletion() }, { SpritePanelType.PANEL, Addressables.LoadAssetAsync((object)"RoR2/Base/UI/texUICleanPanel.png").WaitForCompletion() }, { SpritePanelType.HANDLE, Addressables.LoadAssetAsync((object)"RoR2/Base/UI/texUIHandle.png").WaitForCompletion() }, { SpritePanelType.BACKDROP, Addressables.LoadAssetAsync((object)"RoR2/Base/UI/texUIBackdrop.png").WaitForCompletion() }, { SpritePanelType.ELEMENT, Addressables.LoadAssetAsync((object)"RoR2/Base/UI/texDetailPanel.png").WaitForCompletion() } }; string text = Path.Combine(Path.GetDirectoryName(pluginInfo.Location), "Assets", "assetbundle"); try { _bundle = AssetBundle.LoadFromFile(text); } catch (Exception arg) { Log.Warning($"Failed to load asset from file: {arg}"); } _spriteBaseTileDict = new Dictionary(); _spriteLockedTileDict = new Dictionary(); if (!((Object)(object)_bundle != (Object)null)) { return; } Sprite[] array = _bundle.LoadAllAssets(); Sprite[] array2 = array; foreach (Sprite val in array2) { if (((Object)val).name.Contains("grid_tiles-")) { string text2 = ((Object)val).name.Replace("grid_tiles-", ""); int num = 0; if (text2.Contains('T')) { num |= 8; } if (text2.Contains('B')) { num |= 4; } if (text2.Contains('L')) { num |= 2; } if (text2.Contains('R')) { num |= 1; } _spriteBaseTileDict.Add((SpriteTileType)num, val); } else if (((Object)val).name.Contains("lock_tiles-")) { string text3 = ((Object)val).name.Replace("lock_tiles-", ""); int num2 = 0; if (text3.Contains('T')) { num2 |= 8; } if (text3.Contains('B')) { num2 |= 4; } if (text3.Contains('L')) { num2 |= 2; } if (text3.Contains('R')) { num2 |= 1; } _spriteLockedTileDict.Add((SpriteTileType)num2, val); } else if (((Object)val).name.Contains("drop_zone")) { _spritePanelDict.Add(SpritePanelType.DROP_ZONE, val); } } } public static Sprite GetPickupSprite(UniquePickup pickup) { return ((PickupIndex)(ref pickup.pickupIndex)).pickupDef.iconSprite; } public static Sprite GetUISprite(SpritePanelType type) { return _spritePanelDict.GetValueOrDefault(type, null); } public static Sprite GetTileSprite(bool isLocked, bool t, bool b, bool l, bool r) { int num = (t ? 1 : 0); int num2 = (b ? 1 : 0); int num3 = (l ? 1 : 0); int num4 = (r ? 1 : 0); SpriteTileType key = (SpriteTileType)((num << 3) | (num2 << 2) | (num3 << 1) | num4); if (isLocked) { return _spriteLockedTileDict[key]; } return _spriteBaseTileDict[key]; } public static Sprite GetTileSprite(SpriteTileType tileType) { return _spriteBaseTileDict[tileType]; } } } namespace R2InventoryArtifact.UI.Layouts { [Serializable] public struct BentoSpan { public int Col; public int Row; [Min(1f)] public int ColSpan; [Min(1f)] public int RowSpan; } public class BentoLayoutGroup : LayoutGroup { [SerializeField] private float m_Spacing; [SerializeField] private int m_UnitWidth = 1; [SerializeField] private int m_UnitHeight = 1; [SerializeField] private List m_Spans; [HideInInspector] public float Spacing { get { return m_Spacing; } set { m_Spacing = value; } } [HideInInspector] public int UnitWidth { get { return m_UnitWidth; } set { m_UnitWidth = value; } } [HideInInspector] public int UnitHeight { get { return m_UnitHeight; } set { m_UnitHeight = value; } } [HideInInspector] public List Spans { get { return m_Spans; } set { m_Spans = value ?? new List(); } } public override void CalculateLayoutInputHorizontal() { ((LayoutGroup)this).CalculateLayoutInputHorizontal(); ((LayoutGroup)this).SetLayoutInputForAxis(1f, 1f, 1f, 0); } public override void CalculateLayoutInputVertical() { ((LayoutGroup)this).CalculateLayoutInputHorizontal(); ((LayoutGroup)this).SetLayoutInputForAxis(1f, 1f, 1f, 1); } private (float, float) CalcChildAxis(int axis, BentoSpan span) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_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) float num; Rect rect; float num2; int num3; int num4; if (axis == 0) { num = ((LayoutGroup)this).padding.left; rect = ((LayoutGroup)this).rectTransform.rect; num2 = (((Rect)(ref rect)).width - (float)((LayoutGroup)this).padding.horizontal - Spacing * (float)(UnitWidth - 1)) / (float)UnitWidth; num3 = span.Col; num4 = span.ColSpan; } else { num = ((LayoutGroup)this).padding.top; rect = ((LayoutGroup)this).rectTransform.rect; num2 = (((Rect)(ref rect)).height - (float)((LayoutGroup)this).padding.vertical - Spacing * (float)(UnitHeight - 1)) / (float)UnitHeight; num3 = span.Row; num4 = span.RowSpan; } float item = num + num2 * (float)num3 + Spacing * (float)num3; float item2 = num2 * (float)num4 + Spacing * (float)(num4 - 1); return (item, item2); } public override void SetLayoutHorizontal() { int num = Mathf.Min(((LayoutGroup)this).rectChildren.Count, m_Spans.Count); for (int i = 0; i < num; i++) { var (num2, num3) = CalcChildAxis(0, Spans[i]); ((LayoutGroup)this).SetChildAlongAxis(((LayoutGroup)this).rectChildren[i], 0, num2, num3); } } public override void SetLayoutVertical() { int num = Mathf.Min(((LayoutGroup)this).rectChildren.Count, m_Spans.Count); for (int i = 0; i < num; i++) { var (num2, num3) = CalcChildAxis(1, Spans[i]); ((LayoutGroup)this).SetChildAlongAxis(((LayoutGroup)this).rectChildren[i], 1, num2, num3); } } } public class InventoryGridLayoutGroup : LayoutGroup { private int _cols = 5; private float _cellSize = 100f; private float _spacing = 0f; public Action OnCellSizeChanged; public void Initialize(int cols, int spacing) { _cols = cols; _spacing = spacing; } public override void CalculateLayoutInputHorizontal() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)this).CalculateLayoutInputHorizontal(); Rect rect = ((LayoutGroup)this).rectTransform.rect; float num = ((Rect)(ref rect)).width - (float)((LayoutGroup)this).padding.horizontal; _cellSize = num / (float)_cols; ((LayoutGroup)this).SetLayoutInputForAxis(num, num, num, 0); OnCellSizeChanged(_cellSize); } public override void CalculateLayoutInputVertical() { //IL_003c: 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) ((LayoutGroup)this).CalculateLayoutInputHorizontal(); float num = _cellSize * (float)(((LayoutGroup)this).rectChildren.Count / _cols) + (float)((LayoutGroup)this).padding.vertical; ((LayoutGroup)this).rectTransform.sizeDelta = new Vector2(((LayoutGroup)this).rectTransform.sizeDelta.x, num); ((LayoutGroup)this).SetLayoutInputForAxis(num, num, num, 1); } public override void SetLayoutHorizontal() { float start = ((LayoutGroup)this).padding.left; int i = 0; ((LayoutGroup)this).rectChildren.ForEach(delegate { ((LayoutGroup)this).SetChildAlongAxis(((LayoutGroup)this).rectChildren[i], 0, start + _cellSize * (float)(i % _cols), _cellSize); i++; }); } public override void SetLayoutVertical() { float start = ((LayoutGroup)this).padding.top; int i = 0; ((LayoutGroup)this).rectChildren.ForEach(delegate { ((LayoutGroup)this).SetChildAlongAxis(((LayoutGroup)this).rectChildren[i], 1, start + _cellSize * (float)(i / _cols), _cellSize); i++; }); } } } namespace R2InventoryArtifact.UI.Components { public class InventoryDropComponent : MonoBehaviour, IDropHandler, IEventSystemHandler { public event Action OnInventoryItemDropped; public void OnDrop(PointerEventData eventData) { InventoryItemElement component = eventData.pointerDrag.GetComponent(); if (!((Object)(object)component == (Object)null) && ((component.DragSource != DragSource.GRID && component.DragSource != DragSource.NONEQUIP) || component.Item.IsDroppable)) { this.OnInventoryItemDropped(component.Item); Object.Destroy((Object)(object)((Component)component).gameObject); } } } public class InventoryEffectComponent : MonoBehaviour { private TextMeshProUGUI textLbl; private Dictionary _effectDict; public void Initialize() { InventoryModel.OnEffectAdd += AddEffect; InventoryModel.OnEffectRemove += RemoveEffect; } private void Awake() { textLbl = ((Component)this).GetComponentInChildren(); _effectDict = new Dictionary(); } private void OnDestroy() { InventoryModel.OnEffectAdd -= AddEffect; InventoryModel.OnEffectRemove -= RemoveEffect; } private void AddEffect(InventoryEffectCode code, int stackCount) { if (_effectDict.ContainsKey(code)) { _effectDict[code].UpdateContent(code, stackCount); return; } InventoryEffectElement inventoryEffectElement = ComponentBuilder.BuildEffectElement(code.ToString()); _effectDict[code] = inventoryEffectElement; inventoryEffectElement.UpdateContent(code, stackCount); ((Component)inventoryEffectElement).transform.SetParent(((Component)this).transform); } private void RemoveEffect(InventoryEffectCode code, int stackCount) { if (stackCount > 0) { _effectDict[code].UpdateContent(code, stackCount); return; } Object.Destroy((Object)(object)((Component)_effectDict[code]).gameObject); _effectDict.Remove(code); } } public class InventoryEffectElement : MonoBehaviour { private TextMeshProUGUI text; private void Awake() { text = ((Component)this).GetComponentInChildren(); } public void UpdateContent(InventoryEffectCode code, int stackCount) { ((TMP_Text)text).text = $"{code} ({stackCount})"; } } public class InventoryGridComponent : MonoBehaviour, IPointerExitHandler, IEventSystemHandler { private IntRect _gridRect; private InventorySlotComponent[,] _slots; private GridPosition? _cursorPosition; private static List<(int, int)> _DIRS = new List<(int, int)> { (-1, 0), (1, 0), (0, -1), (0, 1) }; public void Initialize(IntRect gridSize, List locks) { _gridRect = gridSize; _slots = new InventorySlotComponent[_gridRect.Height, _gridRect.Width]; InventoryGridLayoutGroup inventoryGridLayoutGroup = ((Component)this).gameObject.AddComponent(); inventoryGridLayoutGroup.Initialize(_gridRect.Width, 4); ScrollRect scrollRect; if (Object.op_Implicit((Object)(object)(scrollRect = ((Component)((Component)this).gameObject.transform.parent.parent).GetComponent()))) { inventoryGridLayoutGroup.OnCellSizeChanged = (Action)Delegate.Combine(inventoryGridLayoutGroup.OnCellSizeChanged, new Action(HandleCellSizeChanged)); } for (int i = 0; i < gridSize.Height; i++) { for (int j = 0; j < gridSize.Width; j++) { GridPosition pos = new GridPosition(j, i); InventorySlotComponent inventorySlotComponent = ComponentBuilder.BuildGridSlot(((Component)this).transform, $"{i}-{j}"); inventorySlotComponent.Initialize(this, pos); _slots[i, j] = inventorySlotComponent; } } UpdateGridLocks(locks); void HandleCellSizeChanged(float size) { scrollRect.scrollSensitivity = size / 2f; } } public void InsertItemAt(InventoryItem item, GridPosition pos) { InventoryItemElement inventoryItemElement = ComponentBuilder.BuildItemElement(((object)(UniquePickup)(ref item.Pickup)).ToString() ?? ""); inventoryItemElement.Initialize(item, DragSource.GRID); _slots[pos.Row, pos.Col].SlotItem(inventoryItemElement); } public void RemoveAt(GridPosition pos) { if (((Component)_slots[pos.Row, pos.Col]).transform.childCount != 0) { Transform child = ((Component)_slots[pos.Row, pos.Col]).transform.GetChild(0); InventoryItemElement component; if (Object.op_Implicit((Object)(object)child) && Object.op_Implicit((Object)(object)(component = ((Component)child).GetComponent()))) { Object.Destroy((Object)(object)((Component)component).gameObject); } } } public void UnsetItemAt(InventoryItem item, GridPosition pos) { InventoryModel.UnsetItemAt(item, pos); SetHelper(item, pos, set: false); } public void SetItemAt(InventoryItem item, GridPosition pos) { InventoryModel.SetItemAt(item, pos); SetHelper(item, pos, set: true); } private void SetHelper(InventoryItem item, GridPosition pos, bool set) { foreach (GridPosition node in item.Nodes) { GridPosition gridPosition = node + pos; InventorySlotComponent inventorySlotComponent = _slots[gridPosition.Row, gridPosition.Col]; if (set) { inventorySlotComponent.Occupy(item); } else { inventorySlotComponent.UnOccupy(); } } RepaintGrid(); } public void UpdateCursorPosition(GridPosition pos) { _cursorPosition = pos; RepaintGrid(); } public void RepaintGrid() { //IL_023a: 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_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); bool flag = true; if (_cursorPosition.HasValue) { if ((Object)(object)InventoryUI.Instance.CursorElement != (Object)null) { flag = InventoryModel.IsValidItemPosition(InventoryUI.Instance.CursorElement.Item, _cursorPosition.Value); list = InventoryUI.Instance.CursorElement.Item.Nodes.Select((GridPosition n) => n + _cursorPosition.Value).ToList(); } else { InventoryItem itemAt = InventoryModel.GetItemAt(_cursorPosition.Value); if (itemAt != null) { GridPosition itemRoot = InventoryModel.GetItemRoot(itemAt); list2 = (from n in itemAt.Nodes select n + itemRoot into n where _gridRect.Contains(n) select n).ToList(); } } } for (int i = 0; i < _gridRect.Height; i++) { for (int j = 0; j < _gridRect.Width; j++) { InventoryItem itemAt2 = InventoryModel.GetItemAt(i, j); InventorySlotComponent inventorySlotComponent = _slots[i, j]; GridPosition gridPosition = new GridPosition(j, i); InventoryLock lockAt = InventoryModel.GetLockAt(i, j); bool[] array = new bool[_DIRS.Count]; if (itemAt2 != null || (lockAt != null && lockAt.IsLocked)) { for (int k = 0; k < _DIRS.Count; k++) { int row = i + _DIRS[k].Item1; int col = j + _DIRS[k].Item2; if (lockAt != null && lockAt.IsLocked) { array[k] = _gridRect.Contains(row, col) && lockAt == InventoryModel.GetLockAt(row, col); } else { array[k] = _gridRect.Contains(row, col) && InventoryModel.GetItemAt(row, col) == itemAt2; } } } GridPosition item = new GridPosition(j, i); if (lockAt != null && lockAt.IsLocked) { inventorySlotComponent.Paint(UIConstants.COLOR_ITEM_SLOT_LOCKED, isLocked: true, array[0], array[1], array[2], array[3]); } else if (list2.Contains(item)) { inventorySlotComponent.Paint(UIConstants.COLOR_ITEM_SLOT_ACTIVE, isLocked: false, array[0], array[1], array[2], array[3]); } else if (itemAt2 != null) { Color titleColor = itemAt2.GetTooltipContent().titleColor; inventorySlotComponent.Paint(titleColor, isLocked: false, array[0], array[1], array[2], array[3]); } else if ((Object)(object)InventoryUI.Instance.CursorElement != (Object)null && _cursorPosition.HasValue && list.Contains(item)) { inventorySlotComponent.Paint(flag ? UIConstants.COLOR_ITEM_SLOT_HOVER_VALID : UIConstants.COLOR_ITEM_SLOT_HOVER_INVALID); } else { inventorySlotComponent.Paint(UIConstants.COLOR_ITEM_SLOT_NEUTRAL); } } } } public void OnPointerExit(PointerEventData eventData) { _cursorPosition = null; RepaintGrid(); } public void UpdateGridLocks(List locks) { foreach (InventoryLock invLock in locks) { invLock.Nodes.ForEach(delegate(GridPosition node) { if (_gridRect.Contains(node)) { if (invLock.IsLocked) { _slots[node.Row, node.Col].LockSlot(invLock); } else { _slots[node.Row, node.Col].UnlockSlot(); } } }); } } internal void Clear() { for (int i = 0; i < _slots.GetLength(0); i++) { for (int j = 0; j < _slots.GetLength(1); j++) { if (((Component)_slots[i, j]).transform.childCount > 0) { Object.Destroy((Object)(object)((Component)((Component)_slots[i, j]).transform.GetChild(0)).gameObject); } } } } } public class InventoryHoldComponent : MonoBehaviour, IDropHandler, IEventSystemHandler { public static InventoryHoldComponent Instance; private static Transform _listTarget; private static List _elements; private void Awake() { Instance = this; if (((Component)this).transform.childCount > 0) { _listTarget = ((Component)this).transform.GetChild(0); } else { _listTarget = ((Component)this).transform; } _elements = new List(); } public void AddToHold(InventoryItem item) { InventoryHoldElement inventoryHoldElement = ComponentBuilder.BuildHoldElement(_listTarget, ((object)(UniquePickup)(ref item.Pickup)).ToString()); inventoryHoldElement.Initialize(item); ((Component)inventoryHoldElement).transform.SetParent(_listTarget); _elements.Add(inventoryHoldElement); } public void RemoveFromHold(InventoryItem item) { InventoryHoldElement inventoryHoldElement = _elements.Find((InventoryHoldElement element) => element.Item == item); _elements.Remove(inventoryHoldElement); if (Object.op_Implicit((Object)(object)inventoryHoldElement)) { Object.Destroy((Object)(object)((Component)inventoryHoldElement).gameObject); } } public void OnDrop(PointerEventData eventData) { InventoryItemElement component = eventData.pointerDrag.GetComponent(); if (!((Object)(object)component == (Object)null) && (component.Item.IsDroppable || component.DragSource != DragSource.GRID) && component.DragSource != DragSource.NONEQUIP) { InventoryItem item = component.Item; Object.Destroy((Object)(object)((Component)component).gameObject); InventoryUI.Instance.AddToHold(item); } } internal void Clear() { foreach (InventoryHoldElement element in _elements) { Object.Destroy((Object)(object)((Component)element).gameObject); } } } public class InventoryHoldElement : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { public InventoryItem Item; private TextMeshProUGUI _titleLbl; private TextMeshProUGUI _stackLbl; private Image _icon; private TooltipProvider _tooltip; public void Initialize(InventoryItem item) { //IL_003f: 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) Item = item; _icon = ((Component)((Component)this).transform.GetChild(0)).GetComponent(); TextMeshProUGUI[] componentsInChildren = ((Component)this).GetComponentsInChildren(); _titleLbl = componentsInChildren[0]; _stackLbl = componentsInChildren[1]; _icon.sprite = UIAssetService.GetPickupSprite(item.Pickup); Item.OnStackCountChanged += UpdateLabels; _tooltip = ((Component)this).gameObject.AddComponent(); _tooltip.SetContent(Item.GetTooltipContent()); UpdateLabels(); } private void OnDestroy() { Item.OnStackCountChanged -= UpdateLabels; } public void UpdateLabels() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_titleLbl != (Object)null) { ((TMP_Text)_titleLbl).text = Language.GetString(((PickupIndex)(ref Item.Pickup.pickupIndex)).pickupDef.nameToken); } if ((Object)(object)_stackLbl != (Object)null) { ((TMP_Text)_stackLbl).text = $"Stack: {Item.StackCount}"; } _tooltip.SetContent(Item.GetTooltipContent()); } public void OnBeginDrag(PointerEventData eventData) { InventoryItemElement inventoryItemElement = ComponentBuilder.BuildItemElement(((object)(UniquePickup)(ref Item.Pickup)).ToString()); inventoryItemElement.Initialize(Item, DragSource.HOLD); ((Component)inventoryItemElement).transform.SetParent(((Component)InventoryUI.Instance).transform); eventData.pointerDrag = ((Component)inventoryItemElement).gameObject; ExecuteEvents.beginDragHandler.Invoke((IBeginDragHandler)(object)inventoryItemElement, (BaseEventData)(object)eventData); InventoryModel.RemoveFromHold(Item); Object.Destroy((Object)(object)((Component)this).gameObject); } public void OnDrag(PointerEventData eventData) { } public void OnEndDrag(PointerEventData eventData) { } } public enum DragSource { HOLD, GRID, NONEQUIP } public class InventoryItemElement : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IEndDragHandler, IDragHandler { private const int MAX_ROTATION = 4; private Image _icon; private TextMeshProUGUI _label; public InventoryItem Item; private CanvasGroup _canvasGroup; private Transform dropTarget; private int _orientationTarget; public DragSource DragSource; private TooltipProvider _tooltip; public void Initialize(InventoryItem item, DragSource dragSource) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) Item = item; _icon = ((Component)this).GetComponentInChildren(); _label = ((Component)this).GetComponentInChildren(); _canvasGroup = ((Component)this).GetComponent(); if (!item.IsEquippable) { _canvasGroup.blocksRaycasts = false; } _icon.sprite = UIAssetService.GetPickupSprite(Item.Pickup); ((TMP_Text)_label).text = Item.StackCount.ToString(); item.OnStackCountChanged += UpdateStackCountLabel; DragSource = dragSource; _tooltip = ((Component)this).gameObject.AddComponent(); _tooltip.SetContent(Item.GetTooltipContent()); } public void UpdateStackCountLabel() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)_label).text = Item.StackCount.ToString(); _tooltip.SetContent(Item.GetTooltipContent()); } private void OnDestroy() { Item.OnStackCountChanged -= UpdateStackCountLabel; } public void Rotate() { Item.Rotate(); _orientationTarget = (_orientationTarget + 1) % 4; } public void OnBeginDrag(PointerEventData eventData) { SetDropTarget(((Component)this).transform.parent); InventorySlotComponent component; if (Object.op_Implicit((Object)(object)(component = ((Component)((Component)this).transform.parent).GetComponent()))) { component.UnslotItem(); } ((Component)this).transform.SetParent(((Component)this).transform.root); ((Component)this).transform.SetAsLastSibling(); _orientationTarget = 0; InventoryUI.Instance.SetCursorElement(this); _canvasGroup.alpha = 0.5f; _canvasGroup.blocksRaycasts = false; } public void OnDrag(PointerEventData eventData) { //IL_0008: 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) ((Component)this).transform.position = Vector2.op_Implicit(eventData.position); } public void OnEndDrag(PointerEventData eventData) { for (int i = 0; i < 4; i++) { if (_orientationTarget == 0) { break; } Rotate(); } InventorySlotComponent component; if (Object.op_Implicit((Object)(object)(component = ((Component)dropTarget).GetComponent()))) { component.SlotItem(this); } else { ((Component)this).transform.SetParent(dropTarget); } _canvasGroup.alpha = 1f; _canvasGroup.blocksRaycasts = true; InventoryUI.Instance.SetCursorElement(null); } public void SetDropTarget(Transform target) { dropTarget = target; _orientationTarget = 0; } } public class InventoryNonEquipComponent : MonoBehaviour { private List _elements; public static Transform _listTarget; public void Awake() { _elements = new List(); if (((Component)this).transform.childCount > 0) { _listTarget = ((Component)this).transform.GetChild(0); } else { _listTarget = ((Component)this).transform; } } public void AddItem(InventoryItem item) { InventoryItemElement inventoryItemElement = ComponentBuilder.BuildItemElement(((object)(UniquePickup)(ref item.Pickup)).ToString()); inventoryItemElement.Initialize(item, DragSource.NONEQUIP); ((Component)inventoryItemElement).transform.SetParent(_listTarget); _elements.Add(inventoryItemElement); } internal void RemoveFromNonEquip(InventoryItem inventoryItem) { InventoryItemElement inventoryItemElement = _elements.Find((InventoryItemElement item) => item.Item == inventoryItem); _elements.Remove(inventoryItemElement); Object.Destroy((Object)(object)((Component)inventoryItemElement).gameObject); } internal void Clear() { foreach (InventoryItemElement element in _elements) { Object.Destroy((Object)(object)((Component)element).gameObject); } } } public struct SlotPaintParams { public Color baseColor; public Color outlineColor; public bool AdjT; public bool AdjB; public bool AdjL; public bool AdjR; } public class InventorySlotComponent : MonoBehaviour, IDropHandler, IEventSystemHandler, IPointerEnterHandler { private const float OUTLINE_THICKNESS = 0.05f; private GridPosition _pos; private InventoryGridComponent _parentGrid; private InventoryItem _item; private InventoryItemElement _itemElement; private InventoryLock _slotLock; private TooltipProvider _tooltipProvider; private Image _img; public void Initialize(InventoryGridComponent parentGrid, GridPosition pos) { _img = ((Component)this).GetComponent(); _tooltipProvider = ((Component)this).GetComponent(); _parentGrid = parentGrid; _pos = pos; ((Behaviour)_tooltipProvider).enabled = false; } public void Occupy(InventoryItem item) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) _item = item; ((Behaviour)_tooltipProvider).enabled = true; _tooltipProvider.SetContent(_item.GetTooltipContent()); } public void UnOccupy() { _item = null; ((Behaviour)_tooltipProvider).enabled = false; } public void Paint(Color baseColor) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) ((Graphic)_img).color = baseColor; _img.sprite = UIAssetService.GetTileSprite(UIAssetService.SpriteTileType.TILExTBLR); } public void Paint(Color baseColor, bool isLocked, bool AdjT, bool AdjB, bool AdjL, bool AdjR) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) ((Graphic)_img).color = baseColor; _img.sprite = UIAssetService.GetTileSprite(isLocked, !AdjT, !AdjB, !AdjL, !AdjR); } public void SlotItem(InventoryItemElement element) { _parentGrid.SetItemAt(element.Item, _pos); _itemElement = element; ((Component)element).transform.SetParent(((Component)this).transform); } public InventoryItemElement UnslotItem() { _parentGrid.UnsetItemAt(_item, _pos); InventoryItemElement itemElement = _itemElement; _itemElement = null; return itemElement; } public void OnDrop(PointerEventData eventData) { InventoryItemElement component = eventData.pointerDrag.GetComponent(); if (!((Object)(object)component == (Object)null) && component.DragSource != DragSource.NONEQUIP) { if (InventoryModel.IsValidItemPosition(component.Item, _pos)) { component.SetDropTarget(((Component)this).transform); component.DragSource = DragSource.GRID; } else if (component.DragSource == DragSource.HOLD) { InventoryHoldComponent.Instance.AddToHold(component.Item); Object.Destroy((Object)(object)((Component)component).gameObject); } } } public void OnPointerEnter(PointerEventData eventData) { _parentGrid.UpdateCursorPosition(_pos); } public void LockSlot(InventoryLock slotLock) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) _slotLock = slotLock; ((Behaviour)_tooltipProvider).enabled = true; _tooltipProvider.SetContent(new TooltipContent { titleColor = UIConstants.COLOR_TOOLTIP_TITLE_SLOT_LOCKED, bodyColor = UIConstants.COLOR_TOOLTIP_BODY_SLOT_LOCKED, titleToken = "Slot Locked", bodyToken = $"Unlocks at Level {slotLock.UnlockLevel}." }); } public void UnlockSlot() { _slotLock = null; ((Behaviour)_tooltipProvider).enabled = false; } } public class R2Tooltip : MonoBehaviour { private TextMeshProUGUI _headerText; private TextMeshProUGUI _bodyText; private CanvasGroup _group; public void Initialize(TextMeshProUGUI headerText, TextMeshProUGUI bodyText, CanvasGroup group) { _headerText = headerText; _bodyText = bodyText; _group = group; _group.blocksRaycasts = false; } public void UpdateContext(R2TooltipContext context) { ((TMP_Text)_headerText).text = context.Title; ((TMP_Text)_bodyText).text = context.Body; } public void Show() { _group.alpha = 1f; } public void Hide() { _group.alpha = 0f; } } public class R2TooltipProvider : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerMoveHandler { private static R2Tooltip _tooltipInstance; private R2TooltipContext _context; private void Awake() { if ((Object)(object)_tooltipInstance == (Object)null) { _tooltipInstance = ComponentBuilder.BuildR2TooltipComponent("Tooltip"); ((Component)_tooltipInstance).transform.SetParent(((Component)InventoryUI.Instance).transform); } } public void Initialize(R2TooltipContext context) { _context = context; } public void SetTooltipVisiblity(bool show) { if (show) { _tooltipInstance.UpdateContext(_context); _tooltipInstance.Show(); } else { _tooltipInstance.Hide(); } } public void OnPointerEnter(PointerEventData eventData) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((Component)_tooltipInstance).gameObject.transform.position = Vector2.op_Implicit(eventData.position); SetTooltipVisiblity(show: true); } public void OnPointerMove(PointerEventData eventData) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((Component)_tooltipInstance).gameObject.transform.position = Vector2.op_Implicit(eventData.position); } public void OnPointerExit(PointerEventData eventData) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((Component)_tooltipInstance).gameObject.transform.position = Vector2.op_Implicit(eventData.position); SetTooltipVisiblity(show: false); } public void ForceShow() { _tooltipInstance.Show(); } public void ForceHide() { _tooltipInstance.Hide(); } } public struct R2TooltipContext { public string Title; public string Body; public Color HeaderBkg; } } namespace R2InventoryArtifact.UI.Builders { public static class ComponentBuilder { private enum AnchorPreset { START, CENTER, END, STRETCH } public static GameObject BuildScrollView(Transform parent, string objName = "", bool horizontal = false, bool vertical = false) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) RectTransform val = BuildPanel(parent, objName, UIAssetService.SpritePanelType.HEADER); GameObject gameObject = ((Component)val).gameObject; ScrollRect val2 = ((Component)val).gameObject.AddComponent(); val2.horizontal = horizontal; val2.vertical = vertical; val2.inertia = false; val2.movementType = (MovementType)2; RectTransform val3 = BuildPanel(gameObject.transform, "Viewport"); SetRectTransformAnchor(val3, AnchorPreset.STRETCH, AnchorPreset.STRETCH); val3.pivot = Vector2.zero; ((Component)val3).gameObject.AddComponent().showMaskGraphic = false; val2.viewport = ((Component)val3).GetComponent(); RectTransform val4 = BuildPanel(((Component)val3).transform, "Content", UIAssetService.SpritePanelType.BACKDROP); SetRectTransformAnchor(val4, (!horizontal || vertical) ? AnchorPreset.STRETCH : AnchorPreset.START, (!vertical || horizontal) ? AnchorPreset.STRETCH : AnchorPreset.START); ContentSizeFitter val5 = ((Component)val4).gameObject.AddComponent(); if (horizontal) { val5.horizontalFit = (FitMode)1; } if (vertical) { val5.verticalFit = (FitMode)1; } val2.content = val4; if (horizontal) { val2.horizontalScrollbar = BuildScrollBar(gameObject.transform, (Direction)0); val2.horizontalScrollbarVisibility = (ScrollbarVisibility)2; val2.horizontalScrollbarSpacing = -3f; } if (vertical) { val2.verticalScrollbar = BuildScrollBar(gameObject.transform, (Direction)2); val2.verticalScrollbarVisibility = (ScrollbarVisibility)2; val2.verticalScrollbarSpacing = -3f; } gameObject.transform.SetParent(parent); return ((Component)val4).gameObject; } private static Scrollbar BuildScrollBar(Transform parent, Direction direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_003e: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) bool flag = (int)direction == 0 || (int)direction == 1; string objName = (flag ? "HScrollBar" : "VScrollBar"); RectTransform val = BuildPanel(parent, objName, UIAssetService.SpritePanelType.BACKDROP); SetRectTransformAnchor(val, flag ? AnchorPreset.STRETCH : AnchorPreset.END, (!flag) ? AnchorPreset.STRETCH : AnchorPreset.START, (flag ? Vector2.up : Vector2.right) * 8f); val.pivot = (flag ? Vector2.zero : Vector2.one); Scrollbar val2 = ((Component)val).gameObject.AddComponent(); val2.direction = direction; RectTransform val3 = BuildRect(((Component)val).gameObject.transform, "SlidingArea"); SetRectTransformAnchor(val3, AnchorPreset.STRETCH, AnchorPreset.STRETCH); val3.sizeDelta = Vector2.zero; val3.offsetMin = Vector2.zero; val3.offsetMax = Vector2.zero; RectTransform val5 = (val2.handleRect = BuildPanel(((Component)val3).transform, "Handle")); SetRectTransformAnchor(val5, AnchorPreset.STRETCH, AnchorPreset.STRETCH); ((Selectable)val2).targetGraphic = (Graphic)(object)((Component)val5).GetComponent(); return val2; } public static RectTransform BuildRect(Transform parent, string objName = "") { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(objName); RectTransform result = val.AddComponent(); val.transform.SetParent(parent); return result; } public static RectTransform BuildPanel(Transform parent, string objName = "", UIAssetService.SpritePanelType panelType = UIAssetService.SpritePanelType.NONE) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(objName); RectTransform result = val.AddComponent(); val.AddComponent(); Image val2 = val.AddComponent(); if (panelType != 0) { val2.sprite = UIAssetService.GetUISprite(panelType); val2.type = (Type)1; } val.transform.SetParent(parent); return result; } public static RectTransform BuildTile(Transform parent, string objName = "", UIAssetService.SpriteTileType tileType = UIAssetService.SpriteTileType.TILExTBLR) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(objName); RectTransform result = val.AddComponent(); val.AddComponent(); Image val2 = val.AddComponent(); val2.sprite = UIAssetService.GetTileSprite(tileType); val2.type = (Type)1; val.transform.SetParent(parent); return result; } private static void SetRectTransformAnchor(RectTransform transform, AnchorPreset horizontal, AnchorPreset vertical, Vector2 sizeDelta = default(Vector2)) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = 0f; float num3 = 0f; float num4 = 0f; switch (horizontal) { case AnchorPreset.START: num = (num2 = 0f); break; case AnchorPreset.CENTER: num = (num2 = 0.5f); break; case AnchorPreset.END: num = (num2 = 1f); break; case AnchorPreset.STRETCH: num = 0f; num2 = 1f; break; } switch (vertical) { case AnchorPreset.START: num3 = (num4 = 0f); break; case AnchorPreset.CENTER: num3 = (num4 = 0.5f); break; case AnchorPreset.END: num3 = (num4 = 1f); break; case AnchorPreset.STRETCH: num3 = 0f; num4 = 1f; break; } transform.anchorMin = new Vector2(num, num3); transform.anchorMax = new Vector2(num2, num4); transform.sizeDelta = sizeDelta; transform.pivot = Vector2.one; if (horizontal == AnchorPreset.STRETCH && vertical == AnchorPreset.STRETCH) { transform.offsetMin = Vector2.zero; transform.offsetMax = Vector2.zero; } } public static InventoryDropComponent BuildInventoryDropComponent(Transform parent) { RectTransform val = BuildPanel(parent, "DropArea", UIAssetService.SpritePanelType.DROP_ZONE); return ((Component)val).gameObject.AddComponent(); } public static InventoryHoldComponent BuildInventoryHoldComponent(Transform parent) { GameObject val = BuildScrollView(parent, "HoldList", horizontal: false, vertical: true); VerticalLayoutGroup val2 = val.AddComponent(); ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).spacing = 8f; return ((Component)val.transform.parent).gameObject.AddComponent(); } public static InventoryNonEquipComponent BuildInventoryNonEquipComponent(Transform parent) { GameObject val = BuildScrollView(parent, "NonEqiup", horizontal: true); HorizontalLayoutGroup val2 = val.AddComponent(); ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = true; return val.AddComponent(); } public static InventoryEffectComponent BuildInventoryEffectComponent(Transform parent) { GameObject val = BuildScrollView(parent, "EffectList", horizontal: false, vertical: true); return val.AddComponent(); } public static InventoryGridComponent BuildInventoryGridComponent(Transform parent) { GameObject val = BuildScrollView(parent, "Grid", horizontal: true, vertical: true); return val.AddComponent(); } public static InventoryUI BuildInventoryUI(Transform parent) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown RectTransform val = BuildPanel(parent, "InventoryUI", UIAssetService.SpritePanelType.BACKDROP); GameObject gameObject = ((Component)val).gameObject; gameObject.layer = LayerIndex.ui.intVal; Canvas val2 = gameObject.AddComponent(); val2.sortingOrder = 10; val2.renderMode = (RenderMode)0; gameObject.AddComponent(); CanvasScaler val3 = gameObject.AddComponent(); val3.uiScaleMode = (ScaleMode)1; val3.referenceResolution = new Vector2(1920f, 1080f); val3.screenMatchMode = (ScreenMatchMode)1; gameObject.AddComponent(); BentoLayoutGroup bentoLayoutGroup = gameObject.AddComponent(); bentoLayoutGroup.Spans = new List { new BentoSpan { Col = 0, Row = 0, ColSpan = 2, RowSpan = 7 }, new BentoSpan { Col = 0, Row = 7, ColSpan = 2, RowSpan = 3 }, new BentoSpan { Col = 2, Row = 1, ColSpan = 8, RowSpan = 9 }, new BentoSpan { Col = 2, Row = 0, ColSpan = 8, RowSpan = 1 } }; int num = 8; int num2 = (int)(val3.referenceResolution.x * PluginConfig.UIHorizontalPadding.Value * 0.1f); int num3 = (int)(val3.referenceResolution.y * PluginConfig.UIVerticalPadding.Value * 0.1f); bentoLayoutGroup.UnitWidth = 10; bentoLayoutGroup.UnitHeight = 10; bentoLayoutGroup.Spacing = num; ((LayoutGroup)bentoLayoutGroup).padding = new RectOffset(num2, num2, num3, num3); return gameObject.AddComponent(); } public static InventorySlotComponent BuildGridSlot(Transform parent, string objName = "") { RectTransform val = BuildTile(parent, objName); GameObject gameObject = ((Component)val).gameObject; gameObject.AddComponent(); gameObject.AddComponent(); return gameObject.AddComponent(); } public static InventoryItemElement BuildItemElement(string objName = "") { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown GameObject val = new GameObject(objName); val.AddComponent(); val.AddComponent(); val.AddComponent(); val.AddComponent(); val.AddComponent(); AspectRatioFitter val2 = val.AddComponent(); val2.aspectMode = (AspectMode)2; val2.aspectRatio = 1f; GameObject val3 = new GameObject("label"); val3.AddComponent(); TextMeshProUGUI val4 = val3.AddComponent(); ((TMP_Text)val4).horizontalAlignment = (HorizontalAlignmentOptions)4; ((TMP_Text)val4).verticalAlignment = (VerticalAlignmentOptions)1024; val3.transform.SetParent(val.transform); return val.AddComponent(); } public static InventoryEffectElement BuildEffectElement(string objName = "") { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0011: 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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown GameObject val = new GameObject(objName); RectTransform val2 = val.AddComponent(); val2.sizeDelta = new Vector2(val2.sizeDelta.x, 40f); val.AddComponent(); val.AddComponent(); val.AddComponent(); GameObject val3 = new GameObject("label"); val3.AddComponent(); TextMeshProUGUI val4 = val3.AddComponent(); ((TMP_Text)val4).fontSize = 12f; ((TMP_Text)val4).autoSizeTextContainer = true; val3.transform.SetParent(val.transform); return val.AddComponent(); } public static InventoryHoldElement BuildHoldElement(Transform parent, string objName = "") { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown RectTransform val = BuildPanel(null, objName, UIAssetService.SpritePanelType.ELEMENT); GameObject gameObject = ((Component)val).gameObject; gameObject.AddComponent(); LayoutElement val2 = gameObject.AddComponent(); val2.flexibleHeight = 1f; val2.minHeight = 75f; val2.preferredHeight = 75f; BentoLayoutGroup bentoLayoutGroup = gameObject.AddComponent(); bentoLayoutGroup.UnitWidth = 8; bentoLayoutGroup.UnitHeight = 4; bentoLayoutGroup.Spans = new List { new BentoSpan { Col = 0, Row = 0, ColSpan = 3, RowSpan = 4 }, new BentoSpan { Col = 3, Row = 0, ColSpan = 5, RowSpan = 2 }, new BentoSpan { Col = 3, Row = 2, ColSpan = 5, RowSpan = 2 } }; GameObject val3 = new GameObject("icon"); val3.AddComponent(); val3.AddComponent(); AspectRatioFitter val4 = val3.AddComponent(); val4.aspectMode = (AspectMode)1; val4.aspectRatio = 1f; val3.transform.SetParent(gameObject.transform); GameObject val5 = new GameObject("title"); val5.AddComponent(); TextMeshProUGUI val6 = val5.AddComponent(); ((TMP_Text)val6).fontSize = 16f; val5.transform.SetParent(gameObject.transform); GameObject val7 = new GameObject("stack"); val7.AddComponent(); TextMeshProUGUI val8 = val7.AddComponent(); ((TMP_Text)val8).fontSize = 16f; val7.transform.SetParent(gameObject.transform); return gameObject.AddComponent(); } public static R2Tooltip BuildR2TooltipComponent(string objName = "") { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown GameObject val = new GameObject(objName); RectTransform val2 = val.AddComponent(); val2.sizeDelta = new Vector2(200f, 100f); val2.pivot = Vector2.up; ((Transform)val2).position = Vector2.op_Implicit(Vector2.zero); val.AddComponent(); CanvasGroup group = val.AddComponent(); VerticalLayoutGroup val3 = val.AddComponent(); ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = true; GameObject val4 = new GameObject("header"); val4.AddComponent().sizeDelta = new Vector2(200f, 50f); Image val5 = val4.AddComponent(); val4.AddComponent(); val4.transform.SetParent(val.transform); GameObject val6 = new GameObject("headerLbl"); val6.AddComponent(); TextMeshProUGUI val7 = val6.AddComponent(); ((TMP_Text)val7).fontSize = 12f; val6.transform.SetParent(val4.transform); GameObject val8 = new GameObject("body"); val8.AddComponent(); val8.AddComponent(); val8.AddComponent(); val8.transform.SetParent(val.transform); GameObject val9 = new GameObject("bodyLbl"); val9.AddComponent(); TextMeshProUGUI val10 = val9.AddComponent(); ((TMP_Text)val10).fontSize = 12f; val9.transform.SetParent(val8.transform); R2Tooltip r2Tooltip = val.AddComponent(); r2Tooltip.Initialize(val7, val10, group); r2Tooltip.Hide(); return r2Tooltip; } } } namespace R2InventoryArtifact.Hooks { internal struct ItemAddResult { public ItemIndex ItemIndex; public int Delta; } public class InventoryDeltaHook : MonoBehaviour { private Dictionary permaItemSet; private Dictionary tempItemSet; private CharacterMaster CharacterMaster; private bool _isInRun = false; private List _FORCE_ITEMS_TO_NONEQUIP = new List(); private CharacterBody PlayerBody { get { CharacterMaster characterMaster = CharacterMaster; return (characterMaster != null) ? characterMaster.GetBody() : null; } } private void Initialize() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) permaItemSet = new Dictionary(); tempItemSet = new Dictionary(); _FORCE_ITEMS_TO_NONEQUIP = new List { Items.LowerPricedChests.itemIndex, Items.RegeneratingScrap.itemIndex }; } private void HandleItemAdd(UniquePickup pickup, bool toNonEquip, int count) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < count; i++) { InventoryResultCode inventoryResultCode = UIHook.InventoryUI.AddToInventory(pickup, toNonEquip); if (Object.op_Implicit((Object)(object)UIHook.InventoryUI) && (inventoryResultCode == InventoryResultCode.HOLD_INSERT || inventoryResultCode == InventoryResultCode.HOLD_UPDATE)) { UIHook.InventoryUI.SetUIVisibility(show: true); } } } private void HandleItemRemove(UniquePickup pickup, bool fromNonEquip, int count) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) UIHook.InventoryUI.RemoveFromInventory(pickup, fromNonEquip, count); } private void HandleItemDrop(UniquePickup pickup, int count) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Invalid comparison between Unknown and I4 //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)PlayerBody == (Object)null) { return; } if ((int)((PickupIndex)(ref pickup.pickupIndex)).pickupDef.itemIndex != -1) { if (((UniquePickup)(ref pickup)).isTempItem) { PlayerBody.inventory.RemoveItemTemp(((PickupIndex)(ref pickup.pickupIndex)).pickupDef.itemIndex, (float)count); } else { PlayerBody.inventory.RemoveItemPermanent(((PickupIndex)(ref pickup.pickupIndex)).pickupDef.itemIndex, count); } } else if ((int)((PickupIndex)(ref pickup.pickupIndex)).pickupDef.equipmentIndex != -1) { for (int i = 0; i < count; i++) { PlayerBody.inventory.RemoveEquipment(((PickupIndex)(ref pickup.pickupIndex)).pickupDef.equipmentIndex); } } for (int j = 0; j < count; j++) { Vector3 val = (PlayerBody.transform.forward + PlayerBody.transform.up) * 10f; PickupDropletController.CreatePickupDroplet(pickup, PlayerBody.transform.position, val, false); } } private List FindInventoryDelta(Dictionary prev, ItemCollection cur) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) List list = new List(); ReadOnlySpan nonZeroIndicesSpan = ((ItemCollection)(ref cur)).GetNonZeroIndicesSpan(); for (int i = 0; i < nonZeroIndicesSpan.Length; i++) { ItemIndex val = nonZeroIndicesSpan[i]; int valueOrDefault = prev.GetValueOrDefault(val, 0); int stackValue = ((ItemCollection)(ref cur)).GetStackValue(val); int num = stackValue - valueOrDefault; if (num != 0) { if (stackValue == 0 && prev.ContainsKey(val)) { prev.Remove(val); } else { prev[val] = stackValue; } list.Add(new ItemAddResult { ItemIndex = val, Delta = num }); } } List list2 = prev.Keys.ToList(); foreach (ItemIndex item in list2) { int valueOrDefault2 = prev.GetValueOrDefault(item, 0); int stackValue2 = ((ItemCollection)(ref cur)).GetStackValue(item); int num2 = stackValue2 - valueOrDefault2; if (num2 != 0) { if (stackValue2 == 0 && prev.ContainsKey(item)) { prev.Remove(item); } else { prev[item] = stackValue2; } list.Add(new ItemAddResult { ItemIndex = item, Delta = num2 }); } } List voidItemTiers = new List(4) { (ItemTier)6, (ItemTier)9, (ItemTier)7, (ItemTier)8 }; list.Sort(delegate(ItemAddResult a, ItemAddResult b) { //IL_0008: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) int num3 = (voidItemTiers.Contains(ItemCatalog.GetItemDef(a.ItemIndex).tier) ? 1 : 0); int num4 = (voidItemTiers.Contains(ItemCatalog.GetItemDef(a.ItemIndex).tier) ? 1 : 0); return num3 - num4; }); return list; } private void Inventory_onInventoryChangedGlobal(Inventory inventory) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)PlayerBody) || !((Object)(object)PlayerBody.inventory == (Object)(object)inventory)) { return; } List list = FindInventoryDelta(permaItemSet, inventory.permanentItemStacks); List list2 = FindInventoryDelta(tempItemSet, inventory.tempItemsStorage.tempItemStacks); UniquePickup pickup = default(UniquePickup); foreach (ItemAddResult item in list) { ItemDef itemDef = ItemCatalog.GetItemDef(item.ItemIndex); bool flag = _FORCE_ITEMS_TO_NONEQUIP.Contains(item.ItemIndex) || ((Object)(object)itemDef != (Object)null && itemDef.isConsumed); ((UniquePickup)(ref pickup))..ctor(PickupCatalog.FindPickupIndex(item.ItemIndex)); if (item.Delta > 0) { HandleItemAdd(pickup, flag, item.Delta); } else { HandleItemRemove(pickup, flag, Math.Abs(item.Delta)); } } UniquePickup pickup2 = default(UniquePickup); foreach (ItemAddResult item2 in list2) { ((UniquePickup)(ref pickup2))..ctor(PickupCatalog.FindPickupIndex(item2.ItemIndex)); pickup2.decayValue = 80f; if (item2.Delta > 0) { HandleItemAdd(pickup2, toNonEquip: true, item2.Delta); } else { HandleItemRemove(pickup2, fromNonEquip: true, Math.Abs(item2.Delta)); } } } private void CharacterBody_OnEquipmentLost(orig_OnEquipmentLost orig, CharacterBody self, EquipmentDef equipmentDef) { //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_002f: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, equipmentDef); if (!((Object)(object)PlayerBody != (Object)(object)self)) { UniquePickup pickup = default(UniquePickup); ((UniquePickup)(ref pickup))..ctor(PickupCatalog.FindPickupIndex(equipmentDef.equipmentIndex)); HandleItemRemove(pickup, fromNonEquip: false, 1); } } private void CharacterBody_OnEquipmentGained(orig_OnEquipmentGained orig, CharacterBody self, EquipmentDef equipmentDef) { //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_002f: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, equipmentDef); if (!((Object)(object)PlayerBody != (Object)(object)self)) { UniquePickup pickup = default(UniquePickup); ((UniquePickup)(ref pickup))..ctor(PickupCatalog.FindPickupIndex(equipmentDef.equipmentIndex)); HandleItemAdd(pickup, toNonEquip: false, 1); } } private void Awake() { _isInRun = false; Run.onRunStartGlobal += delegate { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown if (InventoryArtifactProvider.IsEnabled()) { _isInRun = true; UIHook.OnInventoryItemDropped = (Action)Delegate.Combine(UIHook.OnInventoryItemDropped, new Action(HandleItemDrop)); UIHook.OnInitializeUI = (Action)Delegate.Combine(UIHook.OnInitializeUI, new Action(Initialize)); CharacterMaster = PlayerCharacterMasterController.instances[0].master; CharacterBody.OnEquipmentGained += new hook_OnEquipmentGained(CharacterBody_OnEquipmentGained); CharacterBody.OnEquipmentLost += new hook_OnEquipmentLost(CharacterBody_OnEquipmentLost); Inventory.onInventoryChangedGlobal += Inventory_onInventoryChangedGlobal; } }; Run.onRunDestroyGlobal += delegate { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown if (InventoryArtifactProvider.IsEnabled() && _isInRun) { _isInRun = false; UIHook.OnInventoryItemDropped = (Action)Delegate.Remove(UIHook.OnInventoryItemDropped, new Action(HandleItemDrop)); UIHook.OnInitializeUI = (Action)Delegate.Remove(UIHook.OnInitializeUI, new Action(Initialize)); CharacterBody.OnEquipmentGained -= new hook_OnEquipmentGained(CharacterBody_OnEquipmentGained); CharacterBody.OnEquipmentLost -= new hook_OnEquipmentLost(CharacterBody_OnEquipmentLost); Inventory.onInventoryChangedGlobal -= Inventory_onInventoryChangedGlobal; } }; } } public class InventoryHook : MonoBehaviour { private Dictionary tempItemDict; private List _FORCE_ITEMS_TO_NONEQUIP = new List(); private List _ITEM_BLACKLIST = new List(); private bool _isInRun = false; public void InitializeInventoryHook() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) tempItemDict = new Dictionary(); _FORCE_ITEMS_TO_NONEQUIP = new List { Items.LowerPricedChests.itemIndex, Items.LowerPricedChestsConsumed.itemIndex, Items.RegeneratingScrap.itemIndex, Items.RegeneratingScrapConsumed.itemIndex, Items.ExtraLifeConsumed.itemIndex, Items.ExtraLifeVoidConsumed.itemIndex, Items.HealingPotionConsumed.itemIndex, Items.FragileDamageBonusConsumed.itemIndex, Items.TeleportOnLowHealthConsumed.itemIndex }; } private bool IsPlayerInventory(Inventory inventory) { CharacterMaster componentInParent = ((Component)inventory).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return false; } return (Object)(object)UIHook.PlayerBody != (Object)null && (Object)(object)componentInParent.GetBody() == (Object)(object)UIHook.PlayerBody; } private void HandleInventoryItemDropped(UniquePickup pickup, int stackCount) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Invalid comparison between Unknown and I4 //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_0084: 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) Vector3 val = (UIHook.PlayerBody.transform.forward + UIHook.PlayerBody.transform.up) * 10f; for (int i = 0; i < stackCount; i++) { PickupDropletController.CreatePickupDroplet(pickup, UIHook.PlayerBody.transform.position, val, false); } PickupDef pickupDef = ((PickupIndex)(ref pickup.pickupIndex)).pickupDef; if ((int)pickupDef.itemIndex != -1) { UIHook.PlayerBody.inventory.RemoveItemPermanent(pickupDef.itemIndex, stackCount); } else if ((int)pickupDef.equipmentIndex != -1) { UIHook.PlayerBody.inventory.RemoveEquipment(pickupDef.equipmentIndex); } } private unsafe void HandleItemRemoved(ItemIndex itemIndex, bool isTemp, int count) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected I4, but got Unknown //IL_0094: 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) bool flag = (from f in new StackTrace(1, fNeedFileInfo: false).GetFrames() select f.GetMethod().Name).Count((string name) => name == "HandleInventoryItemDropped") > 1; if (!_ITEM_BLACKLIST.Contains(itemIndex)) { UniquePickup pickup = default(UniquePickup); ((UniquePickup)(ref pickup))..ctor(PickupCatalog.FindPickupIndex(itemIndex)); ItemDef val = (ItemDef)Unsafe.Read((void*)ItemCatalog.allItemDefs[(int)itemIndex]); bool removeFromNonEquip = isTemp || _FORCE_ITEMS_TO_NONEQUIP.Contains(itemIndex) || val.isConsumed; RemoveFromInventory(pickup, removeFromNonEquip, count); } } private void HandleEquipmentRemoved(EquipmentIndex equipIndex, int count) { //IL_005b: 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_0067: Unknown result type (might be due to invalid IL or missing references) bool flag = (from f in new StackTrace(1, fNeedFileInfo: false).GetFrames() select f.GetMethod().Name).Count((string name) => name == "HandleInventoryItemDropped") > 1; UniquePickup pickup = default(UniquePickup); ((UniquePickup)(ref pickup))..ctor(PickupCatalog.FindPickupIndex(equipIndex)); RemoveFromInventory(pickup, removeFromNonEquip: false, count); } private void RemoveFromInventory(UniquePickup pickup, bool removeFromNonEquip, int count) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)UIHook.InventoryUI)) { Log.Debug($"Removing: {pickup.pickupIndex}"); UIHook.InventoryUI.RemoveFromInventory(pickup, removeFromNonEquip, count); } } private void Inventory_RemoveItemPermanent_ItemIndex_int(orig_RemoveItemPermanent_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_0019: 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) if (IsPlayerInventory(self)) { HandleItemRemoved(itemIndex, isTemp: false, count); } orig.Invoke(self, itemIndex, count); } private void Inventory_RemoveItemPermanent_ItemDef_int(orig_RemoveItemPermanent_ItemDef_int orig, Inventory self, ItemDef itemDef, int count) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (IsPlayerInventory(self)) { HandleItemRemoved(itemDef.itemIndex, isTemp: false, count); } orig.Invoke(self, itemDef, count); } private void Inventory_RemoveItem_ItemIndex_int(orig_RemoveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_0019: 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) if (IsPlayerInventory(self)) { HandleItemRemoved(itemIndex, isTemp: false, count); } orig.Invoke(self, itemIndex, count); } private void Inventory_RemoveItem_ItemDef_int(orig_RemoveItem_ItemDef_int orig, Inventory self, ItemDef itemDef, int count) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (IsPlayerInventory(self)) { HandleItemRemoved(itemDef.itemIndex, isTemp: false, count); } orig.Invoke(self, itemDef, count); } private void Inventory_TempItemsStorage_SyncStackToDecay(orig_SyncStackToDecay orig, ref TempItemsStorage self, ItemIndex itemIndex) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(ref self, itemIndex); if (IsPlayerInventory(self.inventory)) { int valueOrDefault = tempItemDict.GetValueOrDefault(itemIndex, 0); int itemStacks = ((TempItemsStorage)(ref self)).GetItemStacks(itemIndex); if (itemStacks < valueOrDefault) { HandleItemRemoved(itemIndex, isTemp: true, valueOrDefault - itemStacks); } if (itemStacks == 0 && tempItemDict.ContainsKey(itemIndex)) { tempItemDict.Remove(itemIndex); } else { tempItemDict[itemIndex] = itemStacks; } } } private void CharacterBody_OnEquipmentLost(orig_OnEquipmentLost orig, CharacterBody self, EquipmentDef equipmentDef) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)UIHook.PlayerBody == (Object)(object)self) { HandleEquipmentRemoved(equipmentDef.equipmentIndex, 1); } orig.Invoke(self, equipmentDef); } private unsafe void HandleItemAdd(ItemIndex itemIndex, bool isTemp, int count) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected I4, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!_ITEM_BLACKLIST.Contains(itemIndex)) { UniquePickup pickup = default(UniquePickup); ((UniquePickup)(ref pickup))..ctor(PickupCatalog.FindPickupIndex(itemIndex)); ItemDef val = (ItemDef)Unsafe.Read((void*)ItemCatalog.allItemDefs[(int)itemIndex]); bool toNonEquip = isTemp || _FORCE_ITEMS_TO_NONEQUIP.Contains(itemIndex) || val.isConsumed; AddToInventory(pickup, toNonEquip, count); } } private void HandleEquipmentAdd(EquipmentIndex equipIndex, int count) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) UniquePickup pickup = default(UniquePickup); ((UniquePickup)(ref pickup))..ctor(PickupCatalog.FindPickupIndex(equipIndex)); AddToInventory(pickup, toNonEquip: false, count); } private bool AddToInventory(UniquePickup pickup, bool toNonEquip, int count) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0030: 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_0053: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = ((PickupIndex)(ref pickup.pickupIndex)).pickupDef; if ((int)pickupDef.itemIndex == -1 && (int)pickupDef.equipmentIndex == -1) { return false; } Log.Debug($"{pickup.pickupIndex}"); bool result = true; for (int i = 0; i < count; i++) { InventoryResultCode inventoryResultCode = UIHook.InventoryUI.AddToInventory(pickup, toNonEquip); switch (inventoryResultCode) { case InventoryResultCode.FAILED: result = false; continue; default: if (inventoryResultCode != InventoryResultCode.HOLD_UPDATE) { continue; } break; case InventoryResultCode.HOLD_INSERT: break; } UIHook.InventoryUI.SetUIVisibility(show: true); } return result; } private void Inventory_GiveItem_ItemIndex_int(orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_0019: 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) if (IsPlayerInventory(self)) { HandleItemAdd(itemIndex, isTemp: false, count); } orig.Invoke(self, itemIndex, count); } private void Inventory_GiveItemPermanent_ItemIndex_int(orig_GiveItemPermanent_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_0019: 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) if (IsPlayerInventory(self)) { HandleItemAdd(itemIndex, isTemp: false, count); } orig.Invoke(self, itemIndex, count); } private void Inventory_GiveItemTemp(orig_GiveItemTemp orig, Inventory self, ItemIndex itemIndex, float count) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (IsPlayerInventory(self)) { if (count > 0f) { HandleItemAdd(itemIndex, isTemp: true, (int)count); } else { HandleItemRemoved(itemIndex, isTemp: true, (int)count); } } orig.Invoke(self, itemIndex, count); } private void CharacterBody_OnEquipmentGained(orig_OnEquipmentGained orig, CharacterBody self, EquipmentDef equipmentDef) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)UIHook.PlayerBody == (Object)(object)self) { HandleEquipmentAdd(equipmentDef.equipmentIndex, 1); } orig.Invoke(self, equipmentDef); } private bool Inventory_ItemTransformation_TryTransform(orig_TryTransform orig, ref ItemTransformation self, Inventory inventory, out TryTransformResult result) { //IL_001e: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) bool flag = orig.Invoke(ref self, inventory, ref result); if ((Object)(object)UIHook.PlayerBody != (Object)null && ((NetworkBehaviour)UIHook.PlayerBody).netId == ((NetworkBehaviour)inventory).netId && flag && ((TryTransformResult)(ref result)).totalTransformed > 0) { UniquePickup pickup = default(UniquePickup); ((UniquePickup)(ref pickup))..ctor(PickupCatalog.FindPickupIndex(result.takenItem.itemIndex)); UniquePickup pickup2 = default(UniquePickup); ((UniquePickup)(ref pickup2))..ctor(PickupCatalog.FindPickupIndex(result.givenItem.itemIndex)); if (result.takenItem.stackValues.permanentStacks > 0) { RemoveFromInventory(pickup, removeFromNonEquip: false, result.takenItem.stackValues.permanentStacks); } if (result.takenItem.stackValues.temporaryStacksValue > 0f) { RemoveFromInventory(pickup, removeFromNonEquip: true, (int)result.takenItem.stackValues.temporaryStacksValue); } if (result.givenItem.stackValues.permanentStacks > 0) { AddToInventory(pickup2, ((UniquePickup)(ref pickup2)).isTempItem, result.givenItem.stackValues.permanentStacks); } if (result.givenItem.stackValues.temporaryStacksValue > 0f) { AddToInventory(pickup2, ((UniquePickup)(ref pickup2)).isTempItem, (int)result.givenItem.stackValues.temporaryStacksValue); } } return flag; } private void Awake() { Run.onRunStartGlobal += HandleRunStart; Run.onRunDestroyGlobal += HandleRunEnd; } private void HandleRunStart(Run run) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown _isInRun = false; if (InventoryArtifactProvider.IsEnabled()) { _isInRun = true; UIHook.OnInventoryItemDropped = (Action)Delegate.Combine(UIHook.OnInventoryItemDropped, new Action(HandleInventoryItemDropped)); UIHook.OnInitializeUI = (Action)Delegate.Combine(UIHook.OnInitializeUI, new Action(InitializeInventoryHook)); Inventory.GiveItemPermanent_ItemIndex_int += new hook_GiveItemPermanent_ItemIndex_int(Inventory_GiveItemPermanent_ItemIndex_int); Inventory.GiveItemTemp += new hook_GiveItemTemp(Inventory_GiveItemTemp); Inventory.GiveItem_ItemIndex_int += new hook_GiveItem_ItemIndex_int(Inventory_GiveItem_ItemIndex_int); CharacterBody.OnEquipmentGained += new hook_OnEquipmentGained(CharacterBody_OnEquipmentGained); Inventory.RemoveItemPermanent_ItemDef_int += new hook_RemoveItemPermanent_ItemDef_int(Inventory_RemoveItemPermanent_ItemDef_int); Inventory.RemoveItemPermanent_ItemIndex_int += new hook_RemoveItemPermanent_ItemIndex_int(Inventory_RemoveItemPermanent_ItemIndex_int); Inventory.RemoveItem_ItemDef_int += new hook_RemoveItem_ItemDef_int(Inventory_RemoveItem_ItemDef_int); Inventory.RemoveItem_ItemIndex_int += new hook_RemoveItem_ItemIndex_int(Inventory_RemoveItem_ItemIndex_int); CharacterBody.OnEquipmentLost += new hook_OnEquipmentLost(CharacterBody_OnEquipmentLost); TempItemsStorage.SyncStackToDecay += new hook_SyncStackToDecay(Inventory_TempItemsStorage_SyncStackToDecay); ItemTransformation.TryTransform += new hook_TryTransform(Inventory_ItemTransformation_TryTransform); } } private void HandleRunEnd(Run run) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown if (_isInRun) { _isInRun = false; UIHook.OnInventoryItemDropped = (Action)Delegate.Remove(UIHook.OnInventoryItemDropped, new Action(HandleInventoryItemDropped)); UIHook.OnInitializeUI = (Action)Delegate.Remove(UIHook.OnInitializeUI, new Action(InitializeInventoryHook)); Inventory.GiveItemPermanent_ItemIndex_int -= new hook_GiveItemPermanent_ItemIndex_int(Inventory_GiveItemPermanent_ItemIndex_int); Inventory.GiveItemTemp -= new hook_GiveItemTemp(Inventory_GiveItemTemp); Inventory.GiveItem_ItemIndex_int -= new hook_GiveItem_ItemIndex_int(Inventory_GiveItem_ItemIndex_int); CharacterBody.OnEquipmentGained -= new hook_OnEquipmentGained(CharacterBody_OnEquipmentGained); Inventory.RemoveItemPermanent_ItemDef_int -= new hook_RemoveItemPermanent_ItemDef_int(Inventory_RemoveItemPermanent_ItemDef_int); Inventory.RemoveItemPermanent_ItemIndex_int -= new hook_RemoveItemPermanent_ItemIndex_int(Inventory_RemoveItemPermanent_ItemIndex_int); Inventory.RemoveItem_ItemDef_int -= new hook_RemoveItem_ItemDef_int(Inventory_RemoveItem_ItemDef_int); Inventory.RemoveItem_ItemIndex_int -= new hook_RemoveItem_ItemIndex_int(Inventory_RemoveItem_ItemIndex_int); CharacterBody.OnEquipmentLost -= new hook_OnEquipmentLost(CharacterBody_OnEquipmentLost); TempItemsStorage.SyncStackToDecay -= new hook_SyncStackToDecay(Inventory_TempItemsStorage_SyncStackToDecay); ItemTransformation.TryTransform -= new hook_TryTransform(Inventory_ItemTransformation_TryTransform); } } } public class LevelUpHook : MonoBehaviour { private void LevelUpEffectManager_OnCharacterLevelUp(orig_OnCharacterLevelUp orig, CharacterBody characterBody) { if (Object.op_Implicit((Object)(object)UIHook.InventoryUI)) { UIHook.InventoryUI.SetPlayerLevel((int)characterBody.level); } orig.Invoke(characterBody); } private void Start() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown LevelUpEffectManager.OnCharacterLevelUp += new hook_OnCharacterLevelUp(LevelUpEffectManager_OnCharacterLevelUp); } private void OnDestroy() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown LevelUpEffectManager.OnCharacterLevelUp -= new hook_OnCharacterLevelUp(LevelUpEffectManager_OnCharacterLevelUp); } } public class UIHook : MonoBehaviour { private List _locks = new List(); private bool _isInRun = false; private bool _isPaused = false; public static Action OnInventoryItemDropped; public static Action OnInitializeUI; public static InventoryUI InventoryUI; public static NetworkUser ClientUser; private bool IsArtifactEnabled => InventoryArtifactProvider.IsEnabled() && (Object)(object)InventoryUI != (Object)null; public static CharacterBody PlayerBody { get { NetworkUser clientUser = ClientUser; return (clientUser != null) ? clientUser.master.GetBody() : null; } } private void HandleRunStart(Run run) { _isInRun = true; if (NetworkServer.active) { ClientUser = NetworkUser.instancesList.Find((NetworkUser instance) => ((NetworkBehaviour)instance).isClient); } IntRect intRect = new IntRect(PluginConfig.InventoryWidth.Value, PluginConfig.InventoryHeight.Value); _locks = GenerateGridLocks(intRect, 3); if ((Object)(object)InventoryUI != (Object)null) { Object.Destroy((Object)(object)((Component)InventoryUI).gameObject); } InventoryUI = ComponentBuilder.BuildInventoryUI(null); InventoryUI.Initialize(intRect, _locks); InventoryUI.SetUIVisibility(show: false); InventoryUI.OnUIVisibilityChanged += HandleCursorVisibility; InventoryUI.OnInventoryItemDropped += OnInventoryItemDropped; OnInitializeUI?.Invoke(); } private List GenerateGridLocks(IntRect grid, int startRow, int minLevel = 5, int maxLevel = 30) { List list = new List(); int num = Math.Max(grid.Height - startRow, 0); float num2 = (float)(maxLevel - minLevel) / (float)Math.Max(num, 1); int i; for (i = 0; i < num; i++) { list.Add(new InventoryLock { UnlockLevel = (int)Math.Ceiling((float)minLevel + (float)i * num2), Nodes = (from col in Enumerable.Range(0, grid.Width) select new GridPosition(col, startRow + i)).ToList() }); } return list; } private void HandleRunEnd(Run run) { InventoryUI.ResetInventory(); Object.Destroy((Object)(object)((Component)InventoryUI).gameObject); } private void PauseScreenController_OnEnable(orig_OnEnable orig, PauseScreenController self) { orig.Invoke(self); _isPaused = true; if (Object.op_Implicit((Object)(object)InventoryUI) && InventoryUI.IsVisible) { InventoryUI.SetUIVisibility(show: false); } } private void PauseScreenController_OnDisable(orig_OnDisable orig, PauseScreenController self) { orig.Invoke(self); _isPaused = false; InventoryUI.SetUIVisibility(show: false); } private GameEndReportPanelController GameOverController_GenerateReportScreen(orig_GenerateReportScreen orig, GameOverController self, HUD hud) { ((Component)InventoryUI).gameObject.SetActive(false); return orig.Invoke(self, hud); } private void HandleCursorVisibility(bool show) { if (!((Object)(object)InventoryUI == (Object)null) && ((Behaviour)InventoryUI).isActiveAndEnabled) { MPEventSystem primaryEventSystem = MPEventSystemManager.primaryEventSystem; primaryEventSystem.allowCursorPush = true; primaryEventSystem.cursorOpenerCount = ((show || _isPaused) ? 1 : 0); ((EventSystem)primaryEventSystem).SetSelectedGameObject((GameObject)null); } } private void Awake() { Run.onRunStartGlobal += delegate(Run run) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (InventoryArtifactProvider.IsEnabled()) { _isInRun = false; _isPaused = false; HandleRunStart(run); PauseScreenController.OnDisable += new hook_OnDisable(PauseScreenController_OnDisable); PauseScreenController.OnEnable += new hook_OnEnable(PauseScreenController_OnEnable); GameOverController.GenerateReportScreen += new hook_GenerateReportScreen(GameOverController_GenerateReportScreen); } }; Run.onRunDestroyGlobal += delegate(Run run) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown if (_isInRun) { _isInRun = false; _isPaused = false; HandleRunEnd(run); PauseScreenController.OnDisable -= new hook_OnDisable(PauseScreenController_OnDisable); PauseScreenController.OnEnable -= new hook_OnEnable(PauseScreenController_OnEnable); GameOverController.GenerateReportScreen -= new hook_GenerateReportScreen(GameOverController_GenerateReportScreen); } }; } private void Update() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!IsArtifactEnabled || _isPaused) { return; } KeyboardShortcut value; switch (PluginConfig.InventoryShowType.Value) { case InventoryShowType.ToggleShow: value = PluginConfig.ShowInventoryKey.Value; if (((KeyboardShortcut)(ref value)).IsUp()) { InventoryUI.SetUIVisibility(!InventoryUI.IsVisible); } break; case InventoryShowType.HoldToShow: value = PluginConfig.ShowInventoryKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { InventoryUI.SetUIVisibility(show: true); break; } value = PluginConfig.ShowInventoryKey.Value; if (((KeyboardShortcut)(ref value)).IsUp()) { InventoryUI.SetUIVisibility(show: false); } break; } value = PluginConfig.RotateInventoryItemKey.Value; if (((KeyboardShortcut)(ref value)).IsUp() && InventoryUI.IsVisible) { InventoryUI.RotateCursorItem(); } } } } namespace R2InventoryArtifact.Artifact { public abstract class ArtifactBase { public ArtifactDef ArtifactDef; public abstract string ArtifactName { get; } public abstract string ArtifactLangTokenName { get; } public abstract string ArtifactDescription { get; } public abstract Sprite ArtifactEnabledIcon { get; } public abstract Sprite ArtifactDisabledIcon { get; } public bool ArtifactEnabled => RunArtifactManager.instance.IsArtifactEnabled(ArtifactDef); public abstract void Init(ConfigFile config); protected void CreateLang() { LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_NAME", ArtifactName); LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION", ArtifactDescription); } protected void CreateArtifact() { ArtifactDef = ScriptableObject.CreateInstance(); ArtifactDef.cachedName = "ARTIFACT_" + ArtifactLangTokenName; ArtifactDef.nameToken = "ARTIFACT_" + ArtifactLangTokenName + "_NAME"; ArtifactDef.descriptionToken = "ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION"; ArtifactDef.smallIconSelectedSprite = ArtifactEnabledIcon; ArtifactDef.smallIconDeselectedSprite = ArtifactDisabledIcon; ContentAddition.AddArtifactDef(ArtifactDef); } public abstract void Hooks(); } public class InventoryArtifactProvider : IContentPackProvider { [CompilerGenerated] private static class <>O { public static CollectContentPackProvidersDelegate <0>__ContentManager_collectContentPackProviders; } private static string _basePath; public ContentPack ContentPack = new ContentPack(); public static ArtifactDef ArtifactDef; public string identifier => "R2InventoryArtifact.R2InventoryArtifact"; internal static void Initialize(PluginInfo pluginInfo) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown _basePath = Path.GetDirectoryName(pluginInfo.Location); LanguageAPI.Add("ARTIFACT_FOXFEN64_INVENTORY_NAME", "Artifact of Inventory"); LanguageAPI.Add("ARTIFACT_FOXFEN64_INVENTORY_DESC", "Manage your inventory."); object obj = <>O.<0>__ContentManager_collectContentPackProviders; if (obj == null) { CollectContentPackProvidersDelegate val = ContentManager_collectContentPackProviders; <>O.<0>__ContentManager_collectContentPackProviders = val; obj = (object)val; } ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj; } private static void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)new InventoryArtifactProvider()); } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(ContentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { ArtifactDef = ScriptableObject.CreateInstance(); ArtifactDef.cachedName = "ARTIFACT_FOXFEN64_INVENTORY"; ArtifactDef.nameToken = "ARTIFACT_FOXFEN64_INVENTORY_NAME"; ArtifactDef.descriptionToken = "ARTIFACT_FOXFEN64_INVENTORY_DESC"; if (!string.IsNullOrEmpty(_basePath)) { string onPath = Path.Combine(_basePath, "Assets", "aoi-on.png"); string offPath = Path.Combine(_basePath, "Assets", "aoi-off.png"); ArtifactDef.smallIconSelectedSprite = R2InventoryArtifactUtil.LoadSprite(onPath); ArtifactDef.smallIconDeselectedSprite = R2InventoryArtifactUtil.LoadSprite(offPath); } ContentPack.artifactDefs.Add((ArtifactDef[])(object)new ArtifactDef[1] { ArtifactDef }); yield break; } public static bool IsEnabled() { return Object.op_Implicit((Object)(object)RunArtifactManager.instance) && Object.op_Implicit((Object)(object)ArtifactDef) && RunArtifactManager.instance.IsArtifactEnabled(ArtifactDef); } } }