mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-06 18:54:13 +00:00
add msg handling (#1737)
This commit is contained in:
@@ -2216,3 +2216,17 @@ int32_t Entity::GetCollisionGroup() const {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Entity::HandleMsg(GameMessages::GameMsg& msg) const {
|
||||
bool handled = false;
|
||||
const auto [beg, end] = m_MsgHandlers.equal_range(msg.msgId);
|
||||
for (auto it = beg; it != end; ++it) {
|
||||
if (it->second) handled |= it->second(msg);
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
void Entity::RegisterMsg(const MessageType::Game msgId, std::function<bool(GameMessages::GameMsg&)> handler) {
|
||||
m_MsgHandlers.emplace(msgId, handler);
|
||||
}
|
||||
|
Reference in New Issue
Block a user