Resolves MedicalScannerVisualizer is Obsolete (#13893)
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
using Content.Shared.MedicalScanner;
|
using Content.Shared.MedicalScanner;
|
||||||
|
|
||||||
namespace Content.Client.MedicalScanner
|
namespace Content.Client.MedicalScanner;
|
||||||
|
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class MedicalScannerComponent : SharedMedicalScannerComponent
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
|
||||||
public sealed class MedicalScannerComponent : SharedMedicalScannerComponent
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
using System;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Client.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
|
|
||||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent.MedicalScannerStatus;
|
|
||||||
|
|
||||||
namespace Content.Client.MedicalScanner
|
|
||||||
{
|
|
||||||
[UsedImplicitly]
|
|
||||||
public sealed class MedicalScannerVisualizer : AppearanceVisualizer
|
|
||||||
{
|
|
||||||
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
|
||||||
public override void OnChangeData(AppearanceComponent component)
|
|
||||||
{
|
|
||||||
base.OnChangeData(component);
|
|
||||||
|
|
||||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(component.Owner);
|
|
||||||
if (!component.TryGetData(MedicalScannerVisuals.Status, out MedicalScannerStatus status)) return;
|
|
||||||
sprite.LayerSetState(MedicalScannerVisualLayers.Machine, StatusToMachineStateId(status));
|
|
||||||
sprite.LayerSetState(MedicalScannerVisualLayers.Terminal, StatusToTerminalStateId(status));
|
|
||||||
}
|
|
||||||
|
|
||||||
private string StatusToMachineStateId(MedicalScannerStatus status)
|
|
||||||
{
|
|
||||||
switch (status)
|
|
||||||
{
|
|
||||||
case Off: return "closed";
|
|
||||||
case Open: return "open";
|
|
||||||
case Red: return "occupied";
|
|
||||||
case Death: return "occupied";
|
|
||||||
case Green: return "occupied";
|
|
||||||
case Yellow: return "occupied";
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(status), status, "unknown MedicalScannerStatus");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string StatusToTerminalStateId(MedicalScannerStatus status)
|
|
||||||
{
|
|
||||||
switch (status)
|
|
||||||
{
|
|
||||||
case Off: return "off_unlit";
|
|
||||||
case Open: return "idle_unlit";
|
|
||||||
case Red: return "red_unlit";
|
|
||||||
case Death: return "off_unlit";
|
|
||||||
case Green: return "idle_unlit";
|
|
||||||
case Yellow: return "maint_unlit";
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(status), status, "unknown MedicalScannerStatus");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum MedicalScannerVisualLayers : byte
|
|
||||||
{
|
|
||||||
Machine,
|
|
||||||
Terminal,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -167,8 +167,8 @@ namespace Content.Server.Medical
|
|||||||
return MedicalScannerStatus.Open;
|
return MedicalScannerStatus.Open;
|
||||||
|
|
||||||
if (!TryComp<MobStateComponent>(body.Value, out var state))
|
if (!TryComp<MobStateComponent>(body.Value, out var state))
|
||||||
{
|
{ // Is not alive or dead or critical
|
||||||
return MedicalScannerStatus.Open;
|
return MedicalScannerStatus.Yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetStatusFromDamageState(body.Value, state);
|
return GetStatusFromDamageState(body.Value, state);
|
||||||
@@ -213,13 +213,14 @@ namespace Content.Server.Medical
|
|||||||
|
|
||||||
_updateDif -= UpdateRate;
|
_updateDif -= UpdateRate;
|
||||||
|
|
||||||
foreach (var scanner in EntityQuery<MedicalScannerComponent>())
|
var query = EntityQueryEnumerator<MedicalScannerComponent>();
|
||||||
|
while(query.MoveNext(out var uid, out var scanner))
|
||||||
{
|
{
|
||||||
UpdateAppearance(scanner.Owner, scanner);
|
UpdateAppearance(uid, scanner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InsertBody(EntityUid uid, EntityUid user, MedicalScannerComponent? scannerComponent)
|
public void InsertBody(EntityUid uid, EntityUid to_insert, MedicalScannerComponent? scannerComponent)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref scannerComponent))
|
if (!Resolve(uid, ref scannerComponent))
|
||||||
return;
|
return;
|
||||||
@@ -227,10 +228,10 @@ namespace Content.Server.Medical
|
|||||||
if (scannerComponent.BodyContainer.ContainedEntity != null)
|
if (scannerComponent.BodyContainer.ContainedEntity != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!HasComp<MobStateComponent>(user))
|
if (!HasComp<BodyComponent>(to_insert))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scannerComponent.BodyContainer.Insert(user);
|
scannerComponent.BodyContainer.Insert(to_insert);
|
||||||
UpdateAppearance(uid, scannerComponent);
|
UpdateAppearance(uid, scannerComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,26 @@
|
|||||||
snapCardinals: true
|
snapCardinals: true
|
||||||
layers:
|
layers:
|
||||||
- state: open
|
- state: open
|
||||||
map: ["enum.MedicalScannerVisualLayers.Machine"]
|
map: [machineLayer]
|
||||||
- state: idle_unlit
|
- state: idle_unlit
|
||||||
map: ["enum.MedicalScannerVisualLayers.Terminal"]
|
map: [terminalLayer]
|
||||||
|
- type: GenericVisualizer
|
||||||
|
visuals:
|
||||||
|
enum.MedicalScannerVisuals.Status:
|
||||||
|
machineLayer:
|
||||||
|
Off: {state: "closed"}
|
||||||
|
Open: {state: "open"}
|
||||||
|
Red: {state: "occupied"}
|
||||||
|
Death: {state: "occupied"}
|
||||||
|
Green: {state: "occupied"}
|
||||||
|
Yellow: {state: "occupied"}
|
||||||
|
terminalLayer:
|
||||||
|
Off: {state: "off_unlit"}
|
||||||
|
Open: {state: "idle_unlit"}
|
||||||
|
Red: {state: "red_unlit"}
|
||||||
|
Death: {state: "off_unlit"}
|
||||||
|
Green: {state: "idle_unlit"}
|
||||||
|
Yellow: {state: "maint_unlit"}
|
||||||
- type: Physics
|
- type: Physics
|
||||||
bodyType: Static
|
bodyType: Static
|
||||||
- type: Fixtures
|
- type: Fixtures
|
||||||
@@ -62,8 +79,6 @@
|
|||||||
BoardName: "MedicalScanner"
|
BoardName: "MedicalScanner"
|
||||||
LayoutId: MedicalScanner
|
LayoutId: MedicalScanner
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
|
||||||
- type: MedicalScannerVisualizer
|
|
||||||
- type: Climbable
|
- type: Climbable
|
||||||
- type: ApcPowerReceiver
|
- type: ApcPowerReceiver
|
||||||
powerLoad: 200 #Receives most of its power from the console
|
powerLoad: 200 #Receives most of its power from the console
|
||||||
|
|||||||
Reference in New Issue
Block a user