summaryrefslogtreecommitdiff
path: root/engine-ecs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-07-08 23:19:06 +0200
committerHampusM <hampus@hampusmat.com>2026-07-08 23:19:06 +0200
commit213e4cfc698f0e0f9fcfbe43cf8c49f8f331e699 (patch)
tree666b38f087985fa0ed6d85f3d046760b16666365 /engine-ecs
parent05063e79465a33eb156c25edf8193fd77ba24314 (diff)
refactor(engine-ecs): rename entity creation fns to use 'spawn' terminology
Diffstat (limited to 'engine-ecs')
-rw-r--r--engine-ecs/benches/query.rs4
-rw-r--r--engine-ecs/examples/component_changed_event.rs4
-rw-r--r--engine-ecs/examples/component_events.rs6
-rw-r--r--engine-ecs/examples/component_relationship.rs6
-rw-r--r--engine-ecs/examples/component_removed_event.rs6
-rw-r--r--engine-ecs/examples/error_handling.rs2
-rw-r--r--engine-ecs/examples/event_loop.rs8
-rw-r--r--engine-ecs/examples/extension.rs2
-rw-r--r--engine-ecs/examples/multiple_queries.rs10
-rw-r--r--engine-ecs/examples/optional_component.rs8
-rw-r--r--engine-ecs/examples/relationship.rs4
-rw-r--r--engine-ecs/examples/simple.rs4
-rw-r--r--engine-ecs/examples/with_local.rs4
-rw-r--r--engine-ecs/examples/with_sole.rs8
-rw-r--r--engine-ecs/src/entity.rs22
-rw-r--r--engine-ecs/src/extension.rs12
-rw-r--r--engine-ecs/src/lib.rs17
-rw-r--r--engine-ecs/src/phase.rs8
-rw-r--r--engine-ecs/src/sole.rs18
-rw-r--r--engine-ecs/tests/query.rs112
20 files changed, 132 insertions, 133 deletions
diff --git a/engine-ecs/benches/query.rs b/engine-ecs/benches/query.rs
index bbc50ab..766ab82 100644
--- a/engine-ecs/benches/query.rs
+++ b/engine-ecs/benches/query.rs
@@ -64,7 +64,7 @@ struct EvenMoreText
fn spawn_1000_entities(world: &mut World)
{
for _ in 0..300 {
- world.create_entity((
+ world.spawn((
Bar {
_path: "/dev/zero".into(),
_num: 65789,
@@ -92,7 +92,7 @@ fn spawn_1000_entities(world: &mut World)
}
for _ in 0..700 {
- world.create_entity((
+ world.spawn((
Bar {
_path: "/dev/null".into(),
_num: 65789,
diff --git a/engine-ecs/examples/component_changed_event.rs b/engine-ecs/examples/component_changed_event.rs
index 2788505..a963b41 100644
--- a/engine-ecs/examples/component_changed_event.rs
+++ b/engine-ecs/examples/component_changed_event.rs
@@ -49,14 +49,14 @@ fn main()
world.register_observer(print_changed_greetings);
- world.create_entity((
+ world.spawn((
SomeData { num: 987_654 },
Greeting {
greeting: "Good afternoon".to_string(),
},
));
- world.create_entity((
+ world.spawn((
SomeData { num: 345 },
Greeting { greeting: "Good evening".to_string() },
));
diff --git a/engine-ecs/examples/component_events.rs b/engine-ecs/examples/component_events.rs
index 7c65630..82d9b6c 100644
--- a/engine-ecs/examples/component_events.rs
+++ b/engine-ecs/examples/component_events.rs
@@ -56,9 +56,9 @@ fn main()
world.register_observer(on_cheese_removed);
world.register_observer(on_cheese_crumbs_changed);
- world.create_entity((Cheese { name: "Brie" }, CheeseCrumbs { cnt: 0 }));
- world.create_entity((Cheese { name: "Parmesan" }, CheeseCrumbs { cnt: 0 }));
- world.create_entity((Cheese { name: "Gouda" }, CheeseCrumbs { cnt: 0 }));
+ world.spawn((Cheese { name: "Brie" }, CheeseCrumbs { cnt: 0 }));
+ world.spawn((Cheese { name: "Parmesan" }, CheeseCrumbs { cnt: 0 }));
+ world.spawn((Cheese { name: "Gouda" }, CheeseCrumbs { cnt: 0 }));
world.step();
}
diff --git a/engine-ecs/examples/component_relationship.rs b/engine-ecs/examples/component_relationship.rs
index 0f7b514..a85150e 100644
--- a/engine-ecs/examples/component_relationship.rs
+++ b/engine-ecs/examples/component_relationship.rs
@@ -37,7 +37,7 @@ fn main()
world.register_system(*START_PHASE, print_dog_likers);
- world.create_entity((
+ world.spawn((
Person { name: "Irving".to_string() },
Pair::builder()
.relation::<Likes>()
@@ -45,7 +45,7 @@ fn main()
.build(),
));
- world.create_entity((
+ world.spawn((
Person { name: "Mark".to_string() },
Pair::builder()
.relation::<Likes>()
@@ -53,7 +53,7 @@ fn main()
.build(),
));
- world.create_entity((
+ world.spawn((
Person { name: "Helena".to_string() },
Pair::builder()
.relation::<Likes>()
diff --git a/engine-ecs/examples/component_removed_event.rs b/engine-ecs/examples/component_removed_event.rs
index b15c2c3..23dfc92 100644
--- a/engine-ecs/examples/component_removed_event.rs
+++ b/engine-ecs/examples/component_removed_event.rs
@@ -37,9 +37,9 @@ fn main()
world.register_system(*UPDATE, eat_cheese);
world.register_observer(on_cheese_removed);
- world.create_entity((Cheese { name: "Brie" },));
- world.create_entity((Cheese { name: "Parmesan" },));
- world.create_entity((Cheese { name: "Gouda" },));
+ world.spawn((Cheese { name: "Brie" },));
+ world.spawn((Cheese { name: "Parmesan" },));
+ world.spawn((Cheese { name: "Gouda" },));
world.step();
world.step();
diff --git a/engine-ecs/examples/error_handling.rs b/engine-ecs/examples/error_handling.rs
index 264b12f..2025914 100644
--- a/engine-ecs/examples/error_handling.rs
+++ b/engine-ecs/examples/error_handling.rs
@@ -66,7 +66,7 @@ fn main()
world.set_err_handler(engine_ecs::error::err_handler_log_error);
- world.create_entity((State { value: 0 },));
+ world.spawn((State { value: 0 },));
world.register_system(*UPDATE, do_something_fallible);
diff --git a/engine-ecs/examples/event_loop.rs b/engine-ecs/examples/event_loop.rs
index 62d0876..5202788 100644
--- a/engine-ecs/examples/event_loop.rs
+++ b/engine-ecs/examples/event_loop.rs
@@ -102,15 +102,15 @@ fn main()
{
let mut world = World::new();
- world.create_declared_entity(&SHEER_PHASE);
- world.create_declared_entity(&FEED_PHASE);
- world.create_declared_entity(&AGE_PHASE);
+ world.spawn_declared_entity(&SHEER_PHASE);
+ world.spawn_declared_entity(&FEED_PHASE);
+ world.spawn_declared_entity(&AGE_PHASE);
world.register_system(*SHEER_PHASE, sheer);
world.register_system(*FEED_PHASE, feed);
world.register_system(*AGE_PHASE, age);
- world.create_entity((
+ world.spawn((
Wool { remaining: 30 },
Health { health: 3 },
Name { name: "Bessy" },
diff --git a/engine-ecs/examples/extension.rs b/engine-ecs/examples/extension.rs
index a96c1a7..a2447f8 100644
--- a/engine-ecs/examples/extension.rs
+++ b/engine-ecs/examples/extension.rs
@@ -54,7 +54,7 @@ impl Extension for EnemySpawningExtension
{
collector.add_system(*UPDATE_PHASE, spawn_enemies);
- collector.add_entity((Position { x: 187, y: 30 }, EnemySpawnSource));
+ collector.spawn((Position { x: 187, y: 30 }, EnemySpawnSource));
}
}
diff --git a/engine-ecs/examples/multiple_queries.rs b/engine-ecs/examples/multiple_queries.rs
index 1a4aaad..d04e43f 100644
--- a/engine-ecs/examples/multiple_queries.rs
+++ b/engine-ecs/examples/multiple_queries.rs
@@ -63,23 +63,23 @@ fn main()
world.register_system(*START_PHASE, do_attacks);
- world.create_entity((
+ world.spawn((
Health { health: 100 },
EnemyName { name: "Big spider".to_string() },
));
- world.create_entity((
+ world.spawn((
Health { health: 30 },
EnemyName { name: "Small goblin".to_string() },
));
- world.create_entity((
+ world.spawn((
Health { health: 30 },
EnemyName { name: "Headcrab".to_string() },
));
- world.create_entity((AttackStrength::Strong,));
- world.create_entity((AttackStrength::Weak,));
+ world.spawn((AttackStrength::Strong,));
+ world.spawn((AttackStrength::Weak,));
world.step();
}
diff --git a/engine-ecs/examples/optional_component.rs b/engine-ecs/examples/optional_component.rs
index 79650b9..e9ea4fb 100644
--- a/engine-ecs/examples/optional_component.rs
+++ b/engine-ecs/examples/optional_component.rs
@@ -54,24 +54,24 @@ fn main()
world.register_system(*UPDATE_PHASE, pet_cats);
- world.create_entity((
+ world.spawn((
CatName { name: "Jasper".to_string() },
Aggressivity::Medium,
PettingCapacity { capacity_left: 5 },
));
- world.create_entity((
+ world.spawn((
CatName { name: "Otto".to_string() },
PettingCapacity { capacity_left: 9 },
));
- world.create_entity((
+ world.spawn((
CatName { name: "Carrie".to_string() },
PettingCapacity { capacity_left: 2 },
Aggressivity::High,
));
- world.create_entity((
+ world.spawn((
CatName { name: "Tommy".to_string() },
PettingCapacity { capacity_left: 1 },
Aggressivity::Low,
diff --git a/engine-ecs/examples/relationship.rs b/engine-ecs/examples/relationship.rs
index 749c202..41672ef 100644
--- a/engine-ecs/examples/relationship.rs
+++ b/engine-ecs/examples/relationship.rs
@@ -41,9 +41,9 @@ fn main()
world.register_system(*START_PHASE, print_player_stats);
- let sword_uid = world.create_entity((Sword { attack_strength: 17 },));
+ let sword_uid = world.spawn((Sword { attack_strength: 17 },));
- world.create_entity((
+ world.spawn((
Player,
Health { health: 180 },
Pair::builder()
diff --git a/engine-ecs/examples/simple.rs b/engine-ecs/examples/simple.rs
index e03c003..e879ce3 100644
--- a/engine-ecs/examples/simple.rs
+++ b/engine-ecs/examples/simple.rs
@@ -26,14 +26,14 @@ fn main()
world.register_system(*START_PHASE, say_hello);
- world.create_entity((
+ world.spawn((
SomeData { num: 987_654 },
Greeting {
greeting: "Good afternoon".to_string(),
},
));
- world.create_entity((
+ world.spawn((
SomeData { num: 345 },
Greeting { greeting: "Good evening".to_string() },
));
diff --git a/engine-ecs/examples/with_local.rs b/engine-ecs/examples/with_local.rs
index 2c04f26..6d54b7a 100644
--- a/engine-ecs/examples/with_local.rs
+++ b/engine-ecs/examples/with_local.rs
@@ -61,9 +61,9 @@ fn main()
.initialize((SayHelloState { cnt: 0 },)),
);
- world.create_entity((SomeData { num: 987_654 }, Name { name: "Bob".to_string() }));
+ world.spawn((SomeData { num: 987_654 }, Name { name: "Bob".to_string() }));
- world.create_entity((SomeData { num: 345 },));
+ world.spawn((SomeData { num: 345 },));
world.step();
world.step();
diff --git a/engine-ecs/examples/with_sole.rs b/engine-ecs/examples/with_sole.rs
index 4b2fa44..b76d9dc 100644
--- a/engine-ecs/examples/with_sole.rs
+++ b/engine-ecs/examples/with_sole.rs
@@ -46,14 +46,14 @@ fn main()
{
let mut world = World::new();
- world.create_declared_entity(&PRINT_AMMO_COUNT_PHASE);
+ world.spawn_declared_entity(&PRINT_AMMO_COUNT_PHASE);
world.register_system(*UPDATE_PHASE, count_ammo);
world.register_system(*PRINT_AMMO_COUNT_PHASE, print_total_ammo_count);
- world.create_entity((Ammo { ammo_left: 4 },));
- world.create_entity((Ammo { ammo_left: 7 },));
- world.create_entity((Ammo { ammo_left: 8 },));
+ world.spawn((Ammo { ammo_left: 4 },));
+ world.spawn((Ammo { ammo_left: 7 },));
+ world.spawn((Ammo { ammo_left: 8 },));
world.add_sole(AmmoCounter::default()).unwrap();
diff --git a/engine-ecs/src/entity.rs b/engine-ecs/src/entity.rs
index 9ef9da0..b9829e1 100644
--- a/engine-ecs/src/entity.rs
+++ b/engine-ecs/src/entity.rs
@@ -3,16 +3,12 @@ use std::borrow::Cow;
use std::ops::Deref;
use std::sync::LazyLock;
-use crate::Component;
use crate::component::storage::archetype::{
Archetype,
Entity as ArchetypeEntity,
MatchingComponentIter as ArchetypeMatchingComponentIter,
};
-use crate::component::{
- Handle as ComponentHandle,
- HandleMut as ComponentHandleMut,
-};
+use crate::component::{Handle as ComponentHandle, HandleMut as ComponentHandleMut};
use crate::pair::{
ComponentOrWildcard,
MultipleWithWildcard as PairMultipleWithWildcard,
@@ -20,7 +16,7 @@ use crate::pair::{
WithWildcard as PairWithWildcard,
};
use crate::uid::Uid;
-use crate::{EntityComponentRef, World};
+use crate::{Component, EntityComponentRef, World};
pub mod obtainer;
@@ -288,22 +284,22 @@ impl<'a> Iterator for MatchingComponentIter<'a>
pub struct Declaration
{
uid: LazyLock<Uid>,
- create_func: fn(&mut World),
+ spawn_func: fn(&mut World),
}
impl Declaration
{
- pub(crate) fn create(&self, world: &mut World)
+ pub(crate) fn spawn(&self, world: &mut World)
{
- (self.create_func)(world);
+ (self.spawn_func)(world);
}
#[doc(hidden)]
- pub const fn new(create_func: fn(&mut World)) -> Self
+ pub const fn new(spawn_func: fn(&mut World)) -> Self
{
Self {
uid: LazyLock::new(|| Uid::new_unique()),
- create_func,
+ spawn_func,
}
}
}
@@ -324,7 +320,7 @@ macro_rules! declare_entity {
($visibility: vis $ident: ident, $components: expr) => {
$visibility static $ident: $crate::entity::Declaration =
$crate::entity::Declaration::new(|world| {
- world.create_entity_with_uid(*$ident, $components);
+ world.spawn_with_uid(*$ident, $components);
});
}
}
@@ -333,5 +329,5 @@ macro_rules! declare_entity {
#[derive(Debug, Clone, Component)]
pub struct Name
{
- pub name: Cow<'static, str>
+ pub name: Cow<'static, str>,
}
diff --git a/engine-ecs/src/extension.rs b/engine-ecs/src/extension.rs
index 9c6614b..1975933 100644
--- a/engine-ecs/src/extension.rs
+++ b/engine-ecs/src/extension.rs
@@ -46,23 +46,23 @@ impl<'world> Collector<'world>
}
/// Adds a entity to the [`World`].
- pub fn add_entity<Comps>(&mut self, components: Comps)
+ pub fn spawn<Comps>(&mut self, components: Comps)
where
Comps: ComponentSequence,
{
- self.world.create_entity(components);
+ self.world.spawn(components);
}
/// Adds a declared entity to the [`World`].
- pub fn add_declared_entity(&mut self, entity_decl: &EntityDeclaration)
+ pub fn spawn_declared_entity(&mut self, entity_decl: &EntityDeclaration)
{
- self.world.create_declared_entity(entity_decl);
+ self.world.spawn_declared_entity(entity_decl);
}
- /// Adds a globally shared singleton value to the [`World`].
+ /// Adds a singleton component to the [`World`].
///
/// # Errors
- /// Returns `Err` if this [`Sole`] has already been added.
+ /// Returns `Err` if the [`Sole`] already exists.
pub fn add_sole<SoleT>(&mut self, sole: SoleT) -> Result<(), SoleAlreadyExistsError>
where
SoleT: Sole,
diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs
index 88acca9..190eab7 100644
--- a/engine-ecs/src/lib.rs
+++ b/engine-ecs/src/lib.rs
@@ -127,13 +127,13 @@ impl World
/// 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
+ pub fn spawn<Comps>(&mut self, components: Comps) -> Uid
where
Comps: ComponentSequence,
{
let entity_uid = Uid::new_unique();
- self.create_entity_with_uid(entity_uid, components);
+ self.spawn_with_uid(entity_uid, components);
entity_uid
}
@@ -141,7 +141,7 @@ impl World
/// Creates a entity with the given components. The entity will have the specified
/// [`Uid`].
#[tracing::instrument(skip_all)]
- pub fn create_entity_with_uid<Comps>(&mut self, entity_uid: Uid, components: Comps)
+ pub fn spawn_with_uid<Comps>(&mut self, entity_uid: Uid, components: Comps)
where
Comps: ComponentSequence,
{
@@ -158,12 +158,12 @@ impl World
);
}
- pub fn create_declared_entity(&mut self, entity_decl: &EntityDeclaration)
+ pub fn spawn_declared_entity(&mut self, entity_decl: &EntityDeclaration)
{
- entity_decl.create(self);
+ entity_decl.spawn(self);
}
- /// Adds a singleton.
+ /// Adds a singleton component.
///
/// # Errors
/// Returns `Err` if this [`Sole`] has already been added.
@@ -214,12 +214,11 @@ impl World
{
let (type_erased_system, mut system_callbacks) = system.finish();
- let system_ent_id =
- self.create_entity((SystemComponent { system: type_erased_system },));
+ let system_ent_id = self.spawn((SystemComponent { system: type_erased_system },));
system_callbacks.on_created(self, SystemMetadata { ent_id: system_ent_id });
- self.create_entity_with_uid(
+ self.spawn_with_uid(
phase_euid,
(Pair::builder()
.relation::<PhaseHasSystem>()
diff --git a/engine-ecs/src/phase.rs b/engine-ecs/src/phase.rs
index 434e728..cb87cc6 100644
--- a/engine-ecs/src/phase.rs
+++ b/engine-ecs/src/phase.rs
@@ -10,10 +10,10 @@ declare_entity!(pub POST_UPDATE, (Phase,));
pub(crate) fn spawn_entities(world: &mut World)
{
- world.create_declared_entity(&START);
- world.create_declared_entity(&PRE_UPDATE);
- world.create_declared_entity(&UPDATE);
- world.create_declared_entity(&POST_UPDATE);
+ world.spawn_declared_entity(&START);
+ world.spawn_declared_entity(&PRE_UPDATE);
+ world.spawn_declared_entity(&UPDATE);
+ world.spawn_declared_entity(&POST_UPDATE);
}
#[derive(Debug, Component)]
diff --git a/engine-ecs/src/sole.rs b/engine-ecs/src/sole.rs
index 9409bcb..21dafc9 100644
--- a/engine-ecs/src/sole.rs
+++ b/engine-ecs/src/sole.rs
@@ -2,13 +2,15 @@ use std::any::{type_name, Any};
use std::fmt::Debug;
use std::ops::{Deref, DerefMut};
-use crate::uid::Uid;
-use crate::component::HandleMut as ComponentHandleMut;
-use crate::component::IntoParts as IntoComponentParts;
+use crate::component::{
+ HandleMut as ComponentHandleMut,
+ IntoParts as IntoComponentParts,
+};
use crate::system::{Metadata as SystemMetadata, Param as SystemParam};
+use crate::uid::Uid;
use crate::World;
-/// A type which has a single instance and is shared globally.
+/// A component which has a single instance in the [`World`].
pub trait Sole: Any + IntoComponentParts
{
fn id() -> Uid
@@ -49,14 +51,13 @@ impl Debug for dyn Sole
}
}
-/// Holds a reference to a globally shared singleton value.
+/// Holds a reference to a singleton component.
#[derive(Debug)]
pub struct Single<'world, SoleT: Sole>
{
sole: ComponentHandleMut<'world, SoleT>,
}
-
impl<'world, SoleT> Single<'world, SoleT>
where
SoleT: Sole,
@@ -79,7 +80,10 @@ where
.get_entity(SoleT::id())
.and_then(|ent| ent.get_with_id_mut::<SoleT>(SoleT::id()))
.unwrap_or_else(|| {
- panic!("Sole component {} was not found in world", type_name::<SoleT>())
+ panic!(
+ "Sole component {} was not found in world",
+ type_name::<SoleT>()
+ )
});
Self::new(sole)
diff --git a/engine-ecs/tests/query.rs b/engine-ecs/tests/query.rs
index c7956e0..af47083 100644
--- a/engine-ecs/tests/query.rs
+++ b/engine-ecs/tests/query.rs
@@ -90,10 +90,10 @@ fn query_archetype_exists_with_edges_to_next_archetypes()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, B, C));
- let ent_2_id = world.create_entity((A, B, C, D, E));
- let ent_3_id = world.create_entity((A, B, C, E));
- let ent_4_id = world.create_entity((A, B, C, G, F));
+ let ent_1_id = world.spawn((A, B, C));
+ let ent_2_id = world.spawn((A, B, C, D, E));
+ let ent_3_id = world.spawn((A, B, C, E));
+ let ent_4_id = world.spawn((A, B, C, G, F));
assert_query_finds_ents(
world.query::<(&A, &B, &C), ()>(),
@@ -110,9 +110,9 @@ fn query_archetype_exists_with_2_comps_diff_to_next_archetype()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, B, C, D, F));
+ let ent_1_id = world.spawn((A, B, C, D, F));
- let ent_2_id = world.create_entity((A, B, F));
+ let ent_2_id = world.spawn((A, B, F));
assert_query_finds_ents(world.query::<(&A, &B, &F), ()>(), vec![ent_1_id, ent_2_id]);
}
@@ -126,9 +126,9 @@ fn query_archetype_exists_with_2_comps_diff_to_next_archetype_rev()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, B, F));
+ let ent_1_id = world.spawn((A, B, F));
- let ent_2_id = world.create_entity((A, B, C, D, F));
+ let ent_2_id = world.spawn((A, B, C, D, F));
assert_query_finds_ents(world.query::<(&A, &B, &F), ()>(), vec![ent_1_id, ent_2_id]);
}
@@ -142,9 +142,9 @@ fn query_archetype_exists_with_3_comps_diff_to_next_archetype()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, B, C, D, E, F));
+ let ent_1_id = world.spawn((A, B, C, D, E, F));
- let ent_2_id = world.create_entity((A, B, F));
+ let ent_2_id = world.spawn((A, B, F));
assert_query_finds_ents(world.query::<(&A, &B, &F), ()>(), vec![ent_1_id, ent_2_id]);
}
@@ -158,9 +158,9 @@ fn query_archetype_exists_with_3_comps_diff_to_next_archetype_rev()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, B, F));
+ let ent_1_id = world.spawn((A, B, F));
- let ent_2_id = world.create_entity((A, B, C, D, E, F));
+ let ent_2_id = world.spawn((A, B, C, D, E, F));
assert_query_finds_ents(world.query::<(&A, &B, &F), ()>(), vec![ent_1_id, ent_2_id]);
}
@@ -174,9 +174,9 @@ fn query_archetype_exists_with_4_comps_diff_to_next_archetype()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, B, C, D, E, F, G));
+ let ent_1_id = world.spawn((A, B, C, D, E, F, G));
- let ent_2_id = world.create_entity((A, B, G));
+ let ent_2_id = world.spawn((A, B, G));
assert_query_finds_ents(world.query::<(&A, &B, &G), ()>(), vec![ent_1_id, ent_2_id]);
}
@@ -190,9 +190,9 @@ fn query_archetype_exists_with_4_comps_diff_to_next_archetype_rev()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, B, G));
+ let ent_1_id = world.spawn((A, B, G));
- let ent_2_id = world.create_entity((A, B, C, D, E, F, G));
+ let ent_2_id = world.spawn((A, B, C, D, E, F, G));
assert_query_finds_ents(world.query::<(&A, &B, &G), ()>(), vec![ent_1_id, ent_2_id]);
}
@@ -206,9 +206,9 @@ fn query_archetype_exists_with_4_comps_diff_to_next_archetype_and_opt_comp()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, B, C, D, E, F, G));
+ let ent_1_id = world.spawn((A, B, C, D, E, F, G));
- let ent_2_id = world.create_entity((A, B, G));
+ let ent_2_id = world.spawn((A, B, G));
assert_query_finds_ents(
world.query::<(&A, Option<&E>, &G), ()>(),
@@ -225,12 +225,12 @@ fn query_archetype_nonexistant()
let mut world = World::new();
- world.create_entity((A, B, C));
+ world.spawn((A, B, C));
- let ent_2_id = world.create_entity((A, B, C, D, E));
- let ent_3_id = world.create_entity((A, B, C, E));
+ let ent_2_id = world.spawn((A, B, C, D, E));
+ let ent_3_id = world.spawn((A, B, C, E));
- world.create_entity((A, B, C, G, F));
+ world.spawn((A, B, C, G, F));
assert_query_finds_ents(world.query::<(&A, &E), ()>(), vec![ent_2_id, ent_3_id]);
}
@@ -244,10 +244,10 @@ fn query_archetype_nonexistant_and_opt_comp()
let mut world = World::new();
- world.create_entity((A, B, C));
- let ent_2_id = world.create_entity((A, B, C, D, E));
- let ent_3_id = world.create_entity((A, B, C, E));
- world.create_entity((A, B, C, G, F));
+ world.spawn((A, B, C));
+ let ent_2_id = world.spawn((A, B, C, D, E));
+ let ent_3_id = world.spawn((A, B, C, E));
+ world.spawn((A, B, C, G, F));
assert_query_finds_ents(
world.query::<(&A, &E, Option<&D>), ()>(),
@@ -264,13 +264,13 @@ fn query_without_comp_and_archetype_exists()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, B, C));
+ let ent_1_id = world.spawn((A, B, C));
- world.create_entity((A, B, C, E));
- world.create_entity((A, B, C, F, E));
+ world.spawn((A, B, C, E));
+ world.spawn((A, B, C, F, E));
- let ent_2_id = world.create_entity((A, B, C, G));
- let ent_3_id = world.create_entity((A, B, C, G, F));
+ let ent_2_id = world.spawn((A, B, C, G));
+ let ent_3_id = world.spawn((A, B, C, G, F));
assert_query_finds_ents(
world.query::<(&A, &B, &C), (Without<E>,)>(),
@@ -287,13 +287,13 @@ fn query_without_required_comp_and_archetype_exists()
let mut world = World::new();
- world.create_entity((A, B, C));
+ world.spawn((A, B, C));
- world.create_entity((A, B, C, E));
- world.create_entity((A, B, C, F, E));
+ world.spawn((A, B, C, E));
+ world.spawn((A, B, C, F, E));
- world.create_entity((A, B, C, G));
- world.create_entity((A, B, C, G, F));
+ world.spawn((A, B, C, G));
+ world.spawn((A, B, C, G, F));
assert_query_finds_ents(world.query::<(&A, &B), (Without<B>,)>(), vec![]);
}
@@ -307,14 +307,14 @@ fn query_without_comp_and_archetype_nonexistant()
let mut world = World::new();
- world.create_entity((A, B, C));
+ world.spawn((A, B, C));
- let ent_1_id = world.create_entity((A, B, C, E));
+ let ent_1_id = world.spawn((A, B, C, E));
- world.create_entity((A, B, C, F, E));
+ world.spawn((A, B, C, F, E));
- let ent_2_id = world.create_entity((A, B, C, G, E));
- world.create_entity((A, B, C, G, F, E));
+ let ent_2_id = world.spawn((A, B, C, G, E));
+ world.spawn((A, B, C, G, F, E));
assert_query_finds_ents(
world.query::<(&A, &E), (Without<F>,)>(),
@@ -331,32 +331,32 @@ fn query_with_wildcard_target_pair()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, C));
+ let ent_1_id = world.spawn((A, C));
- world.create_entity((B,));
+ world.spawn((B,));
- let ent_2_id = world.create_entity((
+ let ent_2_id = world.spawn((
B,
Pair::builder().relation::<G>().target_id(ent_1_id).build(),
));
- world.create_entity((
+ world.spawn((
B,
Pair::builder().relation::<F>().target_id(ent_1_id).build(),
));
- world.create_entity((
+ world.spawn((
B,
A,
C,
Pair::builder().relation::<F>().target_id(ent_1_id).build(),
));
- let ent_3_id = world.create_entity((
+ let ent_3_id = world.spawn((
B,
Pair::builder().relation::<G>().target_id(ent_2_id).build(),
));
- let ent_4_id = world.create_entity((
+ let ent_4_id = world.spawn((
B,
E,
Pair::builder().relation::<G>().target_as_data(D).build(),
@@ -377,30 +377,30 @@ fn query_with_component_target_pair()
let mut world = World::new();
- let ent_1_id = world.create_entity((A, C));
+ let ent_1_id = world.spawn((A, C));
- world.create_entity((B,));
+ world.spawn((B,));
- world.create_entity((
+ world.spawn((
B,
Pair::builder().relation::<G>().target_id(ent_1_id).build(),
));
- world.create_entity((
+ world.spawn((
B,
Pair::builder().relation::<F>().target_id(ent_1_id).build(),
));
- world.create_entity((
+ world.spawn((
B,
A,
C,
Pair::builder().relation::<F>().target_id(ent_1_id).build(),
));
- let ent_2_id = world
- .create_entity((B, Pair::builder().relation::<G>().target_as_data(F).build()));
+ let ent_2_id =
+ world.spawn((B, Pair::builder().relation::<G>().target_as_data(F).build()));
- let ent_3_id = world.create_entity((
+ let ent_3_id = world.spawn((
B,
E,
Pair::builder().relation::<G>().target_as_data(F).build(),