Add a garbage collection component for grid movement (#7776)
If we move a station and there's thousands of bullets in the way we shouldn't just indefinitely lag the server as a result.
This commit is contained in:
28
Content.Server/Shuttles/EntitySystems/SpaceGarbageSystem.cs
Normal file
28
Content.Server/Shuttles/EntitySystems/SpaceGarbageSystem.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Content.Server.Shuttles.EntitySystems;
|
||||
|
||||
/// <summary>
|
||||
/// Deletes anything with <see cref="SpaceGarbageComponent"/> that has a cross-grid collision with a static body.
|
||||
/// </summary>
|
||||
public sealed class SpaceGarbageSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SpaceGarbageComponent, StartCollideEvent>(OnCollide);
|
||||
}
|
||||
|
||||
private void OnCollide(EntityUid uid, SpaceGarbageComponent component, StartCollideEvent args)
|
||||
{
|
||||
var ourXform = Transform(args.OurFixture.Body.Owner);
|
||||
var otherXform = Transform(args.OtherFixture.Body.Owner);
|
||||
|
||||
if (ourXform.GridID == otherXform.GridID ||
|
||||
args.OtherFixture.Body.BodyType != BodyType.Static) return;
|
||||
|
||||
QueueDel(uid);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user