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_light: Option<LightEmitter>,
|
||||||
projectile_gravity: Option<Gravity>,
|
projectile_gravity: Option<Gravity>,
|
||||||
projectile_speed: f32,
|
projectile_speed: f32,
|
||||||
repetitions: u32,
|
reps_remaining: u32,
|
||||||
current_rep: u32,
|
|
||||||
leap: bool,
|
leap: bool,
|
||||||
},
|
},
|
||||||
Boost {
|
Boost {
|
||||||
@ -589,8 +588,7 @@ impl From<&CharacterAbility> for CharacterState {
|
|||||||
projectile_light,
|
projectile_light,
|
||||||
projectile_gravity,
|
projectile_gravity,
|
||||||
projectile_speed,
|
projectile_speed,
|
||||||
repetitions,
|
reps_remaining,
|
||||||
current_rep,
|
|
||||||
leap,
|
leap,
|
||||||
} => CharacterState::RepeaterRanged(repeater_ranged::Data {
|
} => CharacterState::RepeaterRanged(repeater_ranged::Data {
|
||||||
prepare_timer: Duration::default(),
|
prepare_timer: Duration::default(),
|
||||||
@ -603,8 +601,7 @@ impl From<&CharacterAbility> 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,
|
||||||
repetitions: *repetitions,
|
reps_remaining: *reps_remaining,
|
||||||
current_rep: *current_rep,
|
|
||||||
leap: *leap,
|
leap: *leap,
|
||||||
}),
|
}),
|
||||||
CharacterAbility::GroundShockwave {
|
CharacterAbility::GroundShockwave {
|
||||||
|
@ -349,8 +349,7 @@ impl Tool {
|
|||||||
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,
|
||||||
repetitions: 5,
|
reps_remaining: 5,
|
||||||
current_rep: 0,
|
|
||||||
leap: true,
|
leap: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -26,10 +26,8 @@ pub struct Data {
|
|||||||
pub projectile_light: Option<LightEmitter>,
|
pub projectile_light: Option<LightEmitter>,
|
||||||
pub projectile_gravity: Option<Gravity>,
|
pub projectile_gravity: Option<Gravity>,
|
||||||
pub projectile_speed: f32,
|
pub projectile_speed: f32,
|
||||||
/// How many times to repeat
|
/// How many repetitions remaining
|
||||||
pub repetitions: u32,
|
pub reps_remaining: u32,
|
||||||
/// Current repetition
|
|
||||||
pub current_rep: u32,
|
|
||||||
/// Whether there should be a jump
|
/// Whether there should be a jump
|
||||||
pub leap: bool,
|
pub leap: bool,
|
||||||
}
|
}
|
||||||
@ -41,7 +39,7 @@ impl CharacterBehavior for Data {
|
|||||||
handle_move(data, &mut update, 1.0);
|
handle_move(data, &mut update, 1.0);
|
||||||
handle_jump(data, &mut update);
|
handle_jump(data, &mut update);
|
||||||
|
|
||||||
if self.current_rep <= self.repetitions
|
if self.reps_remaining > 0
|
||||||
&& if self.holdable {
|
&& if self.holdable {
|
||||||
data.inputs.holding_ability_key() || self.prepare_timer < self.prepare_duration
|
data.inputs.holding_ability_key() || self.prepare_timer < self.prepare_duration
|
||||||
} else {
|
} else {
|
||||||
@ -60,8 +58,7 @@ impl CharacterBehavior for Data {
|
|||||||
projectile_light: self.projectile_light,
|
projectile_light: self.projectile_light,
|
||||||
projectile_gravity: self.projectile_gravity,
|
projectile_gravity: self.projectile_gravity,
|
||||||
projectile_speed: self.projectile_speed,
|
projectile_speed: self.projectile_speed,
|
||||||
repetitions: self.repetitions,
|
reps_remaining: self.reps_remaining,
|
||||||
current_rep: self.current_rep,
|
|
||||||
leap: self.leap,
|
leap: self.leap,
|
||||||
});
|
});
|
||||||
} else if self.movement_duration != Duration::default() {
|
} else if self.movement_duration != Duration::default() {
|
||||||
@ -84,8 +81,7 @@ impl CharacterBehavior for Data {
|
|||||||
projectile_light: self.projectile_light,
|
projectile_light: self.projectile_light,
|
||||||
projectile_gravity: self.projectile_gravity,
|
projectile_gravity: self.projectile_gravity,
|
||||||
projectile_speed: self.projectile_speed,
|
projectile_speed: self.projectile_speed,
|
||||||
repetitions: self.repetitions,
|
reps_remaining: self.reps_remaining,
|
||||||
current_rep: self.current_rep,
|
|
||||||
leap: self.leap,
|
leap: self.leap,
|
||||||
});
|
});
|
||||||
} else if self.recover_duration != Duration::default() {
|
} else if self.recover_duration != Duration::default() {
|
||||||
@ -107,11 +103,10 @@ impl CharacterBehavior for Data {
|
|||||||
projectile_light: self.projectile_light,
|
projectile_light: self.projectile_light,
|
||||||
projectile_gravity: self.projectile_gravity,
|
projectile_gravity: self.projectile_gravity,
|
||||||
projectile_speed: self.projectile_speed,
|
projectile_speed: self.projectile_speed,
|
||||||
repetitions: self.repetitions,
|
reps_remaining: self.reps_remaining,
|
||||||
current_rep: self.current_rep,
|
|
||||||
leap: self.leap,
|
leap: self.leap,
|
||||||
});
|
});
|
||||||
} else if self.current_rep < self.repetitions {
|
} else if self.reps_remaining > 0 {
|
||||||
// Hover
|
// Hover
|
||||||
update.vel.0 = Vec3::new(data.vel.0[0], data.vel.0[1], 0.0);
|
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,
|
entity: data.entity,
|
||||||
dir: Dir::from_unnormalized(Vec3::new(
|
dir: Dir::from_unnormalized(Vec3::new(
|
||||||
data.inputs.look_dir[0]
|
data.inputs.look_dir[0]
|
||||||
+ (if self.current_rep % 2 == 0 {
|
+ (if self.reps_remaining % 2 == 0 {
|
||||||
self.current_rep as f32 / 400.0
|
self.reps_remaining as f32 / 400.0
|
||||||
} else {
|
} else {
|
||||||
-1.0 * self.current_rep as f32 / 400.0
|
-1.0 * self.reps_remaining as f32 / 400.0
|
||||||
}),
|
}),
|
||||||
data.inputs.look_dir[1]
|
data.inputs.look_dir[1]
|
||||||
+ (if self.current_rep % 2 == 0 {
|
+ (if self.reps_remaining % 2 == 0 {
|
||||||
-1.0 * self.current_rep as f32 / 400.0
|
-1.0 * self.reps_remaining as f32 / 400.0
|
||||||
} else {
|
} else {
|
||||||
self.current_rep as f32 / 400.0
|
self.reps_remaining as f32 / 400.0
|
||||||
}),
|
}),
|
||||||
data.inputs.look_dir[2],
|
data.inputs.look_dir[2],
|
||||||
))
|
))
|
||||||
@ -158,8 +153,7 @@ impl CharacterBehavior for Data {
|
|||||||
projectile_light: self.projectile_light,
|
projectile_light: self.projectile_light,
|
||||||
projectile_gravity: self.projectile_gravity,
|
projectile_gravity: self.projectile_gravity,
|
||||||
projectile_speed: self.projectile_speed,
|
projectile_speed: self.projectile_speed,
|
||||||
repetitions: self.repetitions,
|
reps_remaining: self.reps_remaining - 1,
|
||||||
current_rep: self.current_rep + 1,
|
|
||||||
leap: self.leap,
|
leap: self.leap,
|
||||||
});
|
});
|
||||||
return update;
|
return update;
|
||||||
|
@ -901,7 +901,7 @@ impl FigureMgr {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
CharacterState::RepeaterRanged(data) => {
|
CharacterState::RepeaterRanged(data) => {
|
||||||
if data.current_rep != 0 {
|
if data.reps_remaining > 0 {
|
||||||
anim::character::ShootAnimation::update_skeleton(
|
anim::character::ShootAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
|
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
|
||||||
|
Loading…
Reference in New Issue
Block a user