private void RaycastCheck <TSetCellVisible>(GameFowManager pFowMgr, FowLos.CRaycastQuadrant quadrant, VInt2 newSurfPos, VInt3 unitLoc, int sightSqr, COM_PLAYERCAMP camp, bool bDrawDebugLines, byte inStartViewblockId, ref TSetCellVisible setCellVisible) where TSetCellVisible : ISetCellVisible { VInt2 aa = new VInt2(unitLoc.x, unitLoc.y); int x = quadrant.min.x; int x2 = quadrant.max.x; int y = quadrant.min.y; int y2 = quadrant.max.y; VInt2 zero = VInt2.zero; int halfSizeX = pFowMgr.m_halfSizeX; int halfSizeY = pFowMgr.m_halfSizeY; for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { VInt2 vInt = new VInt2(i, j); if (i == newSurfPos.x && j == newSurfPos.y) { setCellVisible.SetVisible(vInt, camp, true); } else if ((vInt - newSurfPos).sqrMagnitude < sightSqr) { FieldObj.SViewBlockAttr sViewBlockAttr; if (!pFowMgr.m_pFieldObj.GrassBlockView && pFowMgr.m_pFieldObj.QueryAttr(vInt, out sViewBlockAttr) && sViewBlockAttr.BlockType == 1) { int num = (int)pFowMgr.m_pFieldObj.QueryViewblockId(vInt.x, vInt.y); if (num != (int)inStartViewblockId) { setCellVisible.SetVisible(vInt, camp, false); goto IL_6DD; } } VInt3 zero2 = VInt3.zero; pFowMgr.m_pFieldObj.LevelGrid.GridToWorldPos(i, j, out zero2); VInt2 vInt2 = new VInt2(zero2.x, zero2.y); VInt2 bb = vInt2; bb.x -= halfSizeX; bb.y -= halfSizeY; VInt2 bb2 = vInt2; bb2.x += halfSizeX; bb2.y -= halfSizeY; VInt2 bb3 = vInt2; bb3.x += halfSizeX; bb3.y += halfSizeY; VInt2 bb4 = vInt2; bb4.x -= halfSizeX; bb4.y += halfSizeY; FowLos.SGridWall sGridWall = default(FowLos.SGridWall); bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = i < newSurfPos.x; bool flag5 = j < newSurfPos.y; int num2 = flag4 ? newSurfPos.x : (newSurfPos.x + 1); int num3 = flag5 ? newSurfPos.y : (newSurfPos.y + 1); int num4 = 0; while (!flag && (!flag2 || !flag3)) { if (!flag2) { int num5 = num2 + (flag4 ? (-num4) : num4); if (flag4 && num5 < i + 1) { flag2 = true; } else if (!flag4 && num5 > i) { flag2 = true; } if (!flag2 && quadrant.wallsVertical.Contains((byte)num5)) { List <FowLos.SBlockWalls> .Enumerator enumerator = quadrant.viewBlockArrayFinal.GetEnumerator(); while (enumerator.MoveNext() && !flag) { FowLos.SBlockWalls current = enumerator.get_Current(); List <FowLos.SGridWall> list = null; if (current.m_wallsVertical.TryGetValue((byte)num5, ref list)) { int count = list.get_Count(); int num6 = 0; while (num6 < count && !flag) { FowLos.SGridWall sGridWall2 = list.get_Item(num6); if (bDrawDebugLines) { if (FowLos.SegmentIntersect(aa, vInt2, sGridWall2.m_start, sGridWall2.m_end, ref zero)) { flag = true; } else if (FowLos.SegmentIntersect(aa, bb, sGridWall2.m_start, sGridWall2.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb2, sGridWall2.m_start, sGridWall2.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb3, sGridWall2.m_start, sGridWall2.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb4, sGridWall2.m_start, sGridWall2.m_end, ref zero)) { flag = true; } } else if (FowLos.SegmentIntersect(aa, vInt2, sGridWall2.m_start, sGridWall2.m_end)) { flag = true; } else if (FowLos.SegmentIntersect(aa, bb, sGridWall2.m_start, sGridWall2.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb2, sGridWall2.m_start, sGridWall2.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb3, sGridWall2.m_start, sGridWall2.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb4, sGridWall2.m_start, sGridWall2.m_end, ref zero)) { flag = true; } num6++; } } } } } if (!flag3 && !flag) { int num7 = num3 + (flag5 ? (-num4) : num4); if (flag5 && num7 < j + 1) { flag3 = true; } else if (!flag5 && num7 > j) { flag3 = true; } if (!flag3 && quadrant.wallsHorizontal.Contains((byte)num7)) { List <FowLos.SBlockWalls> .Enumerator enumerator2 = quadrant.viewBlockArrayFinal.GetEnumerator(); while (enumerator2.MoveNext() && !flag) { FowLos.SBlockWalls current2 = enumerator2.get_Current(); List <FowLos.SGridWall> list2 = null; if (current2.m_wallsHorizontal.TryGetValue((byte)num7, ref list2)) { int count2 = list2.get_Count(); int num8 = 0; while (num8 < count2 && !flag) { FowLos.SGridWall sGridWall3 = list2.get_Item(num8); if (bDrawDebugLines) { if (FowLos.SegmentIntersect(aa, vInt2, sGridWall3.m_start, sGridWall3.m_end, ref zero)) { flag = true; } else if (FowLos.SegmentIntersect(aa, bb, sGridWall3.m_start, sGridWall3.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb2, sGridWall3.m_start, sGridWall3.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb3, sGridWall3.m_start, sGridWall3.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb4, sGridWall3.m_start, sGridWall3.m_end, ref zero)) { flag = true; } } else if (FowLos.SegmentIntersect(aa, vInt2, sGridWall3.m_start, sGridWall3.m_end)) { flag = true; } else if (FowLos.SegmentIntersect(aa, bb, sGridWall3.m_start, sGridWall3.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb2, sGridWall3.m_start, sGridWall3.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb3, sGridWall3.m_start, sGridWall3.m_end, ref zero) || FowLos.SegmentIntersect(aa, bb4, sGridWall3.m_start, sGridWall3.m_end, ref zero)) { flag = true; } num8++; } } } } } num4++; } if (!flag) { setCellVisible.SetVisible(vInt, camp, true); } } IL_6DD :; } } }
private List <FowLos.SBlockWalls> CreateBlockWallsInternal() { List <FowLos.SBlockWalls> list = new List <FowLos.SBlockWalls>(); Dictionary <byte, FowLos.SBlockContext> dictionary = this.CreateBlockMap(); Dictionary <byte, FowLos.SBlockContext> .Enumerator enumerator = dictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair <byte, FowLos.SBlockContext> current = enumerator.get_Current(); FowLos.SBlockContext value = current.get_Value(); KeyValuePair <byte, FowLos.SBlockContext> current2 = enumerator.get_Current(); byte key = current2.get_Key(); FowLos.SBlockWalls sBlockWalls = default(FowLos.SBlockWalls); sBlockWalls.ParamlessConstruct(); sBlockWalls.m_areaId = key; sBlockWalls.m_xMin = value.m_xMin; sBlockWalls.m_xMax = value.m_xMax; sBlockWalls.m_yMin = value.m_yMin; sBlockWalls.m_yMax = value.m_yMax; KeyValuePair <byte, FowLos.SBlockContext> current3 = enumerator.get_Current(); List <FowLos.SPolylineSegment> polylineSegList = current3.get_Value().m_polylineSegList; int count = polylineSegList.get_Count(); for (int i = 0; i < count; i++) { FowLos.SGridWall sGridWall = default(FowLos.SGridWall); sGridWall.m_start = polylineSegList.get_Item(i).m_start; sGridWall.m_end = polylineSegList.get_Item(i).m_end; DebugHelper.Assert(sGridWall.m_start != sGridWall.m_end); if (sGridWall.m_start.x == sGridWall.m_end.x) { sGridWall.m_horizontal = false; byte b = (byte)((sGridWall.m_start.x + this.PaneX / 2 - this.LevelGrid.GridInfo.GridPos.x) / this.PaneX); DebugHelper.Assert(b >= 0); DebugHelper.Assert((int)b <= this.NumX); if (sGridWall.m_start.y > sGridWall.m_end.y) { sGridWall.m_start.y = sGridWall.m_start.y + 10; sGridWall.m_end.y = sGridWall.m_end.y - 10; } else { DebugHelper.Assert(sGridWall.m_start.y < sGridWall.m_end.y); sGridWall.m_start.y = sGridWall.m_start.y - 10; sGridWall.m_end.y = sGridWall.m_end.y + 10; } List <FowLos.SGridWall> list2 = null; if (sBlockWalls.m_wallsVertical.TryGetValue(b, ref list2)) { sBlockWalls.m_wallsVertical.get_Item(b).Add(sGridWall); } else { list2 = new List <FowLos.SGridWall>(); list2.Add(sGridWall); sBlockWalls.m_wallsVertical.Add(b, list2); } } else { DebugHelper.Assert(sGridWall.m_start.y == sGridWall.m_end.y); sGridWall.m_horizontal = true; byte b2 = (byte)((sGridWall.m_start.y + this.PaneY / 2 - this.LevelGrid.GridInfo.GridPos.y) / this.PaneY); DebugHelper.Assert(b2 >= 0); DebugHelper.Assert((int)b2 <= this.NumY); if (sGridWall.m_start.x > sGridWall.m_end.x) { sGridWall.m_start.x = sGridWall.m_start.x + 10; sGridWall.m_end.x = sGridWall.m_end.x - 10; } else { DebugHelper.Assert(sGridWall.m_start.x < sGridWall.m_end.x); sGridWall.m_start.x = sGridWall.m_start.x - 10; sGridWall.m_end.x = sGridWall.m_end.x + 10; } List <FowLos.SGridWall> list3 = null; if (sBlockWalls.m_wallsHorizontal.TryGetValue(b2, ref list3)) { sBlockWalls.m_wallsHorizontal.get_Item(b2).Add(sGridWall); } else { list3 = new List <FowLos.SGridWall>(); list3.Add(sGridWall); sBlockWalls.m_wallsHorizontal.Add(b2, list3); } } } list.Add(sBlockWalls); } return(list); }