diff options
author | HampusM <hampus@hampusmat.com> | 2025-08-09 12:37:46 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-08-09 13:50:46 +0200 |
commit | bb7c7d2f7d9bd9ad074c0186f5d503ee96b2f106 (patch) | |
tree | d58ed365764f320e3403c9ebd00f1b9d687217d5 /ecs/src/lib.rs | |
parent | 2d1cf05abb72699d38a7c7db7e131922252e1fc1 (diff) |
fix(ecs): remove use of linkme to make pc-windows-gnu builds work
Linkme is broken on the x86_64-pc-windows-gnu
target (see https://github.com/dtolnay/linkme/issues/25)
so static entities are now called entity declarations and must be
created manually.
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r-- | ecs/src/lib.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index 53abc6b..979b517 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -18,7 +18,7 @@ use crate::component::{ Parts as ComponentParts, Sequence as ComponentSequence, }; -use crate::entity::CREATE_STATIC_ENTITIES; +use crate::entity::Declaration as EntityDeclaration; use crate::event::component::{ Added as ComponentAddedEvent, Removed as ComponentRemovedEvent, @@ -56,9 +56,6 @@ pub mod tuple; pub mod uid; pub mod util; -#[doc(hidden)] -pub mod private; - mod lock; pub use ecs_macros::{Component, Sole}; @@ -84,30 +81,30 @@ impl World is_first_tick: AtomicBool::new(false), }; - world.add_sole(Stats::default()).ok(); + crate::phase::spawn_entities(&mut world); - for create_static_entity in CREATE_STATIC_ENTITIES { - create_static_entity(&mut world); - } + world.add_sole(Stats::default()).ok(); world } - /// Creates a new entity with the given components. + /// Creates a entity with the given components. A new unique [`Uid`] will be generated + /// for this entity. pub fn create_entity<Comps>(&mut self, components: Comps) -> Uid where Comps: ComponentSequence, { let entity_uid = Uid::new_unique(UidKind::Entity); - self.create_entity_with_uid(components, entity_uid); + self.create_entity_with_uid(entity_uid, components); entity_uid } + /// Creates a entity with the given components. The entity will have the specified + /// [`Uid`]. #[tracing::instrument(skip_all)] - #[doc(hidden)] - pub fn create_entity_with_uid<Comps>(&mut self, components: Comps, entity_uid: Uid) + pub fn create_entity_with_uid<Comps>(&mut self, entity_uid: Uid, components: Comps) where Comps: ComponentSequence, { @@ -129,6 +126,11 @@ impl World } } + pub fn create_declared_entity(&mut self, entity_decl: &EntityDeclaration) + { + entity_decl.create(self); + } + /// Adds a globally shared singleton value. /// /// # Errors |