4 static float WrapAngleDiff(
float angle)
6 while (angle < -Math.PI)
8 while (angle > Math.PI)
14 static float WrapAngle(
float angle)
18 while (angle > Math.PI2)
24 static float DirToAngle(vector dir)
26 float a = Math.Atan2(dir[0], dir[2]);
31 class SCR_AITargetInfoPolar : Managed
43 ref array<SCR_AITargetInfo> m_aTargets = {};
44 ref array<float> m_aAngles = {};
45 ref array<float> m_aDistances = {};
46 ref array<IEntity> m_aEntities = {};
54 void AddTarget(SCR_AITargetInfo target,
float angle,
float dist)
56 m_aTargets.Insert(target);
57 m_aAngles.Insert(angle);
58 m_aDistances.Insert(dist);
59 m_aEntities.Insert(target.m_Entity);
68 foreach (
float angle : other.m_aAngles)
69 m_aAngles.Insert(angle);
70 foreach (
float distance : other.m_aDistances)
72 foreach (SCR_AITargetInfo target : other.m_aTargets)
73 m_aTargets.Insert(target);
74 foreach (IEntity entity : other.m_aEntities)
75 m_aEntities.Insert(entity);
78 float span0 =
SCR_AIPolar.WrapAngleDiff(other.m_fAngleMax - m_fAngleMin);
79 float span1 =
SCR_AIPolar.WrapAngleDiff(other.m_fAngleMin - m_fAngleMax);
83 m_fAngleMax = other.m_fAngleMax;
85 m_fAngleMin = other.m_fAngleMin;
86 else if (Math.AbsFloat(span0) > Math.AbsFloat(span1))
87 m_fAngleMax = other.m_fAngleMax;
89 m_fAngleMin = other.m_fAngleMin;
104 float GetMinDistance()
106 if (m_aDistances.IsEmpty())
109 float minDist =
float.MAX;
110 foreach (
float dist : m_aDistances)