Core/Refactor: Part 4

This commit is contained in:
hondacrx
2018-05-27 15:40:06 -04:00
parent d94ad385b1
commit 2c3479c6e2
59 changed files with 159 additions and 223 deletions
+8 -10
View File
@@ -2731,9 +2731,8 @@ namespace Game.Entities
public void MovePosition(ref Position pos, float dist, float angle)
{
angle += GetOrientation();
float destx, desty, destz, ground, floor;
destx = pos.posX + dist * (float)Math.Cos(angle);
desty = pos.posY + dist * (float)Math.Sin(angle);
float destx = pos.posX + dist * (float)Math.Cos(angle);
float desty = pos.posY + dist * (float)Math.Sin(angle);
// Prevent invalid coordinates here, position is unchanged
if (!GridDefines.IsValidMapCoord(destx, desty, pos.posZ))
@@ -2742,9 +2741,9 @@ namespace Game.Entities
return;
}
ground = GetMap().GetHeight(GetPhaseShift(), destx, desty, MapConst.MaxHeight, true);
floor = GetMap().GetHeight(GetPhaseShift(), destx, desty, pos.posZ, true);
destz = Math.Abs(ground - pos.posZ) <= Math.Abs(floor - pos.posZ) ? ground : floor;
float ground = GetMap().GetHeight(GetPhaseShift(), destx, desty, MapConst.MaxHeight, true);
float floor = GetMap().GetHeight(GetPhaseShift(), destx, desty, pos.posZ, true);
float destz = Math.Abs(ground - pos.posZ) <= Math.Abs(floor - pos.posZ) ? ground : floor;
float step = dist / 10.0f;
@@ -2802,9 +2801,8 @@ namespace Game.Entities
public void MovePositionToFirstCollision(ref Position pos, float dist, float angle)
{
angle += GetOrientation();
float destx, desty, destz;
destx = pos.posX + dist * (float)Math.Cos(angle);
desty = pos.posY + dist * (float)Math.Sin(angle);
float destx = pos.posX + dist * (float)Math.Cos(angle);
float desty = pos.posY + dist * (float)Math.Sin(angle);
// Prevent invalid coordinates here, position is unchanged
if (!GridDefines.IsValidMapCoord(destx, desty))
@@ -2813,7 +2811,7 @@ namespace Game.Entities
return;
}
destz = NormalizeZforCollision(this, destx, desty, pos.GetPositionZ());
float destz = NormalizeZforCollision(this, destx, desty, pos.GetPositionZ());
bool col = Global.VMapMgr.getObjectHitPos(PhasingHandler.GetTerrainMapId(GetPhaseShift(), GetMap(), pos.posX, pos.posY), pos.posX, pos.posY, pos.posZ + 0.5f, destx, desty, destz + 0.5f, out destx, out desty, out destz, -0.5f);
// collision occured