diff options
Diffstat (limited to 'engine/src/lib.rs')
-rw-r--r-- | engine/src/lib.rs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/engine/src/lib.rs b/engine/src/lib.rs index a9a5a97..6ccba53 100644 --- a/engine/src/lib.rs +++ b/engine/src/lib.rs @@ -1,35 +1,40 @@ #![deny(clippy::all, clippy::pedantic)] #![allow(clippy::needless_pass_by_value)] -use ecs::component::{Component, Sequence as ComponentSequence}; +use ecs::component::Sequence as ComponentSequence; 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::uid::Uid; use ecs::{SoleAlreadyExistsError, World}; +use crate::asset::{Assets, Extension as AssetExtension}; use crate::delta_time::{update as update_delta_time, DeltaTime, LastUpdate}; mod opengl; 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 file_format; +pub mod image; pub mod input; pub mod lighting; pub mod material; pub mod math; pub mod mesh; +pub mod model; pub mod projection; pub mod renderer; pub mod texture; pub mod transform; -pub mod vertex; pub mod window; pub extern crate ecs; @@ -37,6 +42,8 @@ pub extern crate ecs; pub(crate) use crate::data_types::matrix; pub use crate::data_types::{color, vector}; +const INITIAL_ASSET_CAPACITY: usize = 128; + #[derive(Debug)] pub struct Engine { @@ -60,6 +67,13 @@ impl Engine .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 } } @@ -79,12 +93,11 @@ impl Engine self.world.register_system(phase_euid, system); } - pub fn register_observer_system<'this, SystemImpl, Event>( + pub fn register_observer_system<'this, SystemImpl>( &'this mut self, system: impl System<'this, SystemImpl>, - event: Event, - ) where - Event: Component, + event: Pair<Uid, Uid>, + ) { self.world.register_observer_system(system, event); } @@ -104,7 +117,7 @@ impl Engine } /// Runs the event loop. - pub fn start(&self) + pub fn start(&mut self) { self.world.start_loop(); } |