Beispiel #1
0
        public void RefreshImmediately(int cx, int cz)
        {
            mIO.StopProcess();

            Clear();

            mReqsOutput.Clear();

            int expand = mEvni.DataExpandNum;

            for (int i = cx - expand; i <= cx + expand; i++)
            {
                for (int j = cz - expand; j <= cz + expand; j++)
                {
                    RGChunk chunk = RGPoolSig.GetChunk();
                    chunk.Init(i, j, mEvni);
                    mReqsOutput.reqsChunk.Add(chunk);
                }
            }

            mIO.AddReqs(mReqsOutput.reqsChunk);
            mIO.ProcessReqsImmediatly();

            foreach (RGChunk chunk in mReqsOutput.reqsChunk)
            {
                if (chunk.isEmpty)
                {
                    continue;
                }
                mChunks[chunk.xIndex, chunk.zIndex] = chunk;
            }

            mCenter = new INTVECTOR2(cx, cz);
        }
Beispiel #2
0
        public bool Write(RedGrassInstance rgi)
        {
            Vector3 pos = rgi.Position;

            int cx = (int)pos.x >> SHIFT;
            int cz = (int)pos.z >> SHIFT;

            RGChunk chunk = mChunks [cx, cz];

            if (chunk != null)
            {
                if (rgi.Density < 0.001f)
                {
                    chunk.Remove((int)pos.x, (int)pos.y, (int)pos.z);
                }
                else
                {
                    chunk.Write(rgi);
                }
            }
            else
            {
                if (rgi.Density > 0.001f)
                {
                    chunk = RGPoolSig.GetChunk();
                    chunk.Init(cx, cz, mEvni);
                    mChunks[cx, cz] = chunk;
                    chunk.Write(rgi);
                }
            }

            return(true);
        }
Beispiel #3
0
        public void ReqsUpdate(int cx, int cz)
        {
            Profiler.BeginSample("Req");
            mReqsOutput.Clear();

            IsProcessReqs = true;


            // Find the loading chunk
            int expand = mEvni.DataExpandNum;

            for (int i = cx - expand; i <= cx + expand; i++)
            {
                for (int j = cz - expand; j <= cz + expand; j++)
                {
                    if (!mChunks.Contains(i, j))
                    {
                        RGChunk chunk = RGPoolSig.GetChunk();
                        chunk.Init(i, j, mEvni);
                        mReqsOutput.reqsChunk.Add(chunk);
                    }
                }
            }

            if (mReqsOutput.reqsChunk.Count != 0)
            {
                mIO.AddReqs(mReqsOutput.reqsChunk);
            }

            // Descarding part
            int max_new_x = cx + expand;
            int min_new_x = cx - expand;
            int max_new_z = cz + expand;
            int min_new_z = cz - expand;

            for (int i = mCenter.x - expand; i <= mCenter.x + expand; i++)
            {
                for (int j = mCenter.y - expand; j <= mCenter.y + expand; j++)
                {
                    if (i < min_new_x || i > max_new_x ||
                        j < min_new_z || j > max_new_z)
                    {
                        RGChunk chunk = mChunks[i, j];
                        if (chunk != null)
                        {
                            mReqsOutput.discardChunk.Add(chunk);
                        }
                    }
                }
            }


            if (mReqsOutput.reqsChunk.Count != 0 || mReqsOutput.discardChunk.Count != 0)
            {
                // Activate the DataIO
                mIO.Active(delegate() {
                    IsProcessReqs = false;
                });
            }
            Profiler.EndSample();
        }