Query
The Query, a way to select and iterate entities
All
// Creating many different entities
for(var index = 0; index < 1_000, index++){
world.Create(new Dwarf(), new Position(0,0), new Velocity(1,1), new Pickaxe());
world.Create(new Elf(), new Position(0,0), new Velocity(1,1), new Bow());
world.Create(new Human(), new Position(0,0), new Velocity(1,1), new Pickaxe(), new Sword());
}
// Iterating over all entities that have Position & Velocity to make them move.
var movementQuery = new QueryDescription().WithAll<Position, Velocity>();
world.Query(in movementQuery, (Entity entity, ref Position pos, ref Velocity vel) => {
pos += vel;
Console.WriteLine($"Moved: {entity}");
});None
Any
Exclusive
Last updated