From 85cdbd93f37e01b097b5caa9f53faea47c2f9c0f Mon Sep 17 00:00:00 2001 From: Martin Indra Date: Sat, 22 Jul 2023 18:11:15 +0200 Subject: [PATCH] WIP --- crates/pathing/src/fplugin.rs | 14 ++++++++------ crates/pathing/src/pplugin.rs | 6 +++--- crates/terrain/src/marker.rs | 2 +- crates/terrain/src/shader.rs | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/pathing/src/fplugin.rs b/crates/pathing/src/fplugin.rs index bbf80f786..22177d06c 100644 --- a/crates/pathing/src/fplugin.rs +++ b/crates/pathing/src/fplugin.rs @@ -5,6 +5,7 @@ use bevy::{ tasks::{AsyncComputeTaskPool, Task}, }; use de_core::{ + baseset::PreMovement, gamestate::GameState, objects::{ObjectType, StaticSolid}, state::AppState, @@ -40,12 +41,12 @@ pub struct FinderPlugin; impl Plugin for FinderPlugin { fn build(&self, app: &mut App) { - app.add_event::() + app.add_event::() .add_systems(OnEnter(AppState::InGame), setup_loading) .add_systems(OnEnter(GameState::Playing), setup_playing) .add_systems(OnExit(AppState::InGame), cleanup) .add_systems( - GameSet::PostUpdate, + PostUpdate, ( check_removed .run_if(in_state(AppState::InGame)) @@ -60,7 +61,7 @@ impl Plugin for FinderPlugin { ), ) .add_systems( - GameSet::PreMovement, + PreMovement, check_update_result .run_if(in_state(GameState::Playing)) .in_set(FinderSet::UpdateFinder), @@ -79,7 +80,8 @@ pub(crate) enum FinderSet { /// /// Paths found before the event was sent may no longer be optimal or may lead /// through non-accessible area. -pub(crate) struct PathFinderUpdated; +#[derive(Event)] +pub(crate) struct PathFinderUpdatedEvent; #[derive(Clone, Resource)] pub(crate) struct FinderRes(Arc); @@ -201,12 +203,12 @@ fn update( fn check_update_result( mut state: ResMut, mut finder_res: ResMut, - mut pf_updated: EventWriter, + mut pf_updated: EventWriter, ) { if let Some(finder) = state.check_result() { info!("Inserting updated path finder"); finder_res.update(finder); - pf_updated.send(PathFinderUpdated); + pf_updated.send(PathFinderUpdatedEvent); } } diff --git a/crates/pathing/src/pplugin.rs b/crates/pathing/src/pplugin.rs index 7a06cced2..540e9d3ed 100644 --- a/crates/pathing/src/pplugin.rs +++ b/crates/pathing/src/pplugin.rs @@ -4,7 +4,7 @@ use bevy::{ tasks::{AsyncComputeTaskPool, Task}, }; use de_core::{ - baseset::{GameSet, PostMovement, PreMovement}, + baseset::{PostMovement, PreMovement}, gamestate::GameState, objects::MovableSolid, projection::ToFlat, @@ -13,7 +13,7 @@ use de_core::{ use futures_lite::future; use crate::{ - fplugin::{FinderRes, FinderSet, PathFinderUpdated}, + fplugin::{FinderRes, FinderSet, PathFinderUpdatedEvent}, path::{Path, ScheduledPath}, PathQueryProps, PathTarget, }; @@ -44,7 +44,7 @@ impl Plugin for PathingPlugin { ( update_existing_paths .run_if(in_state(GameState::Playing)) - .run_if(on_event::()) + .run_if(on_event::()) .in_set(PathingSet::UpdateExistingPaths) .after(FinderSet::UpdateFinder), update_requested_paths diff --git a/crates/terrain/src/marker.rs b/crates/terrain/src/marker.rs index a73271c67..d5f5410d4 100644 --- a/crates/terrain/src/marker.rs +++ b/crates/terrain/src/marker.rs @@ -23,7 +23,7 @@ pub(crate) struct MarkerPlugin; impl Plugin for MarkerPlugin { fn build(&self, app: &mut App) { app.add_systems( - CoreSet::PostUpdate, + PostUpdate, ( update_markers:: .run_if(in_state(GameState::Playing)) diff --git a/crates/terrain/src/shader.rs b/crates/terrain/src/shader.rs index 3d0750469..d9d3f32d0 100644 --- a/crates/terrain/src/shader.rs +++ b/crates/terrain/src/shader.rs @@ -2,7 +2,7 @@ use std::{cmp::Ordering, ops::Range}; use bevy::{ prelude::{Handle, Image, Material}, - reflect::TypeUuid, + reflect::{TypePath, TypeUuid}, render::render_resource::{AsBindGroup, ShaderRef, ShaderType}, }; use glam::{Mat3, Vec2}; @@ -14,7 +14,7 @@ pub(crate) const CIRCLE_CAPACITY: usize = 127; // * Keep this smaller or equal to de_core::objects::PLAYER_MAX_BUILDINGS. pub(crate) const RECTANGLE_CAPACITY: usize = 31; -#[derive(AsBindGroup, TypeUuid, Debug, Clone)] +#[derive(AsBindGroup, TypeUuid, TypePath, Debug, Clone)] #[uuid = "9e124e04-fdf1-4836-b82d-fa2f01fddb62"] pub struct TerrainMaterial { #[uniform(0)]