Add health analyzer and medical scanner ECS (#6907)
Co-authored-by: fishfish458 <fishfish458> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -27,10 +27,10 @@ namespace Content.Client.MedicalScanner
|
||||
{
|
||||
case Off: return "closed";
|
||||
case Open: return "open";
|
||||
case Red: return "closed";
|
||||
case Death: return "closed";
|
||||
case Red: return "occupied";
|
||||
case Death: return "occupied";
|
||||
case Green: return "occupied";
|
||||
case Yellow: return "closed";
|
||||
case Yellow: return "occupied";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(status), status, "unknown MedicalScannerStatus");
|
||||
}
|
||||
@@ -43,7 +43,7 @@ namespace Content.Client.MedicalScanner
|
||||
case Off: return "off_unlit";
|
||||
case Open: return "idle_unlit";
|
||||
case Red: return "red_unlit";
|
||||
case Death: return "red_unlit";
|
||||
case Death: return "off_unlit";
|
||||
case Green: return "idle_unlit";
|
||||
case Yellow: return "maint_unlit";
|
||||
default:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
|
||||
|
||||
namespace Content.Client.MedicalScanner.UI
|
||||
@@ -23,7 +22,7 @@ namespace Content.Client.MedicalScanner.UI
|
||||
Title = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Owner).EntityName,
|
||||
};
|
||||
_window.OnClose += Close;
|
||||
_window.ScanButton.OnPressed += _ => SendMessage(new UiButtonPressedMessage(UiButton.ScanDNA));
|
||||
_window.ScanButton.OnPressed += _ => SendMessage(new ScanButtonPressedMessage());
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
@@ -31,7 +30,10 @@ namespace Content.Client.MedicalScanner.UI
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
_window?.Populate((MedicalScannerBoundUserInterfaceState) state);
|
||||
if (state is not MedicalScannerBoundUserInterfaceState cast)
|
||||
return;
|
||||
|
||||
_window?.Populate(cast);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
@@ -40,6 +42,9 @@ namespace Content.Client.MedicalScanner.UI
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
if (_window != null)
|
||||
_window.OnClose -= Close;
|
||||
|
||||
_window?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<DefaultWindow xmlns="https://spacestation14.io"
|
||||
MinSize="250 100"
|
||||
SetSize="250 100">
|
||||
MinSize="200 100"
|
||||
SetSize="200 100">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<Label Name="OccupantName"/>
|
||||
<Button Name="ScanButton"
|
||||
Disabled="True"
|
||||
Access="Public"
|
||||
Text="{Loc 'medical-scanner-window-save-button-text'}" />
|
||||
<Label Name="Diagnostics" />
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
|
||||
|
||||
namespace Content.Client.MedicalScanner.UI
|
||||
@@ -23,59 +16,7 @@ namespace Content.Client.MedicalScanner.UI
|
||||
|
||||
public void Populate(MedicalScannerBoundUserInterfaceState state)
|
||||
{
|
||||
var text = new StringBuilder();
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!state.Entity.HasValue ||
|
||||
!state.HasDamage() ||
|
||||
!entities.EntityExists(state.Entity.Value))
|
||||
{
|
||||
Diagnostics.Text = Loc.GetString("medical-scanner-window-no-patient-data-text");
|
||||
ScanButton.Disabled = true;
|
||||
SetSize = (250, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", entities.GetComponent<MetaDataComponent>(state.Entity.Value).EntityName))}\n");
|
||||
|
||||
var totalDamage = state.DamagePerType.Values.Sum();
|
||||
|
||||
text.Append($"{Loc.GetString("medical-scanner-window-entity-damage-total-text", ("amount", totalDamage))}\n");
|
||||
|
||||
HashSet<string> shownTypes = new();
|
||||
|
||||
// Show the total damage and type breakdown for each damage group.
|
||||
foreach (var (damageGroupId, damageAmount) in state.DamagePerGroup)
|
||||
{
|
||||
text.Append($"\n{Loc.GetString("medical-scanner-window-damage-group-text", ("damageGroup", damageGroupId), ("amount", damageAmount))}");
|
||||
|
||||
// Show the damage for each type in that group.
|
||||
var group = IoCManager.Resolve<IPrototypeManager>().Index<DamageGroupPrototype>(damageGroupId);
|
||||
foreach (var type in group.DamageTypes)
|
||||
{
|
||||
if (state.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 (!shownTypes.Contains(type))
|
||||
{
|
||||
shownTypes.Add(type);
|
||||
text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-text", ("damageType", type), ("amount", typeAmount))}");
|
||||
}
|
||||
else {
|
||||
text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-duplicate-text", ("damageType", type), ("amount", typeAmount))}");
|
||||
}
|
||||
}
|
||||
}
|
||||
text.Append('\n');
|
||||
}
|
||||
|
||||
Diagnostics.Text = text.ToString();
|
||||
ScanButton.Disabled = state.IsScanned;
|
||||
|
||||
// TODO MEDICALSCANNER resize window based on the length of text / number of damage types?
|
||||
// Also, maybe add color schemes for specific damage groups?
|
||||
SetSize = (250, 600);
|
||||
}
|
||||
ScanButton.Disabled = !state.IsScannable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user