add projectile lifetimes
This commit is contained in:
parent
68f4b0d8a0
commit
69bab35998
3 changed files with 25 additions and 5 deletions
|
|
@ -1,11 +1,11 @@
|
|||
(
|
||||
map: {
|
||||
MouseButton(Middle): [
|
||||
CameraOrbitEnable,
|
||||
],
|
||||
KeyCode(ShiftLeft): [
|
||||
MultiPlaceTower,
|
||||
],
|
||||
MouseButton(Middle): [
|
||||
CameraOrbitEnable,
|
||||
],
|
||||
KeyCode(F1): [
|
||||
ToggleDebugUI,
|
||||
],
|
||||
|
|
|
|||
|
|
@ -16,7 +16,13 @@ pub(crate) struct ProjectilePlugin;
|
|||
|
||||
impl Plugin for ProjectilePlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(FixedUpdate, fire_launcher.in_set(GameSystemSet::Execute));
|
||||
app.add_systems(
|
||||
FixedUpdate,
|
||||
(
|
||||
fire_launcher.in_set(GameSystemSet::Execute),
|
||||
tick_lifetime.in_set(GameSystemSet::PostTick),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -154,6 +160,20 @@ fn fire_launcher(
|
|||
}
|
||||
}
|
||||
|
||||
fn tick_lifetime(
|
||||
mut projectiles: Query<(Entity, &mut Projectile)>,
|
||||
mut commands: Commands,
|
||||
time: Res<Time>,
|
||||
) {
|
||||
let delta = time.delta();
|
||||
for (entity, mut projectile) in projectiles.iter_mut() {
|
||||
projectile.lifetime = projectile.lifetime.saturating_sub(delta);
|
||||
if projectile.lifetime == Duration::ZERO {
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// may shoot higher than height if delta y is too big
|
||||
pub fn get_launch_vector(start: Vec3, target: Vec3, height: f32, spread: f32) -> Vec3 {
|
||||
// actually +/-, but go with + for now
|
||||
|
|
|
|||
2
todo.txt
2
todo.txt
|
|
@ -11,7 +11,7 @@ x improve enemy AI
|
|||
- More towers
|
||||
- More upgrades
|
||||
x More enemy types
|
||||
- More resource deposit types
|
||||
x More resource deposit types
|
||||
- Improve wave generation
|
||||
|
||||
--- STILL PRETTY IMPORTANT ---
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue