summaryrefslogtreecommitdiff
path: root/engine/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/lib.rs')
-rw-r--r--engine/src/lib.rs60
1 files changed, 31 insertions, 29 deletions
diff --git a/engine/src/lib.rs b/engine/src/lib.rs
index abf26f5..6ccba53 100644
--- a/engine/src/lib.rs
+++ b/engine/src/lib.rs
@@ -2,46 +2,39 @@
#![allow(clippy::needless_pass_by_value)]
use ecs::component::Sequence as ComponentSequence;
-use ecs::event::component::TypeTransformComponentsToAddedEvents;
-use ecs::event::{Event, Sequence as EventSequence};
use ecs::extension::Extension;
+use ecs::pair::Pair;
+use ecs::phase::PRE_UPDATE as PRE_UPDATE_PHASE;
use ecs::sole::Sole;
use ecs::system::{Into, System};
-use ecs::tuple::Reduce as TupleReduce;
use ecs::uid::Uid;
use ecs::{SoleAlreadyExistsError, World};
+use crate::asset::{Assets, Extension as AssetExtension};
use crate::delta_time::{update as update_delta_time, DeltaTime, LastUpdate};
-use crate::event::{
- Conclude as ConcludeEvent,
- PostPresent as PostPresentEvent,
- PreUpdate as PreUpdateEvent,
- Present as PresentEvent,
- Update as UpdateEvent,
-};
mod opengl;
-mod shader_preprocessor;
mod util;
+mod work_queue;
+pub mod asset;
pub mod camera;
+pub mod collision;
pub mod data_types;
pub mod delta_time;
pub mod draw_flags;
-pub mod event;
pub mod file_format;
+pub mod image;
pub mod input;
pub mod lighting;
pub mod material;
pub mod math;
pub mod mesh;
-pub mod performance;
+pub mod model;
pub mod projection;
pub mod renderer;
-pub mod shader;
pub mod texture;
pub mod transform;
-pub mod vertex;
pub mod window;
pub extern crate ecs;
@@ -49,13 +42,7 @@ pub extern crate ecs;
pub(crate) use crate::data_types::matrix;
pub use crate::data_types::{color, vector};
-type EventOrder = (
- PreUpdateEvent,
- UpdateEvent,
- PresentEvent,
- PostPresentEvent,
- ConcludeEvent,
-);
+const INITIAL_ASSET_CAPACITY: usize = 128;
#[derive(Debug)]
pub struct Engine
@@ -74,30 +61,45 @@ impl Engine
world.add_sole(DeltaTime::default()).ok();
world.register_system(
- PreUpdateEvent,
+ *PRE_UPDATE_PHASE,
update_delta_time
.into_system()
.initialize((LastUpdate::default(),)),
);
+ let mut assets = Assets::with_capacity(INITIAL_ASSET_CAPACITY);
+
+ crate::model::set_asset_importers(&mut assets);
+ crate::image::set_asset_importers(&mut assets);
+
+ world.add_extension(AssetExtension { assets });
+
Self { world }
}
pub fn spawn<Comps>(&mut self, components: Comps) -> Uid
where
- Comps: ComponentSequence + TupleReduce<TypeTransformComponentsToAddedEvents>,
- Comps::Out: EventSequence,
+ Comps: ComponentSequence,
{
self.world.create_entity(components)
}
pub fn register_system<'this, SystemImpl>(
&'this mut self,
- event: impl Event,
+ phase_euid: Uid,
+ system: impl System<'this, SystemImpl>,
+ )
+ {
+ self.world.register_system(phase_euid, system);
+ }
+
+ pub fn register_observer_system<'this, SystemImpl>(
+ &'this mut self,
system: impl System<'this, SystemImpl>,
+ event: Pair<Uid, Uid>,
)
{
- self.world.register_system(event, system);
+ self.world.register_observer_system(system, event);
}
/// Adds a globally shared singleton value.
@@ -115,9 +117,9 @@ impl Engine
}
/// Runs the event loop.
- pub fn start(&self)
+ pub fn start(&mut self)
{
- self.world.event_loop::<EventOrder>();
+ self.world.start_loop();
}
}