public static SimpleInlineElement AppendContent(this IInlineContainer container, string text, IStyleDefinition?localStyle = null) { var element = new SimpleInlineElement() { Text = text }; localStyle?.MergeInto(element.LocalStyles); container.AppendContent(element); return(element); }
private void AppendHitPointDescription(GameObject critter, IInlineContainer content) { var subdualDamage = critter.GetStat(Stat.subdual_damage); var currentHp = critter.GetStat(Stat.hp_current); var maxHp = critter.GetStat(Stat.hp_max); StyleDefinition hpStyleDefinition = null; if (critter.IsPC()) { if (currentHp < maxHp) { hpStyleDefinition = new StyleDefinition() { Color = new PackedLinearColorA(0xFFFF0000) }; } } else if (GameSystems.Critter.IsDeadNullDestroyed(critter) || currentHp <= 0) { hpStyleDefinition = new StyleDefinition() { Color = new PackedLinearColorA(0xFF7F7F7F) }; } else { var injuryLevel = UiSystems.Tooltip.GetInjuryLevel(critter); hpStyleDefinition = new StyleDefinition() { Color = UiSystems.Tooltip.GetInjuryLevelColor(injuryLevel) }; } if (critter.IsPC()) { content.AppendContent(_translations[103]); content.AppendContent(": "); content.AppendContent(currentHp.ToString(), hpStyleDefinition); content.AppendContent($"/{maxHp}"); if (subdualDamage > 0) { content.AppendContent($"({subdualDamage})", CommonStyles.HpSubdualDamage); } } else if (GameSystems.Critter.IsDeadNullDestroyed(critter) || currentHp <= 0) { content.AppendContent(_translations[108]); content.AppendContent(": "); content.AppendContent((maxHp - currentHp).ToString(), hpStyleDefinition); } else { content.AppendContent(GetInjuryLevelDescription(critter), hpStyleDefinition); if (subdualDamage <= 0) { // Show the amount of damage dealt so far if (currentHp < maxHp) { content.AppendContent("\n"); content.AppendContent(_translations[108]); // "Damage" content.AppendContent(": "); content.AppendContent((maxHp - currentHp).ToString(), hpStyleDefinition); } } else { if (subdualDamage >= maxHp) { content.AppendContent("\n"); content.AppendContent(_translations[108]); // "Damage" content.AppendContent(": "); content.AppendContent($"({subdualDamage})", CommonStyles.HpSubdualDamage); } else { content.AppendContent("\n"); content.AppendContent(_translations[108]); // "Damage" content.AppendContent(": @1"); content.AppendContent((maxHp - currentHp).ToString(), hpStyleDefinition); content.AppendContent("@0 "); content.AppendContent($"({subdualDamage})", CommonStyles.HpSubdualDamage); } } } }