~starkingdoms/starkingdoms

ref: 6cc37973babd2f840d5d72056b568d5ab245363c starkingdoms/server/src/config.rs -rw-r--r-- 2.6 KiB
6cc37973core server config file 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// 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 std::collections::HashMap;
use std::net::IpAddr;
use bevy_rapier2d::rapier::dynamics::IntegrationParameters;
use serde::{Deserialize, Serialize};
use crate::component::{PartType, PlanetType};

#[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: u64
}

#[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
}