fix: Consolidates and fixes movement/direction checks (#1861)
This commit is contained in:
parent
06e05f2e52
commit
e6bfc45228
11 changed files with 146 additions and 320 deletions
|
|
@ -54,9 +54,9 @@ namespace Server.Movement
|
|||
|
||||
var checkDiagonals = ((int)d & 0x1) == 0x1;
|
||||
|
||||
Offset(d, ref xForward, ref yForward);
|
||||
Offset((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft);
|
||||
Offset((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight);
|
||||
Movement.Offset(d, ref xForward, ref yForward);
|
||||
Movement.Offset((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft);
|
||||
Movement.Offset((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight);
|
||||
|
||||
if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height)
|
||||
{
|
||||
|
|
@ -578,57 +578,5 @@ namespace Server.Movement
|
|||
zTop = loc.Z;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Offset(Direction d, ref int x, ref int y)
|
||||
{
|
||||
switch (d & Direction.Mask)
|
||||
{
|
||||
case Direction.North:
|
||||
{
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
case Direction.South:
|
||||
{
|
||||
++y;
|
||||
break;
|
||||
}
|
||||
case Direction.West:
|
||||
{
|
||||
--x;
|
||||
break;
|
||||
}
|
||||
case Direction.East:
|
||||
{
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
case Direction.Right:
|
||||
{
|
||||
++x;
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
case Direction.Left:
|
||||
{
|
||||
--x;
|
||||
++y;
|
||||
break;
|
||||
}
|
||||
case Direction.Down:
|
||||
{
|
||||
++x;
|
||||
++y;
|
||||
break;
|
||||
}
|
||||
case Direction.Up:
|
||||
{
|
||||
--x;
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,12 +42,7 @@ namespace Server
|
|||
|
||||
if (index >= 0 && index < dirs.Length)
|
||||
{
|
||||
int x = p.X, y = p.Y;
|
||||
|
||||
CalcMoves.Offset(dirs[index], ref x, ref y);
|
||||
|
||||
p.X = x;
|
||||
p.Y = y;
|
||||
CalcMoves.Offset(dirs[index], ref p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue