Core/Position: Position constructor improvements

Port From (https://github.com/TrinityCore/TrinityCore/commit/d6ae7030dac388bbdf79954bd235c98209b53630)
This commit is contained in:
Hondacrx
2024-11-17 13:51:42 -05:00
parent f23db214ae
commit c3df9bae16
2 changed files with 36 additions and 12 deletions
+31 -3
View File
@@ -16,6 +16,21 @@ namespace Game.Entities
public float posZ;
public float Orientation;
public Position() { }
public Position(float x = 0f, float y = 0f)
{
posX = x;
posY = y;
}
public Position(float x = 0f, float y = 0f, float z = 0f)
{
posX = x;
posY = y;
posZ = z;
}
public Position(float x = 0f, float y = 0f, float z = 0f, float o = 0f)
{
posX = x;
@@ -407,11 +422,24 @@ namespace Game.Entities
public Position _newPosition = new();
public WorldLocation(uint mapId = 0xFFFFFFFF, float x = 0, float y = 0, float z = 0, float o = 0)
public WorldLocation()
{
_mapId = 0xFFFFFFFF;
}
public WorldLocation(uint mapId = 0xFFFFFFFF, float x = 0, float y = 0) : base(x, y)
{
_mapId = mapId;
Relocate(x, y, z, o);
}
public WorldLocation(uint mapId = 0xFFFFFFFF, float x = 0, float y = 0, float z = 0) : base(x, y, z)
{
_mapId = mapId;
}
public WorldLocation(uint mapId = 0xFFFFFFFF, float x = 0, float y = 0, float z = 0, float o = 0) : base(x, y, z, o)
{
_mapId = mapId;
}
public WorldLocation(uint mapId, Position pos)
{
_mapId = mapId;
@@ -440,7 +468,7 @@ namespace Game.Entities
Relocate(loc);
}
public void WorldRelocate(uint mapId = 0xFFFFFFFF, float x = 0.0f, float y = 0.0f, float z = 0.0f, float o = 0.0f)
public void WorldRelocate(uint mapId, float x, float y, float z, float o)
{
_mapId = mapId;
Relocate(x, y, z, o);
+5 -9
View File
@@ -266,20 +266,16 @@ namespace Game.Garrisons
void Enter()
{
WorldLocation loc = new(_siteLevel.MapID);
loc.Relocate(_owner);
_owner.TeleportTo(loc, TeleportToOptions.Seamless);
MapRecord map = CliDB.MapStorage.LookupByKey(_siteLevel.MapID);
if (map != null && _owner.GetMapId() == map.ParentMapID)
_owner.TeleportTo(new WorldLocation(_siteLevel.MapID, _owner), TeleportToOptions.Seamless);
}
void Leave()
{
MapRecord map = CliDB.MapStorage.LookupByKey(_siteLevel.MapID);
if (map != null)
{
WorldLocation loc = new((uint)map.ParentMapID);
loc.Relocate(_owner);
_owner.TeleportTo(loc, TeleportToOptions.Seamless);
}
if (map != null && _owner.GetMapId() == _siteLevel.MapID)
_owner.TeleportTo(new WorldLocation((uint)map.ParentMapID, _owner), TeleportToOptions.Seamless);
}
public uint GetFaction()