Skip to content

Commit

Permalink
Switch mapping over to being a plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-thompson committed Jan 21, 2024
1 parent 7038e65 commit a7bc050
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod mapping;
mod tilemap;
mod util;

use mapping::*;
use util::IteratorToArrayExt;

#[derive(Clone, Debug, Parser, Resource)]
Expand Down Expand Up @@ -73,9 +72,10 @@ fn main() {
}),
..default()
}),
assets::Plugin,
editor::Plugin,
ecs_tilemap::TilemapPlugin,
assets::Plugin,
mapping::Plugin,
tilemap::TiledMapPlugin,
dashboard::Plugin,
))
Expand All @@ -88,7 +88,6 @@ fn main() {
.add_systems(
Update,
(
generate_guidance_field,
handle_keyboard,
handle_ai_players,
apply_velocity
Expand All @@ -100,7 +99,6 @@ fn main() {
.after(apply_velocity)
.after(handle_keyboard)
.after(handle_ai_players),
apply_time_penalties,
),
)
.run();
Expand Down Expand Up @@ -251,7 +249,7 @@ fn spawn_ai_players(
fn apply_friction(
mut query: Query<(&mut Velocity, &mut Transform)>,
time: Res<Time>,
guide: Option<Res<GuidanceField>>,
guide: Option<Res<mapping::GuidanceField>>,
) {
let delta = time.delta_seconds();
for (mut v, t) in query.iter_mut() {
Expand Down Expand Up @@ -445,7 +443,7 @@ fn handle_ai_players(
Without<Player>,
)>,
time: Res<Time>,
guide: Option<Res<GuidanceField>>,
guide: Option<Res<mapping::GuidanceField>>,
prefs: Res<Preferences>,
mut gizmos: Gizmos,
) {
Expand Down
9 changes: 9 additions & 0 deletions src/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ use itertools::Itertools;

use crate::{tilemap, Player, Racer};

#[derive(Default)]
pub struct Plugin;

impl bevy::app::Plugin for Plugin {
fn build(&self, app: &mut App) {
app.add_systems(Update, (generate_guidance_field, apply_time_penalties));
}
}

#[derive(Resource)]
pub struct GuidanceField {
image: image::GrayImage,
Expand Down

0 comments on commit a7bc050

Please sign in to comment.