コード例 #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;
            }
        }
コード例 #2
0
        private void EquipmentIcon_Update(On.RoR2.UI.EquipmentIcon.orig_Update orig, RoR2.UI.EquipmentIcon self)
        {
            orig(self);
            if (self.gameObject.GetComponent <YeetButton>())
            {
                return;
            }
            var btn = self.gameObject.AddComponent <YeetButton>();

            btn.isEquipment = true;
        }
コード例 #3
0
 private void EquipmentIcon_Update(On.RoR2.UI.EquipmentIcon.orig_Update orig, RoR2.UI.EquipmentIcon self)
 {
     orig(self);
     if (self.iconImage && self.currentDisplayData.equipmentDef == instance.equipmentDef && self.targetEquipmentSlot && self.targetEquipmentSlot.characterBody)
     {
         var cpt = self.targetEquipmentSlot.characterBody.GetComponent <PackBoxTracker>();
         if (cpt && cpt.packedObject)
         {
             self.iconImage.texture = instance.secondaryIconResource.texture;
         }
     }
 }
コード例 #4
0
 private void EquipmentIcon_Update(On.RoR2.UI.EquipmentIcon.orig_Update orig, EquipmentIcon self)
 {
     orig(self);
     if (self.targetEquipmentSlot && self.targetEquipmentSlot.equipmentIndex == equipmentDef.equipmentIndex)
     {
         var component = self.targetEquipmentSlot.GetComponent <MysticsItemsOmarHackToolBehaviour>();
         if (component && component.usesLeft <= 0)
         {
             if (self.iconImage)
             {
                 self.iconImage.color = Color.gray;
             }
         }
     }
 }
コード例 #5
0
ファイル: AdvancedIcons.cs プロジェクト: ethall/BetterUI
        internal void EquipmentIcon_Update(On.RoR2.UI.EquipmentIcon.orig_Update orig, EquipmentIcon self)
        {
            orig(self);

            if (!this.EquipmentIconDirty.ContainsKey(self))
            {
                this.EquipmentIconDirty.Add(self, true);
                this.lastEquipment.Add(self, null);
            }
            if ((mod.config.AdvancedIconsEquipementAdvancedDescriptions.Value ||
                 mod.config.AdvancedIconsEquipementShowBaseCooldown.Value ||
                 mod.config.AdvancedIconsEquipementShowCalculatedCooldown.Value) &&
                (self.currentDisplayData.equipmentDef != this.lastEquipment[self] || this.EquipmentIconDirty[self]) &&
                self.currentDisplayData.hasEquipment && self.tooltipProvider)
            {
                this.lastEquipment[self]      = self.currentDisplayData.equipmentDef;
                this.EquipmentIconDirty[self] = false;
                BetterUI.sharedStringBuilder.Clear();
                BetterUI.sharedStringBuilder.Append(Language.GetString(mod.config.AdvancedIconsEquipementAdvancedDescriptions.Value ? self.currentDisplayData.equipmentDef.descriptionToken : self.currentDisplayData.equipmentDef.pickupToken));
                if (mod.config.AdvancedIconsEquipementShowBaseCooldown.Value || mod.config.AdvancedIconsEquipementShowCalculatedCooldown.Value)
                {
                    BetterUI.sharedStringBuilder.Append("\n");
                }
                if (mod.config.AdvancedIconsEquipementShowBaseCooldown.Value)
                {
                    BetterUI.sharedStringBuilder.Append("\nBase Cooldown: <style=cIsDamage>");
                    BetterUI.sharedStringBuilder.Append(self.currentDisplayData.equipmentDef.cooldown);
                    BetterUI.sharedStringBuilder.Append("</style> second");
                    if (self.currentDisplayData.equipmentDef.cooldown != 1)
                    {
                        BetterUI.sharedStringBuilder.Append("s");
                    }
                }
                if (mod.config.AdvancedIconsEquipementShowCalculatedCooldown.Value)
                {
                    inventory = self.targetInventory;
                    if (!inventory && mod.HUD.targetBodyObject)
                    {
                        targetbody = mod.HUD.targetBodyObject.GetComponent <CharacterBody>();
                        if (targetbody)
                        {
                            inventory = targetbody.inventory;
                        }
                    }
                    if (inventory)
                    {
                        float reduction = (float)Math.Pow(0.85, inventory.itemStacks[(int)ItemCatalog.FindItemIndex("EquipmentMagazine")]);
                        if (inventory.itemStacks[(int)ItemCatalog.FindItemIndex("AutoCastEquipment")] > 0)
                        {
                            reduction *= 0.5f * (float)Math.Pow(0.85, inventory.itemStacks[(int)ItemCatalog.FindItemIndex("AutoCastEquipment")] - 1);
                        }
                        if (reduction < 1)
                        {
                            BetterUI.sharedStringBuilder.Append("\nEffective Cooldown: <style=cIsHealing>");
                            BetterUI.sharedStringBuilder.Append((self.currentDisplayData.equipmentDef.cooldown * reduction).ToString("0.###"));
                            BetterUI.sharedStringBuilder.Append("</style> second");
                            if (self.currentDisplayData.equipmentDef.cooldown != 1)
                            {
                                BetterUI.sharedStringBuilder.Append("s");
                            }
                        }
                    }
                }


                self.tooltipProvider.overrideBodyText = BetterUI.sharedStringBuilder.ToString();
            }

            if (mod.config.AdvancedIconsEquipementShowCooldownStacks.Value && self.cooldownText && self.currentDisplayData.cooldownValue > 0)
            {
                self.cooldownText.gameObject.SetActive(true);
            }
        }