コード例 #1
0
ファイル: MapLowManager.cs プロジェクト: veserine/Neo
        private void LoadProc()
        {
            while (mIsRunning)
            {
                MapAreaLowRender item = null;
                lock (mDataToLoad)
                {
                    if (mDataToLoad.Count > 0)
                    {
                        item = mDataToLoad[0];
                        mDataToLoad.RemoveAt(0);
                    }
                }

                if (item == null)
                {
                    Thread.Sleep(30);
                    continue;
                }

                item.InitFromHeightData(mWdlFile.GetEntry(item.IndexX, item.IndexY));
                lock (mLoadedData)
                    mLoadedData.Add(item);
            }
        }
コード例 #2
0
ファイル: MapLowManager.cs プロジェクト: veserine/Neo
        public void UpdatePosition(ref Vector2 position)
        {
            var cx = position.X;
            var cy = position.Y;

            if (IO.FileManager.Instance.Version < IO.FileDataVersion.Lichking)
            {
                cy = 64.0f * Metrics.TileSize - cy;
            }

            var ix = (int)Math.Floor(cx / Metrics.TileSize);
            var iy = (int)Math.Floor(cy / Metrics.TileSize);

            var oldCount = mCurrentValidLinks.Count;

            mCurrentValidLinks.RemoveAll(index =>
            {
                var x = index % 0xFF;
                var y = index / 0xFF;
                return(x > ix + 4 || x < ix - 4 || y > iy + 4 || y < iy - 4);
            });

            if (oldCount == mCurrentValidLinks.Count && oldCount != 0)
            {
                return;
            }

            mCurrentValidLinks.Clear();
            for (var x = ix - 4; x <= ix + 4; ++x)
            {
                for (var y = iy - 4; y <= iy + 4; ++y)
                {
                    if (x < 0 || y < 0 || x > 63 || y > 63)
                    {
                        continue;
                    }

                    mCurrentValidLinks.Add(y * 0xFF + x);
                }
            }

            var loadMask    = new List <int>();
            var invalidList = new List <MapAreaLowRender>();

            foreach (var tile in mAreas)
            {
                var index  = tile.IndexX + tile.IndexY * 0xFF;
                var indexX = tile.IndexX;
                var indexY = tile.IndexY;
                if (indexX < ix - 4 || indexX > ix + 4 || indexY < iy - 4 || indexY > iy + 4)
                {
                    invalidList.Add(tile);
                    continue;
                }

                loadMask.Add(index);
            }

            lock (mUnloadAreas)
            {
                foreach (var area in invalidList)
                {
                    mAreas.Remove(area);
                    mUnloadAreas.Add(area);
                }
            }

            lock (mDataToLoad)
            {
                loadMask.AddRange(mDataToLoad.Select(tile => tile.IndexX + tile.IndexY * 0xFF));
            }

            foreach (var link in mCurrentValidLinks.Where(i => loadMask.Contains(i) == false))
            {
                var x = link % 0xFF;
                var y = link / 0xFF;

                var provider = new MapAreaLowRender(x, y);
                lock (mDataToLoad)
                    mDataToLoad.Add(provider);
            }
        }
コード例 #3
0
ファイル: MapLowManager.cs プロジェクト: Linrasis/WoWEditor
        public void UpdatePosition(ref Vector2 position)
        {
            var cx = position.X;
            var cy = position.Y;

            if (IO.FileManager.Instance.Version < IO.FileDataVersion.Lichking)
                cy = 64.0f * Metrics.TileSize - cy;

            var ix = (int)Math.Floor(cx / Metrics.TileSize);
            var iy = (int)Math.Floor(cy / Metrics.TileSize);

            var oldCount = mCurrentValidLinks.Count;
            mCurrentValidLinks.RemoveAll(index =>
            {
                var x = index % 0xFF;
                var y = index / 0xFF;
                return (x > ix + 4 || x < ix - 4 || y > iy + 4 || y < iy - 4);
            });

            if (oldCount == mCurrentValidLinks.Count && oldCount != 0)
                return;

            mCurrentValidLinks.Clear();
            for (var x = ix - 4; x <= ix + 4; ++x)
            {
                for (var y = iy - 4; y <= iy + 4; ++y)
                {
                    if (x < 0 || y < 0 || x > 63 || y > 63)
                        continue;

                    mCurrentValidLinks.Add(y * 0xFF + x);
                }
            }

            var loadMask = new List<int>();
            var invalidList = new List<MapAreaLowRender>();
            foreach (var tile in mAreas)
            {
                var index = tile.IndexX + tile.IndexY * 0xFF;
                var indexX = tile.IndexX;
                var indexY = tile.IndexY;
                if (indexX < ix - 4 || indexX > ix + 4 || indexY < iy - 4 || indexY > iy + 4)
                {
                    invalidList.Add(tile);
                    continue;
                }

                loadMask.Add(index);
            }

            lock(mUnloadAreas)
            {
                foreach(var area in invalidList)
                {
                    mAreas.Remove(area);
                    mUnloadAreas.Add(area);
                }
            }

            lock(mDataToLoad)
            {
                loadMask.AddRange(mDataToLoad.Select(tile => tile.IndexX + tile.IndexY * 0xFF));
            }

            foreach(var link in mCurrentValidLinks.Where(i => loadMask.Contains(i) == false))
            {
                var x = link % 0xFF;
                var y = link / 0xFF;

                var provider = new MapAreaLowRender(x, y);
                lock (mDataToLoad)
                    mDataToLoad.Add(provider);
            }
        }