This commit is contained in:
aozhiwei 2022-10-03 09:56:36 +08:00
parent 7cf4a4f324
commit 03e289906e
2 changed files with 15 additions and 3 deletions

View File

@ -371,7 +371,12 @@ void Trigger::RemoveBuffs(int cond, std::vector<int>& buffids)
}
}
void Trigger::AddListener(int event_id, std::function<void(const a8::XParams&)> cb)
std::weak_ptr<EventHandler> Trigger::AddListener(int event_id, std::function<void(const a8::XParams&)> cb)
{
}
void Trigger::RemoveEventHandler(std::weak_ptr<EventHandler> handler)
{
}

View File

@ -6,6 +6,12 @@ namespace MetaData
struct Equip;
};
struct EventHandler
{
std::function<void(const a8::XParams&)> cb;
list_head entry;
};
class Weapon;
class Creature;
class Skill;
@ -28,7 +34,8 @@ public:
void Die();
void ActiveBuff(MetaData::Buff* buff_meta);
void DeactiveBuff(MetaData::Buff* buff_meta);
void AddListener(int event_id, std::function<void(const a8::XParams&)> cb);
std::weak_ptr<EventHandler> AddListener(int event_id, std::function<void(const a8::XParams&)> cb);
void RemoveEventHandler(std::weak_ptr<EventHandler> handler);
private:
void TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> func);
@ -41,5 +48,5 @@ public:
private:
Creature* owner_ = nullptr;
int kill_num_ = 0;
std::map<int, std::function<void(const a8::XParams&)>> listeners_hash_;
std::map<int, list_head> listeners_hash_;
};