mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
Get chunks and references serialising correctly
This commit is contained in:
parent
db4a9311d5
commit
a7132d344d
3 changed files with 32 additions and 1 deletions
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
|||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Nibriboard.RippleSpace
|
||||
{
|
||||
|
@ -37,6 +38,7 @@ namespace Nibriboard.RippleSpace
|
|||
/// Represents a single chunk of an infinite <see cref="NibriboardServer.RippleSpace.Plane" />.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class Chunk : IEnumerable<DrawnLine>, IDeserializationCallback
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -47,7 +49,8 @@ namespace Nibriboard.RippleSpace
|
|||
/// <summary>
|
||||
/// The name of the plane that this chunk is on.
|
||||
/// </summary>
|
||||
/// <value>The name of the plane.</value>
|
||||
/// <value>The name of the plane.</value>
|
||||
[JsonProperty]
|
||||
public string PlaneName {
|
||||
get {
|
||||
return plane.Name;
|
||||
|
@ -57,16 +60,19 @@ namespace Nibriboard.RippleSpace
|
|||
/// <summary>
|
||||
/// The lines that this chunk currently contains.
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
private List<DrawnLine> lines = new List<DrawnLine>();
|
||||
|
||||
/// <summary>
|
||||
/// The size of this chunk.
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public readonly int Size;
|
||||
|
||||
/// <summary>
|
||||
/// The location of this chunk, in chunk-space, on the plane.
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public readonly ChunkReference Location;
|
||||
|
||||
/// <summary>
|
||||
|
@ -86,6 +92,7 @@ namespace Nibriboard.RippleSpace
|
|||
/// Whether this <see cref="T:Nibriboard.RippleSpace.Chunk"/> is primary chunk.
|
||||
/// Primary chunks are always loaded.
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public bool IsPrimaryChunk
|
||||
{
|
||||
get {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
using SBRL.Utilities;
|
||||
|
||||
namespace Nibriboard.RippleSpace
|
||||
|
|
|
@ -1,15 +1,38 @@
|
|||
using System;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Nibriboard.RippleSpace
|
||||
{
|
||||
/// <summary>
|
||||
/// An abstract class representing a coordinate reference to a location.
|
||||
/// </summary>
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public abstract class Reference : ICloneable
|
||||
{
|
||||
public readonly Plane Plane;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the plane that this reference is located on.
|
||||
/// Mainly used by the serialisation system that sends things to the client.
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public string PlaneName
|
||||
{
|
||||
get {
|
||||
return Plane.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The x position of this reference.
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public int X { get; set; }
|
||||
/// <summary>
|
||||
/// The y position of this reference.
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public int Y { get; set; }
|
||||
|
||||
public Reference(Plane inPlane, int inX, int inY)
|
||||
|
|
Loading…
Reference in a new issue