Compare commits
No commits in common. "0554e2dded9d44a7d4adcf7a322d7b583918ee63" and "7c7504834ff6b2ea7817a71016c6f1a6738a793d" have entirely different histories.
0554e2dded
...
7c7504834f
|
@ -701,7 +701,6 @@ impl PluginGroup for CorePlugins {
|
||||||
PluginGroupBuilder::start::<Self>()
|
PluginGroupBuilder::start::<Self>()
|
||||||
.add(crate::bevy_tts::TtsPlugin)
|
.add(crate::bevy_tts::TtsPlugin)
|
||||||
.add(crate::bevy_synthizer::SynthizerPlugin::default())
|
.add(crate::bevy_synthizer::SynthizerPlugin::default())
|
||||||
.add(crate::navigation::NavigationPlugin::default())
|
|
||||||
.add(CorePlugin::default())
|
.add(CorePlugin::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,8 +376,27 @@ fn cancel_on_navigate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cleanup(
|
||||||
|
mut commands: Commands,
|
||||||
|
explorers: Query<Entity, With<Exploring>>,
|
||||||
|
focus: Query<Entity, With<ExplorationFocused>>,
|
||||||
|
) {
|
||||||
|
for entity in &explorers {
|
||||||
|
commands.entity(entity).remove::<Exploring>();
|
||||||
|
}
|
||||||
|
for entity in &focus {
|
||||||
|
commands.entity(entity).remove::<ExplorationFocused>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Resource, Clone, Debug, Default)]
|
||||||
|
struct ExplorationConfig<State> {
|
||||||
|
states: Vec<State>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Resource, Clone, Default)]
|
#[derive(Resource, Clone, Default)]
|
||||||
pub struct ExplorationPlugin<ExplorationType, MapData> {
|
pub struct ExplorationPlugin<ExplorationType, State, MapData> {
|
||||||
|
pub states: Vec<State>,
|
||||||
pub exploration_type: PhantomData<ExplorationType>,
|
pub exploration_type: PhantomData<ExplorationType>,
|
||||||
pub map_data: PhantomData<MapData>,
|
pub map_data: PhantomData<MapData>,
|
||||||
}
|
}
|
||||||
|
@ -385,13 +404,18 @@ pub struct ExplorationPlugin<ExplorationType, MapData> {
|
||||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
||||||
pub struct Exploration;
|
pub struct Exploration;
|
||||||
|
|
||||||
impl<ExplorationType, MapData> Plugin for ExplorationPlugin<ExplorationType, MapData>
|
impl<ExplorationType, State, MapData> Plugin for ExplorationPlugin<ExplorationType, State, MapData>
|
||||||
where
|
where
|
||||||
ExplorationType: 'static + Component + Default + Copy + Ord + PartialEq + Into<String>,
|
ExplorationType: 'static + Component + Default + Copy + Ord + PartialEq + Into<String>,
|
||||||
|
State: States,
|
||||||
MapData: 'static + Clone + Default + Send + Sync,
|
MapData: 'static + Clone + Default + Send + Sync,
|
||||||
{
|
{
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.register_type::<ExplorationFocused>()
|
let config = ExplorationConfig {
|
||||||
|
states: self.states.clone(),
|
||||||
|
};
|
||||||
|
app.insert_resource(config.clone())
|
||||||
|
.register_type::<ExplorationFocused>()
|
||||||
.register_type::<Mappable>()
|
.register_type::<Mappable>()
|
||||||
.register_type::<Explorable>()
|
.register_type::<Explorable>()
|
||||||
.add_plugins(InputManagerPlugin::<ExplorationAction>::default())
|
.add_plugins(InputManagerPlugin::<ExplorationAction>::default())
|
||||||
|
@ -419,5 +443,12 @@ where
|
||||||
FixedUpdate,
|
FixedUpdate,
|
||||||
(navigate_to_explored::<MapData>, cancel_on_navigate).in_set(Exploration),
|
(navigate_to_explored::<MapData>, cancel_on_navigate).in_set(Exploration),
|
||||||
);
|
);
|
||||||
|
if !config.states.is_empty() {
|
||||||
|
let states = config.states;
|
||||||
|
for state in states {
|
||||||
|
app.configure_sets(FixedUpdate, Exploration.run_if(in_state(state.clone())))
|
||||||
|
.add_systems(OnExit(state), cleanup);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,13 +312,15 @@ fn add_speed(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log_zone_descriptions(
|
fn log_zone_descriptions<State>(
|
||||||
mut events: EventReader<Collision>,
|
mut events: EventReader<Collision>,
|
||||||
zones: Query<(&ColliderAabb, Option<&Name>), With<Zone>>,
|
zones: Query<(&ColliderAabb, Option<&Name>), With<Zone>>,
|
||||||
players: Query<&Player>,
|
players: Query<&Player>,
|
||||||
config: Res<NavigationPlugin>,
|
config: Res<NavigationPlugin<State>>,
|
||||||
mut log: Query<&mut Log>,
|
mut log: Query<&mut Log>,
|
||||||
) {
|
) where
|
||||||
|
State: 'static + Send + Sync,
|
||||||
|
{
|
||||||
if !config.log_area_descriptions {
|
if !config.log_area_descriptions {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -359,24 +361,29 @@ fn log_zone_descriptions(
|
||||||
pub struct Movement;
|
pub struct Movement;
|
||||||
|
|
||||||
#[derive(Resource, Clone, Debug)]
|
#[derive(Resource, Clone, Debug)]
|
||||||
pub struct NavigationPlugin {
|
pub struct NavigationPlugin<State> {
|
||||||
|
pub states: Vec<State>,
|
||||||
pub describe_undescribed_areas: bool,
|
pub describe_undescribed_areas: bool,
|
||||||
pub log_area_descriptions: bool,
|
pub log_area_descriptions: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for NavigationPlugin {
|
impl<State> Default for NavigationPlugin<State> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
states: vec![],
|
||||||
describe_undescribed_areas: false,
|
describe_undescribed_areas: false,
|
||||||
log_area_descriptions: true,
|
log_area_descriptions: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Plugin for NavigationPlugin {
|
impl<State> Plugin for NavigationPlugin<State>
|
||||||
|
where
|
||||||
|
State: States,
|
||||||
|
{
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.insert_resource(self.clone())
|
app.insert_resource(self.clone());
|
||||||
.init_resource::<SnapTimers>()
|
app.init_resource::<SnapTimers>()
|
||||||
.register_type::<BackwardMovementFactor>()
|
.register_type::<BackwardMovementFactor>()
|
||||||
.register_type::<ForwardMovementFactor>()
|
.register_type::<ForwardMovementFactor>()
|
||||||
.register_type::<StrafeMovementFactor>()
|
.register_type::<StrafeMovementFactor>()
|
||||||
|
@ -394,6 +401,14 @@ impl Plugin for NavigationPlugin {
|
||||||
FixedUpdate,
|
FixedUpdate,
|
||||||
(tick_snap_timers, speak_direction.pipe(error_handler)),
|
(tick_snap_timers, speak_direction.pipe(error_handler)),
|
||||||
)
|
)
|
||||||
.add_systems(PostUpdate, (remove_direction, log_zone_descriptions));
|
.add_systems(
|
||||||
|
PostUpdate,
|
||||||
|
(remove_direction, log_zone_descriptions::<State>),
|
||||||
|
);
|
||||||
|
if !self.states.is_empty() {
|
||||||
|
for state in &self.states {
|
||||||
|
app.configure_sets(Update, Movement.run_if(in_state(state.clone())));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user