use crate::globals::HANDLERS;
use crate::globals::HOT_RELOADER;
use std::collections::HashMap;
use yog_hot_reload::HotReloader;
use yog_hot_reload::ModuleGeneration;
use yog_hot_reload::ModuleRegistry;
use yog_registry::BlockDef;
use yog_registry::ItemDef;
use yog_sync::Arc;
use yog_sync::Mutex;
#[derive(Debug, Clone)]
pub struct UiLayer {
pub id: String,
pub parent: Option<String>,
pub modal: bool,
pub visible: bool,
pub z_index: i32,
}
#[derive(Default)]
pub(crate) struct RuntimeHandlers {
pub(crate) recipes: Vec<(String, String, yog_data::Value)>,
pub(crate) items: Vec<ItemDef>,
pub(crate) entities: Vec<yog_registry::EntityDef>,
pub(crate) attributes: Vec<yog_registry::AttributeDef>,
pub(crate) effects: Vec<yog_registry::EffectDef>,
pub(crate) potions: Vec<yog_registry::PotionDef>,
pub(crate) particles: Vec<yog_registry::ParticleDef>,
pub(crate) blocks: Vec<BlockDef>,
pub(crate) content_blob: Mutex<Option<Arc<Vec<u8>>>>,
pub(crate) sound_groups: HashMap<String, yog_registry::SoundGroup>,
pub(crate) tool_materials: HashMap<String, yog_registry::ToolMaterial>,
pub(crate) biome_features: Vec<yog_registry::BiomeFeature>,
pub(crate) armor_materials: HashMap<String, yog_registry::ArmorMaterial>,
pub(crate) inventories: Vec<yog_inventory::InventoryDef>,
pub(crate) books: std::collections::HashSet<String>,
pub(crate) book_renderers: Mutex<HashMap<String, yog_book::BookRenderer>>,
pub(crate) dimensions: HashMap<String, yog_data::Value>,
pub(crate) terrains: HashMap<String, Arc<yog_worldgen::Generator>>,
pub active_uis: Mutex<Vec<UiLayer>>,
pub(crate) startup_grants: Vec<yog_registry::StartupGrant>,
pub(crate) pending_grants: Mutex<Vec<(String, String, u32)>>,
}
unsafe impl Send for RuntimeHandlers {}
unsafe impl Sync for RuntimeHandlers {}
pub(crate) fn handlers() -> yog_sync::RwLockReadGuard<'static, RuntimeHandlers> {
HANDLERS.read()
}
pub(crate) fn handlers_write() -> yog_sync::RwLockWriteGuard<'static, RuntimeHandlers> {
HANDLERS.write()
}
pub(crate) fn hot_reloader() -> &'static HotReloader<RuntimeModuleRegistry> {
&HOT_RELOADER
}
pub(crate) struct RuntimeModuleRegistry;
impl ModuleRegistry for RuntimeModuleRegistry {
fn retarget(&self, _mod_id: &str, _from: ModuleGeneration, _to: ModuleGeneration) {}
fn purge(&self, generation: ModuleGeneration) {
crate::bus::ROUTER.purge(generation);
crate::bus::purge_descriptors(generation);
crate::game::mirrors::purge(generation);
}
}