From 4ba2ab5b1c78c883b0b7a64839270ee15cdb11a1 Mon Sep 17 00:00:00 2001 From: ReeZer2 Date: Tue, 10 Dec 2024 14:16:17 +0200 Subject: [PATCH] FIX: Nanomed and another vend wall machine now eject entities take angle rotation --- .../VendingMachines/VendingMachineSystem.cs | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Content.Server/VendingMachines/VendingMachineSystem.cs b/Content.Server/VendingMachines/VendingMachineSystem.cs index 160eaf33c34769..163e39ae07d7ca 100644 --- a/Content.Server/VendingMachines/VendingMachineSystem.cs +++ b/Content.Server/VendingMachines/VendingMachineSystem.cs @@ -52,6 +52,7 @@ public sealed class VendingMachineSystem : SharedVendingMachineSystem [Dependency] private readonly SpeakOnUIClosedSystem _speakOnUIClosed = default!; [Dependency] private readonly EntityWhitelistSystem _whitelist = default!; [Dependency] private readonly SharedPointLightSystem _light = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private const float WallVendEjectDistanceFromWall = 1f; @@ -490,6 +491,23 @@ private void EjectItem(EntityUid uid, VendingMachineComponent? vendComponent = n EntityUid ent; + // Default spawn coordinates + var spawnCoordinates = Transform(uid).Coordinates; + + //Make sure the wallvends spawn outside of the wall. + + //ss220 nanomed eject entities fix start + if (HasComp(uid)) + { + var rotation = _transform.GetWorldRotation(uid); + var directionVector = new Vector2((float)-Math.Cos(rotation.Theta), (float)-Math.Sin(rotation.Theta)); + + var offset = directionVector * WallVendEjectDistanceFromWall; + + spawnCoordinates = spawnCoordinates.Offset(offset); + } + //ss220 nanomed eject entities fix end + // SS220 vending-machine-inv begin if (vendComponent.NextEntityToEject is { } entityUid) { @@ -498,23 +516,10 @@ private void EjectItem(EntityUid uid, VendingMachineComponent? vendComponent = n } else { - ent = Spawn(vendComponent.NextItemToEject, Transform(uid).Coordinates); + ent = Spawn(vendComponent.NextItemToEject, spawnCoordinates); } // SS220 vending-machine-inv end - - // 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); - } - if (vendComponent.ThrowNextItem) { var range = vendComponent.NonLimitedEjectRange;