diff --git a/assets/images/hints/arrows.png b/assets/images/hints/arrows.png new file mode 100644 index 0000000..1f6554f Binary files /dev/null and b/assets/images/hints/arrows.png differ diff --git a/assets/images/hints/interaction.png b/assets/images/hints/interaction.png new file mode 100644 index 0000000..1f6554f Binary files /dev/null and b/assets/images/hints/interaction.png differ diff --git a/src/hint/assets.rs b/src/hint/assets.rs new file mode 100644 index 0000000..68ed6f1 --- /dev/null +++ b/src/hint/assets.rs @@ -0,0 +1,26 @@ +use bevy::prelude::*; + +#[derive(Resource, Asset, Reflect, Clone)] +#[reflect(Resource)] +pub struct HintAssets { + #[dependency] + pub arrows: Handle, + #[dependency] + pub interaction: Handle, +} + +impl HintAssets { + pub const PATH_ARROWS: &str = "images/hints/arrows.png"; + pub const PATH_INTERACTION: &str = "images/hints/interaction.png"; +} + +impl FromWorld for HintAssets { + fn from_world(world: &mut World) -> Self { + let assets = world.resource::(); + + Self { + arrows: assets.load(Self::PATH_ARROWS), + interaction: assets.load(Self::PATH_INTERACTION), + } + } +} diff --git a/src/hint/components.rs b/src/hint/components.rs new file mode 100644 index 0000000..ad68d4e --- /dev/null +++ b/src/hint/components.rs @@ -0,0 +1,35 @@ +use std::time::Duration; + +use bevy::prelude::*; + +#[derive(Debug, Reflect, Component, PartialEq, Eq)] +#[reflect(Component)] +pub enum Hint { + Movement, + Interaction, +} + +#[derive(Debug, Reflect, Component)] +#[reflect(Component)] +pub struct IdleTimer { + pub timer: Timer, + pub movement_hint_visible: bool, + pub interaction_hint_visible: bool, +} + +impl IdleTimer { + pub fn hide_all(&mut self) { + self.movement_hint_visible = false; + self.interaction_hint_visible = false; + } +} + +impl Default for IdleTimer { + fn default() -> Self { + Self { + timer: Timer::new(Duration::from_secs(3), TimerMode::Once), + movement_hint_visible: false, + interaction_hint_visible: false, + } + } +} diff --git a/src/hint/mod.rs b/src/hint/mod.rs new file mode 100644 index 0000000..a34f165 --- /dev/null +++ b/src/hint/mod.rs @@ -0,0 +1,13 @@ +pub mod assets; +pub mod components; +mod systems; + +use bevy::{ecs::system::RunSystemOnce, prelude::*}; + +pub(super) fn plugin(app: &mut App) { + app.add_plugins(systems::plugin); +} + +pub fn spawn_hint_command(world: &mut World) { + let _ = world.run_system_once(systems::setup::setup); +} diff --git a/src/hint/systems/check.rs b/src/hint/systems/check.rs new file mode 100644 index 0000000..eb12f29 --- /dev/null +++ b/src/hint/systems/check.rs @@ -0,0 +1,84 @@ +use bevy::prelude::*; +use hexx::Hex; + +use crate::{ + floor::components::CurrentFloor, + hint::components::{Hint, IdleTimer}, + maze::components::MazeConfig, + player::components::{CurrentPosition, MovementTarget, Player}, +}; + +pub fn check_player_hints( + mut idle_query: Query<&mut IdleTimer>, + player_query: Query<(&CurrentPosition, &MovementTarget), With>, + maze_query: Query<&MazeConfig, With>, + mut hint_query: Query<(&mut Visibility, &Hint)>, + time: Res