1
This commit is contained in:
parent
dcffc2f37d
commit
17b79ff66c
@ -4,7 +4,25 @@
|
||||
|
||||
IMPL_TABLE(mt::NpcStandard)
|
||||
|
||||
std::map<long long, const mt::NpcStandard*> mt::NpcStandard::hero_lv_hash_;
|
||||
|
||||
namespace mt
|
||||
{
|
||||
|
||||
void NpcStandard::Init()
|
||||
{
|
||||
hero_lv_hash_[a8::MakeInt64(hero_id(), level())] = this;
|
||||
}
|
||||
|
||||
void NpcStandard::StaticPostInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const mt::NpcStandard* NpcStandard::GetByHeroAndLv(int hero_id, int lv)
|
||||
{
|
||||
auto itr = hero_lv_hash_.find(a8::MakeInt64(hero_id, lv));
|
||||
return itr != hero_lv_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,12 @@ namespace mt
|
||||
"npcStandard@npcStandard.json",
|
||||
"id")
|
||||
public:
|
||||
void Init();
|
||||
static void StaticPostInit();
|
||||
const mt::NpcStandard* GetByHeroAndLv(int hero_id, int lv);
|
||||
|
||||
private:
|
||||
static std::map<long long, const mt::NpcStandard*> hero_lv_hash_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ namespace mtb
|
||||
int damage() const { return damage_; };
|
||||
int defence() const { return defence_; };
|
||||
int hero_id() const { return hero_id_; };
|
||||
int level() const { return level_; };
|
||||
|
||||
bool has_id() const { return __flags__.test(0);};
|
||||
bool has_quality() const { return __flags__.test(1);};
|
||||
|
Loading…
x
Reference in New Issue
Block a user