Esempio n. 1
0
        private static void UpdateTile_OnTileApplied(TerrainTile tile, Products.TileData tileData, Products.StopToken stop)
        {
            Terrain terrain = tile.GetTerrain(tileData.isDraft);

            if (terrain == null)
            {
                return;                                      //seems to be happen when stopping playmode while tile generating
            }
            if (!terrainLinesCache.TryGetValue(terrain, out PolyLine polyLine))
            {
                polyLine = CreateTerrainLine(terrain);
                terrainLinesCache.Add(terrain, polyLine);
            }

            else
            {
                Vector3[] lineArr = CreateLinePoints(terrain);
                if (polyLine.MaxPoints < lineArr.Length)
                {
                    polyLine = CreateTerrainLine(terrain);
                    terrainLinesCache.Remove(terrain);
                    terrainLinesCache.Add(terrain, polyLine);
                }

                else
                {
                    polyLine.SetPoints(lineArr);
                }
            }
        }
        private static void UpdateTile_OnTileApplied(TerrainTile tile, Products.TileData tileData, Products.StopToken stop)
        {
            Terrain terrain = tile.GetTerrain(tileData.isDraft);

            if (!terrainLinesCache.TryGetValue(terrain, out PolyLine polyLine))
            {
                polyLine = CreateTerrainLine(terrain);
                terrainLinesCache.Add(terrain, polyLine);
            }

            else
            {
                Vector3[] lineArr = CreateLinePoints(terrain);
                if (polyLine.MaxPoints < lineArr.Length)
                {
                    polyLine = CreateTerrainLine(terrain);
                    terrainLinesCache.Remove(terrain);
                    terrainLinesCache.Add(terrain, polyLine);
                }

                else
                {
                    polyLine.SetPoints(lineArr);
                }
            }
        }
Esempio n. 3
0
        public static void OnTileApplied_WriteLocksInApply(TerrainTile tile, TileData tileData, StopToken stop)
        {
            Dictionary <Lock, LockDataSet> lockDatasDict;

            if (!lockDatas.TryGetValue(tileData, out lockDatasDict))
            {
                return;
            }

            Terrain terrain = tile.GetTerrain(tileData.isDraft);

            foreach (LockDataSet lockData in lockDatasDict.Values)
            {
                lockData.WriteInApply(terrain);
            }

            if (!tileData.isDraft)
            {
                lockDatas.Remove(tileData);
            }
            //leaving lock data for draft since it might be currently generating and nearly applyied (and there is no data left!)
        }
Esempio n. 4
0
        public static void OnTilePrepare_ReadLocks(TerrainTile tile, TileData tileData)
        {
            //finding locks intersecting tile
            List <Lock> intersectingLocks = null;

            Lock[] allLocks = tile.mapMagic.locks;
            for (int i = 0; i < allLocks.Length; i++)
            {
                if (!allLocks[i].locked)
                {
                    continue;
                }
                if (!allLocks[i].IsIntersecting(tileData.area.active))
                {
                    continue;
                }
                if (tileData.isDraft && !allLocks[i].rescaleDraft)
                {
                    continue;
                }

                if (intersectingLocks == null)
                {
                    intersectingLocks = new List <Lock>();
                }
                intersectingLocks.Add(allLocks[i]);
            }

            if (intersectingLocks == null)                     //no locks on this tile
            {
                return;
            }

            //preparing lock-to-data dict
            Dictionary <Lock, LockDataSet> lockDatasDict;

            if (!lockDatas.TryGetValue(tileData, out lockDatasDict))
            {
                lockDatasDict = new Dictionary <Lock, LockDataSet>();
                lockDatas.Add(tileData, lockDatasDict);
            }

            //writing locks
            Terrain terrain = tile.GetTerrain(tileData.isDraft);

            int intersectingCount = intersectingLocks.Count;

            for (int i = 0; i < intersectingCount; i++)
            {
                Lock lk = intersectingLocks[i];

                if (lockDatasDict.ContainsKey(lk))
                {
                    continue;
                }
                //do not read anything if already contains data ?

                LockDataSet lockData = new LockDataSet();
                lockData.Read(terrain, lk);
                lockDatasDict.Add(lk, lockData);
            }
        }