mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Secondary input now fully functional
This commit is contained in:
parent
21e6f4797c
commit
b5d501199d
@ -1202,6 +1202,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
||||
refresh_distance: 0.0,
|
||||
stage_section: StageSection::Buildup,
|
||||
exhausted: false,
|
||||
end: false,
|
||||
}),
|
||||
CharacterAbility::BasicBlock => CharacterState::BasicBlock,
|
||||
CharacterAbility::Roll {
|
||||
@ -1319,6 +1320,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
||||
spins_remaining: *num_spins - 1,
|
||||
stage_section: StageSection::Buildup,
|
||||
exhausted: false,
|
||||
end: false,
|
||||
}),
|
||||
CharacterAbility::ChargedMelee {
|
||||
energy_cost,
|
||||
@ -1359,6 +1361,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
||||
timer: Duration::default(),
|
||||
exhausted: false,
|
||||
charge_amount: 0.0,
|
||||
end: false,
|
||||
}),
|
||||
CharacterAbility::ChargedRanged {
|
||||
energy_cost: _,
|
||||
@ -1399,6 +1402,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
exhausted: false,
|
||||
end: false,
|
||||
}),
|
||||
CharacterAbility::RepeaterRanged {
|
||||
energy_cost: _,
|
||||
@ -1545,6 +1549,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
|
||||
},
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
end: false,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
@ -122,8 +122,8 @@ pub enum ControlAction {
|
||||
#[repr(u32)]
|
||||
pub enum InputKind {
|
||||
Primary = 0,
|
||||
/* Secondary = 1,
|
||||
* Ability(usize) = 2,
|
||||
Secondary = 1,
|
||||
/* Ability(usize) = 2,
|
||||
* Jump = 3,
|
||||
* Roll = 4,
|
||||
* Glide = 5,
|
||||
@ -244,7 +244,7 @@ pub enum Climb {
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ControllerInputs {
|
||||
//pub primary: Input,
|
||||
pub secondary: Input,
|
||||
//pub secondary: Input,
|
||||
pub ability3: Input,
|
||||
pub ability4: Input,
|
||||
pub jump: Input,
|
||||
@ -273,7 +273,7 @@ impl ControllerInputs {
|
||||
/// Updates all inputs, accounting for delta time
|
||||
pub fn tick(&mut self, dt: Duration) {
|
||||
//self.primary.tick(dt);
|
||||
self.secondary.tick(dt);
|
||||
// self.secondary.tick(dt);
|
||||
self.ability3.tick(dt);
|
||||
self.ability4.tick(dt);
|
||||
self.jump.tick(dt);
|
||||
@ -286,7 +286,7 @@ impl ControllerInputs {
|
||||
|
||||
pub fn tick_freshness(&mut self) {
|
||||
//self.primary.tick_freshness();
|
||||
self.secondary.tick_freshness();
|
||||
// self.secondary.tick_freshness();
|
||||
self.ability3.tick_freshness();
|
||||
self.ability4.tick_freshness();
|
||||
self.jump.tick_freshness();
|
||||
@ -300,7 +300,7 @@ impl ControllerInputs {
|
||||
/// Updates Controller inputs with new version received from the client
|
||||
pub fn update_with_new(&mut self, new: Self) {
|
||||
//self.primary.update_with_new(new.primary);
|
||||
self.secondary.update_with_new(new.secondary);
|
||||
// self.secondary.update_with_new(new.secondary);
|
||||
self.ability3.update_with_new(new.ability3);
|
||||
self.ability4.update_with_new(new.ability4);
|
||||
self.jump.update_with_new(new.jump);
|
||||
@ -316,8 +316,8 @@ impl ControllerInputs {
|
||||
}
|
||||
|
||||
pub fn holding_ability_key(&self) -> bool {
|
||||
//self.primary.is_pressed() ||
|
||||
self.secondary.is_pressed() || self.ability3.is_pressed() || self.ability4.is_pressed()
|
||||
//self.primary.is_pressed() || self.secondary.is_pressed() ||
|
||||
self.ability3.is_pressed() || self.ability4.is_pressed()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,9 @@ impl CharacterBehavior for Data {
|
||||
update.removed_inputs.push(input);
|
||||
|
||||
if Some(input) == self.static_data.ability_info.input {
|
||||
update.character = CharacterState::BasicBeam(Data { end: true, ..*self });
|
||||
if let CharacterState::BasicBeam(c) = &mut update.character {
|
||||
c.end = true;
|
||||
}
|
||||
}
|
||||
|
||||
update
|
||||
|
@ -17,9 +17,6 @@ impl CharacterBehavior for Data {
|
||||
|
||||
handle_move(&data, &mut update, 0.4);
|
||||
|
||||
if !data.physics.on_ground || !data.inputs.secondary.is_pressed() {
|
||||
attempt_wield(data, &mut update);
|
||||
}
|
||||
update
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
||||
comp::{CharacterState, EnergyChange, EnergySource, Melee, StateUpdate},
|
||||
comp::{CharacterState, EnergyChange, EnergySource, InputKind, Melee, StateUpdate},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::{StageSection, *},
|
||||
@ -60,6 +60,8 @@ pub struct Data {
|
||||
pub exhausted: bool,
|
||||
/// How much the attack charged by
|
||||
pub charge_amount: f32,
|
||||
/// Whether or not the state should end
|
||||
pub end: bool,
|
||||
}
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
@ -80,7 +82,9 @@ impl CharacterBehavior for Data {
|
||||
|
||||
match self.stage_section {
|
||||
StageSection::Charge => {
|
||||
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
|
||||
&& update.energy.current() as f32 >= self.static_data.energy_cost
|
||||
&& self.timer < self.static_data.charge_duration
|
||||
{
|
||||
@ -107,7 +111,9 @@ 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)
|
||||
} else if
|
||||
/* ability_key_is_pressed(data, self.static_data.ability_info.key) */
|
||||
!self.end
|
||||
&& update.energy.current() as f32 >= self.static_data.energy_cost
|
||||
{
|
||||
// Maintains charge
|
||||
@ -242,4 +248,17 @@ impl CharacterBehavior for Data {
|
||||
|
||||
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::ChargedMelee(c) = &mut update.character {
|
||||
c.end = true;
|
||||
}
|
||||
}
|
||||
|
||||
update
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ use crate::{
|
||||
DamageSource, GroupTarget, Knockback, KnockbackDir,
|
||||
},
|
||||
comp::{
|
||||
projectile, Body, CharacterState, EnergyChange, EnergySource, Gravity, LightEmitter,
|
||||
Projectile, StateUpdate,
|
||||
projectile, Body, CharacterState, EnergyChange, EnergySource, Gravity, InputKind,
|
||||
LightEmitter, Projectile, StateUpdate,
|
||||
},
|
||||
event::ServerEvent,
|
||||
states::{
|
||||
@ -60,6 +60,8 @@ pub struct Data {
|
||||
pub stage_section: StageSection,
|
||||
/// Whether the attack fired already
|
||||
pub exhausted: bool,
|
||||
/// Whether or not the state should end
|
||||
pub end: bool,
|
||||
}
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
@ -99,9 +101,9 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
},
|
||||
StageSection::Charge => {
|
||||
if !ability_key_is_pressed(data, self.static_data.ability_info.key)
|
||||
&& !self.exhausted
|
||||
{
|
||||
if
|
||||
/* \!ability_key_is_pressed(data, self.static_data.ability_info.key) */
|
||||
self.end && !self.exhausted {
|
||||
let charge_frac = (self.timer.as_secs_f32()
|
||||
/ self.static_data.charge_duration.as_secs_f32())
|
||||
.min(1.0);
|
||||
@ -162,7 +164,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)
|
||||
&& /*ability_key_is_pressed(data, self.static_data.ability_info.key)*/ !self.end
|
||||
{
|
||||
// Charges
|
||||
update.character = CharacterState::ChargedRanged(Data {
|
||||
@ -182,7 +184,9 @@ 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) {
|
||||
} else if
|
||||
/* ability_key_is_pressed(data, self.static_data.ability_info.key) */
|
||||
!self.end {
|
||||
// Holds charge
|
||||
update.character = CharacterState::ChargedRanged(Data {
|
||||
timer: self
|
||||
@ -227,4 +231,17 @@ impl CharacterBehavior for Data {
|
||||
|
||||
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::ChargedRanged(c) = &mut update.character {
|
||||
c.end = true;
|
||||
}
|
||||
}
|
||||
|
||||
update
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
||||
comp::{CharacterState, EnergyChange, EnergySource, Melee, StateUpdate},
|
||||
comp::{CharacterState, EnergyChange, EnergySource, InputKind, Melee, StateUpdate},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
@ -55,7 +55,8 @@ pub struct Data {
|
||||
/// Struct containing data that does not change over the course of the
|
||||
/// character state
|
||||
pub static_data: StaticData,
|
||||
/// Whether the charge should end
|
||||
/// Whether the charge should last a default amount of time or until the
|
||||
/// mouse is released
|
||||
pub auto_charge: bool,
|
||||
/// Timer for each stage
|
||||
pub timer: Duration,
|
||||
@ -65,6 +66,8 @@ pub struct Data {
|
||||
pub stage_section: StageSection,
|
||||
/// Whether the state should attempt attacking again
|
||||
pub exhausted: bool,
|
||||
/// Whether or not the state should end
|
||||
pub end: bool,
|
||||
}
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
@ -97,10 +100,10 @@ impl CharacterBehavior for Data {
|
||||
} else {
|
||||
// Transitions to charge section of stage
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
auto_charge: !ability_key_is_pressed(
|
||||
auto_charge: /*\!ability_key_is_pressed(
|
||||
data,
|
||||
self.static_data.ability_info.key,
|
||||
),
|
||||
)*/self.end,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Charge,
|
||||
..*self
|
||||
@ -110,7 +113,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)
|
||||
&& (/* ability_key_is_pressed(data, self.static_data.ability_info.key) */!self.end
|
||||
|| (self.auto_charge && self.timer < self.static_data.charge_duration))
|
||||
&& update.energy.current() > 0
|
||||
{
|
||||
@ -267,4 +270,17 @@ impl CharacterBehavior for Data {
|
||||
|
||||
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::DashMelee(c) = &mut update.character {
|
||||
c.end = true;
|
||||
}
|
||||
}
|
||||
|
||||
update
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
combat::{Attack, AttackEffect, CombatEffect, CombatRequirement, GroupTarget},
|
||||
comp::{beam, CharacterState, Ori, Pos, StateUpdate},
|
||||
comp::{beam, CharacterState, InputKind, Ori, Pos, StateUpdate},
|
||||
event::ServerEvent,
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
@ -46,6 +46,8 @@ pub struct Data {
|
||||
pub timer: Duration,
|
||||
/// What section the character stage is in
|
||||
pub stage_section: StageSection,
|
||||
/// Whether or not the state should end
|
||||
pub end: bool,
|
||||
}
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
@ -91,7 +93,9 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
},
|
||||
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 {
|
||||
let speed =
|
||||
self.static_data.range / self.static_data.beam_duration.as_secs_f32();
|
||||
let heal = AttackEffect::new(
|
||||
@ -164,4 +168,17 @@ impl CharacterBehavior for Data {
|
||||
|
||||
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::HealingBeam(c) = &mut update.character {
|
||||
c.end = true;
|
||||
}
|
||||
}
|
||||
|
||||
update
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
||||
comp::{CharacterState, EnergyChange, EnergySource, Melee, StateUpdate},
|
||||
comp::{CharacterState, EnergyChange, EnergySource, InputKind, Melee, StateUpdate},
|
||||
consts::GRAVITY,
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
@ -58,6 +58,8 @@ pub struct Data {
|
||||
pub stage_section: StageSection,
|
||||
/// Whether the state can deal damage
|
||||
pub exhausted: bool,
|
||||
/// Whether or not the state should end
|
||||
pub end: bool,
|
||||
}
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
@ -179,7 +181,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)))
|
||||
&& /*ability_key_is_pressed(data, self.static_data.ability_info.key)*/ !self.end))
|
||||
{
|
||||
let new_spins_remaining = if self.static_data.is_infinite {
|
||||
self.spins_remaining
|
||||
@ -233,6 +235,19 @@ impl CharacterBehavior for Data {
|
||||
|
||||
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::SpinMelee(c) = &mut update.character {
|
||||
c.end = true;
|
||||
}
|
||||
}
|
||||
|
||||
update
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
|
@ -315,12 +315,8 @@ fn fly_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
|
||||
/// 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()
|
||||
|| data.inputs.ability4.is_pressed()
|
||||
{
|
||||
// data.inputs.primary.is_pressed() || data.inputs.secondary.is_pressed() ||
|
||||
data.inputs.ability3.is_pressed() || data.inputs.ability4.is_pressed() {
|
||||
attempt_wield(data, update);
|
||||
}
|
||||
}
|
||||
@ -504,6 +500,9 @@ fn handle_ability_pressed(
|
||||
pub fn handle_input(data: &JoinData, update: &mut StateUpdate, input: InputKind) {
|
||||
match input {
|
||||
InputKind::Primary => handle_ability_pressed(data, update, AbilityKey::Mouse1, Some(input)),
|
||||
InputKind::Secondary => {
|
||||
handle_ability_pressed(data, update, AbilityKey::Mouse2, Some(input))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,11 +512,11 @@ pub fn handle_input(data: &JoinData, update: &mut StateUpdate, input: InputKind)
|
||||
}
|
||||
}*/
|
||||
|
||||
pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
if data.inputs.secondary.is_pressed() {
|
||||
handle_ability_pressed(data, update, AbilityKey::Mouse2, None);
|
||||
}
|
||||
}
|
||||
// pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
// if data.inputs.secondary.is_pressed() {
|
||||
// handle_ability_pressed(data, update, AbilityKey::Mouse2, None);
|
||||
// }
|
||||
// }
|
||||
|
||||
pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
if data.inputs.ability3.is_pressed() {
|
||||
@ -614,7 +613,7 @@ pub fn get_crit_data(data: &JoinData, ai: AbilityInfo) -> (f32, f32) {
|
||||
pub fn handle_interrupt(data: &JoinData, update: &mut StateUpdate, attacks_interrupt: bool) {
|
||||
if attacks_interrupt {
|
||||
//handle_ability1_input(data, update);
|
||||
handle_ability2_input(data, update);
|
||||
// handle_ability2_input(data, update);
|
||||
handle_ability3_input(data, update);
|
||||
handle_ability4_input(data, update);
|
||||
}
|
||||
@ -628,7 +627,11 @@ pub fn ability_key_is_pressed(data: &JoinData, ability_key: AbilityKey) -> bool
|
||||
{
|
||||
false
|
||||
},
|
||||
AbilityKey::Mouse2 => data.inputs.secondary.is_pressed(),
|
||||
AbilityKey::Mouse2 =>
|
||||
/* data.inputs.secondary.is_pressed() */
|
||||
{
|
||||
false
|
||||
},
|
||||
AbilityKey::Skill1 => data.inputs.ability3.is_pressed(),
|
||||
AbilityKey::Skill2 => data.inputs.ability4.is_pressed(),
|
||||
AbilityKey::Dodge => data.inputs.roll.is_pressed(),
|
||||
|
@ -18,7 +18,7 @@ impl CharacterBehavior for Data {
|
||||
handle_jump(&data, &mut update);
|
||||
handle_climb(&data, &mut update);
|
||||
//handle_ability1_input(&data, &mut update);
|
||||
handle_ability2_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);
|
||||
|
@ -1118,10 +1118,17 @@ impl<'a> AgentData<'a> {
|
||||
if dist_sqrd < (min_attack_dist * self.scale).powi(2) {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
if agent.action_timer > 6.0 {
|
||||
controller.inputs.secondary.set_state(false);
|
||||
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.inputs.secondary.set_state(true);
|
||||
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
|
||||
@ -1170,10 +1177,17 @@ impl<'a> AgentData<'a> {
|
||||
if dist_sqrd < (min_attack_dist * self.scale).powi(2) {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
if agent.action_timer > 4.0 {
|
||||
controller.inputs.secondary.set_state(false);
|
||||
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.inputs.secondary.set_state(true);
|
||||
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
|
||||
@ -1271,7 +1285,11 @@ impl<'a> AgentData<'a> {
|
||||
controller.inputs.move_dir =
|
||||
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
|
||||
if agent.action_timer > 4.0 {
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
input: InputKind::Secondary,
|
||||
target: None,
|
||||
});
|
||||
// controller.inputs.secondary.set_state(true);
|
||||
agent.action_timer = 0.0;
|
||||
} else {
|
||||
agent.action_timer += dt.0;
|
||||
@ -1317,10 +1335,17 @@ impl<'a> AgentData<'a> {
|
||||
.unwrap_or_else(Vec2::zero)
|
||||
* speed;
|
||||
if agent.action_timer > 4.0 {
|
||||
controller.inputs.secondary.set_state(false);
|
||||
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.inputs.secondary.set_state(true);
|
||||
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
|
||||
@ -1329,11 +1354,17 @@ impl<'a> AgentData<'a> {
|
||||
&& self.energy.current() > 400
|
||||
&& thread_rng().gen_bool(0.8)
|
||||
{
|
||||
controller.inputs.secondary.set_state(false);
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::CancelInput(InputKind::Secondary));
|
||||
// controller.inputs.secondary.set_state(false);
|
||||
controller.inputs.ability3.set_state(true);
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
controller.inputs.secondary.set_state(false);
|
||||
controller
|
||||
.actions
|
||||
.push(ControlAction::CancelInput(InputKind::Secondary));
|
||||
// controller.inputs.secondary.set_state(false);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
input: InputKind::Primary,
|
||||
target: None,
|
||||
@ -1406,7 +1437,11 @@ impl<'a> AgentData<'a> {
|
||||
{
|
||||
controller.inputs.ability3.set_state(true);
|
||||
} else if self.energy.current() > 10 {
|
||||
controller.inputs.secondary.set_state(true);
|
||||
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,
|
||||
@ -1498,7 +1533,11 @@ impl<'a> AgentData<'a> {
|
||||
controller.inputs.move_dir =
|
||||
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
|
||||
if agent.action_timer > 5.0 {
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
input: InputKind::Secondary,
|
||||
target: None,
|
||||
});
|
||||
// controller.inputs.secondary.set_state(true);
|
||||
agent.action_timer = 0.0;
|
||||
} else {
|
||||
agent.action_timer += dt.0;
|
||||
@ -1542,7 +1581,11 @@ impl<'a> AgentData<'a> {
|
||||
.unwrap_or_else(Vec2::unit_y);
|
||||
agent.action_timer += dt.0;
|
||||
} else if agent.action_timer < circle_time as f32 + 0.5 {
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
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)
|
||||
@ -1552,7 +1595,11 @@ impl<'a> AgentData<'a> {
|
||||
.unwrap_or_else(Vec2::unit_y);
|
||||
agent.action_timer += dt.0;
|
||||
} else if agent.action_timer < 2.0 * circle_time as f32 + 1.0 {
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
input: InputKind::Secondary,
|
||||
target: None,
|
||||
});
|
||||
// controller.inputs.secondary.set_state(true);
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
agent.action_timer = 0.0;
|
||||
@ -1619,7 +1666,11 @@ impl<'a> AgentData<'a> {
|
||||
* speed;
|
||||
agent.action_timer += dt.0;
|
||||
}
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
input: InputKind::Secondary,
|
||||
target: None,
|
||||
});
|
||||
// controller.inputs.secondary.set_state(true);
|
||||
controller.inputs.jump.set_state(bearing.z > 1.5);
|
||||
controller.inputs.move_z = bearing.z;
|
||||
} else {
|
||||
@ -1651,7 +1702,11 @@ impl<'a> AgentData<'a> {
|
||||
//controller.inputs.primary.set_state(true);
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
controller.inputs.secondary.set_state(true);
|
||||
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)
|
||||
@ -1682,7 +1737,11 @@ impl<'a> AgentData<'a> {
|
||||
Tactic::QuadLowQuick => {
|
||||
if dist_sqrd < (1.5 * min_attack_dist * self.scale).powi(2) {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
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)
|
||||
{
|
||||
@ -1722,7 +1781,11 @@ impl<'a> AgentData<'a> {
|
||||
if agent.action_timer > 5.0 {
|
||||
agent.action_timer = 0.0;
|
||||
} else if agent.action_timer > 2.0 {
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
input: InputKind::Secondary,
|
||||
target: None,
|
||||
});
|
||||
// controller.inputs.secondary.set_state(true);
|
||||
agent.action_timer += dt.0;
|
||||
} else {
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
@ -1755,7 +1818,11 @@ impl<'a> AgentData<'a> {
|
||||
Tactic::QuadMedJump => {
|
||||
if dist_sqrd < (1.5 * min_attack_dist * self.scale).powi(2) {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
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.inputs.ability3.set_state(true);
|
||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||
@ -1792,7 +1859,11 @@ impl<'a> AgentData<'a> {
|
||||
if dist_sqrd < (min_attack_dist * self.scale).powi(2) {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
if agent.action_timer < 2.0 {
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
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 {
|
||||
@ -1827,7 +1898,11 @@ impl<'a> AgentData<'a> {
|
||||
Tactic::Lavadrake | Tactic::QuadLowBeam => {
|
||||
if dist_sqrd < (2.5 * min_attack_dist * self.scale).powi(2) {
|
||||
controller.inputs.move_dir = Vec2::zero();
|
||||
controller.inputs.secondary.set_state(true);
|
||||
controller.actions.push(ControlAction::StartInput {
|
||||
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)
|
||||
|
@ -372,7 +372,7 @@ impl PlayState for SessionState {
|
||||
}
|
||||
},
|
||||
GameInput::Secondary => {
|
||||
self.inputs.secondary.set_state(false); // To be changed later on
|
||||
// self.inputs.secondary.set_state(false); // To be changed later on
|
||||
|
||||
let mut client = self.client.borrow_mut();
|
||||
|
||||
@ -381,7 +381,8 @@ impl PlayState for SessionState {
|
||||
client.place_block(build_pos, self.selected_block);
|
||||
}
|
||||
} else {
|
||||
self.inputs.secondary.set_state(state);
|
||||
client.handle_input(InputKind::Secondary, state);
|
||||
// self.inputs.secondary.set_state(state);
|
||||
}
|
||||
},
|
||||
GameInput::Roll => {
|
||||
|
Loading…
Reference in New Issue
Block a user