LightOnCollide entityquery (#33886)
This commit is contained in:
@@ -9,9 +9,14 @@ public sealed class LightCollideSystem : EntitySystem
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SlimPoweredLightSystem _lights = default!;
|
||||
|
||||
private EntityQuery<LightOnCollideComponent> _lightQuery;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_lightQuery = GetEntityQuery<LightOnCollideComponent>();
|
||||
|
||||
SubscribeLocalEvent<LightOnCollideColliderComponent, PreventCollideEvent>(OnPreventCollide);
|
||||
SubscribeLocalEvent<LightOnCollideColliderComponent, StartCollideEvent>(OnStart);
|
||||
SubscribeLocalEvent<LightOnCollideColliderComponent, EndCollideEvent>(OnEnd);
|
||||
@@ -35,7 +40,7 @@ public sealed class LightCollideSystem : EntitySystem
|
||||
|
||||
var other = contact.OtherEnt(ent.Owner);
|
||||
|
||||
if (HasComp<LightOnCollideComponent>(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<LightOnCollideColliderComponent> ent, ref PreventCollideEvent args)
|
||||
{
|
||||
if (!HasComp<LightOnCollideComponent>(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<LightOnCollideComponent>(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<LightOnCollideComponent>(args.OtherEntity))
|
||||
if (!_lightQuery.HasComp(args.OtherEntity))
|
||||
return;
|
||||
|
||||
_lights.SetEnabled(args.OtherEntity, true);
|
||||
|
||||
Reference in New Issue
Block a user