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:
metalgearsloth
2022-04-26 18:25:57 +10:00
committed by GitHub
parent 6ab3942bfe
commit 8d46dc42e7
30 changed files with 70 additions and 29 deletions

View File

@@ -66,6 +66,7 @@ namespace Content.Client.Entry
"Drain",
"Food",
"DeployableBarrier",
"SpaceGarbage",
"MagicMirror",
"DiseaseSwab",
"FloorTile",

View File

@@ -0,0 +1,8 @@
namespace Content.Server.Shuttles.Components;
/// <summary>
/// Cleanup component that deletes the entity if it has a cross-grid collision.
/// Useful for small, unimportant items like bullets to avoid generating many contacts.
/// </summary>
[RegisterComponent]
public sealed class SpaceGarbageComponent : Component {}

View 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);
}
}

View File

@@ -2103,9 +2103,9 @@
sprite: Objects/Consumable/Drinks/ramen.rsi
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: entity
parent: DrinkRamen

View File

@@ -36,10 +36,10 @@
stateOpen: icon_open
- type: Tag
tags:
- Recyclable
- Trash
- type: ItemCooldown
- type: Recyclable
- type: SpaceGarbage
- type: entity
parent: DrinkCanBaseFull

View File

@@ -52,9 +52,9 @@
acts: [ "Destruction" ]
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
# Containers
- type: entity

View File

@@ -59,9 +59,9 @@
netsync: false
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: entity
name: bowl

View File

@@ -44,9 +44,9 @@
acts: [ "Destruction" ]
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: entity
name: broken plate
@@ -60,9 +60,9 @@
netsync: false
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
# Small Plate
@@ -142,3 +142,4 @@
tags:
- Trash
- type: Recyclable
- type: SpaceGarbage

View File

@@ -110,6 +110,7 @@
- Egg
- Trash
- type: Recyclable
- type: SpaceGarbage
# Egg

View File

@@ -8,6 +8,7 @@
components:
- type: Food
- type: Recyclable
- type: SpaceGarbage
- type: Sprite
netsync: false

View File

@@ -259,3 +259,4 @@
tags:
- Trash
- type: Recyclable
- type: SpaceGarbage

View File

@@ -211,6 +211,7 @@
- type: Extractable
grindableSolutionName: food
- type: Recyclable
- type: SpaceGarbage
- type: entity
name: carrot

View File

@@ -206,9 +206,9 @@
HeldPrefix: packet
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: entity
noSpawn: true

View File

@@ -23,9 +23,9 @@
openIcon: open
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: entity
id: CigCartonRed

View File

@@ -14,9 +14,9 @@
- type: Tag
tags:
- Cigarette
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: Clothing
sprite: Objects/Consumable/Smokeables/Cigarettes/cigarette.rsi
Slots: [ mask ]

View File

@@ -11,9 +11,9 @@
- type: Tag
tags:
- Cigarette
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: Clothing
sprite: Objects/Consumable/Smokeables/Cigarettes/blunt.rsi
Slots: [ mask ]
@@ -43,9 +43,9 @@
- type: Tag
tags:
- Cigarette
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: Clothing
sprite: Objects/Consumable/Smokeables/Cigarettes/blunt.rsi
Slots: [ mask ]

View File

@@ -7,9 +7,9 @@
- type: Tag
tags:
- CigPack
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: Storage
capacity: 6
- type: Item

View File

@@ -57,10 +57,10 @@
size: 2
- type: Tag
tags:
- Recyclable
- RollingPaper
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: entity
id: CigaretteFilter
@@ -81,6 +81,5 @@
- type: Tag
tags:
- CigFilter
- Recyclable
- Trash
- type: Recyclable

View File

@@ -12,9 +12,9 @@
- type: BurnStateVisualizer
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
# Base for all cigars and cigarettes.
- type: entity

View File

@@ -9,9 +9,9 @@
tags:
- Write
- Crayon
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: UserInterface
interfaces:
- key: enum.CrayonUiKey.Key

View File

@@ -25,9 +25,9 @@
Slash: 2
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: Damageable
damageContainer: Inorganic
damageModifierSet: Glass

View File

@@ -20,7 +20,7 @@
Slash: 2
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage

View File

@@ -9,9 +9,9 @@
sprite: Objects/Misc/utensils.rsi
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: entity
parent: UtensilBase

View File

@@ -54,9 +54,9 @@
- type: LightBulbVisualizer
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
# Lighting color values gathered from
# https://andi-siess.de/rgb-to-color-temperature/

View File

@@ -51,9 +51,9 @@
emptySpriteName: medipen_empty
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: entity
name: emergency medipen

View File

@@ -8,9 +8,9 @@
- type: Tag
tags:
- Bottle
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: Sprite
sprite: Objects/Specific/Chemistry/bottle.rsi
netsync: false

View File

@@ -7,9 +7,9 @@
- type: Tag
tags:
- Flare
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: ExpendableLight
spentName: spent flare
spentDesc: It looks like this flare has burnt out. What a bummer.

View File

@@ -6,9 +6,9 @@
components:
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: ExpendableLight
spentName: spent green glowstick
spentDesc: It looks like this glowstick has stopped glowing. How tragic.

View File

@@ -17,9 +17,9 @@
- type: Tag
tags:
- Matchstick
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage
- type: Sprite
netsync: false
sprite: Objects/Tools/matches.rsi
@@ -81,6 +81,6 @@
- matchbox3
- type: Tag
tags:
- Recyclable
- Trash
- type: Recyclable
- type: SpaceGarbage

View File

@@ -6,7 +6,7 @@
- type: Tag
tags:
- Cartridge
- Recyclable
- type: Item
size: 1
- type: Recyclable
- type: SpaceGarbage