[DataDefinition]
public sealed partial class VendingMachineContrabandWireAction : BaseToggleWireAction
{
+ private VendingMachineSystem _vendingMachineSystem = default!;
+
public override Color Color { get; set; } = Color.Green;
public override string Name { get; set; } = "wire-name-vending-contraband";
public override object? StatusKey { get; } = ContrabandWireKey.StatusKey;
public override object? TimeoutKey { get; } = ContrabandWireKey.TimeoutKey;
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ _vendingMachineSystem = EntityManager.System<VendingMachineSystem>();
+ }
+
public override StatusLightState? GetLightState(Wire wire)
{
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
{
if (EntityManager.TryGetComponent(owner, out VendingMachineComponent? vending))
{
- vending.Contraband = !setting;
+ _vendingMachineSystem.SetContraband(owner, !vending.Contraband, vending);
}
}
component.CanShoot = canShoot;
}
+ /// <summary>
+ /// Sets the <see cref="VendingMachineComponent.Contraband"/> property of the vending machine.
+ /// </summary>
+ public void SetContraband(EntityUid uid, bool contraband, VendingMachineComponent? component = null)
+ {
+ if (!Resolve(uid, ref component))
+ return;
+
+ component.Contraband = contraband;
+ Dirty(uid, component);
+ }
+
public void Deny(EntityUid uid, VendingMachineComponent? vendComponent = null)
{
if (!Resolve(uid, ref vendComponent))
[DataField, AutoNetworkedField]
public Dictionary<string, VendingMachineInventoryEntry> ContrabandInventory = new();
+ [DataField, AutoNetworkedField]
public bool Contraband;
public bool Ejecting;