From 325d6034e17a2a9ed2a307aeb58615fa86c379d1 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sun, 21 Jan 2024 11:44:20 +0000 Subject: [PATCH] Move the modules out of helpers. --- src/{helpers => }/editor.rs | 0 src/helpers/mod.rs | 6 ------ src/main.rs | 25 +++++++++++++------------ src/{helpers/tiled.rs => tilemap.rs} | 0 4 files changed, 13 insertions(+), 18 deletions(-) rename src/{helpers => }/editor.rs (100%) delete mode 100644 src/helpers/mod.rs rename src/{helpers/tiled.rs => tilemap.rs} (100%) diff --git a/src/helpers/editor.rs b/src/editor.rs similarity index 100% rename from src/helpers/editor.rs rename to src/editor.rs diff --git a/src/helpers/mod.rs b/src/helpers/mod.rs deleted file mode 100644 index eef520c..0000000 --- a/src/helpers/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// Copyright (C) 2024 Daniel Thompson -// - -pub mod editor; -pub mod tiled; diff --git a/src/main.rs b/src/main.rs index 0008e5c..25a6a0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use bevy::{ render::camera::ScalingMode, window, }; -use bevy_ecs_tilemap::prelude::*; +use bevy_ecs_tilemap::prelude as ecs_tilemap; use clap::Parser; use itertools::Itertools; use slicetools::*; @@ -17,7 +17,8 @@ use std::f32::consts::PI; mod assets; mod dashboard; -mod helpers; +mod editor; +mod tilemap; mod util; use util::IteratorToArrayExt; @@ -70,10 +71,10 @@ fn main() { }), ..default() }), - helpers::editor::Plugin, - TilemapPlugin, + editor::Plugin, + ecs_tilemap::TilemapPlugin, assets::Plugin, - helpers::tiled::TiledMapPlugin, + tilemap::TiledMapPlugin, dashboard::Plugin, )) .insert_resource(ClearColor(Color::rgb_linear(0.153, 0.682, 0.376))) @@ -145,9 +146,9 @@ fn spawn_camera(mut commands: Commands) { fn load_maps(mut commands: Commands, asset_server: Res, args: Res) { let p = format!("embedded://tdr2024/assets/level{}.tmx", args.level); - let map_handle: Handle = asset_server.load(p); + let map_handle: Handle = asset_server.load(p); - commands.spawn(helpers::tiled::TiledMapBundle { + commands.spawn(tilemap::TiledMapBundle { tiled_map: map_handle, ..default() }); @@ -217,8 +218,8 @@ impl GuidanceField { fn generate_guidance_field( mut commands: Commands, - mut map_events: EventReader>, - maps: Res>, + mut map_events: EventReader>, + maps: Res>, ) { for event in map_events.read() { match event { @@ -334,8 +335,8 @@ fn spawn_ai_players( } fn apply_time_penalties( - mut query: Query<(&mut Transform, &mut Racer, &Player)>, - maps: Res>, + mut query: Query<(&mut Transform, &mut Racer)>, + maps: Res>, ) { let map = match maps.iter().next() { Some(map) => &map.1.map, @@ -348,7 +349,7 @@ fn apply_time_penalties( .and_then(|layer| layer.as_tile_layer()) .expect("Failed to lookup track layer"); - for (t, mut r, _) in query.iter_mut() { + for (t, mut r) in query.iter_mut() { let x = (t.translation.x / map.tile_width as f32) + (map.width as f32 / 2.0); let y = (-t.translation.y / map.tile_height as f32) + (map.height as f32 / 2.0); diff --git a/src/helpers/tiled.rs b/src/tilemap.rs similarity index 100% rename from src/helpers/tiled.rs rename to src/tilemap.rs