Skip to main content

HAS

Constant HAS 

Source
pub const HAS: FunctionDescriptor;
Expand description

Tests whether an entity has the selected concrete component type.

C means a concrete type selector. The result observes the entity’s current component set and rejects an unknown entity rather than inventing absence.

§Signature

func has[C](entity: Entity) -> Bool

§Test component presence

The selector is required when the function value would otherwise not identify C.

type Counter {}
let entity = spawn(Counter {});
let present: func(Entity) -> Bool = has[Counter];
print(present(entity));