New crate: raidillon_app, refactor game/main.rs to use the new crate
This commit is contained in:
parent
82f3b27732
commit
47c3b2b111
12 changed files with 140 additions and 96 deletions
45
app/src/lib.rs
Normal file
45
app/src/lib.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
pub mod prelude;
|
||||
|
||||
pub use prelude::*;
|
||||
|
||||
pub struct App {
|
||||
pub engine: Option<Engine>,
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn new() -> Self {
|
||||
let engine = Engine::new();
|
||||
Self { engine: Some(engine) }
|
||||
}
|
||||
|
||||
pub fn add_system<S: System + Default + 'static>(&mut self) -> &mut Self {
|
||||
self.engine.as_mut().unwrap().system_manager.add::<S>();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn add_scene(&mut self, id: SceneID, scene: Scene) -> &mut Self {
|
||||
self.engine.as_mut().unwrap().scene_manager.add_scene(id, scene);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_active_scene(&mut self, id: SceneID) -> &mut Self {
|
||||
self.engine.as_mut().unwrap().scene_manager.set_active_scene(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn run(&mut self, title: String, width: u32, height: u32) {
|
||||
#[cfg(feature = "glium")]
|
||||
{
|
||||
let platform = GliumPlatform::initialize(
|
||||
self.engine.take().unwrap(),
|
||||
title,
|
||||
width,
|
||||
height,
|
||||
);
|
||||
platform.run();
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "glium")))]
|
||||
compile_error!("No platform feature enabled.");
|
||||
}
|
||||
}
|
||||
43
app/src/prelude.rs
Normal file
43
app/src/prelude.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
pub use raidillon_engine::{
|
||||
Engine,
|
||||
system::System,
|
||||
EngineResources,
|
||||
InputState,
|
||||
system::SystemContext,
|
||||
};
|
||||
|
||||
pub use raidillon_platform::{
|
||||
Platform,
|
||||
Camera,
|
||||
PlatformContext,
|
||||
TimeContext,
|
||||
};
|
||||
|
||||
pub use raidillon_assets::{
|
||||
ModelManagerRef,
|
||||
model_path,
|
||||
};
|
||||
|
||||
pub use raidillon_ecs::{
|
||||
components::{
|
||||
CameraMode,
|
||||
CharacterBodyComponent,
|
||||
ModelHandle,
|
||||
RigidBodyComponent,
|
||||
Transform,
|
||||
},
|
||||
};
|
||||
|
||||
pub use raidillon_physics::Physics;
|
||||
|
||||
pub use raidillon_core::{
|
||||
scene::{Scene, SceneID},
|
||||
EguiQueue,
|
||||
engine::EngineTrait,
|
||||
};
|
||||
|
||||
#[cfg(feature = "glium")]
|
||||
pub use raidillon_glium::{
|
||||
GliumPlatform,
|
||||
RenderingSystem,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue