Compare commits

..

No commits in common. "de9b8d99e88ea9349bb24fd642b9ace9ddc2d926" and "e9a1580ce7cb5185965d65863fcbae43249d31a9" have entirely different histories.

10 changed files with 52 additions and 134 deletions

View file

@ -35,35 +35,29 @@ impl Plugin for ActorPlugin {
app.add_systems(
FixedUpdate,
(
update_physics_lifeforms.run_if(game_running),
update_power.run_if(game_running),
handle_gravity.run_if(game_running),
handle_wants_maxrotation.run_if(game_running),
handle_wants_maxvelocity
.run_if(game_running)
.run_if(any_with_component::<WantsMaxVelocity>),
handle_wants_lookat.run_if(game_running).run_if(alive),
update_physics_lifeforms,
update_power,
handle_gravity,
handle_wants_maxrotation,
handle_wants_maxvelocity.run_if(any_with_component::<WantsMaxVelocity>),
handle_wants_lookat.run_if(alive),
),
);
app.add_systems(
PostUpdate,
handle_gforce
.run_if(game_running)
.after(PhysicsSet::Sync)
.after(sync::position_to_transform),
);
app.add_systems(
Update,
(
handle_input.run_if(in_control).run_if(game_running),
handle_collisions.run_if(game_running),
handle_damage.run_if(game_running),
handle_input.run_if(in_control),
handle_collisions,
handle_damage,
),
);
app.add_systems(
PostUpdate,
(handle_vehicle_enter_exit.run_if(game_running),),
);
app.add_systems(PostUpdate, (handle_vehicle_enter_exit,));
app.add_event::<VehicleEnterExitEvent>();
}
}

View file

@ -32,23 +32,15 @@ pub struct CameraPlugin;
impl Plugin for CameraPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, setup_camera);
app.add_systems(Update, handle_input.run_if(in_control).run_if(game_running));
app.add_systems(
Update,
update_map_only_object_visibility
.run_if(alive)
.run_if(game_running),
);
app.add_systems(Update, handle_input.run_if(in_control));
app.add_systems(Update, update_map_only_object_visibility.run_if(alive));
app.add_systems(
PostUpdate,
manage_player_actor
.run_if(game_running)
.in_set(sync::SyncSet::PositionToTransform),
manage_player_actor.in_set(sync::SyncSet::PositionToTransform),
);
app.add_systems(
PostUpdate,
sync_camera_to_player
.run_if(game_running)
.after(PhysicsSet::Sync)
.after(apply_input_to_player)
.before(TransformSystem::TransformPropagate),
@ -56,16 +48,12 @@ impl Plugin for CameraPlugin {
app.add_systems(
PostUpdate,
update_mapcam_center
.run_if(game_running)
.before(sync::position_to_transform)
.in_set(sync::SyncSet::PositionToTransform),
);
app.add_systems(
Update,
update_map_camera.run_if(in_control).run_if(game_running),
);
app.add_systems(Update, update_fov.run_if(alive).run_if(game_running));
app.add_systems(PreUpdate, apply_input_to_player.run_if(game_running));
app.add_systems(Update, update_map_camera.run_if(in_control));
app.add_systems(Update, update_fov.run_if(alive));
app.add_systems(PreUpdate, apply_input_to_player);
app.insert_resource(MapCam::default());
// To center the renderer origin on the player camera,
@ -78,7 +66,6 @@ impl Plugin for CameraPlugin {
app.add_systems(
PostUpdate,
position_to_transform
.run_if(game_running)
.after(sync::position_to_transform)
.in_set(sync::SyncSet::PositionToTransform),
);

View file

@ -75,20 +75,12 @@ impl Plugin for ChatPlugin {
app.add_systems(
Update,
(
handle_reply_keys
.run_if(game_running)
.before(handle_chat_timer),
handle_chat_timer
.run_if(game_running)
.before(handle_chat_events),
handle_new_conversations
.run_if(game_running)
.before(handle_chat_events),
handle_chat_events
.run_if(game_running)
.before(handle_chat_scripts),
handle_chat_scripts.run_if(game_running),
update_chat_variables.run_if(game_running),
handle_reply_keys.before(handle_chat_timer),
handle_chat_timer.before(handle_chat_events),
handle_new_conversations.before(handle_chat_events),
handle_chat_events.before(handle_chat_scripts),
handle_chat_scripts,
update_chat_variables,
),
);
app.add_event::<StartConversationEvent>();

View file

@ -29,21 +29,15 @@ impl Plugin for CmdPlugin {
app.add_systems(
Update,
handle_spawn_events
.run_if(game_running)
.before(spawn_entities)
.before(spawn_scenes),
);
app.add_systems(Update, spawn_entities.run_if(game_running));
app.add_systems(
Update,
spawn_scenes.run_if(game_running).after(spawn_entities),
);
app.add_systems(Update, process_mesh.run_if(game_running));
app.add_systems(Update, spawn_entities);
app.add_systems(Update, spawn_scenes.after(spawn_entities));
app.add_systems(Update, process_mesh);
app.add_systems(
PreUpdate,
hide_colliders
.run_if(game_running)
.run_if(any_with_component::<NeedsSceneColliderRemoved>),
hide_colliders.run_if(any_with_component::<NeedsSceneColliderRemoved>),
);
app.add_event::<SpawnEvent>();
app.add_event::<SpawnActorEvent>();

View file

@ -72,10 +72,6 @@ pub fn in_control(settings: Res<Settings>) -> bool {
return settings.in_control();
}
pub fn game_running(settings: Res<Settings>) -> bool {
return settings.is_game_running();
}
pub fn in_shadow(
light_source_pos: DVec3,
light_source_r: f64,

View file

@ -26,28 +26,20 @@ pub struct GamePlugin;
impl Plugin for GamePlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, setup);
app.add_systems(
Update,
handle_cheats.run_if(game_running).run_if(in_control),
);
app.add_systems(Update, debug.run_if(game_running));
app.add_systems(Update, handle_cheats.run_if(in_control));
app.add_systems(Update, debug);
app.add_systems(PostUpdate, handle_game_event);
app.add_systems(Update, handle_window_focus);
app.add_systems(PreUpdate, handle_player_death.run_if(game_running));
app.add_systems(PreUpdate, handle_player_death);
app.add_systems(
PostUpdate,
update_id2pos
.run_if(game_running)
.in_set(bevy_xpbd_3d::plugins::sync::SyncSet::PositionToTransform),
update_id2pos.in_set(bevy_xpbd_3d::plugins::sync::SyncSet::PositionToTransform),
);
app.add_systems(PostUpdate, update_id2v);
app.add_systems(
Update,
handle_achievement_event
.run_if(game_running)
.run_if(on_event::<AchievementEvent>()),
handle_achievement_event.run_if(on_event::<AchievementEvent>()),
);
app.add_systems(Update, check_achievements.run_if(game_running));
app.add_systems(Update, check_achievements);
app.insert_resource(Id2Pos(HashMap::new()));
app.insert_resource(Id2V(HashMap::new()));
app.insert_resource(JupiterPos(DVec3::ZERO));
@ -617,19 +609,3 @@ fn check_achievements(
ew_achievement.send(AchievementEvent::InJupitersShadow);
}
}
fn handle_window_focus(
mut settings: ResMut<Settings>,
mut er_focus: EventReader<bevy::window::WindowFocused>,
mut physicstime: ResMut<Time<Physics>>,
) {
for event in er_focus.read() {
settings.window_focused = event.focused;
}
if settings.is_game_running() {
physicstime.unpause();
} else {
physicstime.pause();
}
}

View file

@ -57,31 +57,26 @@ impl Plugin for HudPlugin {
app.add_systems(
Update,
(
update_hud.run_if(game_running),
update_dashboard.run_if(game_running),
update_speedometer.run_if(game_running),
update_gauges.run_if(game_running),
handle_input.run_if(game_running).run_if(in_control),
handle_target_event.run_if(game_running),
update_hud,
update_dashboard,
update_speedometer,
update_gauges,
handle_input.run_if(in_control),
handle_target_event,
),
);
app.add_systems(
PostUpdate,
(
update_overlay_visibility.run_if(game_running),
update_avatar
.run_if(game_running)
.run_if(on_event::<UpdateAvatarEvent>()),
update_overlay_visibility,
update_avatar.run_if(on_event::<UpdateAvatarEvent>()),
update_ar_overlays
.run_if(game_running)
.after(camera::position_to_transform)
.in_set(sync::SyncSet::PositionToTransform),
update_poi_overlays
.run_if(game_running)
.after(camera::position_to_transform)
.in_set(sync::SyncSet::PositionToTransform),
update_target_selectagon
.run_if(game_running)
.after(PhysicsSet::Sync)
.after(camera::apply_input_to_player)
.before(TransformSystem::TransformPropagate),

View file

@ -39,7 +39,6 @@ pub struct Settings {
pub god_mode: bool,
pub version: String,
pub alive: bool,
pub window_focused: bool,
pub mute_sfx: bool,
pub noise_cancellation_mode: usize,
pub noise_cancellation_modes: Vec<(String, f32)>,
@ -172,7 +171,6 @@ impl Default for Settings {
god_mode: false,
version,
alive: true,
window_focused: true,
mute_sfx: false,
noise_cancellation_mode: 0,
noise_cancellation_modes: vec![
@ -310,10 +308,6 @@ impl Settings {
*self = Self::default();
}
pub fn is_game_running(&self) -> bool {
!self.menu_active && self.window_focused
}
pub fn reset_player_settings(&mut self) {
println!("Resetting player settings!");
let default = Self::default();

View file

@ -22,17 +22,14 @@ impl Plugin for VisualPlugin {
app.add_systems(Startup, setup.after(menu::setup).after(hud::setup));
app.add_systems(
Startup,
spawn_effects
.run_if(game_running)
.after(setup)
.after(camera::setup_camera),
spawn_effects.after(setup).after(camera::setup_camera),
);
app.add_systems(Update, spawn_effects.run_if(game_running));
app.add_systems(Update, update_fadein.run_if(game_running));
app.add_systems(Update, update_fadeout.run_if(game_running));
app.add_systems(Update, update_fade_material.run_if(game_running));
app.add_systems(Update, update_grow.run_if(game_running));
app.add_systems(Update, play_animations.run_if(game_running));
app.add_systems(Update, spawn_effects);
app.add_systems(Update, update_fadein);
app.add_systems(Update, update_fadeout);
app.add_systems(Update, update_fade_material);
app.add_systems(Update, update_grow);
app.add_systems(Update, play_animations);
// Blackout disabled for now
//app.add_systems(Update, update_blackout);
app.add_event::<SpawnEffectEvent>();

View file

@ -37,17 +37,10 @@ pub struct WorldPlugin;
impl Plugin for WorldPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, setup);
app.add_systems(Update, handle_respawn.run_if(on_event::<RespawnEvent>()));
app.add_systems(
Update,
handle_respawn
.run_if(game_running)
.run_if(on_event::<RespawnEvent>()),
);
app.add_systems(
Update,
handle_despawn_at
.run_if(game_running)
.run_if(any_with_component::<DespawnAt>),
handle_despawn_at.run_if(any_with_component::<DespawnAt>),
);
app.add_plugins(PhysicsPlugins::default());
//app.add_plugins(PhysicsDebugPlugin::default());
@ -59,8 +52,8 @@ impl Plugin for WorldPlugin {
ASTEROID_UPDATE_INTERVAL,
TimerMode::Repeating,
)));
app.add_systems(Update, spawn_despawn_asteroids.run_if(game_running));
app.add_systems(PostUpdate, handle_despawn_asteroids.run_if(game_running));
app.add_systems(Update, spawn_despawn_asteroids);
app.add_systems(PostUpdate, handle_despawn_asteroids);
app.add_event::<DespawnAsteroidEvent>();
}
}