Wielding now works again

Rolling now resumes combo states correctly again
Cleanup
This commit is contained in:
Sam 2021-03-14 16:35:28 -04:00
parent ac6e192db4
commit ecff675cc4
24 changed files with 120 additions and 303 deletions

View File

@ -123,8 +123,13 @@ pub enum InputKind {
Ability(usize) = 2,
Roll = 3,
Jump = 4,
Glide = 5,
Fly = 6,
Fly = 5,
}
impl InputKind {
pub fn is_ability(self) -> bool {
matches!(self, Self::Primary | Self::Secondary | Self::Ability(_))
}
}
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]

View File

@ -51,15 +51,6 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 0.8);
handle_jump(data, &mut update);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::BasicAura(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Buildup => {
@ -132,6 +123,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -71,15 +71,6 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 0.4);
handle_jump(data, &mut update);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::BasicBeam(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Buildup => {
@ -108,9 +99,7 @@ impl CharacterBehavior for Data {
}
},
StageSection::Cast => {
if
/* ability_key_is_pressed(data, self.static_data.ability_info.key) */
input_is_pressed(data, self.static_data.ability_info.input)
if input_is_pressed(data, self.static_data.ability_info.input)
&& (self.static_data.energy_drain <= f32::EPSILON
|| update.energy.current() > 0)
{
@ -205,6 +194,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -52,15 +52,6 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 0.7);
handle_jump(data, &mut update);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::BasicMelee(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Buildup => {
@ -177,6 +168,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -45,15 +45,6 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 0.3);
handle_jump(data, &mut update);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::BasicRanged(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Buildup => {
@ -124,6 +115,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -29,7 +29,7 @@ pub trait CharacterBehavior {
fn sneak(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
fn stand(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
fn talk(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
fn handle_input(&self, data: &JoinData, input: InputKind, _target: Option<Uid>) -> StateUpdate {
fn start_input(&self, data: &JoinData, input: InputKind, _target: Option<Uid>) -> StateUpdate {
let mut update = StateUpdate::from(data);
update.queued_inputs.insert(input);
update
@ -51,7 +51,7 @@ pub trait CharacterBehavior {
ControlAction::Sneak => self.sneak(data),
ControlAction::Stand => self.stand(data),
ControlAction::Talk => self.talk(data),
ControlAction::StartInput { input, target } => self.handle_input(data, input, target),
ControlAction::StartInput { input, target } => self.start_input(data, input, target),
ControlAction::CancelInput(input) => self.cancel_input(data, input),
}
}

View File

@ -68,21 +68,10 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 0.7);
handle_jump(data, &mut update);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::ChargedMelee(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Charge => {
if
/* ability_key_is_pressed(data, self.static_data.ability_info.key) */
input_is_pressed(data, self.static_data.ability_info.input)
if input_is_pressed(data, self.static_data.ability_info.input)
&& update.energy.current() as f32 >= self.static_data.energy_cost
&& self.timer < self.static_data.charge_duration
{
@ -109,9 +98,7 @@ impl CharacterBehavior for Data {
* self.static_data.speed) as i32,
source: EnergySource::Ability,
});
} else if
/* ability_key_is_pressed(data, self.static_data.ability_info.key) */
input_is_pressed(data, self.static_data.ability_info.input)
} else if input_is_pressed(data, self.static_data.ability_info.input)
&& update.energy.current() as f32 >= self.static_data.energy_cost
{
// Maintains charge
@ -244,6 +231,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -68,15 +68,6 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, self.static_data.move_speed);
handle_jump(data, &mut update);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::ChargedRanged(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Buildup => {
@ -99,9 +90,7 @@ impl CharacterBehavior for Data {
}
},
StageSection::Charge => {
if
/* \!ability_key_is_pressed(data, self.static_data.ability_info.key) */
!input_is_pressed(data, self.static_data.ability_info.input) && !self.exhausted {
if !input_is_pressed(data, self.static_data.ability_info.input) && !self.exhausted {
let charge_frac = (self.timer.as_secs_f32()
/ self.static_data.charge_duration.as_secs_f32())
.min(1.0);
@ -162,7 +151,7 @@ impl CharacterBehavior for Data {
..*self
});
} else if self.timer < self.static_data.charge_duration
&& /*ability_key_is_pressed(data, self.static_data.ability_info.key)*/ input_is_pressed(data, self.static_data.ability_info.input)
&& input_is_pressed(data, self.static_data.ability_info.input)
{
// Charges
update.character = CharacterState::ChargedRanged(Data {
@ -182,9 +171,7 @@ impl CharacterBehavior for Data {
* self.static_data.speed) as i32,
source: EnergySource::Ability,
});
} else if
/* ability_key_is_pressed(data, self.static_data.ability_info.key) */
input_is_pressed(data, self.static_data.ability_info.input) {
} else if input_is_pressed(data, self.static_data.ability_info.input) {
// Holds charge
update.character = CharacterState::ChargedRanged(Data {
timer: self
@ -227,6 +214,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -32,9 +32,7 @@ impl CharacterBehavior for Data {
) {
(wall_dir, climb)
} else {
if
/* data.inputs.jump.is_pressed() */
input_is_pressed(data, InputKind::Jump) {
if input_is_pressed(data, InputKind::Jump) {
// They've climbed atop something, give them a boost
update
.local_events

View File

@ -121,15 +121,6 @@ impl CharacterBehavior for Data {
handle_orientation(data, &mut update, 1.0);
handle_move(data, &mut update, 0.3);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, self.static_data.is_interruptible);
// match update.character {
// CharacterState::ComboMelee(_) => {},
// _ => {
// return update;
// },
// }
// }
let stage_index = (self.stage - 1) as usize;
@ -284,6 +275,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, self.static_data.is_interruptible);
}
update
}
}

View File

@ -74,15 +74,6 @@ impl CharacterBehavior for Data {
handle_orientation(data, &mut update, 1.0);
handle_move(data, &mut update, 0.1);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, self.static_data.is_interruptible);
// match update.character {
// CharacterState::DashMelee(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Buildup => {
@ -98,10 +89,7 @@ impl CharacterBehavior for Data {
} else {
// Transitions to charge section of stage
update.character = CharacterState::DashMelee(Data {
auto_charge: /*\!ability_key_is_pressed(
data,
self.static_data.ability_info.key,
)*/input_is_pressed(data, self.static_data.ability_info.input),
auto_charge: !input_is_pressed(data, self.static_data.ability_info.input),
timer: Duration::default(),
stage_section: StageSection::Charge,
..*self
@ -111,7 +99,7 @@ impl CharacterBehavior for Data {
StageSection::Charge => {
if (self.static_data.infinite_charge
|| self.timer < self.static_data.charge_duration)
&& (/* ability_key_is_pressed(data, self.static_data.ability_info.key) */input_is_pressed(data, self.static_data.ability_info.input)
&& (input_is_pressed(data, self.static_data.ability_info.input)
|| (self.auto_charge && self.timer < self.static_data.charge_duration))
&& update.energy.current() > 0
{
@ -266,6 +254,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, self.static_data.is_interruptible);
}
update
}
}

View File

@ -54,15 +54,6 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 0.4);
handle_jump(data, &mut update);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::HealingBeam(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Buildup => {
@ -91,9 +82,7 @@ impl CharacterBehavior for Data {
}
},
StageSection::Cast => {
if
/* ability_key_is_pressed(data, self.static_data.ability_info.key) */
input_is_pressed(data, self.static_data.ability_info.input) {
if input_is_pressed(data, self.static_data.ability_info.input) {
let speed =
self.static_data.range / self.static_data.beam_duration.as_secs_f32();
let heal = AttackEffect::new(
@ -164,6 +153,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -58,15 +58,6 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 0.3);
handle_jump(data, &mut update);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::LeapMelee(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
// Delay before leaping into the air
@ -220,6 +211,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -53,15 +53,6 @@ impl CharacterBehavior for Data {
handle_move(data, &mut update, 1.0);
handle_jump(data, &mut update);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::RepeaterRanged(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Movement => {
@ -220,6 +211,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -115,18 +115,16 @@ impl CharacterBehavior for Data {
} else {
// Done
if let Some((input, stage)) = self.was_combo {
// if ability_key_is_pressed(data, key) {
// handle_interrupt(data, &mut update, true);
// // If other states are introduced that progress
// through stages, add them
// // here
// if let CharacterState::ComboMelee(c) = &mut
// update.character {
// c.stage = stage;
// }
// } else {
// update.character = CharacterState::Wielding;
// }
if input_is_pressed(data, input) {
handle_input(data, &mut update, input);
// If other states are introduced that progress through stages, add them
// here
if let CharacterState::ComboMelee(c) = &mut update.character {
c.stage = stage;
}
} else {
update.character = CharacterState::Wielding;
}
} else if self.was_wielded {
update.character = CharacterState::Wielding;
} else if self.was_sneak {

View File

@ -60,15 +60,6 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, self.static_data.move_efficiency);
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, false);
// match update.character {
// CharacterState::Shockwave(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Buildup => {
@ -171,6 +162,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, false);
}
update
}
}

View File

@ -75,16 +75,6 @@ impl CharacterBehavior for Data {
},
}
// if !ability_key_is_pressed(data, self.static_data.ability_info.key) {
// handle_interrupt(data, &mut update, self.static_data.is_interruptible);
// match update.character {
// CharacterState::SpinMelee(_) => {},
// _ => {
// return update;
// },
// }
// }
match self.stage_section {
StageSection::Buildup => {
if self.timer < self.static_data.buildup_duration {
@ -179,7 +169,7 @@ impl CharacterBehavior for Data {
} else if update.energy.current() as f32 >= self.static_data.energy_cost
&& (self.spins_remaining != 0
|| (self.static_data.is_infinite
&& /*ability_key_is_pressed(data, self.static_data.ability_info.key)*/ input_is_pressed(data, self.static_data.ability_info.input)))
&& input_is_pressed(data, self.static_data.ability_info.input)))
{
let new_spins_remaining = if self.static_data.is_infinite {
self.spins_remaining
@ -231,6 +221,11 @@ impl CharacterBehavior for Data {
},
}
// At end of state logic so an interrupt isn't overwritten
if !input_is_pressed(data, self.static_data.ability_info.input) {
handle_state_interrupt(data, &mut update, self.static_data.is_interruptible);
}
update
}
}

View File

@ -180,9 +180,7 @@ impl Body {
pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
if let Some(depth) = data.physics.in_liquid {
swim_move(data, update, efficiency, depth);
} else if
/* data.inputs.fly.is_pressed() */
input_is_pressed(data, InputKind::Fly)
} else if input_is_pressed(data, InputKind::Fly)
&& !data.physics.on_ground
&& data.body.can_fly()
{
@ -316,14 +314,12 @@ fn fly_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
handle_orientation(data, update, 1.0);
}
/// First checks whether `primary`, `secondary`, `ability3`, or `ability4` input
/// is pressed, then attempts to go into Equipping state, otherwise Idle
/// Checks if an input related to an attack is held. If one is, moves entity
/// into wielding state
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() ||
// data.inputs.ability4.is_pressed() { attempt_wield(data, update);
// }
if data.controller.queued_inputs.iter().any(|i| i.is_ability()) {
attempt_wield(data, update);
}
}
/// If a tool is equipped, goes into Equipping state, otherwise goes to Idle
@ -421,9 +417,7 @@ pub fn attempt_glide_wield(data: &JoinData, update: &mut StateUpdate) {
/// Checks that player can jump and sends jump event if so
pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) {
if
/* data.inputs.jump.is_pressed() */
input_is_pressed(data, InputKind::Jump)
if input_is_pressed(data, InputKind::Jump)
&& data.physics.on_ground
&& !data
.physics
@ -437,7 +431,7 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) {
}
}
fn handle_ability_pressed(data: &JoinData, update: &mut StateUpdate, input: InputKind) {
fn handle_ability(data: &JoinData, update: &mut StateUpdate, input: InputKind) {
let hands = |equip_slot| match data.inventory.equipped(equip_slot).map(|i| i.kind()) {
Some(ItemKind::Tool(tool)) => Some(tool.hands),
_ => None,
@ -477,7 +471,7 @@ fn handle_ability_pressed(data: &JoinData, update: &mut StateUpdate, input: Inpu
.get(skill_index)
.cloned()
.and_then(unlocked),
InputKind::Roll | InputKind::Jump | InputKind::Glide | InputKind::Fly => None,
InputKind::Roll | InputKind::Jump | InputKind::Fly => None,
})
.map(|a| {
let tool = unwrap_tool_data(data, equip_slot).map(|t| t.kind);
@ -494,14 +488,24 @@ fn handle_ability_pressed(data: &JoinData, update: &mut StateUpdate, input: Inpu
}
}
pub fn handle_ability_input(data: &JoinData, update: &mut StateUpdate) {
if let Some(input) = data
.controller
.queued_inputs
.iter()
.find(|i| i.is_ability())
{
handle_ability(data, update, *input);
}
}
pub fn handle_input(data: &JoinData, update: &mut StateUpdate, input: InputKind) {
match input {
InputKind::Primary | InputKind::Secondary | InputKind::Ability(_) => {
handle_ability_pressed(data, update, input)
handle_ability(data, update, input)
},
InputKind::Roll => handle_dodge_input(data, update),
InputKind::Jump => handle_jump(data, update),
InputKind::Glide => attempt_glide_wield(data, update),
InputKind::Fly => {},
}
}
@ -593,12 +597,9 @@ pub fn get_crit_data(data: &JoinData, ai: AbilityInfo) -> (f32, f32) {
DEFAULT_CRIT_DATA
}
pub fn handle_interrupt(data: &JoinData, update: &mut StateUpdate, attacks_interrupt: bool) {
pub fn handle_state_interrupt(data: &JoinData, update: &mut StateUpdate, attacks_interrupt: bool) {
if attacks_interrupt {
//handle_ability1_input(data, update);
// handle_ability2_input(data, update);
// handle_ability3_input(data, update);
// handle_ability4_input(data, update);
handle_ability_input(data, update);
}
handle_dodge_input(data, update);
}

View File

@ -14,14 +14,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(&data, &mut update, 1.0);
handle_jump(&data, &mut update);
handle_climb(&data, &mut update);
//handle_ability1_input(&data, &mut update);
// handle_ability2_input(&data, &mut update);
// handle_ability3_input(&data, &mut update);
// handle_ability4_input(&data, &mut update);
handle_dodge_input(&data, &mut update);
attempt_input(&data, &mut update);
update

View File

@ -356,11 +356,6 @@ impl<'a> System<'a> for Sys {
local_emitter.append(&mut state_update.local_events);
server_emitter.append(&mut state_update.server_events);
// join_struct
// .controller
// .queued_inputs
// .append(&mut state_update.queued_inputs);
// join_struct.controller.queued_inputs.
incorporate_update(&mut join_struct, state_update);
}
}

View File

@ -589,16 +589,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Fly))
}
// controller.inputs.fly.set_state(
// self.traversal_config.can_fly
// && !read_data
// .terrain
// .ray(self.pos.0, self.pos.0 + (Vec3::unit_z() * 3.0))
// .until(Block::is_solid)
// .cast()
// .1
// .map_or(true, |b| b.is_some()),
// );
if let Some((bearing, speed)) = agent.chaser.chase(
&*read_data.terrain,
self.pos.0,
@ -624,10 +614,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(
// bearing.z > 1.5
// || self.traversal_config.can_fly && self.traversal_config.on_ground,
// );
controller.inputs.climb = Some(comp::Climb::Up);
//.filter(|_| bearing.z > 0.1 || self.physics_state.in_liquid.is_some());
@ -965,7 +951,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
agent.action_timer += dt.0;
@ -1125,7 +1110,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
controller.inputs.move_dir = Vec2::zero();
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
if let Some((bearing, speed)) = agent.chaser.chase(
@ -1150,7 +1134,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
@ -1162,7 +1145,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Roll,
target: None,
});
// controller.inputs.roll.set_state(true);
}
} else {
agent.target = None;
@ -1175,14 +1157,12 @@ impl<'a> AgentData<'a> {
controller
.actions
.push(ControlAction::CancelInput(InputKind::Secondary));
// controller.inputs.secondary.set_state(false);
agent.action_timer = 0.0;
} else if agent.action_timer > 4.0 && self.energy.current() > 10 {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer += dt.0;
} else if self
.stats
@ -1195,14 +1175,12 @@ impl<'a> AgentData<'a> {
input: InputKind::Ability(0),
target: None,
});
// controller.inputs.ability3.set_state(true);
agent.action_timer += dt.0;
} else {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
agent.action_timer += dt.0;
}
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
@ -1228,7 +1206,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
if self.body.map(|b| b.is_humanoid()).unwrap_or(false)
@ -1239,7 +1216,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Roll,
target: None,
});
// controller.inputs.roll.set_state(true);
}
} else {
agent.target = None;
@ -1252,14 +1228,12 @@ impl<'a> AgentData<'a> {
controller
.actions
.push(ControlAction::CancelInput(InputKind::Secondary));
// controller.inputs.secondary.set_state(false);
agent.action_timer = 0.0;
} else if agent.action_timer > 2.0 {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer += dt.0;
} else if self
.stats
@ -1272,14 +1246,12 @@ impl<'a> AgentData<'a> {
input: InputKind::Ability(0),
target: None,
});
// controller.inputs.ability3.set_state(true);
agent.action_timer += dt.0;
} else {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
agent.action_timer += dt.0;
}
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
@ -1306,7 +1278,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Ability(0),
target: None,
});
// controller.inputs.ability3.set_state(true);
agent.action_timer = 0.0;
} else {
agent.action_timer += dt.0;
@ -1324,7 +1295,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
}
@ -1336,7 +1306,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Roll,
target: None,
});
// controller.inputs.roll.set_state(true);
}
} else {
agent.target = None;
@ -1356,7 +1325,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Ability(0),
target: None,
});
// controller.inputs.ability3.set_state(true);
agent.action_timer += dt.0;
} else if agent.action_timer > 2.0 {
agent.action_timer = 0.0;
@ -1365,7 +1333,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
agent.action_timer += dt.0;
}
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
@ -1387,7 +1354,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer = 0.0;
} else {
agent.action_timer += dt.0;
@ -1405,7 +1371,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
}
@ -1417,7 +1382,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Roll,
target: None,
});
// controller.inputs.roll.set_state(true);
}
} else {
agent.target = None;
@ -1431,7 +1395,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Roll,
target: None,
});
// controller.inputs.roll.set_state(true);
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
@ -1454,14 +1417,12 @@ impl<'a> AgentData<'a> {
controller
.actions
.push(ControlAction::CancelInput(InputKind::Secondary));
// controller.inputs.secondary.set_state(false);
agent.action_timer = 0.0;
} else if agent.action_timer > 2.0 && self.energy.current() > 300 {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer += dt.0;
} else if self
.stats
@ -1473,23 +1434,19 @@ impl<'a> AgentData<'a> {
controller
.actions
.push(ControlAction::CancelInput(InputKind::Secondary));
// controller.inputs.secondary.set_state(false);
controller.actions.push(ControlAction::StartInput {
input: InputKind::Ability(0),
target: None,
});
// controller.inputs.ability3.set_state(true);
agent.action_timer += dt.0;
} else {
controller
.actions
.push(ControlAction::CancelInput(InputKind::Secondary));
// controller.inputs.secondary.set_state(false);
controller.actions.push(ControlAction::StartInput {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
agent.action_timer += dt.0;
}
} else {
@ -1505,7 +1462,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
}
@ -1517,7 +1473,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Roll,
target: None,
});
// controller.inputs.roll.set_state(true);
}
} else if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
if let Some((bearing, speed)) = agent.chaser.chase(
@ -1542,7 +1497,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -1557,7 +1511,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Roll,
target: None,
});
// controller.inputs.roll.set_state(true);
} else if dist_sqrd < (5.0 * min_attack_dist * self.scale).powi(2) {
if agent.action_timer < 1.5 {
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
@ -1587,19 +1540,16 @@ impl<'a> AgentData<'a> {
input: InputKind::Ability(0),
target: None,
});
// controller.inputs.ability3.set_state(true);
} else if self.energy.current() > 10 {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
} else {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
}
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
if let Some((bearing, speed)) = agent.chaser.chase(
@ -1623,7 +1573,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
} else {
controller.inputs.move_dir =
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
@ -1637,7 +1586,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
}
@ -1649,7 +1597,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Roll,
target: None,
});
// controller.inputs.roll.set_state(true);
}
} else if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
if let Some((bearing, speed)) = agent.chaser.chase(
@ -1674,7 +1621,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -1697,7 +1643,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Ability(0),
target: None,
});
// controller.inputs.ability3.set_state(true);
}
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
@ -1717,7 +1662,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer = 0.0;
} else {
agent.action_timer += dt.0;
@ -1735,7 +1679,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
}
@ -1754,7 +1697,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
} else if dist_sqrd < (radius as f32 * min_attack_dist * self.scale).powi(2) {
controller.inputs.move_dir = (self.pos.0 - tgt_pos.0)
.xy()
@ -1775,7 +1717,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer += dt.0;
} else if agent.action_timer < 2.0 * circle_time as f32 + 0.5 {
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
@ -1789,7 +1730,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer += dt.0;
} else {
agent.action_timer = 0.0;
@ -1817,7 +1757,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -1834,7 +1773,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
@ -1870,7 +1808,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
if bearing.z > 1.5 {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Jump,
@ -1881,7 +1818,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
} else {
controller.inputs.move_dir =
@ -1896,7 +1832,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -1912,21 +1847,18 @@ impl<'a> AgentData<'a> {
controller
.actions
.push(ControlAction::CancelInput(InputKind::Primary));
//controller.inputs.primary.set_state(false);
agent.action_timer = 0.0;
} else if agent.action_timer > 1.0 {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
agent.action_timer += dt.0;
} else {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer += dt.0;
}
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
@ -1957,7 +1889,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -1971,7 +1902,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
} else if dist_sqrd < (3.0 * min_attack_dist * self.scale).powi(2)
&& dist_sqrd > (2.0 * min_attack_dist * self.scale).powi(2)
{
@ -1979,7 +1909,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
.xy()
.rotated_z(-0.47 * PI)
@ -2008,7 +1937,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -2025,14 +1953,12 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer += dt.0;
} else {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
agent.action_timer += dt.0;
}
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
@ -2058,7 +1984,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -2072,13 +1997,11 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
} else if dist_sqrd < (5.0 * min_attack_dist * self.scale).powi(2) {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Ability(0),
target: None,
});
// controller.inputs.ability3.set_state(true);
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
@ -2095,7 +2018,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
controller.inputs.move_dir =
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
} else {
@ -2111,7 +2033,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
}
@ -2127,14 +2048,12 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
agent.action_timer += dt.0;
} else if agent.action_timer < 3.0 {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
agent.action_timer += dt.0;
} else {
agent.action_timer = 0.0;
@ -2162,7 +2081,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -2176,7 +2094,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Secondary,
target: None,
});
// controller.inputs.secondary.set_state(true);
} else if dist_sqrd < (7.0 * min_attack_dist * self.scale).powi(2) {
if agent.action_timer < 2.0 {
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
@ -2188,7 +2105,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
agent.action_timer += dt.0;
} else if agent.action_timer < 4.0 {
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
@ -2200,14 +2116,12 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
agent.action_timer += dt.0;
} else if agent.action_timer < 6.0 {
controller.actions.push(ControlAction::StartInput {
input: InputKind::Ability(0),
target: None,
});
// controller.inputs.ability3.set_state(true);
agent.action_timer += dt.0;
} else {
agent.action_timer = 0.0;
@ -2235,7 +2149,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -2249,7 +2162,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
@ -2273,7 +2185,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else {
@ -2286,7 +2197,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
} else {
agent.target = None;
}
@ -2298,7 +2208,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
} else {
agent.target = None;
}
@ -2316,7 +2225,6 @@ impl<'a> AgentData<'a> {
input: InputKind::Primary,
target: None,
});
//controller.inputs.primary.set_state(true);
} else {
agent.target = None;
}
@ -2354,7 +2262,6 @@ impl<'a> AgentData<'a> {
.actions
.push(ControlAction::CancelInput(InputKind::Jump))
}
// controller.inputs.jump.set_state(bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
}

View File

@ -3,7 +3,7 @@ use crate::audio::sfx::SfxEvent;
use common::{
comp::{
inventory::loadout_builder::LoadoutBuilder, item::tool::ToolKind, CharacterAbilityType,
CharacterState, Item,
CharacterState, InputKind, Item,
},
states,
};
@ -137,7 +137,6 @@ fn matches_ability_stage() {
stage: 1,
timer: Duration::default(),
stage_section: states::utils::StageSection::Swing,
next_stage: false,
}),
&PreviousEntityState {
event: SfxEvent::Idle,
@ -195,7 +194,6 @@ fn ignores_different_ability_stage() {
stage: 1,
timer: Duration::default(),
stage_section: states::utils::StageSection::Swing,
next_stage: false,
}),
&PreviousEntityState {
event: SfxEvent::Idle,
@ -218,6 +216,6 @@ fn empty_ability_info() -> states::utils::AbilityInfo {
states::utils::AbilityInfo {
tool: None,
hand: None,
key: states::utils::AbilityKey::Mouse1,
input: InputKind::Primary,
}
}

View File

@ -367,12 +367,9 @@ impl PlayState for SessionState {
}
} else {
client.handle_input(InputKind::Primary, state);
//self.inputs.primary.set_state(state);
}
},
GameInput::Secondary => {
// self.inputs.secondary.set_state(false); // To be changed later on
let mut client = self.client.borrow_mut();
if state && can_build {
@ -381,7 +378,6 @@ impl PlayState for SessionState {
}
} else {
client.handle_input(InputKind::Secondary, state);
// self.inputs.secondary.set_state(state);
}
},
GameInput::Roll => {
@ -396,7 +392,6 @@ impl PlayState for SessionState {
}
} else {
client.handle_input(InputKind::Roll, state);
// self.inputs.roll.set_state(state);
}
},
GameInput::Respawn => {
@ -469,8 +464,6 @@ impl PlayState for SessionState {
self.key_state.fly ^= state;
let mut client = self.client.borrow_mut();
client.handle_input(InputKind::Fly, self.key_state.fly);
// self.inputs.fly.set_state(self.key_state.
// fly);
},
GameInput::Climb => {
self.key_state.climb_up = state;
@ -1229,12 +1222,10 @@ impl PlayState for SessionState {
HudEvent::Ability3(state) => {
let mut client = self.client.borrow_mut();
client.handle_input(InputKind::Ability(0), state);
// self.inputs.ability3.set_state(state);
},
HudEvent::Ability4(state) => {
let mut client = self.client.borrow_mut();
client.handle_input(InputKind::Ability(1), state);
// self.inputs.ability4.set_state(state);
},
HudEvent::ChangeFOV(new_fov) => {
global_state.settings.graphics.fov = new_fov;

View File

@ -276,7 +276,6 @@ pub mod con_settings {
pub interact: Button,
pub toggle_wield: Button,
pub swap_loadout: Button,
//pub charge: Button,
}
#[derive(Clone, Debug, Serialize, Deserialize)]