diff --git a/src/features/config/components.rs b/src/features/config/components.rs index 1f3ccb8..f1c5076 100644 --- a/src/features/config/components.rs +++ b/src/features/config/components.rs @@ -2,6 +2,7 @@ use crate::prelude::*; use std::fs::File; use std::io::BufReader; +/// Global configuration loaded from file, containing balancing numbers and paths. #[derive(Resource, Deserialize, Debug)] pub struct GameConfig { pub grid_width: u32, @@ -14,6 +15,7 @@ pub struct GameConfig { pub berries_per_focus_minute: u32, } +/// Configuration for a specific type of seed. #[derive(Deserialize, Debug, Clone)] pub struct BerrySeedConfig { pub name: String, @@ -61,10 +63,12 @@ impl Default for GameConfig { } impl GameConfig { + /// Reads `config.json` from assets. pub fn read_config() -> Option { Self::read_from_path(std::path::Path::new("assets/config.json")) } + /// Reads configuration from a specific path. pub fn read_from_path(path: &std::path::Path) -> Option { let file = File::open(path).ok()?; let reader = BufReader::new(file); diff --git a/src/features/core/mod.rs b/src/features/core/mod.rs index bc0e573..cc979a0 100644 --- a/src/features/core/mod.rs +++ b/src/features/core/mod.rs @@ -2,6 +2,7 @@ use crate::prelude::*; pub mod states; +/// Handles core engine setup like camera and initial state. pub struct CorePlugin; impl Plugin for CorePlugin { @@ -11,6 +12,7 @@ impl Plugin for CorePlugin { } } +/// Spawns the main 2D camera. fn setup_camera(mut commands: Commands) { commands.spawn(Camera2d::default()); } diff --git a/src/features/core/states.rs b/src/features/core/states.rs index e14ed92..8ae853b 100644 --- a/src/features/core/states.rs +++ b/src/features/core/states.rs @@ -1,5 +1,6 @@ use crate::prelude::*; +/// Global states of the application. #[derive(States, Clone, PartialEq, Eq, Debug, Hash, Default)] pub enum AppState { #[default] diff --git a/src/utils/path.rs b/src/utils/path.rs index 22d3cfb..c65cf2e 100644 --- a/src/utils/path.rs +++ b/src/utils/path.rs @@ -1,6 +1,7 @@ use directories::ProjectDirs; use std::path::PathBuf; +/// Returns the platform-specific data directory for the application. pub fn get_internal_path() -> Option { let project_dirs = ProjectDirs::from("de", "demenik", "pomomon-garden");