#[allow(dead_code, unused_imports, unsafe_op_in_unsafe_fn)]
#[path = "../gen_flatbuffers/tables_generated.rs"]
mod data;
pub mod main_city_script;

pub use data::*;
use flatbuffers_owned::*;

macro_rules! file_cfg {
    ($($name:ident;)*) => {
        $(flatbuffers_owned!($name);)*

        ::paste::paste!{
            pub struct NapFileCfg {
                $([<$name:snake>]: [<Owned $name>],)*
        }}

        impl NapFileCfg {
            ::paste::paste!{
                pub fn new() -> Self {
                    Self {
                        $(
                            [<$name:snake>]: {
                                let filename = ::const_format::formatcp!("Filecfg/{}", ::xxhash_rust::const_xxh64::xxh64(stringify!([<$name:lower>]).as_bytes(), 0));
                                let data = std::fs::read(&filename).unwrap();
                                [<Owned $name>]::new(data.into()).unwrap()
                            },
                        )*
                    }
                }

                $(
                    pub fn [<$name:snake>](&self) -> $name {
                        self.[<$name:snake>].as_actual()
                    }
                )*
            }
        }
    };
}

file_cfg! {
    ConditionConfigTemplateTb;
    AvatarBaseTemplateTb;
    WeaponTemplateTb;
    EquipmentTemplateTb;
    EquipmentSuitTemplateTb;
    ProcedureConfigTemplateTb;
    UnlockConfigTemplateTb;
    PostGirlConfigTemplateTb;
    ArchiveFileQuestTemplateTb;
    ArchiveBattleQuestTemplateTb;
    SectionConfigTemplateTb;
    MainCityBGMConfigTemplateTb;
    HollowBuffTemplateTb;
    CafeConfigTemplateTb;
    HollowConfigTemplateTb;
    HollowQuestTemplateTb;
    BattleGroupConfigTemplateTb;
    MusicPlayerConfigTemplateTb;
    TeleportConfigTemplateTb;
    AvatarBattleTemplateTb;
    AvatarLevelAdvanceTemplateTb;
    WeaponLevelTemplateTb;
    WeaponStarTemplateTb;
    AvatarPassiveSkillTemplateTb;
    EquipmentLevelTemplateTb;
}
