add msg handling (#1737)

This commit is contained in:
David Markowitz
2025-01-19 22:42:15 -08:00
committed by GitHub
parent 1b3cdc6d9c
commit e4c2eecbc7
10 changed files with 163 additions and 13 deletions

View File

@@ -14,12 +14,17 @@
#include "Observable.h"
namespace GameMessages {
struct GameMsg;
struct ActivityNotify;
struct ShootingGalleryFire;
struct ChildLoaded;
struct PlayerResurrectionFinished;
};
namespace MessageType {
enum class Game : uint16_t;
}
namespace Loot {
class Info;
};
@@ -316,6 +321,10 @@ public:
// Scale will only be communicated to the client when the construction packet is sent
void SetScale(const float scale) { m_Scale = scale; };
void RegisterMsg(const MessageType::Game msgId, std::function<bool(GameMessages::GameMsg&)> handler);
bool HandleMsg(GameMessages::GameMsg& msg) const;
/**
* @brief The observable for player entity position updates.
*/
@@ -377,6 +386,8 @@ protected:
// objectID of receiver and map of notification name to script
std::map<LWOOBJID, std::map<std::string, CppScripts::Script*>> m_Subscriptions;
std::multimap<MessageType::Game, std::function<bool(GameMessages::GameMsg&)>> m_MsgHandlers;
};
/**