// StarKingdoms.IO, a browser game about drifting through space
// Copyright (C) 2024 ghostly_zsh, TerraMaster85, core
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::component::{PartType, PlanetType};
use bevy_rapier2d::rapier::dynamics::IntegrationParameters;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::net::IpAddr;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct StkConfig {
pub security: SecurityConfig,
pub server: ServerConfig,
pub world: WorldConfig,
pub physics: PhysicsConfig,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SecurityConfig {
pub app_key: String,
pub required_permission_level: i32,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ServerConfig {
pub tick_time_ms: u64,
pub world_fixed_timestep: f64,
pub bind: BindConfig,
pub max_free_parts: usize,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct BindConfig {
pub ip: IpAddr,
pub port: u16,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct WorldConfig {
pub gravity: f32,
pub part_half_size: f32,
pub pixels_per_meter: f32,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PhysicsConfig {
pub parameters: IntegrationParameters,
pub solver: PhysicsSolver,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum PhysicsSolver {
SmallstepPGS,
OldPGS,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PlanetsConfig {
pub planets: HashMap<PlanetType, PlanetConfig>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PlanetConfig {
pub size: f32,
pub mass: f32,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PartsConfig {
pub parts: HashMap<PartType, PartConfig>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PartConfig {
pub mass: f32,
pub energy_capacity: u32,
pub thruster_force: f32,
pub thruster_energy: u32,
}