Health examine button (#6749)

* Health examine button

* better icon

* ignore

* better icon + some reviews

* fix thing
This commit is contained in:
mirrorcult
2022-02-17 20:26:05 -07:00
committed by GitHub
parent 6ef3bff9be
commit 8ae2ec9426
10 changed files with 197 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ namespace Content.Client.Entry
"IngestionBlocker",
"Charger",
"CloningPod",
"HealthExaminable",
"Destructible",
"Temperature",
"AtmosExposed",

View File

@@ -0,0 +1,23 @@
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
namespace Content.Server.HealthExaminable;
[RegisterComponent]
public sealed class HealthExaminableComponent : Component
{
public List<FixedPoint2> Thresholds = new()
{ FixedPoint2.New(10), FixedPoint2.New(25), FixedPoint2.New(50), FixedPoint2.New(75) };
[DataField("examinableTypes", required: true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer<DamageTypePrototype>))]
public HashSet<string> ExaminableTypes = default!;
/// <summary>
/// Health examine text is automatically generated through creating loc string IDs, in the form:
/// `health-examine-[prefix]-[type]-[threshold]`
/// This part determines the prefix.
/// </summary>
[DataField("locPrefix")]
public string LocPrefix = "carbon";
}

View File

@@ -0,0 +1,98 @@
using Content.Server.Examine;
using Content.Shared.Damage;
using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Ghost.Roles;
using Content.Shared.Verbs;
using Robust.Shared.Utility;
namespace Content.Server.HealthExaminable;
public sealed class HealthExaminableSystem : EntitySystem
{
[Dependency] private readonly ExamineSystemShared _examineSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HealthExaminableComponent, GetVerbsEvent<ExamineVerb>>(OnGetExamineVerbs);
}
private void OnGetExamineVerbs(EntityUid uid, HealthExaminableComponent component, GetVerbsEvent<ExamineVerb> args)
{
if (!TryComp<DamageableComponent>(uid, out var damage))
return;
var detailsRange = _examineSystem.IsInDetailsRange(args.User, uid);
var verb = new ExamineVerb()
{
Act = () =>
{
var markup = CreateMarkup(uid, component, damage);
_examineSystem.SendExamineTooltip(args.User, uid, markup, false, false);
},
Text = Loc.GetString("health-examinable-verb-text"),
Category = VerbCategory.Examine,
Disabled = !detailsRange,
Message = Loc.GetString("health-examinable-verb-disabled"),
IconTexture = "/Textures/Interface/VerbIcons/plus.svg.192dpi.png"
};
args.Verbs.Add(verb);
}
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", uid));
// i.e., this string doesn't exist, because theres nothing for that threshold
if (tempLocStr == str)
continue;
chosenLocStr = tempLocStr;
if (dmg > threshold && threshold > closest)
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"));
}
return msg;
}
}

View File

@@ -0,0 +1,18 @@
health-examinable-carbon-none = There are no obvious wounds to be seen.
health-examinable-carbon-Blunt-25 = [color=red]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } minor contusions across { POSS-ADJ($target) } body.[/color]
health-examinable-carbon-Blunt-50 = [color=crimson]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } major bruises all over { POSS-ADJ($target) } body![/color]
health-examinable-carbon-Blunt-75 = [color=crimson]{ CAPITALIZE(POSS-ADJ($target)) } body is completely covered in lesions![/color]
health-examinable-carbon-Slash-10 = [color=red]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } some minor cuts.[/color]
health-examinable-carbon-Slash-25 = [color=red]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } lacerations across { POSS-ADJ($target) } body.[/color]
health-examinable-carbon-Slash-50 = [color=crimson]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } major gashes all over { POSS-ADJ($target) } body![/color]
health-examinable-carbon-Slash-75 = [color=crimson]{ CAPITALIZE(POSS-ADJ($target)) } body is completely mauled![/color]
health-examinable-carbon-Piercing-50 = [color=crimson]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } deep wounds all over { POSS-ADJ($target) } body![/color]
health-examinable-carbon-Heat-25 = [color=orange]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } minor burns across { POSS-ADJ($target) } body.[/color]
health-examinable-carbon-Heat-50 = [color=orange]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } major burns across { POSS-ADJ($target) } body.[/color]
health-examinable-carbon-Heat-75 = [color=orange]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } severe third-degree burns across { POSS-ADJ($target) } body![/color]
health-examinable-carbon-Shock-50 = [color=lightgoldenrod]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } electrical shock marks across { POSS-ADJ($target) } body![/color]

View File

@@ -0,0 +1,2 @@
health-examinable-verb-text = Health
health-examinable-verb-disabled = Not close enough

View File

@@ -22,6 +22,13 @@
- type: MovementSpeedModifier
baseWalkSpeed : 4
baseSprintSpeed : 4
- type: HealthExaminable
examinableTypes:
- Blunt
- Slash
- Piercing
- Heat
- Shock
- type: MovedByPressure
- type: DamageOnHighSpeedImpact
damage:

View File

@@ -48,6 +48,13 @@
solution: chemicals
- type: DrawableSolution
solution: bloodstream
- type: HealthExaminable
examinableTypes:
- Blunt
- Slash
- Piercing
- Heat
- Shock
- type: Bloodstream
bloodlossDamage:
types:

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
version="1.1"
id="svg834"
sodipodi:docname="plus.svg"
inkscape:version="1.1.2 (b8e25be833, 2022-02-05)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs838" />
<sodipodi:namedview
id="namedview836"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
showgrid="false"
inkscape:zoom="33.666667"
inkscape:cx="11.985149"
inkscape:cy="7.2475248"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg834" />
<path
d="M 22.69307,10.252475 H 13.806931 V 1.3663366 H 10.252475 V 10.252475 H 1.3663366 v 3.554455 h 8.8861384 v 8.886139 h 3.554456 V 13.80693 h 8.886139 z"
id="path832"
inkscape:label="path832"
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke-width:0.888614" />
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

View File

@@ -0,0 +1,2 @@
sample:
filter: true