prime31 / zig-ecs

MIT License
251 stars 39 forks source link

Basisc Groups don't have an `each` method #4

Closed OAguinagalde closed 4 years ago

OAguinagalde commented 4 years ago

The Readme states that...


The same example using a non-owning Group:

var group = reg.group(.{}, .{ Velocity, Position }, .{});
group.each(each);

fn each(e: struct { vel: *Velocity, pos: *Position }) void {
    e.pos.*.x += e.vel.x;
    e.pos.*.y += e.vel.y;
}

zig complains:

error: no member named 'each' in struct '.zig-ecs.ecs.groups.BasicGroup'

After looking for it I only managed to find the method each for OwningGroups. Not that I know if there should or shouldn't be such method but just wanted to point out that the readme seems(?) wrong.

prime31 commented 4 years ago

OwningGroup has the added benefit of contiguous array access for the data while non-owning groups have to go through the SparseSet to get to the data. Implementing each for a non-owning group doesnt really have any advantages so it wasnt added.