mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
add SwapLoadout
This commit is contained in:
@ -125,6 +125,7 @@ pub struct ControllerInputs {
|
|||||||
pub wall_leap: Input,
|
pub wall_leap: Input,
|
||||||
pub respawn: Input,
|
pub respawn: Input,
|
||||||
pub toggle_wield: Input,
|
pub toggle_wield: Input,
|
||||||
|
pub swap_loadout: Input,
|
||||||
pub charge: Input,
|
pub charge: Input,
|
||||||
pub move_dir: Vec2<f32>,
|
pub move_dir: Vec2<f32>,
|
||||||
pub look_dir: Vec3<f32>,
|
pub look_dir: Vec3<f32>,
|
||||||
@ -151,6 +152,7 @@ impl ControllerInputs {
|
|||||||
self.wall_leap.tick(dt);
|
self.wall_leap.tick(dt);
|
||||||
self.respawn.tick(dt);
|
self.respawn.tick(dt);
|
||||||
self.toggle_wield.tick(dt);
|
self.toggle_wield.tick(dt);
|
||||||
|
self.swap_loadout.tick(dt);
|
||||||
self.charge.tick(dt);
|
self.charge.tick(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) {
|
||||||
if let CharacterState::Wielding { .. } = update.character {
|
if let CharacterState::Wielding { .. } = update.character {
|
||||||
if data.inputs.toggle_wield.is_pressed() {
|
if data.inputs.toggle_wield.is_pressed() {
|
||||||
@ -138,6 +138,16 @@ pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks that player can Swap and updates Loadout
|
||||||
|
pub fn handle_swap_loadout(data: &JoinData, update: &mut StateUpdate) {
|
||||||
|
if let CharacterState::Wielding { .. } = update.character {
|
||||||
|
if data.inputs.swap_loadout.is_pressed() {
|
||||||
|
//TODO
|
||||||
|
println!("YAH NAH");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Checks that player can glide and updates `CharacterState` if so
|
/// Checks that player can glide and updates `CharacterState` if so
|
||||||
pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) {
|
pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) {
|
||||||
if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character {
|
if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character {
|
||||||
|
@ -160,6 +160,9 @@ impl From<&crate::settings::GamepadSettings> for ControllerSettings {
|
|||||||
map.entry(settings.game_buttons.toggle_wield)
|
map.entry(settings.game_buttons.toggle_wield)
|
||||||
.or_default()
|
.or_default()
|
||||||
.push(GameInput::ToggleWield);
|
.push(GameInput::ToggleWield);
|
||||||
|
map.entry(settings.game_buttons.swap_loadout)
|
||||||
|
.or_default()
|
||||||
|
.push(GameInput::SwapLoadout);
|
||||||
map.entry(settings.game_buttons.charge)
|
map.entry(settings.game_buttons.charge)
|
||||||
.or_default()
|
.or_default()
|
||||||
.push(GameInput::Charge);
|
.push(GameInput::Charge);
|
||||||
|
@ -319,6 +319,27 @@ impl PlayState for SessionState {
|
|||||||
Event::InputUpdate(GameInput::WallLeap, state) => {
|
Event::InputUpdate(GameInput::WallLeap, state) => {
|
||||||
self.inputs.wall_leap.set_state(state)
|
self.inputs.wall_leap.set_state(state)
|
||||||
},
|
},
|
||||||
|
// Event::InputUpdate(GameInput::ToggleWield, state) => {
|
||||||
|
// self.inputs.toggle_wield.set_state(state);
|
||||||
|
// },
|
||||||
|
Event::InputUpdate(GameInput::ToggleWield, 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) => {
|
Event::InputUpdate(GameInput::Mount, true) => {
|
||||||
let mut client = self.client.borrow_mut();
|
let mut client = self.client.borrow_mut();
|
||||||
if client.is_mounted() {
|
if client.is_mounted() {
|
||||||
@ -384,9 +405,6 @@ impl PlayState for SessionState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Event::InputUpdate(GameInput::ToggleWield, state) => {
|
|
||||||
self.inputs.toggle_wield.set_state(state)
|
|
||||||
},
|
|
||||||
Event::InputUpdate(GameInput::Charge, state) => {
|
Event::InputUpdate(GameInput::Charge, state) => {
|
||||||
self.inputs.charge.set_state(state);
|
self.inputs.charge.set_state(state);
|
||||||
},
|
},
|
||||||
|
@ -50,6 +50,7 @@ pub struct ControlSettings {
|
|||||||
pub respawn: KeyMouse,
|
pub respawn: KeyMouse,
|
||||||
pub interact: KeyMouse,
|
pub interact: KeyMouse,
|
||||||
pub toggle_wield: KeyMouse,
|
pub toggle_wield: KeyMouse,
|
||||||
|
pub swap_loadout: KeyMouse,
|
||||||
pub charge: KeyMouse,
|
pub charge: KeyMouse,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +101,7 @@ impl Default for ControlSettings {
|
|||||||
respawn: KeyMouse::Key(VirtualKeyCode::Space),
|
respawn: KeyMouse::Key(VirtualKeyCode::Space),
|
||||||
interact: KeyMouse::Mouse(MouseButton::Right),
|
interact: KeyMouse::Mouse(MouseButton::Right),
|
||||||
toggle_wield: KeyMouse::Key(VirtualKeyCode::T),
|
toggle_wield: KeyMouse::Key(VirtualKeyCode::T),
|
||||||
|
swap_loadout: KeyMouse::Key(VirtualKeyCode::LAlt),
|
||||||
charge: KeyMouse::Key(VirtualKeyCode::Key1),
|
charge: KeyMouse::Key(VirtualKeyCode::Key1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,6 +185,7 @@ pub mod con_settings {
|
|||||||
pub respawn: Button,
|
pub respawn: Button,
|
||||||
pub interact: Button,
|
pub interact: Button,
|
||||||
pub toggle_wield: Button,
|
pub toggle_wield: Button,
|
||||||
|
pub swap_loadout: Button,
|
||||||
pub charge: Button,
|
pub charge: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +271,7 @@ pub mod con_settings {
|
|||||||
respawn: Button::Simple(GilButton::RightTrigger2),
|
respawn: Button::Simple(GilButton::RightTrigger2),
|
||||||
interact: Button::Simple(GilButton::LeftTrigger2),
|
interact: Button::Simple(GilButton::LeftTrigger2),
|
||||||
toggle_wield: Button::Simple(GilButton::DPadLeft),
|
toggle_wield: Button::Simple(GilButton::DPadLeft),
|
||||||
|
swap_loadout: Button::Simple(GilButton::Unknown),
|
||||||
charge: Button::Simple(GilButton::Unknown),
|
charge: Button::Simple(GilButton::Unknown),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ pub enum GameInput {
|
|||||||
Interact,
|
Interact,
|
||||||
ToggleWield,
|
ToggleWield,
|
||||||
Charge,
|
Charge,
|
||||||
|
SwapLoadout,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a key that the game menus recognise after input mapping
|
/// Represents a key that the game menus recognise after input mapping
|
||||||
@ -455,6 +456,9 @@ impl Window {
|
|||||||
map.entry(settings.controls.toggle_wield)
|
map.entry(settings.controls.toggle_wield)
|
||||||
.or_default()
|
.or_default()
|
||||||
.push(GameInput::ToggleWield);
|
.push(GameInput::ToggleWield);
|
||||||
|
map.entry(settings.controls.swap_loadout)
|
||||||
|
.or_default()
|
||||||
|
.push(GameInput::SwapLoadout);
|
||||||
map.entry(settings.controls.charge)
|
map.entry(settings.controls.charge)
|
||||||
.or_default()
|
.or_default()
|
||||||
.push(GameInput::Charge);
|
.push(GameInput::Charge);
|
||||||
|
Reference in New Issue
Block a user