Ejemplo n.º 1
0
        private void CollectNeighbourGrids(List <VInt2> inNeighbourGrids, List <VInt2> inSearchedGrids, VInt2 inCenterCell, int inThickness)
        {
            if (inNeighbourGrids == null)
            {
                return;
            }
            int x    = inCenterCell.x;
            int y    = inCenterCell.y;
            int num  = Mathf.Max(x - inThickness, 0);
            int num2 = Mathf.Min(x + inThickness, this.NumX - 1);
            int num3 = Mathf.Max(y - inThickness, 0);
            int num4 = Mathf.Min(y + inThickness, this.NumY - 1);

            for (int i = num; i <= num2; i++)
            {
                for (int j = num3; j <= num4; j++)
                {
                    VInt2 vInt = new VInt2(i, j);
                    if (inSearchedGrids == null || !inSearchedGrids.Contains(vInt))
                    {
                        inNeighbourGrids.Add(vInt);
                    }
                }
            }
        }
        public static bool VisitFowVisibilityCheck(VCollisionSphere sphere, PoolObjHandle <ActorRoot> inActor, COM_PLAYERCAMP inHostCamp, GameFowManager fowMgr)
        {
            VInt2 zero = VInt2.zero;

            fowMgr.WorldPosToGrid(new VInt3(sphere.WorldPos.x, sphere.WorldPos.z, 0), out zero.x, out zero.y);
            int num = 0;

            fowMgr.m_pFieldObj.UnrealToGridX(sphere.WorldRadius, out num);
            for (int i = -num; i <= num; i++)
            {
                for (int j = -num; j <= num; j++)
                {
                    VInt2 b    = new VInt2(i, j);
                    VInt2 vInt = zero + b;
                    if (fowMgr.IsInsideSurface(vInt.x, vInt.y) && b.sqrMagnitude <= num * num)
                    {
                        bool flag = Singleton <GameFowManager> .instance.IsVisible(vInt.x, vInt.y, inHostCamp);

                        if (flag)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        private void CalcNearestPoint(out VInt3 cp, ref VInt3 start, ref VInt3 end, ref VInt3 p)
        {
            VInt2 vInt             = new VInt2(end.x - start.x, end.z - start.z);
            long  sqrMagnitudeLong = vInt.sqrMagnitudeLong;
            VInt2 vInt2            = new VInt2(p.x - start.x, p.z - start.z);

            cp   = default(VInt3);
            cp.y = p.y;
            long num = VInt2.DotLong(ref vInt2, ref vInt);

            if (sqrMagnitudeLong != 0L)
            {
                long a  = (long)(end.x - start.x) * num;
                long a2 = (long)(end.z - start.z) * num;
                cp.x  = (int)IntMath.Divide(a, sqrMagnitudeLong);
                cp.z  = (int)IntMath.Divide(a2, sqrMagnitudeLong);
                cp.x += start.x;
                cp.z += start.z;
            }
            else
            {
                int num2 = (int)num;
                cp.x = start.x + (end.x - start.x) * num2;
                cp.z = start.z + (end.z - start.z) * num2;
            }
        }
Ejemplo n.º 4
0
    public static bool SegmentIntersect(VInt2 aa, VInt2 bb, VInt2 cc, VInt2 dd, ref VInt2 intersectPoint)
    {
        Vector2 vector  = (Vector2)aa;
        Vector2 vector2 = (Vector2)bb;
        Vector2 vector3 = (Vector2)cc;
        Vector2 vector4 = (Vector2)dd;
        float   num     = (vector.x - vector3.x) * (vector2.y - vector3.y) - (vector.y - vector3.y) * (vector2.x - vector3.x);
        float   num2    = (vector.x - vector4.x) * (vector2.y - vector4.y) - (vector.y - vector4.y) * (vector2.x - vector4.x);

        if (num * num2 >= 0f)
        {
            return(false);
        }
        float num3 = (vector3.x - vector.x) * (vector4.y - vector.y) - (vector3.y - vector.y) * (vector4.x - vector.x);
        float num4 = num3 + num - num2;

        if (num3 * num4 >= 0f)
        {
            return(false);
        }
        float num5 = num2 - num;

        num5 = ((num5 < 0f) ? Mathf.Min(num5, -0.0001f) : Mathf.Max(num5, 0.0001f));
        float   num6 = num3 / num5;
        float   num7 = num6 * (vector2.x - vector.x);
        float   num8 = num6 * (vector2.y - vector.y);
        Vector2 ob   = new Vector2(vector.x + num7, vector.y + num8);

        intersectPoint = (VInt2)ob;
        return(true);
    }
Ejemplo n.º 5
0
        public static bool VisitFowVisibilityCheck(VCollisionBox box, PoolObjHandle <ActorRoot> inActor, COM_PLAYERCAMP inHostCamp, GameFowManager fowMgr)
        {
            VInt2 zero = VInt2.zero;

            if (fowMgr.WorldPosToGrid(new VInt3(box.WorldPos.x, box.WorldPos.z, 0), out zero.x, out zero.y))
            {
                FieldObj pFieldObj = fowMgr.m_pFieldObj;
                int      num       = 0;
                int      num2;
                pFieldObj.UnrealToGridX(box.WorldExtends.x, out num2);
                pFieldObj.UnrealToGridX(box.WorldExtends.z, out num);
                int num3 = zero.x - num2;
                num3 = Math.Max(0, num3);
                int num4 = zero.x + num2;
                num4 = Math.Min(num4, pFieldObj.NumX - 1);
                int num5 = zero.y - num;
                num5 = Math.Max(0, num5);
                int num6 = zero.y + num;
                num6 = Math.Min(num6, pFieldObj.NumY - 1);
                for (int i = num3; i <= num4; i++)
                {
                    for (int j = num5; j <= num6; j++)
                    {
                        bool flag = Singleton <GameFowManager> .get_instance().IsVisible(i, j, inHostCamp);

                        if (flag)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 6
0
        public bool FindNearestNotBrickFromWorldLocNonFow(ref VInt3 newPos, ActorRoot ar)
        {
            VInt3 vInt  = new VInt3(newPos.x, newPos.z, 0);
            VInt2 vInt2 = VInt2.zero;

            this.LevelGrid.WorldPosToGrid(vInt, out vInt2.x, out vInt2.y);
            bool flag = false;

            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            if (this.QueryAttr(vInt2, out sViewBlockAttr) && sViewBlockAttr.BlockType == 2)
            {
                flag = true;
            }
            else if (!PathfindingUtility.IsValidTarget(ar, newPos))
            {
                flag = true;
            }
            if (!flag)
            {
                return(true);
            }
            VInt2 zero = VInt2.zero;

            if (this.FindNearestGrid(vInt2, vInt, FieldObj.EViewBlockType.Brick, true, 4, ar, out zero))
            {
                vInt2 = zero;
                VInt3 zero2 = VInt3.zero;
                this.LevelGrid.GridToWorldPos(vInt2.x, vInt2.y, out zero2);
                newPos = new VInt3(zero2.x, newPos.y, zero2.y);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
            /** Distribute the agents in this node among the children.
             * Used after subdividing the node.
             */
            //GG
            //public void Distribute(Node[] nodes, Rect r)
            public void Distribute(Node[] nodes, VRect r)
            {
                //GG
                //Vector2 c = r.center;
                VInt2 c = r.center;

                while (linkedList != null)
                {
                    Agent nx = linkedList.next;
                    if (linkedList.position.x > c.x)
                    {
                        if (linkedList.position.y > c.y)
                        {
                            nodes[child11].Add(linkedList);
                        }
                        else
                        {
                            nodes[child10].Add(linkedList);
                        }
                    }
                    else
                    {
                        if (linkedList.position.y > c.y)
                        {
                            nodes[child01].Add(linkedList);
                        }
                        else
                        {
                            nodes[child00].Add(linkedList);
                        }
                    }
                    linkedList = nx;
                }
                count = 0;
            }
Ejemplo n.º 8
0
    /// <summary>
    /// 点是否在多边形中,顶点大于3
    /// </summary>
    /// <param name="pnt"></param>
    /// <param name="plg"></param>
    /// <returns></returns>
    public static bool PointInPolygon(ref VInt2 pnt, VInt2[] plg)
    {
        if ((plg == null) || (plg.Length < 3))
        {
            return(false);
        }
        bool flag  = false;
        int  index = 0;

        for (int i = plg.Length - 1; index < plg.Length; i = index++)
        {
            VInt2 num3 = plg[index];
            VInt2 num4 = plg[i];
            if (((num3.y <= pnt.y) && (pnt.y < num4.y)) || ((num4.y <= pnt.y) && (pnt.y < num3.y)))
            {
                int  num5 = num4.y - num3.y;
                long num6 = ((pnt.y - num3.y) * (num4.x - num3.x)) - ((pnt.x - num3.x) * num5);
                if (num5 > 0)
                {
                    if (num6 > 0L)
                    {
                        flag = !flag;
                    }
                }
                else if (num6 < 0L)
                {
                    flag = !flag;
                }
            }
        }
        return(flag);
    }
Ejemplo n.º 9
0
    /*public static VInt3 Divide(VInt3 a, long m, long b)
     * {
     *  a.x = (int)Divide((long)(a.x * m), b);
     *  a.y = (int)Divide((long)(a.y * m), b);
     *  a.z = (int)Divide((long)(a.z * m), b);
     *  return a;
     * }*/

    /// <summary>
    /// 线线相交
    /// </summary>
    /// <param name="seg1Src"></param>
    /// <param name="seg1Vec"></param>
    /// <param name="seg2Src"></param>
    /// <param name="seg2Vec"></param>
    /// <param name="interPoint"></param>
    /// <returns></returns>
    public static bool IntersectSegment(ref VInt2 seg1Src, ref VInt2 seg1Vec, ref VInt2 seg2Src, ref VInt2 seg2Vec, out VInt2 interPoint)
    {
        long num;
        long num2;
        long num3;
        long num4;
        long num5;
        long num6;

        SegvecToLinegen(ref seg1Src, ref seg1Vec, out num, out num2, out num3);
        SegvecToLinegen(ref seg2Src, ref seg2Vec, out num4, out num5, out num6);
        long b = (num * num5) - (num4 * num2);

        if (b != 0)
        {
            long x    = Divide((long)((num2 * num6) - (num5 * num3)), b);
            long y    = Divide((long)((num4 * num3) - (num * num6)), b);
            bool flag = IsPointOnSegment(ref seg1Src, ref seg1Vec, x, y) && IsPointOnSegment(ref seg2Src, ref seg2Vec, x, y);
            interPoint.x = (int)x;
            interPoint.y = (int)y;
            return(flag);
        }
        interPoint = VInt2.zero;
        return(false);
    }
Ejemplo n.º 10
0
    public static bool PointInPolygon(ref VInt2 pnt, VInt2[] plg)
    {
        if (plg == null || plg.Length < 3)
        {
            return(false);
        }
        bool flag = false;
        int  i    = 0;
        int  num  = plg.Length - 1;

        while (i < plg.Length)
        {
            VInt2 vInt  = plg[i];
            VInt2 vInt2 = plg[num];
            if ((vInt.y <= pnt.y && pnt.y < vInt2.y) || (vInt2.y <= pnt.y && pnt.y < vInt.y))
            {
                int  num2 = vInt2.y - vInt.y;
                long num3 = (long)(pnt.y - vInt.y) * (long)(vInt2.x - vInt.x) - (long)(pnt.x - vInt.x) * (long)num2;
                if (num2 > 0)
                {
                    if (num3 > 0L)
                    {
                        flag = !flag;
                    }
                }
                else if (num3 < 0L)
                {
                    flag = !flag;
                }
            }
            num = i++;
        }
        return(flag);
    }
Ejemplo n.º 11
0
    public static bool IntersectSegment(ref VInt2 seg1Src, ref VInt2 seg1Vec, ref VInt2 seg2Src, ref VInt2 seg2Vec, out VInt2 interPoint)
    {
        long num;
        long num2;
        long num3;

        IntMath.SegvecToLinegen(ref seg1Src, ref seg1Vec, out num, out num2, out num3);
        long num4;
        long num5;
        long num6;

        IntMath.SegvecToLinegen(ref seg2Src, ref seg2Vec, out num4, out num5, out num6);
        long num7 = num * num5 - num4 * num2;

        if (num7 != 0L)
        {
            long num8   = IntMath.Divide(num2 * num6 - num5 * num3, num7);
            long num9   = IntMath.Divide(num4 * num3 - num * num6, num7);
            bool result = IntMath.IsPointOnSegment(ref seg1Src, ref seg1Vec, num8, num9) && IntMath.IsPointOnSegment(ref seg2Src, ref seg2Vec, num8, num9);
            interPoint.x = (int)num8;
            interPoint.y = (int)num9;
            return(result);
        }
        interPoint = VInt2.zero;
        return(false);
    }
Ejemplo n.º 12
0
        //Good Game
        private void CalcNearestPoint(out VInt3 cp, ref VInt3 start, ref VInt3 end, ref VInt3 p)
        {
            VInt2 b = new VInt2(end.x - start.x, end.z - start.z);
            long  sqrMagnitudeLong = b.sqrMagnitudeLong;
            VInt2 a = new VInt2(p.x - start.x, p.z - start.z);

            cp   = new VInt3();
            cp.y = p.y;
            long num4 = VInt2.DotLong(ref a, ref b);

            if (sqrMagnitudeLong != 0)
            {
                long num5 = (end.x - start.x) * num4;
                long num6 = (end.z - start.z) * num4;
                cp.x  = (int)IntMath.Divide(num5, sqrMagnitudeLong);
                cp.z  = (int)IntMath.Divide(num6, sqrMagnitudeLong);
                cp.x += start.x;
                cp.z += start.z;
            }
            else
            {
                int num7 = (int)num4;
                cp.x = start.x + ((end.x - start.x) * num7);
                cp.z = start.z + ((end.z - start.z) * num7);
            }
        }
Ejemplo n.º 13
0
        public ObstacleVertex AddObstacle(VInt3 a, VInt3 b, VInt height)
        {
            ObstacleVertex obstacleVertex  = new ObstacleVertex();
            ObstacleVertex obstacleVertex2 = new ObstacleVertex();

            obstacleVertex.prev      = obstacleVertex2;
            obstacleVertex2.prev     = obstacleVertex;
            obstacleVertex.next      = obstacleVertex2;
            obstacleVertex2.next     = obstacleVertex;
            obstacleVertex.position  = a;
            obstacleVertex2.position = b;
            obstacleVertex.height    = height;
            obstacleVertex2.height   = height;
            obstacleVertex2.ignore   = true;
            VInt2 vInt = new VInt2(b.x - a.x, b.z - a.z);

            vInt.Normalize();
            obstacleVertex.dir  = vInt;
            obstacleVertex2.dir = -vInt;
            if (this.Multithreading && this.doubleBuffering)
            {
                for (int i = 0; i < this.workers.Length; i++)
                {
                    this.workers[i].WaitOne();
                }
            }
            this.obstacles.Add(obstacleVertex);
            this.UpdateObstacles();
            return(obstacleVertex);
        }
Ejemplo n.º 14
0
 public void Init(VInt2 pos, int sizeX, int sizeY)
 {
     this.origin    = pos;
     this.numCellsX = (sizeX / this.cellSize) + 1;
     this.numCellsY = (sizeY / this.cellSize) + 1;
     this.cells     = new List <object> [this.numCellsX * this.numCellsY];
 }
Ejemplo n.º 15
0
        public bool IntersectSegment(ref VInt3 segSrc, ref VInt3 segVec, ref VInt3 nearPoint, ref VInt3 pointProj)
        {
            if (this._vertecesXZ == null || this._vertecesXZ.Length < 2)
            {
                return(false);
            }
            if (!this.IsInBoundXZ(segSrc) && !this.IsInBoundXZ(segSrc + segVec))
            {
                return(false);
            }
            VInt2 xz  = segSrc.get_xz();
            VInt2 xz2 = segVec.get_xz();
            VInt2 vInt;
            VInt2 vInt2;

            if (IntMath.SegIntersectPlg(ref xz, ref xz2, this._vertecesXZ, ref vInt, ref vInt2))
            {
                nearPoint.x = vInt.x;
                nearPoint.z = vInt.y;
                pointProj.x = vInt2.x;
                pointProj.z = vInt2.y;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 16
0
    private static bool IsPointOnSegment(ref VInt2 segSrc, ref VInt2 segVec, long x, long y)
    {
        long num  = x - (long)segSrc.x;
        long num2 = y - (long)segSrc.y;

        return((long)segVec.x * num + (long)segVec.y * num2 >= 0L && num * num + num2 * num2 <= segVec.sqrMagnitudeLong);
    }
Ejemplo n.º 17
0
 public SPolylineVertex(VInt2 point)
 {
     this.m_point           = point;
     this.m_belongBlockId   = -1;
     this.m_belongSegNoList = new List <int>();
     this.m_bNative         = true;
 }
Ejemplo n.º 18
0
    public bool ExploreCellsFast(VInt3 location, int surfSightRange, GameFowManager pFowMgr, FieldObj inFieldObj, COM_PLAYERCAMP camp, bool bStaticExplore, bool bDistOnly)
    {
        if (pFowMgr == null || inFieldObj == null)
        {
            return(false);
        }
        VInt2 vInt = VInt2.zero;

        pFowMgr.WorldPosToGrid(location, out vInt.x, out vInt.y);
        FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
        if (inFieldObj.QueryAttr(vInt, out sViewBlockAttr) && sViewBlockAttr.BlockType == 2)
        {
            VInt2 zero = VInt2.zero;
            if (inFieldObj.FindNearestGrid(vInt, location, FieldObj.EViewBlockType.Brick, true, 3, null, out zero))
            {
                vInt = zero;
            }
        }
        if (bStaticExplore)
        {
            FowLos.TraverseStaticSurCell(surfSightRange, vInt.x, vInt.y, inFieldObj.NumX, inFieldObj.NumY, camp);
        }
        else
        {
            FowLos.TraverseSurCell(surfSightRange, vInt.x, vInt.y, inFieldObj.NumX, inFieldObj.NumY, camp, bDistOnly);
        }
        return(true);
    }
Ejemplo n.º 19
0
 public SPolylineVertex(FowLos.SPolylineVertex rhs)
 {
     this.m_point           = rhs.m_point;
     this.m_belongBlockId   = rhs.m_belongBlockId;
     this.m_belongSegNoList = new List <int>(rhs.m_belongSegNoList);
     this.m_bNative         = rhs.m_bNative;
 }
Ejemplo n.º 20
0
            public void Distribute(RVOQuadtree.Node[] nodes, VRect r)
            {
                VInt2 center = r.center;

                while (this.linkedList != null)
                {
                    Agent next = this.linkedList.next;
                    if (this.linkedList.position.x > center.x)
                    {
                        if (this.linkedList.position.z > center.y)
                        {
                            nodes[this.child11].Add(this.linkedList);
                        }
                        else
                        {
                            nodes[this.child10].Add(this.linkedList);
                        }
                    }
                    else if (this.linkedList.position.z > center.y)
                    {
                        nodes[this.child01].Add(this.linkedList);
                    }
                    else
                    {
                        nodes[this.child00].Add(this.linkedList);
                    }
                    this.linkedList = next;
                }
                this.count = 0;
            }
Ejemplo n.º 21
0
        void BuildQuadtree()
        {
            Quadtree.Clear();
            if (agents.Count > 0)
            {
                //GG
                //Rect bounds = Rect.MinMaxRect(agents[0].position.x, agents[0].position.y, agents[0].position.x, agents[0].position.y);
                VRect bounds = VRect.MinMaxRect(agents[0].position.x, agents[0].position.y, agents[0].position.x, agents[0].position.y);
                for (int i = 1; i < agents.Count; i++)
                {
                    //GG

                    /*Vector2 p = agents[i].position;
                     * bounds = Rect.MinMaxRect(Mathf.Min(bounds.xMin, p.x), Mathf.Min(bounds.yMin, p.y), Mathf.Max(bounds.xMax, p.x), Mathf.Max(bounds.yMax, p.y));*/
                    VInt2 p = agents[i].position;
                    bounds = VRect.MinMaxRect(Mathf.Min(bounds.xMin, p.x), Mathf.Min(bounds.yMin, p.y), Mathf.Max(bounds.xMax, p.x), Mathf.Max(bounds.yMax, p.y));
                }
                Quadtree.SetBounds(bounds);

                for (int i = 0; i < agents.Count; i++)
                {
                    Quadtree.Insert(agents[i]);
                }

                //quadtree.DebugDraw ();
            }

            Quadtree.CalculateSpeeds();
        }
Ejemplo n.º 22
0
        public ObstacleVertex AddObstacle(VInt3 a, VInt3 b, VInt height)
        {
            ObstacleVertex item    = new ObstacleVertex();
            ObstacleVertex vertex2 = new ObstacleVertex();

            item.prev        = vertex2;
            vertex2.prev     = item;
            item.next        = vertex2;
            vertex2.next     = item;
            item.position    = a;
            vertex2.position = b;
            item.height      = height;
            vertex2.height   = height;
            vertex2.ignore   = true;
            VInt2 num = new VInt2(b.x - a.x, b.z - a.z);

            num.Normalize();
            item.dir    = num;
            vertex2.dir = -num;
            if (this.Multithreading && this.doubleBuffering)
            {
                for (int i = 0; i < this.workers.Length; i++)
                {
                    this.workers[i].WaitOne();
                }
            }
            this.obstacles.Add(item);
            this.UpdateObstacles();
            return(item);
        }
Ejemplo n.º 23
0
    /// <summary>
    /// 点是否在线段上
    /// </summary>
    /// <param name="segSrc"></param>
    /// <param name="segVec"></param>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <returns></returns>
    private static bool IsPointOnSegment(ref VInt2 segSrc, ref VInt2 segVec, long x, long y)
    {
        long num  = x - segSrc.x;
        long num2 = y - segSrc.y;

        return((((segVec.x * num) + (segVec.y * num2)) >= 0L) && (((num * num) + (num2 * num2)) <= segVec.sqrMagnitudeLong));
    }
Ejemplo n.º 24
0
        public void SyncField(VInt2 inPos, int inFieldX, int inFieldY, int inCellSize)
        {
            int num  = inFieldX / inCellSize;
            int num2 = inFieldY / inCellSize;

            DebugHelper.Assert(num <= 255);
            DebugHelper.Assert(num2 <= 255);
            this.LevelGrid.GridInfo.CellNumX  = num;
            this.LevelGrid.GridInfo.CellNumY  = num2;
            this.LevelGrid.GridInfo.CellSizeX = inFieldX / num;
            this.LevelGrid.GridInfo.CellSizeY = inFieldY / num2;
            this.LevelGrid.GridInfo.GridPos   = inPos;
            this.LevelGrid.GridCells          = new FieldObj.FOGridCell[this.LevelGrid.GridInfo.CellNumX * this.LevelGrid.GridInfo.CellNumY];
            int num3 = this.NumX * this.NumY;

            for (int i = 0; i < num3; i++)
            {
                this.LevelGrid.GridCells[i].CellX = (byte)(i % this.LevelGrid.GridInfo.CellNumX);
                this.LevelGrid.GridCells[i].CellY = (byte)(i / this.LevelGrid.GridInfo.CellNumX);
            }
            this.FieldX = this.NumX * this.PaneX;
            this.FieldY = this.NumY * this.PaneY;
            this.xMin   = this.LevelGrid.GridInfo.GridPos.x;
            this.xMax   = this.LevelGrid.GridInfo.GridPos.x + this.FieldX;
            this.yMin   = this.LevelGrid.GridInfo.GridPos.y;
            this.yMax   = this.LevelGrid.GridInfo.GridPos.y + this.FieldY;
        }
Ejemplo n.º 25
0
 public void ParamlessConstruct()
 {
     this.m_point           = VInt2.zero;
     this.m_belongBlockId   = -1;
     this.m_belongSegNoList = new List <int>();
     this.m_bNative         = true;
 }
Ejemplo n.º 26
0
        public bool FindNearestGrid(VInt2 inCenterCell, VInt3 inCenterPosWorld, FieldObj.EViewBlockType inBlockType, bool bNonType, int inThicknessMax, ActorRoot ar, out VInt2 result)
        {
            result = VInt2.zero;
            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            bool         flag  = false;
            int          num   = 1;
            List <VInt2> list  = new List <VInt2>();
            List <VInt2> list2 = new List <VInt2>();

            while (!flag && num <= inThicknessMax)
            {
                list2.Clear();
                this.CollectNeighbourGrids(list2, list, inCenterCell, num);
                num++;
                list.AddRange(list2);
                if (list2.get_Count() > 0)
                {
                    for (int i = list2.get_Count() - 1; i >= 0; i--)
                    {
                        this.QueryAttr(list2.get_Item(i), out sViewBlockAttr);
                        if ((bNonType && sViewBlockAttr.BlockType == (byte)inBlockType) || (!bNonType && sViewBlockAttr.BlockType != (byte)inBlockType))
                        {
                            list2.RemoveAt(i);
                        }
                    }
                }
                if (list2.get_Count() > 0)
                {
                    long num2 = 2147483647L;
                    for (int j = 0; j < list2.get_Count(); j++)
                    {
                        VInt2 vInt = list2.get_Item(j);
                        VInt3 zero = VInt3.zero;
                        this.LevelGrid.GridToWorldPos(vInt.x, vInt.y, out zero);
                        long sqrMagnitudeLong = (inCenterPosWorld - zero).sqrMagnitudeLong;
                        if (sqrMagnitudeLong < num2)
                        {
                            if (ar == null)
                            {
                                flag   = true;
                                num2   = sqrMagnitudeLong;
                                result = list2.get_Item(j);
                            }
                            else
                            {
                                VInt3 target = new VInt3(zero.x, 0, zero.y);
                                if (PathfindingUtility.IsValidTarget(ar, target))
                                {
                                    flag   = true;
                                    num2   = sqrMagnitudeLong;
                                    result = list2.get_Item(j);
                                }
                            }
                        }
                    }
                }
            }
            return(flag);
        }
Ejemplo n.º 27
0
        private static void MergeBlockSegList(ref FowLos.SBlockContext blockContext, List <FowLos.SPolylineSegment> rawPolylineSegList, int inAreaId)
        {
            int count = rawPolylineSegList.get_Count();

            for (int i = 0; i < count; i++)
            {
                int count2 = blockContext.m_polylineSegList.get_Count();
                FowLos.SPolylineSegment sPolylineSegment = default(FowLos.SPolylineSegment);
                sPolylineSegment.ParamlessConstruct();
                sPolylineSegment.m_belongBlockId = inAreaId;
                sPolylineSegment.m_index         = count2;
                VInt2 start = rawPolylineSegList.get_Item(i).m_start;
                VInt2 end   = rawPolylineSegList.get_Item(i).m_end;
                int   num   = -1;
                if (blockContext.ContainsPoint(start, out num))
                {
                    sPolylineSegment.m_startPtIndex = num;
                    sPolylineSegment.m_start        = blockContext.m_polylineVertices.get_Item(num).m_point;
                    DebugHelper.Assert(blockContext.m_polylineVertices.get_Item(num).m_belongSegNoList.get_Count() > 0);
                    blockContext.m_polylineVertices.get_Item(num).m_belongSegNoList.Add(count2);
                    DebugHelper.Assert(blockContext.m_polylineVertices.get_Item(num).m_belongSegNoList.get_Count() <= 4);
                }
                else
                {
                    int count3 = blockContext.m_polylineVertices.get_Count();
                    FowLos.SPolylineVertex sPolylineVertex = default(FowLos.SPolylineVertex);
                    sPolylineVertex.ParamlessConstruct();
                    sPolylineVertex.m_point         = start;
                    sPolylineVertex.m_belongBlockId = inAreaId;
                    sPolylineVertex.m_belongSegNoList.Add(count2);
                    sPolylineVertex.m_bNative       = true;
                    sPolylineSegment.m_startPtIndex = count3;
                    sPolylineSegment.m_start        = sPolylineVertex.m_point;
                    blockContext.m_polylineVertices.Add(sPolylineVertex);
                }
                if (blockContext.ContainsPoint(end, out num))
                {
                    sPolylineSegment.m_endPtIndex = num;
                    sPolylineSegment.m_end        = blockContext.m_polylineVertices.get_Item(num).m_point;
                    DebugHelper.Assert(blockContext.m_polylineVertices.get_Item(num).m_belongSegNoList.get_Count() > 0);
                    blockContext.m_polylineVertices.get_Item(num).m_belongSegNoList.Add(count2);
                    DebugHelper.Assert(blockContext.m_polylineVertices.get_Item(num).m_belongSegNoList.get_Count() <= 4);
                }
                else
                {
                    int count4 = blockContext.m_polylineVertices.get_Count();
                    FowLos.SPolylineVertex sPolylineVertex2 = default(FowLos.SPolylineVertex);
                    sPolylineVertex2.ParamlessConstruct();
                    sPolylineVertex2.m_point         = end;
                    sPolylineVertex2.m_belongBlockId = inAreaId;
                    sPolylineVertex2.m_belongSegNoList.Add(count2);
                    sPolylineVertex2.m_bNative    = true;
                    sPolylineSegment.m_endPtIndex = count4;
                    sPolylineSegment.m_end        = sPolylineVertex2.m_point;
                    blockContext.m_polylineVertices.Add(sPolylineVertex2);
                }
                blockContext.m_polylineSegList.Add(sPolylineSegment);
            }
        }
Ejemplo n.º 28
0
 public void SetBaseDataVisible(VInt2 inPos, COM_PLAYERCAMP camp, bool bVisible)
 {
     if (this.pFowMgr == null)
     {
         return;
     }
     GameFowManager.SetBaseDataVisible(true, inPos.x, inPos.y, camp, camp == this.pFowMgr.m_hostPlayerCamp);
 }
Ejemplo n.º 29
0
 public override void GetAabb2D(out VInt2 origin, out VInt2 size)
 {
     origin    = this.WorldPos.get_xz();
     origin.x -= this.localRadius;
     origin.y -= this.localRadius;
     size.x    = this.localRadius + this.localRadius;
     size.y    = size.x;
 }
Ejemplo n.º 30
0
 public override void GetAabb2D(out VInt2 origin, out VInt2 size)
 {
     origin    = this.worldPos.xz;
     origin.x -= this.radius;
     origin.y -= this.radius;
     size.x    = this.radius + this.radius;
     size.y    = size.x;
 }