mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/Scripts: Add ZoneScript hook for AreaTrigger creation/deletion (#29236)
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "Transport.h"
|
||||
#include "Unit.h"
|
||||
#include "UpdateData.h"
|
||||
#include "ZoneScript.h"
|
||||
#include "advstd.h"
|
||||
#include <bit>
|
||||
|
||||
@@ -63,6 +64,9 @@ void AreaTrigger::AddToWorld()
|
||||
///- Register the AreaTrigger for guid lookup and for caster
|
||||
if (!IsInWorld())
|
||||
{
|
||||
if (m_zoneScript)
|
||||
m_zoneScript->OnAreaTriggerCreate(this);
|
||||
|
||||
GetMap()->GetObjectsStore().Insert<AreaTrigger>(GetGUID(), this);
|
||||
if (_spawnId)
|
||||
GetMap()->GetAreaTriggerBySpawnIdStore().insert(std::make_pair(_spawnId, this));
|
||||
@@ -76,6 +80,9 @@ void AreaTrigger::RemoveFromWorld()
|
||||
///- Remove the AreaTrigger from the accessor and from all lists of objects in world
|
||||
if (IsInWorld())
|
||||
{
|
||||
if (m_zoneScript)
|
||||
m_zoneScript->OnAreaTriggerRemove(this);
|
||||
|
||||
_isRemoved = true;
|
||||
|
||||
if (Unit* caster = GetCaster())
|
||||
@@ -114,6 +121,8 @@ bool AreaTrigger::Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Uni
|
||||
return false;
|
||||
}
|
||||
|
||||
SetZoneScript();
|
||||
|
||||
_areaTriggerTemplate = _areaTriggerCreateProperties->Template;
|
||||
|
||||
Object::_Create(ObjectGuid::Create<HighGuid::AreaTrigger>(GetMapId(), GetTemplate() ? GetTemplate()->Id.Id : 0, caster->GetMap()->GenerateLowGuid<HighGuid::AreaTrigger>()));
|
||||
@@ -254,6 +263,8 @@ bool AreaTrigger::CreateServer(Map* map, AreaTriggerTemplate const* areaTriggerT
|
||||
return false;
|
||||
}
|
||||
|
||||
SetZoneScript();
|
||||
|
||||
_areaTriggerTemplate = areaTriggerTemplate;
|
||||
|
||||
Object::_Create(ObjectGuid::Create<HighGuid::AreaTrigger>(GetMapId(), areaTriggerTemplate->Id.Id, GetMap()->GenerateLowGuid<HighGuid::AreaTrigger>()));
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "Define.h"
|
||||
#include "ObjectGuid.h"
|
||||
|
||||
class AreaTrigger;
|
||||
class Creature;
|
||||
class GameObject;
|
||||
class Player;
|
||||
@@ -49,6 +50,9 @@ class TC_GAME_API ZoneScript
|
||||
virtual void OnGameObjectCreate(GameObject* ) { }
|
||||
virtual void OnGameObjectRemove(GameObject* ) { }
|
||||
|
||||
virtual void OnAreaTriggerCreate([[maybe_unused]] AreaTrigger* areaTrigger) { }
|
||||
virtual void OnAreaTriggerRemove([[maybe_unused]] AreaTrigger* areaTrigger) { }
|
||||
|
||||
virtual void OnUnitDeath(Unit*) { }
|
||||
|
||||
//All-purpose data storage ObjectGuid
|
||||
|
||||
Reference in New Issue
Block a user