mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Combine dir and force in KnockUp and ApplyForce events
This commit is contained in:
parent
ba3fa16c33
commit
ce0f54e9d6
@ -47,19 +47,11 @@ pub enum SfxEvent {
|
||||
pub enum LocalEvent {
|
||||
/// Applies upward force to entity's `Vel`
|
||||
Jump(EcsEntity),
|
||||
/// Applies the `force` + implicit upward force, in `dir` direction to
|
||||
/// Applies the `force` + implicit upward force to
|
||||
/// `entity`'s `Vel`
|
||||
KnockUp {
|
||||
entity: EcsEntity,
|
||||
dir: Vec3<f32>,
|
||||
force: f32,
|
||||
},
|
||||
/// Applies the `force`, in `dir` direction to `entity`'s `Vel`
|
||||
ApplyForce {
|
||||
entity: EcsEntity,
|
||||
dir: Vec3<f32>,
|
||||
force: f32,
|
||||
},
|
||||
KnockUp { entity: EcsEntity, force: Vec3<f32> },
|
||||
/// Applies the `force` to `entity`'s `Vel`
|
||||
ApplyForce { entity: EcsEntity, force: Vec3<f32> },
|
||||
/// Applies leaping force to `entity`'s `Vel` away from `wall_dir` direction
|
||||
WallLeap {
|
||||
entity: EcsEntity,
|
||||
|
@ -355,15 +355,17 @@ impl State {
|
||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||
}
|
||||
},
|
||||
LocalEvent::KnockUp { entity, dir, force } => {
|
||||
LocalEvent::KnockUp { entity, force } => {
|
||||
if let Some(vel) = velocities.get_mut(entity) {
|
||||
vel.0 = dir * force;
|
||||
vel.0 = force;
|
||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||
}
|
||||
},
|
||||
LocalEvent::ApplyForce { entity, dir, force } => {
|
||||
LocalEvent::ApplyForce { entity, force } => {
|
||||
// TODO: this sets the velocity directly to the value of `force`, consider
|
||||
// renaming the event or changing the behavior
|
||||
if let Some(vel) = velocities.get_mut(entity) {
|
||||
vel.0 = dir * force;
|
||||
vel.0 = force;
|
||||
}
|
||||
},
|
||||
LocalEvent::WallLeap { entity, wall_dir } => {
|
||||
|
@ -141,8 +141,8 @@ impl<'a> System<'a> for Sys {
|
||||
if attack.knockback != 0.0 {
|
||||
local_emitter.emit(LocalEvent::ApplyForce {
|
||||
entity: b,
|
||||
dir: *Dir::slerp(ori.0, Dir::new(Vec3::new(0.0, 0.0, 1.0)), 0.5),
|
||||
force: attack.knockback,
|
||||
force: attack.knockback
|
||||
* *Dir::slerp(ori.0, Dir::new(Vec3::new(0.0, 0.0, 1.0)), 0.5),
|
||||
});
|
||||
}
|
||||
attack.hit_count += 1;
|
||||
|
@ -108,8 +108,8 @@ impl<'a> System<'a> for Sys {
|
||||
{
|
||||
local_emitter.emit(LocalEvent::ApplyForce {
|
||||
entity,
|
||||
dir: *Dir::slerp(ori.0, Dir::new(Vec3::unit_z()), 0.5),
|
||||
force: knockback,
|
||||
force: knockback
|
||||
* *Dir::slerp(ori.0, Dir::new(Vec3::unit_z()), 0.5),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user