mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Battlegrounds: Move to scripts (#29799)
* Introduce new BattlegroundScript class for map/bg specific scripts * Remove all sub, zone specific, battleground classes except Arena * Move all bg zone scripts to new BattlegroundScripts class in script folder * Remove ZoneScript from Battleground class * Remove some unused hooks from Battleground
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
|
||||
#include "Map.h"
|
||||
#include "Battleground.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "BattlegroundScript.h"
|
||||
#include "CellImpl.h"
|
||||
#include "CharacterPackets.h"
|
||||
#include "Containers.h"
|
||||
@@ -3385,7 +3387,7 @@ TeamId InstanceMap::GetTeamIdInInstance() const
|
||||
/* ******* Battleground Instance Maps ******* */
|
||||
|
||||
BattlegroundMap::BattlegroundMap(uint32 id, time_t expiry, uint32 InstanceId, Difficulty spawnMode)
|
||||
: Map(id, expiry, InstanceId, spawnMode), m_bg(nullptr)
|
||||
: Map(id, expiry, InstanceId, spawnMode), m_bg(nullptr), _battlegroundScript(nullptr), _scriptId(0)
|
||||
{
|
||||
//lets initialize visibility distance for BG/Arenas
|
||||
BattlegroundMap::InitVisibilityDistance();
|
||||
@@ -3408,6 +3410,36 @@ void BattlegroundMap::InitVisibilityDistance()
|
||||
m_VisibilityNotifyPeriod = IsBattleArena() ? World::GetVisibilityNotifyPeriodInArenas() : World::GetVisibilityNotifyPeriodInBG();
|
||||
}
|
||||
|
||||
std::string const& BattlegroundMap::GetScriptName() const
|
||||
{
|
||||
return sObjectMgr->GetScriptName(_scriptId);
|
||||
}
|
||||
|
||||
void BattlegroundMap::InitScriptData()
|
||||
{
|
||||
if (_battlegroundScript)
|
||||
return;
|
||||
|
||||
ASSERT(GetBG(), "Battleground not set yet!");
|
||||
|
||||
if (BattlegroundScriptTemplate const* scriptTemplate = sBattlegroundMgr->FindBattlegroundScriptTemplate(GetId(), GetBG()->GetTypeID()))
|
||||
{
|
||||
_scriptId = scriptTemplate->ScriptId;
|
||||
_battlegroundScript.reset(sScriptMgr->CreateBattlegroundData(this));
|
||||
}
|
||||
|
||||
// Make sure every battleground has a default script
|
||||
if (!_battlegroundScript)
|
||||
{
|
||||
if (IsBattleArena())
|
||||
_battlegroundScript = std::make_unique<ArenaScript>(this);
|
||||
else
|
||||
_battlegroundScript = std::make_unique<BattlegroundScript>(this);
|
||||
}
|
||||
|
||||
_battlegroundScript->OnInit();
|
||||
}
|
||||
|
||||
TransferAbortParams BattlegroundMap::CannotEnter(Player* player)
|
||||
{
|
||||
if (player->GetMapRef().getTarget() == this)
|
||||
@@ -3451,6 +3483,12 @@ void BattlegroundMap::RemoveAllPlayers()
|
||||
player->TeleportTo(player->GetBattlegroundEntryPoint());
|
||||
}
|
||||
|
||||
void BattlegroundMap::Update(uint32 diff)
|
||||
{
|
||||
Map::Update(diff);
|
||||
_battlegroundScript->OnUpdate(diff);
|
||||
}
|
||||
|
||||
AreaTrigger* Map::GetAreaTrigger(ObjectGuid const& guid)
|
||||
{
|
||||
return _objectsStore.Find<AreaTrigger>(guid);
|
||||
|
||||
Reference in New Issue
Block a user