コード例 #1
0
        private void SetPickupOptionsHook(
            On.RoR2.UI.PickupPickerPanel.orig_SetPickupOptions orig,
            PickupPickerPanel self,
            PickupPickerController.Option[] options
            )
        {
            orig.Invoke(self, options);

            if (options.Length < 1)
            {
                return;
            }

            ReadOnlyCollection <MPButton> elements =
                self.GetFieldValue <UIElementAllocator <MPButton> >("buttonAllocator").elements;

            Inventory inventory = LocalUserManager.GetFirstLocalUser().cachedMasterController.master.inventory;

            for (int i = 0; i < options.Length; i++)
            {
                Transform parent           = elements[i].transform;
                PickupDef pickupDefinition = PickupCatalog.GetPickupDef(options[i].pickupIndex);
                ItemIndex itemIndex        = pickupDefinition.itemIndex;
                int       itemCount        = !itemIndex.Equals(ItemIndex.None) ? inventory.GetItemCount(itemIndex) : 0;

                if (pickupDefinition.equipmentIndex.Equals(EquipmentIndex.None))
                {
                    CreateNumberLabel(parent, itemIndex, itemCount);
                }

                if (EnableTooltip.Value)
                {
                    CreateTooltip(parent, pickupDefinition, itemCount);
                }
            }
        }
コード例 #2
0
 public void PickupPickerPanel_Awake(On.RoR2.UI.PickupPickerPanel.orig_Awake orig, PickupPickerPanel self)
 {
     currentPanel = self;
     orig(self);
 }