automatically wield on secondary or ability3

This commit is contained in:
scott-c 2020-06-13 00:07:38 +08:00
parent 44da25729c
commit 8bcafa6f19
4 changed files with 10 additions and 7 deletions

View File

@ -11,7 +11,7 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
handle_primary_wield(data, &mut update);
handle_wield(data, &mut update);
// Try to Fall/Stand up/Move
if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 {

View File

@ -12,7 +12,7 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 1.0);
handle_jump(data, &mut update);
handle_primary_wield(data, &mut update);
handle_wield(data, &mut update);
handle_climb(data, &mut update);
handle_glide(data, &mut update);
handle_dodge_input(data, &mut update);

View File

@ -11,7 +11,7 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
handle_primary_wield(data, &mut update);
handle_wield(data, &mut update);
// Try to Fall/Stand up/Move
if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 {

View File

@ -96,10 +96,13 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
}
}
/// First checks whether `primary` input is pressed, then
/// attempts to go into Equipping state, otherwise Idle
pub fn handle_primary_wield(data: &JoinData, update: &mut StateUpdate) {
if data.inputs.primary.is_pressed() {
/// First checks whether `primary`, `secondary` or `ability3` input is pressed,
/// then attempts to go into Equipping state, otherwise Idle
pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) {
if data.inputs.primary.is_pressed()
|| data.inputs.secondary.is_pressed()
|| data.inputs.ability3.is_pressed()
{
attempt_wield(data, update);
}
}