Ejemplo n.º 1
0
        public static bool VisitFowVisibilityCheck(VCollisionSphere sphere, PoolObjHandle <ActorRoot> inActor, COM_PLAYERCAMP inHostCamp, GameFowManager fowMgr)
        {
            VInt2 zero = VInt2.zero;

            if (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 vInt  = new VInt2(i, j);
                        VInt2 vInt2 = zero + vInt;
                        if (fowMgr.IsInsideSurface(vInt2.x, vInt2.y))
                        {
                            if (vInt.get_sqrMagnitude() <= num * num)
                            {
                                bool flag = Singleton <GameFowManager> .get_instance().IsVisible(vInt2.x, vInt2.y, inHostCamp);

                                if (flag)
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
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 vInt  = new VInt2(i, j);
                     VInt2 inPos = newSurfPos + vInt;
                     if (pFowMgr.IsInsideSurface(inPos.x, inPos.y))
                     {
                         if (vInt.get_sqrMagnitude() < surfSightRange * surfSightRange)
                         {
                             setCellVisible.SetVisible(inPos, camp, true);
                         }
                     }
                 }
             }
         }
         else if (ViewExploringMode != FowLos.EViewExploringMode.EViewExploringMode_WatchTower)
         {
             if (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);
                         if ((int)viewBlockId == areaId)
                         {
                             if (sViewBlockAttr.BlockType == 1)
                             {
                                 continue;
                             }
                             if (sViewBlockAttr.BlockType == 2)
                             {
                             }
                         }
                         if (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> arg_2A3_0 = cRaycastQuadrant.wallsHorizontal;
                                 KeyValuePair <byte, List <FowLos.SGridWall> > current2 = enumerator2.get_Current();
                                 BaseAlgorithm.AddUniqueItem <byte>(arg_2A3_0, current2.get_Key());
                             }
                             enumerator2 = current.m_wallsVertical.GetEnumerator();
                             while (enumerator2.MoveNext())
                             {
                                 List <byte> arg_2DF_0 = cRaycastQuadrant.wallsVertical;
                                 KeyValuePair <byte, List <FowLos.SGridWall> > current3 = enumerator2.get_Current();
                                 BaseAlgorithm.AddUniqueItem <byte>(arg_2DF_0, current3.get_Key());
                             }
                         }
                     }
                     this.RaycastCheck <TSetCellVisible>(pFowMgr, cRaycastQuadrant, newSurfPos, unitLoc, sightSqr, camp, bDrawDebugLines, ref setCellVisible);
                 }
                 cRaycastQuadrant.Clear();
             }
         }
     }
 }