mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made bow stay in BasicRanged state while autofiring.
This commit is contained in:
parent
92aa6a1b12
commit
edff3a75c3
@ -76,6 +76,7 @@ pub enum CharacterAbility {
|
||||
projectile_light: Option<LightEmitter>,
|
||||
projectile_gravity: Option<Gravity>,
|
||||
projectile_speed: f32,
|
||||
can_continue: bool,
|
||||
},
|
||||
RepeaterRanged {
|
||||
energy_cost: u32,
|
||||
@ -409,6 +410,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
||||
projectile_light,
|
||||
projectile_gravity,
|
||||
projectile_speed,
|
||||
can_continue,
|
||||
energy_cost: _,
|
||||
} => CharacterState::BasicRanged(basic_ranged::Data {
|
||||
static_data: basic_ranged::StaticData {
|
||||
@ -419,11 +421,13 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
||||
projectile_light: *projectile_light,
|
||||
projectile_gravity: *projectile_gravity,
|
||||
projectile_speed: *projectile_speed,
|
||||
can_continue: *can_continue,
|
||||
ability_key: key,
|
||||
},
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
exhausted: false,
|
||||
continue_next: false,
|
||||
}),
|
||||
CharacterAbility::Boost {
|
||||
movement_duration,
|
||||
|
@ -323,6 +323,7 @@ impl Tool {
|
||||
projectile_light: None,
|
||||
projectile_gravity: Some(Gravity(0.2)),
|
||||
projectile_speed: 100.0,
|
||||
can_continue: true,
|
||||
},
|
||||
ChargedRanged {
|
||||
energy_cost: 0,
|
||||
@ -467,6 +468,7 @@ impl Tool {
|
||||
}),
|
||||
projectile_gravity: Some(Gravity(0.5)),
|
||||
projectile_speed: 40.0,
|
||||
can_continue: false,
|
||||
},
|
||||
],
|
||||
Staff => vec![
|
||||
@ -514,6 +516,7 @@ impl Tool {
|
||||
}),
|
||||
projectile_gravity: Some(Gravity(0.3)),
|
||||
projectile_speed: 60.0,
|
||||
can_continue: false,
|
||||
},
|
||||
BasicBeam {
|
||||
buildup_duration: Duration::from_millis(250),
|
||||
@ -620,6 +623,7 @@ impl Tool {
|
||||
}),
|
||||
projectile_gravity: None,
|
||||
projectile_speed: 100.0,
|
||||
can_continue: false,
|
||||
},
|
||||
],
|
||||
Empty => vec![BasicMelee {
|
||||
|
@ -22,6 +22,8 @@ pub struct StaticData {
|
||||
pub projectile_speed: f32,
|
||||
/// What key is used to press ability
|
||||
pub ability_key: AbilityKey,
|
||||
/// Whether or not the ability can auto continue
|
||||
pub can_continue: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@ -35,6 +37,8 @@ pub struct Data {
|
||||
pub stage_section: StageSection,
|
||||
/// Whether the attack fired already
|
||||
pub exhausted: bool,
|
||||
/// If in buildup, whether the attack has continued form previous attack; if in recover, whether the attack will continue to a new attack
|
||||
pub continue_next: bool,
|
||||
}
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
@ -84,18 +88,41 @@ impl CharacterBehavior for Data {
|
||||
update.character = CharacterState::BasicRanged(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
exhausted: true,
|
||||
continue_next: false,
|
||||
..*self
|
||||
});
|
||||
} else if self.timer < self.static_data.recover_duration {
|
||||
// Recovers
|
||||
if ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||
// Recovers
|
||||
update.character = CharacterState::BasicRanged(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
continue_next: self.static_data.can_continue,
|
||||
..*self
|
||||
});
|
||||
} else {
|
||||
// Recovers
|
||||
update.character = CharacterState::BasicRanged(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
..*self
|
||||
});
|
||||
}
|
||||
} else if self.continue_next {
|
||||
// Restarts character state
|
||||
update.character = CharacterState::BasicRanged(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
exhausted: false,
|
||||
..*self
|
||||
});
|
||||
})
|
||||
} else {
|
||||
// Done
|
||||
update.character = CharacterState::Wielding;
|
||||
|
Loading…
Reference in New Issue
Block a user