From 213e4cfc698f0e0f9fcfbe43cf8c49f8f331e699 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 8 Jul 2026 23:19:06 +0200 Subject: refactor(engine-ecs): rename entity creation fns to use 'spawn' terminology --- engine-ecs/tests/query.rs | 112 +++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'engine-ecs/tests') 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,)>(), @@ -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,)>(), 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,)>(), @@ -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::().target_id(ent_1_id).build(), )); - world.create_entity(( + world.spawn(( B, Pair::builder().relation::().target_id(ent_1_id).build(), )); - world.create_entity(( + world.spawn(( B, A, C, Pair::builder().relation::().target_id(ent_1_id).build(), )); - let ent_3_id = world.create_entity(( + let ent_3_id = world.spawn(( B, Pair::builder().relation::().target_id(ent_2_id).build(), )); - let ent_4_id = world.create_entity(( + let ent_4_id = world.spawn(( B, E, Pair::builder().relation::().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::().target_id(ent_1_id).build(), )); - world.create_entity(( + world.spawn(( B, Pair::builder().relation::().target_id(ent_1_id).build(), )); - world.create_entity(( + world.spawn(( B, A, C, Pair::builder().relation::().target_id(ent_1_id).build(), )); - let ent_2_id = world - .create_entity((B, Pair::builder().relation::().target_as_data(F).build())); + let ent_2_id = + world.spawn((B, Pair::builder().relation::().target_as_data(F).build())); - let ent_3_id = world.create_entity(( + let ent_3_id = world.spawn(( B, E, Pair::builder().relation::().target_as_data(F).build(), -- cgit v1.2.3-18-g5258