Skip to content

Commit

Permalink
Keep track of total lines, base "Import Library" on total lines
Browse files Browse the repository at this point in the history
  • Loading branch information
necrashter committed Dec 8, 2023
1 parent b6d29a8 commit 9bd8287
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
24 changes: 20 additions & 4 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use bevy_editor_pls::EditorPlugin;
use iyes_progress::prelude::*;
use strum::IntoEnumIterator;

use crate::simulation::LinesAddedEvent;
use crate::simulation::Simulation;
use crate::state::AppState;

Expand Down Expand Up @@ -128,19 +129,34 @@ impl Plugin for DebugPlugin {
);
app.add_systems(
Update,
|cheat_settings: Res<CheatSettings>, mut simulation: ResMut<Simulation>| {
if cheat_settings.generate_lines {
simulation.lines += 1.0;
|mut cheat_settings: ResMut<CheatSettings>,
mut simulation: ResMut<Simulation>,
time: Res<Time>,
mut events: EventWriter<LinesAddedEvent>| {
if cheat_settings.generate_lines
&& cheat_settings.timer.tick(time.delta()).just_finished()
{
events.send(LinesAddedEvent { count: 1.0 });
}
},
);
}
}
}

#[derive(Resource, Default)]
#[derive(Resource)]
pub struct CheatSettings {
pub generate_lines: bool,
pub timer: Timer,
}

impl Default for CheatSettings {
fn default() -> Self {
Self {
generate_lines: false,
timer: Timer::from_seconds(0.2, TimerMode::Repeating),
}
}
}

const DEBUG_TOGGLE_KEY: KeyCode = KeyCode::F3;
Expand Down
6 changes: 6 additions & 0 deletions src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ pub struct Simulation {
/// Presentation factor, affects the submissions' results.
pub presentation_score: f64,

/// Total lines generated during this playthrough before the costs are subtracted.
pub total_lines: f64,

/// Newly added line count will be multiplied by this.
pub line_multiplier: f64,

Expand Down Expand Up @@ -87,6 +90,8 @@ impl Default for Simulation {
fun_score: 0.0,
presentation_score: 0.0,

total_lines: 0.0,

line_multiplier: 1.0,

entity_spawn_per_line: 0.0,
Expand Down Expand Up @@ -293,6 +298,7 @@ fn handle_line_added_events(
}
total *= simulation.line_multiplier;
simulation.lines += total;
simulation.total_lines += total;

// Spawn entities
let spawned_entities = (total * simulation.entity_spawn_per_line).floor();
Expand Down
3 changes: 2 additions & 1 deletion src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,14 @@ generate_upgrade_list!(
mut upgrade_list: ResMut<UpgradeList>,
simulation: Res<Simulation>,
| {
upgrade_list[ImportLibrary].value = (simulation.lines * 0.1).max(32.0).floor();
upgrade_list[ImportLibrary].value = (simulation.total_lines * 0.1).max(32.0).floor();
}),
),
install: Some(world.register_system(|
upgrade_list: Res<UpgradeList>,
mut simulation: ResMut<Simulation>,
| {
// TODO: Should this stack with specialization skills?
simulation.lines += upgrade_list[ImportLibrary].value;
})),
..default()
Expand Down

0 comments on commit 9bd8287

Please sign in to comment.