generated from tipragot/rust
Click-on tile handle system #74
|
@ -2,8 +2,8 @@
|
|||
|
||||
pub mod generation;
|
||||
pub mod hex;
|
||||
pub mod selection;
|
||||
pub mod renderer;
|
||||
pub mod selection;
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ use bevy::prelude::*;
|
|||
|
||||
use super::Tile;
|
||||
|
||||
/// The event that is triggered when a tile is selected.
|
||||
/// The event that is triggered when a tile is clicked.
|
||||
///
|
||||
/// The event contains the index (ID) of the selected tile.
|
||||
/// 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>,
|
||||
|
|
Loading…
Reference in a new issue