BeanCheeseBurrito/Flecs.NET

Modify examples to use new source-generated Iter/Each callbacks.

BeanCheeseBurrito opened this issue · 1 comments

The examples were all written before the generic callback source generators were introduced. It would be a good idea to sweep through the examples and use the shorter Each callbacks wherever possible.

Before:

Routine routine = world.Routine(
    filter: world.FilterBuilder()
        .With<Position>()
        .With<Velocity>(),
    callback: (Iter it, int i) =>
    {
        Column<Position> p = it.Field<Position>(1);
        Column<Velocity> v = it.Field<Velocity>(2);

        p[i].X += v[i].X;
        p[i].Y += v[i].Y;
    }
);

After:

Routine routine = world.Routine(
    filter: world.FilterBuilder<Position, Velocity>(),
    callback: (ref Position p, ref Velocity v) =>
    {
        p.X += v.X;
        p.Y += v.Y;
    }
);

Completed here #19