From 836e0f5a14cb8d12b5d5b8788ddfd4af12e7a89a Mon Sep 17 00:00:00 2001 From: eri Date: Mon, 4 Dec 2023 02:34:52 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20entities=20following=20path=20?= =?UTF-8?q?=F0=9F=9B=A3=EF=B8=8F=20yaaaaay=20finally,=20it=20was=20a=20mes?= =?UTF-8?q?s=20to=20get=20set=20up=20with=20every=20possibility=20and=20no?= =?UTF-8?q?t=20just=20for=20the=20best=20path,=20but=20it=20covers=20a=20l?= =?UTF-8?q?ot=20of=20variants=20now,=20specially=20when=20building/rebuild?= =?UTF-8?q?ing=20new=20paths.=20i=20am=20sure=20it=20can=20be=20very=20imp?= =?UTF-8?q?roved=20upon=20but=20for=20this=20game=20jam=20it=20is=20more?= =?UTF-8?q?=20than=20enough?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game.rs | 4 -- src/input.rs | 4 +- src/menu.rs | 2 - src/spirits.rs | 98 +++++++++++++++++++++++++------ src/tilemap.rs | 156 ++++++++++++++++++++++++++++++++++++------------- 5 files changed, 196 insertions(+), 68 deletions(-) diff --git a/src/game.rs b/src/game.rs index 3cfe03c..4325f7e 100644 --- a/src/game.rs +++ b/src/game.rs @@ -2,10 +2,6 @@ use bevy::{prelude::*, render::view::RenderLayers}; use crate::GameState; -// TODO: Spawn entities, follow pathfinding -// TODO: Collisions between entities (traffic) -// TODO: Multiple spawn points - pub struct CharonPlugin; impl Plugin for CharonPlugin { diff --git a/src/input.rs b/src/input.rs index be09445..a686f90 100644 --- a/src/input.rs +++ b/src/input.rs @@ -7,7 +7,7 @@ use bevy::{ use bevy_persistent::Persistent; use serde::{Deserialize, Serialize}; -use crate::config::Keybinds; +use crate::{config::Keybinds, game::GameCam}; // TODO: Mouse movement and gamepad axis @@ -123,7 +123,7 @@ fn clear_input(mut input: ResMut>) { } fn handle_mouse_moved( - camera: Query<(&GlobalTransform, &Camera)>, // TODO: Create game camera and filter it here + camera: Query<(&GlobalTransform, &Camera), With>, mut events: EventReader, mut mouse: ResMut, ) { diff --git a/src/menu.rs b/src/menu.rs index 2ae411e..43c96b6 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -339,8 +339,6 @@ fn layout_keybinds(mut cmd: Commands, node: Entity, style: &UIStyle, keybinds: & node.with_children(|parent| { UIText::new(style, "Keybinds").with_title().add(parent); - // TODO: Scrollable section (Requires #8104 to be merged in 0.13) - for (i, value) in keybinds.iter_fields().enumerate() { let field_name = keybinds.name_at(i).unwrap(); if let Some(value) = value.downcast_ref::>() { diff --git a/src/spirits.rs b/src/spirits.rs index bf88dd2..90d5983 100644 --- a/src/spirits.rs +++ b/src/spirits.rs @@ -3,7 +3,7 @@ use bevy_ecs_tilemap::prelude::*; use crate::{ load::GameAssets, - tilemap::{get_neighbours, pos_to_tile, tile_to_pos, PathTile, StartTile}, + tilemap::{get_neighbours, pos_to_tile, tile_to_pos, EndTile, PathTile, StartTile}, GameState, }; @@ -17,7 +17,10 @@ impl Plugin for SpiritPlugin { fn build(&self, app: &mut App) { app.insert_resource(SpawnTimer::default()) .insert_resource(MoveTimer::default()) - .add_systems(Update, move_spirit.run_if(in_state(GameState::Play))); + .add_systems( + Update, + (spawn_spirit, move_spirit).run_if(in_state(GameState::Play)), + ); } } @@ -39,7 +42,7 @@ struct MoveTimer(Timer); impl Default for MoveTimer { fn default() -> Self { - Self(Timer::from_seconds(1.0, TimerMode::Repeating)) + Self(Timer::from_seconds(0.5, TimerMode::Repeating)) } } @@ -47,14 +50,16 @@ impl Default for MoveTimer { // Components // ·········· -#[derive(Component)] -pub struct Spirit; +#[derive(Component, Default)] +pub struct Spirit { + prev: Option, +} // ······· // Systems // ······· -fn _spawn_spirit( +fn spawn_spirit( mut cmd: Commands, mut timer: ResMut, time: Res