2021-12-23 11:00:37 -05:00
|
|
|
mod item_structs;
|
2021-12-23 11:38:37 -05:00
|
|
|
mod rawmaster;
|
|
|
|
|
|
|
|
use std::sync::Mutex;
|
2021-12-23 11:00:37 -05:00
|
|
|
|
|
|
|
use item_structs::Raws;
|
2021-12-23 11:38:37 -05:00
|
|
|
pub use rawmaster::*;
|
2021-12-23 11:00:37 -05:00
|
|
|
|
|
|
|
rltk::embedded_resource!(RAW_FILE, "../raws/spawns.json");
|
|
|
|
|
2021-12-23 11:38:37 -05:00
|
|
|
lazy_static! {
|
|
|
|
pub static ref RAWS: Mutex<RawMaster> = Mutex::new(RawMaster::empty());
|
|
|
|
}
|
|
|
|
|
2021-12-23 11:00:37 -05:00
|
|
|
pub fn load_raws() {
|
2021-12-23 11:38:37 -05:00
|
|
|
rltk::link_resource!(RAW_FILE, "../raws/spawns.json");
|
|
|
|
|
2021-12-23 11:00:37 -05:00
|
|
|
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");
|
|
|
|
|
2021-12-23 11:38:37 -05:00
|
|
|
RAWS.lock().unwrap().load(decoder);
|
2021-12-23 11:00:37 -05:00
|
|
|
}
|