generated from tipragot/rust
Change textures of tiles #75
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
pub mod generation;
|
pub mod generation;
|
||||||
pub mod hex;
|
pub mod hex;
|
||||||
pub mod selection;
|
|
||||||
pub mod renderer;
|
pub mod renderer;
|
||||||
|
pub mod selection;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ use bevy::prelude::*;
|
||||||
|
|
||||||
use super::Tile;
|
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)]
|
#[derive(Event)]
|
||||||
pub struct TileJustClicked(pub u32);
|
pub struct TileJustClicked(pub u32);
|
||||||
|
|
||||||
|
@ -59,8 +59,7 @@ fn mouse_handler(
|
||||||
events_writer.send(ClickOnTheWorld(cursor_position_in_world));
|
events_writer.send(ClickOnTheWorld(cursor_position_in_world));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Selects the closest tile to the cursor and marks it as selected.
|
/// Get the closest tile to the cursor and send it in an event.
|
||||||
/// It also unmarks the old selection if there is one.
|
|
||||||
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>,
|
||||||
|
|
Loading…
Reference in a new issue