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);
    }
Example #2
0
        public static bool CheckGrassAttaching(ref VInt3 newPos)
        {
            FieldObj pFieldObj = Singleton <GameFowManager> .instance.m_pFieldObj;
            VInt3    vInt      = new VInt3(newPos.x, newPos.z, 0);
            VInt2    zero      = VInt2.zero;

            pFieldObj.LevelGrid.WorldPosToGrid(vInt, out zero.x, out zero.y);
            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            pFieldObj.QueryAttr(zero, out sViewBlockAttr);
            if (sViewBlockAttr.BlockType == 0 && pFieldObj.FindNearestGrid(zero, vInt, FieldObj.EViewBlockType.Grass, false, 1, null, out zero))
            {
                pFieldObj.LevelGrid.GridToWorldPos(zero.x, zero.y, out vInt);
                int num = MonoSingleton <GlobalConfig> .instance.GrassEyeAbsorbDist;
                num += pFieldObj.PaneX / 2;
                if (vInt.x + num > newPos.x && vInt.x - num < newPos.x && vInt.y + num > newPos.z && vInt.y - num < newPos.z)
                {
                    newPos = new VInt3(vInt.x, newPos.y, vInt.y);
                    return(true);
                }
            }
            return(false);
        }
    public bool TryLoad(FieldObj inFieldObj)
    {
        DebugHelper.Assert(inFieldObj != null);
        if (inFieldObj.fowOfflineData == null || inFieldObj.fowOfflineData.Length == 0)
        {
            return(false);
        }
        MemoryStream memoryStream = new MemoryStream(inFieldObj.fowOfflineData);
        BinaryReader binaryReader = new BinaryReader(memoryStream);
        uint         num          = binaryReader.ReadUInt32();
        uint         num2         = binaryReader.ReadUInt32();
        uint         num3         = binaryReader.ReadUInt32();

        if (num != this.VerificationCode || this.Version != num2)
        {
            return(false);
        }
        int num4 = inFieldObj.NumX * inFieldObj.NumY;
        int num5 = binaryReader.ReadInt32();

        if (num4 != num5)
        {
            return(false);
        }
        GameFowManager.InitSurfCellsArray(num4);
        GameFowManager.InitLevelGrid(num4, inFieldObj.LevelGrid.GridInfo.CellNumX, inFieldObj.LevelGrid.GridInfo.CellNumY, inFieldObj.LevelGrid.GridInfo.CellSizeX, inFieldObj.LevelGrid.GridInfo.CellSizeY, inFieldObj.LevelGrid.GridInfo.GridPos.x, inFieldObj.LevelGrid.GridInfo.GridPos.y);
        int num6 = 0;

        inFieldObj.UnrealToGridX(Horizon.QueryGlobalSight(), out num6);
        for (int i = 0; i < num4; i++)
        {
            int gridCellX = inFieldObj.LevelGrid.GetGridCellX(i);
            int gridCellY = inFieldObj.LevelGrid.GetGridCellY(i);
            int xMin      = Mathf.Max(0, gridCellX - num6);
            int xMax      = Mathf.Min(inFieldObj.NumX - 1, gridCellX + num6);
            int yMin      = Mathf.Max(0, gridCellY - num6);
            int yMax      = Mathf.Min(inFieldObj.NumY - 1, gridCellY + num6);
            int num7      = binaryReader.ReadInt32();
            if (num7 > 0)
            {
                byte[] array = new byte[num7];
                binaryReader.Read(array, 0, num7);
                uint[] array2 = FOGameFowOfflineSerializer.ByteArrToUIntArr(array);
                DebugHelper.Assert(array2.Length == num7 / 4);
                GameFowManager.InitSurfCell(i, xMin, xMax, yMin, yMax, true);
                IntPtr intPtr = Marshal.AllocHGlobal(num7);
                Marshal.Copy(array, 0, intPtr, num7);
                GameFowManager.SetSurfCellData(i, intPtr);
                Marshal.FreeHGlobal(intPtr);
            }
            else
            {
                GameFowManager.InitSurfCell(i, xMin, xMax, yMin, yMax, false);
            }
            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            inFieldObj.QueryAttr(gridCellX, gridCellY, out sViewBlockAttr);
            GameFowManager.InitLevelGridCell(i, (int)sViewBlockAttr.BlockType, (int)sViewBlockAttr.LightType);
        }
        int num8 = binaryReader.ReadInt32();

        if (num8 != 987654321)
        {
        }
        binaryReader.Close();
        memoryStream.Close();
        return(true);
    }