Exemple #1
0
        private void EquipmentIconOnUpdate(On.RoR2.UI.EquipmentIcon.orig_Update orig, EquipmentIcon self)
        {
            orig(self);

            var feedback = self.GetComponent <DurabilityFeedback>();

            if (feedback == null)
            {
                feedback = self.gameObject.AddComponent <DurabilityFeedback>();
            }

            var master = self.playerCharacterMasterController?.master;

            if (master != null)
            {
                var tracker = master.GetComponent <DurabilityTracker>();
                if (tracker == null)
                {
                    tracker               = master.gameObject.AddComponent <DurabilityTracker>();
                    tracker.durability    = FullDurability;
                    tracker.durabilityAlt = FullDurability;
                }

                bool useAlt = self.targetEquipmentSlot.activeEquipmentSlot == 0
                    ? self.displayAlternateEquipment
                    : !self.displayAlternateEquipment;
                feedback.percentDurability = useAlt ? tracker.durabilityAlt : tracker.durability;
                feedback.showBar           = self.hasEquipment;
            }
        }
Exemple #2
0
 public void Update()
 {
     foreach (var hud in HUD.readOnlyInstanceList)
     {
         if (hud == null && hud.itemInventoryDisplay == null)
         {
             continue;
         }
         List <ItemIcon> itemIcons = hud.itemInventoryDisplay.GetFieldValue <List <ItemIcon> >("itemIcons");
         foreach (var icon in itemIcons)
         {
             if (icon.GetComponent <ItemDropper>() == null)
             {
                 ItemDropper dropper = icon.gameObject.AddComponent <ItemDropper>();
                 dropper.master = master;
             }
         }
         if (hud.equipmentIcons.Length > 0)
         {
             EquipmentIcon equipmentIcon = hud.equipmentIcons[0];
             if (equipmentIcon.targetInventory == inventory && equipmentIcon.GetComponent <EquipmentDropper>() == null)
             {
                 EquipmentDropper dropper = equipmentIcon.gameObject.AddComponent <EquipmentDropper>();
                 dropper.master = master;
             }
         }
     }
 }
        private void UpdateScoreboard(HUD hud, FieldInfo fieldInfo)
        {
            ScoreboardController scoreboardController = hud.scoreboardPanel.GetComponent <ScoreboardController>();

            if (scoreboardController != null)
            {
                UIElementAllocator <ScoreboardStrip> elements = (UIElementAllocator <ScoreboardStrip>) typeof(ScoreboardController)
                                                                .GetField("stripAllocator", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(scoreboardController);

                if (elements != null)
                {
                    List <ScoreboardStrip> scoreboardStrips = (List <ScoreboardStrip>) typeof(UIElementAllocator <ScoreboardStrip>)
                                                              .GetField("elementControllerComponentsList", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(elements);

                    foreach (ScoreboardStrip scoreboardStrip in scoreboardStrips)
                    {
                        if (scoreboardStrip == null)
                        {
                            continue;
                        }

                        if (fieldInfo != null)
                        {
                            List <ItemIcon> itemIcons = (List <ItemIcon>)fieldInfo.GetValue(scoreboardStrip.itemInventoryDisplay);

                            foreach (ItemIcon itemIcon in itemIcons)
                            {
                                if (itemIcon != null && itemIcon.GetComponent <DropItemController>() == null)
                                {
                                    DropItemController dropItemController = itemIcon.gameObject.AddComponent <DropItemController>();
                                    Inventory          inventory          = (Inventory)typeof(ItemInventoryDisplay).GetField("inventory", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(scoreboardStrip.itemInventoryDisplay);
                                    dropItemController.Inventory            = inventory;
                                    dropItemController.ItemIcon             = itemIcon;
                                    dropItemController.SendDropItemToServer = SendDropItemRequest;
                                }
                            }
                        }

                        EquipmentIcon equipmentIcon = scoreboardStrip.equipmentIcon;

                        if (equipmentIcon != null && equipmentIcon.GetComponent <DropItemController>() == null)
                        {
                            if (equipmentIcon.targetInventory == null)
                            {
                                continue;
                            }
                            EquipmentIndex equipmentIndex = (equipmentIcon.displayAlternateEquipment) ? equipmentIcon.targetInventory.alternateEquipmentIndex : equipmentIcon.targetInventory.currentEquipmentIndex;

                            if (equipmentIndex != EquipmentIndex.None)
                            {
                                DropItemController dropItemController = equipmentIcon.gameObject.AddComponent <DropItemController>();
                                dropItemController.Inventory                 = equipmentIcon.targetInventory;
                                dropItemController.EquipmentIcon             = equipmentIcon;
                                dropItemController.SendDropEquipmentToServer = SendDropEquipmentRequest;
                            }
                        }
                    }
                }
            }
        }
Exemple #4
0
        private static void AttachZetDropHandler(EquipmentIcon icon)
        {
            if (icon.GetComponent <ZetDropHandler>() != null)
            {
                return;
            }
            var dropItemHandler = icon.transform.gameObject.AddComponent <ZetDropHandler>();

            dropItemHandler.GetInventory  = () => icon.targetInventory;
            dropItemHandler.EquipmentIcon = true;
        }
Exemple #5
0
        private static void AttachZetAspectsConvertHandler(EquipmentIcon icon)
        {
            if (icon.GetComponent <ZetAspectsConvertHandler>() != null)
            {
                return;
            }

            ZetAspectsConvertHandler handler = icon.transform.gameObject.AddComponent <ZetAspectsConvertHandler>();

            handler.GetInventory = () => icon.targetInventory;
            handler.GetPCMC      = () => icon.playerCharacterMasterController;
        }
    private bool onItemReady(EditableItemEvents.ItemReady evt)
    {
        int           index = evt.Index;
        EditableItem  item  = evt.Item;
        EquipmentIcon componentInChildren = item.GetComponentInChildren <EquipmentIcon>();

        switch (index)
        {
        case 0:
            item.ShowActionButton = false;
            componentInChildren.SetupCreateButton();
            break;

        case 1:
            item.ShowActionButton = false;
            componentInChildren.SetupCatalogButton();
            break;

        default:
        {
            componentInChildren.SetupEquipmentButton();
            long key = model.DisplayedInventory[index - 2];
            InventoryIconModel <DCustomEquipment> inventoryIconModel = model.InventoryData.Inventory[key];
            item.ShowActionButton = true;
            item.Action           = EditableItem.ActionType.Delete;
            if (templateDefinitions.TryGetValue(inventoryIconModel.Data.DefinitionId, out TemplateDefinition value) && !value.IsEditable)
            {
                if (inventoryIconModel.IsHidden)
                {
                    item.Action = EditableItem.ActionType.Hide;
                }
                else
                {
                    item.Action = EditableItem.ActionType.Show;
                }
            }
            AccessibilitySettings component = componentInChildren.GetComponent <AccessibilitySettings>();
            if (component != null)
            {
                component.CustomToken = value.Name;
            }
            setItemView(componentInChildren, inventoryIconModel);
            break;
        }
        }
        return(false);
    }