aozhiwei 261433b00d 1
2024-01-17 14:04:14 +08:00

159 lines
4.7 KiB
C++

#include "precompile.h"
#include "mt/MetaMgr.h"
#include "mt/Param.h"
#include "mt/Map.h"
#include "mt/Hero.h"
#include "mt/Attr.h"
#include "mt/FormulaPvp.h"
#include "mt/GunQuality.h"
#include "mt/GunTalentGrow.h"
#include "mt/HeroQuality.h"
#include "mt/PveGemini.h"
#include "mt/PveGeminiContent.h"
#include "mt/PveGeminiMode.h"
#include "mt/Text.h"
#include "mt/RankRoom.h"
#include "mt/RankPoint.h"
#include "mt/RankReward.h"
#include "mt/KillReward.h"
#include "mt/KillPoint.h"
#include "mt/AI.h"
#include "mt/Robot.h"
#include "mt/AirLine.h"
#include "mt/AirRaid.h"
#include "mt/AirDrop.h"
#include "mt/Drop.h"
#include "mt/NpcStandard.h"
#include "mt/Buff.h"
#include "mt/MapThing.h"
#include "mt/SafeArea.h"
#include "mt/Equip.h"
#include "mt/Item.h"
#include "mt/SafeAreaPos.h"
#include "mt/Skill.h"
#include "mt/SkillNumber.h"
#include "mt/MapArea.h"
#include "mt/MapCollider.h"
#include "mt/GuideStep.h"
#include "mt/MergeItem.h"
#include "mt/MapThingGroup.h"
#include "mt/SafeAreaSafePoint.h"
#include "mt/BattleBasicAttribute.h"
#include "mt/BattleLevelAttribute.h"
#include "mt/BattleRandAttribute.h"
#include "mt/BattleWeaponAttribute.h"
#include "mt/Condition.h"
#include "mt/Distribution.h"
#include "mt/LootConfig.h"
#include "mt/BattleHeroGrow.h"
#include "app.h"
namespace mt
{
void MetaMgr::Init()
{
if (!f8::IsOnlineEnv()) {
if (f8::IsTestEnv()) {
res_path_ = a8::Format("../test_res%d/",
{
f8::App::Instance()->GetInstanceId()
});
} else {
res_path_ = a8::Format("../dev_res%d/",
{
f8::App::Instance()->GetInstanceId()
});
}
} else {
res_path_ = "../res/";
}
RegMetaTables();
Load();
}
void MetaMgr::RegMetaTables()
{
RegMetaTable<Param>(res_path_);
RegMetaTable<Hero>(res_path_);
RegMetaTable<Map>(res_path_);
RegMetaTable<Attr>(res_path_);
RegMetaTable<FormulaPvp>(res_path_);
RegMetaTable<GunQuality>(res_path_);
RegMetaTable<GunTalentGrow>(res_path_);
RegMetaTable<HeroQuality>(res_path_);
RegMetaTable<PveGemini>(res_path_);
RegMetaTable<PveGeminiContent>(res_path_);
RegMetaTable<PveGeminiMode>(res_path_);
RegMetaTable<Text>(res_path_);
RegMetaTable<RankRoom>(res_path_);
RegMetaTable<RankPoint>(res_path_);
RegMetaTable<RankReward>(res_path_);
RegMetaTable<KillPoint>(res_path_);
RegMetaTable<KillReward>(res_path_);
RegMetaTable<AI>(res_path_);
RegMetaTable<Robot>(res_path_);
RegMetaTable<AirLine>(res_path_);
RegMetaTable<AirRaid>(res_path_);
RegMetaTable<AirDrop>(res_path_);
RegMetaTable<Drop>(res_path_);
RegMetaTable<NpcStandard>(res_path_);
RegMetaTable<Buff>(res_path_);
RegMetaTable<MapThing>(res_path_);
RegMetaTable<SafeArea>(res_path_);
RegMetaTable<Equip>(res_path_);
RegMetaTable<Item>(res_path_);
RegMetaTable<SafeAreaPos>(res_path_);
RegMetaTable<Skill>(res_path_);
RegMetaTable<SkillNumber>(res_path_);
RegMetaTable<MapArea>(res_path_);
RegMetaTable<GuideStep>(res_path_);
RegMetaTable<MergeItem>(res_path_);
RegMetaTable<MapThingGroup>(res_path_);
RegMetaTable<SafeAreaSafePoint>(res_path_);
RegMetaTable<BattleBasicAttribute>(res_path_);
RegMetaTable<BattleLevelAttribute>(res_path_);
RegMetaTable<BattleRandAttribute>(res_path_);
RegMetaTable<BattleWeaponAttribute>(res_path_);
RegMetaTable<Condition>(res_path_);
RegMetaTable<Distribution>(res_path_);
RegMetaTable<LootConfig>(res_path_);
RegMetaTable<BattleHeroGrow>(res_path_);
}
void MetaMgr::Load()
{
for (auto& itr : meta_tables) {
itr->static_pre_init_cb();
itr->load_cb();
}
{
mt::MapCollider::LoadAll();
}
for (size_t i = 0; i < 3; ++i) {
for (auto& itr : meta_tables) {
if (i < itr->init_cbs.size()) {
itr->init_cbs.at(i)();
}
}
}
for (auto& itr : meta_tables) {
itr->static_post_init_cb();
}
{
mt::MapCollider::StaticPostInit();
}
}
void MetaMgr::UnInit()
{
for (auto t : meta_tables) {
t->destory_cb();
}
meta_tables.clear();
}
}