using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace WOMGeneral { public class Address { public int cellX = 0; public int cellY = 0; public int x = 0; public int y = 0; public Address(int cellX, int cellY, int x, int y) { this.cellX = cellX; this.cellY = cellY; this.x = x; this.y = y; } public Address(byte[] serialized) { this.cellX = UtilBase.ReadTwoBytes(serialized[0], serialized[1]); this.cellY = UtilBase.ReadTwoBytes(serialized[2], serialized[3]); if (serialized.Length > 4) { this.x = serialized[4]; this.y = serialized[5]; } } public byte[] Serialize(bool includeXY = true) { if (includeXY) { return UtilBase.MergeArrays(new byte[][] { UtilBase.WriteTwoBytes(cellX), UtilBase.WriteTwoBytes(cellY), new byte[] { (byte)x }, new byte[] { (byte)y } }); } else { return UtilBase.MergeArrays(new byte[][] { UtilBase.WriteTwoBytes(cellX), UtilBase.WriteTwoBytes(cellY) }); } } } }