diff options
author | HampusM <hampus@hampusmat.com> | 2025-09-24 22:16:50 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-09-25 22:42:35 +0200 |
commit | cbed21f5e6cfb449d49087cedc867c8e50721ba9 (patch) | |
tree | 3850ac5e7907a40e4c4e5627f547bd44c37896ce /ecs/examples | |
parent | 8d76fe6be211dfc8fc57d4e2f7e312e757ca899c (diff) |
refactor(ecs): replace Pair ctor functions with builder
Diffstat (limited to 'ecs/examples')
-rw-r--r-- | ecs/examples/component_relationship.rs | 15 | ||||
-rw-r--r-- | ecs/examples/event_loop.rs | 37 | ||||
-rw-r--r-- | ecs/examples/relationship.rs | 5 | ||||
-rw-r--r-- | ecs/examples/with_sole.rs | 8 |
4 files changed, 55 insertions, 10 deletions
diff --git a/ecs/examples/component_relationship.rs b/ecs/examples/component_relationship.rs index 4453e3a..e07b214 100644 --- a/ecs/examples/component_relationship.rs +++ b/ecs/examples/component_relationship.rs @@ -39,17 +39,26 @@ fn main() world.create_entity(( Person { name: "Irving".to_string() }, - Pair::new_with_comp_target::<Likes>(Dogs { large: true }), + Pair::builder() + .relation::<Likes>() + .target_as_data(Dogs { large: true }) + .build(), )); world.create_entity(( Person { name: "Mark".to_string() }, - Pair::new_with_comp_target::<Likes>(Cats), + Pair::builder() + .relation::<Likes>() + .target_as_data(Cats) + .build(), )); world.create_entity(( Person { name: "Helena".to_string() }, - Pair::new_with_comp_target::<Likes>(Dogs { large: false }), + Pair::builder() + .relation::<Likes>() + .target_as_data(Dogs { large: false }) + .build(), )); world.step(); diff --git a/ecs/examples/event_loop.rs b/ecs/examples/event_loop.rs index cc2f7f4..bec2c00 100644 --- a/ecs/examples/event_loop.rs +++ b/ecs/examples/event_loop.rs @@ -65,11 +65,38 @@ fn age(query: Query<(&mut Health, &Name)>, mut actions: Actions) } } -declare_entity!(SHEER_PHASE, (Phase, Pair::new::<ChildOf>(*UPDATE_PHASE))); - -declare_entity!(FEED_PHASE, (Phase, Pair::new::<ChildOf>(*SHEER_PHASE))); - -declare_entity!(AGE_PHASE, (Phase, Pair::new::<ChildOf>(*FEED_PHASE))); +declare_entity!( + SHEER_PHASE, + ( + Phase, + Pair::builder() + .relation::<ChildOf>() + .target_id(*UPDATE_PHASE) + .build() + ) +); + +declare_entity!( + FEED_PHASE, + ( + Phase, + Pair::builder() + .relation::<ChildOf>() + .target_id(*SHEER_PHASE) + .build() + ) +); + +declare_entity!( + AGE_PHASE, + ( + Phase, + Pair::builder() + .relation::<ChildOf>() + .target_id(*FEED_PHASE) + .build() + ) +); fn main() { diff --git a/ecs/examples/relationship.rs b/ecs/examples/relationship.rs index dd2f77a..4e94151 100644 --- a/ecs/examples/relationship.rs +++ b/ecs/examples/relationship.rs @@ -46,7 +46,10 @@ fn main() world.create_entity(( Player, Health { health: 180 }, - Pair::new::<Holding>(sword_uid), + Pair::builder() + .relation::<Holding>() + .target_id(sword_uid) + .build(), )); world.step(); diff --git a/ecs/examples/with_sole.rs b/ecs/examples/with_sole.rs index a292f06..7e89b0a 100644 --- a/ecs/examples/with_sole.rs +++ b/ecs/examples/with_sole.rs @@ -33,7 +33,13 @@ fn print_total_ammo_count(ammo_counter: Single<AmmoCounter>) declare_entity!( PRINT_AMMO_COUNT_PHASE, - (Phase, Pair::new::<ChildOf>(*UPDATE_PHASE)) + ( + Phase, + Pair::builder() + .relation::<ChildOf>() + .target_id(*UPDATE_PHASE) + .build() + ) ); fn main() |