summaryrefslogtreecommitdiff
path: root/ecs/examples/event_loop.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-12-09 14:05:33 +0100
committerHampusM <hampus@hampusmat.com>2024-12-09 14:05:33 +0100
commitdcc40c9205e5f4cf484523f97eb12a561d7b2b22 (patch)
tree2908b6ca3b2fa390a45b383b91edf7a72c42ef4b /ecs/examples/event_loop.rs
parent158e36bf6bfcbc2ed0ffc670788ed8c0abd3f282 (diff)
refactor(ecs): use phases for system ordering
Diffstat (limited to 'ecs/examples/event_loop.rs')
-rw-r--r--ecs/examples/event_loop.rs37
1 files changed, 19 insertions, 18 deletions
diff --git a/ecs/examples/event_loop.rs b/ecs/examples/event_loop.rs
index 8d8d84f..c9f7757 100644
--- a/ecs/examples/event_loop.rs
+++ b/ecs/examples/event_loop.rs
@@ -1,6 +1,7 @@
use ecs::actions::Actions;
-use ecs::event::Event;
-use ecs::{Component, Query, World};
+use ecs::phase::{Phase, UPDATE as UPDATE_PHASE};
+use ecs::relationship::{ChildOf, Relationship};
+use ecs::{static_entity, Component, Query, World};
#[derive(Component)]
struct Wool
@@ -64,28 +65,28 @@ fn age(query: Query<(Health, Name)>, mut actions: Actions)
}
}
-#[derive(Debug)]
-struct EventA;
+static_entity!(
+ SHEER_PHASE,
+ (Phase, <Relationship<ChildOf, Phase>>::new(*UPDATE_PHASE))
+);
-impl Event for EventA {}
+static_entity!(
+ FEED_PHASE,
+ (Phase, <Relationship<ChildOf, Phase>>::new(*SHEER_PHASE))
+);
-#[derive(Debug)]
-struct EventB;
-
-impl Event for EventB {}
-
-#[derive(Debug)]
-struct EventC;
-
-impl Event for EventC {}
+static_entity!(
+ AGE_PHASE,
+ (Phase, <Relationship<ChildOf, Phase>>::new(*FEED_PHASE))
+);
fn main()
{
let mut world = World::new();
- world.register_system(EventA, sheer);
- world.register_system(EventB, feed);
- world.register_system(EventC, age);
+ world.register_system(*SHEER_PHASE, sheer);
+ world.register_system(*FEED_PHASE, feed);
+ world.register_system(*AGE_PHASE, age);
world.create_entity((
Wool { remaining: 30 },
@@ -93,5 +94,5 @@ fn main()
Name { name: "Bessy" },
));
- world.event_loop::<(EventA, EventB, EventC)>();
+ world.start_loop();
}