Skip to content

Commit

Permalink
Implement BurstOfLifePlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Dec 6, 2023
1 parent e12675b commit c5f1ea3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ mod cost_scaling;

use bevy::ecs::event::ManualEventReader;
use bevy::ecs::system::SystemId;
use bevy::math::vec2;
use bevy::prelude::*;
use rand::thread_rng;
use rand::Rng;
use strum::EnumIter;

use crate::config::Config;
use crate::simulation::Simulation;
use crate::simulation::SpawnEvent;
use crate::state::editor_screen::spawn_editor_screen;
use crate::state::editor_screen::SceneView;
use crate::state::editor_screen::UpgradeContainer;
Expand Down Expand Up @@ -160,9 +164,15 @@ fn load_upgrade_list(world: &mut World) {
weight: 1.0,
remaining: usize::MAX,

enable: Some(world.register_system(|mut simulation: ResMut<Simulation>| {
simulation.entities += 10.0;
})),
enable: Some(
world.register_system(|mut events: EventWriter<SpawnEvent>| {
let mut rng = thread_rng();
for _ in 0..10 {
let pos = vec2(rng.gen_range(-50.0..=50.0), rng.gen_range(-20.0..=40.0));
events.send(SpawnEvent(pos));
}
}),
),
update: None,
},
Upgrade {
Expand Down

0 comments on commit c5f1ea3

Please sign in to comment.