[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);
var other = contact.OtherEnt(ent.Owner);
- if (HasComp<LightOnCollideComponent>(other))
+ if (_lightQuery.HasComp(other))
{
_physics.RegenerateContacts(other);
}
// 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;
}
if (args.OurFixtureId != ent.Comp.FixtureId)
return;
- if (!HasComp<LightOnCollideComponent>(args.OtherEntity))
+ if (!_lightQuery.HasComp(args.OtherEntity))
return;
// TODO: Engine bug IsTouching box2d yay.
if (args.OurFixtureId != ent.Comp.FixtureId)
return;
- if (!HasComp<LightOnCollideComponent>(args.OtherEntity))
+ if (!_lightQuery.HasComp(args.OtherEntity))
return;
_lights.SetEnabled(args.OtherEntity, true);