From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:24:00 +0000 (+1100) Subject: LightOnCollide entityquery (#33886) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=386e431ea761d817cd561148ba1a1303d1cd4012;p=space-station-14.git LightOnCollide entityquery (#33886) --- diff --git a/Content.Shared/Light/EntitySystems/LightCollideSystem.cs b/Content.Shared/Light/EntitySystems/LightCollideSystem.cs index f09ae6824e..2de7c5591f 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 @@ public sealed class LightCollideSystem : EntitySystem var other = contact.OtherEnt(ent.Owner); - if (HasComp(other)) + if (_lightQuery.HasComp(other)) { _physics.RegenerateContacts(other); } @@ -46,7 +51,7 @@ public sealed class LightCollideSystem : EntitySystem // 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 @@ public sealed class LightCollideSystem : EntitySystem 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 @@ public sealed class LightCollideSystem : EntitySystem if (args.OurFixtureId != ent.Comp.FixtureId) return; - if (!HasComp(args.OtherEntity)) + if (!_lightQuery.HasComp(args.OtherEntity)) return; _lights.SetEnabled(args.OtherEntity, true);