Click-on tile handle system #74

Merged
CoCo_Sol merged 12 commits from select-tiles into main 2024-03-09 14:51:46 +00:00
2 changed files with 5 additions and 6 deletions
Showing only changes of commit 9079df942a - Show all commits

View file

@ -2,8 +2,8 @@
pub mod generation;
pub mod hex;
pub mod selection;
pub mod renderer;
pub mod selection;
use bevy::prelude::*;

View file

@ -4,9 +4,9 @@ use bevy::prelude::*;
use super::Tile;
/// The event that is triggered when a tile is selected.
///
/// The event contains the index (ID) of the selected tile.
/// The event that is triggered when a tile is clicked.
///
/// The event contains the index (ID) of the clicked tile.
#[derive(Event)]
pub struct TileJustClicked(pub u32);
@ -59,8 +59,7 @@ fn mouse_handler(
events_writer.send(ClickOnTheWorld(cursor_position_in_world));
}
/// Selects the closest tile to the cursor and marks it as selected.
/// It also unmarks the old selection if there is one.
/// Get the closest tile to the cursor and send it in an event.
fn select_closest_tile(
tiles: Query<(Entity, &Transform, &Tile)>,
mut click_event_reader: EventReader<ClickOnTheWorld>,