using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; using Zorro.Core.Serizalization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyTitle("PEAK Packs")] [assembly: AssemblyDescription("Faster backpack, fanny pack, and jetpack inventory for PEAK.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PEAK Packs")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("49724da6-33ea-42ab-bdcd-43d595f61a07")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace Hold_to_Open { [BepInPlugin("tony4twentys.PEAK_Packs", "PEAK Packs", "1.0.2")] [BepInProcess("PEAK.exe")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "tony4twentys.PEAK_Packs"; public const string PluginName = "PEAK Packs"; public const string PluginVersion = "1.0.2"; internal static ConfigEntry EnabledConfig; internal static ConfigEntry StoreKeyConfig; internal static ConfigEntry PutGroundItemsInWornPackConfig; internal static ConfigEntry OpenWheelWhenHeldConfig; internal static ConfigEntry OpenAnyTimeKeyConfig; internal static ConfigEntry OpenAnyTimeToggleModeConfig; internal static ConfigEntry CycleWornPackKeyConfig; internal static ConfigEntry UnlockLookWhileHeldOpenConfig; internal static ConfigEntry PackHotkeysEnabledConfig; internal static ConfigEntry PackHotkeysOnlyWhileHeldConfig; internal static ConfigEntry[] PackSlotKeyConfigs; internal static ConfigEntry PackPrivacyConfig; internal static ConfigEntry PrivacyCycleKeyConfig; internal static ConfigEntry LookOnlyAllowStashConfig; internal static ConfigEntry AllowAnyItemInPackConfig; internal static ConfigEntry AllowNestedPacksConfig; internal static ConfigEntry CarryWithPackConfig; internal static ConfigEntry OpenCarriedPackKeyConfig; internal static ConfigEntry FannyPackPositionConfig; internal static ConfigEntry ShowOwnPacksConfig; internal static ConfigEntry AllowMultipackConfig; internal static ConfigEntry AllowUtilityAndBackpackConfig; internal static ConfigEntry AllowUtilityAndFannypackConfig; internal static ConfigEntry BackpackInFrontWhenWearingUtilityConfig; internal static ConfigEntry FrontPackWhenOpenAnytimeConfig; private Harmony _harmony; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static bool IsEnabled() { return EnabledConfig == null || EnabledConfig.Value; } internal static KeyCode GetStoreKey() { //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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)((StoreKeyConfig == null) ? 102 : ((int)StoreKeyConfig.Value)); } internal static KeyCode GetOpenAnyTimeKey() { //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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)((OpenAnyTimeKeyConfig == null) ? 98 : ((int)OpenAnyTimeKeyConfig.Value)); } internal static KeyCode GetCycleWornPackKey() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)((CycleWornPackKeyConfig == null) ? 324 : ((int)CycleWornPackKeyConfig.Value)); } internal static bool IsOpenAnyTimeToggleMode() { return OpenAnyTimeToggleModeConfig != null && OpenAnyTimeToggleModeConfig.Value; } internal static PackPrivacyMode GetPackPrivacy() { return (PackPrivacyConfig == null) ? PackPrivacyMode.BlockLook : PackPrivacyConfig.Value; } internal static KeyCode GetPrivacyCycleKey() { //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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)((PrivacyCycleKeyConfig == null) ? 108 : ((int)PrivacyCycleKeyConfig.Value)); } private static bool UseHostRules() { return PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient && DualPack.HasHostRules; } internal static bool IsAllowAnyItemInPack() { if (UseHostRules()) { return DualPack.HostAllowAnyItemInPack; } return AllowAnyItemInPackConfig != null && AllowAnyItemInPackConfig.Value; } internal static bool IsCarryWithPack() { if (UseHostRules()) { return DualPack.HostKeepPackWhileCarrying; } return CarryWithPackConfig != null && CarryWithPackConfig.Value; } internal static bool IsLookOnlyAllowStash() { if (UseHostRules()) { return DualPack.HostLookOnlyAllowStash; } return LookOnlyAllowStashConfig != null && LookOnlyAllowStashConfig.Value; } internal static bool IsAllowNestedPacks() { if (UseHostRules()) { return DualPack.HostAllowNestedPacks; } return AllowNestedPacksConfig != null && AllowNestedPacksConfig.Value; } internal static bool IsShowOwnPacks() { return ShowOwnPacksConfig != null && ShowOwnPacksConfig.Value; } internal static bool IsAllowMultipack() { if (UseHostRules()) { return DualPack.HostAllowMultipack; } return AllowMultipackConfig != null && AllowMultipackConfig.Value; } internal static bool IsAllowUtilityAndBackpack() { if (!IsAllowMultipack()) { return false; } if (UseHostRules()) { return DualPack.HostAllowUtilityAndBackpack; } return AllowUtilityAndBackpackConfig != null && AllowUtilityAndBackpackConfig.Value; } internal static bool IsAllowUtilityAndFannypack() { if (!IsAllowMultipack()) { return false; } if (UseHostRules()) { return DualPack.HostAllowUtilityAndFannypack; } return AllowUtilityAndFannypackConfig != null && AllowUtilityAndFannypackConfig.Value; } internal static bool IsBackpackInFrontWhenWearingUtility() { if (!IsAllowMultipack()) { return false; } if (UseHostRules()) { return DualPack.HostBackpackInFrontWhenWearingUtility; } return BackpackInFrontWhenWearingUtilityConfig == null || BackpackInFrontWhenWearingUtilityConfig.Value; } internal static bool IsFrontPackWhenOpenAnytime() { if (UseHostRules()) { return DualPack.HostFrontPackWhenOpenAnytime; } return FrontPackWhenOpenAnytimeConfig != null && FrontPackWhenOpenAnytimeConfig.Value; } internal static float GetFrontBackpackForward() { return 0.5f; } internal static float GetFrontPackUp() { return -0.5f; } internal static float GetFrontPackYaw() { return 180f; } internal static FannyPackPosition GetFannyPackPosition() { return (FannyPackPositionConfig != null) ? FannyPackPositionConfig.Value : FannyPackPosition.Back; } internal static KeyCode GetOpenCarriedPackKey() { //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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)((OpenCarriedPackKeyConfig == null) ? 110 : ((int)OpenCarriedPackKeyConfig.Value)); } internal static bool IsPutGroundItemsInWornPack() { return PutGroundItemsInWornPackConfig == null || PutGroundItemsInWornPackConfig.Value; } internal static bool IsOpenWheelWhenHeld() { return OpenWheelWhenHeldConfig != null && OpenWheelWhenHeldConfig.Value; } internal static bool IsPackHotkeysOnlyWhileHeld() { return PackHotkeysOnlyWhileHeldConfig != null && PackHotkeysOnlyWhileHeldConfig.Value; } internal static bool IsUnlockLookWhileHeldOpen() { return UnlockLookWhileHeldOpenConfig == null || UnlockLookWhileHeldOpenConfig.Value; } private static void OnHostSettingChanged(object sender, EventArgs args) { DualPack.BroadcastHostRulesIfMaster(); } private static void OnPackPrivacySettingChanged(object sender, EventArgs args) { PrivacyHud.Show(GetPackPrivacy()); DualPack.BroadcastPrivacy(); } private void Awake() { //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; EnabledConfig = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "When enabled, PEAK Packs adds hold-to-open wheels, worn-pack opening, and put-in-pack / jetpack fuel prompts."); StoreKeyConfig = ((BaseUnityPlugin)this).Config.Bind("General", "PutInPackKey", (KeyCode)102, "Put a held item into a looked-at ground pack or your worn pack. Also used to put ground items into a worn pack if that option is enabled."); PutGroundItemsInWornPackConfig = ((BaseUnityPlugin)this).Config.Bind("General", "PutGroundItemsInWornPack", true, "If true, looking at a ground item while wearing a pack shows the put-in-pack / use-as-fuel prompt. Held items can still go straight into a pack when this is off."); OpenWheelWhenHeldConfig = ((BaseUnityPlugin)this).Config.Bind("General", "OpenWheelWhenHeld", false, "If true, putting a backpack, fanny pack, or jetpack in your hands opens its inventory wheel. If false, use OpenAnyTimeKey instead."); UnlockLookWhileHeldOpenConfig = ((BaseUnityPlugin)this).Config.Bind("General", "UnlockCameraWhenHeldOpen", true, "If true, a pack in your hands still shows the wheel but mouse look, camera, and throwing stay enabled. Use pack hotkeys to take or stash; the cursor is not captured by the wheel."); PackPrivacyConfig = ((BaseUnityPlugin)this).Config.Bind("General", "PackPrivacyMode", PackPrivacyMode.BlockLook, "Your pack lock. Other players obey this when they touch your worn or dropped pack, even if their own mode is Off. Off = unlocked. BlockLook = nobody else can open it. LookOnly = they can look but cannot take or wear it until you are down. The person carrying you can always open and take. PrivacyCycleKey cycles this like locking a door."); PrivacyCycleKeyConfig = ((BaseUnityPlugin)this).Config.Bind("General", "PrivacyCycleKey", (KeyCode)108, "Cycles your pack lock: Unlocked (Off) -> Locked (BlockLook) -> Look Only -> Unlocked. Shows a So Fly-style popup so you know which mode you landed on."); LookOnlyAllowStashConfig = ((BaseUnityPlugin)this).Config.Bind("General", "LookPrivatePackOnlyAllowStash", false, "Host setting. If true, other players can put items into a LookOnly pack. Off by default so they cannot trap loot they cannot take back out. Everyone with the mod uses the host's value."); AllowAnyItemInPackConfig = ((BaseUnityPlugin)this).Config.Bind("General", "AllowAnyItemInPack", false, "Host setting. If true, items that vanilla blocks from packs (canBackpack false) can still be stashed. Lit flares and beehives may behave oddly. Everyone with the mod uses the host's value."); AllowNestedPacksConfig = ((BaseUnityPlugin)this).Config.Bind("General", "AllowNestedPacks", false, "Host setting. If true, packs can go inside other packs. Inner contents still add weight. You cannot open the inner pack until you take it out, which drops it on the ground. Everyone with the mod uses the host's value."); CarryWithPackConfig = ((BaseUnityPlugin)this).Config.Bind("General", "KeepPackWhileCarrying", false, "Host setting. If true, picking up a teammate does not drop your worn pack, and selecting your pack does not drop the teammate. Everyone with the mod uses the host's value."); OpenAnyTimeKeyConfig = ((BaseUnityPlugin)this).Config.Bind("Pack Wheel", "OpenAnyTimeKey", (KeyCode)98, "Opens a backpack / fanny pack / jetpack on your back or in your hands. Also opens a carried teammate's pack if you do not have one of your own. Hold to keep the vanilla wheel open and release to close it, unless toggle mode is enabled. While that wheel is open, CycleWornPackKey switches between packs you are wearing at the same time."); OpenAnyTimeToggleModeConfig = ((BaseUnityPlugin)this).Config.Bind("Pack Wheel", "ToggleMode", false, "If true, OpenAnyTimeKey taps the wheel open or closed. Click the pack slice to close or wear it. If false, hold the key for the vanilla hold-to-open wheel."); CycleWornPackKeyConfig = ((BaseUnityPlugin)this).Config.Bind("Pack Wheel", "CycleWornPackKey", (KeyCode)324, "While the OpenAnyTimeKey wheel is open, press this to cycle backpack / fanny pack / jetpack or rocketpack if you are wearing more than one. Mouse1 is right-click."); OpenCarriedPackKeyConfig = ((BaseUnityPlugin)this).Config.Bind("Pack Wheel", "OpenCarriedPackKey", (KeyCode)110, "Opens the pack on a teammate you are carrying. OpenAnyTimeKey always opens your own pack. If you have no pack and they do, OpenAnyTimeKey still opens theirs."); PackHotkeysEnabledConfig = ((BaseUnityPlugin)this).Config.Bind("Pack Hotkeys", "Enabled", true, "Press keys to take from / put into / swap a specific backpack or fanny pack slot. Jetpacks are ignored."); PackHotkeysOnlyWhileHeldConfig = ((BaseUnityPlugin)this).Config.Bind("Pack Hotkeys", "OnlyWhileHeld", false, "If true, pack slot hotkeys only work while the pack is in your hands. Worn packs ignore them."); PackSlotKeyConfigs = new ConfigEntry[4]; PackSlotKeyConfigs[0] = ((BaseUnityPlugin)this).Config.Bind("Pack Hotkeys", "Slot1Key", (KeyCode)53, "Pack slot 1. Matches the first item slice clockwise from the top of the wheel."); PackSlotKeyConfigs[1] = ((BaseUnityPlugin)this).Config.Bind("Pack Hotkeys", "Slot2Key", (KeyCode)54, "Pack slot 2. Next slice clockwise."); PackSlotKeyConfigs[2] = ((BaseUnityPlugin)this).Config.Bind("Pack Hotkeys", "Slot3Key", (KeyCode)55, "Pack slot 3. Fanny packs usually ignore this."); PackSlotKeyConfigs[3] = ((BaseUnityPlugin)this).Config.Bind("Pack Hotkeys", "Slot4Key", (KeyCode)56, "Pack slot 4. Fanny packs usually ignore this."); AllowMultipackConfig = ((BaseUnityPlugin)this).Config.Bind("Multipack", "AllowMultipack", false, "Host setting. If true, a backpack and a fanny pack can be worn at the same time. Does not by itself allow a jetpack or rocketpack with those packs."); AllowUtilityAndBackpackConfig = ((BaseUnityPlugin)this).Config.Bind("Multipack", "AllowUtilityAndBackpack", false, "Host setting. If true and AllowMultipack is on, a jetpack or rocketpack can be worn with a backpack."); AllowUtilityAndFannypackConfig = ((BaseUnityPlugin)this).Config.Bind("Multipack", "AllowUtilityAndFannypack", false, "Host setting. If true and AllowMultipack is on, a jetpack or rocketpack can be worn with a fanny pack."); BackpackInFrontWhenWearingUtilityConfig = ((BaseUnityPlugin)this).Config.Bind("Multipack", "BackpackInFrontWhenWearingUtility", true, "Host setting. If true and AllowMultipack is on, a backpack worn with a jetpack or rocketpack sits on the chest. Everyone with the mod uses the host's value."); AllowMultipackConfig.SettingChanged += OnHostSettingChanged; AllowUtilityAndBackpackConfig.SettingChanged += OnHostSettingChanged; AllowUtilityAndFannypackConfig.SettingChanged += OnHostSettingChanged; BackpackInFrontWhenWearingUtilityConfig.SettingChanged += OnHostSettingChanged; LookOnlyAllowStashConfig.SettingChanged += OnHostSettingChanged; AllowAnyItemInPackConfig.SettingChanged += OnHostSettingChanged; AllowNestedPacksConfig.SettingChanged += OnHostSettingChanged; CarryWithPackConfig.SettingChanged += OnHostSettingChanged; PackPrivacyConfig.SettingChanged += OnPackPrivacySettingChanged; FannyPackPositionConfig = ((BaseUnityPlugin)this).Config.Bind("Visuals", "FannyPackPosition", FannyPackPosition.Back, "Where your worn fanny pack sits. Back is vanilla. Other players see the same spot. The host cannot change this for you."); ShowOwnPacksConfig = ((BaseUnityPlugin)this).Config.Bind("Visuals", "ShowOwnPacks", false, "Local only. If true, you can see your own worn packs in first person (and always in the airport mirror). Vanilla hides them because they sit on your back. The host cannot change this for you."); FrontPackWhenOpenAnytimeConfig = ((BaseUnityPlugin)this).Config.Bind("Visuals", "FrontPackWhenOpenAnytime", false, "Host setting. If true, a backpack moves to the chest (and a fanny faces forward) while the OpenAnyTimeKey wheel is open, then returns when you close it. Other players see the same move. Everyone with the mod uses the host's value."); FrontPackWhenOpenAnytimeConfig.SettingChanged += OnHostSettingChanged; DualPack.Ensure(); _harmony = new Harmony("tony4twentys.PEAK_Packs"); _harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} v{1} loaded.", "PEAK Packs", "1.0.2")); } private void Update() { try { PackPrivacy.TickOwners(); PackPrivacy.TickCycle(); PrivacyHud.Tick(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Pack privacy tick failed: " + ex)); } try { HeldBackpackInventory.Tick(); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("Held backpack tick failed: " + ex2)); } try { DualPack.TickVisuals(); } catch (Exception ex3) { ((BaseUnityPlugin)this).Logger.LogError((object)("Pack visual tick failed: " + ex3)); } try { WorldStorePrompt.Tick(); } catch (Exception ex4) { ((BaseUnityPlugin)this).Logger.LogError((object)("World store tick failed: " + ex4)); } try { PackHotkeys.Tick(); } catch (Exception ex5) { ((BaseUnityPlugin)this).Logger.LogError((object)("Pack hotkeys failed: " + ex5)); } try { PackUtil.TickPendingFuel(Character.localCharacter); } catch (Exception ex6) { ((BaseUnityPlugin)this).Logger.LogError((object)("Jetpack fuel tick failed: " + ex6)); } } private void OnDestroy() { HeldBackpackInventory.Close(); PrivacyHud.Shutdown(); if (_harmony != null) { _harmony.UnpatchSelf(); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public enum FannyPackPosition { Back, BackLeft, Left, FrontLeft, Front, FrontRight, Right, BackRight } internal static class GameAccess { internal static IInteractible GetHoveredInteractable() { if ((Object)(object)Interaction.instance == (Object)null) { return null; } return Interaction.instance.currentHovered; } internal static Item GetHoveredItem() { IInteractible hoveredInteractable = GetHoveredInteractable(); if (hoveredInteractable == null) { return null; } Item val = (Item)(object)((hoveredInteractable is Item) ? hoveredInteractable : null); if ((Object)(object)val != (Object)null) { return val; } Component val2 = (Component)(object)((hoveredInteractable is Component) ? hoveredInteractable : null); return ((Object)(object)val2 != (Object)null) ? val2.GetComponentInParent() : null; } internal static void RefreshBackpackVisuals(Backpack backpack) { if ((Object)(object)backpack == (Object)null) { return; } try { BackpackVisuals component = ((Component)backpack).GetComponent(); if ((Object)(object)component != (Object)null) { component.RefreshVisuals(); } } catch { } } } internal static class HeldBackpackInventory { private enum OpenSource { None, Held, WornHold, WornToggle, CarriedHold, CarriedToggle } private const byte PocketSlotCount = 3; private static int _confirmFrame = -1; private static float _dontReopenUntil; private static OpenSource _source; private static Character _packOwner; private static BackpackType _wornWheelType; private static readonly BackpackType[] CycleBuffer = (BackpackType[])(object)new BackpackType[3]; private static bool _openedHeld; private static KeyCode _holdKey; internal static bool IsOpen { get; private set; } internal static bool UsesClickConfirm { get { if (!IsOpen || ShouldFreeLook()) { return false; } return _source == OpenSource.Held || _source == OpenSource.WornToggle || _source == OpenSource.CarriedToggle; } } internal static bool ShouldFreeLook() { return IsOpen && _openedHeld && Plugin.IsUnlockLookWhileHeldOpen(); } internal static bool ShouldKeepWheelOpen() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen) { return false; } if (_source == OpenSource.Held || _source == OpenSource.WornToggle || _source == OpenSource.CarriedToggle) { return true; } if (_source == OpenSource.WornHold || _source == OpenSource.CarriedHold) { return (int)_holdKey != 0 && Input.GetKey(_holdKey); } return false; } internal static void Tick() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) if (Plugin.EnabledConfig == null || !Plugin.EnabledConfig.Value) { Close(); return; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { Close(); return; } Character val = (((Object)(object)localCharacter.data != (Object)null) ? localCharacter.data.carriedPlayer : null); PackInfo info = default(PackInfo); bool flag = (Object)(object)val != (Object)null && PackUtil.TryGetActivePack(val, out info) && !info.IsHeld; if (IsOpen && (Object)(object)_packOwner != (Object)null && (Object)(object)_packOwner != (Object)(object)localCharacter && (!flag || (Object)(object)_packOwner != (Object)(object)val)) { Close(); } TickCarried(val, info, flag); PackInfo info2; bool flag2 = PackUtil.TryGetActivePack(localCharacter, out info2); KeyCode openAnyTimeKey = Plugin.GetOpenAnyTimeKey(); bool flag3 = flag2 && (int)openAnyTimeKey != 0 && (Plugin.IsOpenAnyTimeToggleMode() ? Input.GetKeyDown(openAnyTimeKey) : Input.GetKey(openAnyTimeKey)); if (flag2 && info2.IsHeld && (Object)(object)info2.HeldItem != (Object)null && Plugin.IsOpenWheelWhenHeld()) { if (flag3) { TickManual(localCharacter, localCharacter, info2, openAnyTimeKey, carriedFallback: false); } else if (!IsOpen || (Object)(object)_packOwner == (Object)(object)localCharacter) { TickHeldAuto(localCharacter, info2); } } else if (flag2) { TickManual(localCharacter, localCharacter, info2, openAnyTimeKey, carriedFallback: false); } else if (flag) { TickManual(localCharacter, val, info, openAnyTimeKey, carriedFallback: true); } else if (!IsOpen || !((Object)(object)_packOwner != (Object)null) || !((Object)(object)_packOwner != (Object)(object)localCharacter)) { Close(); } } internal static bool IsOpeningOwnWornPack(PackKind kind) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen || _openedHeld || (Object)(object)_packOwner == (Object)null || (Object)(object)_packOwner != (Object)(object)Character.localCharacter) { return false; } return kind switch { PackKind.Backpack => (int)_wornWheelType == 1, PackKind.Fannypack => (int)_wornWheelType == 2, PackKind.Jetpack => DualPack.IsFlightPack(_wornWheelType), _ => false, }; } internal static void Close() { //IL_002d: 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) if (!IsOpen) { _source = OpenSource.None; return; } IsOpen = false; _source = OpenSource.None; _packOwner = null; _wornWheelType = (BackpackType)0; _openedHeld = false; _holdKey = (KeyCode)0; SetHeldWheelClicksEnabled(enabled: true); GUIManager instance = GUIManager.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.backpackWheel == (Object)null) && ((Component)instance.backpackWheel).gameObject.activeSelf) { if ((Object)(object)Character.localCharacter != (Object)null) { instance.CloseBackpackWheel(); } else { ((Component)instance.backpackWheel).gameObject.SetActive(false); } } } internal static void OnVanillaWheelClosed() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) IsOpen = false; _source = OpenSource.None; _packOwner = null; _wornWheelType = (BackpackType)0; _openedHeld = false; _holdKey = (KeyCode)0; } internal static bool TryStashPocket(Character character, byte pocketSlotId) { if (pocketSlotId >= 3) { return false; } if (PackUtil.TryGetActivePack(character, out var info) && info.Kind == PackKind.Jetpack) { return PackUtil.TryFuelPlayerSlot(character, pocketSlotId); } return PackUtil.TryStashPlayerSlot(character, pocketSlotId); } internal static void AfterInitWheel(BackpackWheel wheel) { if (_source == OpenSource.WornToggle || _source == OpenSource.CarriedToggle) { ShowToggleCloseSlice(wheel); } } internal static void ConfirmSlice(BackpackWheelSlice slice) { if (!UsesClickConfirm || (Object)(object)slice == (Object)null || Time.frameCount == _confirmFrame) { return; } if (slice.isBackpackWear) { _confirmFrame = Time.frameCount; if (_openedHeld) { WearHeldPack(); } else { Close(); } } else { slice.Hover(); ConfirmChosen(); } } internal static void ConfirmChosen() { //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_007f: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (!UsesClickConfirm || Time.frameCount == _confirmFrame) { return; } GUIManager instance = GUIManager.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.backpackWheel == (Object)null) { return; } BackpackWheel backpackWheel = instance.backpackWheel; if (!backpackWheel.chosenSlice.IsSome) { return; } _confirmFrame = Time.frameCount; SliceData value = backpackWheel.chosenSlice.Value; if (value.isBackpackWear) { if (_openedHeld) { WearHeldPack(); } else { Close(); } } else if (!value.isStashSlice && !value.isJetpackFuelSlice && TryTakeFromOpenPack(value.slotID)) { if (_source == OpenSource.Held) { FinishChoice(); } else { RefreshOpenWheel(); } } } internal static bool TryHandleHeldWear(BackpackWheel wheel) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen || !_openedHeld) { return false; } if ((Object)(object)wheel == (Object)null || !wheel.chosenSlice.IsSome || !wheel.chosenSlice.Value.isBackpackWear) { return false; } WearHeldPack(); return true; } internal static void RefreshWheel(Backpack backpack) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)backpack == (Object)null) { return; } GUIManager instance = GUIManager.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.backpackWheel == (Object)null || !((Component)instance.backpackWheel).gameObject.activeSelf) { return; } try { GameAccess.RefreshBackpackVisuals(backpack); instance.backpackWheel.InitWheel(BackpackReference.GetFromBackpackItem((Item)(object)backpack), backpack.slotCount, backpack.backpackType); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RefreshWheel failed: " + ex)); } } } internal static void RefreshOpenWheel() { if (!IsOpen) { return; } if (_openedHeld) { if (PackUtil.TryGetActivePack(Character.localCharacter, out var info) && (Object)(object)info.HeldItem != (Object)null) { RefreshWheel(info.HeldItem); } } else { RefreshWornWheel(); } } private static void TickCarried(Character carried, PackInfo pack, bool carriedHasWorn) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_00b5: Unknown result type (might be due to invalid IL or missing references) KeyCode openCarriedPackKey = Plugin.GetOpenCarriedPackKey(); if ((int)openCarriedPackKey == 0) { return; } GUIManager instance = GUIManager.instance; if ((Object)(object)instance != (Object)null && instance.windowBlockingInput) { return; } if (!carriedHasWorn) { if (_source == OpenSource.CarriedHold || _source == OpenSource.CarriedToggle) { Close(); } } else if (Plugin.IsOpenAnyTimeToggleMode()) { if (Input.GetKeyDown(openCarriedPackKey)) { if (IsOpen && (_source == OpenSource.CarriedToggle || _source == OpenSource.WornToggle) && (Object)(object)_packOwner == (Object)(object)carried) { Close(); } else { _holdKey = openCarriedPackKey; OpenWorn(carried, pack, OpenSource.CarriedToggle); } } if (IsOpen && (Object)(object)_packOwner == (Object)(object)carried && !_openedHeld) { TickCycle(carried); } } else if (Input.GetKey(openCarriedPackKey)) { _holdKey = openCarriedPackKey; if (!IsOpen || _source != OpenSource.CarriedHold || (Object)(object)_packOwner != (Object)(object)carried) { OpenWorn(carried, pack, OpenSource.CarriedHold); } if (IsOpen && (Object)(object)_packOwner == (Object)(object)carried && !_openedHeld) { TickCycle(carried); } } } private static void TickHeldAuto(Character character, PackInfo pack) { if (!(Time.time < _dontReopenUntil)) { if (!IsOpen || _source != OpenSource.Held) { OpenHeld(pack.HeldItem, OpenSource.Held); } SetHeldWheelClicksEnabled(!ShouldFreeLook()); if (IsOpen && !ShouldFreeLook() && (Object)(object)character.input != (Object)null && character.input.interactWasPressed) { ConfirmChosen(); } } } private static void TickManual(Character local, Character packOwner, PackInfo pack, KeyCode key, bool carriedFallback) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0107: 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_0114: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) GUIManager instance = GUIManager.instance; if ((Object)(object)instance != (Object)null && instance.windowBlockingInput) { return; } if ((int)key == 0) { if (_source == OpenSource.WornHold || _source == OpenSource.WornToggle) { Close(); } return; } OpenSource openSource = (carriedFallback ? OpenSource.CarriedHold : OpenSource.WornHold); OpenSource openSource2 = (carriedFallback ? OpenSource.CarriedToggle : OpenSource.WornToggle); if (Plugin.IsOpenAnyTimeToggleMode()) { if (Input.GetKeyDown(key)) { if (IsOpen && _source == openSource2 && (Object)(object)_packOwner == (Object)(object)packOwner) { Close(); } else { _holdKey = key; OpenPack(local, packOwner, pack, openSource2); } } if (IsOpen && (Object)(object)_packOwner == (Object)(object)packOwner && !_openedHeld) { TickCycle(packOwner); } if (_openedHeld) { SetHeldWheelClicksEnabled(!ShouldFreeLook()); } return; } if (Input.GetKey(key)) { _holdKey = key; if (!IsOpen || _source != openSource || (Object)(object)_packOwner != (Object)(object)packOwner) { OpenPack(local, packOwner, pack, openSource); } if (IsOpen && (Object)(object)_packOwner == (Object)(object)packOwner && !_openedHeld) { TickCycle(packOwner); } } if (_openedHeld) { SetHeldWheelClicksEnabled(!ShouldFreeLook()); } } private static void TickCycle(Character owner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Invalid comparison between I4 and Unknown KeyCode cycleWornPackKey = Plugin.GetCycleWornPackKey(); if ((int)cycleWornPackKey == 0 || !Input.GetKeyDown(cycleWornPackKey) || cycleWornPackKey == Plugin.GetOpenAnyTimeKey() || cycleWornPackKey == Plugin.GetOpenCarriedPackKey()) { return; } int num = DualPack.CollectWornTypes(owner, CycleBuffer); if (num < 2) { return; } int num2 = 0; for (int i = 0; i < num; i++) { if ((int)CycleBuffer[i] == (int)_wornWheelType) { num2 = i; break; } } num2 = (num2 + 1) % num; if (PackUtil.TryGetWornPack(owner, CycleBuffer[num2], out var info)) { OpenWorn(owner, info, _source); } } private static void OpenPack(Character local, Character packOwner, PackInfo pack, OpenSource source) { if (pack.IsHeld && (Object)(object)pack.HeldItem != (Object)null && (Object)(object)packOwner == (Object)(object)local) { OpenHeld(pack.HeldItem, source); } else { OpenWorn(packOwner, pack, source); } } private static void OpenHeld(Backpack backpack, OpenSource source) { //IL_0077: 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) GUIManager instance = GUIManager.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.backpackWheel == (Object)null || instance.windowBlockingInput) { return; } GameAccess.RefreshBackpackVisuals(backpack); _openedHeld = true; _packOwner = Character.localCharacter; if (instance.wheelActive) { IsOpen = true; _source = source; RefreshWheel(backpack); return; } IsOpen = true; _source = source; instance.OpenBackpackWheel(BackpackReference.GetFromBackpackItem((Item)(object)backpack), backpack.slotCount, backpack.backpackType); if ((Object)(object)instance.backpackWheel == (Object)null || !((Component)instance.backpackWheel).gameObject.activeSelf) { IsOpen = false; _source = OpenSource.None; _openedHeld = false; _packOwner = null; } } private static void OpenWorn(Character character, PackInfo pack, OpenSource source) { //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) GUIManager instance = GUIManager.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.backpackWheel == (Object)null || instance.windowBlockingInput || (Object)(object)character == (Object)null) { return; } BackpackType val = pack.Type; if ((int)val == 0 && (Object)(object)character.player != (Object)null && character.player.backpackSlot != null) { val = character.player.backpackSlot.backpackType; } _wornWheelType = val; int num = ((!DualPack.IsFlightPack(val)) ? pack.SlotCount : 0); BackpackReference fromEquippedBackpack = BackpackReference.GetFromEquippedBackpack(character); try { if (character.refs != null && (Object)(object)character.refs.backpackHandler != (Object)null && (Object)(object)character.refs.backpackHandler.activeBackpackVisuals != (Object)null) { ((BackpackVisuals)character.refs.backpackHandler.activeBackpackVisuals).RefreshVisuals(); } } catch { } if (instance.wheelActive) { IsOpen = true; _source = source; _openedHeld = false; _packOwner = character; instance.backpackWheel.InitWheel(fromEquippedBackpack, num, val); return; } IsOpen = true; _source = source; _openedHeld = false; _packOwner = character; instance.OpenBackpackWheel(fromEquippedBackpack, num, val); if ((Object)(object)instance.backpackWheel == (Object)null || !((Component)instance.backpackWheel).gameObject.activeSelf) { IsOpen = false; _source = OpenSource.None; _packOwner = null; _wornWheelType = (BackpackType)0; } else if (source == OpenSource.WornToggle || source == OpenSource.CarriedToggle) { ShowToggleCloseSlice(instance.backpackWheel); } } private static void ShowToggleCloseSlice(BackpackWheel wheel) { if ((Object)(object)wheel == (Object)null || wheel.slices == null || wheel.slices.Length == 0) { return; } BackpackWheelSlice val = wheel.slices[0]; if ((Object)(object)val == (Object)null) { return; } ((Component)val).gameObject.SetActive(true); try { val.backpackSlot = byte.MaxValue; } catch { } if ((Object)(object)((UIWheelSlice)val).button != (Object)null) { ((Selectable)((UIWheelSlice)val).button).interactable = true; } try { GameObject val2 = Resources.Load("0_Items/" + ((object)Unsafe.As(ref wheel.backpackType)/*cast due to .constrained prefix*/).ToString()); Backpack val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent() : null); if (!((Object)(object)val.image == (Object)null) && (Object)(object)val3 != (Object)null && ((Item)val3).UIData != null) { ((Behaviour)val.image).enabled = true; val.image.texture = (Texture)(object)((Item)val3).UIData.GetIcon(); } } catch { } } private static void RefreshWornWheel() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) Character val = (((Object)(object)_packOwner != (Object)null) ? _packOwner : Character.localCharacter); if ((!PackUtil.TryGetWornPack(val, _wornWheelType, out var info) && !PackUtil.TryGetActivePack(val, out info)) || info.IsHeld) { return; } GUIManager instance = GUIManager.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.backpackWheel == (Object)null || !((Component)instance.backpackWheel).gameObject.activeSelf) { return; } try { if (val.refs != null && (Object)(object)val.refs.backpackHandler != (Object)null && (Object)(object)val.refs.backpackHandler.activeBackpackVisuals != (Object)null) { ((BackpackVisuals)val.refs.backpackHandler.activeBackpackVisuals).RefreshVisuals(); } BackpackType val2 = (((int)_wornWheelType != 0) ? _wornWheelType : info.Type); instance.backpackWheel.InitWheel(BackpackReference.GetFromEquippedBackpack(val), (!DualPack.IsFlightPack(val2)) ? info.SlotCount : 0, val2); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RefreshWornWheel failed: " + ex)); } } } private static void WearHeldPack() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if (PackUtil.TryGetActivePack(localCharacter, out var info) && info.IsHeld) { FinishChoice(); if (localCharacter.refs != null && (Object)(object)localCharacter.refs.items != (Object)null) { localCharacter.refs.items.EquipSlot(Optionable.None); } } } private static bool TryTakeFromOpenPack(byte slotId) { if (_openedHeld) { if (!PackUtil.TryGetActivePack(Character.localCharacter, out var info) || (Object)(object)info.HeldItem == (Object)null) { return false; } return TryTakeFromHeldPack(Character.localCharacter, info.HeldItem, slotId); } return TryTakeFromWornPack(Character.localCharacter, _packOwner, slotId); } private static bool TryTakeFromHeldPack(Character character, Backpack backpack, byte slotId) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (NestedPacks.TryTakeFromWheel(BackpackReference.GetFromBackpackItem((Item)(object)backpack), slotId, character)) { return true; } if (TryGetSpawnedItem(BackpackReference.GetFromBackpackItem((Item)(object)backpack), slotId, out var item)) { item.Interact(character); return true; } return TryTakeFromPackData(character, ((Item)backpack).GetData((DataEntryKey)7), backpack, slotId); } private static bool TryTakeFromWornPack(Character taker, Character owner, byte slotId) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)taker == (Object)null) { return false; } if ((Object)(object)owner == (Object)null) { owner = taker; } if (NestedPacks.TryTakeFromWheel(BackpackReference.GetFromEquippedBackpack(owner), slotId, taker)) { return true; } if (TryGetSpawnedItem(BackpackReference.GetFromEquippedBackpack(owner), slotId, out var item)) { item.Interact(taker); return true; } if (!PackUtil.TryGetActivePack(owner, out var info)) { return false; } return TryTakeFromPackData(taker, info.Storage, null, slotId); } private static bool TryGetSpawnedItem(BackpackReference reference, byte slotId, out Item item) { item = null; try { if (!((BackpackReference)(ref reference)).exists || (Object)(object)((BackpackReference)(ref reference)).GetVisuals() == (Object)null) { return false; } return ((BackpackReference)(ref reference)).GetVisuals().TryGetSpawnedItem(slotId, ref item) && (Object)(object)item != (Object)null; } catch { return false; } } private static bool TryTakeFromPackData(Character character, BackpackData data, Backpack heldBackpack, byte slotId) { //IL_0136: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null || data == null || data.itemSlots == null) { return false; } if (slotId >= data.itemSlots.Length) { return false; } ItemSlot val = data.itemSlots[slotId]; if (val == null || val.IsEmpty() || (Object)(object)val.prefab == (Object)null) { return false; } if (Plugin.IsAllowNestedPacks() && val.prefab is Backpack) { return false; } if (!PhotonNetwork.IsMasterClient) { return false; } ItemSlot val2 = default(ItemSlot); if (!character.player.AddItem(val.prefab.itemID, val.data, ref val2)) { return false; } val.EmptyOut(); if ((Object)(object)heldBackpack != (Object)null) { SyncHeldBackpackData(heldBackpack); } if (character.refs != null && (Object)(object)character.refs.items != (Object)null && val2 != null) { character.refs.items.EquipSlot(Optionable.Some(val2.itemSlotID)); } return true; } private static void SyncHeldBackpackData(Backpack backpack) { //IL_0016: 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) PhotonView component = ((Component)backpack).GetComponent(); if (!((Object)(object)component == (Object)null)) { BackpackReference fromBackpackItem = BackpackReference.GetFromBackpackItem((Item)(object)backpack); ItemInstanceData itemInstanceData = ((BackpackReference)(ref fromBackpackItem)).GetItemInstanceData(); if (itemInstanceData != null) { component.RPC("SetItemInstanceDataRPC", (RpcTarget)1, new object[1] { itemInstanceData }); } } } private static void FinishChoice() { _dontReopenUntil = Time.time + 0.4f; Close(); } private static void SetHeldWheelClicksEnabled(bool enabled) { GUIManager instance = GUIManager.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.backpackWheel == (Object)null) { return; } BackpackWheelSlice[] slices = instance.backpackWheel.slices; if (slices != null) { for (int i = 0; i < slices.Length; i++) { SetSliceClicksEnabled(slices[i], enabled); } } SetSliceClicksEnabled(instance.backpackWheel.jetpackSlice, enabled); } private static void SetSliceClicksEnabled(BackpackWheelSlice slice, bool enabled) { if (!((Object)(object)slice == (Object)null)) { if ((Object)(object)((UIWheelSlice)slice).button != (Object)null) { ((Behaviour)((UIWheelSlice)slice).button).enabled = enabled; } if ((Object)(object)slice.image != (Object)null) { ((Graphic)slice.image).raycastTarget = enabled; } } } } internal static class PackHotkeys { internal static void Tick() { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Invalid comparison between Unknown and I4 //IL_0155: Unknown result type (might be due to invalid IL or missing references) if (Plugin.EnabledConfig == null || !Plugin.EnabledConfig.Value || Plugin.PackHotkeysEnabledConfig == null || !Plugin.PackHotkeysEnabledConfig.Value || Plugin.PackSlotKeyConfigs == null) { return; } GUIManager instance = GUIManager.instance; if ((Object)(object)instance != (Object)null && instance.windowBlockingInput) { return; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || !localCharacter.IsLocal || (Object)(object)localCharacter.data == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut || !PackUtil.TryGetActivePack(localCharacter, out var info) || (info.Kind != PackKind.Backpack && info.Kind != PackKind.Fannypack) || (Plugin.IsPackHotkeysOnlyWhileHeld() && !info.IsHeld)) { return; } for (byte b = 0; b < Plugin.PackSlotKeyConfigs.Length; b++) { ConfigEntry val = Plugin.PackSlotKeyConfigs[b]; if (val != null && (int)val.Value != 0 && Input.GetKeyDown(val.Value)) { if (b < info.SlotCount) { byte hotkeyIndex = b; if (b < 3 && info.SlotCount >= 3) { hotkeyIndex = (byte)((b + 2) % 3); } byte packSlotId = ResolveVisualSlot(hotkeyIndex, info.SlotCount); PackUtil.TryUsePackSlotHotkey(localCharacter, packSlotId); } break; } } } private static byte ResolveVisualSlot(byte hotkeyIndex, int slotCount) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) GUIManager instance = GUIManager.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.backpackWheel == (Object)null || !((Component)instance.backpackWheel).gameObject.activeSelf) { return hotkeyIndex; } BackpackWheelSlice[] slices = instance.backpackWheel.slices; if (slices == null) { return hotkeyIndex; } int num = 0; byte[] array = new byte[4]; float[] array2 = new float[4]; Vector3 position = ((Component)instance.backpackWheel).transform.position; for (int i = 0; i < slices.Length; i++) { if (num >= array.Length) { break; } BackpackWheelSlice val = slices[i]; if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy || val.isBackpackWear || val.stashSlice || val.jetpackFuelSlice || val.backpackSlot >= slotCount) { continue; } float clockwiseAngleFromTop = GetClockwiseAngleFromTop(((Component)val).transform.position - position); int num2 = num; for (int j = 0; j < num; j++) { if (clockwiseAngleFromTop < array2[j]) { num2 = j; break; } } for (int num3 = num; num3 > num2; num3--) { array[num3] = array[num3 - 1]; array2[num3] = array2[num3 - 1]; } if (num2 < array.Length) { array[num2] = val.backpackSlot; array2[num2] = clockwiseAngleFromTop; num++; } if (num >= array.Length) { break; } } if (hotkeyIndex >= num) { return hotkeyIndex; } return array[hotkeyIndex]; } private static float GetClockwiseAngleFromTop(Vector3 delta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Atan2(delta.x, delta.y); if (num < 0f) { num += (float)Math.PI * 2f; } return num; } } public enum PackPrivacyMode { Off, BlockLook, LookOnly } internal static class PackPrivacy { private static readonly Dictionary LastHolderByGuid = new Dictionary(); private static readonly Dictionary ModeByActor = new Dictionary(); internal static void TickOwners() { List allPlayerCharacters = PlayerHandler.GetAllPlayerCharacters(); if (allPlayerCharacters == null) { return; } for (int i = 0; i < allPlayerCharacters.Count; i++) { Character val = allPlayerCharacters[i]; if ((Object)(object)val == (Object)null || (Object)(object)val.player == (Object)null) { continue; } int actor = GetActor(val); if (actor >= 0) { if (val.player.backpackSlot != null && !((ItemSlot)val.player.backpackSlot).IsEmpty() && ((ItemSlot)val.player.backpackSlot).data != null) { Register(((ItemSlot)val.player.backpackSlot).data.guid, actor); } Backpack val2 = (Backpack)(((Object)(object)val.data != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val2 != (Object)null && ((Item)val2).data != null) { Register(((Item)val2).data.guid, actor); } } } } internal static void TickCycle() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) KeyCode privacyCycleKey = Plugin.GetPrivacyCycleKey(); if ((int)privacyCycleKey == 0 || !Input.GetKeyDown(privacyCycleKey)) { return; } GUIManager instance = GUIManager.instance; if (!((Object)(object)instance != (Object)null) || (!instance.windowBlockingInput && !GUIManager.InPauseMenu)) { PackPrivacyMode packPrivacy = Plugin.GetPackPrivacy(); PackPrivacyMode value = PackPrivacyMode.Off; switch (packPrivacy) { case PackPrivacyMode.Off: value = PackPrivacyMode.BlockLook; break; case PackPrivacyMode.BlockLook: value = PackPrivacyMode.LookOnly; break; } if (Plugin.PackPrivacyConfig != null) { Plugin.PackPrivacyConfig.Value = value; } } } internal static PackPrivacyMode ModeOf(Character owner) { if ((Object)(object)owner == (Object)null) { return PackPrivacyMode.Off; } if (owner.IsLocal) { return Plugin.GetPackPrivacy(); } return ModeOfActor(GetActor(owner)); } internal static PackPrivacyMode ModeOfActor(int actor) { if (actor < 0) { return PackPrivacyMode.Off; } if (PhotonNetwork.LocalPlayer != null && actor == PhotonNetwork.LocalPlayer.ActorNumber) { return Plugin.GetPackPrivacy(); } if (ModeByActor.TryGetValue(actor, out var value)) { return value; } return PackPrivacyMode.Off; } internal static void SetRemoteMode(int actor, PackPrivacyMode mode) { if (actor >= 0) { ModeByActor[actor] = mode; } } internal static void ClearActor(int actor) { ModeByActor.Remove(actor); } internal static void ClearAll() { ModeByActor.Clear(); } internal static bool IsCarrierOf(Character owner) { if ((Object)(object)owner == (Object)null || (Object)(object)owner.data == (Object)null) { return false; } Character localCharacter = Character.localCharacter; return (Object)(object)localCharacter != (Object)null && (Object)(object)owner.data.carrier == (Object)(object)localCharacter; } internal static Character GetEquippedOwner(BackpackReference reference) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0013: 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) if (!((BackpackReference)(ref reference)).exists || (int)reference.type != 1 || (Object)(object)reference.view == (Object)null) { return null; } return ((Component)reference.view).GetComponent(); } internal static bool ShouldBlockLook(Character owner, Character interactor) { if (ModeOf(owner) != PackPrivacyMode.BlockLook) { return false; } if ((Object)(object)owner == (Object)null || (Object)(object)interactor == (Object)null || (Object)(object)owner == (Object)(object)interactor) { return false; } if (IsCarrierOf(owner)) { return false; } return true; } internal static bool ShouldBlockTake(BackpackReference reference, Character interactor = null) { //IL_0025: 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_002c: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)interactor == (Object)null) { interactor = Character.localCharacter; } if ((Object)(object)interactor == (Object)null) { return false; } if ((int)reference.type == 0) { if ((Object)(object)reference.view == (Object)null) { return false; } Backpack component = ((Component)reference.view).GetComponent(); return ShouldBlockDropped(component, interactor); } Character equippedOwner = GetEquippedOwner(reference); if ((Object)(object)equippedOwner == (Object)null || (Object)(object)equippedOwner == (Object)(object)interactor) { return false; } if (ModeOf(equippedOwner) == PackPrivacyMode.Off) { return false; } if (IsCarrierOf(equippedOwner) && (Object)(object)interactor == (Object)(object)Character.localCharacter) { return false; } if ((Object)(object)equippedOwner.data != (Object)null && (Object)(object)equippedOwner.data.carrier == (Object)(object)interactor) { return false; } return true; } internal static bool ShouldBlockStash(BackpackReference reference, Character interactor = null) { //IL_0001: 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) if (!ShouldBlockTake(reference, interactor)) { return false; } if (ModeOfReference(reference) == PackPrivacyMode.LookOnly && Plugin.IsLookOnlyAllowStash()) { return false; } return true; } internal static bool SlotHasItem(BackpackReference reference, byte slotId) { try { if (!((BackpackReference)(ref reference)).exists) { return false; } BackpackData data = ((BackpackReference)(ref reference)).GetData(); if (data == null || data.itemSlots == null || slotId >= data.itemSlots.Length) { return false; } ItemSlot val = data.itemSlots[slotId]; return val != null && !val.IsEmpty(); } catch { return false; } } internal static bool ShouldBlockDropped(Backpack backpack, Character interactor) { if ((Object)(object)backpack == (Object)null || (Object)(object)interactor == (Object)null) { return false; } int num = ResolveDroppedOwner(backpack); if (num < 0) { return false; } if (ModeOfActor(num) == PackPrivacyMode.Off) { return false; } int actor = GetActor(interactor); if (actor >= 0 && actor == num) { return false; } Character val = FindCharacter(num); if ((Object)(object)val == (Object)null) { return false; } if (IsCarrierOf(val)) { return false; } if (OwnerIsDown(val)) { return false; } return true; } internal static bool ShouldBlockDroppedOpen(Backpack backpack, Character interactor) { int actor = ResolveDroppedOwner(backpack); if (ModeOfActor(actor) != PackPrivacyMode.BlockLook) { return false; } return ShouldBlockDropped(backpack, interactor); } internal static bool ShouldBlockPickup(Item item, PhotonView takerView) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null || (Object)(object)takerView == (Object)null) { return false; } Character component = ((Component)takerView).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } Backpack val = (Backpack)(object)((item is Backpack) ? item : null); if ((Object)(object)val != (Object)null && (int)item.itemState == 0) { return ShouldBlockDropped(val, component); } if (!item.backpackReference.IsSome) { return false; } BackpackReference item2 = item.backpackReference.Value.Item2; return ShouldBlockTake(item2); } internal static void DenyPickup(Item item, PhotonView takerView) { if (!((Object)(object)item == (Object)null) && !((Object)(object)((MonoBehaviourPun)item).photonView == (Object)null) && !((Object)(object)takerView == (Object)null)) { Player owner = takerView.Owner; if (owner != null) { ((MonoBehaviourPun)item).photonView.RPC("DenyPickupRPC", owner, Array.Empty()); } } } private static PackPrivacyMode ModeOfReference(BackpackReference reference) { //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_0008: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if ((int)reference.type == 0) { if ((Object)(object)reference.view == (Object)null) { return PackPrivacyMode.Off; } Backpack component = ((Component)reference.view).GetComponent(); return ModeOfActor(ResolveDroppedOwner(component)); } return ModeOf(GetEquippedOwner(reference)); } private static void Register(Guid guid, int actor) { if (!(guid == Guid.Empty) && actor >= 0) { LastHolderByGuid[guid.ToString()] = actor; } } private static int ResolveDroppedOwner(Backpack backpack) { if ((Object)(object)backpack == (Object)null || ((Item)backpack).data == null || ((Item)backpack).data.guid == Guid.Empty) { return -1; } if (LastHolderByGuid.TryGetValue(((Item)backpack).data.guid.ToString(), out var value)) { return value; } return -1; } private static bool OwnerIsDown(Character owner) { if ((Object)(object)owner == (Object)null || (Object)(object)owner.data == (Object)null) { return true; } return owner.data.dead || owner.data.passedOut || owner.data.fullyPassedOut; } private static int GetActor(Character character) { if ((Object)(object)character == (Object)null) { return -1; } PhotonView photonView = ((MonoBehaviourPun)character).photonView; if ((Object)(object)photonView == (Object)null || photonView.Owner == null) { return -1; } return photonView.Owner.ActorNumber; } private static Character FindCharacter(int actor) { List allPlayerCharacters = PlayerHandler.GetAllPlayerCharacters(); if (allPlayerCharacters == null) { return null; } for (int i = 0; i < allPlayerCharacters.Count; i++) { if (GetActor(allPlayerCharacters[i]) == actor) { return allPlayerCharacters[i]; } } return null; } } internal static class PrivacyHud { private const float PopupSeconds = 5f; private static readonly Color Cream = new Color(0.95f, 0.93f, 0.88f, 1f); private static GameObject _canvasObject; private static TextMeshProUGUI _label; private static float _hideAt; private static TMP_FontAsset _cachedFont; private static int _cachedSceneHandle = -1; internal static void Show(PackPrivacyMode mode) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) Ensure(); if (!((Object)(object)_label == (Object)null)) { switch (mode) { case PackPrivacyMode.BlockLook: ((TMP_Text)_label).text = "PACK LOCKED"; break; case PackPrivacyMode.LookOnly: ((TMP_Text)_label).text = "PACK LOOK ONLY"; break; default: ((TMP_Text)_label).text = "PACK UNLOCKED"; break; } ApplyFont(_label); ((TMP_Text)_label).fontSize = 60f; ((Graphic)_label).color = Cream; ((Component)_label).gameObject.SetActive(true); _hideAt = Time.unscaledTime + 5f; } } internal static void Tick() { if (!((Object)(object)_label == (Object)null) && ((Component)_label).gameObject.activeSelf && Time.unscaledTime >= _hideAt) { ((Component)_label).gameObject.SetActive(false); } } internal static void Shutdown() { if ((Object)(object)_canvasObject != (Object)null) { Object.Destroy((Object)(object)_canvasObject); } _canvasObject = null; _label = null; _cachedFont = null; _cachedSceneHandle = -1; } private static void Ensure() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0077: 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_00b9: Expected O, but got Unknown //IL_00e2: 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) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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) if (!((Object)(object)_canvasObject != (Object)null)) { _canvasObject = new GameObject("PEAKPacks_PrivacyHud"); Object.DontDestroyOnLoad((Object)(object)_canvasObject); Canvas val = _canvasObject.AddComponent(); val.renderMode = (RenderMode)0; val.sortingOrder = 9400; val.additionalShaderChannels = (AdditionalCanvasShaderChannels)25; CanvasScaler val2 = _canvasObject.AddComponent(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.matchWidthOrHeight = 1f; GameObject val3 = new GameObject("Text", new Type[2] { typeof(RectTransform), typeof(CanvasRenderer) }); val3.transform.SetParent(_canvasObject.transform, false); RectTransform component = val3.GetComponent(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(900f, 120f); component.anchoredPosition = Vector2.zero; _label = val3.AddComponent(); ((TMP_Text)_label).alignment = (TextAlignmentOptions)514; ((TMP_Text)_label).fontStyle = (FontStyles)0; ((Graphic)_label).raycastTarget = false; ((TMP_Text)_label).enableWordWrapping = false; ((TMP_Text)_label).overflowMode = (TextOverflowModes)0; ApplyFont(_label); val3.SetActive(false); } } private static void ApplyFont(TextMeshProUGUI text) { if (!((Object)(object)text == (Object)null)) { TMP_FontAsset gameFont = GetGameFont(); if ((Object)(object)gameFont != (Object)null) { ((TMP_Text)text).font = gameFont; } ((TMP_Text)text).fontStyle = (FontStyles)0; } } private static TMP_FontAsset GetGameFont() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); int num = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle); if ((Object)(object)_cachedFont != (Object)null && _cachedSceneHandle == num) { return _cachedFont; } try { if ((Object)(object)GUIManager.instance != (Object)null) { TextMeshProUGUI componentInChildren = ((Component)GUIManager.instance).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((TMP_Text)componentInChildren).font != (Object)null) { _cachedFont = ((TMP_Text)componentInChildren).font; _cachedSceneHandle = num; return _cachedFont; } } } catch { } return _cachedFont; } } internal enum PackKind { None, Backpack, Fannypack, Jetpack } internal struct PackInfo { public PackKind Kind; public BackpackType Type; public bool IsHeld; public Backpack HeldItem; public int SlotCount; public BackpackData Storage; } internal static class PackUtil { private enum PendingAction { None, Stash, Fuel } private static PendingAction _pending; private static float _pendingUntil; private static bool _fuelAfterPickup; internal static bool TryGetActivePack(Character character, out PackInfo info) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) info = default(PackInfo); if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null || (Object)(object)character.data == (Object)null) { return false; } CharacterItems val = ((character.refs != null) ? character.refs.items : null); Item currentItem = character.data.currentItem; Backpack val2 = (Backpack)(object)((currentItem is Backpack) ? currentItem : null); if ((Object)(object)val2 != (Object)null && (Object)(object)val != (Object)null && val.currentSelectedSlot.IsSome && val.currentSelectedSlot.Value == 3) { info.Kind = ToKind(val2.backpackType); info.Type = val2.backpackType; if (info.Kind == PackKind.None) { return false; } info.IsHeld = true; info.HeldItem = val2; info.SlotCount = ((info.Kind != PackKind.Jetpack) ? val2.slotCount : 0); if (info.Kind != PackKind.Jetpack) { info.Storage = EnsureStorageSlots(((Item)val2).GetData((DataEntryKey)7)); } return true; } BackpackSlot backpackSlot = character.player.backpackSlot; if (backpackSlot == null || ((ItemSlot)backpackSlot).IsEmpty()) { return false; } if (DualPack.TryGetStorageData(character, out var data, out var slotCount)) { info.Type = DualPack.GetExtraPackType(character); info.Kind = ToKind(info.Type); if (info.Kind == PackKind.None) { info.Kind = PackKind.Backpack; } info.IsHeld = false; info.SlotCount = slotCount; info.Storage = EnsureStorageSlots(data); return true; } info.Kind = ToKind(backpackSlot.backpackType); info.Type = backpackSlot.backpackType; if (info.Kind == PackKind.None) { return false; } info.IsHeld = false; info.SlotCount = GetWornSlotCount(character, info.Kind); if (info.Kind != PackKind.Jetpack) { info.Storage = EnsureStorageSlots(GetWornStorage(backpackSlot)); } return true; } internal static bool TryGetWornPack(Character character, BackpackType type, out PackInfo info) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) info = default(PackInfo); info.Type = type; info.Kind = ToKind(type); info.IsHeld = false; if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null || info.Kind == PackKind.None) { return false; } if (info.Kind == PackKind.Jetpack) { BackpackSlot backpackSlot = character.player.backpackSlot; if (backpackSlot == null || backpackSlot.backpackType != type) { return false; } info.SlotCount = 0; return true; } if (DualPack.TryGetExtraStorage(character, type, out var data, out var slotCount)) { info.SlotCount = slotCount; info.Storage = EnsureStorageSlots(data); return true; } BackpackSlot backpackSlot2 = character.player.backpackSlot; if (backpackSlot2 == null || backpackSlot2.backpackType != type) { return false; } info.SlotCount = GetWornSlotCount(character, info.Kind); info.Storage = EnsureStorageSlots(GetWornStorage(backpackSlot2)); return true; } internal static bool HasStorageSpace(PackInfo info) { if (info.Kind == PackKind.None || info.Kind == PackKind.Jetpack) { return false; } BackpackData val = EnsureStorageSlots(info.Storage); if (val == null) { return true; } byte slotId; return TryGetFirstEmptySlot(val, (info.SlotCount > 0) ? info.SlotCount : 4, out slotId); } internal static bool ItemCanGoInPack(Item item) { if ((Object)(object)item == (Object)null) { return true; } if (Plugin.IsAllowAnyItemInPack()) { return true; } if (Plugin.IsAllowNestedPacks() && item is Backpack) { return true; } if (item.UIData == null) { return true; } return item.UIData.canBackpack; } internal static bool HasFuelRoom(PackInfo info) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (info.Kind != PackKind.Jetpack) { return false; } try { object obj; if (!info.IsHeld || !((Object)(object)info.HeldItem != (Object)null)) { obj = (((Object)(object)Character.localCharacter != (Object)null && (Object)(object)Character.localCharacter.player != (Object)null) ? ((ItemSlot)Character.localCharacter.player.backpackSlot).data : null); } else { BackpackReference fromBackpackItem = BackpackReference.GetFromBackpackItem((Item)(object)info.HeldItem); obj = ((BackpackReference)(ref fromBackpackItem)).GetItemInstanceData(); } ItemInstanceData val = (ItemInstanceData)obj; FloatItemData val2 = default(FloatItemData); if (val != null && val.TryGetDataEntry((DataEntryKey)10, ref val2)) { return val2.Value < 99.5f; } FloatItemData val3 = default(FloatItemData); if (val != null && val.TryGetDataEntry((DataEntryKey)11, ref val3)) { return val3.Value < 0.995f; } } catch { } return true; } internal static string GetStorePromptLabel(PackInfo info) { return info.Kind switch { PackKind.Fannypack => "put in fanny pack", PackKind.Jetpack => "use as fuel", _ => "put in backpack", }; } internal static bool TryGetStorePrompt(Character character, out PackInfo info, out string label) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) info = default(PackInfo); if (CanShowGroundPackStorePrompt(character, out var backpack, out label)) { info.Kind = ToKind(backpack.backpackType); info.HeldItem = backpack; return true; } return CanShowWorldStorePrompt(character, GetHoveredWorldItem(), out info, out label); } internal static bool CanShowWorldStorePrompt(Character character, Item item, out PackInfo info, out string label) { info = default(PackInfo); label = null; if ((Object)(object)item == (Object)null || (Object)(object)character == (Object)null || !TryGetActivePack(character, out info)) { return false; } if (!Plugin.IsPutGroundItemsInWornPack()) { return false; } if ((Object)(object)item == (Object)(object)character.data.currentItem) { return false; } if (info.Kind == PackKind.Jetpack) { label = GetStorePromptLabel(info); return true; } if (item is Backpack) { return false; } if (!ItemCanGoInPack(item)) { return false; } if (!HasStorageSpace(info)) { return false; } label = GetStorePromptLabel(info); return true; } internal static bool CanShowHeldItemStorePrompt(Character character, out PackInfo info, out string label) { info = default(PackInfo); label = null; if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null || (Object)(object)character.data.currentItem == (Object)null) { return false; } if (!TryGetActivePack(character, out info) || info.IsHeld) { return false; } Item currentItem = character.data.currentItem; if (currentItem is Backpack) { return false; } CharacterItems val = ((character.refs != null) ? character.refs.items : null); if ((Object)(object)val == (Object)null || val.currentSelectedSlot.IsNone || val.currentSelectedSlot.Value == 3) { return false; } if (info.Kind == PackKind.Jetpack) { label = GetStorePromptLabel(info); return true; } if (!ItemCanGoInPack(currentItem)) { return false; } if (!HasStorageSpace(info)) { return false; } label = GetStorePromptLabel(info); return true; } internal static bool TryStashPlayerSlot(Character character, byte slotId) { if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null) { return false; } if (!TryGetActivePack(character, out var info) || !HasStorageSpace(info)) { return false; } ItemSlot itemSlot = character.player.GetItemSlot(slotId); if (itemSlot == null || itemSlot.IsEmpty() || (Object)(object)itemSlot.prefab == (Object)null) { return false; } if (!ItemCanGoInPack(itemSlot.prefab)) { return false; } info.Storage = EnsureStorageSlots(info.Storage); if (!TryGetFirstEmptySlot(info.Storage, info.SlotCount, out var slotId2)) { return false; } return StashPlayerSlotTo(character, info, slotId, slotId2); } internal static bool TryStashPlayerSlotTo(Character character, byte slotId, byte destSlot) { if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null) { return false; } if (!TryGetActivePack(character, out var info) || info.Kind == PackKind.Jetpack) { return false; } info.Storage = EnsureStorageSlots(info.Storage); if (info.Storage == null || destSlot >= info.SlotCount || destSlot >= info.Storage.itemSlots.Length) { return false; } ItemSlot val = info.Storage.itemSlots[destSlot]; if (val != null && !val.IsEmpty()) { return false; } ItemSlot itemSlot = character.player.GetItemSlot(slotId); if (itemSlot == null || itemSlot.IsEmpty() || (Object)(object)itemSlot.prefab == (Object)null) { return false; } if (!ItemCanGoInPack(itemSlot.prefab)) { return false; } return StashPlayerSlotTo(character, info, slotId, destSlot); } internal static bool TryTakeFromPackSlot(Character character, byte packSlotId) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00c4: 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_0212: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null) { return false; } if (!TryGetActivePack(character, out var info) || info.Kind == PackKind.Jetpack) { return false; } info.Storage = EnsureStorageSlots(info.Storage); if (info.Storage == null || packSlotId >= info.SlotCount || packSlotId >= info.Storage.itemSlots.Length) { return false; } ItemSlot val = info.Storage.itemSlots[packSlotId]; BackpackReference reference = ((info.IsHeld && (Object)(object)info.HeldItem != (Object)null) ? BackpackReference.GetFromBackpackItem((Item)(object)info.HeldItem) : BackpackReference.GetFromEquippedBackpack(character)); if (NestedPacks.TryTakeFromWheel(reference, packSlotId, character)) { RefreshPackAfterChange(character, info); return true; } if (TryGetSpawnedPackItem(reference, packSlotId, out var item)) { item.Interact(character); RefreshPackAfterChange(character, info); return true; } if (Plugin.IsAllowNestedPacks() && val != null && val.prefab is Backpack) { return false; } if (!PhotonNetwork.IsMasterClient) { return false; } if (val == null || val.IsEmpty() || (Object)(object)val.prefab == (Object)null) { return false; } ItemSlot val2 = default(ItemSlot); if (!character.player.AddItem(val.prefab.itemID, val.data, ref val2)) { return false; } val.EmptyOut(); if (info.IsHeld && (Object)(object)info.HeldItem != (Object)null) { SyncHeldBackpackData(info.HeldItem); } if (character.refs != null && (Object)(object)character.refs.items != (Object)null && val2 != null) { character.refs.items.EquipSlot(Optionable.Some(val2.itemSlotID)); } RefreshPackAfterChange(character, info); return true; } internal static bool TrySwapHandWithPackSlot(Character character, byte playerSlotId, byte packSlotId) { //IL_021d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null || !PhotonNetwork.IsMasterClient) { return false; } if (!TryGetActivePack(character, out var info) || info.Kind == PackKind.Jetpack) { return false; } info.Storage = EnsureStorageSlots(info.Storage); if (info.Storage == null || packSlotId >= info.SlotCount || packSlotId >= info.Storage.itemSlots.Length) { return false; } ItemSlot val = info.Storage.itemSlots[packSlotId]; ItemSlot itemSlot = character.player.GetItemSlot(playerSlotId); if (val == null || val.IsEmpty() || (Object)(object)val.prefab == (Object)null) { return false; } if (itemSlot == null || itemSlot.IsEmpty() || (Object)(object)itemSlot.prefab == (Object)null) { return false; } if (!ItemCanGoInPack(itemSlot.prefab)) { return false; } if (Plugin.IsAllowNestedPacks() && val.prefab is Backpack) { if (!TryTakeFromPackSlot(character, packSlotId)) { return false; } return TryStashPlayerSlotTo(character, playerSlotId, packSlotId); } Item prefab = val.prefab; ItemInstanceData data = val.data; val.EmptyOut(); if (info.IsHeld && (Object)(object)info.HeldItem != (Object)null) { SyncHeldBackpackData(info.HeldItem); } if (!StashPlayerSlotTo(character, info, playerSlotId, packSlotId)) { return false; } ItemSlot val2 = default(ItemSlot); if (!character.player.AddItem(prefab.itemID, data, ref val2)) { return false; } if (character.refs != null && (Object)(object)character.refs.items != (Object)null && val2 != null) { character.refs.items.EquipSlot(Optionable.Some(val2.itemSlotID)); } RefreshPackAfterChange(character, info); return true; } internal static bool TryUsePackSlotHotkey(Character character, byte packSlotId) { //IL_0182: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null || character.refs == null || (Object)(object)character.refs.items == (Object)null) { return false; } if (!TryGetActivePack(character, out var info)) { return false; } if (info.Kind != PackKind.Backpack && info.Kind != PackKind.Fannypack) { return false; } if (packSlotId >= info.SlotCount) { return false; } info.Storage = EnsureStorageSlots(info.Storage); if (info.Storage == null || packSlotId >= info.Storage.itemSlots.Length) { return false; } ItemSlot val = info.Storage.itemSlots[packSlotId]; bool flag = val == null || val.IsEmpty(); CharacterItems items = character.refs.items; bool flag2 = items.currentSelectedSlot.IsSome && items.currentSelectedSlot.Value != 3 && character.player.GetItemSlot(items.currentSelectedSlot.Value) != null && !character.player.GetItemSlot(items.currentSelectedSlot.Value).IsEmpty(); if (flag && flag2) { if (!TryStashPlayerSlotTo(character, items.currentSelectedSlot.Value, packSlotId)) { return false; } items.EquipSlot(Optionable.None); return true; } if (!flag && !flag2) { return TryTakeFromPackSlot(character, packSlotId); } if (!flag && flag2) { return TrySwapHandWithPackSlot(character, items.currentSelectedSlot.Value, packSlotId); } return false; } internal static bool TryFuelPlayerSlot(Character character, byte slotId) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null) { return false; } if (!TryGetActivePack(character, out var info) || info.Kind != PackKind.Jetpack) { return false; } ItemSlot itemSlot = character.player.GetItemSlot(slotId); if (itemSlot == null || itemSlot.IsEmpty() || (Object)(object)itemSlot.prefab == (Object)null) { return false; } float fuel = ComputeFuelAmount(itemSlot.prefab, itemSlot.data); character.player.EmptySlot(Optionable.Some(slotId)); AddFuel(character, info, fuel); RefreshPackAfterChange(character, info); return true; } internal static bool CanShowGroundPackStorePrompt(Character character, out Backpack backpack, out string label) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) backpack = null; label = null; if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null || (Object)(object)character.data.currentItem == (Object)null) { return false; } Item currentItem = character.data.currentItem; if (currentItem is Backpack) { return false; } CharacterItems val = ((character.refs != null) ? character.refs.items : null); if ((Object)(object)val == (Object)null || val.currentSelectedSlot.IsNone || val.currentSelectedSlot.Value == 3) { return false; } Item hoveredWorldItem = GetHoveredWorldItem(); backpack = (Backpack)(object)((hoveredWorldItem is Backpack) ? hoveredWorldItem : null); if ((Object)(object)backpack == (Object)null || (Object)(object)backpack == (Object)(object)currentItem) { return false; } if (PackPrivacy.ShouldBlockStash(BackpackReference.GetFromBackpackItem((Item)(object)backpack), character)) { return false; } PackKind packKind = ToKind(backpack.backpackType); switch (packKind) { case PackKind.None: return false; case PackKind.Jetpack: label = GetStorePromptLabel(new PackInfo { Kind = PackKind.Jetpack }); return true; default: { if (!ItemCanGoInPack(currentItem)) { return false; } BackpackData data = EnsureStorageSlots(((Item)backpack).GetData((DataEntryKey)7)); if (!TryGetFirstEmptySlot(data, backpack.slotCount, out var _)) { return false; } label = GetStorePromptLabel(new PackInfo { Kind = packKind }); return true; } } } internal static void TryStoreFromPrompt(Character character) { if (CanShowGroundPackStorePrompt(character, out var backpack, out var label)) { TryStoreHeldIntoGroundPack(character, backpack); return; } if (CanShowHeldItemStorePrompt(character, out var info, out label)) { TryStoreHeldItem(character, info); return; } Item hoveredWorldItem = GetHoveredWorldItem(); if (!CanShowWorldStorePrompt(character, hoveredWorldItem, out info, out label)) { return; } if (info.Kind == PackKind.Jetpack) { BeginPending(PendingAction.Fuel); if (PhotonNetwork.IsMasterClient && !HasInventorySpace(character, hoveredWorldItem)) { ClearPending(); DirectFuelWorldItem(character, info, hoveredWorldItem); } else { hoveredWorldItem.Interact(character); } } else { BeginPending(PendingAction.Stash); if (PhotonNetwork.IsMasterClient && !HasInventorySpace(character, hoveredWorldItem)) { ClearPending(); DirectStashWorldItem(character, info, hoveredWorldItem); } else { hoveredWorldItem.Interact(character); } } } internal static bool TryConsumePendingPickup(Character character, byte slotId) { if (_pending == PendingAction.None || Time.time > _pendingUntil) { ClearPending(); return false; } PendingAction pending = _pending; ClearPending(); if (slotId == 3) { return false; } switch (pending) { case PendingAction.Stash: TryStashPlayerSlot(character, slotId); return true; case PendingAction.Fuel: _fuelAfterPickup = true; _pendingUntil = Time.time + 2f; break; } return false; } internal static void TickPendingFuel(Character character) { if (!_fuelAfterPickup) { return; } if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null || Time.time > _pendingUntil) { _fuelAfterPickup = false; return; } Item currentItem = character.data.currentItem; if ((Object)(object)currentItem == (Object)null || currentItem is Backpack) { return; } if (!TryGetActivePack(character, out var info) || info.Kind != PackKind.Jetpack) { _fuelAfterPickup = false; return; } _fuelAfterPickup = false; try { if (info.IsHeld && (Object)(object)info.HeldItem != (Object)null) { info.HeldItem.AddFuel(character); } else if (character.refs != null && (Object)(object)character.refs.backpackHandler != (Object)null) { character.refs.backpackHandler.AddFuelToJetpack(character, ComputeFuelAmount(currentItem, currentItem.data)); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Jetpack fuel convert failed: " + ex)); } } } internal static Item GetHoveredWorldItem() { return GameAccess.GetHoveredItem(); } internal static bool IsLookingAtOwnWornPack(Character character) { IInteractible hoveredInteractable = GameAccess.GetHoveredInteractable(); if (hoveredInteractable == null || (Object)(object)character == (Object)null) { return false; } Component val = (Component)(object)((hoveredInteractable is Component) ? hoveredInteractable : null); if ((Object)(object)val == (Object)null) { return false; } if ((Object)(object)val.GetComponentInParent() == (Object)null) { return false; } Character componentInParent = val.GetComponentInParent(); return (Object)(object)componentInParent == (Object)(object)character; } private static void TryStoreHeldItem(Character character, PackInfo info) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) CharacterItems val = ((character.refs != null) ? character.refs.items : null); if (!((Object)(object)val == (Object)null) && !val.currentSelectedSlot.IsNone) { byte value = val.currentSelectedSlot.Value; if ((info.Kind == PackKind.Jetpack) ? TryFuelPlayerSlot(character, value) : TryStashPlayerSlot(character, value)) { val.EquipSlot(Optionable.None); } } } private static void TryStoreHeldIntoGroundPack(Character character, Backpack backpack) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Invalid comparison between Unknown and I4 //IL_00d1: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null || (Object)(object)backpack == (Object)null) { return; } CharacterItems val = ((character.refs != null) ? character.refs.items : null); if ((Object)(object)val == (Object)null || val.currentSelectedSlot.IsNone) { return; } byte value = val.currentSelectedSlot.Value; ItemSlot itemSlot = character.player.GetItemSlot(value); if (itemSlot == null || itemSlot.IsEmpty() || (Object)(object)itemSlot.prefab == (Object)null) { return; } if ((int)backpack.backpackType == 3) { float num = ComputeFuelAmount(itemSlot.prefab, itemSlot.data); character.player.EmptySlot(Optionable.Some(value)); val.EquipSlot(Optionable.None); try { JetpackItem component = ((Component)backpack).GetComponent(); if ((Object)(object)component != (Object)null) { component.AddFuel(num); } return; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Ground jetpack fuel failed: " + ex)); } return; } } if (!ItemCanGoInPack(itemSlot.prefab)) { return; } BackpackData data = EnsureStorageSlots(((Item)backpack).GetData((DataEntryKey)7)); if (TryGetFirstEmptySlot(data, backpack.slotCount, out var slotId)) { PhotonView component2 = ((Component)character.player).GetComponent(); PhotonView component3 = ((Component)backpack).GetComponent(); if (!((Object)(object)component2 == (Object)null) && !((Object)(object)component3 == (Object)null)) { component3.RPC("RPCAddItemToBackpack", (RpcTarget)0, new object[3] { component2, value, slotId }); character.player.EmptySlot(Optionable.Some(value)); val.EquipSlot(Optionable.None); GameAccess.RefreshBackpackVisuals(backpack); } } } internal static bool TryGetFirstEmptySlot(BackpackData data, int slotCount, out byte slotId) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown slotId = 0; if (data == null || data.itemSlots == null) { return false; } int num = Mathf.Min(Mathf.Max(slotCount, 0), data.itemSlots.Length); for (byte b = 0; b < num; b++) { if (data.itemSlots[b] == null || data.itemSlots[b].IsEmpty()) { if (data.itemSlots[b] == null) { data.itemSlots[b] = new ItemSlot(b); } slotId = b; return true; } } return false; } private static bool HasInventorySpace(Character character, Item item) { try { return character.player.HasEmptySlot(item.itemID); } catch { return true; } } private static void DirectStashWorldItem(Character character, PackInfo info, Item item) { info.Storage = EnsureStorageSlots(info.Storage); if (TryGetFirstEmptySlot(info.Storage, info.SlotCount, out var slotId)) { Item val = default(Item); if (!ItemDatabase.TryGetItem(item.itemID, ref val) || (Object)(object)val == (Object)null) { val = item; } info.Storage.AddItem(val, item.data, slotId); PhotonView component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null) { PhotonNetwork.Destroy(component); } RefreshPackAfterChange(character, info); } } private static void DirectFuelWorldItem(Character character, PackInfo info, Item item) { float fuel = ComputeFuelAmount(item, item.data); PhotonView component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null) { PhotonNetwork.Destroy(component); } AddFuel(character, info, fuel); RefreshPackAfterChange(character, info); } private static void AddFuel(Character character, PackInfo info, float fuel) { if (info.IsHeld && (Object)(object)info.HeldItem != (Object)null) { JetpackItem component = ((Component)info.HeldItem).GetComponent(); if ((Object)(object)component != (Object)null) { component.AddFuel(fuel); } return; } PhotonView component2 = ((Component)character).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.RPC("RPCAddFuelToJetpack", (RpcTarget)0, new object[1] { fuel }); } } private static float ComputeFuelAmount(Item prefab, ItemInstanceData data) { int num = 25; if ((Object)(object)prefab == (Object)null) { return num; } try { FloatItemData val = default(FloatItemData); if (data != null && data.HasData((DataEntryKey)10) && data.TryGetDataEntry((DataEntryKey)10, ref val)) { return prefab.overrideJetpackFuelAmount + Mathf.RoundToInt(val.Value * prefab.overrideJetpackFuelPerFuelMult); } if (prefab is Backpack) { return prefab.overrideJetpackFuelAmount; } if (prefab.overrideJetpackFuel) { OptionableIntItemData val2 = default(OptionableIntItemData); if (data != null && data.HasData((DataEntryKey)2) && data.TryGetDataEntry((DataEntryKey)2, ref val2)) { return prefab.overrideJetpackFuelAmount + val2.Value * prefab.overrideJetpackFuelPerUse; } return prefab.overrideJetpackFuelAmount; } } catch { } return num; } private static bool StashPlayerSlotTo(Character character, PackInfo info, byte slotId, byte destSlot) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) PhotonView component = ((Component)character.player).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } if (info.IsHeld && (Object)(object)info.HeldItem != (Object)null) { PhotonView component2 = ((Component)info.HeldItem).GetComponent(); if ((Object)(object)component2 == (Object)null) { return false; } component2.RPC("RPCAddItemToBackpack", (RpcTarget)0, new object[3] { component, slotId, destSlot }); } else { PhotonView component3 = ((Component)character).GetComponent(); if ((Object)(object)component3 == (Object)null) { return false; } component3.RPC("RPCAddItemToCharacterBackpack", (RpcTarget)0, new object[3] { component, slotId, destSlot }); } character.player.EmptySlot(Optionable.Some(slotId)); RefreshPackAfterChange(character, info); return true; } private static void SyncHeldBackpackData(Backpack backpack) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)backpack == (Object)null) { return; } PhotonView component = ((Component)backpack).GetComponent(); if (!((Object)(object)component == (Object)null)) { BackpackReference fromBackpackItem = BackpackReference.GetFromBackpackItem((Item)(object)backpack); ItemInstanceData itemInstanceData = ((BackpackReference)(ref fromBackpackItem)).GetItemInstanceData(); if (itemInstanceData != null) { component.RPC("SetItemInstanceDataRPC", (RpcTarget)1, new object[1] { itemInstanceData }); } } } private static bool TryGetSpawnedPackItem(BackpackReference reference, byte slotId, out Item item) { item = null; try { if (!((BackpackReference)(ref reference)).exists || (Object)(object)((BackpackReference)(ref reference)).GetVisuals() == (Object)null) { return false; } return ((BackpackReference)(ref reference)).GetVisuals().TryGetSpawnedItem(slotId, ref item) && (Object)(object)item != (Object)null; } catch { return false; } } private static void RefreshPackAfterChange(Character character, PackInfo info) { try { if (character.refs != null && (Object)(object)character.refs.items != (Object)null) { character.refs.items.RefreshAllCharacterCarryWeight(); } } catch { } try { if (info.IsHeld && (Object)(object)info.HeldItem != (Object)null) { HeldBackpackInventory.RefreshWheel(info.HeldItem); } else { HeldBackpackInventory.RefreshOpenWheel(); } if (!info.IsHeld && character.refs != null && (Object)(object)character.refs.backpackHandler != (Object)null && (Object)(object)character.refs.backpackHandler.activeBackpackVisuals != (Object)null) { ((BackpackVisuals)character.refs.backpackHandler.activeBackpackVisuals).RefreshVisuals(); ((BackpackVisuals)character.refs.backpackHandler.activeBackpackVisuals).RefreshPocketBehaviors(character.player); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Pack visual refresh failed: " + ex.Message)); } } } private static BackpackData EnsureStorageSlots(BackpackData data) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if (data == null) { return null; } if (data.itemSlots == null) { data.itemSlots = (ItemSlot[])(object)new ItemSlot[4]; } for (byte b = 0; b < data.itemSlots.Length; b++) { if (data.itemSlots[b] == null) { data.itemSlots[b] = new ItemSlot(b); } } return data; } private static BackpackData GetWornStorage(BackpackSlot slot) { if (slot == null) { return null; } try { if (((ItemSlot)slot).data == null) { return null; } BackpackData val = default(BackpackData); if (!((ItemSlot)slot).data.TryGetDataEntry((DataEntryKey)7, ref val) || val == null) { val = ((ItemSlot)slot).data.RegisterNewEntry((DataEntryKey)7); } return EnsureStorageSlots(val); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Worn pack storage read failed: " + ex.Message)); } return null; } } private static int GetWornSlotCount(Character character, PackKind kind) { if (kind == PackKind.Jetpack) { return 0; } try { if (character.refs != null && (Object)(object)character.refs.backpackHandler != (Object)null && (Object)(object)character.refs.backpackHandler.activeBackpackVisuals != (Object)null) { return character.refs.backpackHandler.activeBackpackVisuals.slotCount; } } catch { } return 4; } private static PackKind ToKind(BackpackType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 if ((int)type == 1) { return PackKind.Backpack; } if ((int)type == 2) { return PackKind.Fannypack; } if ((int)type == 3) { return PackKind.Jetpack; } if ((int)type == 4) { return PackKind.Jetpack; } return PackKind.None; } private static void BeginPending(PendingAction action) { _pending = action; _pendingUntil = Time.time + 2f; _fuelAfterPickup = false; } private static void ClearPending() { _pending = PendingAction.None; } } internal static class NestedPacks { private struct SavedNestedSlot { public ItemSlot Slot; public Item Prefab; } private static readonly List HiddenNestedSlots = new List(); internal static int ExtraNestedWeight(Character character) { if (!Plugin.IsAllowNestedPacks() || (Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null) { return 0; } if (character.player.backpackSlot == null || ((ItemSlot)character.player.backpackSlot).IsEmpty()) { return 0; } BackpackData val = default(BackpackData); if (((ItemSlot)character.player.backpackSlot).data == null || !((ItemSlot)character.player.backpackSlot).data.TryGetDataEntry((DataEntryKey)7, ref val) || val == null || val.itemSlots == null) { return 0; } int num = 0; for (int i = 0; i < val.itemSlots.Length; i++) { num += ContentsWeight(val.itemSlots[i], 0); } return num; } internal static void HideNestedPackVisuals(BackpackVisuals visuals) { HiddenNestedSlots.Clear(); if (!Plugin.IsAllowNestedPacks() || (Object)(object)visuals == (Object)null || !(visuals is BackpackOnBackVisuals)) { return; } BackpackData backpackData; try { backpackData = visuals.GetBackpackData(); } catch { return; } if (backpackData == null || backpackData.itemSlots == null) { return; } SavedNestedSlot item = default(SavedNestedSlot); for (int i = 0; i < backpackData.itemSlots.Length; i++) { ItemSlot val = backpackData.itemSlots[i]; if (val != null && !val.IsEmpty() && val.prefab is Backpack) { item.Slot = val; item.Prefab = val.prefab; HiddenNestedSlots.Add(item); val.prefab = null; } } } internal static void RestoreNestedPackVisuals() { for (int i = 0; i < HiddenNestedSlots.Count; i++) { SavedNestedSlot savedNestedSlot = HiddenNestedSlots[i]; if (savedNestedSlot.Slot != null) { savedNestedSlot.Slot.prefab = savedNestedSlot.Prefab; } } HiddenNestedSlots.Clear(); } internal static void DetachGroundedVisuals(BackpackVisuals visuals) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 if ((Object)(object)visuals == (Object)null || visuals.visualItems == null) { return; } byte[] array = new byte[visuals.visualItems.Count]; visuals.visualItems.Keys.CopyTo(array, 0); foreach (byte key in array) { if (!visuals.visualItems.TryGetValue(key, out (GameObject, ushort) value) || (Object)(object)value.Item1 == (Object)null) { visuals.visualItems.Remove(key); if (visuals.spawnedVisualItems != null) { visuals.spawnedVisualItems.Remove(key); } continue; } Item component = value.Item1.GetComponent(); if (!((Object)(object)component != (Object)null) || (int)component.itemState != 2) { visuals.visualItems.Remove(key); if (visuals.spawnedVisualItems != null) { visuals.spawnedVisualItems.Remove(key); } } } } internal static bool TryTakeFromWheel(BackpackReference reference, byte slotId, Character interactor) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.IsAllowNestedPacks() || (Object)(object)interactor == (Object)null || !((BackpackReference)(ref reference)).exists) { return false; } if (TryGetSpawnedItem(reference, slotId, out var item) && item is Backpack && (int)item.itemState == 2) { return TryDropInnerPack(item, interactor); } BackpackData data; try { data = ((BackpackReference)(ref reference)).GetData(); } catch { return false; } if (data == null || data.itemSlots == null || slotId >= data.itemSlots.Length) { return false; } ItemSlot val = data.itemSlots[slotId]; if (val == null || val.IsEmpty() || !(val.prefab is Backpack)) { return false; } if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient) { DualPack.RequestTakeNested(reference, slotId, interactor); return true; } return TakeNestedOnMaster(reference, slotId, interactor); } internal static bool TakeNestedOnMaster(BackpackReference reference, byte slotId, Character interactor) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom) { return false; } BackpackData data; try { data = ((BackpackReference)(ref reference)).GetData(); } catch { return false; } if (data == null || data.itemSlots == null || slotId >= data.itemSlots.Length) { return false; } ItemSlot packSlot = data.itemSlots[slotId]; if (!TrySpawnAndDrop(interactor, packSlot)) { return false; } SyncOuter(reference); return true; } private static bool TryGetSpawnedItem(BackpackReference reference, byte slotId, out Item item) { item = null; try { BackpackVisuals visuals = ((BackpackReference)(ref reference)).GetVisuals(); return (Object)(object)visuals != (Object)null && visuals.TryGetSpawnedItem(slotId, ref item) && (Object)(object)item != (Object)null; } catch { return false; } } private static void SyncOuter(BackpackReference reference) { //IL_000a: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_005b: 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_00c1: Unknown result type (might be due to invalid IL or missing references) if (!((BackpackReference)(ref reference)).exists || (Object)(object)reference.view == (Object)null) { return; } try { if ((int)reference.type == 0) { reference.view.RPC("SetItemInstanceDataRPC", (RpcTarget)1, new object[1] { ((BackpackReference)(ref reference)).GetItemInstanceData() }); } else { Character component = ((Component)reference.view).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.player == (Object)null) { return; } if (DualPack.HasStorage(component)) { DualPack.Broadcast(component); } else { byte[] array = IBinarySerializable.ToManagedArray(new InventorySyncData(component.player.itemSlots, component.player.backpackSlot, component.player.tempFullSlot)); ((MonoBehaviourPun)component.player).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2] { array, false }); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Nested pack outer sync failed: " + ex)); } } try { BackpackVisuals visuals = ((BackpackReference)(ref reference)).GetVisuals(); if ((Object)(object)visuals != (Object)null) { visuals.RefreshVisuals(); } } catch { } } internal static bool TryDropInnerPack(Item visual, Character interactor) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.IsAllowNestedPacks() || (Object)(object)visual == (Object)null || !(visual is Backpack)) { return false; } if ((int)visual.itemState != 2) { return false; } if (!TryGetPrefabName(visual, out var name)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Nested pack drop failed: no prefab name for itemID " + visual.itemID)); } return false; } Vector3 dropPos = DropPosition(interactor); ItemInstanceData data = CloneInstance(visual.data); if (!SpawnGroundPack(name, data, dropPos)) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)("Nested pack drop failed: could not spawn " + name)); } return false; } try { if (!visual.backpackReference.IsNone) { visual.ClearDataFromBackpack(); } } catch (Exception ex) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogError((object)("Nested pack slot clear failed: " + ex)); } } if ((Object)(object)interactor != (Object)null && interactor.refs != null && (Object)(object)interactor.refs.afflictions != (Object)null) { interactor.refs.afflictions.UpdateWeight(); } return true; } internal static bool TrySpawnAndDrop(Character interactor, ItemSlot packSlot) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.IsAllowNestedPacks() || (Object)(object)interactor == (Object)null || packSlot == null || packSlot.IsEmpty() || (Object)(object)packSlot.prefab == (Object)null) { return false; } if (!(packSlot.prefab is Backpack)) { return false; } if (!TryGetPrefabName(packSlot, out var name)) { return false; } ItemInstanceData data = CloneInstance(packSlot.data); if (!SpawnGroundPack(name, data, DropPosition(interactor))) { return false; } packSlot.EmptyOut(); if (interactor.refs != null && (Object)(object)interactor.refs.afflictions != (Object)null) { interactor.refs.afflictions.UpdateWeight(); } return true; } private static bool SpawnGroundPack(string prefabName, ItemInstanceData data, Vector3 dropPos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) GameObject val = PhotonNetwork.Instantiate("0_Items/" + prefabName, dropPos, Quaternion.identity, (byte)0, (object[])null); if ((Object)(object)val == (Object)null) { return false; } Item component = val.GetComponent(); if ((Object)(object)component == (Object)null) { PhotonNetwork.Destroy(val); return false; } if (data != null && (Object)(object)((MonoBehaviourPun)component).photonView != (Object)null) { ((MonoBehaviourPun)component).photonView.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { data }); } PlaceOnGround(component, dropPos, val.transform.rotation); try { component.SetKinematicNetworked(false, dropPos, val.transform.rotation); } catch { } try { GameAccess.RefreshBackpackVisuals((Backpack)(object)((component is Backpack) ? component : null)); } catch { } return true; } private static void PlaceOnGround(Item item, Vector3 dropPos, Quaternion dropRot) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) ((Component)item).transform.SetParent((Transform)null, true); ((Component)item).gameObject.SetActive(true); Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { componentsInChildren[i].enabled = true; } } Backpack val = (Backpack)(object)((item is Backpack) ? item : null); if ((Object)(object)val != (Object)null) { try { val.EnableVisuals(); } catch { } } item.SetState((ItemState)0, (Character)null); item.Move(dropPos, dropRot); item.ForceSyncForFrames(15); } private static Vector3 DropPosition(Character interactor) { //IL_0015: 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_0024: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)interactor == (Object)null) { return Vector3.up; } return interactor.Center + Vector3.up * 0.45f + ((Component)interactor).transform.forward * 0.35f; } private static bool TryGetPrefabName(Item item, out string name) { name = null; Item val = default(Item); if (ItemDatabase.TryGetItem(item.itemID, ref val) && (Object)(object)val != (Object)null) { name = ((Object)((Component)val).gameObject).name; return true; } name = StripClone(((Object)((Component)item).gameObject).name); return !string.IsNullOrEmpty(name); } private static bool TryGetPrefabName(ItemSlot slot, out string name) { name = null; if (slot != null && (Object)(object)slot.prefab != (Object)null) { name = ((Object)((Component)slot.prefab).gameObject).name; return true; } name = ((slot != null) ? slot.GetPrefabName() : null); return !string.IsNullOrEmpty(name); } private static string StripClone(string objectName) { if (string.IsNullOrEmpty(objectName)) { return objectName; } if (objectName.EndsWith("(Clone)", StringComparison.Ordinal)) { return objectName.Substring(0, objectName.Length - "(Clone)".Length).Trim(); } return objectName; } internal static ItemInstanceData CloneInstance(ItemInstanceData source) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0068: 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) ItemInstanceData val = new ItemInstanceData(Guid.NewGuid()); ItemInstanceDataHandler.AddInstanceData(val); if (source == null || source.data == null) { return val; } DataEntryValue val3 = default(DataEntryValue); foreach (KeyValuePair datum in source.data) { DataEntryValue value = datum.Value; BackpackData val2 = (BackpackData)(object)((value is BackpackData) ? value : null); if (val2 != null) { val.data[datum.Key] = (DataEntryValue)(object)CloneBackpackData(val2); } else if (DataEntryValue.TryCopy(datum.Value, ref val3) && val3 != null) { val.data[datum.Key] = val3; } } return val; } private static BackpackData CloneBackpackData(BackpackData source) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown BackpackData val = new BackpackData(); ((DataEntryValue)val).Init(); if (source == null) { return val; } val.litRocketData = source.litRocketData; if (source.itemSlots == null) { return val; } int num = Mathf.Min(source.itemSlots.Length, val.itemSlots.Length); for (int i = 0; i < num; i++) { ItemSlot val2 = source.itemSlots[i]; if (val2 != null && !val2.IsEmpty() && !((Object)(object)val2.prefab == (Object)null)) { val.itemSlots[i].SetItem(val2.prefab, CloneInstance(val2.data)); } } return val; } private static int ContentsWeight(ItemSlot slot, int depth) { if (depth > 4 || slot == null || slot.IsEmpty() || (Object)(object)slot.prefab == (Object)null) { return 0; } if (!(slot.prefab is Backpack)) { return 0; } BackpackData val = default(BackpackData); if (slot.data == null || !slot.data.TryGetDataEntry((DataEntryKey)7, ref val) || val == null || val.itemSlots == null) { return 0; } int num = 0; for (int i = 0; i < val.itemSlots.Length; i++) { ItemSlot val2 = val.itemSlots[i]; if (val2 != null && !val2.IsEmpty() && !((Object)(object)val2.prefab == (Object)null)) { num += val2.prefab.CarryWeight; num += ContentsWeight(val2, depth + 1); } } return num; } } internal sealed class DualPack : MonoBehaviour, IOnEventCallback, IInRoomCallbacks { internal struct ExtraStorage { public ushort ItemId; public ItemInstanceData Data; } private sealed class ExtraLoadout { public ExtraStorage Backpack; public ExtraStorage Fanny; } private struct SavedPose { public Vector3 Position; public Quaternion Rotation; public Vector3 LocalCenter; public bool HasCenter; } internal const byte EventCode = 194; private const string Magic = "tony4twentys.PEAK_Packs"; private const string Protocol = "DUAL_V3"; private const string ProtocolV2 = "DUAL_V2"; private const string ProtocolLegacy = "DUAL_V1"; private const string TakeNested = "TAKE_NESTED"; private const string FannyYawSync = "FANNY_YAW"; private const string FrontWheelSync = "FRONT_WHEEL"; private const string FannyFlipSync = "FANNY_FLIP"; private const string CombinePickup = "COMBINE_V1"; private const string HostCfg = "HOST_CFG"; private const string PrivacySync = "PRIVACY"; private static DualPack _instance; private static readonly Dictionary ExtraByActor = new Dictionary(); private static readonly Dictionary FannyPosByActor = new Dictionary(); private static readonly Dictionary InspectByActor = new Dictionary(); private static readonly Dictionary ConsumedUntilByView = new Dictionary(); private static bool _sentFannyPos; private static FannyPackPosition _sentFannyPosValue; private static bool _sentInspect; private static byte _sentInspectValue; private const byte InspectNone = 0; private const byte InspectBackpack = 1; private const byte InspectFanny = 2; private static readonly Dictionary ProtectUntilByActor = new Dictionary(); private static readonly Dictionary EmptiedByActor = new Dictionary(); internal static bool DropSlot3Active; private static float _nextExtraBroadcast; private static float _nextConsumedPrune; private static bool _wasInRoom; private static bool _sentHostRules; private static bool _sentPrivacy; private static PackPrivacyMode _sentPrivacyValue; internal static bool HasHostRules; internal static bool HostAllowMultipack; internal static bool HostAllowUtilityAndBackpack; internal static bool HostAllowUtilityAndFannypack; internal static bool HostBackpackInFrontWhenWearingUtility = true; internal static bool HostLookOnlyAllowStash; internal static bool HostAllowAnyItemInPack; internal static bool HostAllowNestedPacks; internal static bool HostKeepPackWhileCarrying; internal static bool HostFrontPackWhenOpenAnytime; internal static BackpackType WheelType; private static readonly Dictionary BackpackPoses = new Dictionary(); private static readonly Dictionary FannyPoses = new Dictionary(); internal static void Ensure() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { GameObject val = new GameObject("PEAKPacks_DualPack"); Object.DontDestroyOnLoad((Object)(object)val); _instance = val.AddComponent(); } } private void OnEnable() { PhotonNetwork.AddCallbackTarget((object)this); } private void OnDisable() { PhotonNetwork.RemoveCallbackTarget((object)this); } internal static bool IsFlightPack(BackpackType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 return (int)type == 3 || (int)type == 4; } private static bool Has(ExtraStorage extra) { return extra.ItemId != 0 && extra.Data != null; } internal static bool HasStorage(Character character) { ExtraLoadout loadout = GetLoadout(character, create: false); return loadout != null && (Has(loadout.Backpack) || Has(loadout.Fanny)); } internal static bool HasBackpackExtra(Character character) { ExtraLoadout loadout = GetLoadout(character, create: false); return loadout != null && Has(loadout.Backpack); } internal static bool HasFannyExtra(Character character) { ExtraLoadout loadout = GetLoadout(character, create: false); return loadout != null && Has(loadout.Fanny); } internal static bool CanAccept(Player player, ushort itemId) { if (!Plugin.IsEnabled()) { return false; } Backpack incoming; return CanPair(player, itemId, out incoming); } private static bool CanPair(Player player, ushort itemId, out Backpack incoming) { //IL_00dc: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Invalid comparison between Unknown and I4 //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Invalid comparison between Unknown and I4 //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Invalid comparison between Unknown and I4 //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Invalid comparison between Unknown and I4 //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Invalid comparison between Unknown and I4 //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Invalid comparison between Unknown and I4 //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Invalid comparison between Unknown and I4 //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Invalid comparison between Unknown and I4 incoming = null; if ((Object)(object)player == (Object)null || (Object)(object)player.character == (Object)null || player.backpackSlot == null) { return false; } Character character = player.character; CharacterItems val = ((character.refs != null) ? character.refs.items : null); if ((Object)(object)val != (Object)null && val.currentSelectedSlot.IsSome && val.currentSelectedSlot.Value == 3) { return false; } Item val2 = default(Item); if (!ItemDatabase.TryGetItem(itemId, ref val2)) { return false; } incoming = (Backpack)(object)((val2 is Backpack) ? val2 : null); if ((Object)(object)incoming == (Object)null) { return false; } BackpackSlot backpackSlot = player.backpackSlot; if (((ItemSlot)backpackSlot).IsEmpty()) { return false; } if (IsFlightPack(incoming.backpackType)) { if (IsFlightPack(backpackSlot.backpackType)) { return false; } bool flag = (int)backpackSlot.backpackType == 1 || HasBackpackExtra(character); bool flag2 = (int)backpackSlot.backpackType == 2 || HasFannyExtra(character); if (flag && !Plugin.IsAllowUtilityAndBackpack()) { return false; } if (flag2 && !Plugin.IsAllowUtilityAndFannypack()) { return false; } return flag || flag2; } if (!Plugin.IsAllowMultipack()) { return false; } if ((int)incoming.backpackType == 1) { if ((int)backpackSlot.backpackType == 1 || HasBackpackExtra(character)) { return false; } if (IsFlightPack(backpackSlot.backpackType)) { return Plugin.IsAllowUtilityAndBackpack(); } return (int)backpackSlot.backpackType == 2; } if ((int)incoming.backpackType == 2) { if ((int)backpackSlot.backpackType == 2 || HasFannyExtra(character)) { return false; } if (IsFlightPack(backpackSlot.backpackType)) { return Plugin.IsAllowUtilityAndFannypack(); } return (int)backpackSlot.backpackType == 1; } return false; } internal static bool TryGet(Character character, out ExtraStorage extra) { extra = default(ExtraStorage); ExtraLoadout loadout = GetLoadout(character, create: false); if (loadout == null) { return false; } if (Has(loadout.Backpack)) { extra = loadout.Backpack; return true; } if (Has(loadout.Fanny)) { extra = loadout.Fanny; return true; } return false; } internal static bool TryGetExtraStorage(Character character, BackpackType type, out BackpackData data, out int slotCount) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 data = null; slotCount = 4; ExtraLoadout loadout = GetLoadout(character, create: false); if (loadout == null) { return false; } if ((int)type == 1) { return Has(loadout.Backpack) && TryReadStorage(loadout.Backpack, out data, out slotCount); } if ((int)type == 2) { return Has(loadout.Fanny) && TryReadStorage(loadout.Fanny, out data, out slotCount); } return false; } internal static int CollectWornTypes(Character character, BackpackType[] types) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected I4, but got Unknown if (types == null || types.Length == 0 || (Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null || character.player.backpackSlot == null) { return 0; } int num = 0; BackpackSlot backpackSlot = character.player.backpackSlot; if (num < types.Length && (HasBackpackExtra(character) || (int)backpackSlot.backpackType == 1)) { types[num++] = (BackpackType)1; } if (num < types.Length && (HasFannyExtra(character) || (int)backpackSlot.backpackType == 2)) { types[num++] = (BackpackType)2; } if (num < types.Length && IsFlightPack(backpackSlot.backpackType)) { types[num++] = (BackpackType)(int)backpackSlot.backpackType; } return num; } internal static bool TryGetStorageData(Character character, out BackpackData data, out int slotCount) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) ExtraLoadout loadout = GetLoadout(character, create: false); data = null; slotCount = 4; if (loadout != null && Has(loadout.Backpack)) { return TryReadStorage(loadout.Backpack, out data, out slotCount); } Player val = (((Object)(object)character != (Object)null) ? character.player : null); if ((Object)(object)val != (Object)null && val.backpackSlot != null && IsFlightPack(val.backpackSlot.backpackType) && loadout != null && Has(loadout.Fanny)) { return TryReadStorage(loadout.Fanny, out data, out slotCount); } return false; } internal static bool TryGetWheelStorage(Character character, out BackpackData data, out int slotCount) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 ExtraLoadout loadout = GetLoadout(character, create: false); data = null; slotCount = 4; if (loadout == null) { return false; } if ((int)WheelType == 2) { return Has(loadout.Fanny) && TryReadStorage(loadout.Fanny, out data, out slotCount); } if ((int)WheelType == 1) { return Has(loadout.Backpack) && TryReadStorage(loadout.Backpack, out data, out slotCount); } return false; } internal static bool TryResolveEquippedData(Character character, out BackpackData data) { int slotCount; return TryGetWheelStorage(character, out data, out slotCount); } internal static BackpackType GetExtraPackType(Character character) { //IL_0016: 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) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!TryGet(character, out var extra)) { return (BackpackType)1; } return TypeOf(extra, (BackpackType)1); } internal static int ExtraWeight(Character character) { ExtraLoadout loadout = GetLoadout(character, create: false); if (loadout == null) { return 0; } return StorageWeight(loadout.Backpack) + StorageWeight(loadout.Fanny); } internal static bool TryCombine(Player player, ushort itemId, ItemInstanceData instanceData, out ItemSlot slot) { //IL_004a: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Invalid comparison between Unknown and I4 //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) slot = null; if (!Plugin.IsEnabled()) { return false; } if (!CanPair(player, itemId, out var incoming)) { return false; } Character character = player.character; BackpackSlot backpackSlot = player.backpackSlot; ItemInstanceData val = (ItemInstanceData)((instanceData != null) ? ((object)NestedPacks.CloneInstance(instanceData)) : ((object)new ItemInstanceData(Guid.NewGuid()))); if (IsFlightPack(incoming.backpackType)) { ParkSlotIntoExtra(character, backpackSlot); backpackSlot.backpackType = incoming.backpackType; ((ItemSlot)backpackSlot).SetItem((Item)(object)incoming, val); } else if ((int)incoming.backpackType == 1) { if ((int)backpackSlot.backpackType == 2) { SetFannyExtra(character, (ushort)(((Object)(object)((ItemSlot)backpackSlot).prefab != (Object)null) ? ((ItemSlot)backpackSlot).prefab.itemID : 0), NestedPacks.CloneInstance(((ItemSlot)backpackSlot).data)); backpackSlot.backpackType = incoming.backpackType; ((ItemSlot)backpackSlot).SetItem((Item)(object)incoming, val); } else { SetBackpackExtra(character, ((Item)incoming).itemID, val); } } else { SetFannyExtra(character, ((Item)incoming).itemID, val); } slot = (ItemSlot)(object)backpackSlot; SyncInventory(player); Broadcast(character); if (character.refs != null && (Object)(object)character.refs.afflictions != (Object)null) { character.refs.afflictions.UpdateWeight(); } return true; } internal static bool TryConsumeGroundPack(Item item, Character taker) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_010a: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown if (!Plugin.IsEnabled() || (Object)(object)item == (Object)null || (Object)(object)taker == (Object)null || (Object)(object)taker.player == (Object)null) { return false; } if (!(item is Backpack) || (int)item.itemState > 0) { return false; } if (!CanAccept(taker.player, item.itemID)) { return false; } PhotonView val = ViewOf(item); PhotonView val2 = (((Object)(object)((MonoBehaviourPun)taker).photonView != (Object)null) ? ((MonoBehaviourPun)taker).photonView : ((taker.refs != null) ? taker.refs.view : null)); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return false; } HideWorldItem(val.ViewID); PhotonNetwork.RaiseEvent((byte)194, (object)new object[4] { "tony4twentys.PEAK_Packs", "COMBINE_V1", val.ViewID, val2.ViewID }, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); if (PhotonNetwork.IsMasterClient) { FinishConsume(val.ViewID, val2.ViewID); } return true; } internal static bool AlreadyConsumed(Item item) { PhotonView val = ViewOf(item); return (Object)(object)val != (Object)null && AlreadyConsumed(val.ViewID); } private static bool AlreadyConsumed(int viewId) { float value; return ConsumedUntilByView.TryGetValue(viewId, out value) && Time.realtimeSinceStartup < value; } private static void MarkConsumed(int viewId) { ConsumedUntilByView[viewId] = Time.realtimeSinceStartup + 8f; } private static void PruneConsumed() { if (ConsumedUntilByView.Count == 0 || Time.realtimeSinceStartup < _nextConsumedPrune) { return; } _nextConsumedPrune = Time.realtimeSinceStartup + 8f; List list = null; foreach (KeyValuePair item in ConsumedUntilByView) { if (!(item.Value >= Time.realtimeSinceStartup)) { if (list == null) { list = new List(); } list.Add(item.Key); } } if (list != null) { for (int i = 0; i < list.Count; i++) { ConsumedUntilByView.Remove(list[i]); } } } private static void FinishConsume(int itemViewId, int takerViewId) { if (!PhotonNetwork.IsMasterClient || AlreadyConsumed(itemViewId)) { return; } PhotonView val = PhotonView.Find(itemViewId); PhotonView val2 = PhotonView.Find(takerViewId); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return; } Item component = ((Component)val).GetComponent(); Character component2 = ((Component)val2).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component2.player == (Object)null) { return; } MarkConsumed(itemViewId); HideWorldItem(itemViewId); if (!TryCombine(component2.player, component.itemID, component.data, out var slot) || slot == null) { ConsumedUntilByView.Remove(itemViewId); try { ((Component)component).gameObject.SetActive(true); return; } catch { return; } } if (component2.refs != null && (Object)(object)component2.refs.view != (Object)null && (Object)(object)((MonoBehaviourPun)component2.player).photonView != (Object)null) { component2.refs.view.RPC("OnPickupAccepted", ((MonoBehaviourPun)component2.player).photonView.Owner, new object[1] { slot.itemSlotID }); } DestroyWorldItem(component); } private static void HandleCombinePickup(object[] payload) { if (payload != null && payload.Length >= 4) { int num = Convert.ToInt32(payload[2]); int takerViewId = Convert.ToInt32(payload[3]); HideWorldItem(num); FinishConsume(num, takerViewId); } } private static void HideWorldItem(int viewId) { PhotonView val = PhotonView.Find(viewId); if ((Object)(object)val == (Object)null) { return; } try { ((Component)val).gameObject.SetActive(false); } catch { } } private static void DestroyWorldItem(Item item) { PhotonView val = ViewOf(item); if ((Object)(object)val == (Object)null || !PhotonNetwork.IsMasterClient) { return; } try { PhotonNetwork.Destroy(val); } catch { try { PhotonNetwork.Destroy(((Component)val).gameObject); } catch { } } } private static PhotonView ViewOf(Item item) { if ((Object)(object)item == (Object)null) { return null; } if ((Object)(object)item.view != (Object)null) { return item.view; } return ((MonoBehaviourPun)item).photonView; } internal static bool ShouldProtectRestoredSlot(Player player) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || player.backpackSlot == null || ((ItemSlot)player.backpackSlot).IsEmpty()) { return false; } if (IsFlightPack(player.backpackSlot.backpackType)) { return false; } int num = ActorOf(player.character); float value; return num >= 0 && ProtectUntilByActor.TryGetValue(num, out value) && Time.realtimeSinceStartup < value; } internal static bool ShouldSkipClientRemoveRpc(Player player) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (DropSlot3Active) { return true; } return (Object)(object)player != (Object)null && player.backpackSlot != null && IsFlightPack(player.backpackSlot.backpackType) && HasStorage(player.character); } internal static void CaptureRestore(Player player) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Invalid comparison between Unknown and I4 //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Invalid comparison between Unknown and I4 SetEmptied(player, (BackpackType)0); if ((Object)(object)player == (Object)null || player.backpackSlot == null || ((ItemSlot)player.backpackSlot).IsEmpty()) { return; } BackpackType backpackType = player.backpackSlot.backpackType; SetEmptied(player, backpackType); if (IsFlightPack(backpackType)) { return; } ExtraLoadout loadout = GetLoadout(player.character, create: false); if (loadout != null) { if ((int)backpackType == 1 && Has(loadout.Backpack)) { loadout.Backpack = default(ExtraStorage); } else if ((int)backpackType == 2 && Has(loadout.Fanny)) { loadout.Fanny = default(ExtraStorage); } if (!Has(loadout.Backpack) && !Has(loadout.Fanny)) { ClearActor(player.character); } else { Broadcast(player.character); } } } internal static void TryRestoreAfterUtilityRemoved(Player player) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Invalid comparison between Unknown and I4 //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Invalid comparison between Unknown and I4 if ((Object)(object)player == (Object)null || player.backpackSlot == null || !((ItemSlot)player.backpackSlot).IsEmpty()) { return; } ExtraLoadout loadout = GetLoadout(player.character, create: false); if (loadout == null) { return; } BackpackType emptied = GetEmptied(player); ExtraStorage extra = default(ExtraStorage); bool flag = false; if (Has(loadout.Backpack) && (int)emptied != 1) { extra = loadout.Backpack; flag = true; } else if (Has(loadout.Fanny) && (int)emptied != 2) { extra = loadout.Fanny; } if (!Has(extra)) { SetEmptied(player, (BackpackType)0); return; } if (!WearFromExtra(player, extra)) { SetEmptied(player, (BackpackType)0); return; } if (flag) { loadout.Backpack = default(ExtraStorage); } else { loadout.Fanny = default(ExtraStorage); } ReconcileExtras(player.character); loadout = GetLoadout(player.character, create: false); if (loadout == null || (!Has(loadout.Backpack) && !Has(loadout.Fanny))) { ClearActor(player.character); } SetEmptied(player, (BackpackType)0); int num = ActorOf(player.character); if (num >= 0) { ProtectUntilByActor[num] = Time.realtimeSinceStartup + 2f; } Broadcast(player.character); SyncInventory(player); if ((Object)(object)player.character != (Object)null && player.character.refs != null && (Object)(object)player.character.refs.afflictions != (Object)null) { player.character.refs.afflictions.UpdateWeight(); } } internal static void TickVisuals() { if (!PhotonNetwork.InRoom) { if (_wasInRoom) { _wasInRoom = false; BackpackPoses.Clear(); FannyPoses.Clear(); ConsumedUntilByView.Clear(); PackPrivacy.ClearAll(); } _sentFannyPos = false; _sentInspect = false; _sentPrivacy = false; HasHostRules = false; _sentHostRules = false; return; } _wasInRoom = true; PruneConsumed(); BroadcastHostRulesIfMaster(); if ((Object)(object)Character.localCharacter != (Object)null && (Object)(object)Character.localCharacter.player != (Object)null && !ShouldProtectRestoredSlot(Character.localCharacter.player)) { ReconcileExtras(Character.localCharacter); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter != (Object)null && HasStorage(localCharacter) && Time.realtimeSinceStartup >= _nextExtraBroadcast) { _nextExtraBroadcast = Time.realtimeSinceStartup + 1.5f; Broadcast(localCharacter); } FannyPackPosition fannyPackPosition = Plugin.GetFannyPackPosition(); byte b = LocalInspect(); int num = ActorOf(localCharacter); if (num >= 0) { FannyPosByActor[num] = fannyPackPosition; InspectByActor[num] = b; } if (!_sentFannyPos || fannyPackPosition != _sentFannyPosValue) { _sentFannyPos = true; _sentFannyPosValue = fannyPackPosition; BroadcastFannyPos(fannyPackPosition); } if (num >= 0 && (!_sentInspect || _sentInspectValue != b)) { _sentInspect = true; _sentInspectValue = b; BroadcastInspect(num, b); } PackPrivacyMode packPrivacy = Plugin.GetPackPrivacy(); if (!_sentPrivacy || _sentPrivacyValue != packPrivacy) { BroadcastPrivacy(); } } internal static void ShowExtraVisuals(CharacterBackpackHandler handler) { if (Plugin.IsEnabled() && !((Object)(object)handler == (Object)null) && !((Object)(object)handler.character == (Object)null) && !((Object)(object)((MonoBehaviourPun)handler.character).photonView == (Object)null)) { bool isSpectating = MainCameraMovement.IsSpectating; bool flag = ((MonoBehaviourPun)handler.character).photonView.IsMine && !isSpectating; bool flag2 = IsHoldingPack(handler); if ((!flag || Plugin.IsShowOwnPacks()) && !flag2) { ShowVanillaWorn(handler, show: true); } ApplyWornExtras(handler); } } internal static void HideLocalPacksAfterMirror() { if (Plugin.IsShowOwnPacks() || MainCameraMovement.IsSpectating) { return; } Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && localCharacter.refs != null && !((Object)(object)localCharacter.refs.backpackHandler == (Object)null)) { CharacterBackpackHandler backpackHandler = localCharacter.refs.backpackHandler; if ((Object)(object)backpackHandler.backpackVisuals != (Object)null) { backpackHandler.backpackVisuals.SetViewActive(false); } if ((Object)(object)backpackHandler.fannypackVisuals != (Object)null) { backpackHandler.fannypackVisuals.SetViewActive(false); } if ((Object)(object)backpackHandler.jetpackVisuals != (Object)null) { backpackHandler.jetpackVisuals.SetViewActive(false); } if ((Object)(object)backpackHandler.rocketpackVisuals != (Object)null) { backpackHandler.rocketpackVisuals.SetViewActive(false); } } } internal static void ShowLocalPacksForMirror() { Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && localCharacter.refs != null && !((Object)(object)localCharacter.refs.backpackHandler == (Object)null)) { CharacterBackpackHandler backpackHandler = localCharacter.refs.backpackHandler; ShowVanillaWorn(backpackHandler, show: true); ApplyWornExtras(backpackHandler); } } private static bool IsHoldingPack(CharacterBackpackHandler handler) { return (Object)(object)handler != (Object)null && (Object)(object)handler.characterItems != (Object)null && handler.characterItems.currentSelectedSlot.IsSome && handler.characterItems.currentSelectedSlot.Value == 3; } private static byte LocalInspect() { if (!Plugin.IsFrontPackWhenOpenAnytime()) { return 0; } if (HeldBackpackInventory.IsOpeningOwnWornPack(PackKind.Backpack)) { return 1; } if (HeldBackpackInventory.IsOpeningOwnWornPack(PackKind.Fannypack)) { return 2; } return 0; } private static byte InspectOf(Character character) { int num = ActorOf(character); if (num >= 0 && InspectByActor.TryGetValue(num, out var value)) { return value; } if ((Object)(object)character != (Object)null && character.IsLocal) { return LocalInspect(); } return 0; } private static bool IsWheelFront(Character character) { return InspectOf(character) == 1; } private static bool IsFannyFlip(Character character) { return InspectOf(character) == 2; } private static void ApplyWornExtras(CharacterBackpackHandler handler) { //IL_0059: 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_0078: Invalid comparison between Unknown and I4 //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 if ((Object)(object)handler == (Object)null || (Object)(object)handler.character == (Object)null || (Object)(object)handler.character.player == (Object)null) { return; } BackpackSlot backpackSlot = handler.character.player.backpackSlot; ExtraLoadout loadout = GetLoadout(handler.character, create: false); bool flag = backpackSlot != null && IsFlightPack(backpackSlot.backpackType); bool flag2 = IsHoldingPack(handler); bool flag3 = backpackSlot != null && (int)backpackSlot.backpackType == 1; bool flag4 = backpackSlot != null && (int)backpackSlot.backpackType == 2; bool flag5 = loadout != null && Has(loadout.Backpack); bool flag6 = loadout != null && Has(loadout.Fanny); bool flag7 = flag5 || flag3; bool front = flag7 && ((flag && Plugin.IsBackpackInFrontWhenWearingUtility()) || IsWheelFront(handler.character)); if ((flag6 || flag4) && !(flag2 && flag4)) { ShowFanny(handler, active: true); } if (!((Object)(object)handler.backpackVisuals == (Object)null)) { bool flag8 = flag7; if (flag2 && flag3) { flag8 = flag5; } if (flag8) { handler.backpackVisuals.SetViewActive(true); PlaceBackpack(handler.backpackVisuals, handler.character, front); } else { PlaceBackpack(handler.backpackVisuals, handler.character, front: false); } } } private static void PlaceBackpack(BackpackOnBackVisuals visuals, Character character, bool front) { //IL_0044: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00aa: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) if ((Object)(object)visuals == (Object)null) { return; } Transform transform = ((Component)visuals).transform; if ((Object)(object)transform == (Object)null) { return; } SavedPose savedPose = CachePose(BackpackPoses, transform, (Component)(object)visuals); if (!front) { transform.localPosition = savedPose.Position; transform.localRotation = savedPose.Rotation; return; } Transform val = BodypartTransform(character, (BodypartType)2); if ((Object)(object)val == (Object)null) { transform.localPosition = savedPose.Position; transform.localRotation = savedPose.Rotation; } else { transform.position = val.position + val.forward * Plugin.GetFrontBackpackForward() + val.up * Plugin.GetFrontPackUp(); transform.rotation = val.rotation * Quaternion.Euler(0f, Plugin.GetFrontPackYaw(), 0f); } } private static SavedPose CachePose(Dictionary store, Transform target, Component visuals) { //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_002d: 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_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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0088: Unknown result type (might be due to invalid IL or missing references) int instanceID = ((Object)target).GetInstanceID(); if (store.TryGetValue(instanceID, out var value)) { return value; } value.Position = target.localPosition; value.Rotation = target.localRotation; value.HasCenter = false; value.LocalCenter = Vector3.zero; Renderer val = (((Object)(object)visuals != (Object)null) ? visuals.GetComponentInChildren() : ((Component)target).GetComponentInChildren()); if ((Object)(object)val != (Object)null) { Bounds bounds = val.bounds; value.LocalCenter = target.InverseTransformPoint(((Bounds)(ref bounds)).center); value.HasCenter = true; } store[instanceID] = value; return value; } private static void ShowVanillaWorn(CharacterBackpackHandler handler, bool show) { if (!((Object)(object)handler == (Object)null) && !((Object)(object)handler.character == (Object)null) && !((Object)(object)handler.character.player == (Object)null) && !((Object)(object)handler.characterItems == (Object)null)) { BackpackSlot backpackSlot = handler.character.player.backpackSlot; bool flag = handler.characterItems.currentSelectedSlot.IsSome && handler.characterItems.currentSelectedSlot.Value == 3; bool flag2 = backpackSlot != null && !((ItemSlot)backpackSlot).IsEmpty() && !flag; if (show && flag2 && !((Object)(object)handler.activeBackpackVisuals == (Object)null)) { handler.activeBackpackVisuals.SetViewActive(true); } } } private static void ShowFanny(CharacterBackpackHandler handler, bool active) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)handler.fannypackVisuals == (Object)null) { return; } handler.fannypackVisuals.SetViewActive(active); Transform transform = ((Component)handler.fannypackVisuals).transform; if ((Object)(object)transform == (Object)null) { return; } SavedPose savedPose = CachePose(FannyPoses, transform, (Component)(object)handler.fannypackVisuals); transform.localPosition = savedPose.Position; transform.localRotation = savedPose.Rotation; FannyPackPosition fannyPackPosition = PositionFor(handler.character); if (IsFannyFlip(handler.character) && fannyPackPosition != FannyPackPosition.Front) { fannyPackPosition = FannyPackPosition.Front; } if (fannyPackPosition == FannyPackPosition.Back || (Object)(object)handler.character == (Object)null) { return; } Vector3 up = ((Component)handler.character).transform.up; if (fannyPackPosition == FannyPackPosition.Front) { if (savedPose.HasCenter) { transform.RotateAround(transform.TransformPoint(savedPose.LocalCenter), up, 180f); } else { transform.localRotation = savedPose.Rotation * Quaternion.Euler(0f, 180f, 0f); } Transform val = BodypartTransform(handler.character, (BodypartType)2); if ((Object)(object)val != (Object)null) { transform.position += val.forward * 0.15f; } } else { Transform val2 = BodypartTransform(handler.character, (BodypartType)0); if ((Object)(object)val2 == (Object)null) { val2 = BodypartTransform(handler.character, (BodypartType)2); } if (!((Object)(object)val2 == (Object)null)) { transform.RotateAround(val2.position, up, YawOf(fannyPackPosition)); } } } private static float YawOf(FannyPackPosition pos) { return pos switch { FannyPackPosition.BackLeft => 45f, FannyPackPosition.Left => 90f, FannyPackPosition.FrontLeft => 135f, FannyPackPosition.Front => 180f, FannyPackPosition.FrontRight => 225f, FannyPackPosition.Right => 270f, FannyPackPosition.BackRight => 315f, _ => 0f, }; } private static FannyPackPosition PositionFor(Character character) { int num = ActorOf(character); if (num >= 0 && FannyPosByActor.TryGetValue(num, out var value)) { return value; } if ((Object)(object)character != (Object)null && character.IsLocal) { return Plugin.GetFannyPackPosition(); } return FannyPackPosition.Back; } private static void BroadcastFannyPos(FannyPackPosition pos) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown if (PhotonNetwork.InRoom) { Character localCharacter = Character.localCharacter; int num = ActorOf(localCharacter); if (num >= 0) { FannyPosByActor[num] = pos; PhotonNetwork.RaiseEvent((byte)194, (object)new object[4] { "tony4twentys.PEAK_Packs", "FANNY_YAW", num, (int)pos }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } } private static void BroadcastInspect(int actor, byte inspect) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown if (PhotonNetwork.InRoom && actor >= 0) { InspectByActor[actor] = inspect; PhotonNetwork.RaiseEvent((byte)194, (object)new object[4] { "tony4twentys.PEAK_Packs", "FRONT_WHEEL", actor, inspect }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } private static void SyncInventory(Player player) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !((Object)(object)player.view == (Object)null) && PhotonNetwork.IsMasterClient) { byte[] array = IBinarySerializable.ToManagedArray(new InventorySyncData(player.itemSlots, player.backpackSlot, player.tempFullSlot)); player.view.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2] { array, false }); } } public void OnEvent(EventData photonEvent) { if (photonEvent.Code != 194 || !(photonEvent.CustomData is object[] array) || array.Length < 2 || !(array[0] is string) || (string)array[0] != "tony4twentys.PEAK_Packs" || !(array[1] is string)) { return; } switch ((string)array[1]) { case "FANNY_YAW": if (array.Length >= 4) { int key = Convert.ToInt32(array[2]); int num = Convert.ToInt32(array[3]); if (num < 0 || num > 7) { num = 0; } FannyPosByActor[key] = (FannyPackPosition)num; } break; case "FRONT_WHEEL": if (array.Length >= 4) { InspectByActor[Convert.ToInt32(array[2])] = Convert.ToByte(array[3]); } break; case "FANNY_FLIP": if (array.Length >= 4) { InspectByActor[Convert.ToInt32(array[2])] = (byte)(Convert.ToBoolean(array[3]) ? 2 : 0); } break; case "COMBINE_V1": HandleCombinePickup(array); break; case "HOST_CFG": HandleHostRules(array); break; case "PRIVACY": HandlePrivacy(array); break; case "TAKE_NESTED": HandleTakeNested(array); break; case "DUAL_V3": HandleLoadout(array); break; case "DUAL_V2": HandleLoadoutV2(array); break; case "DUAL_V1": HandleLegacy(array); break; } } internal static void RequestTakeNested(BackpackReference reference, byte slotId, Character interactor) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected I4, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown if (PhotonNetwork.InRoom && !((Object)(object)reference.view == (Object)null)) { int num = 0; if ((Object)(object)interactor != (Object)null && (Object)(object)((MonoBehaviourPun)interactor).photonView != (Object)null) { num = ((MonoBehaviourPun)interactor).photonView.ViewID; } PhotonNetwork.RaiseEvent((byte)194, (object)new object[6] { "tony4twentys.PEAK_Packs", "TAKE_NESTED", (byte)(int)reference.type, reference.view.ViewID, slotId, num }, new RaiseEventOptions { Receivers = (ReceiverGroup)2 }, SendOptions.SendReliable); } } private static void HandleTakeNested(object[] payload) { //IL_003e: 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_0090: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient || payload == null || payload.Length < 6) { return; } PhotonView val = PhotonView.Find(Convert.ToInt32(payload[3])); if ((Object)(object)val == (Object)null) { return; } BackpackReference reference = new BackpackReference { type = (BackpackType)Convert.ToByte(payload[2]), view = val }; Character interactor = null; int num = Convert.ToInt32(payload[5]); if (num != 0) { PhotonView val2 = PhotonView.Find(num); if ((Object)(object)val2 != (Object)null) { interactor = ((Component)val2).GetComponent(); } } NestedPacks.TakeNestedOnMaster(reference, Convert.ToByte(payload[4]), interactor); } public void OnPlayerEnteredRoom(Player newPlayer) { _sentFannyPos = false; _sentInspect = false; _sentPrivacy = false; _sentHostRules = false; BroadcastHostRulesIfMaster(); BroadcastPrivacy(); if (!PhotonNetwork.IsMasterClient) { return; } List allPlayerCharacters = PlayerHandler.GetAllPlayerCharacters(); if (allPlayerCharacters != null) { for (int i = 0; i < allPlayerCharacters.Count; i++) { Broadcast(allPlayerCharacters[i]); } } } public void OnPlayerLeftRoom(Player otherPlayer) { if (otherPlayer != null) { ExtraByActor.Remove(otherPlayer.ActorNumber); FannyPosByActor.Remove(otherPlayer.ActorNumber); InspectByActor.Remove(otherPlayer.ActorNumber); ProtectUntilByActor.Remove(otherPlayer.ActorNumber); EmptiedByActor.Remove(otherPlayer.ActorNumber); PackPrivacy.ClearActor(otherPlayer.ActorNumber); } } public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged) { } public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { } public void OnMasterClientSwitched(Player newMasterClient) { if (PhotonNetwork.IsMasterClient) { BroadcastHostRulesIfMaster(); } } internal static void BroadcastHostRulesIfMaster() { //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient) { bool flag = Plugin.AllowMultipackConfig != null && Plugin.AllowMultipackConfig.Value; bool flag2 = Plugin.AllowUtilityAndBackpackConfig != null && Plugin.AllowUtilityAndBackpackConfig.Value; bool flag3 = Plugin.AllowUtilityAndFannypackConfig != null && Plugin.AllowUtilityAndFannypackConfig.Value; bool flag4 = Plugin.BackpackInFrontWhenWearingUtilityConfig == null || Plugin.BackpackInFrontWhenWearingUtilityConfig.Value; bool flag5 = Plugin.LookOnlyAllowStashConfig != null && Plugin.LookOnlyAllowStashConfig.Value; bool flag6 = Plugin.AllowAnyItemInPackConfig != null && Plugin.AllowAnyItemInPackConfig.Value; bool flag7 = Plugin.AllowNestedPacksConfig != null && Plugin.AllowNestedPacksConfig.Value; bool flag8 = Plugin.CarryWithPackConfig != null && Plugin.CarryWithPackConfig.Value; bool flag9 = Plugin.FrontPackWhenOpenAnytimeConfig != null && Plugin.FrontPackWhenOpenAnytimeConfig.Value; if (!_sentHostRules || flag != HostAllowMultipack || flag2 != HostAllowUtilityAndBackpack || flag3 != HostAllowUtilityAndFannypack || flag4 != HostBackpackInFrontWhenWearingUtility || flag5 != HostLookOnlyAllowStash || flag6 != HostAllowAnyItemInPack || flag7 != HostAllowNestedPacks || flag8 != HostKeepPackWhileCarrying || flag9 != HostFrontPackWhenOpenAnytime) { _sentHostRules = true; HasHostRules = true; HostAllowMultipack = flag; HostAllowUtilityAndBackpack = flag2; HostAllowUtilityAndFannypack = flag3; HostBackpackInFrontWhenWearingUtility = flag4; HostLookOnlyAllowStash = flag5; HostAllowAnyItemInPack = flag6; HostAllowNestedPacks = flag7; HostKeepPackWhileCarrying = flag8; HostFrontPackWhenOpenAnytime = flag9; PhotonNetwork.RaiseEvent((byte)194, (object)new object[11] { "tony4twentys.PEAK_Packs", "HOST_CFG", HostAllowMultipack, HostAllowUtilityAndBackpack, HostAllowUtilityAndFannypack, HostBackpackInFrontWhenWearingUtility, HostLookOnlyAllowStash, HostAllowAnyItemInPack, HostAllowNestedPacks, HostKeepPackWhileCarrying, HostFrontPackWhenOpenAnytime }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } } private static void HandleHostRules(object[] payload) { if (!PhotonNetwork.IsMasterClient && payload != null && payload.Length >= 6) { HasHostRules = true; HostAllowMultipack = Convert.ToBoolean(payload[2]); HostAllowUtilityAndBackpack = Convert.ToBoolean(payload[3]); HostAllowUtilityAndFannypack = Convert.ToBoolean(payload[4]); HostBackpackInFrontWhenWearingUtility = Convert.ToBoolean(payload[5]); if (payload.Length >= 11) { HostLookOnlyAllowStash = Convert.ToBoolean(payload[6]); HostAllowAnyItemInPack = Convert.ToBoolean(payload[7]); HostAllowNestedPacks = Convert.ToBoolean(payload[8]); HostKeepPackWhileCarrying = Convert.ToBoolean(payload[9]); HostFrontPackWhenOpenAnytime = Convert.ToBoolean(payload[10]); } } } internal static void BroadcastPrivacy() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown if (PhotonNetwork.InRoom) { int num = ActorOf(Character.localCharacter); if (num < 0 && PhotonNetwork.LocalPlayer != null) { num = PhotonNetwork.LocalPlayer.ActorNumber; } if (num >= 0) { PackPrivacyMode packPrivacy = Plugin.GetPackPrivacy(); PackPrivacy.SetRemoteMode(num, packPrivacy); _sentPrivacy = true; _sentPrivacyValue = packPrivacy; PhotonNetwork.RaiseEvent((byte)194, (object)new object[4] { "tony4twentys.PEAK_Packs", "PRIVACY", num, (int)packPrivacy }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } } private static void HandlePrivacy(object[] payload) { if (payload != null && payload.Length >= 4) { int actor = Convert.ToInt32(payload[2]); int num = Convert.ToInt32(payload[3]); if (num < 0 || num > 2) { num = 0; } PackPrivacy.SetRemoteMode(actor, (PackPrivacyMode)num); } } internal static void Broadcast(Character character) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown if (!PhotonNetwork.InRoom) { return; } int num = ActorOf(character); if (num >= 0) { ExtraLoadout loadout = GetLoadout(character, create: false); ushort itemId = 0; byte[] bytes = null; ushort itemId2 = 0; byte[] bytes2 = null; if (loadout != null) { PartsOf(loadout.Backpack, out itemId, out bytes); PartsOf(loadout.Fanny, out itemId2, out bytes2); } byte value = 0; InspectByActor.TryGetValue(num, out value); if ((Object)(object)character != (Object)null && character.IsLocal) { value = LocalInspect(); } PhotonNetwork.RaiseEvent((byte)194, (object)new object[8] { "tony4twentys.PEAK_Packs", "DUAL_V3", num, itemId, bytes, itemId2, bytes2, value }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } private static void HandleLoadout(object[] payload) { if (payload != null && payload.Length >= 7) { int key = Convert.ToInt32(payload[2]); ExtraLoadout extraLoadout = new ExtraLoadout(); extraLoadout.Backpack = FromParts(payload[3], payload[4]); extraLoadout.Fanny = FromParts(payload[5], payload[6]); if (!Has(extraLoadout.Backpack) && !Has(extraLoadout.Fanny)) { ExtraByActor.Remove(key); } else { ExtraByActor[key] = extraLoadout; } if (payload.Length >= 8) { InspectByActor[key] = Convert.ToByte(payload[7]); } } } private static void HandleLoadoutV2(object[] payload) { if (payload != null && payload.Length >= 5) { int key = Convert.ToInt32(payload[2]); ExtraLoadout extraLoadout = new ExtraLoadout(); extraLoadout.Backpack = FromBytes(payload[3]); extraLoadout.Fanny = FromBytes(payload[4]); if (!Has(extraLoadout.Backpack) && !Has(extraLoadout.Fanny)) { ExtraByActor.Remove(key); } else { ExtraByActor[key] = extraLoadout; } } } private static void HandleLegacy(object[] payload) { //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_0080: Invalid comparison between Unknown and I4 if (payload == null || payload.Length < 4) { return; } int key = Convert.ToInt32(payload[2]); ushort num = Convert.ToUInt16(payload[3]); if (num == 0 || payload.Length < 5 || payload[4] == null) { ExtraByActor.Remove(key); return; } ExtraStorage extraStorage = default(ExtraStorage); extraStorage.ItemId = num; extraStorage.Data = (ItemInstanceData)CustomTypeRPCSerialization.DeserializeItemData((byte[])payload[4]); ExtraLoadout extraLoadout = new ExtraLoadout(); if ((int)TypeOf(extraStorage, (BackpackType)1) == 2) { extraLoadout.Fanny = extraStorage; } else { extraLoadout.Backpack = extraStorage; } ExtraByActor[key] = extraLoadout; } private static bool ReconcileExtras(Character character) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 ExtraLoadout loadout = GetLoadout(character, create: false); if (loadout == null || (Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null || character.player.backpackSlot == null) { return false; } BackpackSlot backpackSlot = character.player.backpackSlot; bool flag = false; if ((int)backpackSlot.backpackType == 1 && Has(loadout.Backpack)) { loadout.Backpack = default(ExtraStorage); flag = true; } if ((int)backpackSlot.backpackType == 2 && Has(loadout.Fanny)) { loadout.Fanny = default(ExtraStorage); flag = true; } if (!flag) { return false; } if (!Has(loadout.Backpack) && !Has(loadout.Fanny)) { ClearActor(character); } return true; } private static void ParkSlotIntoExtra(Character character, BackpackSlot worn) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 if (worn != null && !((ItemSlot)worn).IsEmpty() && !((Object)(object)((ItemSlot)worn).prefab == (Object)null)) { ItemInstanceData data = NestedPacks.CloneInstance(((ItemSlot)worn).data); if ((int)worn.backpackType == 2) { SetFannyExtra(character, ((ItemSlot)worn).prefab.itemID, data); } else if ((int)worn.backpackType == 1) { SetBackpackExtra(character, ((ItemSlot)worn).prefab.itemID, data); } } } private static void SetBackpackExtra(Character character, ushort itemId, ItemInstanceData data) { ExtraLoadout loadout = GetLoadout(character, create: true); ExtraStorage backpack = default(ExtraStorage); backpack.ItemId = itemId; backpack.Data = data; loadout.Backpack = backpack; } private static void SetFannyExtra(Character character, ushort itemId, ItemInstanceData data) { ExtraLoadout loadout = GetLoadout(character, create: true); ExtraStorage fanny = default(ExtraStorage); fanny.ItemId = itemId; fanny.Data = data; loadout.Fanny = fanny; } private static ExtraLoadout GetLoadout(Character character, bool create) { int num = ActorOf(character); if (num < 0) { return null; } if (ExtraByActor.TryGetValue(num, out var value)) { return value; } if (!create) { return null; } value = new ExtraLoadout(); ExtraByActor[num] = value; return value; } private static void ClearActor(Character character) { int num = ActorOf(character); if (num >= 0) { ExtraByActor.Remove(num); } } private static bool WearFromExtra(Player player, ExtraStorage extra) { //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) Item val = default(Item); if (!ItemDatabase.TryGetItem(extra.ItemId, ref val) || !(val is Backpack)) { return false; } Backpack val2 = (Backpack)(object)((val is Backpack) ? val : null); player.backpackSlot.backpackType = (BackpackType)((!((Object)(object)val2 != (Object)null)) ? 1 : ((int)val2.backpackType)); ((ItemSlot)player.backpackSlot).SetItem(val, extra.Data); return true; } private static bool TryReadStorage(ExtraStorage extra, out BackpackData data, out int slotCount) { data = null; slotCount = 4; if (!Has(extra)) { return false; } if (!extra.Data.TryGetDataEntry((DataEntryKey)7, ref data) || data == null) { data = extra.Data.RegisterNewEntry((DataEntryKey)7); } Item val = default(Item); if (ItemDatabase.TryGetItem(extra.ItemId, ref val)) { Backpack val2 = (Backpack)(object)((val is Backpack) ? val : null); if ((Object)(object)val2 != (Object)null && val2.slotCount > 0) { slotCount = val2.slotCount; } } return data != null; } private static int StorageWeight(ExtraStorage extra) { if (!Has(extra)) { return 0; } int num = 0; Item val = default(Item); if (ItemDatabase.TryGetItem(extra.ItemId, ref val) && (Object)(object)val != (Object)null) { num += val.CarryWeight; } if (!TryReadStorage(extra, out var data, out var _) || data.itemSlots == null) { return num; } for (int i = 0; i < data.itemSlots.Length; i++) { ItemSlot val2 = data.itemSlots[i]; if (val2 != null && !val2.IsEmpty() && !((Object)(object)val2.prefab == (Object)null)) { num += val2.prefab.CarryWeight; } } return num; } private static BackpackType TypeOf(ExtraStorage extra, BackpackType fallback) { //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_002d: 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_0035: 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) Item val = default(Item); if (!ItemDatabase.TryGetItem(extra.ItemId, ref val)) { return fallback; } Backpack val2 = (Backpack)(object)((val is Backpack) ? val : null); return ((Object)(object)val2 != (Object)null) ? val2.backpackType : fallback; } private static void PartsOf(ExtraStorage extra, out ushort itemId, out byte[] bytes) { itemId = 0; bytes = null; if (Has(extra)) { itemId = extra.ItemId; bytes = CustomTypeRPCSerialization.SerializeItemData((object)extra.Data); } } private static ExtraStorage FromParts(object idObj, object bytesObj) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown ExtraStorage result = default(ExtraStorage); if (idObj == null || bytesObj == null) { return result; } result.ItemId = Convert.ToUInt16(idObj); if (result.ItemId == 0) { return default(ExtraStorage); } result.Data = (ItemInstanceData)CustomTypeRPCSerialization.DeserializeItemData((byte[])bytesObj); return result; } private static ExtraStorage FromBytes(object raw) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown ExtraStorage result = default(ExtraStorage); if (!(raw is object[] array) || array.Length < 2 || array[1] == null) { return result; } result.ItemId = Convert.ToUInt16(array[0]); result.Data = (ItemInstanceData)CustomTypeRPCSerialization.DeserializeItemData((byte[])array[1]); return result; } private static Transform BodypartTransform(Character character, BodypartType type) { //IL_0052: 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) if ((Object)(object)character == (Object)null) { return null; } try { if (character.refs != null && (int)type == 0 && (Object)(object)character.refs.hip != (Object)null) { return character.refs.hip.transform; } Bodypart bodypart = character.GetBodypart(type); return ((Object)(object)bodypart != (Object)null) ? bodypart.transform : null; } catch { return null; } } private static int ActorOf(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)((MonoBehaviourPun)character).photonView == (Object)null || ((MonoBehaviourPun)character).photonView.Owner == null) { return -1; } return ((MonoBehaviourPun)character).photonView.Owner.ActorNumber; } private static BackpackType GetEmptied(Player player) { //IL_0036: 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_0032: 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) int num = ActorOf(((Object)(object)player != (Object)null) ? player.character : null); if (num >= 0 && EmptiedByActor.TryGetValue(num, out var value)) { return value; } return (BackpackType)0; } private static void SetEmptied(Player player, BackpackType type) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) int num = ActorOf(((Object)(object)player != (Object)null) ? player.character : null); if (num >= 0) { if ((int)type == 0) { EmptiedByActor.Remove(num); } else { EmptiedByActor[num] = type; } } } } internal static class WorldStorePrompt { private static readonly Dictionary DisabledChrome = new Dictionary(); private static TextMeshProUGUI _heldPrompt; private static GameObject _heldPromptGo; private static TextMeshProUGUI _heldKeycap; internal static void Tick() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) if (Plugin.EnabledConfig == null || !Plugin.EnabledConfig.Value) { return; } KeyCode storeKey = Plugin.GetStoreKey(); if ((int)storeKey != 0 && Input.GetKeyDown(storeKey)) { Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && localCharacter.IsLocal) { PackUtil.TryStoreFromPrompt(localCharacter); } } } internal static void ShowHeldHud(GUIManager gui) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gui == (Object)null) { return; } Character localCharacter = Character.localCharacter; if (Plugin.EnabledConfig == null || !Plugin.EnabledConfig.Value || !PackUtil.CanShowHeldItemStorePrompt(localCharacter, out var _, out var label)) { HideHeldHud(); return; } KeyCode storeKey = Plugin.GetStoreKey(); if ((int)storeKey == 0) { HideHeldHud(); return; } TextMeshProUGUI val = EnsureHeldPromptRow(gui); if (!((Object)(object)val == (Object)null) && !((Object)(object)_heldPromptGo == (Object)null)) { ((TMP_Text)val).text = (string.IsNullOrWhiteSpace(label) ? "put in backpack" : label); ApplyPromptStyle(val); if ((Object)(object)_heldKeycap != (Object)null) { ApplyPromptStyle(_heldKeycap); string keycapSpriteTag = GetKeycapSpriteTag(storeKey); ((TMP_Text)_heldKeycap).text = (string.IsNullOrEmpty(keycapSpriteTag) ? string.Empty : keycapSpriteTag); } _heldPromptGo.SetActive(true); Transform parent = _heldPromptGo.transform.parent; RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (val2 != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(val2); } } } internal static void HideHeldHud() { if ((Object)(object)_heldPromptGo != (Object)null) { _heldPromptGo.SetActive(false); } } private static TextMeshProUGUI EnsureHeldPromptRow(GUIManager gui) { if ((Object)(object)_heldPrompt != (Object)null && (Object)(object)_heldPromptGo != (Object)null) { return _heldPrompt; } if ((Object)(object)gui.itemPromptDrop == (Object)null) { return null; } Transform parent = ((TMP_Text)gui.itemPromptDrop).transform.parent; if ((Object)(object)parent == (Object)null) { return null; } GameObject val = Object.Instantiate(((Component)gui.itemPromptDrop).gameObject, parent, false); ((Object)val).name = "HoldToOpen_StorePrompt"; if ((Object)(object)gui.itemPromptThrow != (Object)null) { val.transform.SetSiblingIndex(((TMP_Text)gui.itemPromptThrow).transform.GetSiblingIndex() + 1); } else { val.transform.SetAsLastSibling(); } TextMeshProUGUI component = val.GetComponent(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); return null; } LocalizedText component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.autoSet = false; ((Behaviour)component2).enabled = false; } Transform val2 = val.transform.Find("UI_InputIcon"); TextMeshProUGUI heldKeycap = null; if ((Object)(object)val2 != (Object)null) { Transform val3 = val2.Find("PromptHold"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(false); } TextMeshProUGUI[] componentsInChildren = ((Component)val2).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Object)(object)componentsInChildren[i] == (Object)null) && !((Object)(object)componentsInChildren[i] == (Object)(object)component) && (!((Object)(object)val3 != (Object)null) || !((TMP_Text)componentsInChildren[i]).transform.IsChildOf(val3))) { heldKeycap = componentsInChildren[i]; break; } } } _heldPromptGo = val; _heldPrompt = component; _heldKeycap = heldKeycap; val.SetActive(false); return component; } internal static void Show(GUIManager gui) { //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_00bf: 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) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown if ((Object)(object)gui == (Object)null) { return; } if ((Object)(object)gui.interactPromptSecondary != (Object)null) { RestoreChrome(gui.interactPromptSecondary); } if ((Object)(object)gui.interactPromptSecondary != (Object)null && (Object)(object)gui.interactPromptSecondary.transform.parent != (Object)null) { RestoreChrome(((Component)gui.interactPromptSecondary.transform.parent).gameObject); } if (Plugin.EnabledConfig == null || !Plugin.EnabledConfig.Value) { return; } Character localCharacter = Character.localCharacter; if (!PackUtil.TryGetStorePrompt(localCharacter, out var _, out var label)) { return; } KeyCode storeKey = Plugin.GetStoreKey(); if ((int)storeKey == 0 || (Object)(object)gui.interactPromptSecondary == (Object)null || (Object)(object)gui.secondaryInteractPromptText == (Object)null) { return; } GameObject interactPromptSecondary = gui.interactPromptSecondary; TextMeshProUGUI secondaryInteractPromptText = gui.secondaryInteractPromptText; StripChrome(interactPromptSecondary, secondaryInteractPromptText); if ((Object)(object)interactPromptSecondary.transform.parent != (Object)null) { foreach (Transform item in interactPromptSecondary.transform.parent) { Transform val = item; if (Object.op_Implicit((Object)(object)val) && !((Object)(object)val == (Object)(object)interactPromptSecondary.transform) && IsChrome(val)) { RememberAndDisable(((Component)val).gameObject); } } } interactPromptSecondary.SetActive(true); ApplyPromptStyle(secondaryInteractPromptText); ((TMP_Text)secondaryInteractPromptText).text = FormatPrompt(storeKey, label); } private unsafe static string FormatPrompt(KeyCode keyCode, string label) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string keycapSpriteTag = GetKeycapSpriteTag(keyCode); string text = (string.IsNullOrWhiteSpace(label) ? "put in backpack" : label.Trim().ToLowerInvariant()); if (string.IsNullOrEmpty(keycapSpriteTag)) { return "[" + ((object)(*(KeyCode*)(&keyCode))/*cast due to .constrained prefix*/).ToString() + "] " + text; } return keycapSpriteTag + " " + text; } private static void ApplyPromptStyle(TextMeshProUGUI tmp) { if ((Object)(object)tmp == (Object)null) { return; } try { InputSpriteData instance = SingletonAsset.Instance; if (!((Object)(object)instance == (Object)null)) { FieldInfo fieldInfo = AccessTools.Field(typeof(InputSpriteData), "keyboardSprites"); TMP_SpriteAsset val = (TMP_SpriteAsset)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val != (Object)null) { ((TMP_Text)tmp).spriteAsset = val; } } } catch { } } private static string GetKeycapSpriteTag(KeyCode keyCode) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) try { InputSpriteData instance = SingletonAsset.Instance; if ((Object)(object)instance == (Object)null) { return string.Empty; } string text = KeyCodeToSpritePathKey(keyCode); if (string.IsNullOrEmpty(text)) { return string.Empty; } string spriteTagFromInputPathKeyboard = instance.GetSpriteTagFromInputPathKeyboard("/" + text); return string.IsNullOrEmpty(spriteTagFromInputPathKeyboard) ? string.Empty : spriteTagFromInputPathKeyboard; } catch { return string.Empty; } } private unsafe static string KeyCodeToSpritePathKey(KeyCode keyCode) { //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_0008: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_002c: 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_0050: Expected I4, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 KeyCode val = keyCode; KeyCode val2 = val; if ((int)val2 <= 27) { if ((int)val2 == 8) { return "backspace"; } if ((int)val2 == 13) { return "enter"; } if ((int)val2 == 27) { return "esc"; } } else { if ((int)val2 == 32) { return "space"; } if ((int)val2 == 127) { return "delete"; } switch (val2 - 303) { case 0: case 1: return "shift"; case 2: case 3: return "ctrl"; case 4: case 5: return "alt"; } } string text = ((object)(*(KeyCode*)(&keyCode))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Alpha", StringComparison.Ordinal) && text.Length == 6) { return text.Substring(5).ToLowerInvariant(); } if (text.Length == 1) { return text.ToLowerInvariant(); } return text.ToLowerInvariant(); } private static void StripChrome(GameObject root, TextMeshProUGUI keepText) { if (!Object.op_Implicit((Object)(object)root)) { return; } Transform val = (((Object)(object)keepText != (Object)null) ? ((TMP_Text)keepText).transform : null); Transform[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val2) && !((Object)(object)val2 == (Object)(object)root.transform) && (!((Object)(object)val != (Object)null) || (!((Object)(object)val2 == (Object)(object)val) && !val2.IsChildOf(val))) && IsChrome(val2)) { RememberAndDisable(((Component)val2).gameObject); } } Image[] componentsInChildren2 = root.GetComponentsInChildren(true); foreach (Image val3 in componentsInChildren2) { if (!((Object)(object)val3 == (Object)null) && (!((Object)(object)val != (Object)null) || !((Object)(object)((Component)val3).transform == (Object)(object)val)) && !((Object)(object)((Component)val3).GetComponent() != (Object)null)) { RememberAndDisable(((Component)val3).gameObject); } } } private static bool IsChrome(Transform t) { if (!Object.op_Implicit((Object)(object)t)) { return false; } string text = ((Object)t).name ?? string.Empty; if (text.IndexOf("icon", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (text.IndexOf("mouse", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if ((Object)(object)((Component)t).GetComponent() != (Object)null && (Object)(object)((Component)t).GetComponent() == (Object)null) { return true; } TextMeshProUGUI component = ((Component)t).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } string text2 = ((TMP_Text)component).text ?? string.Empty; if (text2.IndexOf("sprite", StringComparison.OrdinalIgnoreCase) < 0) { return false; } string text3 = text2; while (true) { int num = text3.IndexOf('<'); if (num < 0) { break; } int num2 = text3.IndexOf('>', num); if (num2 < 0) { break; } text3 = text3.Remove(num, num2 - num + 1); } return string.IsNullOrWhiteSpace(text3); } private static void RememberAndDisable(GameObject go) { if (Object.op_Implicit((Object)(object)go)) { int instanceID = ((Object)go).GetInstanceID(); if (!DisabledChrome.ContainsKey(instanceID)) { DisabledChrome[instanceID] = go.activeSelf; } if (go.activeSelf) { go.SetActive(false); } } } private static void RestoreChrome(GameObject root) { if (!Object.op_Implicit((Object)(object)root)) { return; } Transform[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val)) { int instanceID = ((Object)((Component)val).gameObject).GetInstanceID(); if (DisabledChrome.TryGetValue(instanceID, out var value)) { ((Component)val).gameObject.SetActive(value); DisabledChrome.Remove(instanceID); } } } int instanceID2 = ((Object)root).GetInstanceID(); if (DisabledChrome.TryGetValue(instanceID2, out var value2)) { root.SetActive(value2); DisabledChrome.Remove(instanceID2); } } } [HarmonyPatch(typeof(Character), "CanDoInput")] internal static class Patch_CanDoInput { private static bool Prefix(Character __instance, ref bool __result) { try { if (!HeldBackpackInventory.IsOpen || !__instance.IsLocal) { return true; } GUIManager instance = GUIManager.instance; if ((Object)(object)instance != (Object)null && instance.windowBlockingInput) { __result = false; return false; } __result = true; return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("CanDoInput prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(CharacterMovement), "CanMoveCamera")] internal static class Patch_CanMoveCamera { private static void Postfix(ref bool __result) { try { if (HeldBackpackInventory.ShouldFreeLook()) { __result = true; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("CanMoveCamera postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(CursorHandler), "Update")] internal static class Patch_CursorHandler_Update { private static void Postfix() { try { if (HeldBackpackInventory.ShouldFreeLook()) { GUIManager instance = GUIManager.instance; if (!((Object)(object)instance != (Object)null) || (!instance.windowBlockingInput && !instance.windowShowingCursor && !GUIManager.InPauseMenu)) { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("CursorHandler postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(CharacterItems), "DoSwitching")] internal static class Patch_DoSwitching { private static bool Prefix() { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.input == (Object)null) { return true; } for (byte b = 0; b < 3; b++) { if (localCharacter.input.SelectSlotWasPressed((int)b)) { if ((!PackUtil.TryGetActivePack(localCharacter, out var info) || !info.IsHeld) && !HeldBackpackInventory.IsOpen) { return true; } try { HeldBackpackInventory.TryStashPocket(localCharacter, b); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Stash from pocket " + b + " failed: " + ex)); } } return false; } } return true; } } [HarmonyPatch(typeof(BackpackWheel), "Update")] internal static class Patch_BackpackWheel_Update { private static bool _spoofedInteract; private static bool _previousInteract; private static void Prefix() { _spoofedInteract = false; try { if (HeldBackpackInventory.ShouldKeepWheelOpen()) { Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && !((Object)(object)localCharacter.input == (Object)null)) { _previousInteract = localCharacter.input.interactIsPressed; localCharacter.input.interactIsPressed = true; _spoofedInteract = true; } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("BackpackWheel.Update prefix failed: " + ex)); } } } private static void Postfix() { if (!_spoofedInteract) { return; } try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter != (Object)null && (Object)(object)localCharacter.input != (Object)null) { localCharacter.input.interactIsPressed = _previousInteract; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("BackpackWheel.Update postfix failed: " + ex)); } } _spoofedInteract = false; } } [HarmonyPatch(typeof(BackpackWheel), "InitWheel")] internal static class Patch_BackpackWheel_InitWheel { private static void Prefix(BackpackType backpackType) { //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) DualPack.WheelType = backpackType; } private static void Postfix(BackpackWheel __instance) { if ((Object)(object)__instance == (Object)null) { return; } if (__instance.slices != null) { for (int i = 0; i < __instance.slices.Length; i++) { BindSliceClick(__instance.slices[i]); } } BindSliceClick(__instance.jetpackSlice); HeldBackpackInventory.AfterInitWheel(__instance); } private static void BindSliceClick(BackpackWheelSlice slice) { if (!((Object)(object)slice == (Object)null) && (Object)(object)((Component)slice).GetComponent() == (Object)null) { ((Component)slice).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(BackpackWheel), "Choose")] internal static class Patch_BackpackWheel_Choose { private static bool Prefix(BackpackWheel __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0100: 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_010c: Invalid comparison between Unknown and I4 //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) try { if (HeldBackpackInventory.TryHandleHeldWear(__instance)) { return false; } if ((Object)(object)__instance == (Object)null || !__instance.chosenSlice.IsSome) { return true; } SliceData value = __instance.chosenSlice.Value; if (value.isBackpackWear) { if (PackPrivacy.ShouldBlockTake(value.backpackReference)) { return false; } return true; } if (value.isStashSlice) { return !PackPrivacy.ShouldBlockStash(value.backpackReference); } if (value.isJetpackFuelSlice) { return true; } if (PackPrivacy.SlotHasItem(value.backpackReference, value.slotID)) { if (PackPrivacy.ShouldBlockTake(value.backpackReference)) { return false; } Character localCharacter = Character.localCharacter; if (NestedPacks.TryTakeFromWheel(value.backpackReference, value.slotID, localCharacter)) { return false; } if ((int)value.backpackReference.type == 1 && (Object)(object)value.backpackReference.view != (Object)null) { Character component = ((Component)value.backpackReference.view).GetComponent(); if ((Object)(object)component == (Object)(object)localCharacter && DualPack.HasStorage(localCharacter) && PackUtil.TryTakeFromPackSlot(localCharacter, value.slotID)) { return false; } } return true; } if ((Object)(object)Character.localCharacter != (Object)null && (Object)(object)Character.localCharacter.data != (Object)null && (Object)(object)Character.localCharacter.data.currentItem != (Object)null) { return !PackPrivacy.ShouldBlockStash(value.backpackReference); } return true; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Choose prefix failed: " + ex)); } return true; } } } internal sealed class HeldWheelSliceClick : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public void OnPointerClick(PointerEventData eventData) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if (eventData != null && (int)eventData.button <= 0 && HeldBackpackInventory.UsesClickConfirm) { HeldBackpackInventory.ConfirmSlice(((Component)this).GetComponent()); } } } [HarmonyPatch(typeof(GUIManager), "CloseBackpackWheel")] internal static class Patch_CloseBackpackWheel { private static void Postfix() { HeldBackpackInventory.OnVanillaWheelClosed(); } } [HarmonyPatch(typeof(GUIManager), "RefreshInteractablePrompt")] internal static class Patch_RefreshInteractablePrompt { private static void Postfix(GUIManager __instance) { try { WorldStorePrompt.Show(__instance); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Store prompt failed: " + ex)); } } } } [HarmonyPatch(typeof(GUIManager), "UpdateItemPrompts")] internal static class Patch_UpdateItemPrompts { private static void Postfix(GUIManager __instance) { try { WorldStorePrompt.ShowHeldHud(__instance); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Held store prompt failed: " + ex)); } } } } [HarmonyPatch(typeof(CharacterItems), "OnPickupAccepted")] internal static class Patch_OnPickupAccepted { private static bool Prefix(CharacterItems __instance, byte slotID) { try { Character component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component != (Object)(object)Character.localCharacter) { return true; } if (!PackUtil.TryConsumePendingPickup(component, slotID)) { if (slotID == 3 && (Object)(object)component.data != (Object)null && (Object)(object)component.data.carriedPlayer != (Object)null && Plugin.IsCarryWithPack()) { try { __instance.RefreshAllCharacterCarryWeight(); } catch { } return false; } return true; } try { __instance.RefreshAllCharacterCarryWeight(); } catch { } return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("OnPickupAccepted prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(BackpackOnBackVisuals), "IsInteractible")] internal static class Patch_WornPack_IsInteractible { private static bool Prefix(BackpackOnBackVisuals __instance, Character interactor, ref bool __result) { try { if ((Object)(object)__instance == (Object)null || !PackPrivacy.ShouldBlockLook(__instance.character, interactor)) { return true; } __result = false; return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Worn pack IsInteractible prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(BackpackWheelSlice), "get_canInteract")] internal static class Patch_Slice_CanInteract { private static void Postfix(BackpackWheelSlice __instance, ref bool __result) { try { if (__result || (Object)(object)__instance == (Object)null || __instance.hasItem || __instance.isBackpackWear || __instance.stashSlice || __instance.jetpackFuelSlice) { return; } Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && !((Object)(object)localCharacter.data == (Object)null) && !((Object)(object)localCharacter.data.currentItem == (Object)null)) { if (Plugin.IsAllowAnyItemInPack()) { __result = true; } else if (Plugin.IsAllowNestedPacks() && localCharacter.data.currentItem is Backpack) { __result = true; } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("canInteract postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(Backpack), "Wear")] internal static class Patch_Backpack_Wear_DualPack { private static bool Prefix(Backpack __instance, Character interactor) { try { if ((Object)(object)__instance == (Object)null) { return true; } if (PackPrivacy.ShouldBlockDropped(__instance, interactor)) { return false; } return !DualPack.TryConsumeGroundPack((Item)(object)__instance, interactor); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Wear dual-pack prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(Item), "RequestPickup")] internal static class Patch_RequestPickup { private static bool Prefix(Item __instance, PhotonView characterView) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Invalid comparison between Unknown and I4 try { if (!PackPrivacy.ShouldBlockPickup(__instance, characterView)) { if (Plugin.IsAllowNestedPacks() && __instance is Backpack && (int)__instance.itemState == 2) { Character interactor = (((Object)(object)characterView != (Object)null) ? ((Component)characterView).GetComponent() : Character.localCharacter); NestedPacks.TryDropInnerPack(__instance, interactor); return false; } if (__instance is Backpack && (int)__instance.itemState == 0) { if (DualPack.AlreadyConsumed(__instance)) { return false; } Character val = (((Object)(object)characterView != (Object)null) ? ((Component)characterView).GetComponent() : Character.localCharacter); if ((Object)(object)val != (Object)null && DualPack.TryConsumeGroundPack(__instance, val)) { return false; } } return true; } PackPrivacy.DenyPickup(__instance, characterView); return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RequestPickup prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(CharacterItems), "DoSwitching")] internal static class Patch_DoSwitching_CarryDrop { internal static bool SkipCarryDrop; private static void Prefix() { SkipCarryDrop = Plugin.IsCarryWithPack(); } private static void Postfix() { SkipCarryDrop = false; } } [HarmonyPatch(typeof(CharacterCarrying), "Drop")] internal static class Patch_CarryDrop { private static bool Prefix() { try { return !Patch_DoSwitching_CarryDrop.SkipCarryDrop; } catch { return true; } } } [HarmonyPatch(typeof(CharacterCarrying), "StartCarry")] internal static class Patch_StartCarry { private static bool Prefix(CharacterCarrying __instance, Character target) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) try { if (!Plugin.IsCarryWithPack() || (Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || (Object)(object)target == (Object)null) { return true; } Character character = __instance.character; CharacterItems val = ((character.refs != null) ? character.refs.items : null); if ((!((Object)(object)character.data != (Object)null) || !(character.data.currentItem is Backpack) || !((Object)(object)val != (Object)null) || !val.currentSelectedSlot.IsSome || val.currentSelectedSlot.Value != 3) && (Object)(object)val != (Object)null) { val.EquipSlot(Optionable.None); } ((MonoBehaviourPun)character).photonView.RPC("RPCA_StartCarry", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)target).photonView }); return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("StartCarry prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(CharacterCarrying), "RPCA_StartCarry")] internal static class Patch_RPCA_StartCarry { private static bool Prefix(CharacterCarrying __instance, PhotonView targetView) { try { if (!Plugin.IsCarryWithPack() || (Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || (Object)(object)targetView == (Object)null) { return true; } Character character = __instance.character; Character component = ((Component)targetView).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } if ((Object)(object)character.data.carriedPlayer != (Object)null) { character.refs.carriying.Drop(character.data.carriedPlayer); } component.refs.carriying.ToggleCarryPhysics(true); component.data.isCarried = true; character.data.carriedPlayer = component; component.data.carrier = character; component.refs.afflictions.SubtractStatus((STATUSTYPE)14, 1f, true, false); component.refs.afflictions.SubtractStatus((STATUSTYPE)11, 1f, true, false); List allPlayerCharacters = PlayerHandler.GetAllPlayerCharacters(); for (int i = 0; i < allPlayerCharacters.Count; i++) { allPlayerCharacters[i].refs.afflictions.UpdateWeight(); } return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RPCA_StartCarry prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(Backpack), "Interact")] internal static class Patch_Backpack_Interact { private static bool Prefix(Backpack __instance, Character interactor) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 try { if ((Object)(object)__instance == (Object)null) { return true; } if ((int)((Item)__instance).itemState == 2) { NestedPacks.TryDropInnerPack((Item)(object)__instance, interactor); return false; } if (PackPrivacy.ShouldBlockDroppedOpen(__instance, interactor)) { return false; } return true; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Backpack.Interact prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(Backpack), "Stash")] internal static class Patch_Backpack_Stash { private static bool Prefix(Backpack __instance, Character interactor) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) try { return (Object)(object)__instance == (Object)null || !PackPrivacy.ShouldBlockStash(BackpackReference.GetFromBackpackItem((Item)(object)__instance), interactor); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Backpack.Stash prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(Item), "IsInteractible")] internal static class Patch_Item_IsInteractible { private static void Postfix(Item __instance, Character interactor, ref bool __result) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) try { Backpack val = (Backpack)(object)((__instance is Backpack) ? __instance : null); if (!((Object)(object)val == (Object)null) && __result && (int)((Item)val).itemState == 0 && PackPrivacy.ShouldBlockDroppedOpen(val, interactor)) { __result = false; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Item.IsInteractible postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(GUIManager), "OpenBackpackWheel")] internal static class Patch_OpenBackpackWheel { private static bool Prefix(BackpackReference backpackReference) { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) try { if ((int)backpackReference.type != 0 || (Object)(object)backpackReference.view == (Object)null) { return true; } Backpack component = ((Component)backpackReference.view).GetComponent(); return !PackPrivacy.ShouldBlockDroppedOpen(component, Character.localCharacter); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("OpenBackpackWheel prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(CharacterBackpackHandler), "StashInBackpack")] internal static class Patch_StashInBackpack { private static bool Prefix(CharacterBackpackHandler __instance, Character interactor) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null) { return true; } BackpackReference fromEquippedBackpack = BackpackReference.GetFromEquippedBackpack(__instance.character); return !PackPrivacy.ShouldBlockStash(fromEquippedBackpack, interactor); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("StashInBackpack prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(CharacterBackpackHandler), "RPCAddItemToCharacterBackpack")] internal static class Patch_RPCAddItemToCharacterBackpack { private static bool Prefix(CharacterBackpackHandler __instance, PhotonView playerView, byte inventorySlotID, byte backpackSlotID) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || (Object)(object)playerView == (Object)null) { return true; } Player component = ((Component)playerView).GetComponent(); Character interactor = (((Object)(object)component != (Object)null) ? component.character : null); BackpackReference fromEquippedBackpack = BackpackReference.GetFromEquippedBackpack(__instance.character); if (PackPrivacy.ShouldBlockStash(fromEquippedBackpack, interactor)) { return false; } if (!DualPack.TryGetWheelStorage(__instance.character, out var data, out var _) || data == null) { return true; } if ((Object)(object)component == (Object)null) { return true; } ItemSlot itemSlot = component.GetItemSlot(inventorySlotID); if (itemSlot == null || itemSlot.IsEmpty()) { return false; } data.AddItem(itemSlot.prefab, itemSlot.data, backpackSlotID); if (__instance.character.IsLocal && __instance.character.refs != null && (Object)(object)__instance.character.refs.afflictions != (Object)null) { __instance.character.refs.afflictions.UpdateWeight(); } return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RPCAddItemToCharacterBackpack prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(Backpack), "RPCAddItemToBackpack")] internal static class Patch_RPCAddItemToBackpack { private static bool Prefix(Backpack __instance, PhotonView playerView) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || (Object)(object)playerView == (Object)null) { return true; } Player component = ((Component)playerView).GetComponent(); Character interactor = (((Object)(object)component != (Object)null) ? component.character : null); return !PackPrivacy.ShouldBlockStash(BackpackReference.GetFromBackpackItem((Item)(object)__instance), interactor); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RPCAddItemToBackpack prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")] internal static class Patch_UpdateWeight { private static void Postfix(CharacterAfflictions __instance) { try { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.character == (Object)null)) { int num = NestedPacks.ExtraNestedWeight(__instance.character) + DualPack.ExtraWeight(__instance.character); if (num > 0) { float currentStatus = __instance.GetCurrentStatus((STATUSTYPE)7); __instance.SetStatus((STATUSTYPE)7, currentStatus + 0.025f * (float)num, true); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("UpdateWeight postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(BackpackVisuals), "RefreshVisuals")] internal static class Patch_BackpackVisuals_RefreshVisuals { private static void Prefix(BackpackVisuals __instance) { try { NestedPacks.DetachGroundedVisuals(__instance); NestedPacks.HideNestedPackVisuals(__instance); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RefreshVisuals detach prefix failed: " + ex)); } } } private static void Postfix() { try { NestedPacks.RestoreNestedPackVisuals(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RefreshVisuals restore postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(Player), "HasEmptySlot")] internal static class Patch_HasEmptySlot_DualPack { private static void Postfix(Player __instance, ushort itemID, ref bool __result) { try { if (!__result && !((Object)(object)__instance == (Object)null)) { __result = DualPack.CanAccept(__instance, itemID); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("HasEmptySlot dual-pack postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(Player), "AddItem")] internal static class Patch_AddItem_DualPack { private static bool Prefix(Player __instance, ushort itemID, ItemInstanceData instanceData, ref ItemSlot slot, ref bool __result) { try { if (!DualPack.TryCombine(__instance, itemID, instanceData, out slot)) { return true; } __result = true; return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("AddItem dual-pack prefix failed: " + ex)); } return true; } } } [HarmonyPatch(typeof(CharacterItems), "DropItemRpc")] internal static class Patch_DropItemRpc_DualPack { private static void Prefix(byte slotID) { DualPack.DropSlot3Active = slotID == 3; } private static void Postfix() { DualPack.DropSlot3Active = false; } } [HarmonyPatch(typeof(Player), "EmptySlot")] internal static class Patch_EmptySlot_DualPack { private static bool Prefix(Player __instance, Optionable slot) { try { if (!slot.IsSome || slot.Value != 3) { return true; } DualPack.CaptureRestore(__instance); if (PhotonNetwork.IsMasterClient || !DualPack.ShouldSkipClientRemoveRpc(__instance)) { return true; } ItemSlot itemSlot = __instance.GetItemSlot((byte)3); if (itemSlot != null) { itemSlot.EmptyOut(); } DualPack.TryRestoreAfterUtilityRemoved(__instance); return false; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("EmptySlot dual-pack prefix failed: " + ex)); } return true; } } private static void Postfix(Player __instance, Optionable slot) { try { if (slot.IsSome && slot.Value == 3) { DualPack.TryRestoreAfterUtilityRemoved(__instance); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("EmptySlot dual-pack postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(Player), "RPCRemoveItemFromSlot")] internal static class Patch_RPCRemoveItemFromSlot_DualPack { private static bool Prefix(Player __instance, byte slotID) { try { if (slotID == 3 && DualPack.ShouldProtectRestoredSlot(__instance)) { return false; } return true; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RPCRemoveItemFromSlot dual-pack prefix failed: " + ex)); } return true; } } private static void Postfix(Player __instance, byte slotID) { try { if (slotID == 3 && !DualPack.ShouldProtectRestoredSlot(__instance)) { DualPack.TryRestoreAfterUtilityRemoved(__instance); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("RPCRemoveItemFromSlot dual-pack postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(BackpackSlot), "GetPrefabName")] internal static class Patch_BackpackSlot_GetPrefabName { private static void Postfix(BackpackSlot __instance, ref string __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 try { if (__instance != null && (int)__instance.backpackType == 0) { __result = ""; } } catch { } } } [HarmonyPatch(typeof(MirrorCameraScript), "RenderMirror")] internal static class Patch_Mirror_Render { private static void Prefix() { try { DualPack.ShowLocalPacksForMirror(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Mirror pack show failed: " + ex)); } } } private static void Postfix() { try { DualPack.HideLocalPacksAfterMirror(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Mirror pack hide failed: " + ex)); } } } } [HarmonyPatch(typeof(CharacterBackpackHandler), "LateUpdate")] internal static class Patch_BackpackHandler_LateUpdate { private static void Postfix(CharacterBackpackHandler __instance) { try { DualPack.ShowExtraVisuals(__instance); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Dual pack visuals postfix failed: " + ex)); } } } } [HarmonyPatch(typeof(BackpackReference), "GetData")] internal static class Patch_BackpackReference_GetData { private static void Postfix(BackpackReference __instance, ref BackpackData __result) { //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_0009: Invalid comparison between Unknown and I4 //IL_000b: 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) try { if ((int)__instance.type == 1 && !((Object)(object)__instance.view == (Object)null)) { Character component = ((Component)__instance.view).GetComponent(); if (DualPack.TryResolveEquippedData(component, out var data) && data != null) { __result = data; } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("BackpackReference.GetData postfix failed: " + ex)); } } } } }