mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Projectile hits regenerate energy
This commit is contained in:
parent
4bfc934772
commit
ad0314b4f5
@ -106,6 +106,7 @@ impl ToolData {
|
||||
cause: HealthSource::Projectile { owner: None },
|
||||
}),
|
||||
projectile::Effect::Knockback(10.0),
|
||||
projectile::Effect::RewardEnergy(100),
|
||||
projectile::Effect::Vanish,
|
||||
],
|
||||
time_left: Duration::from_secs(15),
|
||||
@ -146,6 +147,7 @@ impl ToolData {
|
||||
amount: -1,
|
||||
cause: HealthSource::Projectile { owner: None },
|
||||
}),
|
||||
projectile::Effect::RewardEnergy(100),
|
||||
projectile::Effect::Vanish,
|
||||
],
|
||||
time_left: Duration::from_secs(20),
|
||||
|
@ -7,6 +7,7 @@ use std::time::Duration;
|
||||
pub enum Effect {
|
||||
Damage(comp::HealthChange),
|
||||
Knockback(f32),
|
||||
RewardEnergy(u32),
|
||||
Explode { power: f32 },
|
||||
Vanish,
|
||||
Stick,
|
||||
|
@ -1,5 +1,7 @@
|
||||
use crate::{
|
||||
comp::{projectile, HealthSource, Ori, PhysicsState, Pos, Projectile, Vel},
|
||||
comp::{
|
||||
projectile, Energy, EnergySource, HealthSource, Ori, PhysicsState, Pos, Projectile, Vel,
|
||||
},
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
state::DeltaTime,
|
||||
sync::UidAllocator,
|
||||
@ -22,6 +24,7 @@ impl<'a> System<'a> for Sys {
|
||||
ReadStorage<'a, Vel>,
|
||||
WriteStorage<'a, Ori>,
|
||||
WriteStorage<'a, Projectile>,
|
||||
WriteStorage<'a, Energy>,
|
||||
);
|
||||
|
||||
fn run(
|
||||
@ -37,6 +40,7 @@ impl<'a> System<'a> for Sys {
|
||||
velocities,
|
||||
mut orientations,
|
||||
mut projectiles,
|
||||
mut energies,
|
||||
): Self::SystemData,
|
||||
) {
|
||||
let mut local_emitter = local_bus.emitter();
|
||||
@ -108,6 +112,15 @@ impl<'a> System<'a> for Sys {
|
||||
});
|
||||
}
|
||||
},
|
||||
projectile::Effect::RewardEnergy(energy) => {
|
||||
if let Some(energy_mut) = projectile
|
||||
.owner
|
||||
.and_then(|o| uid_allocator.retrieve_entity_internal(o.into()))
|
||||
.and_then(|o| energies.get_mut(o))
|
||||
{
|
||||
energy_mut.change_by(energy as i32, EnergySource::HitEnemy);
|
||||
}
|
||||
},
|
||||
projectile::Effect::Explode { power } => {
|
||||
server_emitter.emit(ServerEvent::Explosion {
|
||||
pos: pos.0,
|
||||
|
Loading…
Reference in New Issue
Block a user