WIP: Begin porting to Bevy 0.6.
This commit is contained in:
parent
3f8636a639
commit
356caa09e0
|
@ -7,11 +7,10 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies.bevy]
|
||||
version = "0.5"
|
||||
version = "0.6"
|
||||
default-features = false
|
||||
features = [
|
||||
"bevy_gilrs",
|
||||
"bevy_wgpu",
|
||||
"bevy_winit",
|
||||
"render",
|
||||
"x11",
|
||||
|
@ -23,7 +22,7 @@ features = [
|
|||
backtrace = "0.3"
|
||||
bevy_input_actionmap = { path = "../bevy_input_actionmap" }
|
||||
bevy_openal = { path = "../bevy_openal" }
|
||||
bevy_rapier2d = { version = "0.11", features = ["serde-serialize", "simd-stable"] }
|
||||
bevy_rapier2d = { version = "0.12", features = ["serde-serialize", "simd-stable"] }
|
||||
bevy_tts = { path = "../bevy_tts" }
|
||||
coord_2d = "0.3"
|
||||
derive_more = "0.99"
|
||||
|
|
40
src/core.rs
40
src/core.rs
|
@ -14,7 +14,7 @@ use once_cell::sync::Lazy;
|
|||
use rand::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deref, DerefMut, PartialEq, PartialOrd, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, PartialEq, PartialOrd, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Coordinates(pub (f32, f32));
|
||||
|
||||
|
@ -260,7 +260,7 @@ impl Display for MovementDirection {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[derive(Component, Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum CardinalDirection {
|
||||
North,
|
||||
East,
|
||||
|
@ -570,7 +570,7 @@ impl From<&dyn PointLike> for (i32, i32) {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Player;
|
||||
|
||||
|
@ -645,10 +645,10 @@ fn copy_coordinates_to_transform(
|
|||
(&Coordinates, &mut Transform),
|
||||
(
|
||||
Changed<Transform>,
|
||||
Without<RigidBodyPosition>,
|
||||
Without<RigidBodyPositionSync>,
|
||||
Without<ColliderPosition>,
|
||||
Without<ColliderPositionSync>,
|
||||
Without<RigidBodyPositionComponent>,
|
||||
Without<RigidBodyPositionSyncComponent>,
|
||||
Without<ColliderPositionComponent>,
|
||||
Without<ColliderPositionSyncComponent>,
|
||||
),
|
||||
>,
|
||||
) {
|
||||
|
@ -666,8 +666,8 @@ fn copy_coordinates_to_transform(
|
|||
|
||||
fn copy_rigid_body_position_to_coordinates(
|
||||
mut query: Query<
|
||||
(&mut Coordinates, &RigidBodyPosition),
|
||||
(Changed<RigidBodyPosition>, With<RigidBodyPositionSync>),
|
||||
(&mut Coordinates, &RigidBodyPositionComponent),
|
||||
(Changed<RigidBodyPositionComponent>, With<RigidBodyPositionSync>),
|
||||
>,
|
||||
) {
|
||||
for (mut coordinates, position) in query.iter_mut() {
|
||||
|
@ -682,11 +682,11 @@ fn copy_rigid_body_position_to_coordinates(
|
|||
|
||||
fn copy_collider_position_to_coordinates(
|
||||
mut query: Query<
|
||||
(&mut Coordinates, &ColliderPosition),
|
||||
(&mut Coordinates, &ColliderPositionComponent),
|
||||
(
|
||||
Without<RigidBodyPosition>,
|
||||
Changed<ColliderPosition>,
|
||||
With<ColliderPositionSync>,
|
||||
Without<RigidBodyPositionComponent>,
|
||||
Changed<ColliderPositionComponent>,
|
||||
With<ColliderPositionSyncComponent>,
|
||||
),
|
||||
>,
|
||||
) {
|
||||
|
@ -725,27 +725,23 @@ fn sync_config(config: Res<CoreConfig>) {
|
|||
pub struct CorePlugin;
|
||||
|
||||
impl Plugin for CorePlugin {
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
fn build(&self, app: &mut App) {
|
||||
if !app.world().contains_resource::<CoreConfig>() {
|
||||
app.insert_resource(CoreConfig::default());
|
||||
}
|
||||
app.register_type::<Coordinates>()
|
||||
.add_startup_system(setup.system())
|
||||
.add_startup_system(setup)
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
copy_coordinates_to_transform
|
||||
.system()
|
||||
.before(TransformSystem::TransformPropagate),
|
||||
)
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
copy_rigid_body_position_to_coordinates.system(),
|
||||
copy_rigid_body_position_to_coordinates,
|
||||
)
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
copy_collider_position_to_coordinates.system(),
|
||||
)
|
||||
.add_system(sync_config.system());
|
||||
.add_system_to_stage(CoreStage::PostUpdate, copy_collider_position_to_coordinates)
|
||||
.add_system(sync_config);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ pub struct ErrorConfig {
|
|||
pub struct ErrorPlugin;
|
||||
|
||||
impl Plugin for ErrorPlugin {
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
fn build(&self, app: &mut App) {
|
||||
init_panic_handler();
|
||||
if let Some(config) = app.world().get_resource::<ErrorConfig>() {
|
||||
if let Some(dsn) = &config.sentry_dsn {
|
||||
|
|
|
@ -15,16 +15,16 @@ use crate::{
|
|||
visibility::{RevealedTiles, Viewshed, Visible, VisibleEntities},
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, PartialEq, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Explorable;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, PartialEq, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct ExplorationFocused;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Reflect)]
|
||||
pub enum ExplorationType {
|
||||
Portal = 0,
|
||||
Item = 1,
|
||||
|
@ -61,16 +61,16 @@ impl Into<&str> for ExplorationType {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Exploring(pub (f32, f32));
|
||||
|
||||
impl_pointlike_for_tuple_component!(Exploring);
|
||||
|
||||
#[derive(Clone, Debug, Default, Deref, DerefMut)]
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut)]
|
||||
pub struct FocusedExplorationType(pub Option<ExplorationType>);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Mappable;
|
||||
|
||||
|
@ -456,7 +456,7 @@ where
|
|||
A: Hash + Eq + Clone + Send + Sync,
|
||||
'a: 'static,
|
||||
{
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
fn build(&self, app: &mut App) {
|
||||
if !app.world().contains_resource::<ExplorationConfig<S, A>>() {
|
||||
app.insert_resource(ExplorationConfig::<S, A>::default());
|
||||
}
|
||||
|
@ -470,53 +470,29 @@ where
|
|||
.register_type::<Mappable>()
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
exploration_changed_announcement
|
||||
.system()
|
||||
.chain(error_handler.system()),
|
||||
exploration_changed_announcement.chain(error_handler),
|
||||
);
|
||||
if config.exploration_control_states.is_empty() {
|
||||
app.add_system(exploration_focus::<S, A>.system())
|
||||
.add_system(
|
||||
exploration_type_focus::<S, A>
|
||||
.system()
|
||||
.chain(error_handler.system()),
|
||||
)
|
||||
.add_system(
|
||||
exploration_type_change::<S, A>
|
||||
.system()
|
||||
.chain(error_handler.system()),
|
||||
)
|
||||
.add_system(navigate_to_explored::<S, A>.system())
|
||||
app.add_system(exploration_focus::<S, A>)
|
||||
.add_system(exploration_type_focus::<S, A>.chain(error_handler))
|
||||
.add_system(exploration_type_change::<S, A>.chain(error_handler))
|
||||
.add_system(navigate_to_explored::<S, A>)
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
exploration_type_changed_announcement
|
||||
.system()
|
||||
.chain(error_handler.system()),
|
||||
exploration_type_changed_announcement.chain(error_handler),
|
||||
);
|
||||
} else {
|
||||
let states = config.exploration_control_states;
|
||||
for state in states {
|
||||
app.add_system_set(
|
||||
SystemSet::on_update(state.clone())
|
||||
.with_system(exploration_focus::<S, A>.system())
|
||||
.with_system(
|
||||
exploration_type_focus::<S, A>
|
||||
.system()
|
||||
.chain(error_handler.system()),
|
||||
.with_system(exploration_focus::<S, A>)
|
||||
.with_system(exploration_type_focus::<S, A>.chain(error_handler))
|
||||
.with_system(exploration_type_change::<S, A>.chain(error_handler))
|
||||
.with_system(navigate_to_explored::<S, A>)
|
||||
.with_system(exploration_type_changed_announcement.chain(error_handler)),
|
||||
)
|
||||
.with_system(
|
||||
exploration_type_change::<S, A>
|
||||
.system()
|
||||
.chain(error_handler.system()),
|
||||
)
|
||||
.with_system(navigate_to_explored::<S, A>.system())
|
||||
.with_system(
|
||||
exploration_type_changed_announcement
|
||||
.system()
|
||||
.chain(error_handler.system()),
|
||||
),
|
||||
)
|
||||
.add_system_set(SystemSet::on_exit(state).with_system(cleanup.system()));
|
||||
.add_system_set(SystemSet::on_exit(state).with_system(cleanup));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
12
src/log.rs
12
src/log.rs
|
@ -6,7 +6,7 @@ use derive_more::{Deref, DerefMut};
|
|||
|
||||
use crate::error::error_handler;
|
||||
|
||||
#[derive(Clone, Debug, Default, Deref, DerefMut)]
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut)]
|
||||
pub struct Log(pub Vec<LogEntry>);
|
||||
|
||||
impl Log {
|
||||
|
@ -18,7 +18,7 @@ impl Log {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Component, Clone, Debug)]
|
||||
pub struct LogEntry {
|
||||
pub time: Instant,
|
||||
pub message: String,
|
||||
|
@ -47,10 +47,8 @@ fn read_log(
|
|||
pub struct LogPlugin;
|
||||
|
||||
impl Plugin for LogPlugin {
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
app.add_startup_system(setup.system()).add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
read_log.system().chain(error_handler.system()),
|
||||
);
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_startup_system(setup)
|
||||
.add_system_to_stage(CoreStage::PostUpdate, read_log.chain(error_handler));
|
||||
}
|
||||
}
|
||||
|
|
30
src/map.rs
30
src/map.rs
|
@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet};
|
|||
use bevy::prelude::*;
|
||||
use bevy_rapier2d::prelude::*;
|
||||
use derive_more::{Deref, DerefMut};
|
||||
pub use mapgen::Map;
|
||||
pub use mapgen::Map as MapgenMap;
|
||||
use mapgen::{geometry::Rect as MRect, MapFilter, Tile};
|
||||
use maze_generator::{prelude::*, recursive_backtracking::RbGenerator};
|
||||
use rand::prelude::StdRng;
|
||||
|
@ -22,23 +22,27 @@ impl From<mapgen::geometry::Point> for Coordinates {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Area;
|
||||
|
||||
#[derive(Clone, Debug, Default, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Map(pub MapgenMap);
|
||||
|
||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct MapObstruction;
|
||||
|
||||
#[derive(Clone, Debug, Default, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Portal;
|
||||
|
||||
#[derive(Clone, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct SpawnColliderPerTile(pub bool);
|
||||
|
||||
#[derive(Clone, Debug, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct SpawnColliders(pub bool);
|
||||
|
||||
|
@ -48,7 +52,7 @@ impl Default for SpawnColliders {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct SpawnPortals(pub bool);
|
||||
|
||||
|
@ -417,7 +421,7 @@ fn spawn_portals(
|
|||
fn spawn_portal_colliders(
|
||||
mut commands: Commands,
|
||||
map: Query<(Entity, &SpawnColliders), With<Map>>,
|
||||
portals: Query<(Entity, &Coordinates), Without<ColliderShape>>,
|
||||
portals: Query<(Entity, &Coordinates), Without<ColliderShapeComponent>>,
|
||||
) {
|
||||
for (map_entity, spawn_colliders) in map.iter() {
|
||||
if **spawn_colliders {
|
||||
|
@ -479,17 +483,17 @@ fn area_description(
|
|||
pub struct MapPlugin;
|
||||
|
||||
impl Plugin for MapPlugin {
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
fn build(&self, app: &mut App) {
|
||||
if !app.world().contains_resource::<MapConfig>() {
|
||||
app.insert_resource(MapConfig::default());
|
||||
}
|
||||
let config = app.world().get_resource::<MapConfig>().unwrap().clone();
|
||||
app.register_type::<Portal>()
|
||||
.add_system(spawn_colliders.system())
|
||||
.add_system(spawn_portals.system())
|
||||
.add_system(spawn_portal_colliders.system());
|
||||
.add_system(spawn_colliders)
|
||||
.add_system(spawn_portals)
|
||||
.add_system(spawn_portal_colliders);
|
||||
if config.speak_area_descriptions {
|
||||
app.add_system_to_stage(CoreStage::PostUpdate, area_description.system());
|
||||
app.add_system_to_stage(CoreStage::PostUpdate, area_description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
pathfinding::Destination,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct MaxSpeed(pub f32);
|
||||
|
||||
|
@ -23,7 +23,7 @@ impl Default for MaxSpeed {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct RotationSpeed(pub Angle);
|
||||
|
||||
|
@ -33,11 +33,11 @@ impl Default for RotationSpeed {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Speed(pub f32);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Sprinting;
|
||||
|
||||
|
@ -49,11 +49,11 @@ fn movement_controls<S, A: 'static>(
|
|||
mut query: Query<
|
||||
(
|
||||
Entity,
|
||||
&mut RigidBodyVelocity,
|
||||
&mut RigidBodyVelocityComponent,
|
||||
&mut Speed,
|
||||
&MaxSpeed,
|
||||
Option<&RotationSpeed>,
|
||||
&mut RigidBodyPosition,
|
||||
&mut RigidBodyPositionComponent,
|
||||
Option<&Destination>,
|
||||
),
|
||||
With<Player>,
|
||||
|
@ -202,7 +202,7 @@ fn speak_direction(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn remove_speed(removed: RemovedComponents<Speed>, mut query: Query<&mut RigidBodyVelocity>) {
|
||||
fn remove_speed(removed: RemovedComponents<Speed>, mut query: Query<&mut RigidBodyVelocityComponent>) {
|
||||
for entity in removed.iter() {
|
||||
if let Ok(mut velocity) = query.get_mut(entity) {
|
||||
velocity.linvel = Vec2::ZERO.into();
|
||||
|
@ -259,7 +259,7 @@ where
|
|||
A: Hash + Eq + Clone + Send + Sync,
|
||||
'a: 'static,
|
||||
{
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
fn build(&self, app: &mut App) {
|
||||
if !app.world().contains_resource::<NavigationConfig<S, A>>() {
|
||||
app.insert_resource(NavigationConfig::<S, A>::default());
|
||||
}
|
||||
|
@ -271,16 +271,16 @@ where
|
|||
app.register_type::<MaxSpeed>()
|
||||
.register_type::<RotationSpeed>()
|
||||
.register_type::<Sprinting>()
|
||||
.add_system(update_direction.system())
|
||||
.add_system(speak_direction.system().chain(error_handler.system()))
|
||||
.add_system_to_stage(CoreStage::PostUpdate, remove_speed.system());
|
||||
.add_system(update_direction)
|
||||
.add_system(speak_direction.chain(error_handler))
|
||||
.add_system_to_stage(CoreStage::PostUpdate, remove_speed);
|
||||
if config.movement_control_states.is_empty() {
|
||||
app.add_system(movement_controls::<S, A>.system());
|
||||
app.add_system(movement_controls::<S, A>);
|
||||
} else {
|
||||
let states = config.movement_control_states;
|
||||
for state in states {
|
||||
app.add_system_set(
|
||||
SystemSet::on_update(state).with_system(movement_controls::<S, A>.system()),
|
||||
SystemSet::on_update(state).with_system(movement_controls::<S, A>),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,20 +20,20 @@ use crate::{
|
|||
navigation::{RotationSpeed, Speed},
|
||||
};
|
||||
|
||||
#[derive(Debug, Deref, DerefMut)]
|
||||
#[derive(Component, Debug, Deref, DerefMut)]
|
||||
struct Calculating(Task<Option<Path>>);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deref, DerefMut, Eq, Hash, PartialEq, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Eq, Hash, PartialEq, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Destination(pub (i32, i32));
|
||||
|
||||
impl_pointlike_for_tuple_component!(Destination);
|
||||
|
||||
#[derive(Clone, Debug, Default, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct NoPath;
|
||||
|
||||
#[derive(Clone, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Path(pub Vec<(i32, i32)>);
|
||||
|
||||
|
@ -62,15 +62,29 @@ struct StaticColliderComponentsSet(
|
|||
HashMap<Entity, (ColliderPosition, ColliderShape, ColliderFlags)>,
|
||||
);
|
||||
|
||||
impl
|
||||
impl<'world, 'state>
|
||||
From<(
|
||||
&Query<'_, (Entity, &ColliderPosition, &SharedShape, &ColliderFlags)>,
|
||||
&Query<'_, &MapObstruction>,
|
||||
&Query<
|
||||
'world,
|
||||
'state,
|
||||
(
|
||||
Entity,
|
||||
&ColliderPositionComponent,
|
||||
&ColliderShapeComponent,
|
||||
&ColliderFlagsComponent,
|
||||
),
|
||||
>,
|
||||
&Query<'world, 'state, &MapObstruction>,
|
||||
)> for StaticColliderComponentsSet
|
||||
{
|
||||
fn from(
|
||||
query: (
|
||||
&Query<(Entity, &ColliderPosition, &SharedShape, &ColliderFlags)>,
|
||||
&Query<(
|
||||
Entity,
|
||||
&ColliderPositionComponent,
|
||||
&ColliderShapeComponent,
|
||||
&ColliderFlagsComponent,
|
||||
)>,
|
||||
&Query<&MapObstruction>,
|
||||
),
|
||||
) -> Self {
|
||||
|
@ -188,7 +202,10 @@ fn calculate_path(
|
|||
query_pipeline: Res<QueryPipeline>,
|
||||
obstructions: Query<&MapObstruction>,
|
||||
collider_query: QueryPipelineColliderComponentsQuery,
|
||||
query: Query<(Entity, &Destination, &Coordinates, &ColliderShape), Changed<Destination>>,
|
||||
query: Query<
|
||||
(Entity, &Destination, &Coordinates, &ColliderShapeComponent),
|
||||
Changed<Destination>,
|
||||
>,
|
||||
map: Query<&Map>,
|
||||
) {
|
||||
for (entity, destination, coordinates, shape) in query.iter() {
|
||||
|
@ -253,8 +270,8 @@ fn negotiate_path(
|
|||
mut query: Query<(
|
||||
Entity,
|
||||
&mut Path,
|
||||
&mut RigidBodyPosition,
|
||||
&mut RigidBodyVelocity,
|
||||
&mut RigidBodyPositionComponent,
|
||||
&mut RigidBodyVelocityComponent,
|
||||
&Speed,
|
||||
Option<&RotationSpeed>,
|
||||
)>,
|
||||
|
@ -312,11 +329,11 @@ fn remove_calculating(
|
|||
pub struct PathfindingPlugin;
|
||||
|
||||
impl Plugin for PathfindingPlugin {
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
app.add_system(calculate_path.system())
|
||||
.add_system_to_stage(CoreStage::PostUpdate, remove_destination.system())
|
||||
.add_system(poll_tasks.system())
|
||||
.add_system(negotiate_path.system())
|
||||
.add_system_to_stage(CoreStage::PostUpdate, remove_calculating.system());
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_system(calculate_path)
|
||||
.add_system_to_stage(CoreStage::PostUpdate, remove_destination)
|
||||
.add_system(poll_tasks)
|
||||
.add_system(negotiate_path)
|
||||
.add_system_to_stage(CoreStage::PostUpdate, remove_calculating);
|
||||
}
|
||||
}
|
||||
|
|
22
src/sound.rs
22
src/sound.rs
|
@ -11,7 +11,7 @@ use crate::{
|
|||
visibility::{Viewshed, VisibleEntities},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Footstep {
|
||||
pub sound: HandleId,
|
||||
|
@ -39,7 +39,7 @@ impl Default for Footstep {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Component, Clone, Debug)]
|
||||
pub struct SoundIcon {
|
||||
pub sound: HandleId,
|
||||
pub gain: f32,
|
||||
|
@ -284,7 +284,7 @@ where
|
|||
S: bevy::ecs::component::Component + Clone + Debug + Eq + Hash,
|
||||
'a: 'static,
|
||||
{
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
fn build(&self, app: &mut App) {
|
||||
if !app.world().contains_resource::<SoundConfig<S>>() {
|
||||
app.insert_resource(SoundConfig::<S>::default());
|
||||
}
|
||||
|
@ -296,17 +296,15 @@ where
|
|||
.unwrap();
|
||||
}
|
||||
app.register_type::<Footstep>()
|
||||
.add_system(add_footstep_sounds.system())
|
||||
.add_system(add_footstep_sounds)
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
footstep.system().after(TransformSystem::TransformPropagate),
|
||||
footstep.after(TransformSystem::TransformPropagate),
|
||||
)
|
||||
.add_system(add_sound_icon_sounds.system())
|
||||
.add_system(add_sound_icon_sounds)
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
sound_icon::<S>
|
||||
.system()
|
||||
.after(TransformSystem::TransformPropagate),
|
||||
sound_icon::<S>.after(TransformSystem::TransformPropagate),
|
||||
)
|
||||
.add_stage_after(
|
||||
CoreStage::PostUpdate,
|
||||
|
@ -315,12 +313,12 @@ where
|
|||
)
|
||||
.add_system_to_stage(
|
||||
SOUND_ICON_AND_EXPLORATION_STAGE,
|
||||
sound_icon_exploration_focus_changed.system(),
|
||||
sound_icon_exploration_focus_changed,
|
||||
)
|
||||
.add_system_to_stage(
|
||||
SOUND_ICON_AND_EXPLORATION_STAGE,
|
||||
sound_icon_exploration_focus_removed.system(),
|
||||
sound_icon_exploration_focus_removed,
|
||||
)
|
||||
.add_system(scale_sounds.system());
|
||||
.add_system(scale_sounds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,15 +17,15 @@ use crate::{
|
|||
utils::target_and_other,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct DontLogWhenVisible;
|
||||
|
||||
#[derive(Clone, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct RevealedTiles(pub Vec<bool>);
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
#[derive(Component, Clone, Debug, Eq, PartialEq)]
|
||||
pub struct Viewshed {
|
||||
pub range: u32,
|
||||
pub visible_points: HashSet<(i32, i32)>,
|
||||
|
@ -139,7 +139,7 @@ impl Viewshed {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deref, DerefMut, Reflect)]
|
||||
#[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct Visible(pub u8);
|
||||
|
||||
|
@ -159,7 +159,7 @@ impl Visible {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deref, DerefMut)]
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut)]
|
||||
pub struct VisibleEntities(HashSet<Entity>);
|
||||
|
||||
#[derive(Bundle, Default)]
|
||||
|
@ -356,7 +356,7 @@ fn log_visible(
|
|||
mut log: Query<&mut Log>,
|
||||
viewers: Query<(Entity, &Coordinates, &Transform), (With<Player>, With<Viewshed>)>,
|
||||
visible: Query<
|
||||
(&Name, Option<&RigidBodyPosition>, Option<&ColliderPosition>),
|
||||
(&Name, Option<&RigidBodyPositionComponent>, Option<&ColliderPositionComponent>),
|
||||
Without<DontLogWhenVisible>,
|
||||
>,
|
||||
) {
|
||||
|
@ -402,17 +402,17 @@ pub const LOG_VISIBLE_LABEL: &str = "LOG_VISIBLE";
|
|||
pub struct VisibilityPlugin;
|
||||
|
||||
impl Plugin for VisibilityPlugin {
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_event::<VisibilityChanged>()
|
||||
.add_system(add_visibility_indices.system())
|
||||
.add_system_to_stage(CoreStage::PostUpdate, viewshed_removed.system())
|
||||
.add_system(add_visibility_indices)
|
||||
.add_system_to_stage(CoreStage::PostUpdate, viewshed_removed)
|
||||
.add_system_set(
|
||||
SystemSet::new()
|
||||
.with_run_criteria(FixedTimestep::step(0.1))
|
||||
.with_system(update_viewshed.system()),
|
||||
.with_system(update_viewshed),
|
||||
)
|
||||
.add_system_to_stage(CoreStage::PostUpdate, remove_visible.system())
|
||||
.add_system_to_stage(CoreStage::PostUpdate, update_revealed_tiles.system())
|
||||
.add_system_to_stage(CoreStage::PostUpdate, log_visible.system());
|
||||
.add_system_to_stage(CoreStage::PostUpdate, remove_visible)
|
||||
.add_system_to_stage(CoreStage::PostUpdate, update_revealed_tiles)
|
||||
.add_system_to_stage(CoreStage::PostUpdate, log_visible);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user