Exemplo n.º 1
0
        public bool IsCellViewBlocking(int surfCellX, int surfCellY, int unitAreadId)
        {
            int num = surfCellY * this.LevelGrid.GridInfo.CellNumX + surfCellX;

            FieldObj.FOGridCell fOGridCell = this.LevelGrid.GridCells[num];
            return(fOGridCell.m_viewBlockId != 0 && (unitAreadId == 0 || unitAreadId != (int)fOGridCell.m_viewBlockId) && this.IsAreaViewBlocking(fOGridCell.m_viewBlockId));
        }
Exemplo n.º 2
0
        private Dictionary <byte, FowLos.SBlockContext> CreateBlockMap()
        {
            Dictionary <byte, FowLos.SBlockContext> dictionary = new Dictionary <byte, FowLos.SBlockContext>();

            FieldObj.FOGridInfo gridInfo = this.LevelGrid.GridInfo;
            int cellNumX = gridInfo.CellNumX;
            int cellNumY = gridInfo.CellNumY;
            int num      = cellNumX * cellNumY;
            Dictionary <byte, List <int> > dictionary2 = new Dictionary <byte, List <int> >();

            for (int i = 0; i < num; i++)
            {
                FieldObj.FOGridCell fOGridCell = this.LevelGrid.GridCells[i];
                byte viewBlockId = fOGridCell.m_viewBlockId;
                if (this.IsAreaViewBlocking(viewBlockId))
                {
                    List <int> list = null;
                    if (dictionary2.TryGetValue(viewBlockId, ref list))
                    {
                        list.Add(i);
                    }
                    else
                    {
                        list = new List <int>();
                        list.Add(i);
                        dictionary2.Add(viewBlockId, list);
                    }
                }
            }
            Dictionary <byte, List <int> > .Enumerator enumerator = dictionary2.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <byte, List <int> > current = enumerator.get_Current();
                List <int> value = current.get_Value();
                KeyValuePair <byte, List <int> > current2 = enumerator.get_Current();
                byte       key   = current2.get_Key();
                List <int> list2 = new List <int>();
                int        num2  = 2147483647;
                int        num3  = 2147483647;
                int        num4  = -2147483647;
                int        num5  = -2147483647;
                int        count = value.get_Count();
                for (int j = 0; j < count; j++)
                {
                    int num6 = value.get_Item(j);
                    FieldObj.FOGridCell fOGridCell2 = this.LevelGrid.GridCells[num6];
                    int cellX = (int)fOGridCell2.CellX;
                    int cellY = (int)fOGridCell2.CellY;
                    if (num2 > cellX)
                    {
                        num2 = cellX;
                    }
                    if (num4 < cellX)
                    {
                        num4 = cellX;
                    }
                    if (num3 > cellY)
                    {
                        num3 = cellY;
                    }
                    if (num5 < cellY)
                    {
                        num5 = cellY;
                    }
                    List <int> list3 = new List <int>();
                    bool       flag  = false;
                    if (cellX > 0)
                    {
                        list3.Add(num6 - 1);
                    }
                    else
                    {
                        list2.Add(num6);
                        flag = true;
                    }
                    if (!flag)
                    {
                        if (cellX < cellNumX - 1)
                        {
                            list3.Add(num6 + 1);
                        }
                        else
                        {
                            list2.Add(num6);
                            flag = true;
                        }
                        if (!flag)
                        {
                            if (cellY > 0)
                            {
                                list3.Add(num6 - cellNumX);
                            }
                            else
                            {
                                list2.Add(num6);
                                flag = true;
                            }
                            if (!flag)
                            {
                                if (cellY < cellNumY - 1)
                                {
                                    list3.Add(num6 + cellNumX);
                                }
                                else
                                {
                                    list2.Add(num6);
                                    flag = true;
                                }
                                if (!flag)
                                {
                                    int count2 = list3.get_Count();
                                    for (int k = 0; k < count2; k++)
                                    {
                                        int num7 = list3.get_Item(k);
                                        if (!value.Contains(num7))
                                        {
                                            list2.Add(num6);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                FowLos.SBlockContext sBlockContext = default(FowLos.SBlockContext);
                sBlockContext.ParamlessConstruct();
                sBlockContext.m_areaId = (int)key;
                int num8  = gridInfo.GridPos.x + gridInfo.CellSizeX * (num4 + 1);
                int num9  = gridInfo.GridPos.y + gridInfo.CellSizeY * (num5 + 1);
                int num10 = gridInfo.GridPos.x + gridInfo.CellSizeX * num2;
                int num11 = gridInfo.GridPos.y + gridInfo.CellSizeY * num3;
                sBlockContext.m_bounds.Origin.x    = (num8 + num10) / 2;
                sBlockContext.m_bounds.Origin.y    = (num9 + num11) / 2;
                sBlockContext.m_bounds.Origin.z    = 0;
                sBlockContext.m_bounds.BoxExtent.x = (num8 - num10) / 2;
                sBlockContext.m_bounds.BoxExtent.y = (num9 - num11) / 2;
                sBlockContext.m_bounds.BoxExtent.z = 1000;
                DebugHelper.Assert(num2 <= 255);
                DebugHelper.Assert(num4 <= 255);
                DebugHelper.Assert(num3 <= 255);
                DebugHelper.Assert(num5 <= 255);
                sBlockContext.m_xMin = (byte)num2;
                sBlockContext.m_xMax = (byte)num4;
                sBlockContext.m_yMin = (byte)num3;
                sBlockContext.m_yMax = (byte)num5;
                int count3 = list2.get_Count();
                List <FowLos.SPolylineSegment> list4 = new List <FowLos.SPolylineSegment>();
                for (int l = num3; l <= num5; l++)
                {
                    Dictionary <int, int> dictionary3 = new Dictionary <int, int>();
                    for (int m = 0; m < count3; m++)
                    {
                        int num12 = list2.get_Item(m);
                        FieldObj.FOGridCell fOGridCell3 = this.LevelGrid.GridCells[num12];
                        int cellX2 = (int)fOGridCell3.CellX;
                        int cellY2 = (int)fOGridCell3.CellY;
                        if (cellY2 == l)
                        {
                            dictionary3.Add(cellX2, num12);
                        }
                    }
                    List <FowLos.SPolylineSegment> list5 = new List <FowLos.SPolylineSegment>();
                    List <FowLos.SPolylineSegment> list6 = new List <FowLos.SPolylineSegment>();
                    int num13 = -1;
                    int num14 = -1;
                    Dictionary <int, int> .Enumerator enumerator2 = dictionary3.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                        KeyValuePair <int, int> current3 = enumerator2.get_Current();
                        int value2 = current3.get_Value();
                        FieldObj.FOGridCell fOGridCell4 = this.LevelGrid.GridCells[value2];
                        int   cellX3 = (int)fOGridCell4.CellX;
                        int   cellY3 = (int)fOGridCell4.CellY;
                        VInt2 start  = new VInt2(gridInfo.GridPos.x + gridInfo.CellSizeX * cellX3, gridInfo.GridPos.y + gridInfo.CellSizeY * cellY3);
                        VInt2 end    = new VInt2(gridInfo.GridPos.x + gridInfo.CellSizeX * (cellX3 + 1), gridInfo.GridPos.y + gridInfo.CellSizeY * (cellY3 + 1));
                        VInt2 start2 = new VInt2(start.x, end.y);
                        VInt2 end2   = new VInt2(end.x, start.y);
                        if (cellY3 == 0 || key != this.LevelGrid.GridCells[value2 - cellNumX].m_viewBlockId)
                        {
                            if (num13 != -1 && cellX3 == num13 + 1)
                            {
                                if (list6.get_Count() > 0)
                                {
                                    FowLos.SPolylineSegment sPolylineSegment = new FowLos.SPolylineSegment(list6.get_Item(list6.get_Count() - 1));
                                    sPolylineSegment.m_end = end2;
                                    list6.set_Item(list6.get_Count() - 1, sPolylineSegment);
                                }
                                else
                                {
                                    list6.Add(new FowLos.SPolylineSegment(start, end2));
                                }
                            }
                            else
                            {
                                list6.Add(new FowLos.SPolylineSegment(start, end2));
                            }
                            num13 = cellX3;
                        }
                        if (cellY3 == cellNumY - 1 || key != this.LevelGrid.GridCells[value2 + cellNumX].m_viewBlockId)
                        {
                            if (num14 != -1 && cellX3 == num14 + 1)
                            {
                                if (list5.get_Count() > 0)
                                {
                                    FowLos.SPolylineSegment sPolylineSegment2 = new FowLos.SPolylineSegment(list5.get_Item(list5.get_Count() - 1));
                                    sPolylineSegment2.m_end = end;
                                    list5.set_Item(list5.get_Count() - 1, sPolylineSegment2);
                                }
                                else
                                {
                                    list5.Add(new FowLos.SPolylineSegment(start2, end));
                                }
                            }
                            else
                            {
                                list5.Add(new FowLos.SPolylineSegment(start2, end));
                            }
                            num14 = cellX3;
                        }
                    }
                    FieldObj.MergeBlockSegList(ref sBlockContext, list4, (int)key);
                    FieldObj.MergeBlockSegList(ref sBlockContext, list6, (int)key);
                    list4 = list5;
                }
                FieldObj.MergeBlockSegList(ref sBlockContext, list4, (int)key);
                list4.Clear();
                DebugHelper.Assert(sBlockContext.m_polylineSegList.get_Count() >= 2);
                for (int n = num2; n <= num4; n++)
                {
                    Dictionary <int, int> dictionary4 = new Dictionary <int, int>();
                    for (int num15 = 0; num15 < count3; num15++)
                    {
                        int num16 = list2.get_Item(num15);
                        FieldObj.FOGridCell fOGridCell5 = this.LevelGrid.GridCells[num16];
                        int cellX4 = (int)fOGridCell5.CellX;
                        int cellY4 = (int)fOGridCell5.CellY;
                        if (cellX4 == n)
                        {
                            dictionary4.Add(cellY4, num16);
                        }
                    }
                    List <FowLos.SPolylineSegment> list7 = new List <FowLos.SPolylineSegment>();
                    List <FowLos.SPolylineSegment> list8 = new List <FowLos.SPolylineSegment>();
                    int num17 = -1;
                    int num18 = -1;
                    Dictionary <int, int> .Enumerator enumerator3 = dictionary4.GetEnumerator();
                    while (enumerator3.MoveNext())
                    {
                        KeyValuePair <int, int> current4 = enumerator3.get_Current();
                        int value3 = current4.get_Value();
                        FieldObj.FOGridCell fOGridCell6 = this.LevelGrid.GridCells[value3];
                        int   cellX5 = (int)fOGridCell6.CellX;
                        int   cellY5 = (int)fOGridCell6.CellY;
                        VInt2 start3 = new VInt2(gridInfo.GridPos.x + gridInfo.CellSizeX * cellX5, gridInfo.GridPos.y + gridInfo.CellSizeY * cellY5);
                        VInt2 end3   = new VInt2(gridInfo.GridPos.x + gridInfo.CellSizeX * (cellX5 + 1), gridInfo.GridPos.y + gridInfo.CellSizeY * (cellY5 + 1));
                        VInt2 end4   = new VInt2(start3.x, end3.y);
                        VInt2 start4 = new VInt2(end3.x, start3.y);
                        if (cellX5 == 0 || key != this.LevelGrid.GridCells[value3 - 1].m_viewBlockId)
                        {
                            if (num17 != -1 && cellY5 == num17 + 1)
                            {
                                if (list8.get_Count() > 0)
                                {
                                    FowLos.SPolylineSegment sPolylineSegment3 = new FowLos.SPolylineSegment(list8.get_Item(list8.get_Count() - 1));
                                    sPolylineSegment3.m_end = end4;
                                    list8.set_Item(list8.get_Count() - 1, sPolylineSegment3);
                                }
                                else
                                {
                                    list8.Add(new FowLos.SPolylineSegment(start3, end4));
                                }
                            }
                            else
                            {
                                list8.Add(new FowLos.SPolylineSegment(start3, end4));
                            }
                            num17 = cellY5;
                        }
                        if (cellX5 == cellNumX - 1 || key != this.LevelGrid.GridCells[value3 + 1].m_viewBlockId)
                        {
                            if (num18 != -1 && cellY5 == num18 + 1)
                            {
                                if (list7.get_Count() > 0)
                                {
                                    FowLos.SPolylineSegment sPolylineSegment4 = new FowLos.SPolylineSegment(list7.get_Item(list7.get_Count() - 1));
                                    sPolylineSegment4.m_end = end3;
                                    list7.set_Item(list7.get_Count() - 1, sPolylineSegment4);
                                }
                                else
                                {
                                    list7.Add(new FowLos.SPolylineSegment(start4, end3));
                                }
                            }
                            else
                            {
                                list7.Add(new FowLos.SPolylineSegment(start4, end3));
                            }
                            num18 = cellY5;
                        }
                    }
                    FieldObj.MergeBlockSegList(ref sBlockContext, list4, (int)key);
                    FieldObj.MergeBlockSegList(ref sBlockContext, list8, (int)key);
                    list4 = list7;
                }
                FieldObj.MergeBlockSegList(ref sBlockContext, list4, (int)key);
                list4.Clear();
                DebugHelper.Assert(sBlockContext.m_polylineSegList.get_Count() >= 4);
                int count4 = sBlockContext.m_polylineVertices.get_Count();
                for (int num19 = 0; num19 < count4; num19++)
                {
                    FowLos.SPolylineVertex sPolylineVertex = sBlockContext.m_polylineVertices.get_Item(num19);
                    DebugHelper.Assert(sPolylineVertex.m_bNative);
                    DebugHelper.Assert(sPolylineVertex.m_belongBlockId != -1);
                    DebugHelper.Assert(sPolylineVertex.m_belongSegNoList.get_Count() <= 4);
                    DebugHelper.Assert(sPolylineVertex.m_belongSegNoList.get_Count() >= 2);
                }
                int count5 = sBlockContext.m_polylineSegList.get_Count();
                for (int num20 = 0; num20 < count5; num20++)
                {
                    FowLos.SPolylineSegment sPolylineSegment5 = sBlockContext.m_polylineSegList.get_Item(num20);
                    DebugHelper.Assert(sPolylineSegment5.m_index == num20);
                    DebugHelper.Assert(sPolylineSegment5.m_belongBlockId != -1);
                    DebugHelper.Assert(sPolylineSegment5.m_startPtIndex != -1);
                    DebugHelper.Assert(sPolylineSegment5.m_endPtIndex != -1);
                }
                sBlockContext.m_blockerGridIndexList = value;
                if (dictionary.ContainsKey(key))
                {
                    dictionary.set_Item(key, sBlockContext);
                }
                else
                {
                    dictionary.Add(key, sBlockContext);
                }
            }
            return(dictionary);
        }