Esempio n. 1
0
        public Chunk LoadChunk(int x, int y)
        {
            //Get the megachunk coordinates
            int mx = (int)Math.Floor(x / (float)Megachunk.SIZE);
            int my = (int)Math.Floor(y / (float)Megachunk.SIZE);


            //Get the megachunk if in memory
            Megachunk mc = megachunks.Get(mx, my);

            if (mc == null)
            {
                mc = LoadMegachunk(mx, my);
            }
            else
            {
                if (mc.IsClosing)
                {
                    mc.PleaseDontClose = true;
                }
            }

            //Get the chunk from within the megachunk
            Chunk c = mc.GetChunk(Tools.Mod(x, Megachunk.SIZE), Tools.Mod(y, Megachunk.SIZE));

            return(c);
        }
Esempio n. 2
0
        public void UnloadChunk(Chunk chunk)
        {
            int mx = (int)Math.Floor(chunk.pos.X / (float)Megachunk.SIZE);
            int my = (int)Math.Floor(chunk.pos.Y / (float)Megachunk.SIZE);

            Megachunk mc = megachunks.Get(mx, my);

            mc.UnloadChunk(Tools.Mod(chunk.pos.X, Megachunk.SIZE), Tools.Mod(chunk.pos.Y, Megachunk.SIZE));
        }
Esempio n. 3
0
        public Megachunk LoadMegachunk(int x, int y)
        {
            Megachunk mc = null;

            mc = new Megachunk(x, y, graphicsDevice, generator, () => {
                megachunks.Remove(x, y);
            });
            megachunks.Add(x, y, mc);
            return(mc);
        }