Wire action cleanup (#13496)

This commit is contained in:
Leon Friedrich
2023-01-21 12:51:02 +13:00
committed by GitHub
parent 319cf162fd
commit b20b4b11cc
21 changed files with 294 additions and 627 deletions

View File

@@ -1,4 +1,4 @@
using Content.Server.Medical.Components;
using Content.Server.Medical.Components;
using Content.Server.Wires;
using Content.Shared.Medical.Cryogenics;
using Content.Shared.Wires;
@@ -8,52 +8,31 @@ namespace Content.Server.Medical;
/// <summary>
/// Causes a failure in the cryo pod ejection system when cut. A crowbar will be needed to pry open the pod.
/// </summary>
[DataDefinition]
public sealed class CryoPodEjectLockWireAction: BaseWireAction
public sealed class CryoPodEjectLockWireAction: ComponentWireAction<CryoPodComponent>
{
[DataField("color")]
private Color _statusColor = Color.Red;
[DataField("name")]
private string _text = "LOCK";
public override Color Color { get; set; } = Color.Red;
public override string Name { get; set; } = "wire-name-lock";
public override bool LightRequiresPower { get; set; } = false;
public override object? StatusKey { get; } = CryoPodWireActionKey.Key;
public override bool Cut(EntityUid user, Wire wire)
public override bool Cut(EntityUid user, Wire wire, CryoPodComponent cryoPodComponent)
{
if (EntityManager.TryGetComponent<CryoPodComponent>(wire.Owner, out var cryoPodComponent) && !cryoPodComponent.PermaLocked)
{
if (!cryoPodComponent.PermaLocked)
cryoPodComponent.Locked = true;
}
return true;
}
public override bool Mend(EntityUid user, Wire wire)
public override bool Mend(EntityUid user, Wire wire, CryoPodComponent cryoPodComponent)
{
if (EntityManager.TryGetComponent<CryoPodComponent>(wire.Owner, out var cryoPodComponent) && !cryoPodComponent.PermaLocked)
{
if (!cryoPodComponent.PermaLocked)
cryoPodComponent.Locked = false;
}
return true;
}
public override bool Pulse(EntityUid user, Wire wire)
{
return true;
}
public override void Pulse(EntityUid user, Wire wire, CryoPodComponent cryoPodComponent) { }
public override StatusLightData? GetStatusLightData(Wire wire)
{
StatusLightState lightState = StatusLightState.Off;
if (EntityManager.TryGetComponent<CryoPodComponent>(wire.Owner, out var cryoPodComponent) && cryoPodComponent.Locked)
{
lightState = StatusLightState.On; //TODO figure out why this doesn't get updated when the pod is emagged
}
return new StatusLightData(
_statusColor,
lightState,
_text);
}
public override StatusLightState? GetLightState(Wire wire, CryoPodComponent comp)
=> comp.Locked ? StatusLightState.On : StatusLightState.Off;
}