From d1812c11fde58ffa23967c50524472c6324334a2 Mon Sep 17 00:00:00 2001 From: goet <6637097+goet@users.noreply.github.com> Date: Wed, 25 Sep 2024 07:21:24 +0200 Subject: [PATCH] Fix contraband never getting added to vend inventory (#32431) * fix contraband never getting added to vend inventory * Revert "fix contraband never getting added to vend inventory" This reverts commit e7fb3a60c3cb6fcbf41d7f015f13dbc7b1c1901d. * readd setter method to system * fix again without reparenting --- .../VendingMachineContrabandWireAction.cs | 11 ++++++++++- .../VendingMachines/VendingMachineSystem.cs | 12 ++++++++++++ .../VendingMachines/VendingMachineComponent.cs | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Content.Server/VendingMachines/VendingMachineContrabandWireAction.cs b/Content.Server/VendingMachines/VendingMachineContrabandWireAction.cs index 22a0341fcb..39231fbe83 100644 --- a/Content.Server/VendingMachines/VendingMachineContrabandWireAction.cs +++ b/Content.Server/VendingMachines/VendingMachineContrabandWireAction.cs @@ -7,11 +7,20 @@ namespace Content.Server.VendingMachines; [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(); + } + public override StatusLightState? GetLightState(Wire wire) { if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending)) @@ -28,7 +37,7 @@ public sealed partial class VendingMachineContrabandWireAction : BaseToggleWireA { if (EntityManager.TryGetComponent(owner, out VendingMachineComponent? vending)) { - vending.Contraband = !setting; + _vendingMachineSystem.SetContraband(owner, !vending.Contraband, vending); } } diff --git a/Content.Server/VendingMachines/VendingMachineSystem.cs b/Content.Server/VendingMachines/VendingMachineSystem.cs index 38407a98c7..90fe4cb7d8 100644 --- a/Content.Server/VendingMachines/VendingMachineSystem.cs +++ b/Content.Server/VendingMachines/VendingMachineSystem.cs @@ -192,6 +192,18 @@ namespace Content.Server.VendingMachines component.CanShoot = canShoot; } + /// + /// Sets the property of the vending machine. + /// + 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)) diff --git a/Content.Shared/VendingMachines/VendingMachineComponent.cs b/Content.Shared/VendingMachines/VendingMachineComponent.cs index a3c7949600..50023a023a 100644 --- a/Content.Shared/VendingMachines/VendingMachineComponent.cs +++ b/Content.Shared/VendingMachines/VendingMachineComponent.cs @@ -41,6 +41,7 @@ namespace Content.Shared.VendingMachines [DataField, AutoNetworkedField] public Dictionary ContrabandInventory = new(); + [DataField, AutoNetworkedField] public bool Contraband; public bool Ejecting;