Пример #1
0
        public static void OnOutputFinalized_WriteLocksInThread(Type type, TileData tileData, IApplyData applyData, StopToken stop)
        {
            Dictionary <Lock, LockDataSet> lockDatasDict;

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

            foreach (var kvp in lockDatasDict)
            {
                Lock        lk       = kvp.Key;
                LockDataSet lockData = kvp.Value;

                if (!lk.locked)
                {
                    continue;
                }

                bool relativeHeight = lk.relativeHeight;
                if (lk.IsIntersecting(tileData.area.active) && !lk.IsContained(tileData.area.active))
                {
                    relativeHeight = false;
                }

                lockData.WriteInThread(applyData, relativeHeight);
            }
        }
Пример #2
0
        /*public void Process (Dictionary<Type,IApplyData> apply, float heightDelta)
         * {
         *      for (int i=0; i<lockDatas.Length; i++)
         *              lockDatas[i].Process(apply, heightDelta);
         * }*/

        public static void Resize(LockDataSet src, LockDataSet dst)
        {
            for (int i = 0; i < dst.lockDatas.Length; i++)
            {
                dst.lockDatas[i].ResizeFrom(src.lockDatas[i]);
            }
        }
Пример #3
0
        public static void OnGenerateStarted_ResizeDrafts(TerrainTile tile, TileData draftTileData, StopToken stop)
        {
            if (!draftTileData.isDraft)
            {
                return;
            }

            TileData mainTileData = tile.main?.data;

            if (mainTileData == null)
            {
                return;
            }

            if (!lockDatas.TryGetValue(draftTileData, out Dictionary <Lock, LockDataSet> draftLockDatasDict))
            {
                return;
            }
            if (!lockDatas.TryGetValue(mainTileData, out Dictionary <Lock, LockDataSet> mainLockDatasDict))
            {
                return;
            }

            foreach (var kvp in draftLockDatasDict)
            {
                Lock lk = kvp.Key;
                if (!lk.rescaleDraft)
                {
                    continue;
                }

                LockDataSet draftLockData = kvp.Value;
                LockDataSet mainLockData;

                if (!mainLockDatasDict.TryGetValue(lk, out mainLockData))
                {
                    continue;
                }

                LockDataSet.Resize(mainLockData, draftLockData);
            }
        }
Пример #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);
            }
        }