Skip to content

Commit 4e2cb4e

Browse files
committed
Bump to flecs 4.1.6
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
1 parent 406b1f7 commit 4e2cb4e

11 files changed

Lines changed: 186 additions & 285 deletions

File tree

native/flecs

Submodule flecs updated 366 files

src/Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>4.1.5</VersionPrefix>
3+
<VersionPrefix>4.1.6</VersionPrefix>
44
<Authors>BeanCheeseBurrito</Authors>
55
<Copyright>BeanCheeseBurrito</Copyright>
66
<PackageProjectUrl>https://github.com/BeanCheeseBurrito/Flecs.NET</PackageProjectUrl>
@@ -55,4 +55,4 @@
5555
</PropertyGroup>
5656
</When>
5757
</Choose>
58-
</Project>
58+
</Project>

src/Flecs.NET.Bindings/Flecs.g.cs

Lines changed: 123 additions & 45 deletions
Large diffs are not rendered by default.

src/Flecs.NET.Tests/CSharp/Core/QueryBuilderTests.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ private void GroupBy()
2020
using Query q = world.QueryBuilder()
2121
.With<Tag3>()
2222
.GroupBy<Tag3>(GroupByFirstId)
23+
.QueryFlags(Ecs.QueryGroupByOrdered)
2324
.Build();
2425

2526
using Query qReverse = world.QueryBuilder()
2627
.With<Tag3>()
27-
.GroupBy<Tag3>(GroupByFirstIdNegated)
28+
.GroupBy<Tag3>(GroupByFirstId)
29+
.QueryFlags(Ecs.QueryGroupByOrdered | Ecs.QueryGroupByDesc)
2830
.Build();
2931

3032
Entity e3 = world.Entity().Add<Tag3>().Add<Tag2>();
@@ -75,11 +77,6 @@ static ulong GroupByFirstId(World world, Table table, ulong id)
7577
FlecsType type = table.Type();
7678
return type.Get(0);
7779
}
78-
79-
static ulong GroupByFirstIdNegated(World world, Table table, ulong id)
80-
{
81-
return ~GroupByFirstId(world, table, id);
82-
}
8380
}
8481

8582

src/Flecs.NET.Tests/Cpp/ObserverTests.cs

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,98 +1219,6 @@ private void AddToNamedInEmitForNamedEntityWithDefer()
12191219
world.DeferEnd();
12201220
}
12211221

1222-
[Fact]
1223-
private void RegisterTwiceWithEach()
1224-
{
1225-
using World world = World.Create();
1226-
1227-
int count1 = 0;
1228-
int count2 = 0;
1229-
1230-
world.Observer<Position>("Test")
1231-
.Event(Ecs.OnSet)
1232-
.Each((ref Position _) => { count1++; });
1233-
1234-
world.Entity().Set(new Position(10, 20));
1235-
Assert.Equal(1, count1);
1236-
1237-
world.Observer<Position>("Test")
1238-
.Event(Ecs.OnSet)
1239-
.Each((ref Position _) => { count2++; });
1240-
1241-
world.Entity().Set(new Position(10, 20));
1242-
Assert.Equal(1, count2);
1243-
}
1244-
1245-
[Fact]
1246-
private void RegisterTwiceWithRun()
1247-
{
1248-
using World world = World.Create();
1249-
1250-
int count1 = 0;
1251-
int count2 = 0;
1252-
1253-
world.Observer<Position>("Test")
1254-
.Event(Ecs.OnSet)
1255-
.Run((Iter _) => { count1++; });
1256-
1257-
world.Entity().Set(new Position(10, 20));
1258-
Assert.Equal(1, count1);
1259-
1260-
world.Observer<Position>("Test")
1261-
.Event(Ecs.OnSet)
1262-
.Run((Iter _) => { count2++; });
1263-
1264-
world.Entity().Set(new Position(10, 20));
1265-
Assert.Equal(1, count2);
1266-
}
1267-
1268-
[Fact]
1269-
private void RegisterTwiceWithRunEach()
1270-
{
1271-
using World world = World.Create();
1272-
1273-
int count1 = 0;
1274-
int count2 = 0;
1275-
1276-
world.Observer<Position>("Test")
1277-
.Event(Ecs.OnSet)
1278-
.Run((Iter _) => { count1++; });
1279-
1280-
world.Entity().Set(new Position(10, 20));
1281-
Assert.Equal(1, count1);
1282-
1283-
world.Observer<Position>("Test")
1284-
.Event(Ecs.OnSet)
1285-
.Each((ref Position _) => { count2++; });
1286-
1287-
world.Entity().Set(new Position(10, 20));
1288-
Assert.Equal(1, count2);
1289-
}
1290-
1291-
[Fact]
1292-
private void RegisterTwiceWithEachRun()
1293-
{
1294-
using World world = World.Create();
1295-
1296-
int count1 = 0;
1297-
int count2 = 0;
1298-
1299-
world.Observer<Position>("Test")
1300-
.Event(Ecs.OnSet)
1301-
.Each((ref Position _) => { count1++; });
1302-
1303-
world.Entity().Set(new Position(10, 20));
1304-
Assert.Equal(1, count1);
1305-
1306-
world.Observer<Position>("Test")
1307-
.Event(Ecs.OnSet)
1308-
.Run((Iter _) => { count2++; });
1309-
1310-
world.Entity().Set(new Position(10, 20));
1311-
Assert.Equal(1, count2);
1312-
}
1313-
13141222
[Fact]
13151223
private void OtherTable()
13161224
{

src/Flecs.NET.Tests/Cpp/QueryBuilderTests.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,12 +2251,6 @@ private static ulong GroupByFirstId(World world, Table table, ulong id)
22512251
ecs_type_t* type = ecs_table_get_type(table);
22522252
return type->array[0];
22532253
}
2254-
2255-
private static ulong GroupByFirstIdNegated(World world, Table table, ulong id)
2256-
{
2257-
return ~GroupByFirstId(world, table, id);
2258-
}
2259-
22602254
[Theory]
22612255
[MemberData(nameof(CacheKinds))]
22622256
private void GroupByRaw(ecs_query_cache_kind_t cacheKind)
@@ -2275,7 +2269,8 @@ private void GroupByRaw(ecs_query_cache_kind_t cacheKind)
22752269

22762270
using Query qReverse = world.QueryBuilder()
22772271
.With<Tag23>()
2278-
.GroupBy(world.Id<Tag23>(), GroupByFirstIdNegated)
2272+
.GroupBy(world.Id<Tag23>(), GroupByFirstId)
2273+
.QueryFlags(EcsQueryGroupByOrdered | EcsQueryGroupByDesc)
22792274
.Build();
22802275

22812276
Entity e3 = world.Entity().Add<Tag23>().Add<Tag2>();
@@ -2340,7 +2335,8 @@ private void GroupByTemplate(ecs_query_cache_kind_t cacheKind)
23402335

23412336
using Query qReverse = world.QueryBuilder()
23422337
.With<Tag23>()
2343-
.GroupBy<Tag23>(GroupByFirstIdNegated)
2338+
.GroupBy<Tag23>(GroupByFirstId)
2339+
.QueryFlags(EcsQueryGroupByOrdered | EcsQueryGroupByDesc)
23442340
.Build();
23452341

23462342
Entity e3 = world.Entity().Add<Tag23>().Add<Tag2>();

src/Flecs.NET.Tests/Cpp/SystemTests.cs

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,90 +2570,6 @@ private void PipelineStepDependsOnPipelineStepWithEnum()
25702570
Assert.True(ranTest);
25712571
}
25722572

2573-
[Fact]
2574-
private void RegisterTwiceWithEach()
2575-
{
2576-
using World world = World.Create();
2577-
2578-
int count1 = 0;
2579-
int count2 = 0;
2580-
2581-
System_ sys1 = world.System("Test")
2582-
.Each((Iter it, int i) => { count1++; });
2583-
2584-
sys1.Run();
2585-
Assert.Equal(1, count1);
2586-
2587-
System_ sys2 = world.System("Test")
2588-
.Each((Iter it, int i) => { count2++; });
2589-
2590-
sys2.Run();
2591-
Assert.Equal(1, count2);
2592-
}
2593-
2594-
[Fact]
2595-
private void RegisterTwiceWithRun()
2596-
{
2597-
using World world = World.Create();
2598-
2599-
int count1 = 0;
2600-
int count2 = 0;
2601-
2602-
System_ sys1 = world.System("Test")
2603-
.Run((Iter it) => { count1++; });
2604-
2605-
sys1.Run();
2606-
Assert.Equal(1, count1);
2607-
2608-
System_ sys2 = world.System("Test")
2609-
.Run((Iter it) => { count2++; });
2610-
2611-
sys2.Run();
2612-
Assert.Equal(1, count2);
2613-
}
2614-
2615-
[Fact]
2616-
private void RegisterTwiceWithRunEach()
2617-
{
2618-
using World world = World.Create();
2619-
2620-
int count1 = 0;
2621-
int count2 = 0;
2622-
2623-
System_ sys1 = world.System("Test")
2624-
.Run((Iter it) => { count1++; });
2625-
2626-
sys1.Run();
2627-
Assert.Equal(1, count1);
2628-
2629-
System_ sys2 = world.System("Test")
2630-
.Each((Iter it, int i) => { count2++; });
2631-
2632-
sys2.Run();
2633-
Assert.Equal(1, count2);
2634-
}
2635-
2636-
[Fact]
2637-
private void RegisterTwiceWithEachRun()
2638-
{
2639-
using World world = World.Create();
2640-
2641-
int count1 = 0;
2642-
int count2 = 0;
2643-
2644-
System_ sys1 = world.System("Test")
2645-
.Each((Iter it, int i) => { count1++; });
2646-
2647-
sys1.Run();
2648-
Assert.Equal(1, count1);
2649-
2650-
System_ sys2 = world.System("Test")
2651-
.Run((Iter it) => { count2++; });
2652-
2653-
sys2.Run();
2654-
Assert.Equal(1, count2);
2655-
}
2656-
26572573
[Fact]
26582574
private void RunWith0SrcQuery()
26592575
{

src/Flecs.NET/Core/Ecs/Aliases.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,17 @@ public static partial class Ecs
659659
/// Query only returns whole tables (ignores toggle/member fields).
660660
/// </summary>
661661
public const uint QueryTableOnly = EcsQueryTableOnly;
662+
663+
/// <summary>
664+
/// Enable ordering for query groups (ascending, lower group ids first).
665+
/// </summary>
666+
public const uint QueryGroupByOrdered = EcsQueryGroupByOrdered;
667+
668+
/// <summary>
669+
/// Enable descending ordering for query groups (higher group ids first).
670+
/// Only takes effect in combination with <see cref="QueryGroupByOrdered"/>.
671+
/// </summary>
672+
public const uint QueryGroupByDesc = EcsQueryGroupByDesc;
662673
}
663674

664675
#pragma warning restore CA1707, CA1708

src/Flecs.NET/Core/Invoker.cs

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public static void Callback(Iter it)
2828
public static void Iter(ecs_iter_t* iter, Ecs.IterCallback callback)
2929
{
3030
Ecs.TableLock(iter->world, iter->table);
31-
callback(new Iter(iter));
32-
Ecs.TableUnlock(iter->world, iter->table);
31+
try { callback(new Iter(iter)); } finally { Ecs.TableUnlock(iter->world, iter->table); }
3332
}
3433

3534
/// <summary>
@@ -42,11 +41,10 @@ public static void Each(ecs_iter_t* iter, Ecs.EachEntityCallback callback)
4241
Ecs.Assert(iter->entities != null, "No entities returned, use Iter() or Each() without the entity argument instead.");
4342

4443
Ecs.TableLock(iter->world, iter->table);
45-
46-
for (int i = 0; i < iter->count; i++)
47-
callback(new Entity(iter->world, iter->entities[i]));
48-
49-
Ecs.TableUnlock(iter->world, iter->table);
44+
try {
45+
for (int i = 0; i < iter->count; i++)
46+
callback(new Entity(iter->world, iter->entities[i]));
47+
} finally { Ecs.TableUnlock(iter->world, iter->table); }
5048
}
5149

5250
/// <summary>
@@ -57,13 +55,11 @@ public static void Each(ecs_iter_t* iter, Ecs.EachEntityCallback callback)
5755
public static void Each(ecs_iter_t* iter, Ecs.EachIterCallback callback)
5856
{
5957
Ecs.TableLock(iter->world, iter->table);
60-
61-
int count = iter->count == 0 && iter->table == null ? 1 : iter->count;
62-
63-
for (int i = 0; i < count; i++)
64-
callback(new Iter(iter), i);
65-
66-
Ecs.TableUnlock(iter->world, iter->table);
58+
try {
59+
int count = iter->count == 0 && iter->table == null ? 1 : iter->count;
60+
for (int i = 0; i < count; i++)
61+
callback(new Iter(iter), i);
62+
} finally { Ecs.TableUnlock(iter->world, iter->table); }
6763
}
6864

6965
/// <summary>
@@ -212,8 +208,7 @@ public static void Observe<T>(ecs_iter_t* iter, delegate*<Entity, T*, void> call
212208
public static void Iter(ecs_iter_t* iter, delegate*<Iter, void> callback)
213209
{
214210
Ecs.TableLock(iter->world, iter->table);
215-
callback(new Iter(iter));
216-
Ecs.TableUnlock(iter->world, iter->table);
211+
try { callback(new Iter(iter)); } finally { Ecs.TableUnlock(iter->world, iter->table); }
217212
}
218213

219214
/// <summary>
@@ -226,11 +221,10 @@ public static void Each(ecs_iter_t* iter, delegate*<Entity, void> callback)
226221
Ecs.Assert(iter->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead.");
227222

228223
Ecs.TableLock(iter->world, iter->table);
229-
230-
for (int i = 0; i < iter->count; i++)
231-
callback(new Entity(iter->world, iter->entities[i]));
232-
233-
Ecs.TableUnlock(iter->world, iter->table);
224+
try {
225+
for (int i = 0; i < iter->count; i++)
226+
callback(new Entity(iter->world, iter->entities[i]));
227+
} finally { Ecs.TableUnlock(iter->world, iter->table); }
234228
}
235229

236230
/// <summary>
@@ -241,13 +235,11 @@ public static void Each(ecs_iter_t* iter, delegate*<Entity, void> callback)
241235
public static void Each(ecs_iter_t* iter, delegate*<Iter, int, void> callback)
242236
{
243237
Ecs.TableLock(iter->world, iter->table);
244-
245-
int count = iter->count == 0 && iter->table == null ? 1 : iter->count;
246-
247-
for (int i = 0; i < count; i++)
248-
callback(new Iter(iter), i);
249-
250-
Ecs.TableUnlock(iter->world, iter->table);
238+
try {
239+
int count = iter->count == 0 && iter->table == null ? 1 : iter->count;
240+
for (int i = 0; i < count; i++)
241+
callback(new Iter(iter), i);
242+
} finally { Ecs.TableUnlock(iter->world, iter->table); }
251243
}
252244

253245
/// <summary>

0 commit comments

Comments
 (0)