MASSIVE Kinematic Character Controller Update
- NEW kinematic character controller powered by rapier3d at kinematic_character_controller.rs - NEW camera modes. The ability to switch between the free debug camera and new character controller. - NEW keybinds system to support the camera mode swap
This commit is contained in:
parent
db1b427e2a
commit
f503c70a9b
12 changed files with 323 additions and 26 deletions
52
game/src/systems/keybinds.rs
Normal file
52
game/src/systems/keybinds.rs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
use winit::keyboard::KeyCode;
|
||||
use raidillon_core::DebugUIBuffer;
|
||||
use raidillon_core::scene::Scene;
|
||||
use raidillon_ecs::components::CameraMode;
|
||||
use raidillon_engine::{EngineResources, InputState};
|
||||
use raidillon_engine::system::System;
|
||||
use raidillon_platform::Camera;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct KeybindsSystem;
|
||||
|
||||
impl System for KeybindsSystem {
|
||||
fn fixed_update(&mut self, res: &mut EngineResources, scene: &mut Scene) {
|
||||
let input = res.get::<InputState>().unwrap();
|
||||
|
||||
if input.key_held(KeyCode::F5) {
|
||||
self.toggle_camera_mode(scene);
|
||||
}
|
||||
}
|
||||
|
||||
fn frame_update(&mut self, res: &mut EngineResources, scene: &mut Scene) {
|
||||
let dbg_ui = scene.resources.get_mut::<DebugUIBuffer>().unwrap();
|
||||
|
||||
dbg_ui.text("F5 to switch camera".to_owned());
|
||||
|
||||
let mut q = scene.world.query::<(&Camera, &CameraMode)>();
|
||||
let (cam_ent, (cam, cam_mode)) = q
|
||||
.iter()
|
||||
.next()
|
||||
.unwrap();
|
||||
dbg_ui.text(format!("Camera Mode: {:?}", cam_mode));
|
||||
}
|
||||
}
|
||||
|
||||
impl KeybindsSystem {
|
||||
fn toggle_camera_mode(&mut self, scene: &mut Scene) {
|
||||
let q = scene.world.query_mut::<(&mut Camera, &mut CameraMode)>();
|
||||
let (cam_ent, (cam, cam_mode)) = q
|
||||
.into_iter()
|
||||
.next()
|
||||
.unwrap();
|
||||
|
||||
match *cam_mode {
|
||||
CameraMode::Kinematic => {
|
||||
*cam_mode = CameraMode::Debug;
|
||||
}
|
||||
CameraMode::Debug => {
|
||||
*cam_mode = CameraMode::Kinematic;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue