fix ci test step
CI / build (push) Failing after 2m35s
Details
CI / build (push) Failing after 2m35s
Details
This commit is contained in:
parent
958c86cf73
commit
64099f598c
|
@ -3,11 +3,11 @@ use std::ptr::NonNull;
|
||||||
use lyra_engine::{
|
use lyra_engine::{
|
||||||
assets::{gltf::Gltf, ResourceManager},
|
assets::{gltf::Gltf, ResourceManager},
|
||||||
ecs::{
|
ecs::{
|
||||||
query::{Res, ResMut, View},
|
query::{Res, View},
|
||||||
system::{BatchedSystem, Criteria, CriteriaSchedule, IntoSystem},
|
system::{BatchedSystem, Criteria, CriteriaSchedule, IntoSystem},
|
||||||
World,
|
World,
|
||||||
},
|
},
|
||||||
game::Game,
|
game::App,
|
||||||
input::{
|
input::{
|
||||||
Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource,
|
Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource,
|
||||||
InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput,
|
InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput,
|
||||||
|
@ -40,74 +40,72 @@ async fn main() {
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_MOVE_FORWARD_BACKWARD,
|
ACTLBL_MOVE_FORWARD_BACKWARD,
|
||||||
&[
|
&[
|
||||||
ActionSource::Keyboard(KeyCode::W).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyW).into_binding_modifier(1.0),
|
||||||
ActionSource::Keyboard(KeyCode::S).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyS).into_binding_modifier(-1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_MOVE_LEFT_RIGHT,
|
ACTLBL_MOVE_LEFT_RIGHT,
|
||||||
&[
|
&[
|
||||||
ActionSource::Keyboard(KeyCode::A).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyA).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::D).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyD).into_binding_modifier(1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_MOVE_UP_DOWN,
|
ACTLBL_MOVE_UP_DOWN,
|
||||||
&[
|
&[
|
||||||
ActionSource::Keyboard(KeyCode::C).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyC).into_binding_modifier(1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Z).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyZ).into_binding_modifier(-1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_LOOK_LEFT_RIGHT,
|
ACTLBL_LOOK_LEFT_RIGHT,
|
||||||
&[
|
&[
|
||||||
ActionSource::Mouse(MouseInput::Axis(MouseAxis::X)).into_binding(),
|
ActionSource::Mouse(MouseInput::Axis(MouseAxis::X)).into_binding(),
|
||||||
ActionSource::Keyboard(KeyCode::Left).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::ArrowLeft).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Right).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::ArrowRight).into_binding_modifier(1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_LOOK_UP_DOWN,
|
ACTLBL_LOOK_UP_DOWN,
|
||||||
&[
|
&[
|
||||||
ActionSource::Mouse(MouseInput::Axis(MouseAxis::Y)).into_binding(),
|
ActionSource::Mouse(MouseInput::Axis(MouseAxis::Y)).into_binding(),
|
||||||
ActionSource::Keyboard(KeyCode::Up).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::ArrowUp).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Down).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::ArrowDown).into_binding_modifier(1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_LOOK_ROLL,
|
ACTLBL_LOOK_ROLL,
|
||||||
&[
|
&[
|
||||||
ActionSource::Keyboard(KeyCode::E).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyE).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Q).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyQ).into_binding_modifier(1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
"Debug",
|
"Debug",
|
||||||
&[ActionSource::Keyboard(KeyCode::B).into_binding()],
|
&[ActionSource::Keyboard(KeyCode::KeyB).into_binding()],
|
||||||
)
|
)
|
||||||
.finish(),
|
.finish(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
let world = game.world_mut();
|
let world = &mut app.world;
|
||||||
world.add_resource(action_handler);
|
world.add_resource(action_handler);
|
||||||
game.with_plugin(InputActionPlugin);
|
app.with_plugin(InputActionPlugin);
|
||||||
};
|
};
|
||||||
|
|
||||||
Game::initialize()
|
let mut app = App::new();
|
||||||
.await
|
app.with_plugin(lyra_engine::DefaultPlugins);
|
||||||
.with_plugin(lyra_engine::DefaultPlugins)
|
app.with_plugin(setup_scene_plugin);
|
||||||
.with_plugin(setup_scene_plugin)
|
app.with_plugin(action_handler_plugin);
|
||||||
.with_plugin(action_handler_plugin)
|
//app.with_plugin(camera_debug_plugin)
|
||||||
//.with_plugin(camera_debug_plugin)
|
app.with_plugin(FreeFlyCameraPlugin);
|
||||||
.with_plugin(FreeFlyCameraPlugin)
|
app.run();
|
||||||
.run()
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_scene_plugin(app: &mut App) {
|
fn setup_scene_plugin(app: &mut App) {
|
||||||
let world = game.world_mut();
|
let world = &mut app.world;
|
||||||
let resman = world.get_resource_mut::<ResourceManager>();
|
let resman = world.get_resource_mut::<ResourceManager>().unwrap();
|
||||||
let camera_gltf = resman
|
let camera_gltf = resman
|
||||||
.request::<Gltf>("../assets/AntiqueCamera.glb")
|
.request::<Gltf>("../assets/AntiqueCamera.glb")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -141,11 +139,11 @@ fn setup_scene_plugin(app: &mut App) {
|
||||||
camera.transform.translation += math::Vec3::new(0.0, 0.0, 1.5);
|
camera.transform.translation += math::Vec3::new(0.0, 0.0, 1.5);
|
||||||
world.spawn((camera, FreeFlyCamera::default()));
|
world.spawn((camera, FreeFlyCamera::default()));
|
||||||
|
|
||||||
let fps_counter = |mut counter: ResMut<fps_counter::FPSCounter>,
|
let fps_counter = |counter: Res<fps_counter::FPSCounter>,
|
||||||
delta: Res<DeltaTime>| -> anyhow::Result<()> {
|
delta: Res<DeltaTime>| -> anyhow::Result<()> {
|
||||||
let tick = counter.tick();
|
let tick = counter.tick();
|
||||||
|
|
||||||
info!("FPS: {}, frame time: {}", tick, **delta);
|
info!("FPS: {}, frame time: {}", *tick, **delta);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
@ -169,7 +167,7 @@ fn setup_scene_plugin(app: &mut App) {
|
||||||
sys.with_system(rotate_system.into_system());
|
sys.with_system(rotate_system.into_system());
|
||||||
sys.with_system(fps_counter.into_system());
|
sys.with_system(fps_counter.into_system());
|
||||||
|
|
||||||
game.with_system("fixed_timestep", sys, &[]);
|
app.with_system("fixed_timestep", sys, &[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FixedTimestep {
|
struct FixedTimestep {
|
||||||
|
@ -212,7 +210,7 @@ impl Criteria for FixedTimestep {
|
||||||
fn can_run(&mut self, mut world: NonNull<World>, check_count: u32) -> CriteriaSchedule {
|
fn can_run(&mut self, mut world: NonNull<World>, check_count: u32) -> CriteriaSchedule {
|
||||||
let world = unsafe { world.as_mut() };
|
let world = unsafe { world.as_mut() };
|
||||||
if check_count == 0 {
|
if check_count == 0 {
|
||||||
let delta_time = world.get_resource::<DeltaTime>();
|
let delta_time = world.get_resource::<DeltaTime>().unwrap();
|
||||||
self.accumulator += **delta_time;
|
self.accumulator += **delta_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +224,7 @@ impl Criteria for FixedTimestep {
|
||||||
|
|
||||||
fn modify_world(&mut self, mut world: NonNull<World>) {
|
fn modify_world(&mut self, mut world: NonNull<World>) {
|
||||||
let world = unsafe { world.as_mut() };
|
let world = unsafe { world.as_mut() };
|
||||||
self.old_dt = world.try_get_resource().map(|r| *r);
|
self.old_dt = world.get_resource().map(|r| *r);
|
||||||
|
|
||||||
world.add_resource(DeltaTime::from(self.fixed_time));
|
world.add_resource(DeltaTime::from(self.fixed_time));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use lyra_engine::{assets::{gltf::Gltf, ResourceManager}, ecs::query::{Res, ResMut, View}, game::Game, input::{Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput}, math::{self, Quat, Transform, Vec3}, render::light::{directional::DirectionalLight, PointLight}, scene::{CameraComponent, FreeFlyCamera, FreeFlyCameraPlugin, ACTLBL_LOOK_LEFT_RIGHT, ACTLBL_LOOK_ROLL, ACTLBL_LOOK_UP_DOWN, ACTLBL_MOVE_FORWARD_BACKWARD, ACTLBL_MOVE_LEFT_RIGHT, ACTLBL_MOVE_UP_DOWN}, DeltaTime};
|
use lyra_engine::{assets::{gltf::Gltf, ResourceManager}, ecs::query::{Res, View}, game::App, input::{Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput}, math::{self, Quat, Transform, Vec3}, render::light::{directional::DirectionalLight, PointLight}, scene::{CameraComponent, FreeFlyCamera, FreeFlyCameraPlugin, ACTLBL_LOOK_LEFT_RIGHT, ACTLBL_LOOK_ROLL, ACTLBL_LOOK_UP_DOWN, ACTLBL_MOVE_FORWARD_BACKWARD, ACTLBL_MOVE_LEFT_RIGHT, ACTLBL_MOVE_UP_DOWN}, DeltaTime};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
|
@ -32,68 +32,88 @@ async fn main() {
|
||||||
.add_action(ACTLBL_LOOK_UP_DOWN, Action::new(ActionKind::Axis))
|
.add_action(ACTLBL_LOOK_UP_DOWN, Action::new(ActionKind::Axis))
|
||||||
.add_action(ACTLBL_LOOK_ROLL, Action::new(ActionKind::Axis))
|
.add_action(ACTLBL_LOOK_ROLL, Action::new(ActionKind::Axis))
|
||||||
.add_action("Debug", Action::new(ActionKind::Button))
|
.add_action("Debug", Action::new(ActionKind::Button))
|
||||||
|
.add_mapping(
|
||||||
|
ActionMapping::builder(LayoutId::from(0), ActionMappingId::from(0))
|
||||||
|
.bind(
|
||||||
|
ACTLBL_MOVE_FORWARD_BACKWARD,
|
||||||
|
&[
|
||||||
|
ActionSource::Keyboard(KeyCode::KeyW).into_binding_modifier(1.0),
|
||||||
|
ActionSource::Keyboard(KeyCode::KeyS).into_binding_modifier(-1.0),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.bind(
|
||||||
|
ACTLBL_MOVE_LEFT_RIGHT,
|
||||||
|
&[
|
||||||
|
ActionSource::Keyboard(KeyCode::KeyA).into_binding_modifier(-1.0),
|
||||||
|
ActionSource::Keyboard(KeyCode::KeyD).into_binding_modifier(1.0),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.bind(
|
||||||
|
ACTLBL_MOVE_UP_DOWN,
|
||||||
|
&[
|
||||||
|
ActionSource::Keyboard(KeyCode::KeyC).into_binding_modifier(1.0),
|
||||||
|
ActionSource::Keyboard(KeyCode::KeyZ).into_binding_modifier(-1.0),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.bind(
|
||||||
|
ACTLBL_LOOK_LEFT_RIGHT,
|
||||||
|
&[
|
||||||
|
ActionSource::Mouse(MouseInput::Axis(MouseAxis::X)).into_binding(),
|
||||||
|
ActionSource::Keyboard(KeyCode::ArrowLeft).into_binding_modifier(-1.0),
|
||||||
|
ActionSource::Keyboard(KeyCode::ArrowRight).into_binding_modifier(1.0),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.bind(
|
||||||
|
ACTLBL_LOOK_UP_DOWN,
|
||||||
|
&[
|
||||||
|
ActionSource::Mouse(MouseInput::Axis(MouseAxis::Y)).into_binding(),
|
||||||
|
ActionSource::Keyboard(KeyCode::ArrowUp).into_binding_modifier(-1.0),
|
||||||
|
ActionSource::Keyboard(KeyCode::ArrowDown).into_binding_modifier(1.0),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.bind(
|
||||||
|
ACTLBL_LOOK_ROLL,
|
||||||
|
&[
|
||||||
|
ActionSource::Keyboard(KeyCode::KeyE).into_binding_modifier(-1.0),
|
||||||
|
ActionSource::Keyboard(KeyCode::KeyQ).into_binding_modifier(1.0),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.bind(
|
||||||
|
"Debug",
|
||||||
|
&[ActionSource::Keyboard(KeyCode::KeyB).into_binding()],
|
||||||
|
)
|
||||||
|
.finish(),
|
||||||
|
)
|
||||||
|
.finish();
|
||||||
|
|
||||||
.add_mapping(ActionMapping::builder(LayoutId::from(0), ActionMappingId::from(0))
|
let world = &mut app.world;
|
||||||
.bind(ACTLBL_MOVE_FORWARD_BACKWARD, &[
|
|
||||||
ActionSource::Keyboard(KeyCode::W).into_binding_modifier(1.0),
|
|
||||||
ActionSource::Keyboard(KeyCode::S).into_binding_modifier(-1.0)
|
|
||||||
])
|
|
||||||
.bind(ACTLBL_MOVE_LEFT_RIGHT, &[
|
|
||||||
ActionSource::Keyboard(KeyCode::A).into_binding_modifier(-1.0),
|
|
||||||
ActionSource::Keyboard(KeyCode::D).into_binding_modifier(1.0)
|
|
||||||
])
|
|
||||||
.bind(ACTLBL_MOVE_UP_DOWN, &[
|
|
||||||
ActionSource::Keyboard(KeyCode::C).into_binding_modifier(1.0),
|
|
||||||
ActionSource::Keyboard(KeyCode::Z).into_binding_modifier(-1.0)
|
|
||||||
])
|
|
||||||
.bind(ACTLBL_LOOK_LEFT_RIGHT, &[
|
|
||||||
ActionSource::Mouse(MouseInput::Axis(MouseAxis::X)).into_binding(),
|
|
||||||
ActionSource::Keyboard(KeyCode::Left).into_binding_modifier(-1.0),
|
|
||||||
ActionSource::Keyboard(KeyCode::Right).into_binding_modifier(1.0),
|
|
||||||
])
|
|
||||||
.bind(ACTLBL_LOOK_UP_DOWN, &[
|
|
||||||
ActionSource::Mouse(MouseInput::Axis(MouseAxis::Y)).into_binding(),
|
|
||||||
ActionSource::Keyboard(KeyCode::Up).into_binding_modifier(-1.0),
|
|
||||||
ActionSource::Keyboard(KeyCode::Down).into_binding_modifier(1.0),
|
|
||||||
])
|
|
||||||
.bind(ACTLBL_LOOK_ROLL, &[
|
|
||||||
ActionSource::Keyboard(KeyCode::E).into_binding_modifier(-1.0),
|
|
||||||
ActionSource::Keyboard(KeyCode::Q).into_binding_modifier(1.0),
|
|
||||||
])
|
|
||||||
.bind("Debug", &[
|
|
||||||
ActionSource::Keyboard(KeyCode::B).into_binding(),
|
|
||||||
])
|
|
||||||
.finish()
|
|
||||||
).finish();
|
|
||||||
|
|
||||||
let world = game.world_mut();
|
|
||||||
world.add_resource(action_handler);
|
world.add_resource(action_handler);
|
||||||
game.with_plugin(InputActionPlugin);
|
app.with_plugin(InputActionPlugin);
|
||||||
};
|
};
|
||||||
|
|
||||||
Game::initialize().await
|
let mut app = App::new();
|
||||||
.with_plugin(lyra_engine::DefaultPlugins)
|
app.with_plugin(lyra_engine::DefaultPlugins);
|
||||||
.with_plugin(setup_scene_plugin)
|
app.with_plugin(setup_scene_plugin);
|
||||||
.with_plugin(action_handler_plugin)
|
app.with_plugin(action_handler_plugin);
|
||||||
.with_plugin(camera_debug_plugin)
|
app.with_plugin(camera_debug_plugin);
|
||||||
.with_plugin(FreeFlyCameraPlugin)
|
app.with_plugin(FreeFlyCameraPlugin);
|
||||||
.run().await;
|
app.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_scene_plugin(app: &mut App) {
|
fn setup_scene_plugin(app: &mut App) {
|
||||||
let fps_counter = |mut counter: ResMut<fps_counter::FPSCounter>, delta: Res<DeltaTime>| -> anyhow::Result<()> {
|
let fps_counter = |counter: Res<fps_counter::FPSCounter>, delta: Res<DeltaTime>| -> anyhow::Result<()> {
|
||||||
let tick = counter.tick();
|
let tick = counter.tick();
|
||||||
|
|
||||||
info!("FPS: {}, frame time: {}", tick, **delta);
|
info!("FPS: {}, frame time: {}", *tick, **delta);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
game.with_system("fps_counter", fps_counter, &[]);
|
app.with_system("fps_counter", fps_counter, &[]);
|
||||||
|
|
||||||
let world = game.world_mut();
|
let world = &mut app.world;
|
||||||
world.add_resource(fps_counter::FPSCounter::new());
|
world.add_resource(fps_counter::FPSCounter::new());
|
||||||
|
|
||||||
let resman = world.get_resource_mut::<ResourceManager>();
|
let resman = world.get_resource_mut::<ResourceManager>().unwrap();
|
||||||
let cube_gltf = resman.request::<Gltf>("../assets/texture-sep/texture-sep.gltf").unwrap();
|
let cube_gltf = resman.request::<Gltf>("../assets/texture-sep/texture-sep.gltf").unwrap();
|
||||||
|
|
||||||
cube_gltf.wait_recurse_dependencies_load();
|
cube_gltf.wait_recurse_dependencies_load();
|
||||||
|
@ -185,5 +205,5 @@ fn camera_debug_plugin(app: &mut App) {
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
game.with_system("camera_debug_trigger", sys, &[]);
|
app.with_system("camera_debug_trigger", sys, &[]);
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
use lyra_engine::{
|
use lyra_engine::{
|
||||||
assets::{gltf::Gltf, ResourceManager},
|
assets::{gltf::Gltf, ResourceManager},
|
||||||
game::Game,
|
game::App,
|
||||||
input::{
|
input::{
|
||||||
Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource,
|
Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource,
|
||||||
InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput,
|
InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput,
|
||||||
|
@ -8,7 +8,7 @@ use lyra_engine::{
|
||||||
math::{self, Quat, Transform, Vec3},
|
math::{self, Quat, Transform, Vec3},
|
||||||
render::{
|
render::{
|
||||||
graph::{ShadowCasterSettings, ShadowFilteringMode},
|
graph::{ShadowCasterSettings, ShadowFilteringMode},
|
||||||
light::{directional::DirectionalLight, PointLight, SpotLight},
|
light::{directional::DirectionalLight, SpotLight},
|
||||||
},
|
},
|
||||||
scene::{
|
scene::{
|
||||||
CameraComponent, FreeFlyCamera, FreeFlyCameraPlugin, WorldTransform,
|
CameraComponent, FreeFlyCamera, FreeFlyCameraPlugin, WorldTransform,
|
||||||
|
@ -34,74 +34,72 @@ async fn main() {
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_MOVE_FORWARD_BACKWARD,
|
ACTLBL_MOVE_FORWARD_BACKWARD,
|
||||||
&[
|
&[
|
||||||
ActionSource::Keyboard(KeyCode::W).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyW).into_binding_modifier(1.0),
|
||||||
ActionSource::Keyboard(KeyCode::S).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyS).into_binding_modifier(-1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_MOVE_LEFT_RIGHT,
|
ACTLBL_MOVE_LEFT_RIGHT,
|
||||||
&[
|
&[
|
||||||
ActionSource::Keyboard(KeyCode::A).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyA).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::D).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyD).into_binding_modifier(1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_MOVE_UP_DOWN,
|
ACTLBL_MOVE_UP_DOWN,
|
||||||
&[
|
&[
|
||||||
ActionSource::Keyboard(KeyCode::C).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyC).into_binding_modifier(1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Z).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyZ).into_binding_modifier(-1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_LOOK_LEFT_RIGHT,
|
ACTLBL_LOOK_LEFT_RIGHT,
|
||||||
&[
|
&[
|
||||||
ActionSource::Mouse(MouseInput::Axis(MouseAxis::X)).into_binding(),
|
ActionSource::Mouse(MouseInput::Axis(MouseAxis::X)).into_binding(),
|
||||||
ActionSource::Keyboard(KeyCode::Left).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::ArrowLeft).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Right).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::ArrowRight).into_binding_modifier(1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_LOOK_UP_DOWN,
|
ACTLBL_LOOK_UP_DOWN,
|
||||||
&[
|
&[
|
||||||
ActionSource::Mouse(MouseInput::Axis(MouseAxis::Y)).into_binding(),
|
ActionSource::Mouse(MouseInput::Axis(MouseAxis::Y)).into_binding(),
|
||||||
ActionSource::Keyboard(KeyCode::Up).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::ArrowUp).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Down).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::ArrowDown).into_binding_modifier(1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
ACTLBL_LOOK_ROLL,
|
ACTLBL_LOOK_ROLL,
|
||||||
&[
|
&[
|
||||||
ActionSource::Keyboard(KeyCode::E).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyE).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Q).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyQ).into_binding_modifier(1.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
"Debug",
|
"Debug",
|
||||||
&[ActionSource::Keyboard(KeyCode::B).into_binding()],
|
&[ActionSource::Keyboard(KeyCode::KeyB).into_binding()],
|
||||||
)
|
)
|
||||||
.finish(),
|
.finish(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
let world = game.world_mut();
|
let world = &mut app.world;
|
||||||
world.add_resource(action_handler);
|
world.add_resource(action_handler);
|
||||||
game.with_plugin(InputActionPlugin);
|
app.with_plugin(InputActionPlugin);
|
||||||
};
|
};
|
||||||
|
|
||||||
Game::initialize()
|
let mut app = App::new();
|
||||||
.await
|
app.with_plugin(lyra_engine::DefaultPlugins);
|
||||||
.with_plugin(lyra_engine::DefaultPlugins)
|
app.with_plugin(setup_scene_plugin);
|
||||||
.with_plugin(setup_scene_plugin)
|
app.with_plugin(action_handler_plugin);
|
||||||
.with_plugin(action_handler_plugin)
|
//app.with_plugin(camera_debug_plugin)
|
||||||
//.with_plugin(camera_debug_plugin)
|
app.with_plugin(FreeFlyCameraPlugin);
|
||||||
.with_plugin(FreeFlyCameraPlugin)
|
app.run();
|
||||||
.run()
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_scene_plugin(app: &mut App) {
|
fn setup_scene_plugin(app: &mut App) {
|
||||||
let world = game.world_mut();
|
let world = &mut app.world;
|
||||||
let resman = world.get_resource_mut::<ResourceManager>();
|
let resman = world.get_resource_mut::<ResourceManager>().unwrap();
|
||||||
|
|
||||||
/* let camera_gltf = resman
|
/* let camera_gltf = resman
|
||||||
.request::<Gltf>("../assets/AntiqueCamera.glb")
|
.request::<Gltf>("../assets/AntiqueCamera.glb")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{ptr::NonNull, thread, time::Duration};
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
use lyra_engine::{assets::gltf::Gltf, change_tracker::Ct, ecs::{query::{Res, View}, system::{Criteria, CriteriaSchedule, IntoSystem}, Component, World}, game::Game, input::{Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput}, math::{self, Quat, Transform, Vec3}, render::{light::{directional::DirectionalLight, PointLight, SpotLight}, window::{CursorGrabMode, WindowOptions}}, scene::{self, CameraComponent, FreeFlyCamera, FreeFlyCameraPlugin, WorldTransform, ACTLBL_LOOK_LEFT_RIGHT, ACTLBL_LOOK_ROLL, ACTLBL_LOOK_UP_DOWN, ACTLBL_MOVE_FORWARD_BACKWARD, ACTLBL_MOVE_LEFT_RIGHT, ACTLBL_MOVE_UP_DOWN}, DeltaTime};
|
use lyra_engine::{assets::gltf::Gltf, ecs::{query::{Res, View}, system::{Criteria, CriteriaSchedule, IntoSystem}, Component, World}, game::App, input::{Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput}, math::{self, Quat, Transform, Vec3}, render::{light::{directional::DirectionalLight, PointLight, SpotLight}, window::{CursorGrabMode, WindowOptions}}, scene::{self, CameraComponent, FreeFlyCamera, FreeFlyCameraPlugin, WorldTransform, ACTLBL_LOOK_LEFT_RIGHT, ACTLBL_LOOK_ROLL, ACTLBL_LOOK_UP_DOWN, ACTLBL_MOVE_FORWARD_BACKWARD, ACTLBL_MOVE_LEFT_RIGHT, ACTLBL_MOVE_UP_DOWN}, DeltaTime};
|
||||||
use lyra_engine::assets::ResourceManager;
|
use lyra_engine::assets::ResourceManager;
|
||||||
|
|
||||||
struct FixedTimestep {
|
struct FixedTimestep {
|
||||||
|
@ -43,7 +43,7 @@ impl Criteria for FixedTimestep {
|
||||||
fn can_run(&mut self, mut world: NonNull<World>, check_count: u32) -> CriteriaSchedule {
|
fn can_run(&mut self, mut world: NonNull<World>, check_count: u32) -> CriteriaSchedule {
|
||||||
let world = unsafe { world.as_mut() };
|
let world = unsafe { world.as_mut() };
|
||||||
if check_count == 0 {
|
if check_count == 0 {
|
||||||
let delta_time = world.get_resource::<DeltaTime>();
|
let delta_time = world.get_resource::<DeltaTime>().unwrap();
|
||||||
self.accumulator += **delta_time;
|
self.accumulator += **delta_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ impl Criteria for FixedTimestep {
|
||||||
|
|
||||||
fn modify_world(&mut self, mut world: NonNull<World>) {
|
fn modify_world(&mut self, mut world: NonNull<World>) {
|
||||||
let world = unsafe { world.as_mut() };
|
let world = unsafe { world.as_mut() };
|
||||||
self.old_dt = world.try_get_resource().map(|r| *r);
|
self.old_dt = world.get_resource().map(|r| *r);
|
||||||
|
|
||||||
world.add_resource(DeltaTime::from(self.fixed_time));
|
world.add_resource(DeltaTime::from(self.fixed_time));
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ async fn main() {
|
||||||
window_options.cursor_visible = false; */
|
window_options.cursor_visible = false; */
|
||||||
}
|
}
|
||||||
|
|
||||||
let resman = world.get_resource_mut::<ResourceManager>();
|
let resman = world.get_resource_mut::<ResourceManager>().unwrap();
|
||||||
//let diffuse_texture = resman.request::<Texture>("assets/happy-tree.png").unwrap();
|
//let diffuse_texture = resman.request::<Texture>("assets/happy-tree.png").unwrap();
|
||||||
//let antique_camera_model = resman.request::<Model>("assets/AntiqueCamera.glb").unwrap();
|
//let antique_camera_model = resman.request::<Model>("assets/AntiqueCamera.glb").unwrap();
|
||||||
//let cube_model = resman.request::<Model>("assets/cube-texture-bin.glb").unwrap();
|
//let cube_model = resman.request::<Model>("assets/cube-texture-bin.glb").unwrap();
|
||||||
|
@ -271,8 +271,8 @@ async fn main() {
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
game.with_system("camera_debug_trigger", sys, &[]);
|
app.with_system("camera_debug_trigger", sys, &[]);
|
||||||
game.with_system("update_world_transforms", scene::system_update_world_transforms, &[]);
|
app.with_system("update_world_transforms", scene::system_update_world_transforms, &[]);
|
||||||
};
|
};
|
||||||
|
|
||||||
let action_handler_plugin = |app: &mut App| {
|
let action_handler_plugin = |app: &mut App| {
|
||||||
|
@ -289,42 +289,42 @@ async fn main() {
|
||||||
|
|
||||||
.add_mapping(ActionMapping::builder(LayoutId::from(0), ActionMappingId::from(0))
|
.add_mapping(ActionMapping::builder(LayoutId::from(0), ActionMappingId::from(0))
|
||||||
.bind(ACTLBL_MOVE_FORWARD_BACKWARD, &[
|
.bind(ACTLBL_MOVE_FORWARD_BACKWARD, &[
|
||||||
ActionSource::Keyboard(KeyCode::W).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyW).into_binding_modifier(1.0),
|
||||||
ActionSource::Keyboard(KeyCode::S).into_binding_modifier(-1.0)
|
ActionSource::Keyboard(KeyCode::KeyS).into_binding_modifier(-1.0)
|
||||||
])
|
])
|
||||||
.bind(ACTLBL_MOVE_LEFT_RIGHT, &[
|
.bind(ACTLBL_MOVE_LEFT_RIGHT, &[
|
||||||
ActionSource::Keyboard(KeyCode::A).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyA).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::D).into_binding_modifier(1.0)
|
ActionSource::Keyboard(KeyCode::KeyD).into_binding_modifier(1.0)
|
||||||
])
|
])
|
||||||
.bind(ACTLBL_MOVE_UP_DOWN, &[
|
.bind(ACTLBL_MOVE_UP_DOWN, &[
|
||||||
ActionSource::Keyboard(KeyCode::C).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyC).into_binding_modifier(1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Z).into_binding_modifier(-1.0)
|
ActionSource::Keyboard(KeyCode::KeyZ).into_binding_modifier(-1.0)
|
||||||
])
|
])
|
||||||
.bind(ACTLBL_LOOK_LEFT_RIGHT, &[
|
.bind(ACTLBL_LOOK_LEFT_RIGHT, &[
|
||||||
ActionSource::Mouse(MouseInput::Axis(MouseAxis::X)).into_binding(),
|
ActionSource::Mouse(MouseInput::Axis(MouseAxis::X)).into_binding(),
|
||||||
ActionSource::Keyboard(KeyCode::Left).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::ArrowLeft).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Right).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::ArrowRight).into_binding_modifier(1.0),
|
||||||
//ActionSource::Gamepad(GamepadFormat::DualAxis, GamepadInput::Axis(GamepadAxis::RThumbstickX)).into_binding(),
|
//ActionSource::Gamepad(GamepadFormat::DualAxis, GamepadInput::Axis(GamepadAxis::RThumbstickX)).into_binding(),
|
||||||
])
|
])
|
||||||
.bind(ACTLBL_LOOK_UP_DOWN, &[
|
.bind(ACTLBL_LOOK_UP_DOWN, &[
|
||||||
ActionSource::Mouse(MouseInput::Axis(MouseAxis::Y)).into_binding(),
|
ActionSource::Mouse(MouseInput::Axis(MouseAxis::Y)).into_binding(),
|
||||||
ActionSource::Keyboard(KeyCode::Up).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::ArrowUp).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Down).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::ArrowDown).into_binding_modifier(1.0),
|
||||||
//ActionSource::Gamepad(GamepadFormat::DualAxis, GamepadInput::Axis(GamepadAxis::RThumbstickY)).into_binding(),
|
//ActionSource::Gamepad(GamepadFormat::DualAxis, GamepadInput::Axis(GamepadAxis::RThumbstickY)).into_binding(),
|
||||||
])
|
])
|
||||||
.bind(ACTLBL_LOOK_ROLL, &[
|
.bind(ACTLBL_LOOK_ROLL, &[
|
||||||
ActionSource::Keyboard(KeyCode::E).into_binding_modifier(-1.0),
|
ActionSource::Keyboard(KeyCode::KeyE).into_binding_modifier(-1.0),
|
||||||
ActionSource::Keyboard(KeyCode::Q).into_binding_modifier(1.0),
|
ActionSource::Keyboard(KeyCode::KeyQ).into_binding_modifier(1.0),
|
||||||
])
|
])
|
||||||
.bind("Debug", &[
|
.bind("Debug", &[
|
||||||
ActionSource::Keyboard(KeyCode::B).into_binding(),
|
ActionSource::Keyboard(KeyCode::KeyB).into_binding(),
|
||||||
])
|
])
|
||||||
.finish()
|
.finish()
|
||||||
).finish();
|
).finish();
|
||||||
|
|
||||||
let world = game.world_mut();
|
let world = &mut app.world;
|
||||||
world.add_resource(action_handler);
|
world.add_resource(action_handler);
|
||||||
game.with_plugin(InputActionPlugin);
|
app.with_plugin(InputActionPlugin);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* let script_test_plugin = |app: &mut App| {
|
/* let script_test_plugin = |app: &mut App| {
|
||||||
|
@ -342,13 +342,13 @@ async fn main() {
|
||||||
|
|
||||||
}; */
|
}; */
|
||||||
|
|
||||||
Game::initialize().await
|
let mut app = App::new();
|
||||||
.with_plugin(lyra_engine::DefaultPlugins)
|
app.with_plugin(lyra_engine::DefaultPlugins);
|
||||||
.with_startup_system(setup_sys.into_system())
|
app.with_startup_system(setup_sys.into_system());
|
||||||
.with_plugin(action_handler_plugin)
|
app.with_plugin(action_handler_plugin);
|
||||||
//.with_plugin(script_test_plugin)
|
//app.with_plugin(script_test_plugin)
|
||||||
//.with_plugin(fps_plugin)
|
//app.with_plugin(fps_plugin)
|
||||||
.with_plugin(camera_debug_plugin)
|
app.with_plugin(camera_debug_plugin);
|
||||||
.with_plugin(FreeFlyCameraPlugin)
|
app.with_plugin(FreeFlyCameraPlugin);
|
||||||
.run().await;
|
app.run();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue