Core/Misc: Misc fixes

This commit is contained in:
hondacrx
2018-03-21 23:43:28 -04:00
parent 9b2c85950b
commit caa3cfed24
4 changed files with 20 additions and 13 deletions
+14
View File
@@ -265,10 +265,14 @@ namespace Game.Entities
if (obj == this)
return true;
// move arc to range 0.. 2*pi
arc = NormalizeOrientation(arc);
float angle = GetAngle(obj);
angle -= GetOrientation();
// move angle to range -pi ... +pi
angle = NormalizeOrientation(angle);
if (angle > MathFunctions.PI)
angle -= 2.0f * MathFunctions.PI;
@@ -276,6 +280,16 @@ namespace Game.Entities
float rborder = (arc / border); // in range 0..pi
return ((angle >= lborder) && (angle <= rborder));
}
public bool HasInLine(Position pos, float width)
{
if (!HasInArc(MathFunctions.PI, pos))
return false;
float angle = GetRelativeAngle(pos);
return Math.Abs(Math.Sin(angle)) * GetExactDist2d(pos.GetPositionX(), pos.GetPositionY()) < width;
}
public void GetSinCos(float x, float y, out float vsin, out float vcos)
{
float dx = GetPositionX() - x;
@@ -2568,14 +2568,6 @@ namespace Game.Entities
public virtual bool LoadFromDB(ulong guid, Map map) { return true; }
//Position
public bool HasInLine(WorldObject target, float width)
{
if (!HasInArc(MathFunctions.PI, target))
return false;
width += target.GetObjectSize();
float angle = GetRelativeAngle(target);
return Math.Abs(Math.Sin(angle)) * GetExactDist2d(target.GetPositionX(), target.GetPositionY()) < width;
}
public float GetDistanceZ(WorldObject obj)
{