]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix wall vending machines spawning items in walls. (#28279)
authorRepo <47093363+Titian3@users.noreply.github.com>
Tue, 28 May 2024 14:02:15 +0000 (02:02 +1200)
committerGitHub <noreply@github.com>
Tue, 28 May 2024 14:02:15 +0000 (17:02 +0300)
* Find spawning of wall vending machines.

* Review fixes

Content.Server/VendingMachines/VendingMachineSystem.cs

index 723b9de6267c93621f12321cf860bf9095ece366..63ec8f2c24bb015303df9884a2542e68ae212326 100644 (file)
@@ -19,6 +19,7 @@ using Content.Shared.Popups;
 using Content.Shared.Throwing;
 using Content.Shared.UserInterface;
 using Content.Shared.VendingMachines;
+using Content.Shared.Wall;
 using Robust.Server.GameObjects;
 using Robust.Shared.Audio;
 using Robust.Shared.Prototypes;
@@ -39,6 +40,8 @@ namespace Content.Server.VendingMachines
         [Dependency] private readonly IGameTiming _timing = default!;
         [Dependency] private readonly SpeakOnUIClosedSystem _speakOnUIClosed = default!;
 
+        private const float WallVendEjectDistanceFromWall = 1f;
+
         public override void Initialize()
         {
             base.Initialize();
@@ -384,7 +387,20 @@ namespace Content.Server.VendingMachines
                 return;
             }
 
-            var ent = Spawn(vendComponent.NextItemToEject, Transform(uid).Coordinates);
+            // Default spawn coordinates
+            var spawnCoordinates = Transform(uid).Coordinates;
+
+            //Make sure the wallvends spawn outside of the wall.
+
+            if (TryComp<WallMountComponent>(uid, out var wallMountComponent))
+            {
+
+                var offset = wallMountComponent.Direction.ToWorldVec() * WallVendEjectDistanceFromWall;
+                spawnCoordinates = spawnCoordinates.Offset(offset);
+            }
+
+            var ent = Spawn(vendComponent.NextItemToEject, spawnCoordinates);
+
             if (vendComponent.ThrowNextItem)
             {
                 var range = vendComponent.NonLimitedEjectRange;