private FormattedMessage CreateMarkup(EntityUid uid, HealthExaminableComponent component, DamageableComponent damage) { var msg = new FormattedMessage(); var first = true; foreach (var type in component.ExaminableTypes) { if (!damage.Damage.DamageDict.TryGetValue(type, out var dmg)) { continue; } if (dmg == FixedPoint2.Zero) { continue; } FixedPoint2 closest = FixedPoint2.Zero; string chosenLocStr = string.Empty; foreach (var threshold in component.Thresholds) { var str = $"health-examinable-{component.LocPrefix}-{type}-{threshold}"; var tempLocStr = Loc.GetString($"health-examinable-{component.LocPrefix}-{type}-{threshold}", ("target", Identity.Entity(uid, EntityManager))); // i.e., this string doesn't exist, because theres nothing for that threshold if (tempLocStr == str) { continue; } if (dmg > threshold && threshold > closest) { chosenLocStr = tempLocStr; closest = threshold; } } if (closest == FixedPoint2.Zero) { continue; } if (!first) { msg.PushNewline(); } else { first = false; } msg.AddMarkup(chosenLocStr); } if (msg.IsEmpty) { msg.AddMarkup(Loc.GetString($"health-examinable-{component.LocPrefix}-none")); } // Anything else want to add on to this? RaiseLocalEvent(uid, new HealthBeingExaminedEvent(msg), true); return(msg); }
public Entry(LiteResult result) { MouseFilter = MouseFilterMode.Stop; Result = result; var compl = new FormattedMessage(); var dim = Color.FromHsl((0f, 0f, 0.8f, 1f)); // warning: ew ahead string basen = "default"; if (Result.Tags.Contains("Interface")) { basen = "interface name"; } else if (Result.Tags.Contains("Class")) { basen = "class name"; } else if (Result.Tags.Contains("Struct")) { basen = "struct name"; } else if (Result.Tags.Contains("Keyword")) { basen = "keyword"; } else if (Result.Tags.Contains("Namespace")) { basen = "namespace name"; } else if (Result.Tags.Contains("Method")) { basen = "method name"; } else if (Result.Tags.Contains("Property")) { basen = "property name"; } else if (Result.Tags.Contains("Field")) { basen = "field name"; } Color basec = ScriptingColorScheme.ColorScheme[basen]; compl.PushColor(basec * dim); compl.AddText(Result.DisplayTextPrefix); compl.PushColor(basec); compl.AddText(Result.DisplayText); compl.PushColor(basec * dim); compl.AddText(Result.DisplayTextSuffix); compl.AddText(" [" + String.Join(", ", Result.Tags) + "]"); if (Result.InlineDescription.Length != 0) { compl.PushNewline(); compl.AddText(": "); compl.PushColor(Color.LightSlateGray); compl.AddText(Result.InlineDescription); } SetMessage(compl); }