mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add knockback
Former-commit-id: a703eb937ef7094a085548ca3197a575059855a0
This commit is contained in:
parent
a0918d11b6
commit
30bf1cde10
@ -103,6 +103,7 @@ impl State {
|
||||
ecs.register_synced::<comp::Actor>();
|
||||
ecs.register_synced::<comp::Player>();
|
||||
ecs.register_synced::<comp::Stats>();
|
||||
ecs.register::<comp::phys::ForceUpdate>();
|
||||
|
||||
// Register unsynced (or synced by other means) components.
|
||||
ecs.register::<comp::phys::Pos>();
|
||||
|
@ -5,7 +5,7 @@ use vek::*;
|
||||
// Crate
|
||||
use crate::{
|
||||
comp::{
|
||||
phys::{Pos, Vel},
|
||||
phys::{ForceUpdate, Pos, Vel},
|
||||
Action, Actions, Control, Stats,
|
||||
},
|
||||
state::{DeltaTime, Time},
|
||||
@ -23,11 +23,12 @@ impl<'a> System<'a> for Sys {
|
||||
ReadStorage<'a, Pos>,
|
||||
WriteStorage<'a, Vel>,
|
||||
WriteStorage<'a, Stats>,
|
||||
WriteStorage<'a, ForceUpdate>,
|
||||
);
|
||||
|
||||
fn run(
|
||||
&mut self,
|
||||
(entities, time, dt, mut actions, positions, mut velocities, mut stats): Self::SystemData,
|
||||
(entities, time, dt, mut actions, positions, mut velocities, mut stats, mut force_updates): Self::SystemData,
|
||||
) {
|
||||
for (a, actions_a, pos_a) in (&entities, &mut actions, &positions).join() {
|
||||
for event in actions_a.0.drain(..) {
|
||||
@ -40,7 +41,10 @@ impl<'a> System<'a> for Sys {
|
||||
continue;
|
||||
}
|
||||
if pos_a.0.distance_squared(pos_b.0) < 50.0 {
|
||||
stat_b.hp.change_by(-60); // TODO: variable damage
|
||||
stat_b.hp.change_by(-10); // TODO: variable damage
|
||||
vel_b.0 += (pos_b.0 - pos_a.0).normalized() * 20.0;
|
||||
vel_b.0.z = 20.0;
|
||||
force_updates.insert(b, ForceUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,6 @@ impl Server {
|
||||
let (chunk_tx, chunk_rx) = mpsc::channel();
|
||||
|
||||
let mut state = State::new();
|
||||
state.ecs_mut().register::<comp::phys::ForceUpdate>();
|
||||
state
|
||||
.ecs_mut()
|
||||
.add_resource(SpawnPoint(Vec3::new(16_384.0, 16_384.0, 280.0)));
|
||||
|
Loading…
Reference in New Issue
Block a user