@@ -161,6 +161,9 @@ pub const EcsAperiodicComponentMonitors = 1 << 2;
161
161
pub const EcsAperiodicEmptyQueries = 1 << 4 ;
162
162
163
163
// Extern declarations
164
+ extern const EcsQuery : entity_t ;
165
+ extern const EcsObserver : entity_t ;
166
+ extern const EcsSystem : entity_t ;
164
167
extern const EcsWildcard : entity_t ;
165
168
extern const EcsAny : entity_t ;
166
169
extern const EcsTransitive : entity_t ;
@@ -223,6 +226,9 @@ extern const EcsPredLookup: entity_t;
223
226
extern const EcsIsA : entity_t ;
224
227
extern const EcsDependsOn : entity_t ;
225
228
229
+ pub var Query : entity_t = undefined ;
230
+ pub var Observer : entity_t = undefined ;
231
+ pub var System : entity_t = undefined ;
226
232
pub var Wildcard : entity_t = undefined ;
227
233
pub var Any : entity_t = undefined ;
228
234
pub var Transitive : entity_t = undefined ;
@@ -1175,6 +1181,9 @@ pub fn init() *world_t {
1175
1181
component_ids_hm .ensureTotalCapacity (32 ) catch @panic ("OOM" );
1176
1182
const world = ecs_init ();
1177
1183
1184
+ Query = EcsQuery ;
1185
+ Observer = EcsObserver ;
1186
+ System = EcsSystem ;
1178
1187
Wildcard = EcsWildcard ;
1179
1188
Any = EcsAny ;
1180
1189
Transitive = EcsTransitive ;
@@ -1498,9 +1507,9 @@ extern fn ecs_add_id(world: *world_t, entity: entity_t, id: id_t) void;
1498
1507
pub const remove_id = ecs_remove_id ;
1499
1508
extern fn ecs_remove_id (world : * world_t , entity : entity_t , id : id_t ) void ;
1500
1509
1501
- /// `pub fn override_id (world: *world_t, entity: entity_t, id: id_t) void`
1502
- pub const override_id = ecs_override_id ;
1503
- extern fn ecs_override_id (world : * world_t , entity : entity_t , id : id_t ) void ;
1510
+ /// `pub fn auto_override_id (world: *world_t, entity: entity_t, id: id_t) void`
1511
+ pub const auto_override_id = ecs_auto_override_id ;
1512
+ extern fn ecs_auto_override_id (world : * world_t , entity : entity_t , id : id_t ) void ;
1504
1513
1505
1514
/// `pub fn clear(world: *world_t, entity: entity_t) void`
1506
1515
pub const clear = ecs_clear ;
@@ -2039,10 +2048,6 @@ extern fn ecs_enqueue(world: *world_t, desc: *event_desc_t) void;
2039
2048
pub const observer_init = ecs_observer_init ;
2040
2049
extern fn ecs_observer_init (world : * world_t , desc : * const observer_desc_t ) entity_t ;
2041
2050
2042
- /// `pub fn observer_default_run_action(it: *iter_t) bool`
2043
- pub const observer_default_run_action = ecs_observer_default_run_action ;
2044
- extern fn ecs_observer_default_run_action (it : * iter_t ) bool ;
2045
-
2046
2051
/// `pub fn observer_get_ctx(world: *const world_t, observer: entity_t) ?*anyopaque`
2047
2052
pub const observer_get_ctx = ecs_observer_get_ctx ;
2048
2053
extern fn ecs_observer_get_ctx (world : * const world_t , observer : entity_t ) ? * anyopaque ;
@@ -2466,7 +2471,7 @@ pub fn SYSTEM(
2466
2471
name : [* :0 ]const u8 ,
2467
2472
phase : entity_t ,
2468
2473
system_desc : * system_desc_t ,
2469
- ) void {
2474
+ ) entity_t {
2470
2475
var entity_desc = entity_desc_t {};
2471
2476
entity_desc .id = new_id (world );
2472
2477
entity_desc .name = name ;
@@ -2475,20 +2480,20 @@ pub fn SYSTEM(
2475
2480
entity_desc .add = &.{ first , second , 0 };
2476
2481
2477
2482
system_desc .entity = entity_init (world , & entity_desc );
2478
- _ = system_init (world , system_desc );
2483
+ return system_init (world , system_desc );
2479
2484
}
2480
2485
2481
2486
pub fn OBSERVER (
2482
2487
world : * world_t ,
2483
2488
name : [* :0 ]const u8 ,
2484
2489
observer_desc : * observer_desc_t ,
2485
- ) void {
2490
+ ) entity_t {
2486
2491
var entity_desc = entity_desc_t {};
2487
2492
entity_desc .id = new_id (world );
2488
2493
entity_desc .name = name ;
2489
2494
2490
2495
observer_desc .entity = entity_init (world , & entity_desc );
2491
- _ = observer_init (world , observer_desc );
2496
+ return observer_init (world , observer_desc );
2492
2497
}
2493
2498
2494
2499
/// Implements a flecs system from function parameters.
@@ -2575,9 +2580,9 @@ pub fn ADD_SYSTEM(
2575
2580
name : [* :0 ]const u8 ,
2576
2581
phase : entity_t ,
2577
2582
comptime fn_system : anytype ,
2578
- ) void {
2583
+ ) entity_t {
2579
2584
var desc = SYSTEM_DESC (fn_system );
2580
- SYSTEM (world , name , phase , & desc );
2585
+ return SYSTEM (world , name , phase , & desc );
2581
2586
}
2582
2587
2583
2588
/// Creates a system description and adds it to the world, from function parameters
@@ -2588,9 +2593,9 @@ pub fn ADD_SYSTEM_WITH_FILTERS(
2588
2593
phase : entity_t ,
2589
2594
comptime fn_system : anytype ,
2590
2595
filters : []const term_t ,
2591
- ) void {
2596
+ ) entity_t {
2592
2597
var desc = SYSTEM_DESC_WITH_FILTERS (fn_system , filters );
2593
- SYSTEM (world , name , phase , & desc );
2598
+ return SYSTEM (world , name , phase , & desc );
2594
2599
}
2595
2600
2596
2601
pub fn new_entity (world : * world_t , name : [* :0 ]const u8 ) entity_t {
@@ -2600,7 +2605,7 @@ pub fn new_entity(world: *world_t, name: [*:0]const u8) entity_t {
2600
2605
pub fn new_prefab (world : * world_t , name : [* :0 ]const u8 ) entity_t {
2601
2606
return entity_init (world , &.{
2602
2607
.name = name ,
2603
- .add = [_ ]id_t {EcsPrefab } ++ [_ ]id_t {0 } ** (FLECS_ID_DESC_MAX - 1 ),
2608
+ .add = @ptrCast (& [_ ]id_t {EcsPrefab } ++ [_ ]id_t {0 } ** (FLECS_ID_DESC_MAX - 1 ) ),
2604
2609
});
2605
2610
}
2606
2611
@@ -2693,7 +2698,7 @@ pub fn remove(world: *world_t, entity: entity_t, comptime T: type) void {
2693
2698
}
2694
2699
2695
2700
pub fn override (world : * world_t , entity : entity_t , comptime T : type ) void {
2696
- ecs_override_id (world , entity , id (T ));
2701
+ ecs_auto_override_id (world , entity , id (T ));
2697
2702
}
2698
2703
2699
2704
pub fn modified (world : * world_t , entity : entity_t , comptime T : type ) void {
@@ -2939,11 +2944,11 @@ extern fn ecs_import_c(world: *world_t, module: module_action_t, module_name_c:
2939
2944
2940
2945
//--------------------------------------------------------------------------------------------------
2941
2946
//
2942
- // FLECS_MONITOR
2947
+ // FLECS_STATS
2943
2948
//
2944
2949
//--------------------------------------------------------------------------------------------------
2945
2950
2946
- pub extern fn FlecsMonitorImport (world : * world_t ) void ;
2951
+ pub extern fn FlecsStatsImport (world : * world_t ) void ;
2947
2952
//--------------------------------------------------------------------------------------------------
2948
2953
//
2949
2954
// FLECS_REST
0 commit comments