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(super) struct RuntimeHandlers {
pub(super) recipes: Vec<(String, String, yog_data::Value)>,
pub(super) items: Vec<ItemDef>,
pub(super) entities: Vec<yog_registry::EntityDef>,
pub(super) attributes: Vec<yog_registry::AttributeDef>,
pub(super) effects: Vec<yog_registry::EffectDef>,
pub(super) potions: Vec<yog_registry::PotionDef>,
pub(super) blocks: Vec<BlockDef>,
pub(super) content_blob: Mutex<Option<Arc<Vec<u8>>>>,
pub(super) sound_groups: HashMap<String, yog_registry::SoundGroup>,
pub(super) tool_materials: HashMap<String, yog_registry::ToolMaterial>,
pub(super) biome_features: Vec<yog_registry::BiomeFeature>,
pub(super) armor_materials: HashMap<String, yog_registry::ArmorMaterial>,
pub(super) inventories: Vec<yog_inventory::InventoryDef>,
pub(super) books: std::collections::HashSet<String>,
pub(super) book_renderers: Mutex<HashMap<String, yog_book::BookRenderer>>,
pub(super) dimensions: HashMap<String, yog_data::Value>,
pub(super) terrains: HashMap<String, Arc<yog_worldgen::Generator>>,
pub active_uis: Mutex<Vec<UiLayer>>,
pub(super) startup_grants: Vec<yog_registry::StartupGrant>,
pub(super) pending_grants: Mutex<Vec<(String, String, u32)>>,
}
unsafe impl Send for RuntimeHandlers {}
unsafe impl Sync for RuntimeHandlers {}
pub(super) fn handlers() -> yog_sync::RwLockReadGuard<'static, RuntimeHandlers> {
HANDLERS.read()
}
pub(super) fn handlers_write() -> yog_sync::RwLockWriteGuard<'static, RuntimeHandlers> {
HANDLERS.write()
}
pub(super) fn hot_reloader() -> &'static HotReloader<RuntimeModuleRegistry> {
&HOT_RELOADER
}
pub(super) 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);
}
}