Remove empty damage values from health analyzer UI (#20366)
This commit is contained in:
@@ -38,17 +38,17 @@ namespace Content.Client.HealthAnalyzer.UI
|
|||||||
IReadOnlyDictionary<string, FixedPoint2> damagePerGroup = damageable.DamagePerGroup;
|
IReadOnlyDictionary<string, FixedPoint2> damagePerGroup = damageable.DamagePerGroup;
|
||||||
IReadOnlyDictionary<string, FixedPoint2> damagePerType = damageable.Damage.DamageDict;
|
IReadOnlyDictionary<string, FixedPoint2> damagePerType = damageable.Damage.DamageDict;
|
||||||
|
|
||||||
text.Append($"{Loc.GetString("health-analyzer-window-entity-health-text", ("entityName", entityName))}\n");
|
text.Append($"{Loc.GetString("health-analyzer-window-entity-health-text", ("entityName", entityName))}\n\n");
|
||||||
|
|
||||||
|
|
||||||
text.Append($"{Loc.GetString("health-analyzer-window-entity-temperature-text", ("temperature", float.IsNaN(msg.Temperature) ? "N/A" : $"{msg.Temperature - 273f:F1} °C"))}\n");
|
text.Append($"{Loc.GetString("health-analyzer-window-entity-temperature-text", ("temperature", float.IsNaN(msg.Temperature) ? "N/A" : $"{msg.Temperature - 273f:F1} °C"))}\n");
|
||||||
|
|
||||||
|
|
||||||
text.Append($"{Loc.GetString("health-analyzer-window-entity-blood-level-text", ("bloodLevel", float.IsNaN(msg.BloodLevel) ? "N/A" : $"{msg.BloodLevel * 100:F1} %"))}\n");
|
text.Append($"{Loc.GetString("health-analyzer-window-entity-blood-level-text", ("bloodLevel", float.IsNaN(msg.BloodLevel) ? "N/A" : $"{msg.BloodLevel * 100:F1} %"))}\n\n");
|
||||||
|
|
||||||
|
|
||||||
// Damage
|
// Damage
|
||||||
text.Append($"\n{Loc.GetString("health-analyzer-window-entity-damage-total-text", ("amount", damageable.TotalDamage))}\n");
|
text.Append($"{Loc.GetString("health-analyzer-window-entity-damage-total-text", ("amount", damageable.TotalDamage))}\n");
|
||||||
|
|
||||||
HashSet<string> shownTypes = new();
|
HashSet<string> shownTypes = new();
|
||||||
|
|
||||||
@@ -57,15 +57,20 @@ namespace Content.Client.HealthAnalyzer.UI
|
|||||||
// Show the total damage and type breakdown for each damage group.
|
// Show the total damage and type breakdown for each damage group.
|
||||||
foreach (var (damageGroupId, damageAmount) in damagePerGroup)
|
foreach (var (damageGroupId, damageAmount) in damagePerGroup)
|
||||||
{
|
{
|
||||||
|
if (damageAmount == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
text.Append($"\n{Loc.GetString("health-analyzer-window-damage-group-text", ("damageGroup", Loc.GetString("health-analyzer-window-damage-group-" + damageGroupId)), ("amount", damageAmount))}");
|
text.Append($"\n{Loc.GetString("health-analyzer-window-damage-group-text", ("damageGroup", Loc.GetString("health-analyzer-window-damage-group-" + damageGroupId)), ("amount", damageAmount))}");
|
||||||
|
|
||||||
// Show the damage for each type in that group.
|
// Show the damage for each type in that group.
|
||||||
var group = protos.Index<DamageGroupPrototype>(damageGroupId);
|
var group = protos.Index<DamageGroupPrototype>(damageGroupId);
|
||||||
foreach (var type in group.DamageTypes)
|
foreach (var type in group.DamageTypes)
|
||||||
{
|
{
|
||||||
if (damagePerType.TryGetValue(type, out var typeAmount))
|
if (damagePerType.TryGetValue(type, out var typeAmount) )
|
||||||
{
|
{
|
||||||
// If damage types are allowed to belong to more than one damage group, they may appear twice here. Mark them as duplicate.
|
// If damage types are allowed to belong to more than one damage group, they may appear twice here. Mark them as duplicate.
|
||||||
if (!shownTypes.Contains(type))
|
if (!shownTypes.Contains(type) && typeAmount > 0)
|
||||||
{
|
{
|
||||||
shownTypes.Add(type);
|
shownTypes.Add(type);
|
||||||
text.Append($"\n- {Loc.GetString("health-analyzer-window-damage-type-text", ("damageType", Loc.GetString("health-analyzer-window-damage-type-" + type)), ("amount", typeAmount))}");
|
text.Append($"\n- {Loc.GetString("health-analyzer-window-damage-type-text", ("damageType", Loc.GetString("health-analyzer-window-damage-type-" + type)), ("amount", typeAmount))}");
|
||||||
|
|||||||
Reference in New Issue
Block a user