Skip to content

Commit

Permalink
fix system::new, add entity registration, and add missing pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Indra-db committed Mar 4, 2024
1 parent d1a7cd2 commit 8321310
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
38 changes: 38 additions & 0 deletions flecs_ecs/src/addons/system/system_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,26 @@ where
};
obj.desc.query = *obj.query_builder.get_desc_query();
obj.desc.query.filter = *obj.filter_builder.get_desc_filter();
let entity_desc: ecs_entity_desc_t = ecs_entity_desc_t {
name: std::ptr::null(),
sep: SEPARATOR.as_ptr(),
root_sep: SEPARATOR.as_ptr(),
..Default::default()
};
obj.desc.entity = unsafe { ecs_entity_init(obj.world.raw_world, &entity_desc) };

T::populate(&mut obj);

#[cfg(feature = "flecs_pipeline")]
unsafe {
ecs_add_id(
world.raw_world,
obj.desc.entity,
ecs_dependson(ECS_ON_UPDATE),
);
ecs_add_id(world.raw_world, obj.desc.entity, ECS_ON_UPDATE);
}

obj
}

Expand All @@ -84,7 +103,26 @@ where
};
obj.desc.query = *obj.query_builder.get_desc_query();
obj.desc.query.filter = *obj.filter_builder.get_desc_filter();
let entity_desc: ecs_entity_desc_t = ecs_entity_desc_t {
name: std::ptr::null(),
sep: SEPARATOR.as_ptr(),
root_sep: SEPARATOR.as_ptr(),
..Default::default()
};
obj.desc.entity = unsafe { ecs_entity_init(obj.world.raw_world, &entity_desc) };

T::populate(&mut obj);

#[cfg(feature = "flecs_pipeline")]
unsafe {
ecs_add_id(
world.raw_world,
obj.desc.entity,
ecs_dependson(ECS_ON_UPDATE),
);
ecs_add_id(world.raw_world, obj.desc.entity, ECS_ON_UPDATE);
}

obj
}

Expand Down
1 change: 1 addition & 0 deletions flecs_ecs/src/core/observer_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ where
let entity_desc: ecs_entity_desc_t = ecs_entity_desc_t {
name: std::ptr::null(),
sep: SEPARATOR.as_ptr(),
root_sep: SEPARATOR.as_ptr(),
..default::Default::default()
};

Expand Down
2 changes: 1 addition & 1 deletion flecs_ecs/src/core/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3411,7 +3411,7 @@ impl World {
///
/// * C++ API: `world::system`
#[doc(alias = "world::system")]
pub fn system(&self, entity: Entity) -> System {
pub fn system_from_entity(&self, entity: Entity) -> System {
System::new_from_existing(self, entity)
}

Expand Down
1 change: 0 additions & 1 deletion flecs_ecs/tests/common.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use flecs_ecs::core::{c_types::*, component_registration::*};
use flecs_ecs_derive::Component;
use std::{ffi::CStr, sync::OnceLock};

#[cfg(test)]
#[ctor::ctor]
Expand Down

0 comments on commit 8321310

Please sign in to comment.