Skip to content

Commit

Permalink
Make SplashOfLifePlugin spawn 32 entities from a single point
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Dec 6, 2023
1 parent 5717504 commit 3b9d242
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/state/editor_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::state::editor_screen::info_bar::spawn_info_bar;
use crate::state::editor_screen::outline_panel::spawn_outline_panel;
use crate::state::editor_screen::scene_view::spawn_scene_view;
pub use crate::state::editor_screen::scene_view::SceneView;
pub use crate::state::editor_screen::scene_view::SceneViewBounds;
pub use crate::state::editor_screen::scene_view::WrapWithinSceneView;
use crate::state::editor_screen::upgrade_panel::spawn_upgrade_panel;
pub use crate::state::editor_screen::upgrade_panel::UpgradeContainer;
Expand Down
6 changes: 3 additions & 3 deletions src/state/editor_screen/scene_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ fn click_spawn(

#[derive(Resource, Reflect, Default)]
#[reflect(Resource)]
struct SceneViewBounds {
min: Vec3,
max: Vec3,
pub struct SceneViewBounds {
pub min: Vec3,
pub max: Vec3,
}

fn update_scene_view_bounds(
Expand Down
20 changes: 8 additions & 12 deletions src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +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::EnumCount;

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::SceneViewBounds;
use crate::state::editor_screen::UpgradeContainer;
use crate::AppRoot;
use crate::AppSet;
Expand Down Expand Up @@ -97,7 +95,7 @@ impl UpgradeList {
pub const INITIAL_UPGRADES: [UpgradeKind; 5] = [
UpgradeKind::DarkMode,
UpgradeKind::TouchOfLifePlugin,
UpgradeKind::BurstOfLifePlugin,
UpgradeKind::SplashOfLifePlugin,
UpgradeKind::Brainstorm,
UpgradeKind::ImportLibrary,
];
Expand Down Expand Up @@ -174,20 +172,18 @@ generate_upgrade_list!(
),
update: None,
},
BurstOfLifePlugin: Upgrade {
name: "BurstOfLifePlugin".to_string(),
description: "Spawns 10 entities immediately.".to_string(),
SplashOfLifePlugin: Upgrade {
name: "SplashOfLifePlugin".to_string(),
description: "Spawns 32 entities immediately.".to_string(),

cost: 2.0,
weight: 1.0,
remaining: usize::MAX,

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));
world.register_system(|mut events: EventWriter<SpawnEvent>, bounds: Res<SceneViewBounds>| {
for _ in 0..32 {
events.send(SpawnEvent((bounds.min.xy() + bounds.max.xy()) / 2.0));
}
}),
),
Expand Down

0 comments on commit 3b9d242

Please sign in to comment.