mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-30 05:43:12 +01:00
Game/Scripting: Add OnGameEvent hook for game objects.
Called when specific game event starts
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "UnitAI.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
GameEventMgr* GameEventMgr::instance()
|
||||
{
|
||||
@@ -1642,8 +1643,13 @@ class GameEventAIHookWorker
|
||||
void Visit(std::unordered_map<ObjectGuid, GameObject*>& gameObjectMap)
|
||||
{
|
||||
for (auto const& p : gameObjectMap)
|
||||
{
|
||||
if (p.second->IsInWorld())
|
||||
{
|
||||
p.second->AI()->OnGameEvent(_activate, _eventId);
|
||||
sScriptMgr->OnGameEvent(_activate, _eventId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -1510,6 +1510,11 @@ InstanceScript* ScriptMgr::CreateInstanceData(InstanceMap* map)
|
||||
return tmpscript->GetInstanceScript(map);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGameEvent(bool start, uint16 eventId)
|
||||
{
|
||||
FOREACH_SCRIPT(GameObjectScript)->OnGameEvent(start, eventId);
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Item* target)
|
||||
{
|
||||
ASSERT(caster);
|
||||
|
||||
@@ -483,6 +483,9 @@ class TC_GAME_API GameObjectScript : public ScriptObject, public UpdatableScript
|
||||
|
||||
// Called when a GameObjectAI object is needed for the gameobject.
|
||||
virtual GameObjectAI* GetAI(GameObject* /*go*/) const { return NULL; }
|
||||
|
||||
// Called when specific game event starts.
|
||||
virtual void OnGameEvent(bool /*start*/, uint16 /*eventId*/) { }
|
||||
};
|
||||
|
||||
class TC_GAME_API AreaTriggerScript : public ScriptObject
|
||||
@@ -983,6 +986,7 @@ class TC_GAME_API ScriptMgr
|
||||
void OnGameObjectStateChanged(GameObject* go, uint32 state);
|
||||
void OnGameObjectUpdate(GameObject* go, uint32 diff);
|
||||
GameObjectAI* GetGameObjectAI(GameObject* go);
|
||||
void OnGameEvent(bool start, uint16 eventId);
|
||||
|
||||
public: /* AreaTriggerScript */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user