Core/Battlegrounds: Replace manual criteria timer starts in battlegrounds with new GameEvents api

Port From (https://github.com/TrinityCore/TrinityCore/commit/111fc6ac6fd703bb645046e7a477a986d8519a64)
This commit is contained in:
hondacrx
2022-05-31 19:51:16 -04:00
parent 623c3198c0
commit adfca19d4c
6 changed files with 32 additions and 20 deletions
+24 -13
View File
@@ -38,23 +38,34 @@ namespace Game
zoneScript.ProcessEvent(target, gameEventId, source);
Map map = refForMapAndZoneScript.GetMap();
if (target)
GameObject goTarget = target?.ToGameObject();
if (goTarget != null)
{
GameObject goTarget = target.ToGameObject();
if (goTarget != null)
{
GameObjectAI goAI = goTarget.GetAI();
if (goAI != null)
goAI.EventInform(gameEventId);
}
BattlegroundMap bgMap = map.ToBattlegroundMap();
if (bgMap != null)
bgMap.GetBG().ProcessEvent(target, gameEventId, source);
GameObjectAI goAI = goTarget.GetAI();
if (goAI != null)
goAI.EventInform(gameEventId);
}
map.ScriptsStart(ScriptsType.Event, gameEventId, source, target);
Player sourcePlayer = source?.ToPlayer();
if (sourcePlayer != null)
TriggerForPlayer(gameEventId, sourcePlayer);
TriggerForMap(gameEventId, map, source, target);
}
public static void TriggerForPlayer(uint gameEventId, Player source)
{
Map map = source.GetMap();
if (map.Instanceable())
source.StartCriteriaTimer(CriteriaStartEvent.SendEvent, gameEventId);
}
public static void TriggerForMap(uint gameEventId, Map map, WorldObject source = null, WorldObject target = null)
{
BattlegroundMap bgMap = map.ToBattlegroundMap();
if (bgMap != null)
bgMap.GetBG().ProcessEvent(target, gameEventId, source);
map.ScriptsStart(ScriptsType.Event, gameEventId, source, target);
}
}
}