Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Indy2222 committed Jul 22, 2023
1 parent c2b3e0c commit 85cdbd9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
14 changes: 8 additions & 6 deletions crates/pathing/src/fplugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use bevy::{
tasks::{AsyncComputeTaskPool, Task},
};
use de_core::{
baseset::PreMovement,
gamestate::GameState,
objects::{ObjectType, StaticSolid},
state::AppState,
Expand Down Expand Up @@ -40,12 +41,12 @@ pub struct FinderPlugin;

impl Plugin for FinderPlugin {
fn build(&self, app: &mut App) {
app.add_event::<PathFinderUpdated>()
app.add_event::<PathFinderUpdatedEvent>()
.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))
Expand All @@ -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),
Expand All @@ -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<PathFinder>);
Expand Down Expand Up @@ -201,12 +203,12 @@ fn update(
fn check_update_result(
mut state: ResMut<UpdateFinderState>,
mut finder_res: ResMut<FinderRes>,
mut pf_updated: EventWriter<PathFinderUpdated>,
mut pf_updated: EventWriter<PathFinderUpdatedEvent>,
) {
if let Some(finder) = state.check_result() {
info!("Inserting updated path finder");
finder_res.update(finder);
pf_updated.send(PathFinderUpdated);
pf_updated.send(PathFinderUpdatedEvent);
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/pathing/src/pplugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
};
Expand Down Expand Up @@ -44,7 +44,7 @@ impl Plugin for PathingPlugin {
(
update_existing_paths
.run_if(in_state(GameState::Playing))
.run_if(on_event::<PathFinderUpdated>())
.run_if(on_event::<PathFinderUpdatedEvent>())
.in_set(PathingSet::UpdateExistingPaths)
.after(FinderSet::UpdateFinder),
update_requested_paths
Expand Down
2 changes: 1 addition & 1 deletion crates/terrain/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CircleMarker>
.run_if(in_state(GameState::Playing))
Expand Down
4 changes: 2 additions & 2 deletions crates/terrain/src/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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)]
Expand Down

0 comments on commit 85cdbd9

Please sign in to comment.