Core/Objects: Refactor private object checks into separate function

Port From (https://github.com/TrinityCore/TrinityCore/commit/f21270b987211041b95d6befa7192d313692920d)
This commit is contained in:
hondacrx
2021-03-29 17:20:45 -04:00
parent b4bf10ed22
commit 1ca5b5bcad
3 changed files with 22 additions and 6 deletions
+19 -3
View File
@@ -1100,20 +1100,36 @@ namespace Game.Entities
return 0.0f;
}
public bool CheckPrivateObjectOwnerVisibility(WorldObject seer)
{
if (!IsPrivateObject())
return true;
// Owner of this private object
if (_privateObjectOwner == seer.GetGUID())
return true;
// Another private object of the same owner
if (_privateObjectOwner == seer.GetPrivateObjectOwner())
return true;
return false;
}
public bool CanSeeOrDetect(WorldObject obj, bool ignoreStealth = false, bool distanceCheck = false, bool checkAlert = false)
{
if (this == obj)
return true;
if (!obj.GetPrivateObjectOwner().IsEmpty())
return GetGUID() == obj.GetPrivateObjectOwner() || GetPrivateObjectOwner() == obj.GetPrivateObjectOwner();
if (obj.IsNeverVisibleFor(this) || CanNeverSee(obj))
return false;
if (obj.IsAlwaysVisibleFor(this) || CanAlwaysSee(obj))
return true;
if (!obj.CheckPrivateObjectOwnerVisibility(this))
return false;
bool corpseVisibility = false;
if (distanceCheck)
{