If roll input remains held, allows you to keep rolling and stay in roll state.

You can now jump to interrupt the recovery portion of roll.
Jumping out of roll slightly increases jump strength.
This commit is contained in:
Sam 2021-03-22 18:47:13 -04:00
parent f48c1e6535
commit 356bb5baee
18 changed files with 60 additions and 28 deletions

View File

@ -1217,6 +1217,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
recover_duration: Duration::from_secs_f32(*recover_duration),
roll_strength: *roll_strength,
immune_melee: *immune_melee,
ability_info,
},
timer: Duration::default(),
stage_section: StageSection::Buildup,

View File

@ -50,7 +50,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.8);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
StageSection::Buildup => {

View File

@ -70,7 +70,7 @@ impl CharacterBehavior for Data {
}
handle_move(data, &mut update, 0.4);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
StageSection::Buildup => {

View File

@ -51,7 +51,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.7);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
StageSection::Buildup => {

View File

@ -44,7 +44,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.3);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
StageSection::Buildup => {

View File

@ -67,7 +67,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.7);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
StageSection::Charge => {

View File

@ -67,7 +67,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, self.static_data.move_speed);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
StageSection::Buildup => {

View File

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

View File

@ -26,8 +26,8 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
handle_move(&data, &mut update, 1.0);
handle_jump(&data, &mut update);
handle_move(data, &mut update, 1.0);
handle_jump(data, &mut update, 1.0);
if self.timer < self.static_data.buildup_duration {
// Draw weapon

View File

@ -10,8 +10,8 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
handle_move(&data, &mut update, 1.0);
handle_jump(&data, &mut update);
handle_move(data, &mut update, 1.0);
handle_jump(data, &mut update, 1.0);
handle_dodge_input(data, &mut update);
handle_wield(data, &mut update);

View File

@ -53,7 +53,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.4);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
StageSection::Buildup => {

View File

@ -11,7 +11,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 1.0);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
handle_wield(data, &mut update);
handle_climb(data, &mut update);
handle_dodge_input(data, &mut update);

View File

@ -57,7 +57,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.3);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
// Delay before leaping into the air

View File

@ -52,7 +52,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 1.0);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
match self.stage_section {
StageSection::Movement => {

View File

@ -21,6 +21,8 @@ pub struct StaticData {
pub roll_strength: f32,
/// Affects whether you are immune to melee attacks while rolling
pub immune_melee: bool,
/// Information about the ability
pub ability_info: AbilityInfo,
}
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
@ -94,17 +96,25 @@ impl CharacterBehavior for Data {
..*self
});
} else {
// Transitions to recover section of stage
// Keeps rolling if sufficient energy, else transitions to recover section of
// stage
if input_is_pressed(data, self.static_data.ability_info.input) {
reset_state(self, data, &mut update);
} else {
update.character = CharacterState::Roll(Data {
timer: Duration::default(),
stage_section: StageSection::Recover,
..*self
});
}
}
},
StageSection::Recover => {
if self.timer < self.static_data.recover_duration {
// Build up
// Allows for jumps to interrupt recovery in roll
if self.timer < self.static_data.recover_duration
&& !handle_jump(data, &mut update, 1.5)
{
// Recover
update.character = CharacterState::Roll(Data {
timer: self
.timer
@ -143,3 +153,19 @@ impl CharacterBehavior for Data {
update
}
}
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
handle_input(join, update, data.static_data.ability_info.input);
if let CharacterState::Roll(r) = &mut update.character {
r.was_combo = data.was_combo;
r.was_sneak = data.was_sneak;
r.was_wielded = data.was_wielded;
if matches!(r.stage_section, StageSection::Movement) {
r.timer = Duration::default();
r.stage_section = StageSection::Recover;
} else {
r.stage_section = StageSection::Movement;
}
}
}

View File

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

View File

@ -11,7 +11,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.4);
handle_jump(data, &mut update);
handle_jump(data, &mut update, 1.0);
handle_wield(data, &mut update);
handle_climb(data, &mut update);
handle_dodge_input(data, &mut update);

View File

@ -455,7 +455,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) {
pub fn handle_jump(data: &JoinData, update: &mut StateUpdate, strength: f32) -> bool {
if input_is_pressed(data, InputKind::Jump)
&& data.physics.on_ground
&& !data
@ -467,8 +467,11 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) {
{
update.local_events.push_front(LocalEvent::Jump(
data.entity,
data.body.jump_impulse().unwrap(),
data.body.jump_impulse().unwrap() * strength,
));
true
} else {
false
}
}
@ -546,7 +549,9 @@ pub fn handle_input(data: &JoinData, update: &mut StateUpdate, input: InputKind)
handle_ability(data, update, input)
},
InputKind::Roll => handle_dodge_input(data, update),
InputKind::Jump => handle_jump(data, update),
InputKind::Jump => {
handle_jump(data, update, 1.0);
},
InputKind::Fly => {},
}
}