v4.0.2
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, ...>()returnsQuery<T1, ...>World.QueryBuilder<T1, ...>()returnsQueryBuilder<T1, ...>World.Observer<T1, ...>returnsObserver<T1, ...>World.System<T1, ...>returnsSystem<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()returnsIterIterable<T1, ...>IIterable.Page()returnsPageIterable<T1, ...>IIterable.Worker()returnsWorkerIterable<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.Routinehas been removed. UseEcs.Systeminstead.RoutineBuilder.RoutineDescrenamed toRoutineBuilder.DescObserverBuilder.ObserverDescrenamed toObserverBuilder.DescPipelineBuilder.PipelineDescrenamed toPipelineBuilder.DescAlertBuilder.AlertDescrenamed toPipelineBuilder.DescAlertBuilder.Idrenamed toAlertBuilder.AlertIdAlertBuilder.Varrenamed toAlertBuilder.AlertVarEntity.Read()callbacks now takeref readonlyinstead ofinmodifiers
What's Changed
- Update zig build script and CI by @BeanCheeseBurrito in #34
- Register System.Type on component entities by @xentripetal in #41
- Implement type-safe query api, upgrade to .NET 8, remove Unity package support by @BeanCheeseBurrito in #42
- Update to flecs 4.0.1 and improve .Each() iteration by @BeanCheeseBurrito in #43
- Update flecs submodule to 4.0.2 and port latest changes by @BeanCheeseBurrito in #44
New Contributors
- @xentripetal made their first contribution in #41
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