2022-02-01 15:41:08 -05:00
|
|
|
//! Generates entities based on spec files
|
2022-01-11 14:16:23 -05:00
|
|
|
mod faction_structs;
|
2021-12-23 11:00:37 -05:00
|
|
|
mod item_structs;
|
2022-01-05 09:42:36 -05:00
|
|
|
mod loot_structs;
|
2021-12-23 12:31:03 -05:00
|
|
|
mod mob_structs;
|
2021-12-23 12:48:09 -05:00
|
|
|
mod prop_structs;
|
2021-12-23 11:38:37 -05:00
|
|
|
mod rawmaster;
|
2021-12-23 13:07:50 -05:00
|
|
|
mod spawn_table_structs;
|
2022-01-25 09:58:30 -05:00
|
|
|
mod spell_structs;
|
2022-01-31 09:48:44 -05:00
|
|
|
mod weapon_traits;
|
2021-12-23 11:38:37 -05:00
|
|
|
|
|
|
|
use std::sync::Mutex;
|
2021-12-23 11:00:37 -05:00
|
|
|
|
2021-12-24 10:38:44 -05:00
|
|
|
use ::rltk::{embedded_resource, link_resource};
|
|
|
|
use ::serde::Deserialize;
|
2022-01-11 14:16:23 -05:00
|
|
|
pub use faction_structs::*;
|
2021-12-23 12:31:03 -05:00
|
|
|
use item_structs::*;
|
2022-01-05 09:42:36 -05:00
|
|
|
use loot_structs::*;
|
2021-12-23 12:31:03 -05:00
|
|
|
use mob_structs::*;
|
2021-12-23 12:48:09 -05:00
|
|
|
use prop_structs::*;
|
2021-12-23 11:38:37 -05:00
|
|
|
pub use rawmaster::*;
|
2021-12-23 13:07:50 -05:00
|
|
|
use spawn_table_structs::*;
|
2022-01-25 09:58:30 -05:00
|
|
|
pub use spell_structs::Spell;
|
2022-01-31 09:48:44 -05:00
|
|
|
pub use weapon_traits::*;
|
2021-12-23 12:31:03 -05:00
|
|
|
|
2022-01-25 09:58:30 -05:00
|
|
|
#[derive(Deserialize, Default, Debug)]
|
2021-12-23 12:31:03 -05:00
|
|
|
pub struct Raws {
|
|
|
|
pub items: Vec<Item>,
|
|
|
|
pub mobs: Vec<Mob>,
|
2021-12-23 12:48:09 -05:00
|
|
|
pub props: Vec<Prop>,
|
2021-12-23 13:07:50 -05:00
|
|
|
pub spawn_table: Vec<SpawnTableEntry>,
|
2022-01-05 09:42:36 -05:00
|
|
|
pub loot_tables: Vec<LootTable>,
|
2022-01-11 14:16:23 -05:00
|
|
|
pub faction_table: Vec<FactionInfo>,
|
2022-01-25 09:58:30 -05:00
|
|
|
pub spells: Vec<Spell>,
|
2022-01-31 09:48:44 -05:00
|
|
|
pub weapon_traits: Vec<WeaponTrait>,
|
2021-12-23 12:31:03 -05:00
|
|
|
}
|
2021-12-23 11:00:37 -05:00
|
|
|
|
2021-12-24 10:38:44 -05:00
|
|
|
embedded_resource!(RAW_FILE, "../raws/spawns.json");
|
2021-12-23 11:00:37 -05:00
|
|
|
|
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-24 10:38:44 -05:00
|
|
|
link_resource!(RAW_FILE, "../raws/spawns.json");
|
2021-12-23 11:38:37 -05:00
|
|
|
|
2021-12-24 10:38:44 -05:00
|
|
|
let raw_data = ::rltk::embedding::EMBED
|
2021-12-23 11:00:37 -05:00
|
|
|
.lock()
|
|
|
|
.get_resource("../raws/spawns.json".to_string())
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let raw_string =
|
2021-12-23 12:05:56 -05:00
|
|
|
std::str::from_utf8(raw_data).expect("Unable to convert to a valid UTF-8 string.");
|
2021-12-24 10:38:44 -05:00
|
|
|
let decoder: Raws = ::serde_json::from_str(raw_string).expect("Unable to parse JSON");
|
2021-12-23 11:00:37 -05:00
|
|
|
|
2021-12-23 11:38:37 -05:00
|
|
|
RAWS.lock().unwrap().load(decoder);
|
2021-12-23 11:00:37 -05:00
|
|
|
}
|