save
Some checks failed
Rust Checks / checks (push) Waiting to run
Rust Checks / checks (pull_request) Failing after 7s

This commit is contained in:
CoCo_Sol 2024-03-11 08:37:33 +01:00
parent 32624d0232
commit 61c56bcdca
2 changed files with 5 additions and 17 deletions

View file

@ -2,9 +2,7 @@
use bevy::prelude::*;
use border_wars::camera::CameraPlugin;
use border_wars::map::generation::{MapGenerationPlugin, StartMapGeneration};
use border_wars::map::renderer::RendererPlugin;
use border_wars::map::selected_tile::TilesClickable;
use border_wars::scenes::ScenesPlugin;
fn main() {
@ -13,15 +11,5 @@ fn main() {
.add_plugins(ScenesPlugin)
.add_plugins(RendererPlugin)
.add_plugins(CameraPlugin)
.add_plugins(TilesClickable)
.add_plugins(MapGenerationPlugin)
.add_systems(OnEnter(border_wars::CurrentScene::Game), start)
.run();
}
fn start(mut event: EventWriter<StartMapGeneration>) {
event.send(StartMapGeneration {
seed: 0,
radius: 10,
});
}

View file

@ -1,4 +1,4 @@
//! All programs related to the clicking on a tile.
//! All programs related to the selection of a tile.
use bevy::prelude::*;
@ -45,9 +45,9 @@ impl SelectedTile {
}
/// A plugin that handles the selection of tiles.
pub struct TilesClickable;
pub struct SelectTilePlugin;
impl Plugin for TilesClickable {
impl Plugin for SelectTilePlugin {
fn build(&self, app: &mut App) {
app.add_systems(PreUpdate, mouse_handler)
.add_systems(PreUpdate, select_closest_tile)
@ -97,7 +97,7 @@ fn mouse_handler(
events_writer.send(ClickOnTheWorld(cursor_position_in_world));
}
/// Get the closest tile to the cursor and send it in an event.
/// Get the closest tile to the cursor, send it in an event and select it.
fn select_closest_tile(
tiles: Query<(Entity, &Transform, &Tile)>,
mut click_event_reader: EventReader<ClickOnTheWorld>,