summaryrefslogtreecommitdiff
path: root/ecs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs')
-rw-r--r--ecs/src/event.rs2
-rw-r--r--ecs/src/event/start.rs7
-rw-r--r--ecs/src/lib.rs6
3 files changed, 14 insertions, 1 deletions
diff --git a/ecs/src/event.rs b/ecs/src/event.rs
index 6a4c3a8..93d4545 100644
--- a/ecs/src/event.rs
+++ b/ecs/src/event.rs
@@ -6,6 +6,8 @@ use seq_macro::seq;
pub trait Event: Debug + 'static {}
+pub mod start;
+
/// The ID of a [`Event`].
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Id
diff --git a/ecs/src/event/start.rs b/ecs/src/event/start.rs
new file mode 100644
index 0000000..248dd50
--- /dev/null
+++ b/ecs/src/event/start.rs
@@ -0,0 +1,7 @@
+use crate::event::Event;
+
+/// Start event.
+#[derive(Debug, Clone, Copy)]
+pub struct Start;
+
+impl Event for Start {}
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index cf2f198..0da8b71 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -13,6 +13,7 @@ use crate::actions::Action;
use crate::component::storage::Storage as ComponentStorage;
use crate::component::{Component, Id as ComponentId, Sequence as ComponentSequence};
use crate::entity::Uid as EntityUid;
+use crate::event::start::Start as StartEvent;
use crate::event::{Event, Id as EventId, Ids, Sequence as EventSequence};
use crate::extension::{Collector as ExtensionCollector, Extension};
use crate::lock::Lock;
@@ -195,7 +196,8 @@ impl World
.make_archetype_lookup_entries();
}
- /// A event loop which runs until a stop is issued with [`Flags::stop`].
+ /// A event loop which runs until a stop is issued with [`Flags::stop`]. Before the
+ /// loop begins, [`StartEvent`] is emitted.
///
/// # Panics
/// Will panic if a internal lock cannot be acquired.
@@ -203,6 +205,8 @@ impl World
{
self.prepare();
+ self.emit(StartEvent);
+
let event_seq = EventSeq::ids();
loop {