Core/AreaTriggers: Implement AreaTriggerActionSetFlag::DontRunOnLeaveWhenExpiring
Port From (https://github.com/TrinityCore/TrinityCore/commit/1085b3f43321e58f151c1543a70b3558c26ed8e5)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Framework.Constants;
|
||||
using Game.Entities;
|
||||
using Game.Spells;
|
||||
|
||||
@@ -34,7 +35,7 @@ namespace Game.AI
|
||||
public virtual void OnUnitEnter(Unit unit) { }
|
||||
|
||||
// Called when an unit exit the AreaTrigger, or when the AreaTrigger is removed
|
||||
public virtual void OnUnitExit(Unit unit) { }
|
||||
public virtual void OnUnitExit(Unit unit, AreaTriggerExitReason reason) { }
|
||||
|
||||
// Called when the AreaTrigger is removed
|
||||
public virtual void OnRemove() { }
|
||||
|
||||
@@ -1200,7 +1200,7 @@ namespace Game.AI
|
||||
GetScript().ProcessEventsFor(SmartEvents.AreatriggerEnter, unit);
|
||||
}
|
||||
|
||||
public override void OnUnitExit(Unit unit)
|
||||
public override void OnUnitExit(Unit unit, AreaTriggerExitReason reason)
|
||||
{
|
||||
GetScript().ProcessEventsFor(SmartEvents.AreatriggerExit, unit);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Game.Entities
|
||||
_ai.OnRemove();
|
||||
|
||||
// Handle removal of all units, calling OnUnitExit & deleting auras if needed
|
||||
HandleUnitEnterExit(new List<Unit>());
|
||||
HandleUnitEnterExit(new List<Unit>(), AreaTriggerExitReason.ByExpire);
|
||||
|
||||
base.RemoveFromWorld();
|
||||
if (IsStaticSpawn())
|
||||
@@ -809,7 +809,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
void HandleUnitEnterExit(List<Unit> newTargetList)
|
||||
void HandleUnitEnterExit(List<Unit> newTargetList, AreaTriggerExitReason exitMode = AreaTriggerExitReason.NotInside)
|
||||
{
|
||||
List<ObjectGuid> exitUnits = _insideUnits;
|
||||
_insideUnits.Clear();
|
||||
@@ -832,7 +832,7 @@ namespace Game.Entities
|
||||
{
|
||||
Unit leavingUnit = Global.ObjAccessor.GetUnit(this, exitUnitGuid);
|
||||
if (leavingUnit != null)
|
||||
HandleUnitExitInternal(leavingUnit);
|
||||
HandleUnitExitInternal(leavingUnit, exitMode);
|
||||
}
|
||||
|
||||
UpdateHasPlayersFlag();
|
||||
@@ -861,23 +861,30 @@ namespace Game.Entities
|
||||
unit.EnterAreaTrigger(this);
|
||||
}
|
||||
|
||||
void HandleUnitExitInternal(Unit unit)
|
||||
void HandleUnitExitInternal(Unit unit, AreaTriggerExitReason exitMode = AreaTriggerExitReason.NotInside)
|
||||
{
|
||||
bool canTriggerOnExit = exitMode != AreaTriggerExitReason.ByExpire || !HasActionSetFlag(AreaTriggerActionSetFlag.DontRunOnLeaveWhenExpiring);
|
||||
|
||||
Player player = unit.ToPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
if (player.IsDebugAreaTriggers)
|
||||
player.SendSysMessage(CypherStrings.DebugAreatriggerEntityLeft, GetEntry(), IsCustom(), IsStaticSpawn(), _spawnId);
|
||||
|
||||
player.UpdateQuestObjectiveProgress(QuestObjectiveType.AreaTriggerExit, (int)GetEntry(), 1);
|
||||
if (canTriggerOnExit)
|
||||
{
|
||||
player.UpdateQuestObjectiveProgress(QuestObjectiveType.AreaTriggerExit, (int)GetEntry(), 1);
|
||||
|
||||
if (GetTemplate().ActionSetId != 0)
|
||||
player.UpdateCriteria(CriteriaType.LeaveAreaTriggerWithActionSet, GetTemplate().ActionSetId);
|
||||
if (GetTemplate().ActionSetId != 0)
|
||||
player.UpdateCriteria(CriteriaType.LeaveAreaTriggerWithActionSet, GetTemplate().ActionSetId);
|
||||
}
|
||||
}
|
||||
|
||||
UndoActions(unit);
|
||||
|
||||
_ai.OnUnitExit(unit);
|
||||
if (canTriggerOnExit)
|
||||
_ai.OnUnitExit(unit, exitMode);
|
||||
|
||||
unit.ExitAreaTrigger(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user