Beispiel #1
0
        public IEnumerable <T> GetNearestObjectsByType <T>() where T : NwGameObject
        {
            int  objType = (int)NwObject.GetObjectType <T>();
            int  i;
            uint next;

            for (i = 1, next = NWScript.GetNearestObjectToLocation(objType, this, i); next != NwObject.Invalid; i++, next = NWScript.GetNearestObjectToLocation(objType, this, i))
            {
                T?obj = next.ToNwObjectSafe <T>();
                if (obj != null)
                {
                    yield return(obj);
                }
            }
        }
Beispiel #2
0
        public IEnumerable <T> GetObjectsInShapeByType <T>(Shape shape, float size, bool losCheck, Vector3 origin = default) where T : NwGameObject
        {
            int typeFilter = (int)NwObject.GetObjectType <T>();
            int nShape     = (int)shape;

            for (uint obj = NWScript.GetFirstObjectInShape(nShape, size, this, losCheck.ToInt(), typeFilter, origin);
                 obj != NWScript.OBJECT_INVALID;
                 obj = NWScript.GetNextObjectInShape(nShape, size, this, losCheck.ToInt(), typeFilter, origin))
            {
                T?gameObject = obj.ToNwObject <T>();
                if (gameObject != null)
                {
                    yield return(gameObject);
                }
            }
        }