Fix ItemPlacer (#21160)
This is going to lead to many entities being ticked unnecessarily and performance problems.
This commit is contained in:
@@ -9,6 +9,7 @@ namespace Content.Shared.Placeable;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ItemPlacerSystem : EntitySystem
|
public sealed class ItemPlacerSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly CollisionWakeSystem _wake = default!;
|
||||||
[Dependency] private readonly PlaceableSurfaceSystem _placeableSurface = default!;
|
[Dependency] private readonly PlaceableSurfaceSystem _placeableSurface = default!;
|
||||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
|
|
||||||
@@ -25,8 +26,8 @@ public sealed class ItemPlacerSystem : EntitySystem
|
|||||||
if (comp.Whitelist != null && !comp.Whitelist.IsValid(args.OtherEntity))
|
if (comp.Whitelist != null && !comp.Whitelist.IsValid(args.OtherEntity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Disallow sleeping so we can detect when entity is removed from the heater.
|
if (TryComp<CollisionWakeComponent>(uid, out var wakeComp))
|
||||||
_physics.SetSleepingAllowed(args.OtherEntity, args.OtherBody, false);
|
_wake.SetEnabled(uid, false, wakeComp);
|
||||||
|
|
||||||
var count = comp.PlacedEntities.Count;
|
var count = comp.PlacedEntities.Count;
|
||||||
if (comp.MaxEntities == 0 || count < comp.MaxEntities)
|
if (comp.MaxEntities == 0 || count < comp.MaxEntities)
|
||||||
@@ -46,8 +47,8 @@ public sealed class ItemPlacerSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnEndCollide(EntityUid uid, ItemPlacerComponent comp, ref EndCollideEvent args)
|
private void OnEndCollide(EntityUid uid, ItemPlacerComponent comp, ref EndCollideEvent args)
|
||||||
{
|
{
|
||||||
// Re-allow sleeping.
|
if (TryComp<CollisionWakeComponent>(uid, out var wakeComp))
|
||||||
_physics.SetSleepingAllowed(args.OtherEntity, args.OtherBody, true);
|
_wake.SetEnabled(uid, true, wakeComp);
|
||||||
|
|
||||||
comp.PlacedEntities.Remove(args.OtherEntity);
|
comp.PlacedEntities.Remove(args.OtherEntity);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user