Vending machine changes (#8060)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using Content.Server.VendingMachines.Systems;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.VendingMachines;
|
||||
using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.VendingMachines;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class VendingMachineEjectItemWireAction : BaseWireAction
|
||||
{
|
||||
private VendingMachineSystem _vendingMachineSystem = default!;
|
||||
|
||||
private Color _color = Color.Red;
|
||||
private string _text = "VEND";
|
||||
public override object? StatusKey { get; } = EjectWireKey.StatusKey;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
|
||||
if (IsPowered(wire.Owner)
|
||||
&& EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent vending))
|
||||
{
|
||||
lightState = vending.CanShoot
|
||||
? StatusLightState.BlinkingFast
|
||||
: StatusLightState.On;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_color,
|
||||
lightState,
|
||||
_text);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_vendingMachineSystem = EntitySystem.Get<VendingMachineSystem>();
|
||||
}
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent vending))
|
||||
{
|
||||
vending.CanShoot = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent vending))
|
||||
{
|
||||
vending.CanShoot = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
{
|
||||
_vendingMachineSystem.EjectRandom(wire.Owner, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user