Skip to content

v4.0.2

Latest
Compare
Choose a tag to compare
@BeanCheeseBurrito BeanCheeseBurrito released this 06 Oct 12:40
· 19 commits to main since this release
98a2483

Minimum target version bumped to .NET 8

All projects must now target .NET 8 or above. Support for .NET 7 and lower versions have been removed. This change is a prerequisite to implementing pinned array storage for managed types in the future #21. The Unity package will no longer be updated.

New generic query API

A new type-safe generic query API has been added to help reduce common errors relating to queries.

Old:

using Query query = world.Query<Position, Velocity>();
query.Each((ref Position p, ref Velocity v) => { });

New:

using Query<Position, Velocity> query = world.Query<Position, Velocity>();
query.Each((ref Position p, ref Velocity v) => { }); // Parameter types must match the query's type list.

When calling factory methods for query types using type parameters (ex. World.Query<T1, ...>), a generic query object will be returned instead of an untyped query.

  • World.Query<T1, ...>() returns Query<T1, ...>
  • World.QueryBuilder<T1, ...>() returns QueryBuilder<T1, ...>
  • World.Observer<T1, ...> returns Observer<T1, ...>
  • World.System<T1, ...> returns System<T1, ...>

Using tags in the above factory methods is no longer allowed and will trigger an assert in debug mode. Use .With<Tag>() to query for tag types.

public record struct Position(int X, int Y);
public struct Tag;

// Invalid and will trigger assert.
Query<Position, Tag> query = world.QueryBuilder<Position, Tag>()
    .Build()

// Correct
Query<Position> query = world.QueryBuilder<Position>()
    .With<Tag>()
    .Build()

IterIterable, PageIterable, and WorkerIterable types now have generic versions as well.

  • IIterable.Iter() returns IterIterable<T1, ...>
  • IIterable.Page() returns PageIterable<T1, ...>
  • IIterable.Worker() returns WorkerIterable<T1, ...>

Routine renamed to System

Routine and RoutineBuilder have been renamed to System and SystemBuilder to more closely match the C++ API.

System<Position, Velocity> system = world.System<Position, Velocity>()
    .Each((ref Position p, ref Velocity v) =>
    {
        p.X += v.X;
        p.Y += v.Y;
    });

// Systems that contain no type arguments have an underscore at the end to prevent clashing with the System namespace.
System_ system = world.System().Run((Iter it) => { });

System.Type lookup for types

A component's System.Type can now be retrieved through the component's entity by calling .Get<Type>()

// This is equivalent to typeof(string)
Type type = world.Component<string>().Entity.Get<Type>()

Other Breaking Changes

  • Ecs.Routine has been removed. Use Ecs.System instead.
  • RoutineBuilder.RoutineDesc renamed to RoutineBuilder.Desc
  • ObserverBuilder.ObserverDesc renamed to ObserverBuilder.Desc
  • PipelineBuilder.PipelineDesc renamed to PipelineBuilder.Desc
  • AlertBuilder.AlertDesc renamed to PipelineBuilder.Desc
  • AlertBuilder.Id renamed to AlertBuilder.AlertId
  • AlertBuilder.Var renamed to AlertBuilder.AlertVar
  • Entity.Read() callbacks now take ref readonly instead of in modifiers

What's Changed

New Contributors

Full Changelog: v4.0.0...v4.0.2

Nuget Packages

Flecs.NET (Wrapper + Bindings + Native Libraries): Release | Debug
Flecs.NET.Bindings (Bindings + Native Libraries): Release | Debug
Flecs.NET.Native (Native Libraries): Release | Debug