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
|
|
@ -1,25 +1,11 @@
|
|||
use raidillon_app::prelude::*;
|
||||
|
||||
mod systems;
|
||||
use std::fmt::format;
|
||||
use glam::{Quat, Vec3};
|
||||
use rapier3d::dynamics::{CoefficientCombineRule, RigidBodyType};
|
||||
use rapier3d::prelude::ColliderBuilder;
|
||||
use raidillon_engine::{Engine, system::System, EngineResources, InputState};
|
||||
use raidillon_engine::system::SystemContext;
|
||||
use raidillon_platform::{Platform, Camera, PlatformContext};
|
||||
use raidillon_assets::model_path;
|
||||
use raidillon_core::engine::EngineTrait;
|
||||
use raidillon_ecs::components::{CameraMode, CharacterBodyComponent, ModelHandle, RigidBodyComponent};
|
||||
use raidillon_ecs::Transform;
|
||||
use raidillon_core::scene::Scene;
|
||||
#[cfg(feature = "glium")]
|
||||
use raidillon_glium::GliumPlatform;
|
||||
use winit::event::{ElementState, Event, WindowEvent};
|
||||
use winit::event::DeviceEvent::MouseMotion;
|
||||
use winit::keyboard::{KeyCode, PhysicalKey};
|
||||
use raidillon_core::{EguiQueue};
|
||||
use winit::event::{Event, WindowEvent};
|
||||
use systems::debug_camera::FPSDebugCameraSystem;
|
||||
use raidillon_glium::RenderingSystem;
|
||||
use raidillon_physics::Physics;
|
||||
use crate::systems::{KeybindsSystem, KinematicCharacterController, PhysicsSystem};
|
||||
|
||||
const TEST_GLTF: &str = "sphere.glb";
|
||||
|
|
@ -46,9 +32,9 @@ impl System for UpdateAspectRatioSystem {
|
|||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct RenderingTestSystem;
|
||||
struct MainSystem;
|
||||
|
||||
impl System for RenderingTestSystem {
|
||||
impl System for MainSystem {
|
||||
fn load_world(&mut self, res: &mut EngineResources, scene: &mut Scene) {
|
||||
let pctx = res.get::<PlatformContext>().expect("PlatformContext missing").clone();
|
||||
let physics = scene.resources.get_mut::<Physics>().expect("Physics missing");
|
||||
|
|
@ -130,35 +116,14 @@ impl System for RenderingTestSystem {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let mut engine = Engine::new();
|
||||
// Define systems
|
||||
engine.system_manager.add::<PhysicsSystem>();
|
||||
engine.system_manager.add::<KeybindsSystem>();
|
||||
engine.system_manager.add::<KinematicCharacterController>();
|
||||
engine.system_manager.add::<FPSDebugCameraSystem>();
|
||||
engine.system_manager.add::<RenderingTestSystem>();
|
||||
engine.system_manager.add::<UpdateAspectRatioSystem>();
|
||||
// engine.system_manager.add::<InputTestSystem>();
|
||||
|
||||
// Set up the scene
|
||||
let main_scene = Scene::new(
|
||||
MAIN_SCENE_ID.to_owned(),
|
||||
None,
|
||||
);
|
||||
engine.scene_manager.add_scene(MAIN_SCENE_ID, main_scene);
|
||||
engine.scene_manager.set_active_scene(MAIN_SCENE_ID);
|
||||
|
||||
#[cfg(feature = "glium")]
|
||||
{
|
||||
let platform = GliumPlatform::initialize(
|
||||
engine,
|
||||
"Raidillon".to_string(),
|
||||
2560,
|
||||
1080,
|
||||
);
|
||||
platform.run()
|
||||
};
|
||||
|
||||
#[cfg(not(any(feature = "glium")))]
|
||||
compile_error!("No platform feature enabled.");
|
||||
raidillon_app::App::new()
|
||||
.add_system::<PhysicsSystem>()
|
||||
.add_system::<KeybindsSystem>()
|
||||
.add_system::<KinematicCharacterController>()
|
||||
.add_system::<FPSDebugCameraSystem>()
|
||||
.add_system::<MainSystem>()
|
||||
.add_system::<UpdateAspectRatioSystem>()
|
||||
.add_scene(MAIN_SCENE_ID, Scene::new(MAIN_SCENE_ID.to_owned(), None))
|
||||
.set_active_scene(MAIN_SCENE_ID)
|
||||
.run("Raidillon".to_string(), 2560, 1080);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue