Exemple #1
0
        internal void LoadoutPanelController_Row_AddButton(On.RoR2.UI.LoadoutPanelController.Row.orig_AddButton orig, object self, LoadoutPanelController owner, Sprite icon, string titleToken, string bodyToken, Color tooltipColor, UnityEngine.Events.UnityAction callback, string unlockableName, ViewablesCatalog.Node viewableNode, bool isWIP = false)
        {
            orig(self, owner, icon, titleToken, bodyToken, tooltipColor, callback, unlockableName, viewableNode, isWIP);

            LoadoutPanelController.Row selfRow = (LoadoutPanelController.Row)self;
            UserProfile userProfile            = selfRow.userProfile;

            if (mod.config.AdvancedIconsSkillShowProcCoefficient.Value || mod.config.AdvancedIconsSkillShowBaseCooldown.Value)
            {
                if (userProfile != null && userProfile.HasUnlockable(unlockableName))
                {
                    BetterUI.sharedStringBuilder.Clear();
                    BetterUI.sharedStringBuilder.Append(Language.GetString(bodyToken));
                    if (mod.config.AdvancedIconsSkillShowBaseCooldown.Value)
                    {
                        BetterUI.print(titleToken);
                        var skillDef = RoR2.Skills.SkillCatalog.GetSkillDef(Utils.TheREALFindSkillIndexByName(titleToken));
                        if (skillDef)
                        {
                            BetterUI.sharedStringBuilder.Append("\n\nCooldown: <style=cIsDamage>");
                            BetterUI.sharedStringBuilder.Append(skillDef.baseRechargeInterval);
                            BetterUI.sharedStringBuilder.Append("</style> second");
                            if (skillDef.baseRechargeInterval != 1)
                            {
                                BetterUI.sharedStringBuilder.Append("s");
                            }
                        }
                    }

                    if (mod.config.AdvancedIconsSkillShowProcCoefficient.Value)
                    {
                        List <ProcCoefficientCatalog.ProcCoefficientInfo> procCoefficientInfos = ProcCoefficientCatalog.GetProcCoefficientInfo(titleToken);

                        if (procCoefficientInfos != null)
                        {
                            foreach (var info in procCoefficientInfos)
                            {
                                BetterUI.sharedStringBuilder.Append("\n\n<size=110%>");
                                BetterUI.sharedStringBuilder.Append(info.name);
                                BetterUI.sharedStringBuilder.Append(":</size>");
                                if (mod.config.AdvancedIconsSkillShowProcCoefficient.Value)
                                {
                                    BetterUI.sharedStringBuilder.Append("\n <style=cIsUtility>Proc Coefficient: ");
                                    BetterUI.sharedStringBuilder.Append(info.procCoefficient);
                                    BetterUI.sharedStringBuilder.Append("</style>");
                                }
                            }
                        }
                    }
                    TooltipProvider tooltipProvider = selfRow.buttons[selfRow.buttons.Count - 1].GetComponent <TooltipProvider>();
                    if (tooltipProvider != null)
                    {
                        tooltipProvider.overrideBodyText = BetterUI.sharedStringBuilder.ToString();
                    }
                }
            }
        }
Exemple #2
0
        internal void SkillIcon_Update(On.RoR2.UI.SkillIcon.orig_Update orig, SkillIcon self)
        {
            orig(self);

            if (!SkillIconDirty.ContainsKey(self))
            {
                this.SkillIconDirty.Add(self, true);
                this.lastSkill.Add(self, null);
            }
            if (self.targetSkill && (self.targetSkill != this.lastSkill[self] || this.SkillIconDirty[self]))
            {
                this.lastSkill[self]      = self.targetSkill;
                this.SkillIconDirty[self] = false;
                BetterUI.sharedStringBuilder.Clear();
                BetterUI.sharedStringBuilder.Append(Language.GetString(self.targetSkill.skillDescriptionToken));
                if (mod.config.AdvancedIconsSkillShowBaseCooldown.Value || mod.config.AdvancedIconsSkillShowCalculatedCooldown.Value)
                {
                    BetterUI.sharedStringBuilder.Append("\n");
                }
                if (mod.config.AdvancedIconsSkillShowBaseCooldown.Value)
                {
                    BetterUI.sharedStringBuilder.Append("\nBase Cooldown: <style=cIsDamage>");
                    BetterUI.sharedStringBuilder.Append(self.targetSkill.baseRechargeInterval);
                    BetterUI.sharedStringBuilder.Append("</style> second");
                    if (self.targetSkill.baseRechargeInterval != 1)
                    {
                        BetterUI.sharedStringBuilder.Append("s");
                    }
                }
                if (mod.config.AdvancedIconsSkillShowCalculatedCooldown.Value && self.targetSkill.baseRechargeInterval > self.targetSkill.finalRechargeInterval)
                {
                    BetterUI.sharedStringBuilder.Append("\nEffective Cooldown: <style=cIsHealing>");
                    BetterUI.sharedStringBuilder.Append(self.targetSkill.finalRechargeInterval);
                    BetterUI.sharedStringBuilder.Append("</style> second");
                    if (self.targetSkill.baseRechargeInterval != 1)
                    {
                        BetterUI.sharedStringBuilder.Append("s");
                    }
                }

                if (mod.config.AdvancedIconsSkillShowProcCoefficient.Value || mod.config.AdvancedIconsSkillCalculateSkillProcEffects.Value)
                {
                    procCoefficientInfos = ProcCoefficientCatalog.GetProcCoefficientInfo(self.targetSkill.skillDef.skillNameToken);

                    if (procCoefficientInfos != null)
                    {
                        foreach (var info in procCoefficientInfos)
                        {
                            BetterUI.sharedStringBuilder.Append("\n\n<size=110%>");
                            BetterUI.sharedStringBuilder.Append(info.name);
                            BetterUI.sharedStringBuilder.Append("</size>");
                            if (mod.config.AdvancedIconsSkillShowProcCoefficient.Value)
                            {
                                BetterUI.sharedStringBuilder.Append("\n <style=cIsUtility>Proc Coefficient: ");
                                BetterUI.sharedStringBuilder.Append(info.procCoefficient);
                                BetterUI.sharedStringBuilder.Append("</style>");
                            }
                            if (info.procCoefficient > 0 && mod.config.AdvancedIconsSkillCalculateSkillProcEffects.Value)
                            {
                                foreach (var item in ProcItemsCatalog.GetAllItems())
                                {
                                    int stacks = self.targetSkill.characterBody.inventory.itemStacks[(int)item.Key];
                                    if (stacks > 0)
                                    {
                                        ItemDef itemDef = ItemCatalog.GetItemDef(item.Key);
                                        BetterUI.sharedStringBuilder.Append("\n  ");
                                        BetterUI.sharedStringBuilder.Append(Language.GetString(itemDef.nameToken));
                                        BetterUI.sharedStringBuilder.Append(": ");
                                        BetterUI.sharedStringBuilder.Append(item.Value.GetOutputString(stacks, self.targetSkill.characterBody.master.luck, info.procCoefficient));
                                    }
                                }
                            }
                        }
                    }
                }

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

            if (mod.config.AdvancedIconsSkillShowCooldownStacks.Value && self.targetSkill && self.targetSkill.cooldownRemaining > 0)
            {
                BetterUI.sharedStringBuilder.Clear();
                BetterUI.sharedStringBuilder.AppendInt(Mathf.CeilToInt(self.targetSkill.cooldownRemaining), 0U, uint.MaxValue);
                self.cooldownText.SetText(BetterUI.sharedStringBuilder);
                self.cooldownText.gameObject.SetActive(true);
            }
        }