groundwork for role, crun, cidle

This commit is contained in:
jshipsey 2019-06-11 00:08:55 -04:00 committed by timokoesters
parent 1f6c1188bc
commit 4de5489367
No known key found for this signature in database
GPG Key ID: CD80BE9AAEE78097
17 changed files with 463 additions and 8 deletions

View File

@ -7,6 +7,9 @@ pub enum Animation {
Jump,
Gliding,
Attack,
Roll,
Crun,
Cidle,
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]

View File

@ -5,8 +5,11 @@ use vek::*;
pub struct Controller {
pub move_dir: Vec2<f32>,
pub jump: bool,
pub glide: bool,
pub attack: bool,
pub roll: bool,
pub crun: bool,
pub cidle: bool,
pub glide: bool,
pub respawn: bool,
}

View File

@ -13,6 +13,24 @@ pub struct Attacking {
pub applied: bool,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Rolling {
pub time: f32,
pub applied: bool,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Crunning {
pub time: f32,
pub applied: bool,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Cidling {
pub time: f32,
pub applied: bool,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OnGround;
@ -35,6 +53,32 @@ impl Attacking {
}
}
impl Rolling {
pub fn start() -> Self {
Self {
time: 0.0,
applied: false,
}
}
}
impl Crunning {
pub fn start() -> Self {
Self {
time: 0.0,
applied: false,
}
}
}
impl Cidling {
pub fn start() -> Self {
Self {
time: 0.0,
applied: false,
}
}
}
impl Component for MoveDir {
type Storage = VecStorage<Self>;
}
@ -43,6 +87,15 @@ impl Component for Attacking {
type Storage = FlaggedStorage<Self, VecStorage<Self>>;
}
impl Component for Rolling {
type Storage = FlaggedStorage<Self, VecStorage<Self>>;
}
impl Component for Crunning {
type Storage = FlaggedStorage<Self, VecStorage<Self>>;
}
impl Component for Cidling {
type Storage = FlaggedStorage<Self, VecStorage<Self>>;
}
impl Component for OnGround {
type Storage = NullStorage<Self>;
}

View File

@ -18,6 +18,9 @@ pub use animation::Animation;
pub use animation::AnimationInfo;
pub use controller::Controller;
pub use inputs::Attacking;
pub use inputs::Rolling;
pub use inputs::Crunning;
pub use inputs::Cidling;
pub use inputs::Gliding;
pub use inputs::Jumping;
pub use inputs::MoveDir;

View File

@ -24,6 +24,10 @@ sphynx::sum_type! {
Player(comp::Player),
Stats(comp::Stats),
Attacking(comp::Attacking),
Rolling(comp::Rolling),
Crunning(comp::Crunning),
Cidling(comp::Cidling),
}
}
// Automatically derive From<T> for EcsCompPhantom
@ -38,6 +42,10 @@ sphynx::sum_type! {
Player(PhantomData<comp::Player>),
Stats(PhantomData<comp::Stats>),
Attacking(PhantomData<comp::Attacking>),
Rolling(PhantomData<comp::Rolling>),
Crunning(PhantomData<comp::Crunning>),
Cidling(PhantomData<comp::Cidling>),
}
}
impl sphynx::CompPacket for EcsCompPacket {

View File

@ -103,6 +103,9 @@ impl State {
ecs.register_synced::<comp::Player>();
ecs.register_synced::<comp::Stats>();
ecs.register_synced::<comp::Attacking>(); // TODO: Don't send this to the client?
ecs.register_synced::<comp::Rolling>(); // TODO: Don't send this to the client?
ecs.register_synced::<comp::Crunning>(); // TODO: Don't send this to the client?
ecs.register_synced::<comp::Cidling>(); // TODO: Don't send this to the client?
ecs.register::<comp::phys::ForceUpdate>();
// Register components synced by other means

View File

@ -1,5 +1,5 @@
use crate::{
comp::{phys, Animation, AnimationInfo, Attacking, Gliding, Jumping, OnGround},
comp::{phys, Animation, AnimationInfo, Attacking, Rolling, Crunning, Cidling, Gliding, Jumping, OnGround},
state::DeltaTime,
};
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
@ -15,20 +15,26 @@ impl<'a> System<'a> for Sys {
ReadStorage<'a, Jumping>,
ReadStorage<'a, Gliding>,
ReadStorage<'a, Attacking>,
ReadStorage<'a, Rolling>,
ReadStorage<'a, Crunning>,
ReadStorage<'a, Cidling>,
WriteStorage<'a, AnimationInfo>,
);
fn run(
&mut self,
(entities, dt, velocities, on_grounds, jumpings, glidings, attackings, mut animation_infos): Self::SystemData,
(entities, dt, velocities, on_grounds, jumpings, glidings, attackings, rollings, crunnings, cidlings, mut animation_infos): Self::SystemData,
) {
for (entity, vel, on_ground, jumping, gliding, attacking, mut animation_info) in (
for (entity, vel, on_ground, jumping, gliding, attacking, rolling, crunning, cidling, mut animation_info) in (
&entities,
&velocities,
on_grounds.maybe(),
jumpings.maybe(),
glidings.maybe(),
attackings.maybe(),
rollings.maybe(),
crunnings.maybe(),
cidlings.maybe(),
&mut animation_infos,
)
.join()
@ -52,6 +58,9 @@ impl<'a> System<'a> for Sys {
(false, _, false, false) => Animation::Jump,
(_, _, false, true) => Animation::Gliding,
(_, _, true, false) => Animation::Attack,
(true, true, false, false) => Animation::Roll,
(_, true, false, false) => Animation::Crun,
(true, false, false, false) => Animation::Cidle,
(_, _, true, true) => impossible_animation(),
};

View File

@ -1,7 +1,8 @@
use crate::{
comp::{
phys::{ForceUpdate, Ori, Pos, Vel},
Attacking, Controller, Gliding, Jumping, MoveDir, OnGround, Respawning, Stats,
Animation, AnimationInfo, Attacking, Rolling, Crunning, Cidling, Controller, Gliding, HealthSource, Jumping, MoveDir,
OnGround, Respawning, Stats,
},
state::DeltaTime,
};
@ -22,6 +23,9 @@ impl<'a> System<'a> for Sys {
WriteStorage<'a, OnGround>,
WriteStorage<'a, Jumping>,
WriteStorage<'a, Attacking>,
WriteStorage<'a, Rolling>,
WriteStorage<'a, Crunning>,
WriteStorage<'a, Cidling>,
WriteStorage<'a, Respawning>,
WriteStorage<'a, Gliding>,
WriteStorage<'a, ForceUpdate>,
@ -41,6 +45,9 @@ impl<'a> System<'a> for Sys {
mut on_grounds,
mut jumpings,
mut attackings,
mut rollings,
mut crunnings,
mut cidlings,
mut respawns,
mut glidings,
force_updates,
@ -107,6 +114,13 @@ impl<'a> System<'a> for Sys {
} else {
jumping = None;
}
// Roll
if on_grounds.get(entity).is_some() && controller.roll {
rollings.insert(entity, Rolling::start());
} else {
rollings.remove(entity);
}
}
}
}

View File

@ -1,7 +1,7 @@
use crate::{
comp::{
phys::{Ori, Pos, Vel},
Gliding, Jumping, MoveDir, OnGround, Stats,
Gliding, Jumping, MoveDir, OnGround, Stats, Rolling, Cidling, Crunning,
},
state::DeltaTime,
terrain::TerrainMap,
@ -58,7 +58,10 @@ impl<'a> System<'a> for Sys {
ReadStorage<'a, MoveDir>,
ReadStorage<'a, Jumping>,
ReadStorage<'a, Gliding>,
WriteStorage<'a, Stats>,
ReadStorage<'a, Rolling>,
ReadStorage<'a, Crunning>,
ReadStorage<'a, Cidling>,
ReadStorage<'a, Stats>,
);
fn run(
@ -74,11 +77,14 @@ impl<'a> System<'a> for Sys {
move_dirs,
jumpings,
glidings,
rollings,
crunnings,
cidlings,
stats,
): Self::SystemData,
) {
// Apply movement inputs
for (entity, mut pos, mut vel, mut ori, mut on_ground, move_dir, jumping, gliding, stats) in
for (entity, mut pos, mut vel, mut ori, mut on_ground, move_dir, jumping, gliding, rolling, crunning, cidling, stats) in
(
&entities,
&mut positions,
@ -88,6 +94,9 @@ impl<'a> System<'a> for Sys {
move_dirs.maybe(),
jumpings.maybe(),
glidings.maybe(),
rollings.maybe(),
crunnings.maybe(),
cidlings.maybe(),
&stats,
)
.join()
@ -122,6 +131,11 @@ impl<'a> System<'a> for Sys {
vel.0.z += dt.0 * lift * Vec2::<f32>::from(vel.0 * 0.15).magnitude().min(1.0);
}
// TODO:
if rolling.is_some() {}
if crunning.is_some() {}
if cidling.is_some() {}
// Set direction based on velocity
if vel.0.magnitude_squared() != 0.0 {
ori.0 = vel.0.normalized() * Vec3::new(1.0, 1.0, 0.0);

View File

@ -0,0 +1,104 @@
use super::{super::Animation, CharacterSkeleton};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct CidleAnimation;
impl Animation for CidleAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
fn update_skeleton(
skeleton: &Self::Skeleton,
global_time: f64,
anim_time: f64,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin();
let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos();
let head_look = Vec2::new(
((global_time + anim_time) as f32 / 8.0)
.floor()
.mul(7331.0)
.sin()
* 0.5,
((global_time + anim_time) as f32 / 8.0)
.floor()
.mul(1337.0)
.sin()
* 0.25,
);
next.head.offset = Vec3::new(0.0, 2.0, 11.0 + wave_ultra_slow * 0.3);
next.head.ori = Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_ultra_slow * 0.3);
next.chest.ori = Quaternion::rotation_x(0.0);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + wave_ultra_slow * 0.3);
next.belt.ori = Quaternion::rotation_x(0.0);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + wave_ultra_slow * 0.3);
next.shorts.ori = Quaternion::rotation_x(0.0);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
-7.5,
-2.0 + wave_ultra_slow_cos * 0.15,
8.0 + wave_ultra_slow * 0.5,
) / 11.0;
next.l_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * 0.06);
next.l_hand.scale = Vec3::one() / 11.0;
next.r_hand.offset = Vec3::new(
7.5,
-2.0 + wave_ultra_slow_cos * 0.15,
8.0 + wave_ultra_slow * 0.5,
) / 11.0;
next.r_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * 0.06);
next.r_hand.scale = Vec3::one() / 11.;
next.l_foot.offset = Vec3::new(-3.4, -0.1, 8.0);
next.l_foot.ori = Quaternion::identity();
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, -0.1, 8.0);
next.r_foot.ori = Quaternion::identity();
next.r_foot.scale = Vec3::one();
next.weapon.offset = Vec3::new(-7.0, -5.0, 15.0);
next.weapon.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.weapon.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(-10.0, -3.2, 2.5);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.04;
next.r_shoulder.offset = Vec3::new(0.0, -3.2, 2.5);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.04;
next.draw.offset = Vec3::new(0.0, 5.0, 0.0);
next.draw.ori = Quaternion::rotation_y(0.0);
next.draw.scale = Vec3::one() * 0.0;
next.left_equip.offset = Vec3::new(0.0, 0.0, 5.0) / 11.0;
next.left_equip.ori = Quaternion::rotation_x(0.0);;
next.left_equip.scale = Vec3::one() * 0.0;
next.right_equip.offset = Vec3::new(0.0, 0.0, 5.0) / 11.0;
next.right_equip.ori = Quaternion::rotation_x(0.0);;
next.right_equip.scale = Vec3::one() * 0.0;
next.torso.offset = Vec3::new(0.0, -0.2, 0.1);
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0;
next
}
}

View File

@ -0,0 +1,97 @@
use super::{super::Animation, CharacterSkeleton};
use std::ops::Mul;
use vek::*;
pub struct CrunAnimation;
impl Animation for CrunAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (f32, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
(velocity, global_time): Self::Dependency,
anim_time: f64,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let wave = (anim_time as f32 * 14.0).sin();
let wave_cos = (anim_time as f32 * 14.0).cos();
let head_look = Vec2::new(
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(7331.0)
.sin()
* 0.2,
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(1337.0)
.sin()
* 0.1,
);
next.head.offset = Vec3::new(0.0, 3.0, 12.0 + wave_cos * 1.3);
next.head.ori = Quaternion::rotation_z(head_look.x + wave * 0.1)
* Quaternion::rotation_x(head_look.y + 0.35);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 1.1);
next.chest.ori = Quaternion::rotation_z(wave * 0.1);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + wave_cos * 1.1);
next.belt.ori = Quaternion::rotation_z(wave * 0.25);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + wave_cos * 1.1);
next.shorts.ori = Quaternion::rotation_z(wave * 0.6);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(-9.0, 3.0 + wave_cos * 8.0, 12.0 - wave * 1.0) / 11.0;
next.l_hand.ori = Quaternion::rotation_x(wave_cos * 1.1);
next.l_hand.scale = Vec3::one() / 11.0;
next.r_hand.offset = Vec3::new(9.0, 3.0 - wave_cos * 8.0, 12.0 + wave * 1.0) / 11.0;
next.r_hand.ori = Quaternion::rotation_x(wave_cos * -1.1);
next.r_hand.scale = Vec3::one() / 11.0;
next.l_foot.offset = Vec3::new(-3.4, 0.0 + wave_cos * 1.0, 6.0);
next.l_foot.ori = Quaternion::rotation_x(-0.0 - wave_cos * 1.5);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 0.0 - wave_cos * 1.0, 6.0);
next.r_foot.ori = Quaternion::rotation_x(-0.0 + wave_cos * 1.5);
next.r_foot.scale = Vec3::one();
next.weapon.offset = Vec3::new(-7.0, -5.0, 15.0);
next.weapon.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.weapon.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(-10.0, -3.2, 2.5);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.04;
next.r_shoulder.offset = Vec3::new(0.0, -3.2, 2.5);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.04;
next.draw.offset = Vec3::new(0.0, 5.0, 0.0);
next.draw.ori = Quaternion::rotation_y(0.0);
next.draw.scale = Vec3::one() * 0.0;
next.left_equip.offset = Vec3::new(0.0, 0.0, 5.0) / 11.0;
next.left_equip.ori = Quaternion::rotation_x(0.0);;
next.left_equip.scale = Vec3::one() * 0.0;
next.right_equip.offset = Vec3::new(0.0, 0.0, 5.0) / 11.0;
next.right_equip.ori = Quaternion::rotation_x(0.0);;
next.right_equip.scale = Vec3::one() * 0.0;
next.torso.offset = Vec3::new(0.0, -0.2, 0.4);
next.torso.ori = Quaternion::rotation_x(-velocity * 0.04 - wave_cos * 0.10);
next.torso.scale = Vec3::one() / 11.0;
next
}
}

View File

@ -3,6 +3,9 @@ pub mod gliding;
pub mod idle;
pub mod jump;
pub mod run;
pub mod roll;
pub mod crun;
pub mod cidle;
// Reexports
pub use self::attack::AttackAnimation;
@ -10,6 +13,10 @@ pub use self::gliding::GlidingAnimation;
pub use self::idle::IdleAnimation;
pub use self::jump::JumpAnimation;
pub use self::run::RunAnimation;
pub use self::roll::RollAnimation;
pub use self::crun::CrunAnimation;
pub use self::cidle::CidleAnimation;
use super::{Bone, Skeleton};
use crate::render::FigureBoneData;

View File

@ -0,0 +1,98 @@
use super::{super::Animation, CharacterSkeleton};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct RollAnimation;
impl Animation for RollAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = f64;
fn update_skeleton(
skeleton: &Self::Skeleton,
global_time: f64,
anim_time: f64,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let wave = (anim_time as f32 * 4.0).sin();
let wave_quick = (anim_time as f32 * 7.0).sin();
let wave_quick_cos = (anim_time as f32 * 7.0).cos();
let wave_cos = (anim_time as f32 * 4.0).cos();
let wave_slow = (anim_time as f32 * 2.0 + PI).sin();
let wave_dub = (anim_time as f32 * 4.0).sin();
next.head.offset = Vec3::new(0.0, -1.0 + wave_slow * -3.0, 16.0 + wave_dub * -3.0);
next.head.ori = Quaternion::rotation_x(wave_dub * -0.4);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_dub * -1.5);
next.chest.ori = Quaternion::rotation_x(wave_dub * -0.5);
next.chest.scale = Vec3::one() * 1.01;
next.belt.offset = Vec3::new(0.0, 0.0, 5.0);
next.belt.ori = Quaternion::rotation_x(0.0);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, 2.0);
next.shorts.ori = Quaternion::rotation_x(0.0);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
-5.5 + wave * -0.5,
-2.0 + wave_quick_cos * 5.5,
8.0 + wave_quick * -5.5,
) / 11.0;
next.l_hand.ori =
Quaternion::rotation_x(wave_slow * 6.5) * Quaternion::rotation_y(wave * 0.3);
next.l_hand.scale = Vec3::one() / 11.0;
next.r_hand.offset = Vec3::new(
5.5 + wave * 0.5,
-2.0 + wave_quick_cos * 5.5,
8.0 + wave_quick * -5.5,
) / 11.0;
next.r_hand.ori =
Quaternion::rotation_x(wave_slow * 6.5) * Quaternion::rotation_y(wave * 0.3);
next.r_hand.scale = Vec3::one() / 11.;
next.l_foot.offset = Vec3::new(-3.4, -0.1, 9.0 - 0.0 + wave * 1.2);
next.l_foot.ori = Quaternion::rotation_x(wave * 0.6);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, -0.1, 9.0 - 0.0 + wave * 1.0);
next.r_foot.ori = Quaternion::rotation_x(wave * -0.4);
next.r_foot.scale = Vec3::one();
next.weapon.offset = Vec3::new(-7.0, -7.0, 18.0);
next.weapon.ori =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_quick * 1.0);
next.weapon.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(-10.0, -3.2, 2.5);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.04;
next.r_shoulder.offset = Vec3::new(0.0, -3.2, 2.5);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.04;
next.draw.offset = Vec3::new(0.0, 5.0, 0.0);
next.draw.ori = Quaternion::rotation_y(0.0);
next.draw.scale = Vec3::one() * 0.0;
next.left_equip.offset = Vec3::new(0.0, 0.0, 5.0) / 11.0;
next.left_equip.ori = Quaternion::rotation_x(0.0);;
next.left_equip.scale = Vec3::one() * 0.0;
next.right_equip.offset = Vec3::new(0.0, 0.0, 5.0) / 11.0;
next.right_equip.ori = Quaternion::rotation_x(0.0);;
next.right_equip.scale = Vec3::one() * 0.0;
next.torso.offset = Vec3::new(0.0, -2.2, 0.1 + wave_dub * 12.0) / 11.0;
next.torso.ori = Quaternion::rotation_x(wave_slow * 6.0);
next.torso.scale = Vec3::one() / 11.0;
next
}
}

View File

@ -556,6 +556,21 @@ impl FigureMgr {
time,
animation_info.time,
),
comp::Animation::Roll => character::RollAnimation::update_skeleton(
state.skeleton_mut(),
time,
animation_info.time,
),
comp::Animation::Crun => character::CrunAnimation::update_skeleton(
state.skeleton_mut(),
(vel.0.magnitude(), time),
animation_info.time,
),
comp::Animation::Cidle => character::CidleAnimation::update_skeleton(
state.skeleton_mut(),
time,
animation_info.time,
),
comp::Animation::Gliding => {
character::GlidingAnimation::update_skeleton(
state.skeleton_mut(),

View File

@ -119,6 +119,15 @@ impl PlayState for SessionState {
self.controller.attack = state;
self.controller.respawn = state; // TODO: Don't do both
}
Event::InputUpdate(GameInput::Roll, state) => {
self.controller.roll = state;
}
Event::InputUpdate(GameInput::Crun, state) => {
self.controller.crun = state;
}
Event::InputUpdate(GameInput::Cidle, state) => {
self.controller.cidle = state;
}
Event::InputUpdate(GameInput::Jump, state) => {
self.controller.jump = state;
}

View File

@ -31,6 +31,11 @@ pub struct ControlSettings {
pub screenshot: KeyMouse,
pub toggle_ingame_ui: KeyMouse,
pub attack: KeyMouse,
pub roll: KeyMouse,
pub crun: KeyMouse,
pub cidle: KeyMouse,
}
impl Default for ControlSettings {
@ -59,6 +64,9 @@ impl Default for ControlSettings {
screenshot: KeyMouse::Key(VirtualKeyCode::F4),
toggle_ingame_ui: KeyMouse::Key(VirtualKeyCode::F6),
attack: KeyMouse::Mouse(MouseButton::Left),
roll: KeyMouse::Mouse(MouseButton::Middle),
crun: KeyMouse::Key(VirtualKeyCode::K),
cidle: KeyMouse::Key(VirtualKeyCode::J),
}
}
}

View File

@ -34,6 +34,9 @@ pub enum GameInput {
Screenshot,
ToggleIngameUi,
Attack,
Roll,
Crun,
Cidle,
Respawn,
}
@ -134,6 +137,10 @@ impl Window {
GameInput::ToggleIngameUi,
);
key_map.insert(settings.controls.attack, GameInput::Attack);
key_map.insert(settings.controls.roll, GameInput::Roll);
key_map.insert(settings.controls.crun, GameInput::Crun);
key_map.insert(settings.controls.cidle, GameInput::Cidle);
Ok(Self {
events_loop,