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:
@@ -317,6 +317,7 @@ namespace Content.Client.Entry
|
||||
"EnergySword",
|
||||
"DoorRemote",
|
||||
"InteractionPopup",
|
||||
"HealthAnalyzer"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
using static Content.Shared.MedicalScanner.SharedHealthAnalyzerComponent;
|
||||
|
||||
namespace Content.Client.HealthAnalyzer.UI
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class HealthAnalyzerBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private HealthAnalyzerWindow? _window;
|
||||
|
||||
public HealthAnalyzerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_window = new HealthAnalyzerWindow
|
||||
{
|
||||
Title = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Owner).EntityName,
|
||||
};
|
||||
_window.OnClose += Close;
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
||||
{
|
||||
if (_window == null)
|
||||
return;
|
||||
|
||||
if (message is not HealthAnalyzerScannedUserMessage cast)
|
||||
return;
|
||||
|
||||
_window.Populate(cast);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
if (_window != null)
|
||||
_window.OnClose -= Close;
|
||||
|
||||
_window?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<DefaultWindow xmlns="https://spacestation14.io"
|
||||
MinSize="250 100"
|
||||
SetSize="250 100">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<Label
|
||||
Name="Diagnostics"
|
||||
Text="{Loc health-analyzer-window-no-patient-data-text}"/>
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Text;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.Damage;
|
||||
|
||||
using static Content.Shared.MedicalScanner.SharedHealthAnalyzerComponent;
|
||||
|
||||
namespace Content.Client.HealthAnalyzer.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class HealthAnalyzerWindow : DefaultWindow
|
||||
{
|
||||
public HealthAnalyzerWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void Populate(HealthAnalyzerScannedUserMessage msg)
|
||||
{
|
||||
var text = new StringBuilder();
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (msg.TargetEntity != null && entities.TryGetComponent<DamageableComponent>(msg.TargetEntity, out var damageable))
|
||||
{
|
||||
string entityName = "Unknown";
|
||||
if (msg.TargetEntity != null && entities.TryGetComponent<MetaDataComponent>(msg.TargetEntity.Value, out var metaData))
|
||||
entityName = metaData.EntityName;
|
||||
|
||||
IReadOnlyDictionary<string, FixedPoint2> DamagePerGroup = damageable.DamagePerGroup;
|
||||
IReadOnlyDictionary<string, FixedPoint2> DamagePerType = damageable.Damage.DamageDict;
|
||||
|
||||
text.Append($"{Loc.GetString("health-analyzer-window-entity-health-text", ("entityName", entityName))}\n");
|
||||
|
||||
text.Append($"{Loc.GetString("health-analyzer-window-entity-damage-total-text", ("amount", damageable.TotalDamage))}\n");
|
||||
|
||||
HashSet<string> shownTypes = new();
|
||||
|
||||
var protos = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
// Show the total damage and type breakdown for each damage group.
|
||||
foreach (var (damageGroupId, damageAmount) in DamagePerGroup)
|
||||
{
|
||||
text.Append($"\n{Loc.GetString("health-analyzer-window-damage-group-text", ("damageGroup", damageGroupId), ("amount", damageAmount))}");
|
||||
// Show the damage for each type in that group.
|
||||
var group = protos.Index<DamageGroupPrototype>(damageGroupId);
|
||||
foreach (var type in group.DamageTypes)
|
||||
{
|
||||
if (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("health-analyzer-window-damage-type-text", ("damageType", type), ("amount", typeAmount))}");
|
||||
}
|
||||
}
|
||||
}
|
||||
text.AppendLine();
|
||||
}
|
||||
Diagnostics.Text = text.ToString();
|
||||
SetSize = (250, 600);
|
||||
}
|
||||
else
|
||||
{
|
||||
Diagnostics.Text = Loc.GetString("health-analyzer-window-no-patient-data-text");
|
||||
SetSize = (250, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
</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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
27
Content.Server/Medical/Components/HealthAnalyzerComponent.cs
Normal file
27
Content.Server/Medical/Components/HealthAnalyzerComponent.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Threading;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.MedicalScanner;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.Medical.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// After scanning, retrieves the target Uid to use with its related UI.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedHealthAnalyzerComponent))]
|
||||
public sealed class HealthAnalyzerComponent : SharedHealthAnalyzerComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// How long it takes to scan someone.
|
||||
/// </summary>
|
||||
[DataField("scanDelay")]
|
||||
[ViewVariables]
|
||||
public float ScanDelay = 0.8f;
|
||||
/// <summary>
|
||||
/// Token for interrupting scanning do after.
|
||||
/// </summary>
|
||||
public CancellationTokenSource? CancelToken;
|
||||
public BoundUserInterface? UserInterface => Owner.GetUIOrNull(HealthAnalyzerUiKey.Key);
|
||||
}
|
||||
}
|
||||
@@ -1,249 +1,22 @@
|
||||
using System;
|
||||
using Content.Server.Climbing;
|
||||
using Content.Server.Cloning;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.MedicalScanner;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Preferences;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Medical.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
[ComponentReference(typeof(SharedMedicalScannerComponent))]
|
||||
public sealed class MedicalScannerComponent : SharedMedicalScannerComponent, IActivate, IDestroyAct
|
||||
public sealed class MedicalScannerComponent : SharedMedicalScannerComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IServerPreferencesManager _prefsManager = null!;
|
||||
|
||||
public static readonly TimeSpan InternalOpenAttemptDelay = TimeSpan.FromSeconds(0.5);
|
||||
public TimeSpan LastInternalOpenAttempt;
|
||||
|
||||
private ContainerSlot _bodyContainer = default!;
|
||||
|
||||
[ViewVariables]
|
||||
private bool Powered => !_entMan.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||
[ViewVariables]
|
||||
private BoundUserInterface? UserInterface => Owner.GetUIOrNull(MedicalScannerUiKey.Key);
|
||||
|
||||
public bool IsOccupied => _bodyContainer.ContainedEntity != null;
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (UserInterface != null)
|
||||
{
|
||||
UserInterface.OnReceiveMessage += OnUiReceiveMessage;
|
||||
}
|
||||
|
||||
_bodyContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-bodyContainer");
|
||||
|
||||
// TODO: write this so that it checks for a change in power events and acts accordingly.
|
||||
var newState = GetUserInterfaceState();
|
||||
UserInterface?.SetState(newState);
|
||||
|
||||
UpdateUserInterface();
|
||||
}
|
||||
|
||||
private static readonly MedicalScannerBoundUserInterfaceState EmptyUIState =
|
||||
new(
|
||||
null,
|
||||
null,
|
||||
false);
|
||||
|
||||
private MedicalScannerBoundUserInterfaceState GetUserInterfaceState()
|
||||
{
|
||||
var body = _bodyContainer.ContainedEntity;
|
||||
if (body == null)
|
||||
{
|
||||
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance?.SetData(MedicalScannerVisuals.Status, MedicalScannerStatus.Open);
|
||||
}
|
||||
|
||||
return EmptyUIState;
|
||||
}
|
||||
|
||||
if (!_entMan.TryGetComponent(body.Value, out DamageableComponent? damageable))
|
||||
{
|
||||
return EmptyUIState;
|
||||
}
|
||||
|
||||
if (_bodyContainer.ContainedEntity == null)
|
||||
{
|
||||
return new MedicalScannerBoundUserInterfaceState(body, damageable, true);
|
||||
}
|
||||
|
||||
var cloningSystem = EntitySystem.Get<CloningSystem>();
|
||||
var scanned = _entMan.TryGetComponent(_bodyContainer.ContainedEntity.Value, out MindComponent? mindComponent) &&
|
||||
mindComponent.Mind != null &&
|
||||
cloningSystem.HasDnaScan(mindComponent.Mind);
|
||||
|
||||
return new MedicalScannerBoundUserInterfaceState(body, damageable, scanned);
|
||||
}
|
||||
|
||||
private void UpdateUserInterface()
|
||||
{
|
||||
if (!Powered)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var newState = GetUserInterfaceState();
|
||||
UserInterface?.SetState(newState);
|
||||
}
|
||||
|
||||
private MedicalScannerStatus GetStatusFromDamageState(MobStateComponent state)
|
||||
{
|
||||
if (state.IsAlive())
|
||||
{
|
||||
return MedicalScannerStatus.Green;
|
||||
}
|
||||
else if (state.IsCritical())
|
||||
{
|
||||
return MedicalScannerStatus.Red;
|
||||
}
|
||||
else if (state.IsDead())
|
||||
{
|
||||
return MedicalScannerStatus.Death;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MedicalScannerStatus.Yellow;
|
||||
}
|
||||
}
|
||||
|
||||
private MedicalScannerStatus GetStatus()
|
||||
{
|
||||
if (Powered)
|
||||
{
|
||||
var body = _bodyContainer.ContainedEntity;
|
||||
if (body == null)
|
||||
return MedicalScannerStatus.Open;
|
||||
|
||||
var state = _entMan.GetComponentOrNull<MobStateComponent>(body.Value);
|
||||
|
||||
return state == null ? MedicalScannerStatus.Open : GetStatusFromDamageState(state);
|
||||
}
|
||||
|
||||
return MedicalScannerStatus.Off;
|
||||
}
|
||||
|
||||
private void UpdateAppearance()
|
||||
{
|
||||
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(MedicalScannerVisuals.Status, GetStatus());
|
||||
}
|
||||
}
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs args)
|
||||
{
|
||||
if (!_entMan.TryGetComponent(args.User, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Powered)
|
||||
return;
|
||||
|
||||
UserInterface?.Open(actor.PlayerSession);
|
||||
}
|
||||
|
||||
public void InsertBody(EntityUid user)
|
||||
{
|
||||
_bodyContainer.Insert(user);
|
||||
UpdateUserInterface();
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
public void EjectBody()
|
||||
{
|
||||
if (_bodyContainer.ContainedEntity is not {Valid: true} contained) return;
|
||||
_bodyContainer.Remove(contained);
|
||||
UpdateUserInterface();
|
||||
UpdateAppearance();
|
||||
EntitySystem.Get<ClimbSystem>().ForciblySetClimbing(contained);
|
||||
}
|
||||
|
||||
public void Update(float frameTime)
|
||||
{
|
||||
UpdateUserInterface();
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj)
|
||||
{
|
||||
if (obj.Message is not UiButtonPressedMessage message || obj.Session.AttachedEntity == null) return;
|
||||
|
||||
switch (message.Button)
|
||||
{
|
||||
case UiButton.ScanDNA:
|
||||
if (_bodyContainer.ContainedEntity != null)
|
||||
{
|
||||
var cloningSystem = EntitySystem.Get<CloningSystem>();
|
||||
|
||||
if (!_entMan.TryGetComponent(_bodyContainer.ContainedEntity.Value, out MindComponent? mindComp) || mindComp.Mind == null)
|
||||
{
|
||||
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-no-soul"));
|
||||
break;
|
||||
}
|
||||
|
||||
// Null suppression based on above check. Yes, it's explicitly needed
|
||||
var mind = mindComp.Mind!;
|
||||
|
||||
// We need the HumanoidCharacterProfile
|
||||
// TODO: Move this further 'outwards' into a DNAComponent or somesuch.
|
||||
// Ideally this ends with GameTicker & CloningSystem handing DNA to a function that sets up a body for that DNA.
|
||||
var mindUser = mind.UserId;
|
||||
|
||||
if (mindUser.HasValue == false || mind.Session == null)
|
||||
{
|
||||
// For now assume this means soul departed
|
||||
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-soul-broken"));
|
||||
break;
|
||||
}
|
||||
|
||||
var profile = GetPlayerProfileAsync(mindUser.Value);
|
||||
cloningSystem.AddToDnaScans(new ClonerDNAEntry(mind, profile));
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
public ContainerSlot BodyContainer = default!;
|
||||
public BoundUserInterface? UserInterface => Owner.GetUIOrNull(MedicalScannerUiKey.Key);
|
||||
|
||||
// ECS this out!, when DragDropSystem and InteractionSystem refactored
|
||||
public override bool DragDropOn(DragDropEvent eventArgs)
|
||||
{
|
||||
_bodyContainer.Insert(eventArgs.Dragged);
|
||||
return true;
|
||||
}
|
||||
|
||||
void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs)
|
||||
{
|
||||
EjectBody();
|
||||
}
|
||||
|
||||
private HumanoidCharacterProfile GetPlayerProfileAsync(NetUserId userId)
|
||||
{
|
||||
return (HumanoidCharacterProfile) _prefsManager.GetPreferences(userId).SelectedCharacter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
120
Content.Server/Medical/HealthAnalyzerSystem.cs
Normal file
120
Content.Server/Medical/HealthAnalyzerSystem.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using System.Threading;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Medical.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using static Content.Shared.MedicalScanner.SharedHealthAnalyzerComponent;
|
||||
|
||||
namespace Content.Server.Medical
|
||||
{
|
||||
public sealed class HealthAnalyzerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<HealthAnalyzerComponent, ActivateInWorldEvent>(HandleActivateInWorld);
|
||||
SubscribeLocalEvent<HealthAnalyzerComponent, AfterInteractEvent>(OnAfterInteract);
|
||||
SubscribeLocalEvent<TargetScanSuccessfulEvent>(OnTargetScanSuccessful);
|
||||
SubscribeLocalEvent<ScanCancelledEvent>(OnScanCancelled);
|
||||
}
|
||||
|
||||
private void HandleActivateInWorld(EntityUid uid, HealthAnalyzerComponent healthAnalyzer, ActivateInWorldEvent args)
|
||||
{
|
||||
OpenUserInterface(args.User, healthAnalyzer);
|
||||
}
|
||||
|
||||
private void OnAfterInteract(EntityUid uid, HealthAnalyzerComponent healthAnalyzer, AfterInteractEvent args)
|
||||
{
|
||||
if (healthAnalyzer.CancelToken != null)
|
||||
{
|
||||
healthAnalyzer.CancelToken.Cancel();
|
||||
healthAnalyzer.CancelToken = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Target == null)
|
||||
return;
|
||||
|
||||
if (!args.CanReach)
|
||||
return;
|
||||
|
||||
if (healthAnalyzer.CancelToken != null)
|
||||
return;
|
||||
|
||||
if (!HasComp<MobStateComponent>(args.Target))
|
||||
return;
|
||||
|
||||
healthAnalyzer.CancelToken = new CancellationTokenSource();
|
||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(args.User, healthAnalyzer.ScanDelay, healthAnalyzer.CancelToken.Token, target: args.Target)
|
||||
{
|
||||
BroadcastFinishedEvent = new TargetScanSuccessfulEvent(args.User, args.Target, healthAnalyzer),
|
||||
BroadcastCancelledEvent = new ScanCancelledEvent(healthAnalyzer),
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
BreakOnStun = true,
|
||||
NeedHand = true
|
||||
});
|
||||
}
|
||||
|
||||
private void OnTargetScanSuccessful(TargetScanSuccessfulEvent args)
|
||||
{
|
||||
args.Component.CancelToken = null;
|
||||
UpdateScannedUser(args.Component.Owner, args.User, args.Target, args.Component);
|
||||
}
|
||||
|
||||
private void OpenUserInterface(EntityUid user, HealthAnalyzerComponent healthAnalyzer)
|
||||
{
|
||||
if (!TryComp<ActorComponent>(user, out var actor))
|
||||
return;
|
||||
|
||||
healthAnalyzer.UserInterface?.Open(actor.PlayerSession);
|
||||
}
|
||||
|
||||
public void UpdateScannedUser(EntityUid uid, EntityUid user, EntityUid? target, HealthAnalyzerComponent? healthAnalyzer)
|
||||
{
|
||||
if (!Resolve(uid, ref healthAnalyzer))
|
||||
return;
|
||||
|
||||
if (target == null || healthAnalyzer.UserInterface == null)
|
||||
return;
|
||||
|
||||
if (!HasComp<DamageableComponent>(target))
|
||||
return;
|
||||
|
||||
OpenUserInterface(user, healthAnalyzer);
|
||||
healthAnalyzer.UserInterface?.SendMessage(new HealthAnalyzerScannedUserMessage(target));
|
||||
}
|
||||
|
||||
private static void OnScanCancelled(ScanCancelledEvent args)
|
||||
{
|
||||
args.HealthAnalyzer.CancelToken = null;
|
||||
}
|
||||
|
||||
private sealed class ScanCancelledEvent : EntityEventArgs
|
||||
{
|
||||
public readonly HealthAnalyzerComponent HealthAnalyzer;
|
||||
public ScanCancelledEvent(HealthAnalyzerComponent healthAnalyzer)
|
||||
{
|
||||
HealthAnalyzer = healthAnalyzer;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class TargetScanSuccessfulEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid User { get; }
|
||||
public EntityUid? Target { get; }
|
||||
public HealthAnalyzerComponent Component { get; }
|
||||
|
||||
public TargetScanSuccessfulEvent(EntityUid user, EntityUid? target, HealthAnalyzerComponent component)
|
||||
{
|
||||
User = user;
|
||||
Target = target;
|
||||
Component = component;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,77 @@
|
||||
using Content.Server.Climbing;
|
||||
using Content.Server.Cloning;
|
||||
using Content.Server.Medical.Components;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.CharacterAppearance.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Movement;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Verbs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
|
||||
|
||||
namespace Content.Server.Medical
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class MedicalScannerSystem : EntitySystem
|
||||
public sealed class MedicalScannerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IServerPreferencesManager _prefsManager = null!;
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly ClimbSystem _climbSystem = default!;
|
||||
[Dependency] private readonly CloningSystem _cloningSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
|
||||
private const float UpdateRate = 1f;
|
||||
private float _updateDif;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<MedicalScannerComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, ActivateInWorldEvent>(OnActivated);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, RelayMovementEntityEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<InteractionVerb>>(AddInsertOtherVerb);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<AlternativeVerb>>(AddAlternativeVerbs);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, DestructionEventArgs>(OnDestroyed);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, DragDropEvent>(HandleDragDropOn);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, ScanButtonPressedMessage>(OnScanButtonPressed);
|
||||
}
|
||||
|
||||
private void OnComponentInit(EntityUid uid, MedicalScannerComponent scannerComponent, ComponentInit args)
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
scannerComponent.BodyContainer = scannerComponent.Owner.EnsureContainer<ContainerSlot>($"{scannerComponent.Name}-bodyContainer");
|
||||
UpdateUserInterface(uid, scannerComponent);
|
||||
}
|
||||
|
||||
private void OnActivated(EntityUid uid, MedicalScannerComponent scannerComponent, ActivateInWorldEvent args)
|
||||
{
|
||||
if (!TryComp<ActorComponent>(args.User, out var actor) || !IsPowered(scannerComponent))
|
||||
return;
|
||||
|
||||
scannerComponent.UserInterface?.Toggle(actor.PlayerSession);
|
||||
UpdateUserInterface(uid, scannerComponent);
|
||||
}
|
||||
|
||||
private void OnRelayMovement(EntityUid uid, MedicalScannerComponent scannerComponent, RelayMovementEntityEvent args)
|
||||
{
|
||||
if (!_blocker.CanInteract(args.Entity, scannerComponent.Owner))
|
||||
return;
|
||||
|
||||
EjectBody(uid, scannerComponent);
|
||||
}
|
||||
|
||||
private void AddInsertOtherVerb(EntityUid uid, MedicalScannerComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||
@@ -31,14 +79,20 @@ namespace Content.Server.Medical
|
||||
if (args.Using == null ||
|
||||
!args.CanAccess ||
|
||||
!args.CanInteract ||
|
||||
component.IsOccupied ||
|
||||
IsOccupied(component) ||
|
||||
!component.CanInsert(args.Using.Value))
|
||||
return;
|
||||
|
||||
InteractionVerb verb = new();
|
||||
verb.Act = () => component.InsertBody(args.Using.Value);
|
||||
verb.Category = VerbCategory.Insert;
|
||||
verb.Text = EntityManager.GetComponent<MetaDataComponent>(args.Using.Value).EntityName;
|
||||
string name = "Unknown";
|
||||
if (TryComp<MetaDataComponent>(args.Using.Value, out var metadata))
|
||||
name = metadata.EntityName;
|
||||
|
||||
InteractionVerb verb = new()
|
||||
{
|
||||
Act = () => InsertBody(component.Owner, args.Target, component),
|
||||
Category = VerbCategory.Insert,
|
||||
Text = name
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
@@ -48,52 +102,226 @@ namespace Content.Server.Medical
|
||||
return;
|
||||
|
||||
// Eject verb
|
||||
if (component.IsOccupied)
|
||||
if (IsOccupied(component))
|
||||
{
|
||||
AlternativeVerb verb = new();
|
||||
verb.Act = () => component.EjectBody();
|
||||
verb.Act = () => EjectBody(uid, component);
|
||||
verb.Category = VerbCategory.Eject;
|
||||
verb.Text = Loc.GetString("medical-scanner-verb-noun-occupant");
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
// Self-insert verb
|
||||
if (!component.IsOccupied &&
|
||||
if (!IsOccupied(component) &&
|
||||
component.CanInsert(args.User) &&
|
||||
_actionBlockerSystem.CanMove(args.User))
|
||||
_blocker.CanMove(args.User))
|
||||
{
|
||||
AlternativeVerb verb = new();
|
||||
verb.Act = () => component.InsertBody(args.User);
|
||||
verb.Act = () => InsertBody(component.Owner, args.User, component);
|
||||
verb.Text = Loc.GetString("medical-scanner-verb-enter");
|
||||
// TODO VERN ICON
|
||||
// TODO VERB CATEGORY
|
||||
// create a verb category for "enter"?
|
||||
// See also, disposal unit. Also maybe add verbs for entering lockers/body bags?
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRelayMovement(EntityUid uid, MedicalScannerComponent component, RelayMovementEntityEvent args)
|
||||
private void OnDestroyed(EntityUid uid, MedicalScannerComponent scannerComponent, DestructionEventArgs args)
|
||||
{
|
||||
if (_blocker.CanInteract(args.Entity, null))
|
||||
EjectBody(uid, scannerComponent);
|
||||
}
|
||||
|
||||
private void HandleDragDropOn(EntityUid uid, MedicalScannerComponent scannerComponent, DragDropEvent args)
|
||||
{
|
||||
if (_gameTiming.CurTime <
|
||||
component.LastInternalOpenAttempt + MedicalScannerComponent.InternalOpenAttemptDelay)
|
||||
InsertBody(uid, args.Dragged, scannerComponent);
|
||||
}
|
||||
|
||||
private void OnScanButtonPressed(EntityUid uid, MedicalScannerComponent scannerComponent, ScanButtonPressedMessage args)
|
||||
{
|
||||
TrySaveCloningData(uid, scannerComponent);
|
||||
}
|
||||
|
||||
private static readonly MedicalScannerBoundUserInterfaceState EmptyUIState =
|
||||
new(false);
|
||||
|
||||
private MedicalScannerBoundUserInterfaceState GetUserInterfaceState(EntityUid uid, MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
EntityUid? containedBody = scannerComponent.BodyContainer.ContainedEntity;
|
||||
|
||||
if (containedBody == null)
|
||||
{
|
||||
UpdateAppearance(uid, scannerComponent);
|
||||
return EmptyUIState;
|
||||
}
|
||||
|
||||
if (!HasComp<DamageableComponent>(containedBody))
|
||||
return EmptyUIState;
|
||||
|
||||
if (!HasComp<HumanoidAppearanceComponent>(containedBody))
|
||||
return EmptyUIState;
|
||||
|
||||
if (!TryComp<MindComponent>(containedBody, out var mindComponent) || mindComponent.Mind == null)
|
||||
return EmptyUIState;
|
||||
|
||||
bool isScanned = _cloningSystem.HasDnaScan(mindComponent.Mind);
|
||||
|
||||
return new MedicalScannerBoundUserInterfaceState(!isScanned);
|
||||
}
|
||||
|
||||
private void UpdateUserInterface(EntityUid uid, MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
if (!IsPowered(scannerComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
component.LastInternalOpenAttempt = _gameTiming.CurTime;
|
||||
component.EjectBody();
|
||||
var newState = GetUserInterfaceState(uid, scannerComponent);
|
||||
scannerComponent.UserInterface?.SetState(newState);
|
||||
}
|
||||
|
||||
private MedicalScannerStatus GetStatus(MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
if (IsPowered(scannerComponent))
|
||||
{
|
||||
var body = scannerComponent.BodyContainer.ContainedEntity;
|
||||
if (body == null)
|
||||
return MedicalScannerStatus.Open;
|
||||
|
||||
if (!TryComp<MobStateComponent>(body.Value, out var state))
|
||||
{
|
||||
return MedicalScannerStatus.Open;
|
||||
}
|
||||
|
||||
return GetStatusFromDamageState(state);
|
||||
}
|
||||
return MedicalScannerStatus.Off;
|
||||
}
|
||||
|
||||
public bool IsPowered(MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
if (TryComp<ApcPowerReceiverComponent>(scannerComponent.Owner, out var receiver))
|
||||
{
|
||||
return receiver.Powered;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsOccupied(MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
return scannerComponent.BodyContainer.ContainedEntity != null;
|
||||
}
|
||||
|
||||
private MedicalScannerStatus GetStatusFromDamageState(MobStateComponent state)
|
||||
{
|
||||
if (state.IsAlive())
|
||||
return MedicalScannerStatus.Green;
|
||||
|
||||
if (state.IsCritical())
|
||||
return MedicalScannerStatus.Red;
|
||||
|
||||
if (state.IsDead())
|
||||
return MedicalScannerStatus.Death;
|
||||
|
||||
return MedicalScannerStatus.Yellow;
|
||||
}
|
||||
|
||||
private void UpdateAppearance(EntityUid uid, MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
if (TryComp<AppearanceComponent>(scannerComponent.Owner, out var appearance))
|
||||
{
|
||||
appearance.SetData(MedicalScannerVisuals.Status, GetStatus(scannerComponent));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var comp in EntityManager.EntityQuery<MedicalScannerComponent>())
|
||||
base.Update(frameTime);
|
||||
|
||||
_updateDif += frameTime;
|
||||
if (_updateDif < UpdateRate)
|
||||
return;
|
||||
|
||||
_updateDif -= UpdateRate;
|
||||
|
||||
foreach (var scanner in EntityQuery<MedicalScannerComponent>())
|
||||
{
|
||||
comp.Update(frameTime);
|
||||
}
|
||||
UpdateAppearance(scanner.Owner, scanner);
|
||||
}
|
||||
}
|
||||
|
||||
public void InsertBody(EntityUid uid, EntityUid user, MedicalScannerComponent? scannerComponent)
|
||||
{
|
||||
if (!Resolve(uid, ref scannerComponent))
|
||||
return;
|
||||
|
||||
if (scannerComponent.BodyContainer.ContainedEntity != null)
|
||||
return;
|
||||
|
||||
if (!TryComp<MobStateComponent>(user, out var comp))
|
||||
return;
|
||||
|
||||
scannerComponent.BodyContainer.Insert(user);
|
||||
UpdateUserInterface(uid, scannerComponent);
|
||||
UpdateAppearance(scannerComponent.Owner, scannerComponent);
|
||||
}
|
||||
|
||||
public void EjectBody(EntityUid uid, MedicalScannerComponent? scannerComponent)
|
||||
{
|
||||
if (!Resolve(uid, ref scannerComponent))
|
||||
return;
|
||||
|
||||
if (scannerComponent.BodyContainer.ContainedEntity is not {Valid: true} contained) return;
|
||||
|
||||
scannerComponent.BodyContainer.Remove(contained);
|
||||
_climbSystem.ForciblySetClimbing(contained);
|
||||
UpdateUserInterface(uid, scannerComponent);
|
||||
UpdateAppearance(scannerComponent.Owner, scannerComponent);
|
||||
}
|
||||
|
||||
public void TrySaveCloningData(EntityUid uid, MedicalScannerComponent? scannerComponent)
|
||||
{
|
||||
if (!Resolve(uid, ref scannerComponent))
|
||||
return;
|
||||
|
||||
EntityUid? body = scannerComponent.BodyContainer.ContainedEntity;
|
||||
|
||||
if (body == null)
|
||||
return;
|
||||
|
||||
// Check to see if they are humanoid
|
||||
if (!TryComp<HumanoidAppearanceComponent>(body, out var humanoid))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("medical-scanner-component-msg-no-humanoid-component"), uid, Filter.Pvs(uid));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryComp<MindComponent>(body, out var mindComp) || mindComp.Mind == null)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("medical-scanner-component-msg-no-soul"), uid, Filter.Pvs(uid));
|
||||
return;
|
||||
}
|
||||
|
||||
// Null suppression based on above check. Yes, it's explicitly needed
|
||||
var mind = mindComp.Mind;
|
||||
// We need the HumanoidCharacterProfile
|
||||
// TODO: Move this further 'outwards' into a DNAComponent or somesuch.
|
||||
// Ideally this ends with GameTicker & CloningSystem handing DNA to a function that sets up a body for that DNA.
|
||||
var mindUser = mind.UserId;
|
||||
|
||||
if (mindUser.HasValue == false || mind.Session == null)
|
||||
{
|
||||
// For now assume this means soul departed
|
||||
_popupSystem.PopupEntity(Loc.GetString("medical-scanner-component-msg-soul-broken"), uid, Filter.Pvs(uid));
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO get synchronously
|
||||
// This must be changed to grab the details of the mob itself, not session preferences
|
||||
var profile = GetPlayerProfileAsync(mindUser.Value);
|
||||
_cloningSystem.AddToDnaScans(new ClonerDNAEntry(mind, profile));
|
||||
UpdateUserInterface(uid, scannerComponent);
|
||||
}
|
||||
|
||||
private HumanoidCharacterProfile GetPlayerProfileAsync(NetUserId userId)
|
||||
{
|
||||
return (HumanoidCharacterProfile) _prefsManager.GetPreferences(userId).SelectedCharacter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.MedicalScanner
|
||||
{
|
||||
public abstract class SharedHealthAnalyzerComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// On interacting with an entity retrieves the entity UID for use with getting the current damage of the mob.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class HealthAnalyzerScannedUserMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly EntityUid? TargetEntity;
|
||||
|
||||
public HealthAnalyzerScannedUserMessage(EntityUid? targetEntity)
|
||||
{
|
||||
TargetEntity = targetEntity;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum HealthAnalyzerUiKey : byte
|
||||
{
|
||||
Key
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.MedicalScanner
|
||||
@@ -15,25 +9,11 @@ namespace Content.Shared.MedicalScanner
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MedicalScannerBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public readonly EntityUid? Entity;
|
||||
public readonly IReadOnlyDictionary<string, FixedPoint2> DamagePerGroup;
|
||||
public readonly IReadOnlyDictionary<string, FixedPoint2> DamagePerType;
|
||||
public readonly bool IsScanned;
|
||||
public readonly bool IsScannable;
|
||||
|
||||
public MedicalScannerBoundUserInterfaceState(
|
||||
EntityUid? entity,
|
||||
DamageableComponent? damageable,
|
||||
bool isScanned)
|
||||
public MedicalScannerBoundUserInterfaceState(bool isScannable)
|
||||
{
|
||||
Entity = entity;
|
||||
DamagePerGroup = damageable?.DamagePerGroup ?? new();
|
||||
DamagePerType = damageable?.Damage?.DamageDict ?? new();
|
||||
IsScanned = isScanned;
|
||||
}
|
||||
|
||||
public bool HasDamage()
|
||||
{
|
||||
return DamagePerType.Count > 0;
|
||||
IsScannable = isScannable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,20 +41,8 @@ namespace Content.Shared.MedicalScanner
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum UiButton
|
||||
public sealed class ScanButtonPressedMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
ScanDNA,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class UiButtonPressedMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly UiButton Button;
|
||||
|
||||
public UiButtonPressedMessage(UiButton button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanInsert(EntityUid entity)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
health-analyzer-window-no-patient-data-text = No patient data.
|
||||
health-analyzer-window-entity-health-text = {$entityName}'s health:
|
||||
health-analyzer-window-entity-damage-total-text = Total Damage: {$amount}
|
||||
health-analyzer-window-damage-group-text = {$damageGroup}: {$amount}
|
||||
health-analyzer-window-damage-type-text = {$damageType}: {$amount}
|
||||
health-analyzer-window-damage-type-duplicate-text = {$damageType}: {$amount} (duplicate)
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
medical-scanner-component-msg-no-soul = ERROR: Body is completely devoid of soul
|
||||
medical-scanner-component-msg-soul-broken = ERROR: Soul present, but defunct / departed
|
||||
medical-scanner-component-msg-no-humanoid-component = ERROR: Body is incompatible
|
||||
|
||||
## EnterVerb
|
||||
|
||||
@@ -11,9 +12,3 @@ medical-scanner-verb-noun-occupant = occupant
|
||||
## UI
|
||||
|
||||
medical-scanner-window-save-button-text = Scan and Save DNA
|
||||
medical-scanner-window-no-patient-data-text = No patient data.
|
||||
medical-scanner-window-entity-health-text = {$entityName}'s health:
|
||||
medical-scanner-window-entity-damage-total-text = Total Damage: {$amount}
|
||||
medical-scanner-window-damage-group-text = {$damageGroup}: {$amount}
|
||||
medical-scanner-window-damage-type-text = {$damageType}: {$amount}
|
||||
medical-scanner-window-damage-type-duplicate-text = {$damageType}: {$amount} (duplicate)
|
||||
|
||||
@@ -23,23 +23,20 @@
|
||||
components:
|
||||
- type: StorageFill
|
||||
contents:
|
||||
- id: HandheldHealthAnalyzer
|
||||
- id: ClothingHandsGlovesLatex
|
||||
prob: 1
|
||||
- id: ClothingHeadsetMedical
|
||||
prob: 1
|
||||
# - id: ClothingEyesHudMedical #Removed until working properly
|
||||
# prob: 1
|
||||
- id: ClothingBeltMedical
|
||||
prob: 1
|
||||
- id: ClothingHeadHatSurgcapBlue
|
||||
prob: 1
|
||||
orGroup: Surgcaps
|
||||
- id: ClothingHeadHatSurgcapGreen
|
||||
prob: 0.1
|
||||
orGroup: Surgcaps
|
||||
- id: ClothingHeadHatSurgcapPurple
|
||||
prob: 0.05
|
||||
orGroup: Surgcaps
|
||||
- id: ClothingHeadHatSurgcapBlue
|
||||
prob: 0.90
|
||||
orGroup: Surgcaps
|
||||
- id: UniformScrubsColorBlue
|
||||
prob: 0.5
|
||||
orGroup: Surgshrubs
|
||||
@@ -50,7 +47,6 @@
|
||||
prob: 0.05
|
||||
orGroup: Surgshrubs
|
||||
- id: ClothingMaskSterile
|
||||
prob: 1
|
||||
|
||||
- type: entity
|
||||
id: LockerChemistryFilled
|
||||
@@ -60,8 +56,5 @@
|
||||
- type: StorageFill
|
||||
contents:
|
||||
- id: BoxSyringe
|
||||
prob: 1
|
||||
- id: BoxBeaker
|
||||
prob: 1
|
||||
- id: BoxPillCanister
|
||||
prob: 1
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
animationDuration: 1.8
|
||||
spriteName: medical
|
||||
startingInventory:
|
||||
HandheldHealthAnalyzer: 4
|
||||
Brutepack: 5
|
||||
Ointment: 5
|
||||
EpinephrineChemistryBottle: 3
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
- type: entity
|
||||
name: health analyzer
|
||||
parent: BaseItem
|
||||
id: HandheldHealthAnalyzer
|
||||
description: A hand-held body scanner capable of distinguishing vital signs of the subject.
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Specific/Medical/healthanalyzer.rsi
|
||||
netsync: false
|
||||
state: analyzer
|
||||
- type: ActivatableUI
|
||||
key: enum.HealthAnalyzerUiKey.Key
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.HealthAnalyzerUiKey.Key
|
||||
type: HealthAnalyzerBoundUserInterface
|
||||
- type: HealthAnalyzer
|
||||
@@ -65,6 +65,7 @@
|
||||
- Spade
|
||||
- CableStack
|
||||
- HandheldGPSBasic
|
||||
- HandheldHealthAnalyzer
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: AutolatheVisualizer
|
||||
|
||||
@@ -64,3 +64,12 @@
|
||||
Glass: 1200
|
||||
Steel: 1000
|
||||
Plastic: 1400
|
||||
|
||||
- type: latheRecipe
|
||||
id: HandheldHealthAnalyzer
|
||||
icon: Objects/Specific/Medical/healthanalyzer.rsi/icon.png
|
||||
result: HandheldHealthAnalyzer
|
||||
completetime: 1000
|
||||
materials:
|
||||
Glass: 500
|
||||
Steel: 500
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/f07f847706d85b7cfa4b398e5175732212b69a63",
|
||||
"states": [
|
||||
{
|
||||
"name": "analyzer",
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.5
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "icon"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user