docs: add documentation to core, config, and utility modules (#65)
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::prelude::*;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
|
|
||||||
|
/// Global configuration loaded from file, containing balancing numbers and paths.
|
||||||
#[derive(Resource, Deserialize, Debug)]
|
#[derive(Resource, Deserialize, Debug)]
|
||||||
pub struct GameConfig {
|
pub struct GameConfig {
|
||||||
pub grid_width: u32,
|
pub grid_width: u32,
|
||||||
@@ -14,6 +15,7 @@ pub struct GameConfig {
|
|||||||
pub berries_per_focus_minute: u32,
|
pub berries_per_focus_minute: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Configuration for a specific type of seed.
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct BerrySeedConfig {
|
pub struct BerrySeedConfig {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@@ -61,10 +63,12 @@ impl Default for GameConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GameConfig {
|
impl GameConfig {
|
||||||
|
/// Reads `config.json` from assets.
|
||||||
pub fn read_config() -> Option<Self> {
|
pub fn read_config() -> Option<Self> {
|
||||||
Self::read_from_path(std::path::Path::new("assets/config.json"))
|
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<Self> {
|
pub fn read_from_path(path: &std::path::Path) -> Option<Self> {
|
||||||
let file = File::open(path).ok()?;
|
let file = File::open(path).ok()?;
|
||||||
let reader = BufReader::new(file);
|
let reader = BufReader::new(file);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use crate::prelude::*;
|
|||||||
|
|
||||||
pub mod states;
|
pub mod states;
|
||||||
|
|
||||||
|
/// Handles core engine setup like camera and initial state.
|
||||||
pub struct CorePlugin;
|
pub struct CorePlugin;
|
||||||
|
|
||||||
impl Plugin for CorePlugin {
|
impl Plugin for CorePlugin {
|
||||||
@@ -11,6 +12,7 @@ impl Plugin for CorePlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Spawns the main 2D camera.
|
||||||
fn setup_camera(mut commands: Commands) {
|
fn setup_camera(mut commands: Commands) {
|
||||||
commands.spawn(Camera2d::default());
|
commands.spawn(Camera2d::default());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
/// Global states of the application.
|
||||||
#[derive(States, Clone, PartialEq, Eq, Debug, Hash, Default)]
|
#[derive(States, Clone, PartialEq, Eq, Debug, Hash, Default)]
|
||||||
pub enum AppState {
|
pub enum AppState {
|
||||||
#[default]
|
#[default]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
/// Returns the platform-specific data directory for the application.
|
||||||
pub fn get_internal_path() -> Option<PathBuf> {
|
pub fn get_internal_path() -> Option<PathBuf> {
|
||||||
let project_dirs = ProjectDirs::from("de", "demenik", "pomomon-garden");
|
let project_dirs = ProjectDirs::from("de", "demenik", "pomomon-garden");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user