added target finding within box (thanks kjLotus!)

- added function to return position as Vector3 to Actor (todo: maybe we should just use the class instead of 3 separate floats?)
- added function to return all actors in Area
- actually added documentation to TargetFind stuff (kill me pls)
- todo: actually test this..
This commit is contained in:
Tahir Akhlaq 2017-07-10 02:31:37 +01:00
parent 4ed8f3e5e2
commit 1637bba167
4 changed files with 196 additions and 26 deletions

View file

@ -70,5 +70,41 @@ namespace FFXIVClassic.Common
{
return (lhs.X * rhs.X) + (lhs.Y * rhs.Y) + (lhs.Z * rhs.Z);
}
public static float GetAngle(Vector3 lhs, Vector3 rhs)
{
var angle = (float)Math.Atan((rhs.Z - lhs.Z) / (rhs.X - lhs.X));
return lhs.X > rhs.X ? angle + (float)Math.PI : angle;
}
public Vector3 NewHorizontalVector(float angle, float extents)
{
var newVec = new Vector3();
newVec.Y = this.Y;
newVec.X = this.X + (float)Math.Cos(angle) * extents;
newVec.Z = this.Z + (float)Math.Sin(angle) * extents;
return newVec;
}
public bool IsWithinCircle(Vector3 centre, float radius)
{
float diffX = centre.X - this.X;
float diffZ = centre.Z - this.Z;
float distance = (float)Math.Sqrt((diffX * diffX) + (diffZ * diffZ));
return distance < radius;
}
public bool IsWithinBox(Vector3 upperLeftCorner, Vector3 lowerRightCorner)
{
return upperLeftCorner.X <= this.X &&
upperLeftCorner.Y <= this.Y &&
upperLeftCorner.Z <= this.Z &&
lowerRightCorner.X >= this.X &&
lowerRightCorner.Y >= this.Y &&
lowerRightCorner.Z >= this.Z;
}
}
}