Add 'Scan DNA' function to medical scanner (#1783)
* Add art assets for cloning * Added a 'Scan DNA' button to the medical scanner * Made the UI update unconditional for the medical scanner until checks for power changes are in place * Update Medical scanner to reflect powered status and fix #1774 * added a 'scan dna' button the the medical scanner that will add the contained bodies Uid to a list in CloningSystem, fixed an issue with the menu not populating if the scanner starts in an unpowered state * Add disabling logic to 'Scan DNA' button on medical scanner * Removed un-used libraries * changed scan dna button to Scan and Save DNA
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.Components.Damage;
|
||||
using Content.Shared.GameObjects.Components.Medical;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
@@ -38,9 +39,14 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
_appearance = Owner.GetComponent<AppearanceComponent>();
|
||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
|
||||
.GetBoundUserInterface(MedicalScannerUiKey.Key);
|
||||
_userInterface.OnReceiveMessage += OnUiReceiveMessage;
|
||||
_bodyContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-bodyContainer", Owner);
|
||||
_powerReceiver = Owner.GetComponent<PowerReceiverComponent>();
|
||||
|
||||
//TODO: write this so that it checks for a change in power events and acts accordingly.
|
||||
var newState = GetUserInterfaceState();
|
||||
_userInterface.SetState(newState);
|
||||
|
||||
UpdateUserInterface();
|
||||
}
|
||||
|
||||
@@ -48,7 +54,8 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
new MedicalScannerBoundUserInterfaceState(
|
||||
null,
|
||||
new Dictionary<DamageClass, int>(),
|
||||
new Dictionary<DamageType, int>());
|
||||
new Dictionary<DamageType, int>(),
|
||||
false);
|
||||
|
||||
private MedicalScannerBoundUserInterfaceState GetUserInterfaceState()
|
||||
{
|
||||
@@ -68,7 +75,7 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
var classes = new Dictionary<DamageClass, int>(damageable.DamageClasses);
|
||||
var types = new Dictionary<DamageType, int>(damageable.DamageTypes);
|
||||
|
||||
return new MedicalScannerBoundUserInterfaceState(body.Uid, classes, types);
|
||||
return new MedicalScannerBoundUserInterfaceState(body.Uid, classes, types, CloningSystem.HasUid(body.Uid));
|
||||
}
|
||||
|
||||
private void UpdateUserInterface()
|
||||
@@ -92,12 +99,18 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
default: throw new ArgumentException(nameof(damageState));
|
||||
}
|
||||
}
|
||||
|
||||
private MedicalScannerStatus GetStatus()
|
||||
{
|
||||
var body = _bodyContainer.ContainedEntity;
|
||||
return body == null
|
||||
? MedicalScannerStatus.Open
|
||||
: GetStatusFromDamageState(body.GetComponent<IDamageableComponent>().CurrentDamageState);
|
||||
if (Powered)
|
||||
{
|
||||
var body = _bodyContainer.ContainedEntity;
|
||||
return body == null
|
||||
? MedicalScannerStatus.Open
|
||||
: GetStatusFromDamageState(body.GetComponent<IDamageableComponent>().CurrentDamageState);
|
||||
}
|
||||
|
||||
return MedicalScannerStatus.Off;
|
||||
}
|
||||
|
||||
private void UpdateAppearance()
|
||||
@@ -178,14 +191,28 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
|
||||
public void Update(float frameTime)
|
||||
{
|
||||
if (_bodyContainer.ContainedEntity == null)
|
||||
{
|
||||
// There's no need to update if there's no one inside
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateUserInterface();
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj)
|
||||
{
|
||||
if (!(obj.Message is UiButtonPressedMessage message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (message.Button)
|
||||
{
|
||||
case UiButton.ScanDNA:
|
||||
if (_bodyContainer.ContainedEntity != null)
|
||||
{
|
||||
CloningSystem.AddToScannedUids(_bodyContainer.ContainedEntity.Uid);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user