34#include <boost/container/small_vector.hpp>
70 template<
typename Func>
86 for (
auto seat = vehicle->Seats.begin(); seat != vehicle->Seats.end(); ++seat)
99 AddPhase(
object, phaseId, object->
GetGUID(), updateVisibility, visitor);
104 bool changed =
object->GetPhaseShift().AddPhase(phaseId, GetPhaseFlags(phaseId),
nullptr);
107 object->GetPhaseShift().PersonalGuid = personalGuid;
111 unit->OnPhaseChange();
114 AddPhase(controlled, phaseId, personalGuid, updateVisibility, visitor);
116 unit->RemoveNotOwnSingleTargetAuras(
true);
125 RemovePhase(
object, phaseId, updateVisibility, visitor);
130 bool changed =
object->GetPhaseShift().RemovePhase(phaseId).Erased;
134 unit->OnPhaseChange();
137 RemovePhase(controlled, phaseId, updateVisibility, visitor);
139 unit->RemoveNotOwnSingleTargetAuras(
true);
147 std::vector<uint32>
const* phasesInGroup =
sDB2Manager.GetPhasesForGroup(phaseGroupId);
157 bool changed =
false;
158 for (
uint32 phaseId : *phasesInGroup)
159 changed =
object->GetPhaseShift().AddPhase(phaseId, GetPhaseFlags(phaseId),
nullptr) || changed;
162 object->GetPhaseShift().PersonalGuid = personalGuid;
166 unit->OnPhaseChange();
169 AddPhaseGroup(controlled, phasesInGroup, personalGuid, updateVisibility, visitor);
171 unit->RemoveNotOwnSingleTargetAuras(
true);
179 std::vector<uint32>
const* phasesInGroup =
sDB2Manager.GetPhasesForGroup(phaseGroupId);
189 bool changed =
false;
190 for (
uint32 phaseId : *phasesInGroup)
191 changed =
object->GetPhaseShift().RemovePhase(phaseId).Erased || changed;
195 unit->OnPhaseChange();
200 unit->RemoveNotOwnSingleTargetAuras(
true);
215 bool changed =
object->GetPhaseShift().AddVisibleMapId(visibleMapId, terrainSwapInfo);
218 changed =
object->GetPhaseShift().AddUiMapPhaseId(uiMapPhaseId) || changed;
240 bool changed =
object->GetPhaseShift().RemoveVisibleMapId(visibleMapId).Erased;
243 changed =
object->GetPhaseShift().RemoveUiMapPhaseId(uiWorldMapAreaIDSwap).Erased || changed;
258 object->GetPhaseShift().Clear();
259 object->GetSuppressedPhaseShift().Clear();
270 PhaseShift& phaseShift =
object->GetPhaseShift();
271 PhaseShift& suppressedPhaseShift =
object->GetSuppressedPhaseShift();
274 object->GetPhaseShift().VisibleMapIds.clear();
275 object->GetPhaseShift().UiMapPhaseIds.clear();
276 object->GetSuppressedPhaseShift().VisibleMapIds.clear();
278 for (
auto const& visibleMapPair :
sObjectMgr->GetTerrainSwaps())
284 if (visibleMapPair.first == object->
GetMapId())
291 else if (visibleMapPair.first == object->
GetMapId())
301 PhaseShift& phaseShift =
object->GetPhaseShift();
302 PhaseShift& suppressedPhaseShift =
object->GetSuppressedPhaseShift();
306 object->GetPhaseShift().ClearPhases();
307 object->GetSuppressedPhaseShift().ClearPhases();
309 uint32 areaId =
object->GetAreaId();
313 if (std::vector<PhaseAreaInfo>
const* newAreaPhases =
sObjectMgr->GetPhasesForArea(areaEntry->
ID))
317 if (phaseArea.SubAreaExclusions.find(areaId) != phaseArea.SubAreaExclusions.end())
320 uint32 phaseId = phaseArea.PhaseInfo->Id;
321 if (
sConditionMgr->IsObjectMeetToConditions(srcInfo, phaseArea.Conditions))
322 phaseShift.
AddPhase(phaseId, GetPhaseFlags(phaseId), &phaseArea.Conditions);
324 suppressedPhaseShift.
AddPhase(phaseId, GetPhaseFlags(phaseId), &phaseArea.Conditions);
331 bool changed = phaseShift.
Phases != oldPhases;
337 changed = phaseShift.
AddPhase(phaseId, GetPhaseFlags(phaseId),
nullptr) || changed;
341 if (std::vector<uint32>
const* phasesInGroup =
sDB2Manager.GetPhasesForGroup(
uint32(aurEff->GetMiscValueB())))
342 for (
uint32 phaseId : *phasesInGroup)
343 changed = phaseShift.
AddPhase(phaseId, GetPhaseFlags(phaseId),
nullptr) || changed;
349 unit->OnPhaseChange();
358 unit->RemoveNotOwnSingleTargetAuras(
true);
371 PhaseShift& phaseShift =
object->GetPhaseShift();
372 PhaseShift& suppressedPhaseShift =
object->GetSuppressedPhaseShift();
375 bool changed =
false;
379 if (itr->AreaConditions && !
sConditionMgr->IsObjectMeetToConditions(srcInfo, *itr->AreaConditions))
381 newSuppressions.
AddPhase(itr->Id, itr->Flags, itr->AreaConditions, itr->References);
393 changed = phaseShift.
AddPhase(itr->Id, itr->Flags, itr->AreaConditions, itr->References) || changed;
405 newSuppressions.
AddVisibleMapId(itr->first, itr->second.VisibleMapInfo, itr->second.References);
406 for (
uint32 uiMapPhaseId : itr->second.VisibleMapInfo->UiMapPhaseIDs)
419 changed = phaseShift.
AddVisibleMapId(itr->first, itr->second.VisibleMapInfo, itr->second.References) || changed;
420 for (
uint32 uiMapPhaseId : itr->second.VisibleMapInfo->UiMapPhaseIDs)
435 auto eraseResult = newSuppressions.
RemovePhase(phaseId);
437 if (eraseResult.Iterator != newSuppressions.
Phases.
end() || eraseResult.Erased)
438 phaseShift.
AddPhase(phaseId, GetPhaseFlags(phaseId),
nullptr);
443 if (std::vector<uint32>
const* phasesInGroup =
sDB2Manager.GetPhasesForGroup(
uint32(aurEff->GetMiscValueB())))
445 for (
uint32 phaseId : *phasesInGroup)
447 auto eraseResult = newSuppressions.
RemovePhase(phaseId);
449 if (eraseResult.Iterator != newSuppressions.
Phases.
end() || eraseResult.Erased)
450 phaseShift.
AddPhase(phaseId, GetPhaseFlags(phaseId),
nullptr);
463 for (std::pair<uint32 const, PhaseShift::VisibleMapIdRef>
const& visibleMap : newSuppressions.
VisibleMapIds)
464 suppressedPhaseShift.
AddVisibleMapId(visibleMap.first, visibleMap.second.VisibleMapInfo, visibleMap.second.References);
494 phaseShiftChange.VisibleMapIDs.reserve(phaseShift.VisibleMapIds.size());
495 std::transform(phaseShift.VisibleMapIds.begin(), phaseShift.VisibleMapIds.end(), std::back_inserter(phaseShiftChange.VisibleMapIDs),
496 [](PhaseShift::VisibleMapIdContainer::value_type
const& visibleMapId) { return visibleMapId.first; });
497 phaseShiftChange.UiMapPhaseIDs.reserve(phaseShift.UiMapPhaseIds.size());
498 std::transform(phaseShift.UiMapPhaseIds.begin(), phaseShift.UiMapPhaseIds.end(), std::back_inserter(phaseShiftChange.UiMapPhaseIDs),
499 [](PhaseShift::UiMapPhaseIdContainer::value_type
const& uiWorldMapAreaIdSwap) { return uiWorldMapAreaIdSwap.first; });
501 player->SendDirectMessage(phaseShiftChange.Write());
540 phaseShift.
AddPhase(phaseId, GetPhaseFlags(phaseId),
nullptr);
541 else if (phaseGroupId)
542 if (std::vector<uint32>
const* phasesInGroup =
sDB2Manager.GetPhasesForGroup(phaseGroupId))
543 for (
uint32 phaseInGroup : *phasesInGroup)
544 phaseShift.
AddPhase(phaseInGroup, GetPhaseFlags(phaseInGroup),
nullptr);
567 if (visibleMapId != -1)
575 return object->GetPhaseShift().CanSee(phaseShift);
590 for (std::pair<uint32 const, PhaseShift::VisibleMapIdRef>
const& visibleMap : phaseShift.
VisibleMapIds)
592 return visibleMap.first;
614 object->GetPhaseShift().UpdateUnphasedFlag();
623 std::string phaseOwnerName =
"N/A";
626 phaseOwnerName = personalGuid->GetName();
633 std::ostringstream phases;
639 phases <<
' ' <<
' ' <<
' ';
640 phases << phase.
Id <<
' ' <<
'(' <<
sObjectMgr->GetPhaseName(phase.
Id) <<
')';
642 phases <<
' ' <<
'(' << cosmetic <<
')';
644 phases <<
' ' <<
'(' << personal <<
')';
652 std::ostringstream visibleMapIds;
653 for (PhaseShift::VisibleMapIdContainer::value_type
const& visibleMapId : phaseShift.
VisibleMapIds)
654 visibleMapIds << visibleMapId.first <<
',' <<
' ';
661 std::ostringstream uiWorldMapAreaIdSwaps;
662 for (PhaseShift::UiMapPhaseIdContainer::value_type
const& uiWorldMapAreaIdSwap : phaseShift.
UiMapPhaseIds)
663 uiWorldMapAreaIdSwaps << uiWorldMapAreaIdSwap.first <<
',' <<
' ';
671 std::ostringstream phases;
673 phases << phase.
Id <<
',';
693 if (updateVisibility)
696 player->GetMap()->SendUpdateTransportVisibility(player);
698 object->UpdateObjectVisibility();
@ CONDITION_SOURCE_TYPE_TERRAIN_SWAP
DB2Storage< PhaseEntry > sPhaseStore("Phase.db2", &PhaseLoadInfo::Instance)
DB2Storage< AreaTableEntry > sAreaTableStore("AreaTable.db2", &AreaTableLoadInfo::Instance)
@ PHASE_USE_FLAGS_ALWAYS_VISIBLE
@ PHASE_USE_FLAGS_INVERSE
#define ASSERT_NOTNULL(pointer)
#define MAX_NUMBER_OF_GRIDS
@ LANG_PHASE_FLAG_PERSONAL
@ LANG_PHASESHIFT_UI_WORLD_MAP_AREA_SWAPS
@ LANG_PHASESHIFT_VISIBLE_MAP_IDS
@ LANG_PHASE_FLAG_COSMETIC
virtual LocaleConstant GetSessionDbLocaleIndex() const
void PSendSysMessage(const char *fmt, Args &&... args)
constexpr bool HasFlag(T flag) const
constexpr std::underlying_type_t< T > AsUnderlyingType() const
std::string ToString() const
static Unit * ToUnit(Object *o)
static ObjectGuid GetGUID(Object const *o)
static Player * ToPlayer(Object *o)
EnumFlag< PhaseShiftFlags > Flags
bool HasPhase(uint32 phaseId) const
void ModifyPhasesReferences(PhaseContainer::iterator itr, int32 references)
bool HasPersonalPhase() const
EraseResult< PhaseContainer > RemovePhase(uint32 phaseId)
UiMapPhaseIdContainer UiMapPhaseIds
bool AddVisibleMapId(uint32 visibleMapId, TerrainSwapInfo const *visibleMapInfo, int32 references=1)
EraseResult< UiMapPhaseIdContainer > RemoveUiMapPhaseId(uint32 uiMapPhaseId)
bool AddUiMapPhaseId(uint32 uiMapPhaseId, int32 references=1)
bool AddPhase(uint32 phaseId, PhaseFlags flags, std::vector< Condition > const *areaConditions, int32 references=1)
VisibleMapIdContainer VisibleMapIds
void VisitControlledOf(Unit *unit, Func &&func)
ControlledUnitVisitor(WorldObject *owner)
Trinity::Containers::FlatSet< WorldObject *, std::less< WorldObject * >, boost::container::small_vector< WorldObject *, 8 > > _visited
static void SetInversed(WorldObject *object, bool apply, bool updateVisibility)
static void OnAreaChange(WorldObject *object)
static void UpdateVisibilityIfNeeded(WorldObject *object, bool updateVisibility, bool changed)
static void PrintToChat(ChatHandler *chat, WorldObject const *target)
static void AddVisibleMapId(WorldObject *object, uint32 visibleMapId)
static uint32 GetTerrainMapId(PhaseShift const &phaseShift, uint32 mapId, TerrainInfo const *terrain, float x, float y)
static bool IsPersonalPhase(uint32 phaseId)
static void AddPhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
static std::string FormatPhases(PhaseShift const &phaseShift)
static void AddPhaseGroup(WorldObject *object, uint32 phaseGroupId, bool updateVisibility)
static void RemoveVisibleMapId(WorldObject *object, uint32 visibleMapId)
static void FillPartyMemberPhase(WorldPackets::Party::PartyMemberPhaseStates *partyMemberPhases, PhaseShift const &phaseShift)
static void RemovePhaseGroup(WorldObject *object, uint32 phaseGroupId, bool updateVisibility)
static bool InDbPhaseShift(WorldObject const *object, uint8 phaseUseFlags, uint16 phaseId, uint32 phaseGroupId)
static void InheritPhaseShift(WorldObject *target, WorldObject const *source)
static PhaseShift const & GetAlwaysVisiblePhaseShift()
static void ResetPhaseShift(WorldObject *object)
static void RemovePhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
static void OnMapChange(WorldObject *object)
static void SendToPlayer(Player const *player, PhaseShift const &phaseShift)
static void InitDbPersonalOwnership(PhaseShift &phaseShift, ObjectGuid const &personalGuid)
static bool OnConditionChange(WorldObject *object, bool updateVisibility=true)
static PhaseShift const & GetEmptyPhaseShift()
static void InitDbVisibleMapId(PhaseShift &phaseShift, int32 visibleMapId)
static void SetAlwaysVisible(WorldObject *object, bool apply, bool updateVisibility)
static void InitDbPhaseShift(PhaseShift &phaseShift, uint8 phaseUseFlags, uint16 phaseId, uint32 phaseGroupId)
bool HasChildTerrainGridFile(uint32 mapId, int32 gx, int32 gy) const
std::pair< iterator, bool > insert(Key const &key)
std::size_t erase(Key const &key)
Vehicle * GetVehicle() const
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
virtual void OnPhaseChange()
std::array< ObjectGuid, MAX_SUMMON_SLOT > m_SummonSlot
Vehicle * GetVehicleKit() const
void RemoveNotOwnSingleTargetAuras(bool onPhaseChange=false)
constexpr uint32 GetMapId() const
PhaseShift & GetPhaseShift()
PhaseShift & GetSuppressedPhaseShift()
PhaseShiftData Phaseshift
TC_GAME_API WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
GridCoord ComputeGridCoord(float x, float y)
std::vector< Condition > const * AreaConditions
EnumFlag< PhaseFlags > Flags
std::vector< uint32 > UiMapPhaseIDs
std::vector< PhaseShiftDataPhase > Phases
std::vector< PartyMemberPhase > List