protected void LoadAround(Point3i position)
 {
     foreach (var chunk in Chunks(position))
     {
         LoadAt(chunk);
     }
 }
        protected void Save(Point3i position, object @object)
        {
            Debug.WriteLine("Save {0}: {1}", position, @object);
            var directory = DirectoryInfo(position);

            if (!directory.Exists)
            {
                directory.Create();
            }

            var file = new FileSystem(String.Format("{0}/{1}.xml", directory, @object.GetHashCode()));

            file.Save(@object);
        }
        public IEnumerable <Point3i> Chunks(Point3i position)
        {
            var c = (int)Math.Ceiling((double)LOADED_RADIUS / CHUNK_SIZE);

            for (var x = -c; x <= c; x++)
            {
                for (var y = -c; y <= c; y++)
                {
                    for (var z = -c; z <= c; z++)
                    {
                        yield return(new Point3i(position.X + x, position.Y + y, position.Z + z));
                    }
                }
            }
        }
        protected void LoadAt(Point3i position)
        {
            var directory_info = DirectoryInfo(position);

            if (!directory_info.Exists)
            {
                return;
            }

            lock (loader_lock)
            {
                foreach (var file_info in directory_info.GetFiles("*.xml"))
                {
                    Debug.WriteLine("Load {0}: {1}", position, file_info.FullName);
                    var file   = new FileSystem(file_info.FullName);
                    var entity = file.Load <Entity>();
                    file_info.Delete();
                    loader_entities.Add(entity);
                }
            }
        }
 public bool Equals(Point3i other)
 {
     return(X == other.X && Y == other.Y && Z == other.Z);
 }
 protected DirectoryInfo DirectoryInfo(Point3i position)
 {
     return(new DirectoryInfo(DirectoryName(position)));
 }
 protected string DirectoryName(Point3i position)
 {
     return(String.Format("Savegames/{0}.{1}.{2}/", position.X, position.Y, position.Z));
 }