]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix contraband never getting added to vend inventory (#32431)
authorgoet <6637097+goet@users.noreply.github.com>
Wed, 25 Sep 2024 05:21:24 +0000 (07:21 +0200)
committerGitHub <noreply@github.com>
Wed, 25 Sep 2024 05:21:24 +0000 (15:21 +1000)
* 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

Content.Server/VendingMachines/VendingMachineContrabandWireAction.cs
Content.Server/VendingMachines/VendingMachineSystem.cs
Content.Shared/VendingMachines/VendingMachineComponent.cs

index 22a0341fcbeac18df1430bb45154e986fc50fda9..39231fbe8349a38877bdeee36c5fb4f9504d4030 100644 (file)
@@ -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<VendingMachineSystem>();
+    }
+
     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);
         }
     }
 
index 38407a98c72943529e3799095b70b0dcd16dc8c4..90fe4cb7d8ae7ba53d09b8053f3b48b59c473f19 100644 (file)
@@ -192,6 +192,18 @@ namespace Content.Server.VendingMachines
             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))
index a3c7949600a18951712d7747c93410ff9a15e30f..50023a023ab1dd93f54eaa7010709574dd58ed2a 100644 (file)
@@ -41,6 +41,7 @@ namespace Content.Shared.VendingMachines
         [DataField, AutoNetworkedField]
         public Dictionary<string, VendingMachineInventoryEntry> ContrabandInventory = new();
 
+        [DataField, AutoNetworkedField]
         public bool Contraband;
 
         public bool Ejecting;