feat: add WoW event system for Lua addons

Implement the WoW-compatible event system that lets addons react to
gameplay events in real-time:

- RegisterEvent(eventName, handler) — register a Lua function for an event
- UnregisterEvent(eventName, handler) — remove a handler
- fireEvent() dispatches events to all registered handlers with args

Currently fired events:
- PLAYER_ENTERING_WORLD — after addons load and world entry completes
- PLAYER_LEAVING_WORLD — before logout/disconnect

Events are stored in a __WoweeEvents Lua table, dispatched via
LuaEngine::fireEvent() which is called from AddonManager::fireEvent().
Error handling logs Lua errors without crashing.

Updated HelloWorld addon to use RegisterEvent for world entry/exit.
This commit is contained in:
Kelsi 2026-03-20 11:23:38 -07:00
parent 7da1f6f5ca
commit 510f03fa32
6 changed files with 148 additions and 14 deletions

View file

@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <vector>
struct lua_State;
@ -24,6 +25,11 @@ public:
void setGameHandler(game::GameHandler* handler);
// Fire a WoW event to all registered Lua handlers.
// Extra string args are pushed as event arguments.
void fireEvent(const std::string& eventName,
const std::vector<std::string>& args = {});
lua_State* getState() { return L_; }
bool isInitialized() const { return L_ != nullptr; }
@ -32,6 +38,7 @@ private:
game::GameHandler* gameHandler_ = nullptr;
void registerCoreAPI();
void registerEventAPI();
};
} // namespace wowee::addons