change name
All checks were successful
Rust Checks / checks (push) Successful in 3m30s
Rust Checks / checks (pull_request) Successful in 3m11s

This commit is contained in:
CoCo_Sol 2024-03-09 14:01:27 +01:00
parent 79f0335637
commit 87c8f508d8
2 changed files with 6 additions and 6 deletions

View file

@ -2,7 +2,7 @@
use bevy::prelude::*; use bevy::prelude::*;
use border_wars::camera::CameraPlugin; use border_wars::camera::CameraPlugin;
use border_wars::map::click_tile::SelectorPlugin; use border_wars::map::click_tile::TilesClickable;
use border_wars::map::renderer::RendererPlugin; use border_wars::map::renderer::RendererPlugin;
use border_wars::scenes::ScenesPlugin; use border_wars::scenes::ScenesPlugin;
@ -12,6 +12,6 @@ fn main() {
.add_plugins(ScenesPlugin) .add_plugins(ScenesPlugin)
.add_plugins(RendererPlugin) .add_plugins(RendererPlugin)
.add_plugins(CameraPlugin) .add_plugins(CameraPlugin)
.add_plugins(SelectorPlugin) .add_plugins(TilesClickable)
.run(); .run();
} }

View file

@ -22,9 +22,9 @@ struct ClickOnTheWorld(Vec2);
pub struct ZoneNotClickable; pub struct ZoneNotClickable;
/// A plugin that handles the selection of tiles. /// A plugin that handles the selection of tiles.
pub struct SelectorPlugin; pub struct TilesClickable;
impl Plugin for SelectorPlugin { impl Plugin for TilesClickable {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems(PreUpdate, mouse_handler) app.add_systems(PreUpdate, mouse_handler)
.add_systems(PreUpdate, select_closest_tile) .add_systems(PreUpdate, select_closest_tile)
@ -77,7 +77,7 @@ fn mouse_handler(
fn select_closest_tile( fn select_closest_tile(
tiles: Query<(Entity, &Transform, &Tile)>, tiles: Query<(Entity, &Transform, &Tile)>,
mut click_event_reader: EventReader<ClickOnTheWorld>, mut click_event_reader: EventReader<ClickOnTheWorld>,
mut select_tile_event_writer: EventWriter<TileJustClicked>, mut clicked_tile_event_writer: EventWriter<TileJustClicked>,
) { ) {
for click_event in click_event_reader.read() { for click_event in click_event_reader.read() {
// The closest tile and its distance to the cursor. // The closest tile and its distance to the cursor.
@ -99,7 +99,7 @@ fn select_closest_tile(
} }
} }
if let Some(tile_entity) = closest_entity { if let Some(tile_entity) = closest_entity {
select_tile_event_writer.send(TileJustClicked(tile_entity.index())); clicked_tile_event_writer.send(TileJustClicked(tile_entity.index()));
} }
} }
} }