Exemplo n.º 1
0
        void SearchUnitInBox(List <Unit> targetList)
        {
            float extentsX, extentsY, extentsZ;

            unsafe
            {
                extentsX = GetTemplate().BoxDatas.Extents[0];
                extentsY = GetTemplate().BoxDatas.Extents[1];
                extentsZ = GetTemplate().BoxDatas.Extents[2];
            }

            var check    = new AnyUnitInObjectRangeCheck(this, GetTemplate().MaxSearchRadius, false);
            var searcher = new UnitListSearcher(this, targetList, check);

            Cell.VisitAllObjects(this, searcher, GetTemplate().MaxSearchRadius);

            float halfExtentsX = extentsX / 2.0f;
            float halfExtentsY = extentsY / 2.0f;
            float halfExtentsZ = extentsZ / 2.0f;

            float minX = GetPositionX() - halfExtentsX;
            float maxX = GetPositionX() + halfExtentsX;

            float minY = GetPositionY() - halfExtentsY;
            float maxY = GetPositionY() + halfExtentsY;

            float minZ = GetPositionZ() - halfExtentsZ;
            float maxZ = GetPositionZ() + halfExtentsZ;

            AxisAlignedBox box = new AxisAlignedBox(new Vector3(minX, minY, minZ), new Vector3(maxX, maxY, maxZ));

            targetList.RemoveAll(unit => !box.contains(new Vector3(unit.GetPositionX(), unit.GetPositionY(), unit.GetPositionZ())));
        }
Exemplo n.º 2
0
        void SearchUnitInBox(List <Unit> targetList)
        {
            float extentsX, extentsY, extentsZ;

            unsafe
            {
                extentsX = GetTemplate().BoxDatas.Extents[0];
                extentsY = GetTemplate().BoxDatas.Extents[1];
                extentsZ = GetTemplate().BoxDatas.Extents[2];
            }

            SearchUnits(targetList, GetTemplate().MaxSearchRadius, false);

            float halfExtentsX = extentsX / 2.0f;
            float halfExtentsY = extentsY / 2.0f;
            float halfExtentsZ = extentsZ / 2.0f;

            float minX = GetPositionX() - halfExtentsX;
            float maxX = GetPositionX() + halfExtentsX;

            float minY = GetPositionY() - halfExtentsY;
            float maxY = GetPositionY() + halfExtentsY;

            float minZ = GetPositionZ() - halfExtentsZ;
            float maxZ = GetPositionZ() + halfExtentsZ;

            AxisAlignedBox box = new AxisAlignedBox(new Vector3(minX, minY, minZ), new Vector3(maxX, maxY, maxZ));

            targetList.RemoveAll(unit => !box.contains(new Vector3(unit.GetPositionX(), unit.GetPositionY(), unit.GetPositionZ())));
        }