use wowsunpack::data::idx::FileNode;
use wowsunpack::data::pkg::PkgFileLoader;
pub use wowsunpack::game_constants::{
BattleConstants, ChannelConstants, CommonConstants, ShipsConstants, WeaponsConstants,
};
#[derive(Clone)]
pub struct GameConstants {
battle: BattleConstants,
ships: ShipsConstants,
weapons: WeaponsConstants,
common: CommonConstants,
channel: ChannelConstants,
}
impl GameConstants {
pub fn from_pkg(file_tree: &FileNode, pkg_loader: &PkgFileLoader) -> Self {
Self {
battle: BattleConstants::load(file_tree, pkg_loader),
ships: ShipsConstants::load(file_tree, pkg_loader),
weapons: WeaponsConstants::load(file_tree, pkg_loader),
common: CommonConstants::load(file_tree, pkg_loader),
channel: ChannelConstants::load(file_tree, pkg_loader),
}
}
pub fn defaults() -> Self {
Self {
battle: BattleConstants::defaults(),
ships: ShipsConstants::defaults(),
weapons: WeaponsConstants::defaults(),
common: CommonConstants::defaults(),
channel: ChannelConstants::defaults(),
}
}
pub fn battle(&self) -> &BattleConstants {
&self.battle
}
pub fn ships(&self) -> &ShipsConstants {
&self.ships
}
pub fn weapons(&self) -> &WeaponsConstants {
&self.weapons
}
pub fn common(&self) -> &CommonConstants {
&self.common
}
pub fn channel(&self) -> &ChannelConstants {
&self.channel
}
pub fn game_mode_name(&self, id: i32) -> Option<&str> {
self.battle.game_mode(id)
}
pub fn death_reason_name(&self, id: i32) -> Option<&str> {
self.battle.death_reason(id)
}
pub fn camera_mode_name(&self, id: i32) -> Option<&str> {
self.battle.camera_mode(id)
}
}