Breaking Changes #22
Replies: 9 comments
-
The Old: ecs_world_t* world = query.World; New: World world = query.World();
World realWorld = query.RealWorld(); |
Beta Was this translation helpful? Give feedback.
-
Old: Entity e = world.Entity()
.Add(Color.Red)
.Set(Color.Red);
e.Has<Color>(Ecs.Wildcard); // True
e.Has<Color>(); // True
e.Remove<Color>();
e.Has<Color>(Ecs.Wildcard); // False
e.Has<Color>(); // True New: Entity e = world.Entity()
.Add(Color.Red)
.Set(Color.Red);
e.Has<Color>(Ecs.Wildcard); // True
e.Has<Color>(); // True
e.Remove<Color>();
e.Has<Color>(Ecs.Wildcard); // True
e.Has<Color>(); // False |
Beta Was this translation helpful? Give feedback.
-
Instanced queries have been removed. See this post for more information SanderMertens/flecs#466 (comment) |
Beta Was this translation helpful? Give feedback.
-
The following fields have been renamed:
Routines have been renamed to System to more closely match the C++ API. |
Beta Was this translation helpful? Give feedback.
-
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.
Using tags in the above factory methods is no longer allowed and will trigger an assert in debug mode. Use IterIterable, PageIterable, and WorkerIterable types now have generic versions as well.
|
Beta Was this translation helpful? Give feedback.
-
Minimum target version bumped to .NET 8All 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. |
Beta Was this translation helpful? Give feedback.
-
Old: e.Each((Id id) =>
{
if (id.IsEntity())
{
Entity comp = id.Entity();
Console.Write(comp.ToString());
}
}); New: e.Each((Id id) =>
{
if (id.IsEntity())
{
Entity comp = id.ToEntity(); // Renamed to ToEntity()
Console.Write(comp.ToString());
}
}); |
Beta Was this translation helpful? Give feedback.
-
The callback signature for Old: using World world = World.Create();
world.App()
.Init(Setup)
.Run();
static void Setup(ecs_world_t* worldPtr)
{
World world = World.Create(worldPtr);
world.Import<Module1>();
world.Import<Module2>();
world.Import<Module3>();
} New: using World world = World.Create();
world.App()
.Init(Setup)
.Run();
static void Setup(World world)
{
world.Import<Module1>();
world.Import<Module2>();
world.Import<Module3>();
} |
Beta Was this translation helpful? Give feedback.
-
Managed types are now allowed to be passed as user context to systems and observers. Previously only pointers to unmanaged types were allowed. Old: int value = 10;
world.System()
.Ctx(&value) // Pointer has to be passed.
.Each(static (Iter it, int _) =>
{
ref int ctx = ref it.Ctx<int>();
Console.WriteLine(ctx); // Prints 10
}); New: world.System()
.Ctx("Context") // Context is passed by value
.Each(static (Iter it, int _) =>
{
ref string ctx = ref it.Ctx<string>();
Console.WriteLine(ctx); // Prints "String"
}); A callback can be provided to run clean-up logic before the context object is freed. world.System()
.Ctx("Context", static (ref string ctx) =>
{
Console.WriteLine("Context is being freed");
})
.Each(...); |
Beta Was this translation helpful? Give feedback.
-
Breaking changes will be posted here.
Beta Was this translation helpful? Give feedback.
All reactions