예제 #1
0
        private void ScoreboardStrip_UpdateMoneyText(On.RoR2.UI.ScoreboardStrip.orig_UpdateMoneyText orig, ScoreboardStrip self)
        {
            var master = self.GetFieldValue <CharacterMaster>("master");

            if (master?.inventory is null)
            {
                return;
            }

            var tierCountMap         = Utils.GetTierCounts(master.inventory);
            var tierCountMapFiltered = tierCountMap.Where(kv => kv.Value > 0);
            var itemCount            = tierCountMap.Sum(kv => kv.Value);

            StringBuilder sb = new StringBuilder();

            if (itemCount > 0)
            {
                sb.Append($"<nobr><color=#FFF>{itemCount} ");
                sb.Append("[");
                foreach (var pair in tierCountMapFiltered)
                {
                    string tierCount = pair.Value.ToString().Colorize(Utils.TierToHexString(pair.Key));
                    sb.Append($"{tierCount}");
                    sb.Append(" ");
                }
                if (sb[sb.Length - 1] == ' ')
                {
                    sb[sb.Length - 1] = ']';
                }

                sb.Append("</color></nobr>\n<nobr>");
            }
            sb.Append($"${master.money}</nobr>");
            self.moneyText.text         = sb.ToString();
            self.moneyText.overflowMode = TMPro.TextOverflowModes.Overflow;
        }