GameFramework.EntityManager.GetNearest C# (CSharp) Method

GetNearest() public method

public GetNearest ( ScriptRuntime pos, float &minPowDist ) : EntityInfo
pos ScriptRuntime
minPowDist float
return EntityInfo
        public EntityInfo GetNearest(ScriptRuntime.Vector3 pos, ref float minPowDist)
        {
            EntityInfo result = null;
            float powDist = 0.0f;
            for (LinkedListNode<EntityInfo> linkNode = m_Entities.FirstValue; null != linkNode; linkNode = linkNode.Next) {
                EntityInfo entity = linkNode.Value;
                if (null != entity && entity.IsCombatNpc()) {
                    powDist = Geometry.DistanceSquare(pos, entity.GetMovementStateInfo().GetPosition3D());
                    if (minPowDist > powDist) {
                        result = entity;
                        minPowDist = powDist;
                    }
                }
            }
            return result;
        }

Usage Example

Exemplo n.º 1
0
 static public int GetNearest(IntPtr l)
 {
     try {
         GameFramework.EntityManager self = (GameFramework.EntityManager)checkSelf(l);
         ScriptRuntime.Vector3       a1;
         checkValueType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         var ret = self.GetNearest(a1, ref a2);
         pushValue(l, true);
         pushValue(l, ret);
         pushValue(l, a2);
         return(3);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }