public static PlaneInfo FromPlane(Plane plane) { PlaneInfo result = new PlaneInfo(plane.Name, plane.ChunkSize); result.Creators = plane.Creators; result.Members = plane.Members; return(result); }
/// <summary> /// Loads a plane from a given nplane file. /// </summary> /// <param name="planeDirectory">The directory from which the plane should be loaded.</param> /// <returns>The loaded plane.</returns> public static async Task <Plane> FromDirectory(string planeDirectory) { PlaneInfo planeInfo = JsonConvert.DeserializeObject <PlaneInfo>( File.ReadAllText(CalcPaths.PlaneIndex(planeDirectory)) ); Plane loadedPlane = new Plane(planeInfo, planeDirectory); // Load the primary chunks into the plane await loadedPlane.LoadPrimaryChunks(); return(loadedPlane); }
/// <summary> /// Initialises a new plane. /// </summary> /// <param name="inInfo">The settings to use to initialise the new plane.</param> /// <param name="inStorageDirectory">The storage directory in which we should store the plane's chunks (may be prepopulated).</param> public Plane(PlaneInfo inInfo, string inStorageDirectory) { Name = inInfo.Name; ChunkSize = inInfo.ChunkSize; StorageDirectory = inStorageDirectory; Creators = inInfo.Creators ?? new List <string>(); Members = inInfo.Members ?? new List <string>(); // Set the soft loaded chunk limit to double the number of chunks in the // primary chunks area // Note that the primary chunk area is a radius around (0, 0) - not the diameter SoftLoadedChunkLimit = PrimaryChunkAreaSize * PrimaryChunkAreaSize * 16; }
/// <summary> /// Creates a new plane, adds it to this RippleSpaceManager, and then returns it. /// </summary> /// <param name="newPlaneInfo">The settings for the new plane to create.</param> /// <returns>The newly created plane.</returns> public Plane CreatePlane(PlaneInfo newPlaneInfo) { if (this[newPlaneInfo.Name] != null) { throw new InvalidOperationException($"Error: A plane with the name '{newPlaneInfo.Name}' already exists in this RippleSpaceManager."); } Log.WriteLine("[RippleSpace] Creating plane {0}", newPlaneInfo.Name); Plane newPlane = new Plane( newPlaneInfo, CalcPaths.PlaneDirectory(SourceDirectory, newPlaneInfo.Name) ); Planes.Add(newPlane); return(newPlane); }