From 55f232ae09bdb484c616d79ca8640143102861ac Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Fri, 27 Oct 2023 13:14:01 +1100 Subject: [PATCH] Fix ItemPlacer (#21160) This is going to lead to many entities being ticked unnecessarily and performance problems. --- Content.Shared/Placeable/ItemPlacerSystem.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Content.Shared/Placeable/ItemPlacerSystem.cs b/Content.Shared/Placeable/ItemPlacerSystem.cs index 92dc8eb74b..ec6ece671f 100644 --- a/Content.Shared/Placeable/ItemPlacerSystem.cs +++ b/Content.Shared/Placeable/ItemPlacerSystem.cs @@ -9,6 +9,7 @@ namespace Content.Shared.Placeable; /// public sealed class ItemPlacerSystem : EntitySystem { + [Dependency] private readonly CollisionWakeSystem _wake = default!; [Dependency] private readonly PlaceableSurfaceSystem _placeableSurface = 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)) return; - // Disallow sleeping so we can detect when entity is removed from the heater. - _physics.SetSleepingAllowed(args.OtherEntity, args.OtherBody, false); + if (TryComp(uid, out var wakeComp)) + _wake.SetEnabled(uid, false, wakeComp); var count = comp.PlacedEntities.Count; 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) { - // Re-allow sleeping. - _physics.SetSleepingAllowed(args.OtherEntity, args.OtherBody, true); + if (TryComp(uid, out var wakeComp)) + _wake.SetEnabled(uid, true, wakeComp); comp.PlacedEntities.Remove(args.OtherEntity); -- 2.51.2