Skip to content

Commit

Permalink
Merge pull request #406 from LucasTheDrgn/health-analyser-mass
Browse files Browse the repository at this point in the history
Adding Body Mass to Health Analyzer UI
  • Loading branch information
Fansana authored Dec 15, 2024
2 parents 067ed7d + 72e7a87 commit bb3f178
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<GridContainer Margin="0 5 0 0" Columns="2">
<Label Text="{Loc 'health-analyzer-window-entity-status-text'}" />
<Label Name="StatusLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-mass-text'}" />
<Label Name="MassLabel" /> <!-- Floof: Health scanners show body mass -->
<Label Text="{Loc 'health-analyzer-window-entity-temperature-text'}" />
<Label Name="TemperatureLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-blood-level-text'}" />
Expand Down
4 changes: 4 additions & 0 deletions Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)

// Basic Diagnostic

MassLabel.Text = !float.IsNaN(msg.Mass) // Floof: Health scanners show body mass
? $"{msg.Mass:F1} kg"
: Loc.GetString("health-analyzer-window-entity-unknown-value-text");

TemperatureLabel.Text = !float.IsNaN(msg.Temperature)
? $"{msg.Temperature - Atmospherics.T0C:F1} °C ({msg.Temperature:F1} K)"
: Loc.GetString("health-analyzer-window-entity-unknown-value-text");
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Medical/CryoPodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Timing;
using Robust.Shared.Physics.Components;
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;

namespace Content.Server.Medical;
Expand Down Expand Up @@ -193,6 +194,7 @@ private void OnActivateUI(Entity<CryoPodComponent> entity, ref AfterActivatableU
if (!entity.Comp.BodyContainer.ContainedEntity.HasValue)
return;

TryComp<PhysicsComponent>(entity.Comp.BodyContainer.ContainedEntity, out var physics); // Floof: Health scanners show body mass
TryComp<TemperatureComponent>(entity.Comp.BodyContainer.ContainedEntity, out var temp);
TryComp<BloodstreamComponent>(entity.Comp.BodyContainer.ContainedEntity, out var bloodstream);

Expand All @@ -206,6 +208,7 @@ private void OnActivateUI(Entity<CryoPodComponent> entity, ref AfterActivatableU
entity.Owner,
HealthAnalyzerUiKey.Key,
new HealthAnalyzerScannedUserMessage(GetNetEntity(entity.Comp.BodyContainer.ContainedEntity),
physics?.FixturesMass ?? 0, // Floof: Health scanners show body mass
temp?.CurrentTemperature ?? 0,
(bloodstream != null && _solutionContainerSystem.ResolveSolution(entity.Comp.BodyContainer.ContainedEntity.Value,
bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution))
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/Medical/HealthAnalyzerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Physics.Components;

namespace Content.Server.Medical;

Expand Down Expand Up @@ -181,6 +182,11 @@ public void UpdateScannedUser(EntityUid healthAnalyzer, EntityUid target, bool s
if (!HasComp<DamageableComponent>(target))
return;

var mass = float.NaN; // Floof: Health scanners show body mass

if (TryComp<PhysicsComponent>(target, out var physics))
mass = physics.FixturesMass;

var bodyTemperature = float.NaN;

if (TryComp<TemperatureComponent>(target, out var temp))
Expand All @@ -203,6 +209,7 @@ public void UpdateScannedUser(EntityUid healthAnalyzer, EntityUid target, bool s
*/
_uiSystem.ServerSendUiMessage(healthAnalyzer, HealthAnalyzerUiKey.Key, new HealthAnalyzerScannedUserMessage(
GetNetEntity(target),
mass, // Floof: Health scanners show body mass
bodyTemperature,
bloodAmount,
scanMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ namespace Content.Shared.MedicalScanner;
public sealed class HealthAnalyzerScannedUserMessage : BoundUserInterfaceMessage
{
public readonly NetEntity? TargetEntity;
public float Mass; // Floof: Health scanners show body mass
public float Temperature;
public float BloodLevel;
public bool? ScanMode;
public bool? Bleeding;
public bool? Unrevivable;

public HealthAnalyzerScannedUserMessage(NetEntity? targetEntity, float temperature, float bloodLevel, bool? scanMode, bool? bleeding, bool? unrevivable)
public HealthAnalyzerScannedUserMessage(NetEntity? targetEntity, float mass, float temperature, float bloodLevel, bool? scanMode, bool? bleeding, bool? unrevivable)
{
TargetEntity = targetEntity;
Mass = mass; // Floof: Health scanners show body mass
Temperature = temperature;
BloodLevel = bloodLevel;
ScanMode = scanMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ health-analyzer-window-entity-alive-text = Alive
health-analyzer-window-entity-dead-text = Dead
health-analyzer-window-entity-critical-text = Critical
health-analyzer-window-entity-mass-text = Mass:
health-analyzer-window-entity-temperature-text = Temperature:
health-analyzer-window-entity-blood-level-text = Blood Level:
health-analyzer-window-entity-status-text = Status:
Expand Down

0 comments on commit bb3f178

Please sign in to comment.