Exemplo n.º 1
0
 public void ExploreCellsInternal <TSetCellVisible>(ref TSetCellVisible setCellVisible, VInt2 newSurfPos, VInt3 unitLoc, int surfSightRange, GameFowManager pFowMgr, COM_PLAYERCAMP camp, FowLos.EViewExploringMode ViewExploringMode, bool bDrawDebugLines) where TSetCellVisible : ISetCellVisible
 {
     if (pFowMgr == null || pFowMgr.m_pFieldObj == null)
     {
         return;
     }
     if (ViewExploringMode != FowLos.EViewExploringMode.EViewExploringMode_ShadowCast)
     {
         if (ViewExploringMode == FowLos.EViewExploringMode.EViewExploringMode_DistOnly)
         {
             for (int i = -surfSightRange - 1; i <= surfSightRange + 1; i++)
             {
                 for (int j = -surfSightRange - 1; j <= surfSightRange + 1; j++)
                 {
                     VInt2 b     = new VInt2(i, j);
                     VInt2 inPos = newSurfPos + b;
                     if (pFowMgr.IsInsideSurface(inPos.x, inPos.y) && b.sqrMagnitude < surfSightRange * surfSightRange)
                     {
                         setCellVisible.SetVisible(inPos, camp, true);
                     }
                 }
             }
         }
         else if (ViewExploringMode != FowLos.EViewExploringMode.EViewExploringMode_WatchTower && ViewExploringMode == FowLos.EViewExploringMode.EViewExploringMode_RayCast)
         {
             int sightSqr = surfSightRange * surfSightRange;
             int num      = newSurfPos.x - surfSightRange;
             int num2     = newSurfPos.x + surfSightRange;
             int num3     = newSurfPos.y - surfSightRange;
             int num4     = newSurfPos.y + surfSightRange;
             num  = Mathf.Clamp(num, 0, pFowMgr.m_pFieldObj.NumX - 1);
             num2 = Mathf.Clamp(num2, 0, pFowMgr.m_pFieldObj.NumX - 1);
             num3 = Mathf.Clamp(num3, 0, pFowMgr.m_pFieldObj.NumY - 1);
             num4 = Mathf.Clamp(num4, 0, pFowMgr.m_pFieldObj.NumY - 1);
             byte viewBlockId = pFowMgr.m_pFieldObj.LevelGrid.GetGridCell(newSurfPos).m_viewBlockId;
             FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
             pFowMgr.m_pFieldObj.QueryAttr(newSurfPos, out sViewBlockAttr);
             FowLos.CRaycastQuadrant cRaycastQuadrant = new FowLos.CRaycastQuadrant();
             cRaycastQuadrant.min = new VInt2(num, num3);
             cRaycastQuadrant.max = new VInt2(num2, num4);
             if (pFowMgr.m_pFieldObj.ViewBlockArrayImpl != null)
             {
                 List <FowLos.SBlockWalls> .Enumerator enumerator = pFowMgr.m_pFieldObj.ViewBlockArrayImpl.GetEnumerator();
                 while (enumerator.MoveNext())
                 {
                     FowLos.SBlockWalls current = enumerator.get_Current();
                     int areaId = (int)current.m_areaId;
                     DebugHelper.Assert(areaId != 0);
                     FieldObj.SViewBlockAttr sViewBlockAttr2;
                     if (((int)viewBlockId != areaId || sViewBlockAttr.BlockType != 1) && (pFowMgr.m_pFieldObj.GrassBlockView || !pFowMgr.m_pFieldObj.ViewBlockAttrMap.TryGetValue((byte)areaId, ref sViewBlockAttr2) || sViewBlockAttr2.BlockType != 1) && this.ValidateViewBlock(current, cRaycastQuadrant.min.x, cRaycastQuadrant.max.x, cRaycastQuadrant.min.y, cRaycastQuadrant.max.y))
                     {
                         cRaycastQuadrant.viewBlockArrayFinal.Add(current);
                         Dictionary <byte, List <FowLos.SGridWall> > .Enumerator enumerator2 = current.m_wallsHorizontal.GetEnumerator();
                         while (enumerator2.MoveNext())
                         {
                             List <byte> wallsHorizontal = cRaycastQuadrant.wallsHorizontal;
                             KeyValuePair <byte, List <FowLos.SGridWall> > current2 = enumerator2.get_Current();
                             BaseAlgorithm.AddUniqueItem <byte>(wallsHorizontal, current2.get_Key());
                         }
                         enumerator2 = current.m_wallsVertical.GetEnumerator();
                         while (enumerator2.MoveNext())
                         {
                             List <byte> wallsVertical = cRaycastQuadrant.wallsVertical;
                             KeyValuePair <byte, List <FowLos.SGridWall> > current3 = enumerator2.get_Current();
                             BaseAlgorithm.AddUniqueItem <byte>(wallsVertical, current3.get_Key());
                         }
                     }
                 }
                 this.RaycastCheck <TSetCellVisible>(pFowMgr, cRaycastQuadrant, newSurfPos, unitLoc, sightSqr, camp, bDrawDebugLines, viewBlockId, ref setCellVisible);
             }
             cRaycastQuadrant.Clear();
         }
     }
 }
Exemplo n.º 2
0
    public void ExploreCells(VInt3 location, int inSightRange, GameFowManager pFowMgr, COM_PLAYERCAMP camp, FowLos.EViewExploringMode ViewExploringMode, bool bDrawDebugLines)
    {
        if (pFowMgr == null || pFowMgr.m_pFieldObj == null)
        {
            return;
        }
        if (pFowMgr.m_pFieldObj.ViewBlockArrayImpl == null && Application.isPlaying)
        {
            pFowMgr.m_pFieldObj.CreateBlockWalls();
        }
        VInt3 vInt = location;
        VInt2 zero = VInt2.zero;

        pFowMgr.WorldPosToGrid(vInt, out zero.x, out zero.y);
        pFowMgr.ReviseWorldPosToCenter(vInt, out vInt);
        this.ExploreCellsInternal <_SetCellVisible>(ref this.m_setCellVisible, zero, vInt, inSightRange, pFowMgr, camp, ViewExploringMode, bDrawDebugLines);
    }