54 lines
1.3 KiB
Rust
54 lines
1.3 KiB
Rust
mod faction_structs;
|
|
mod item_structs;
|
|
mod loot_structs;
|
|
mod mob_structs;
|
|
mod prop_structs;
|
|
mod rawmaster;
|
|
mod spawn_table_structs;
|
|
mod spell_structs;
|
|
|
|
use std::sync::Mutex;
|
|
|
|
use ::rltk::{embedded_resource, link_resource};
|
|
use ::serde::Deserialize;
|
|
pub use faction_structs::*;
|
|
use item_structs::*;
|
|
use loot_structs::*;
|
|
use mob_structs::*;
|
|
use prop_structs::*;
|
|
pub use rawmaster::*;
|
|
use spawn_table_structs::*;
|
|
pub use spell_structs::Spell;
|
|
|
|
#[derive(Deserialize, Default, Debug)]
|
|
pub struct Raws {
|
|
pub items: Vec<Item>,
|
|
pub mobs: Vec<Mob>,
|
|
pub props: Vec<Prop>,
|
|
pub spawn_table: Vec<SpawnTableEntry>,
|
|
pub loot_tables: Vec<LootTable>,
|
|
pub faction_table: Vec<FactionInfo>,
|
|
pub spells: Vec<Spell>,
|
|
}
|
|
|
|
embedded_resource!(RAW_FILE, "../raws/spawns.json");
|
|
|
|
lazy_static! {
|
|
pub static ref RAWS: Mutex<RawMaster> = Mutex::new(RawMaster::empty());
|
|
}
|
|
|
|
pub fn load_raws() {
|
|
link_resource!(RAW_FILE, "../raws/spawns.json");
|
|
|
|
let raw_data = ::rltk::embedding::EMBED
|
|
.lock()
|
|
.get_resource("../raws/spawns.json".to_string())
|
|
.unwrap();
|
|
|
|
let raw_string =
|
|
std::str::from_utf8(raw_data).expect("Unable to convert to a valid UTF-8 string.");
|
|
let decoder: Raws = ::serde_json::from_str(raw_string).expect("Unable to parse JSON");
|
|
|
|
RAWS.lock().unwrap().load(decoder);
|
|
}
|