Skip to content

Commit

Permalink
Balance some more
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Dec 11, 2023
1 parent 5ef4ce1 commit ee867cf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ const MAX_SPAWN_PER_EVENT: usize = 8;
pub struct SpawnEvent {
pub position: Vec2,
pub count: f64,
pub custom_cap: Option<usize>,
}

fn spawn_entities(world: &mut World, mut reader: Local<ManualEventReader<SpawnEvent>>) {
Expand All @@ -213,8 +214,12 @@ fn spawn_entities(world: &mut World, mut reader: Local<ManualEventReader<SpawnEv
let simulation = world.resource::<Simulation>();
let mut spawn_count = event.count as usize;
if simulation.entities >= ENTITY_CAP as f64 {
spawn_count = MAX_SPAWN_PER_EVENT.min(spawn_count);
spawn_count = event
.custom_cap
.unwrap_or(MAX_SPAWN_PER_EVENT)
.min(spawn_count);
}

let mut bundles = vec![];
for _ in 0..spawn_count {
let angle = rng.gen_range(0.0..=TAU);
Expand Down Expand Up @@ -245,7 +250,6 @@ fn spawn_entities(world: &mut World, mut reader: Local<ManualEventReader<SpawnEv
));
}

// TODO: Technically, we don't need to set the velocity. We can assign random velocities in spawn_entity_pool
for (visibility, transform, velocity, sprite, texture) in bundles {
let entity = world.resource_mut::<EntityPool>().recycle();
let mut entity = world.entity_mut(entity);
Expand Down Expand Up @@ -353,6 +357,7 @@ fn spawn_entities_passively(
events.send(SpawnEvent {
position: (bounds.min.xy() + bounds.max.xy()) / 2.0,
count: spawner.amount,
custom_cap: None,
});
}

Expand Down Expand Up @@ -381,6 +386,7 @@ fn handle_line_added_events(
spawn_events.send(SpawnEvent {
position: (bounds.min.xy() + bounds.max.xy()) / 2.0,
count: spawned_entities,
custom_cap: None,
});
}
}
1 change: 1 addition & 0 deletions src/state/editor_screen/scene_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ fn click_spawn(
events.send(SpawnEvent {
position,
count: scene_view.spawns_per_click,
custom_cap: Some(250),
});
scene_view.spawns_per_click *= scene_view.spawns_per_click_multiplier_per_click;
}
Expand Down
18 changes: 11 additions & 7 deletions src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ generate_upgrade_list!(
spawn_events.send(SpawnEvent {
count: simulation.entities * 3.0,
position: (bounds.min.xy() + bounds.max.xy()) / 2.0,
custom_cap: None,
});
line_events.send(LinesAddedEvent {
count: simulation.lines * 3.0,
Expand Down Expand Up @@ -604,7 +605,7 @@ generate_upgrade_list!(
base_cost: 2_000.0,
cost_scale_factor: 1.2,
weight: 0.25,
entity_min: 400.0,
entity_min: 1_000.0,
install: Some(world.register_system(|
mut physics_settings: ResMut<PhysicsSettings>,
| {
Expand Down Expand Up @@ -642,6 +643,7 @@ generate_upgrade_list!(
events.send(SpawnEvent {
position: (bounds.min.xy() + bounds.max.xy()) / 2.0,
count: this.value,
custom_cap: Some(200),
});
}),
),
Expand Down Expand Up @@ -675,6 +677,7 @@ generate_upgrade_list!(
events.send(SpawnEvent {
position: (bounds.min.xy() + bounds.max.xy()) / 2.0,
count: simulation.lines,
custom_cap: Some(2000),
});

simulation.lines = 0.0;
Expand Down Expand Up @@ -702,6 +705,7 @@ generate_upgrade_list!(
events.send(SpawnEvent {
position: (bounds.min.xy() + bounds.max.xy()) / 2.0,
count: 1.0,
custom_cap: None,
});

for mut scene_view in &mut scene_view_query {
Expand All @@ -716,7 +720,7 @@ generate_upgrade_list!(
name: "Laptop Sticker".to_string(),
desc: "Spawns 1 more entity per click.".to_string(),
base_cost: 15.0,
weight: 1.0,
weight: 2.0,
remaining: 4,
install: Some(
world.register_system(|mut scene_view_query: Query<&mut SceneView>| {
Expand Down Expand Up @@ -953,7 +957,7 @@ generate_upgrade_list!(
Types an extra 5 characters per key press.\
".to_string(),
sound: Some(SoundEffectKind::Keyboard),
base_cost: 20.0,
base_cost: 15.0,
install: Some(world.register_system(|
mut typer_query: Query<&mut CodeTyper>,
| {
Expand Down Expand Up @@ -1009,9 +1013,9 @@ generate_upgrade_list!(
sound: Some(SoundEffectKind::Keyboard),
no_count: true,
base_cost: 150.0,
weight: 2.5,
weight: 3.5,
remaining: 3,
entity_min: 250.0,
entity_min: 150.0,
installed_min: vec![(MechanicalKeyboard, 1)],
install: Some(world.register_system(|
mut typer_query: Query<&mut CodeTyper>,
Expand Down Expand Up @@ -1156,8 +1160,8 @@ generate_upgrade_list!(
tech_debt: -5.0,
base_cost: 50.0,
cost_scale_factor: 1.5,
weight: 2.0,
remaining: 8,
weight: 4.0,
remaining: 10,
tech_debt_min: 5.0,
install: Some(world.register_system(|mut upgrade_list: ResMut<UpgradeList>| {
let this = &mut upgrade_list[Refactor];
Expand Down

0 comments on commit ee867cf

Please sign in to comment.