Vending machine changes (#8060)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Flipp Syder
2022-05-09 19:22:58 -07:00
committed by GitHub
parent 8257635811
commit 8f223586d4
12 changed files with 240 additions and 57 deletions

View File

@@ -0,0 +1,43 @@
using Content.Server.Wires;
using Content.Shared.VendingMachines;
using Content.Shared.Wires;
namespace Content.Server.VendingMachines;
[DataDefinition]
public sealed class VendingMachineContrabandWireAction : BaseToggleWireAction
{
private readonly Color _color = Color.Green;
private readonly string _text = "MNGR";
public override object? StatusKey { get; } = ContrabandWireKey.StatusKey;
public override object? TimeoutKey { get; } = ContrabandWireKey.TimeoutKey;
public override StatusLightData? GetStatusLightData(Wire wire)
{
var lightState = StatusLightState.Off;
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent vending))
{
lightState = vending.Contraband
? StatusLightState.BlinkingSlow
: StatusLightState.On;
}
return new StatusLightData(
_color,
lightState,
_text);
}
public override void ToggleValue(EntityUid owner, bool setting)
{
if (EntityManager.TryGetComponent(owner, out VendingMachineComponent vending))
{
vending.Contraband = !setting;
}
}
public override bool GetValue(EntityUid owner)
{
return EntityManager.TryGetComponent(owner, out VendingMachineComponent vending) && !vending.Contraband;
}
}