2022-05-09 19:22:58 -07:00
|
|
|
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)
|
2022-06-04 19:17:48 +12:00
|
|
|
&& EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
2022-05-09 19:22:58 -07:00
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
2022-06-04 19:17:48 +12:00
|
|
|
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
2022-05-09 19:22:58 -07:00
|
|
|
{
|
2022-08-31 14:12:09 +02:00
|
|
|
_vendingMachineSystem.SetShooting(wire.Owner, true, vending);
|
2022-05-09 19:22:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Mend(EntityUid user, Wire wire)
|
|
|
|
|
{
|
2022-06-04 19:17:48 +12:00
|
|
|
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
2022-05-09 19:22:58 -07:00
|
|
|
{
|
2022-08-31 14:12:09 +02:00
|
|
|
_vendingMachineSystem.SetShooting(wire.Owner, false, vending);
|
2022-05-09 19:22:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Pulse(EntityUid user, Wire wire)
|
|
|
|
|
{
|
|
|
|
|
_vendingMachineSystem.EjectRandom(wire.Owner, true);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|