Fix fulton parenting (#19662)

This commit is contained in:
metalgearsloth
2023-08-31 10:51:31 +10:00
committed by GitHub
parent 6bbdbc9a9f
commit c5c99151aa

View File

@@ -1,7 +1,6 @@
using System.Numerics;
using Content.Shared.Salvage.Fulton; using Content.Shared.Salvage.Fulton;
using Robust.Shared.Containers;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Random; using Robust.Shared.Random;
namespace Content.Server.Salvage; namespace Content.Server.Salvage;
@@ -9,6 +8,7 @@ namespace Content.Server.Salvage;
public sealed class FultonSystem : SharedFultonSystem public sealed class FultonSystem : SharedFultonSystem
{ {
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -50,12 +50,14 @@ public sealed class FultonSystem : SharedFultonSystem
private void Fulton(EntityUid uid, FultonedComponent component) private void Fulton(EntityUid uid, FultonedComponent component)
{ {
if (!Deleted(component.Beacon)) if (!Deleted(component.Beacon) &&
TryComp<TransformComponent>(component.Beacon, out var beaconXform) &&
!_container.IsEntityOrParentInContainer(component.Beacon.Value, xform: beaconXform))
{ {
var xform = Transform(uid); var xform = Transform(uid);
var oldCoords = xform.Coordinates; var oldCoords = xform.Coordinates;
var offset = _random.NextVector2(1.5f); var offset = _random.NextVector2(1.5f);
TransformSystem.SetCoordinates(uid, new EntityCoordinates(component.Beacon.Value, offset)); TransformSystem.SetCoordinates(uid, new EntityCoordinates(beaconXform.ParentUid, offset));
RaiseNetworkEvent(new FultonAnimationMessage() RaiseNetworkEvent(new FultonAnimationMessage()
{ {