From 4cec8110b0112b37971d6bac2da3593dd014b61c Mon Sep 17 00:00:00 2001 From: Repo <47093363+Titian3@users.noreply.github.com> Date: Wed, 29 May 2024 02:02:15 +1200 Subject: [PATCH] Fix wall vending machines spawning items in walls. (#28279) * Find spawning of wall vending machines. * Review fixes --- .../VendingMachines/VendingMachineSystem.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Content.Server/VendingMachines/VendingMachineSystem.cs b/Content.Server/VendingMachines/VendingMachineSystem.cs index 723b9de626..63ec8f2c24 100644 --- a/Content.Server/VendingMachines/VendingMachineSystem.cs +++ b/Content.Server/VendingMachines/VendingMachineSystem.cs @@ -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(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; -- 2.51.2