Merge branch 'combat' of https://gitlab.com/veloren/veloren into combat

This commit is contained in:
jshipsey 2020-03-21 15:47:28 -04:00
commit 434a3f9036
30 changed files with 35 additions and 5 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -125,6 +125,7 @@ pub struct ControllerInputs {
pub wall_leap: Input,
pub respawn: Input,
pub toggle_wield: Input,
pub swap_loadout: Input,
pub charge: Input,
pub move_dir: Vec2<f32>,
pub look_dir: Vec3<f32>,
@ -151,6 +152,7 @@ impl ControllerInputs {
self.wall_leap.tick(dt);
self.respawn.tick(dt);
self.toggle_wield.tick(dt);
self.swap_loadout.tick(dt);
self.charge.tick(dt);
}

View File

@ -86,7 +86,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) {
if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600))
{
update.vel.0.z =
(update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(BASE_HUMANOID_WATER_SPEED);
(update.vel.0.z + data.dt.0 * GRAVITY * 2.25).min(BASE_HUMANOID_WATER_SPEED);
}
}
@ -129,7 +129,7 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) {
}
}
/// Checks that player can `Glide` and updates `CharacterState` if so
/// Checks that player can Unwield and updates `CharacterState` if so
pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) {
if let CharacterState::Wielding { .. } = update.character {
if data.inputs.toggle_wield.is_pressed() {

View File

@ -160,6 +160,9 @@ impl From<&crate::settings::GamepadSettings> for ControllerSettings {
map.entry(settings.game_buttons.toggle_wield)
.or_default()
.push(GameInput::ToggleWield);
map.entry(settings.game_buttons.swap_loadout)
.or_default()
.push(GameInput::SwapLoadout);
map.entry(settings.game_buttons.charge)
.or_default()
.push(GameInput::Charge);

View File

@ -319,6 +319,26 @@ impl PlayState for SessionState {
Event::InputUpdate(GameInput::WallLeap, state) => {
self.inputs.wall_leap.set_state(state)
},
Event::InputUpdate(GameInput::ToggleWield, state) => {
self.inputs.toggle_wield.set_state(state);
},
Event::InputUpdate(GameInput::SwapLoadout, state) => {
let mut client = self.client.borrow_mut();
let entity = client.entity();
let loadout = client
.state()
.read_storage::<comp::Loadout>()
.get(entity)
.cloned();
if let Some(loadout) = loadout {
let mut new_loadout = loadout.clone();
new_loadout.second_item = loadout.active_item;
new_loadout.active_item = loadout.second_item;
client.state_mut().write_component(entity, new_loadout);
}
},
Event::InputUpdate(GameInput::Mount, true) => {
let mut client = self.client.borrow_mut();
if client.is_mounted() {
@ -384,9 +404,6 @@ impl PlayState for SessionState {
}
}
},
Event::InputUpdate(GameInput::ToggleWield, state) => {
self.inputs.toggle_wield.set_state(state)
},
Event::InputUpdate(GameInput::Charge, state) => {
self.inputs.charge.set_state(state);
},

View File

@ -50,6 +50,7 @@ pub struct ControlSettings {
pub respawn: KeyMouse,
pub interact: KeyMouse,
pub toggle_wield: KeyMouse,
pub swap_loadout: KeyMouse,
pub charge: KeyMouse,
}
@ -100,6 +101,7 @@ impl Default for ControlSettings {
respawn: KeyMouse::Key(VirtualKeyCode::Space),
interact: KeyMouse::Mouse(MouseButton::Right),
toggle_wield: KeyMouse::Key(VirtualKeyCode::T),
swap_loadout: KeyMouse::Key(VirtualKeyCode::LAlt),
charge: KeyMouse::Key(VirtualKeyCode::Key1),
}
}
@ -183,6 +185,7 @@ pub mod con_settings {
pub respawn: Button,
pub interact: Button,
pub toggle_wield: Button,
pub swap_loadout: Button,
pub charge: Button,
}
@ -268,6 +271,7 @@ pub mod con_settings {
respawn: Button::Simple(GilButton::RightTrigger2),
interact: Button::Simple(GilButton::LeftTrigger2),
toggle_wield: Button::Simple(GilButton::DPadLeft),
swap_loadout: Button::Simple(GilButton::Unknown),
charge: Button::Simple(GilButton::Unknown),
}
}

View File

@ -49,6 +49,7 @@ pub enum GameInput {
Interact,
ToggleWield,
Charge,
SwapLoadout,
}
/// Represents a key that the game menus recognise after input mapping
@ -455,6 +456,9 @@ impl Window {
map.entry(settings.controls.toggle_wield)
.or_default()
.push(GameInput::ToggleWield);
map.entry(settings.controls.swap_loadout)
.or_default()
.push(GameInput::SwapLoadout);
map.entry(settings.controls.charge)
.or_default()
.push(GameInput::Charge);