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);
    }
Exemple #2
0
    public static void CopyBitmap()
    {
        VInt2    mainActorFakeSightPos = FogOfWar.MainActorFakeSightPos;
        FieldObj pFieldObj             = Singleton <GameFowManager> .get_instance().m_pFieldObj;

        FowLos.PreCopyBitmap(mainActorFakeSightPos.x, mainActorFakeSightPos.y, pFieldObj.NumX, pFieldObj.NumY, Singleton <GamePlayerCenter> .get_instance().GetHostPlayer().PlayerCamp);
        FogOfWar._bitmapData = Singleton <GameFowManager> .get_instance().GetCommitPixels();
    }
Exemple #3
0
 public static void CopyBitmap()
 {
     FowLos.PreCopyBitmap();
     if (!Singleton <WatchController> .instance.IsWatching)
     {
         VInt2    mainActorFakeSightPos = FogOfWar.MainActorFakeSightPos;
         FieldObj pFieldObj             = Singleton <GameFowManager> .instance.m_pFieldObj;
         FowLos.PreCopyBitmapFakeSight(mainActorFakeSightPos.x, mainActorFakeSightPos.y, pFieldObj.NumX, pFieldObj.NumY);
     }
     FogOfWar._bitmapData = Singleton <GameFowManager> .instance.GetCommitPixels();
 }
    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 :;
            }
        }
    }