Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Nanomed and another vend wall machine now eject entities take i.a. angle rotation #2333

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions Content.Server/VendingMachines/VendingMachineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<WallMountComponent>(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)
{
Expand All @@ -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<WallMountComponent>(uid, out var wallMountComponent))
{

var offset = wallMountComponent.Direction.ToWorldVec() * WallVendEjectDistanceFromWall;
spawnCoordinates = spawnCoordinates.Offset(offset);
}

if (vendComponent.ThrowNextItem)
{
var range = vendComponent.NonLimitedEjectRange;
Expand Down
Loading