示例#1
0
        void ExpandMap()
        {
            HashSet <Int2> _cover = new HashSet <Int2>();

            foreach (var playerInfo in activatedPlayers.Values)
            {
                Int3 p  = playerInfo.PositionI;
                Int2 p1 = new Int2(p.X, p.Z).AlignedDown(16);
                for (int x = -192; x <= 192; x += 16)
                {
                    for (int y = -192; y <= 192; y += 16)
                    {
                        _cover.Add(new Int2(p1.X + x, p1.Y + y));
                    }
                }
            }
            Parallel.ForEach(_cover, (Int2 p64) =>
            {
                int filledCount = 0;
                Int2 position   = new Int2(p64.X, p64.Y);
                if (!this.regionInfos.TryGetValue(position, out var regionInfo) || !regionInfo.m_generatorFilled)
                {
                    chunkGenerator.FillRegion(position.X, position.Y, this);
                }
                else
                {
                    filledCount++;
                }
            });
            _cover.Clear();
        }
示例#2
0
 void ExpandMap()
 {
     foreach (var playerInfo in gameContext.playerInfos.Values)
     {
         INT3 p  = playerInfo.positionI;
         INT2 p1 = new INT2(p.x, p.z).AlignedDown(64);
         for (int x = -192; x < 256; x += 64)
         {
             for (int y = -192; y < 256; y += 64)
             {
                 cover64.Add(new INT2(p1.x + x, p1.y + y));
             }
         }
     }
     foreach (var p64 in cover64)
     {
         int filledCount = 0;
         if (gameContext.regionInfo64.TryGetValue(p64, out var regionInfo64))
         {
             if (regionInfo64.m_generatorFilled)
             {
                 continue;
             }
         }
         else
         {
             regionInfo64 = new RegionInfo();
             gameContext.regionInfo64[p64] = regionInfo64;
         }
         for (int x = 0; x < 64; x += 16)
         {
             for (int y = 0; y < 64; y += 16)
             {
                 INT2 position = new INT2(p64.x + x, p64.y + y);
                 if (!gameContext.regionInfo.TryGetValue(position, out var regionInfo) || !regionInfo.m_generatorFilled)
                 {
                     chunkGenerator.FillRegion(position.x, position.y, gameContext);
                 }
                 else
                 {
                     filledCount++;
                 }
             }
         }
         if (filledCount == 16)
         {
             regionInfo64.m_generatorFilled = true;
         }
     }
     cover64.Clear();
 }