Decompiled source of PEAK Packs v1.0.2
tony4twentys-PEAK Packs.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.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<bool> EnabledConfig; internal static ConfigEntry<KeyCode> StoreKeyConfig; internal static ConfigEntry<bool> PutGroundItemsInWornPackConfig; internal static ConfigEntry<bool> OpenWheelWhenHeldConfig; internal static ConfigEntry<KeyCode> OpenAnyTimeKeyConfig; internal static ConfigEntry<bool> OpenAnyTimeToggleModeConfig; internal static ConfigEntry<KeyCode> CycleWornPackKeyConfig; internal static ConfigEntry<bool> UnlockLookWhileHeldOpenConfig; internal static ConfigEntry<bool> PackHotkeysEnabledConfig; internal static ConfigEntry<bool> PackHotkeysOnlyWhileHeldConfig; internal static ConfigEntry<KeyCode>[] PackSlotKeyConfigs; internal static ConfigEntry<PackPrivacyMode> PackPrivacyConfig; internal static ConfigEntry<KeyCode> PrivacyCycleKeyConfig; internal static ConfigEntry<bool> LookOnlyAllowStashConfig; internal static ConfigEntry<bool> AllowAnyItemInPackConfig; internal static ConfigEntry<bool> AllowNestedPacksConfig; internal static ConfigEntry<bool> CarryWithPackConfig; internal static ConfigEntry<KeyCode> OpenCarriedPackKeyConfig; internal static ConfigEntry<FannyPackPosition> FannyPackPositionConfig; internal static ConfigEntry<bool> ShowOwnPacksConfig; internal static ConfigEntry<bool> AllowMultipackConfig; internal static ConfigEntry<bool> AllowUtilityAndBackpackConfig; internal static ConfigEntry<bool> AllowUtilityAndFannypackConfig; internal static ConfigEntry<bool> BackpackInFrontWhenWearingUtilityConfig; internal static ConfigEntry<bool> 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<bool>("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<KeyCode>("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<bool>("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<bool>("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<bool>("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<PackPrivacyMode>("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<KeyCode>("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<bool>("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<bool>("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<bool>("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<bool>("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<KeyCode>("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<bool>("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<KeyCode>("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<KeyCode>("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<bool>("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<bool>("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<KeyCode>[4]; PackSlotKeyConfigs[0] = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("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<KeyCode>("Pack Hotkeys", "Slot2Key", (KeyCode)54, "Pack slot 2. Next slice clockwise."); PackSlotKeyConfigs[2] = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Pack Hotkeys", "Slot3Key", (KeyCode)55, "Pack slot 3. Fanny packs usually ignore this."); PackSlotKeyConfigs[3] = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Pack Hotkeys", "Slot4Key", (KeyCode)56, "Pack slot 4. Fanny packs usually ignore this."); AllowMultipackConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("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<bool>("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<bool>("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<bool>("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<FannyPackPosition>("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<bool>("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<bool>("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<Item>() : null; } internal static void RefreshBackpackVisuals(Backpack backpack) { if ((Object)(object)backpack == (Object)null) { return; } try { BackpackVisuals component = ((Component)backpack).GetComponent<BackpackVisuals>(); 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<GameObject>("0_Items/" + ((object)Unsafe.As<BackpackType, BackpackType>(ref wheel.backpackType)/*cast due to .constrained prefix*/).ToString()); Backpack val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<Backpack>() : 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<byte>.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<BackpackData>((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<byte>.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<PhotonView>(); 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<KeyCode> 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<string, int> LastHolderByGuid = new Dictionary<string, int>(); private static readonly Dictionary<int, PackPrivacyMode> ModeByActor = new Dictionary<int, PackPrivacyMode>(); internal static void TickOwners() { List<Character> 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<Character>(); } 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<Backpack>(); 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<Character>(); 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<object>()); } } } 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<Backpack>(); 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<Character> 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<Canvas>(); val.renderMode = (RenderMode)0; val.sortingOrder = 9400; val.additionalShaderChannels = (AdditionalCanvasShaderChannels)25; CanvasScaler val2 = _canvasObject.AddComponent<CanvasScaler>(); 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<RectTransform>(); 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<TextMeshProUGUI>(); ((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<TextMeshProUGUI>(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<BackpackData>((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<FloatItemData>((DataEntryKey)10, ref val2)) { return val2.Value < 99.5f; } FloatItemData val3 = default(FloatItemData); if (val != null && val.TryGetDataEntry<FloatItemData>((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<byte>.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<byte>.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<byte>.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<byte>.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<BackpackData>((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<BackpackOnBackVisuals>() == (Object)null) { return false; } Character componentInParent = val.GetComponentInParent<Character>(); 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<byte>.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<byte>.Some(value)); val.EquipSlot(Optionable<byte>.None); try { JetpackItem component = ((Component)backpack).GetComponent<JetpackItem>(); 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<BackpackData>((DataEntryKey)7)); if (TryGetFirstEmptySlot(data, backpack.slotCount, out var slotId)) { PhotonView component2 = ((Component)character.player).GetComponent<PhotonView>(); PhotonView component3 = ((Component)backpack).GetComponent<PhotonView>(); 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<byte>.Some(value)); val.EquipSlot(Optionable<byte>.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<PhotonView>(); 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<PhotonView>(); if ((Object)(object)component != (Object)null) { PhotonNetwork.Destroy(component