external config
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
use bevy::prelude::Resource;
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Resource)]
|
||||
pub struct GameConfig {
|
||||
pub initial_chunk_radius: i32,
|
||||
pub spawn_counts: SpawnCounts,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct SpawnCounts {
|
||||
pub dorfs: u32,
|
||||
pub pigs: u32,
|
||||
pub rabbits: u32,
|
||||
}
|
||||
|
||||
impl GameConfig {
|
||||
pub fn load() -> Self {
|
||||
let config_str = fs::read_to_string("config.toml").expect("Failed to find config.toml");
|
||||
toml::from_str(&config_str).expect("Failed to parse config.toml")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user