mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Make power bar configurable
This commit is contained in:
@@ -16,6 +16,8 @@ pub struct BattleConfig {
|
||||
pub multiplayer: super::MultiplayerConfig,
|
||||
#[serde(default = "default_maps")]
|
||||
pub maps: super::MapsConfig,
|
||||
#[serde(default = "default_energy")]
|
||||
pub energy: EnergyConfig,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
@@ -234,6 +236,12 @@ impl GameType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Copy)]
|
||||
pub struct EnergyConfig {
|
||||
pub refill_rate_per_s: f32,
|
||||
pub total: u32,
|
||||
}
|
||||
|
||||
fn default_game_modes() -> GameModes {
|
||||
GameModes {
|
||||
battle_arena: GameMode {
|
||||
@@ -498,3 +506,10 @@ fn default_maps() -> super::MapsConfig {
|
||||
map: super::maps::default_map(),
|
||||
}
|
||||
}
|
||||
|
||||
fn default_energy() -> EnergyConfig {
|
||||
EnergyConfig {
|
||||
refill_rate_per_s: 0.1, // should take 10s to refill
|
||||
total: 12_550,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,4 +434,11 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
implementation: player.implementation.clone().to_config(),
|
||||
}).collect()
|
||||
}
|
||||
|
||||
fn energy(&self) -> super::EnergyConfig {
|
||||
super::EnergyConfig {
|
||||
refill_rate: self.battle.energy.refill_rate_per_s,
|
||||
total: self.battle.energy.total,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ mod cubes_json;
|
||||
pub use cubes_json::CubeConfig;
|
||||
|
||||
mod traits;
|
||||
pub use traits::{ConfigProvider, CompleteCampaignProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator};
|
||||
pub use traits::{ConfigProvider, CompleteCampaignProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig};
|
||||
|
||||
pub type ConfigImpl = CubeConfig;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ pub trait ConfigProvider<C: Clone> {
|
||||
fn maps(&self) -> std::collections::HashMap<GameMap, MapConfig>;
|
||||
fn url_links(&self) -> LinksConfig;
|
||||
fn fake_players(&self) -> Vec<FakePlayer>;
|
||||
fn energy(&self) -> EnergyConfig;
|
||||
}
|
||||
|
||||
pub struct CompleteCampaignProvider {
|
||||
@@ -379,3 +380,9 @@ pub struct FakePlayer {
|
||||
pub enum ClientEmulator {
|
||||
Experiment,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct EnergyConfig {
|
||||
pub refill_rate: f32,
|
||||
pub total: u32,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user