mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-10 06:24:38 +02:00
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:
parent
4ed8f3e5e2
commit
1637bba167
4 changed files with 196 additions and 26 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue