mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Reducing the amount of data in character state
This commit is contained in:
parent
05623eb8bd
commit
431f99a791
@ -84,8 +84,7 @@ pub enum CharacterAbility {
|
||||
projectile_light: Option<LightEmitter>,
|
||||
projectile_gravity: Option<Gravity>,
|
||||
projectile_speed: f32,
|
||||
repetitions: u32,
|
||||
current_rep: u32,
|
||||
reps_remaining: u32,
|
||||
leap: bool,
|
||||
},
|
||||
Boost {
|
||||
@ -589,8 +588,7 @@ impl From<&CharacterAbility> for CharacterState {
|
||||
projectile_light,
|
||||
projectile_gravity,
|
||||
projectile_speed,
|
||||
repetitions,
|
||||
current_rep,
|
||||
reps_remaining,
|
||||
leap,
|
||||
} => CharacterState::RepeaterRanged(repeater_ranged::Data {
|
||||
prepare_timer: Duration::default(),
|
||||
@ -603,8 +601,7 @@ impl From<&CharacterAbility> for CharacterState {
|
||||
projectile_light: *projectile_light,
|
||||
projectile_gravity: *projectile_gravity,
|
||||
projectile_speed: *projectile_speed,
|
||||
repetitions: *repetitions,
|
||||
current_rep: *current_rep,
|
||||
reps_remaining: *reps_remaining,
|
||||
leap: *leap,
|
||||
}),
|
||||
CharacterAbility::GroundShockwave {
|
||||
|
@ -349,8 +349,7 @@ impl Tool {
|
||||
projectile_light: None,
|
||||
projectile_gravity: Some(Gravity(0.2)),
|
||||
projectile_speed: 100.0,
|
||||
repetitions: 5,
|
||||
current_rep: 0,
|
||||
reps_remaining: 5,
|
||||
leap: true,
|
||||
},
|
||||
],
|
||||
|
@ -26,10 +26,8 @@ pub struct Data {
|
||||
pub projectile_light: Option<LightEmitter>,
|
||||
pub projectile_gravity: Option<Gravity>,
|
||||
pub projectile_speed: f32,
|
||||
/// How many times to repeat
|
||||
pub repetitions: u32,
|
||||
/// Current repetition
|
||||
pub current_rep: u32,
|
||||
/// How many repetitions remaining
|
||||
pub reps_remaining: u32,
|
||||
/// Whether there should be a jump
|
||||
pub leap: bool,
|
||||
}
|
||||
@ -41,7 +39,7 @@ impl CharacterBehavior for Data {
|
||||
handle_move(data, &mut update, 1.0);
|
||||
handle_jump(data, &mut update);
|
||||
|
||||
if self.current_rep <= self.repetitions
|
||||
if self.reps_remaining > 0
|
||||
&& if self.holdable {
|
||||
data.inputs.holding_ability_key() || self.prepare_timer < self.prepare_duration
|
||||
} else {
|
||||
@ -60,8 +58,7 @@ impl CharacterBehavior for Data {
|
||||
projectile_light: self.projectile_light,
|
||||
projectile_gravity: self.projectile_gravity,
|
||||
projectile_speed: self.projectile_speed,
|
||||
repetitions: self.repetitions,
|
||||
current_rep: self.current_rep,
|
||||
reps_remaining: self.reps_remaining,
|
||||
leap: self.leap,
|
||||
});
|
||||
} else if self.movement_duration != Duration::default() {
|
||||
@ -84,8 +81,7 @@ impl CharacterBehavior for Data {
|
||||
projectile_light: self.projectile_light,
|
||||
projectile_gravity: self.projectile_gravity,
|
||||
projectile_speed: self.projectile_speed,
|
||||
repetitions: self.repetitions,
|
||||
current_rep: self.current_rep,
|
||||
reps_remaining: self.reps_remaining,
|
||||
leap: self.leap,
|
||||
});
|
||||
} else if self.recover_duration != Duration::default() {
|
||||
@ -107,11 +103,10 @@ impl CharacterBehavior for Data {
|
||||
projectile_light: self.projectile_light,
|
||||
projectile_gravity: self.projectile_gravity,
|
||||
projectile_speed: self.projectile_speed,
|
||||
repetitions: self.repetitions,
|
||||
current_rep: self.current_rep,
|
||||
reps_remaining: self.reps_remaining,
|
||||
leap: self.leap,
|
||||
});
|
||||
} else if self.current_rep < self.repetitions {
|
||||
} else if self.reps_remaining > 0 {
|
||||
// Hover
|
||||
update.vel.0 = Vec3::new(data.vel.0[0], data.vel.0[1], 0.0);
|
||||
|
||||
@ -122,16 +117,16 @@ impl CharacterBehavior for Data {
|
||||
entity: data.entity,
|
||||
dir: Dir::from_unnormalized(Vec3::new(
|
||||
data.inputs.look_dir[0]
|
||||
+ (if self.current_rep % 2 == 0 {
|
||||
self.current_rep as f32 / 400.0
|
||||
+ (if self.reps_remaining % 2 == 0 {
|
||||
self.reps_remaining as f32 / 400.0
|
||||
} else {
|
||||
-1.0 * self.current_rep as f32 / 400.0
|
||||
-1.0 * self.reps_remaining as f32 / 400.0
|
||||
}),
|
||||
data.inputs.look_dir[1]
|
||||
+ (if self.current_rep % 2 == 0 {
|
||||
-1.0 * self.current_rep as f32 / 400.0
|
||||
+ (if self.reps_remaining % 2 == 0 {
|
||||
-1.0 * self.reps_remaining as f32 / 400.0
|
||||
} else {
|
||||
self.current_rep as f32 / 400.0
|
||||
self.reps_remaining as f32 / 400.0
|
||||
}),
|
||||
data.inputs.look_dir[2],
|
||||
))
|
||||
@ -158,8 +153,7 @@ impl CharacterBehavior for Data {
|
||||
projectile_light: self.projectile_light,
|
||||
projectile_gravity: self.projectile_gravity,
|
||||
projectile_speed: self.projectile_speed,
|
||||
repetitions: self.repetitions,
|
||||
current_rep: self.current_rep + 1,
|
||||
reps_remaining: self.reps_remaining - 1,
|
||||
leap: self.leap,
|
||||
});
|
||||
return update;
|
||||
|
@ -901,7 +901,7 @@ impl FigureMgr {
|
||||
}
|
||||
},
|
||||
CharacterState::RepeaterRanged(data) => {
|
||||
if data.current_rep != 0 {
|
||||
if data.reps_remaining > 0 {
|
||||
anim::character::ShootAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
|
||||
|
Loading…
Reference in New Issue
Block a user