2022-04-26 18:25:57 +10:00
|
|
|
using Content.Server.Shuttles.Components;
|
|
|
|
|
using Robust.Shared.Physics;
|
|
|
|
|
using Robust.Shared.Physics.Dynamics;
|
2022-09-14 17:26:26 +10:00
|
|
|
using Robust.Shared.Physics.Events;
|
2022-04-26 18:25:57 +10:00
|
|
|
|
2022-06-16 15:28:16 +10:00
|
|
|
namespace Content.Server.Shuttles.Systems;
|
2022-04-26 18:25:57 +10:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes anything with <see cref="SpaceGarbageComponent"/> that has a cross-grid collision with a static body.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class SpaceGarbageSystem : EntitySystem
|
|
|
|
|
{
|
2024-01-04 14:25:32 +11:00
|
|
|
private EntityQuery<TransformComponent> _xformQuery;
|
|
|
|
|
|
2022-04-26 18:25:57 +10:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2024-01-04 14:25:32 +11:00
|
|
|
_xformQuery = GetEntityQuery<TransformComponent>();
|
2022-04-26 18:25:57 +10:00
|
|
|
SubscribeLocalEvent<SpaceGarbageComponent, StartCollideEvent>(OnCollide);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 17:26:26 +10:00
|
|
|
private void OnCollide(EntityUid uid, SpaceGarbageComponent component, ref StartCollideEvent args)
|
2022-04-26 18:25:57 +10:00
|
|
|
{
|
2024-01-04 14:25:32 +11:00
|
|
|
if (args.OtherBody.BodyType != BodyType.Static)
|
|
|
|
|
return;
|
2022-07-15 14:11:41 +10:00
|
|
|
|
2024-01-04 14:25:32 +11:00
|
|
|
var ourXform = _xformQuery.GetComponent(uid);
|
|
|
|
|
var otherXform = _xformQuery.GetComponent(args.OtherEntity);
|
2022-04-26 18:25:57 +10:00
|
|
|
|
2024-01-04 14:25:32 +11:00
|
|
|
if (ourXform.GridUid == otherXform.GridUid)
|
|
|
|
|
return;
|
2022-04-26 18:25:57 +10:00
|
|
|
|
|
|
|
|
QueueDel(uid);
|
|
|
|
|
}
|
|
|
|
|
}
|