From 815d04da602c58ed8b13eeb612fe73180204039d Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 26 Feb 2024 20:05:27 +0100 Subject: fix(ecs): make Component trait not automatic & add derive macro --- ecs/examples/with_local.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'ecs/examples/with_local.rs') diff --git a/ecs/examples/with_local.rs b/ecs/examples/with_local.rs index 0bd8f66..334f129 100644 --- a/ecs/examples/with_local.rs +++ b/ecs/examples/with_local.rs @@ -1,28 +1,29 @@ use ecs::component::Local; -use ecs::system::{Input as SystemInput, Into, System}; -use ecs::{Query, World}; +use ecs::system::{Into, System}; +use ecs::{Component, Query, World}; +#[derive(Component)] struct SomeData { num: u64, } +#[derive(Component)] struct Name { name: String, } +#[derive(Component)] struct SayHelloState { cnt: usize, } -impl SystemInput for SayHelloState {} - -fn say_hello(mut query: Query<(SomeData, String)>, mut state: Local) +fn say_hello(mut query: Query<(SomeData,)>, mut state: Local) { - for (data, text) in query.iter_mut() { - println!("Hello there. Count {}: {}: {}", state.cnt, text, data.num); + for (data,) in query.iter_mut() { + println!("Hello there. Count {}: {}", state.cnt, data.num); state.cnt += 1; } @@ -64,13 +65,9 @@ fn main() .initialize((SayHelloState { cnt: 0 },)), ); - world.create_entity(( - SomeData { num: 987_654 }, - "Yoo".to_string(), - Name { name: "Bob".to_string() }, - )); + world.create_entity((SomeData { num: 987_654 }, Name { name: "Bob".to_string() })); - world.create_entity((SomeData { num: 345 }, "Haha".to_string())); + world.create_entity((SomeData { num: 345 },)); world.emit(&Event::Update); -- cgit v1.2.3-18-g5258