Skip to content

Commit

Permalink
Add suffix system to every system function
Browse files Browse the repository at this point in the history
  • Loading branch information
vladbat00 committed Jan 23, 2023
1 parent 33612cb commit fc64797
Show file tree
Hide file tree
Showing 27 changed files with 183 additions and 166 deletions.
4 changes: 2 additions & 2 deletions libs/client_lib/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct ReattachCameraQueries<'w, 's> {
all_entities: Query<'w, 's, Entity>,
}

pub fn reattach_camera(
pub fn reattach_camera_system(
mut commands: Commands,
time: Res<GameTime>,
main_camera_pivot: Res<MainCameraPivotEntity>,
Expand Down Expand Up @@ -119,7 +119,7 @@ pub fn reattach_camera(
}
}

pub fn move_free_camera_pivot(
pub fn move_free_camera_pivot_system(
time: Res<Time>,
main_camera_pivot: Res<MainCameraPivotEntity>,
mut camera_pivot_query: Query<(&CameraPivotDirection, &mut Transform)>,
Expand Down
2 changes: 1 addition & 1 deletion libs/client_lib/src/game_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use mr_shared_lib::{
util::PLAYER_RESPAWN_TIME, SimulationTime, SIMULATIONS_PER_SECOND,
};

pub fn process_scheduled_spawns(
pub fn process_scheduled_spawns_system(
time: Res<SimulationTime>,
players: PlayerSystemParamsMut,
players_query: Query<&Spawned>,
Expand Down
4 changes: 2 additions & 2 deletions libs/client_lib/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub struct UiParams<'w, 's> {
marker: PhantomData<&'s ()>,
}

pub fn track_input_events(
pub fn track_input_events_system(
mut input_events: InputEvents,
time: Res<GameTime>,
mut ui_params: UiParams,
Expand Down Expand Up @@ -181,7 +181,7 @@ pub fn track_input_events(
}
}

pub fn cast_mouse_ray(
pub fn cast_mouse_ray_system(
windows: Res<Windows>,
mouse_position: Res<MouseScreenPosition>,
main_camera_entity: Res<MainCameraEntity>,
Expand Down
79 changes: 40 additions & 39 deletions libs/client_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@
pub use net::DEFAULT_SERVER_PORT;

use crate::{
camera::{move_free_camera_pivot, reattach_camera},
camera::{move_free_camera_pivot_system, reattach_camera_system},
components::{CameraPivotDirection, CameraPivotTag},
config_storage::OfflineAuthConfig,
game_events::process_scheduled_spawns,
game_events::process_scheduled_spawns_system,
input::{LevelObjectRequestsQueue, MouseRay, MouseWorldPosition, PlayerRequestsQueue},
net::{
auth::read_offline_auth_config, fill_actual_frames_ahead, init_matchmaker_connection,
maintain_connection, process_network_events, send_network_updates, send_requests,
auth::read_offline_auth_config_system, fill_actual_frames_ahead_system,
init_matchmaker_connection_system, maintain_connection_system,
process_network_events_system, send_network_updates_system, send_requests_system,
ServerToConnect,
},
ui::{
builder_ui::{EditedLevelObject, EditedObjectUpdate},
debug_ui::update_debug_ui_state,
debug_ui::update_debug_ui_state_system,
},
visuals::{
control_builder_visibility, process_control_points_input, spawn_control_points,
update_player_sensor_materials,
control_builder_visibility_system, process_control_points_input_system,
spawn_control_points_system, update_player_sensor_materials_system,
},
};
use bevy::{
Expand Down Expand Up @@ -76,22 +77,22 @@ impl Plugin for MuddleClientPlugin {
let input_stage = SystemStage::single_threaded()
// Processing network events should happen before tracking input
// because we reset current's player inputs on each delta update.
.with_system(maintain_connection)
.with_system(process_network_events.after(maintain_connection))
.with_system(input::track_input_events.after(process_network_events))
.with_system(input::cast_mouse_ray.after(input::track_input_events));
.with_system(maintain_connection_system)
.with_system(process_network_events_system.after(maintain_connection_system))
.with_system(input::track_input_events_system.after(process_network_events_system))
.with_system(input::cast_mouse_ray_system.after(input::track_input_events_system));
let broadcast_updates_stage = SystemStage::single_threaded()
.with_system(send_network_updates)
.with_system(send_requests);
.with_system(send_network_updates_system)
.with_system(send_requests_system);
let post_tick_stage = SystemStage::single_threaded()
.with_system(control_builder_visibility)
.with_system(update_player_sensor_materials)
.with_system(reattach_camera)
.with_system(move_free_camera_pivot.after(reattach_camera))
.with_system(pause_simulation)
.with_system(update_debug_ui_state.after(pause_simulation))
.with_system(control_ticking_speed.after(pause_simulation))
.with_system(fill_actual_frames_ahead.after(control_ticking_speed));
.with_system(control_builder_visibility_system)
.with_system(update_player_sensor_materials_system)
.with_system(reattach_camera_system)
.with_system(move_free_camera_pivot_system.after(reattach_camera_system))
.with_system(pause_simulation_system)
.with_system(update_debug_ui_state_system.after(pause_simulation_system))
.with_system(control_ticking_speed_system.after(pause_simulation_system))
.with_system(fill_actual_frames_ahead_system.after(control_ticking_speed_system));

app.add_plugin(bevy_mod_picking::PickingPlugin)
.add_plugin(FrameTimeDiagnosticsPlugin)
Expand All @@ -102,9 +103,9 @@ impl Plugin for MuddleClientPlugin {
.init_resource::<input::MouseScreenPosition>()
.add_event::<EditedObjectUpdate>()
// Startup systems.
.add_startup_system(init_matchmaker_connection)
.add_startup_system(basic_scene)
.add_startup_system(read_offline_auth_config)
.add_startup_system(init_matchmaker_connection_system)
.add_startup_system(basic_scene_system)
.add_startup_system(read_offline_auth_config_system)
// Game.
.add_plugin(MuddleSharedPlugin::new(
IntoSystem::into_system(net_adaptive_run_criteria),
Expand All @@ -114,22 +115,22 @@ impl Plugin for MuddleClientPlugin {
post_tick_stage,
None,
))
.add_system(process_scheduled_spawns)
.add_system(process_scheduled_spawns_system)
// Egui.
.add_startup_system(ui::set_ui_scale_factor)
.add_system(ui::debug_ui::update_debug_visibility)
.add_system(ui::debug_ui::debug_ui)
.add_system(ui::debug_ui::profiler_ui)
.add_system(ui::overlay_ui::connection_status_overlay)
.add_system(ui::debug_ui::inspect_object)
.add_system(ui::player_ui::leaderboard_ui)
.add_system(ui::player_ui::help_ui)
.add_system(ui::main_menu_ui::main_menu_ui)
.add_startup_system(ui::set_ui_scale_factor_system)
.add_system(ui::debug_ui::update_debug_visibility_system)
.add_system(ui::debug_ui::debug_ui_system)
.add_system(ui::debug_ui::profiler_ui_system)
.add_system(ui::overlay_ui::connection_status_overlay_system)
.add_system(ui::debug_ui::inspect_object_system)
.add_system(ui::player_ui::leaderboard_ui_system)
.add_system(ui::player_ui::help_ui_system)
.add_system(ui::main_menu_ui::main_menu_ui_system)
// Not only Egui for builder mode.
.add_system_set(ui::builder_ui::builder_system_set().label("builder_system_set"))
// Add to the system set above after fixing https://github.com/mvlabat/muddle-run/issues/46.
.add_system(process_control_points_input.after("builder_system_set"))
.add_system(spawn_control_points.after("builder_system_set"));
.add_system(process_control_points_input_system.after("builder_system_set"))
.add_system(spawn_control_points_system.after("builder_system_set"));

let world = &mut app.world;
world
Expand Down Expand Up @@ -283,7 +284,7 @@ pub struct MainCameraPivotEntity(pub Entity);
#[derive(Resource)]
pub struct MainCameraEntity(pub Entity);

fn pause_simulation(
fn pause_simulation_system(
mut game_state: ResMut<State<GameState>>,
connection_state: Res<ConnectionState>,
game_time: Res<GameTime>,
Expand Down Expand Up @@ -333,7 +334,7 @@ fn pause_simulation(
}
}

fn basic_scene(mut commands: Commands) {
fn basic_scene_system(mut commands: Commands) {
// Add entities to the scene.
commands.spawn(PointLightBundle {
point_light: PointLight {
Expand Down Expand Up @@ -376,7 +377,7 @@ pub struct ControlTickingSpeedParams<'w, 's> {
marker: PhantomData<&'s ()>,
}

fn control_ticking_speed(
fn control_ticking_speed_system(
mut frames_ticked: Local<u16>,
mut prev_generation: Local<usize>,
mut params: ControlTickingSpeedParams,
Expand Down
2 changes: 1 addition & 1 deletion libs/client_lib/src/net/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub struct PendingOAuthRequest {
redirect_uri: String,
}

pub fn read_offline_auth_config(mut offline_auth_config: ResMut<OfflineAuthConfig>) {
pub fn read_offline_auth_config_system(mut offline_auth_config: ResMut<OfflineAuthConfig>) {
let config: OfflineAuthConfig = match config_storage::read(AUTH_CONFIG_KEY) {
Ok(config) => config,
Err(err) => {
Expand Down
15 changes: 9 additions & 6 deletions libs/client_lib/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ pub struct MainMenuUiChannels {
#[derive(Resource, DerefMut, Deref, Default)]
pub struct ServerToConnect(pub Option<Server>);

pub fn init_matchmaker_connection(mut commands: Commands, client_config: Res<MuddleClientConfig>) {
pub fn init_matchmaker_connection_system(
mut commands: Commands,
client_config: Res<MuddleClientConfig>,
) {
let matchmaker_url = match &client_config.matchmaker_url {
Some(url) => url.clone(),
None => {
Expand Down Expand Up @@ -275,7 +278,7 @@ pub struct MatchmakerParams<'w, 's> {
marker: PhantomData<&'s ()>,
}

pub fn process_network_events(
pub fn process_network_events_system(
mut network_params: NetworkParams,
mut network_events: EventReader<NetworkEvent>,
mut current_player_net_id: ResMut<CurrentPlayerNetId>,
Expand Down Expand Up @@ -687,7 +690,7 @@ pub fn process_network_events(
}
}

pub fn maintain_connection(
pub fn maintain_connection_system(
time: Res<GameTime>,
client_config: Res<MuddleClientConfig>,
matchmaker_state: Option<ResMut<MatchmakerState>>,
Expand Down Expand Up @@ -816,7 +819,7 @@ pub struct PlayerUpdateParams<'w, 's> {
player_directions: Query<'w, 's, &'static PlayerDirection>,
}

pub fn send_network_updates(
pub fn send_network_updates_system(
time: Res<GameTime>,
mut network_params: NetworkParams,
current_player_net_id: Res<CurrentPlayerNetId>,
Expand Down Expand Up @@ -912,7 +915,7 @@ pub fn send_network_updates(
}
}

pub fn send_requests(
pub fn send_requests_system(
mut network_params: NetworkParams,
mut player_requests: ResMut<PlayerRequestsQueue>,
mut level_object_requests: ResMut<LevelObjectRequestsQueue>,
Expand Down Expand Up @@ -988,7 +991,7 @@ fn can_process_delta_update_message(time: &GameTime, delta_update: &DeltaUpdate)

/// We need to access an actual value on each (fresh) delta update message, so
/// we write it for every frame, as we can't predict when we'll receive those.
pub fn fill_actual_frames_ahead(
pub fn fill_actual_frames_ahead_system(
time: Res<GameTime>,
simulation_time: Res<SimulationTime>,
mut target_frames_ahead: ResMut<TargetFramesAhead>,
Expand Down
8 changes: 4 additions & 4 deletions libs/client_lib/src/ui/builder_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ pub struct EditedObjectUpdate {
pub fn builder_system_set() -> SystemSet {
SystemSet::new()
.with_run_criteria(builder_run_criteria)
.with_system(builder_ui)
.with_system(process_builder_mouse_input.after(builder_ui))
.with_system(builder_ui_system)
.with_system(process_builder_mouse_input_system.after(builder_ui_system))
}

pub fn builder_run_criteria(
Expand All @@ -139,7 +139,7 @@ pub fn builder_run_criteria(
ShouldRun::Yes
}

pub fn builder_ui(
pub fn builder_ui_system(
mut egui_context: ResMut<EguiContext>,
mut builder_ui_state: Local<BuilderUiState>,
mouse_input: MouseInput<(), ()>,
Expand Down Expand Up @@ -343,7 +343,7 @@ pub fn builder_ui(
});
}

pub fn process_builder_mouse_input(
pub fn process_builder_mouse_input_system(
mut egui_context: ResMut<EguiContext>,
mut mouse_input: MouseInput<(), ()>,
mut level_objects: LevelObjects,
Expand Down
13 changes: 8 additions & 5 deletions libs/client_lib/src/ui/debug_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct DebugUiState {
pub jitter_millis: usize,
}

pub fn update_debug_visibility(
pub fn update_debug_visibility_system(
mut debug_ui_was_shown: Local<bool>,
debug_ui_state: Res<DebugUiState>,
mut visibility_settings: ResMut<VisibilitySettings>,
Expand All @@ -78,7 +78,10 @@ pub fn update_debug_visibility(
*debug_ui_was_shown = debug_ui_state.show;
}

pub fn update_debug_ui_state(mut debug_ui_state: ResMut<DebugUiState>, debug_data: DebugData) {
pub fn update_debug_ui_state_system(
mut debug_ui_state: ResMut<DebugUiState>,
debug_data: DebugData,
) {
#[cfg(feature = "profiler")]
puffin::profile_function!();
if debug_ui_state.pause {
Expand All @@ -99,7 +102,7 @@ pub fn update_debug_ui_state(mut debug_ui_state: ResMut<DebugUiState>, debug_dat
debug_ui_state.jitter_millis = debug_data.connection_state.jitter_millis() as usize;
}

pub fn profiler_ui(
pub fn profiler_ui_system(
// ResMut is intentional, to avoid fighting over the Mutex from different systems.
mut egui_context: ResMut<EguiContext>,
debug_ui_state: Res<DebugUiState>,
Expand All @@ -120,7 +123,7 @@ pub fn profiler_ui(
});
}

pub fn debug_ui(
pub fn debug_ui_system(
// ResMut is intentional, to avoid fighting over the Mutex from different systems.
mut egui_context: ResMut<EguiContext>,
mut debug_ui_state: ResMut<DebugUiState>,
Expand Down Expand Up @@ -221,7 +224,7 @@ pub struct InspectObjectQueries<'w, 's> {
static_ghosts: Query<'w, 's, &'static LevelObjectStaticGhostParent>,
}

pub fn inspect_object(
pub fn inspect_object_system(
// ResMut is intentional, to avoid fighting over the Mutex from different systems.
debug_ui_state: Res<DebugUiState>,
mut egui_context: ResMut<EguiContext>,
Expand Down
2 changes: 1 addition & 1 deletion libs/client_lib/src/ui/main_menu_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ pub struct UiContext<'w, 's> {
_marker: PhantomData<&'s ()>,
}

pub fn main_menu_ui(
pub fn main_menu_ui_system(
mut main_menu_ui_state: Local<MainMenuUiState>,
mut ui_context: UiContext,
matchmaker_state: Option<ResMut<MatchmakerState>>,
Expand Down
2 changes: 1 addition & 1 deletion libs/client_lib/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod player_ui;

mod widgets;

pub fn set_ui_scale_factor(mut egui_settings: ResMut<EguiSettings>, windows: Res<Windows>) {
pub fn set_ui_scale_factor_system(mut egui_settings: ResMut<EguiSettings>, windows: Res<Windows>) {
if let Some(window) = windows.get_primary() {
if window.scale_factor() % 2.0 > 0.0 {
egui_settings.scale_factor = 1.0 / window.scale_factor();
Expand Down
2 changes: 1 addition & 1 deletion libs/client_lib/src/ui/overlay_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy::ecs::system::{Res, ResMut};
use bevy_egui::{egui, EguiContext};
use mr_shared_lib::net::{ConnectionState, ConnectionStatus};

pub fn connection_status_overlay(
pub fn connection_status_overlay_system(
mut egui_context: ResMut<EguiContext>,
connection_state: Res<ConnectionState>,
server_to_connect: Res<ServerToConnect>,
Expand Down
4 changes: 2 additions & 2 deletions libs/client_lib/src/ui/player_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use mr_shared_lib::{
messages::RespawnPlayerReason, player::PlayerRole, GameTime, SIMULATIONS_PER_SECOND,
};

pub fn help_ui(
pub fn help_ui_system(
time: Res<GameTime>,
mut egui_context: ResMut<EguiContext>,
player_params: PlayerParams,
Expand Down Expand Up @@ -55,7 +55,7 @@ impl Default for LeaderboardState {
}
}

pub fn leaderboard_ui(
pub fn leaderboard_ui_system(
mut state: Local<LeaderboardState>,
keyboard_input: Res<Input<KeyCode>>,
mut egui_context: ResMut<EguiContext>,
Expand Down
Loading

0 comments on commit fc64797

Please sign in to comment.