diff --git a/Content.Shared/Light/EntitySystems/LightCollideSystem.cs b/Content.Shared/Light/EntitySystems/LightCollideSystem.cs index f09ae6824ea8ac..2de7c5591fdb9c 100644 --- a/Content.Shared/Light/EntitySystems/LightCollideSystem.cs +++ b/Content.Shared/Light/EntitySystems/LightCollideSystem.cs @@ -9,9 +9,14 @@ public sealed class LightCollideSystem : EntitySystem [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SlimPoweredLightSystem _lights = default!; + private EntityQuery _lightQuery; + public override void Initialize() { base.Initialize(); + + _lightQuery = GetEntityQuery(); + SubscribeLocalEvent(OnPreventCollide); SubscribeLocalEvent(OnStart); SubscribeLocalEvent(OnEnd); @@ -35,7 +40,7 @@ private void OnCollideShutdown(Entity ent, ref var other = contact.OtherEnt(ent.Owner); - if (HasComp(other)) + if (_lightQuery.HasComp(other)) { _physics.RegenerateContacts(other); } @@ -46,7 +51,7 @@ private void OnCollideShutdown(Entity ent, ref // At the moment there's no easy way to do collision whitelists based on components. private void OnPreventCollide(Entity ent, ref PreventCollideEvent args) { - if (!HasComp(args.OtherEntity)) + if (!_lightQuery.HasComp(args.OtherEntity)) { args.Cancelled = true; } @@ -57,7 +62,7 @@ private void OnEnd(Entity ent, ref EndCollideEv if (args.OurFixtureId != ent.Comp.FixtureId) return; - if (!HasComp(args.OtherEntity)) + if (!_lightQuery.HasComp(args.OtherEntity)) return; // TODO: Engine bug IsTouching box2d yay. @@ -74,7 +79,7 @@ private void OnStart(Entity ent, ref StartColli if (args.OurFixtureId != ent.Comp.FixtureId) return; - if (!HasComp(args.OtherEntity)) + if (!_lightQuery.HasComp(args.OtherEntity)) return; _lights.SetEnabled(args.OtherEntity, true);