mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Primary ability fully functional.
This commit is contained in:
parent
19c81f1528
commit
21e6f4797c
@ -11,5 +11,4 @@ BasicRanged(
|
|||||||
projectile_light: None,
|
projectile_light: None,
|
||||||
projectile_gravity: Some(Gravity(0.2)),
|
projectile_gravity: Some(Gravity(0.2)),
|
||||||
projectile_speed: 100.0,
|
projectile_speed: 100.0,
|
||||||
can_continue: true,
|
|
||||||
)
|
)
|
||||||
|
@ -11,5 +11,4 @@ BasicRanged(
|
|||||||
projectile_light: None,
|
projectile_light: None,
|
||||||
projectile_gravity: Some(Gravity(0.2)),
|
projectile_gravity: Some(Gravity(0.2)),
|
||||||
projectile_speed: 100.0,
|
projectile_speed: 100.0,
|
||||||
can_continue: true,
|
|
||||||
)
|
)
|
||||||
|
@ -10,5 +10,4 @@ BasicRanged(
|
|||||||
}),*/
|
}),*/
|
||||||
projectile_gravity: None,
|
projectile_gravity: None,
|
||||||
projectile_speed: 100.0,
|
projectile_speed: 100.0,
|
||||||
can_continue: false,
|
|
||||||
)
|
)
|
@ -14,5 +14,4 @@ BasicRanged(
|
|||||||
}),*/
|
}),*/
|
||||||
projectile_gravity: Some(Gravity(0.3)),
|
projectile_gravity: Some(Gravity(0.3)),
|
||||||
projectile_speed: 60.0,
|
projectile_speed: 60.0,
|
||||||
can_continue: true,
|
|
||||||
)
|
)
|
||||||
|
@ -14,5 +14,4 @@ BasicRanged(
|
|||||||
}),*/
|
}),*/
|
||||||
projectile_gravity: Some(Gravity(0.3)),
|
projectile_gravity: Some(Gravity(0.3)),
|
||||||
projectile_speed: 60.0,
|
projectile_speed: 60.0,
|
||||||
can_continue: true,
|
|
||||||
)
|
)
|
||||||
|
@ -14,5 +14,4 @@ BasicRanged(
|
|||||||
}),*/
|
}),*/
|
||||||
projectile_gravity: Some(Gravity(5.0)),
|
projectile_gravity: Some(Gravity(5.0)),
|
||||||
projectile_speed: 70.0,
|
projectile_speed: 70.0,
|
||||||
can_continue: true,
|
|
||||||
)
|
)
|
||||||
|
@ -11,5 +11,4 @@ BasicRanged(
|
|||||||
projectile_light: None,
|
projectile_light: None,
|
||||||
projectile_gravity: Some(Gravity(0.1)),
|
projectile_gravity: Some(Gravity(0.1)),
|
||||||
projectile_speed: 100.0,
|
projectile_speed: 100.0,
|
||||||
can_continue: true,
|
|
||||||
)
|
)
|
||||||
|
@ -13,5 +13,4 @@ BasicRanged(
|
|||||||
}),*/
|
}),*/
|
||||||
projectile_gravity: Some(Gravity(0.3)),
|
projectile_gravity: Some(Gravity(0.3)),
|
||||||
projectile_speed: 60.0,
|
projectile_speed: 60.0,
|
||||||
can_continue: true,
|
|
||||||
)
|
)
|
||||||
|
@ -994,7 +994,7 @@ impl Client {
|
|||||||
pub fn handle_input(&mut self, input: InputKind, pressed: bool) {
|
pub fn handle_input(&mut self, input: InputKind, pressed: bool) {
|
||||||
if pressed {
|
if pressed {
|
||||||
self.control_action(ControlAction::StartInput {
|
self.control_action(ControlAction::StartInput {
|
||||||
ability: input,
|
input,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,7 +75,6 @@ pub enum CharacterAbility {
|
|||||||
projectile_light: Option<LightEmitter>,
|
projectile_light: Option<LightEmitter>,
|
||||||
projectile_gravity: Option<Gravity>,
|
projectile_gravity: Option<Gravity>,
|
||||||
projectile_speed: f32,
|
projectile_speed: f32,
|
||||||
can_continue: bool,
|
|
||||||
},
|
},
|
||||||
RepeaterRanged {
|
RepeaterRanged {
|
||||||
energy_cost: f32,
|
energy_cost: f32,
|
||||||
@ -1121,6 +1120,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
|||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
exhausted: false,
|
exhausted: false,
|
||||||
|
end: false,
|
||||||
}),
|
}),
|
||||||
CharacterAbility::BasicRanged {
|
CharacterAbility::BasicRanged {
|
||||||
buildup_duration,
|
buildup_duration,
|
||||||
@ -1130,7 +1130,6 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
|||||||
projectile_light,
|
projectile_light,
|
||||||
projectile_gravity,
|
projectile_gravity,
|
||||||
projectile_speed,
|
projectile_speed,
|
||||||
can_continue,
|
|
||||||
energy_cost: _,
|
energy_cost: _,
|
||||||
} => CharacterState::BasicRanged(basic_ranged::Data {
|
} => CharacterState::BasicRanged(basic_ranged::Data {
|
||||||
static_data: basic_ranged::StaticData {
|
static_data: basic_ranged::StaticData {
|
||||||
@ -1141,13 +1140,12 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
|||||||
projectile_light: *projectile_light,
|
projectile_light: *projectile_light,
|
||||||
projectile_gravity: *projectile_gravity,
|
projectile_gravity: *projectile_gravity,
|
||||||
projectile_speed: *projectile_speed,
|
projectile_speed: *projectile_speed,
|
||||||
can_continue: *can_continue,
|
|
||||||
ability_info,
|
ability_info,
|
||||||
},
|
},
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
exhausted: false,
|
exhausted: false,
|
||||||
continue_next: false,
|
end: false,
|
||||||
}),
|
}),
|
||||||
CharacterAbility::Boost {
|
CharacterAbility::Boost {
|
||||||
movement_duration,
|
movement_duration,
|
||||||
@ -1252,7 +1250,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
|||||||
stage: 1,
|
stage: 1,
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
next_stage: false,
|
end: false,
|
||||||
}),
|
}),
|
||||||
CharacterAbility::LeapMelee {
|
CharacterAbility::LeapMelee {
|
||||||
energy_cost: _,
|
energy_cost: _,
|
||||||
@ -1497,6 +1495,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
|||||||
},
|
},
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
|
end: false,
|
||||||
}),
|
}),
|
||||||
CharacterAbility::BasicAura {
|
CharacterAbility::BasicAura {
|
||||||
buildup_duration,
|
buildup_duration,
|
||||||
|
@ -112,7 +112,7 @@ pub enum ControlAction {
|
|||||||
Stand,
|
Stand,
|
||||||
Talk,
|
Talk,
|
||||||
StartInput {
|
StartInput {
|
||||||
ability: InputKind,
|
input: InputKind,
|
||||||
target: Option<Uid>,
|
target: Option<Uid>,
|
||||||
},
|
},
|
||||||
CancelInput(InputKind),
|
CancelInput(InputKind),
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement, Damage, DamageSource,
|
Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement, Damage, DamageSource,
|
||||||
GroupTarget,
|
GroupTarget,
|
||||||
},
|
},
|
||||||
comp::{beam, CharacterState, EnergyChange, EnergySource, Ori, Pos, StateUpdate},
|
comp::{beam, CharacterState, EnergyChange, EnergySource, InputKind, Ori, Pos, StateUpdate},
|
||||||
event::ServerEvent,
|
event::ServerEvent,
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
@ -56,6 +56,8 @@ pub struct Data {
|
|||||||
pub timer: Duration,
|
pub timer: Duration,
|
||||||
/// What section the character stage is in
|
/// What section the character stage is in
|
||||||
pub stage_section: StageSection,
|
pub stage_section: StageSection,
|
||||||
|
/// Whether or not the state should end
|
||||||
|
pub end: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterBehavior for Data {
|
impl CharacterBehavior for Data {
|
||||||
@ -108,7 +110,9 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
StageSection::Cast => {
|
StageSection::Cast => {
|
||||||
if ability_key_is_pressed(data, self.static_data.ability_info.key)
|
if
|
||||||
|
/* ability_key_is_pressed(data, self.static_data.ability_info.key) */
|
||||||
|
!self.end
|
||||||
&& (self.static_data.energy_drain <= f32::EPSILON
|
&& (self.static_data.energy_drain <= f32::EPSILON
|
||||||
|| update.energy.current() > 0)
|
|| update.energy.current() > 0)
|
||||||
{
|
{
|
||||||
@ -205,6 +209,17 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cancel_input(&self, data: &JoinData, input: InputKind) -> StateUpdate {
|
||||||
|
let mut update = StateUpdate::from(data);
|
||||||
|
update.removed_inputs.push(input);
|
||||||
|
|
||||||
|
if Some(input) == self.static_data.ability_info.input {
|
||||||
|
update.character = CharacterState::BasicBeam(Data { end: true, ..*self });
|
||||||
|
}
|
||||||
|
|
||||||
|
update
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
||||||
comp::{CharacterState, Melee, StateUpdate},
|
comp::{CharacterState, InputKind, Melee, StateUpdate},
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
utils::*,
|
utils::*,
|
||||||
@ -44,6 +44,8 @@ pub struct Data {
|
|||||||
pub stage_section: StageSection,
|
pub stage_section: StageSection,
|
||||||
/// Whether the attack can deal more damage
|
/// Whether the attack can deal more damage
|
||||||
pub exhausted: bool,
|
pub exhausted: bool,
|
||||||
|
/// Whether or not the state should end
|
||||||
|
pub end: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterBehavior for Data {
|
impl CharacterBehavior for Data {
|
||||||
@ -162,9 +164,13 @@ impl CharacterBehavior for Data {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Done
|
// Done
|
||||||
update.character = CharacterState::Wielding;
|
if self.end || self.static_data.ability_info.input.is_none() {
|
||||||
// Make sure attack component is removed
|
update.character = CharacterState::Wielding;
|
||||||
data.updater.remove::<Melee>(data.entity);
|
// Make sure attack component is removed
|
||||||
|
data.updater.remove::<Melee>(data.entity);
|
||||||
|
} else {
|
||||||
|
reset_state(self, data, &mut update);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
@ -177,4 +183,21 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cancel_input(&self, data: &JoinData, input: InputKind) -> StateUpdate {
|
||||||
|
let mut update = StateUpdate::from(data);
|
||||||
|
update.removed_inputs.push(input);
|
||||||
|
|
||||||
|
if Some(input) == self.static_data.ability_info.input {
|
||||||
|
if let CharacterState::BasicMelee(c) = &mut update.character {
|
||||||
|
c.end = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
||||||
|
handle_input(join, update, data.static_data.ability_info.input.unwrap());
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{Body, CharacterState, Gravity, LightEmitter, ProjectileConstructor, StateUpdate},
|
comp::{
|
||||||
|
Body, CharacterState, Gravity, InputKind, LightEmitter, ProjectileConstructor, StateUpdate,
|
||||||
|
},
|
||||||
event::ServerEvent,
|
event::ServerEvent,
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
@ -24,8 +26,6 @@ pub struct StaticData {
|
|||||||
pub projectile_speed: f32,
|
pub projectile_speed: f32,
|
||||||
/// What key is used to press ability
|
/// What key is used to press ability
|
||||||
pub ability_info: AbilityInfo,
|
pub ability_info: AbilityInfo,
|
||||||
/// Whether or not the ability can auto continue
|
|
||||||
pub can_continue: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -39,9 +39,8 @@ pub struct Data {
|
|||||||
pub stage_section: StageSection,
|
pub stage_section: StageSection,
|
||||||
/// Whether the attack fired already
|
/// Whether the attack fired already
|
||||||
pub exhausted: bool,
|
pub exhausted: bool,
|
||||||
/// If in buildup, whether the attack has continued form previous attack; if
|
/// Whether or not the state should end
|
||||||
/// in recover, whether the attack will continue to a new attack
|
pub end: bool,
|
||||||
pub continue_next: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterBehavior for Data {
|
impl CharacterBehavior for Data {
|
||||||
@ -103,41 +102,24 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
update.character = CharacterState::BasicRanged(Data {
|
update.character = CharacterState::BasicRanged(Data {
|
||||||
exhausted: true,
|
exhausted: true,
|
||||||
continue_next: false,
|
|
||||||
..*self
|
..*self
|
||||||
});
|
});
|
||||||
} else if self.timer < self.static_data.recover_duration {
|
} else if self.timer < self.static_data.recover_duration {
|
||||||
if ability_key_is_pressed(data, self.static_data.ability_info.key) {
|
// Recovers
|
||||||
// Recovers
|
|
||||||
update.character = CharacterState::BasicRanged(Data {
|
|
||||||
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 {
|
|
||||||
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 {
|
update.character = CharacterState::BasicRanged(Data {
|
||||||
timer: Duration::default(),
|
timer: self
|
||||||
stage_section: StageSection::Buildup,
|
.timer
|
||||||
exhausted: false,
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
..*self
|
..*self
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
// Done
|
// Done
|
||||||
update.character = CharacterState::Wielding;
|
if self.end || self.static_data.ability_info.input.is_none() {
|
||||||
|
update.character = CharacterState::Wielding;
|
||||||
|
} else {
|
||||||
|
reset_state(self, data, &mut update);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
@ -148,4 +130,21 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cancel_input(&self, data: &JoinData, input: InputKind) -> StateUpdate {
|
||||||
|
let mut update = StateUpdate::from(data);
|
||||||
|
update.removed_inputs.push(input);
|
||||||
|
|
||||||
|
if Some(input) == self.static_data.ability_info.input {
|
||||||
|
if let CharacterState::BasicRanged(c) = &mut update.character {
|
||||||
|
c.end = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
||||||
|
handle_input(join, update, data.static_data.ability_info.input.unwrap());
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,7 @@ pub trait CharacterBehavior {
|
|||||||
ControlAction::Sneak => self.sneak(data),
|
ControlAction::Sneak => self.sneak(data),
|
||||||
ControlAction::Stand => self.stand(data),
|
ControlAction::Stand => self.stand(data),
|
||||||
ControlAction::Talk => self.talk(data),
|
ControlAction::Talk => self.talk(data),
|
||||||
ControlAction::StartInput { ability, target } => {
|
ControlAction::StartInput { input, target } => self.handle_input(data, input, target),
|
||||||
self.handle_input(data, ability, target)
|
|
||||||
},
|
|
||||||
ControlAction::CancelInput(input) => self.cancel_input(data, input),
|
ControlAction::CancelInput(input) => self.cancel_input(data, input),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ impl CharacterBehavior for Data {
|
|||||||
if self.end || self.static_data.ability_info.input.is_none() {
|
if self.end || self.static_data.ability_info.input.is_none() {
|
||||||
update.character = CharacterState::Wielding;
|
update.character = CharacterState::Wielding;
|
||||||
} else {
|
} else {
|
||||||
reset_state(self, &mut update);
|
reset_state(self, data, &mut update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,16 +64,15 @@ impl CharacterBehavior for Data {
|
|||||||
update.removed_inputs.push(input);
|
update.removed_inputs.push(input);
|
||||||
|
|
||||||
if Some(input) == self.static_data.ability_info.input {
|
if Some(input) == self.static_data.ability_info.input {
|
||||||
update.character = CharacterState::Boost(Data { end: true, ..*self });
|
if let CharacterState::Boost(c) = &mut update.character {
|
||||||
|
c.end = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset_state(data: &Data, update: &mut StateUpdate) {
|
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
||||||
update.character = CharacterState::Boost(Data {
|
handle_input(join, update, data.static_data.ability_info.input.unwrap());
|
||||||
timer: Duration::default(),
|
|
||||||
..*data
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
||||||
comp::{CharacterState, Melee, StateUpdate},
|
comp::{CharacterState, InputKind, Melee, StateUpdate},
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
utils::*,
|
utils::*,
|
||||||
@ -113,8 +113,8 @@ pub struct Data {
|
|||||||
pub timer: Duration,
|
pub timer: Duration,
|
||||||
/// Checks what section a stage is in
|
/// Checks what section a stage is in
|
||||||
pub stage_section: StageSection,
|
pub stage_section: StageSection,
|
||||||
/// Whether the state should go onto the next stage
|
/// Whether or not the state should end
|
||||||
pub next_stage: bool,
|
pub end: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterBehavior for Data {
|
impl CharacterBehavior for Data {
|
||||||
@ -261,41 +261,23 @@ impl CharacterBehavior for Data {
|
|||||||
StageSection::Recover => {
|
StageSection::Recover => {
|
||||||
if self.timer < self.static_data.stage_data[stage_index].base_recover_duration {
|
if self.timer < self.static_data.stage_data[stage_index].base_recover_duration {
|
||||||
// Recovers
|
// Recovers
|
||||||
if ability_key_is_pressed(data, self.static_data.ability_info.key) {
|
|
||||||
// Checks if state will transition to next stage after recover
|
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
|
||||||
static_data: self.static_data.clone(),
|
|
||||||
timer: self
|
|
||||||
.timer
|
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0 * speed_modifer))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
next_stage: true,
|
|
||||||
..*self
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
|
||||||
static_data: self.static_data.clone(),
|
|
||||||
timer: self
|
|
||||||
.timer
|
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0 * speed_modifer))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
..*self
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if self.next_stage {
|
|
||||||
// Transitions to buildup section of next stage
|
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
static_data: self.static_data.clone(),
|
static_data: self.static_data.clone(),
|
||||||
stage: (self.stage % self.static_data.num_stages) + 1,
|
timer: self
|
||||||
timer: Duration::default(),
|
.timer
|
||||||
stage_section: StageSection::Buildup,
|
.checked_add(Duration::from_secs_f32(data.dt.0 * speed_modifer))
|
||||||
next_stage: false,
|
.unwrap_or_default(),
|
||||||
|
..*self
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Done
|
// Done
|
||||||
update.character = CharacterState::Wielding;
|
if self.end || self.static_data.ability_info.input.is_none() {
|
||||||
// Make sure attack component is removed
|
update.character = CharacterState::Wielding;
|
||||||
data.updater.remove::<Melee>(data.entity);
|
// Make sure attack component is removed
|
||||||
|
data.updater.remove::<Melee>(data.entity);
|
||||||
|
} else {
|
||||||
|
reset_state(self, data, &mut update);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
@ -306,20 +288,27 @@ impl CharacterBehavior for Data {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grant energy on successful hit
|
update
|
||||||
if let Some(attack) = data.melee_attack {
|
}
|
||||||
if attack.applied && attack.hit_count > 0 {
|
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
fn cancel_input(&self, data: &JoinData, input: InputKind) -> StateUpdate {
|
||||||
static_data: self.static_data.clone(),
|
let mut update = StateUpdate::from(data);
|
||||||
stage: self.stage,
|
update.removed_inputs.push(input);
|
||||||
timer: self.timer,
|
|
||||||
stage_section: self.stage_section,
|
if Some(input) == self.static_data.ability_info.input {
|
||||||
next_stage: self.next_stage,
|
if let CharacterState::ComboMelee(c) = &mut update.character {
|
||||||
});
|
c.end = true;
|
||||||
data.updater.remove::<Melee>(data.entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset_state(data: &Data, join: &JoinData, update: &mut StateUpdate) {
|
||||||
|
handle_input(join, update, data.static_data.ability_info.input.unwrap());
|
||||||
|
|
||||||
|
if let CharacterState::ComboMelee(c) = &mut update.character {
|
||||||
|
c.stage = (data.stage % data.static_data.num_stages) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{InventoryAction, StateUpdate},
|
comp::{CharacterState, InputKind, InventoryAction, StateUpdate},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::behavior::{CharacterBehavior, JoinData},
|
||||||
|
uid::Uid,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Data;
|
pub struct Data;
|
||||||
@ -19,6 +20,18 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_input(
|
||||||
|
&self,
|
||||||
|
data: &JoinData,
|
||||||
|
_input: InputKind,
|
||||||
|
_target: Option<Uid>,
|
||||||
|
) -> StateUpdate {
|
||||||
|
let mut update = StateUpdate::from(data);
|
||||||
|
update.character = CharacterState::Wielding;
|
||||||
|
|
||||||
|
update
|
||||||
|
}
|
||||||
|
|
||||||
fn wield(&self, data: &JoinData) -> StateUpdate {
|
fn wield(&self, data: &JoinData) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
attempt_wield(data, &mut update);
|
attempt_wield(data, &mut update);
|
||||||
|
@ -26,14 +26,9 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_input(
|
fn handle_input(&self, data: &JoinData, input: InputKind, _target: Option<Uid>) -> StateUpdate {
|
||||||
&self,
|
|
||||||
data: &JoinData,
|
|
||||||
ability: InputKind,
|
|
||||||
_target: Option<Uid>,
|
|
||||||
) -> StateUpdate {
|
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
handle_input(&data, &mut update, ability);
|
handle_input(&data, &mut update, input);
|
||||||
|
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
@ -1082,7 +1082,7 @@ impl<'a> AgentData<'a> {
|
|||||||
Tactic::Melee => {
|
Tactic::Melee => {
|
||||||
if dist_sqrd < (min_attack_dist * self.scale).powi(2) {
|
if dist_sqrd < (min_attack_dist * self.scale).powi(2) {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1134,7 +1134,7 @@ impl<'a> AgentData<'a> {
|
|||||||
agent.action_timer += dt.0;
|
agent.action_timer += dt.0;
|
||||||
} else {
|
} else {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1186,7 +1186,7 @@ impl<'a> AgentData<'a> {
|
|||||||
agent.action_timer += dt.0;
|
agent.action_timer += dt.0;
|
||||||
} else {
|
} else {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1250,7 +1250,7 @@ impl<'a> AgentData<'a> {
|
|||||||
agent.action_timer = 0.0;
|
agent.action_timer = 0.0;
|
||||||
} else {
|
} else {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1335,7 +1335,7 @@ impl<'a> AgentData<'a> {
|
|||||||
} else {
|
} else {
|
||||||
controller.inputs.secondary.set_state(false);
|
controller.inputs.secondary.set_state(false);
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1409,7 +1409,7 @@ impl<'a> AgentData<'a> {
|
|||||||
controller.inputs.secondary.set_state(true);
|
controller.inputs.secondary.set_state(true);
|
||||||
} else {
|
} else {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1433,7 +1433,7 @@ impl<'a> AgentData<'a> {
|
|||||||
.unwrap_or_else(Vec2::zero)
|
.unwrap_or_else(Vec2::zero)
|
||||||
* speed;
|
* speed;
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1476,7 +1476,7 @@ impl<'a> AgentData<'a> {
|
|||||||
// large hitbox
|
// large hitbox
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1522,7 +1522,7 @@ impl<'a> AgentData<'a> {
|
|||||||
{
|
{
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1584,7 +1584,7 @@ impl<'a> AgentData<'a> {
|
|||||||
.try_normalized()
|
.try_normalized()
|
||||||
.unwrap_or_else(Vec2::unit_y);
|
.unwrap_or_else(Vec2::unit_y);
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1645,7 +1645,7 @@ impl<'a> AgentData<'a> {
|
|||||||
agent.action_timer = 0.0;
|
agent.action_timer = 0.0;
|
||||||
} else if agent.action_timer > 1.0 {
|
} else if agent.action_timer > 1.0 {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1687,7 +1687,7 @@ impl<'a> AgentData<'a> {
|
|||||||
&& dist_sqrd > (2.0 * min_attack_dist * self.scale).powi(2)
|
&& dist_sqrd > (2.0 * min_attack_dist * self.scale).powi(2)
|
||||||
{
|
{
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1726,7 +1726,7 @@ impl<'a> AgentData<'a> {
|
|||||||
agent.action_timer += dt.0;
|
agent.action_timer += dt.0;
|
||||||
} else {
|
} else {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1771,7 +1771,7 @@ impl<'a> AgentData<'a> {
|
|||||||
) {
|
) {
|
||||||
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1796,7 +1796,7 @@ impl<'a> AgentData<'a> {
|
|||||||
agent.action_timer += dt.0;
|
agent.action_timer += dt.0;
|
||||||
} else if agent.action_timer < 3.0 {
|
} else if agent.action_timer < 3.0 {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1836,7 +1836,7 @@ impl<'a> AgentData<'a> {
|
|||||||
.try_normalized()
|
.try_normalized()
|
||||||
.unwrap_or_else(Vec2::unit_y);
|
.unwrap_or_else(Vec2::unit_y);
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1848,7 +1848,7 @@ impl<'a> AgentData<'a> {
|
|||||||
.try_normalized()
|
.try_normalized()
|
||||||
.unwrap_or_else(Vec2::unit_y);
|
.unwrap_or_else(Vec2::unit_y);
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1883,7 +1883,7 @@ impl<'a> AgentData<'a> {
|
|||||||
if dist_sqrd < (2.0 * min_attack_dist * self.scale).powi(2) {
|
if dist_sqrd < (2.0 * min_attack_dist * self.scale).powi(2) {
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1910,7 +1910,7 @@ impl<'a> AgentData<'a> {
|
|||||||
Tactic::Turret => {
|
Tactic::Turret => {
|
||||||
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1922,7 +1922,7 @@ impl<'a> AgentData<'a> {
|
|||||||
controller.inputs.look_dir = self.ori.look_dir();
|
controller.inputs.look_dir = self.ori.look_dir();
|
||||||
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
@ -1940,7 +1940,7 @@ impl<'a> AgentData<'a> {
|
|||||||
);
|
);
|
||||||
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
|
||||||
controller.actions.push(ControlAction::StartInput {
|
controller.actions.push(ControlAction::StartInput {
|
||||||
ability: InputKind::Primary,
|
input: InputKind::Primary,
|
||||||
target: None,
|
target: None,
|
||||||
});
|
});
|
||||||
//controller.inputs.primary.set_state(true);
|
//controller.inputs.primary.set_state(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user