mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
add knockback localevent
This commit is contained in:
parent
598a4c6cbb
commit
52059d83d3
@ -47,6 +47,7 @@ pub enum SfxEvent {
|
||||
|
||||
pub enum LocalEvent {
|
||||
Jump(EcsEntity),
|
||||
Knockback(EcsEntity),
|
||||
WallLeap {
|
||||
entity: EcsEntity,
|
||||
wall_dir: Vec3<f32>,
|
||||
|
@ -334,6 +334,7 @@ impl State {
|
||||
let events = self.ecs.read_resource::<EventBus<LocalEvent>>().recv_all();
|
||||
for event in events {
|
||||
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
||||
let mut orientations = self.ecs.write_storage::<comp::Ori>();
|
||||
let mut controllers = self.ecs.write_storage::<comp::Controller>();
|
||||
match event {
|
||||
LocalEvent::Jump(entity) => {
|
||||
@ -341,6 +342,14 @@ impl State {
|
||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||
}
|
||||
},
|
||||
LocalEvent::Knockback(entity) => {
|
||||
if let Some(vel) = velocities.get_mut(entity) {
|
||||
if let Some(ori) = orientations.get_mut(entity) {
|
||||
vel.0 = -ori.0 * 10.0;
|
||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||
}
|
||||
}
|
||||
},
|
||||
LocalEvent::WallLeap { entity, wall_dir } => {
|
||||
if let (Some(vel), Some(_controller)) =
|
||||
(velocities.get_mut(entity), controllers.get_mut(entity))
|
||||
|
Loading…
Reference in New Issue
Block a user