public void Deserialize(NetDataReader reader) { TechBonuses = new PlayerTechBonuses(); Inventory = new StorageComponent(4); ReactorStorage = new StorageComponent(4); WarpStorage = new StorageComponent(1); Forge = new MechaForge(); Forge.tasks = new List <ForgeTask>(); Forge.extraItems = new ItemPack(); TechBonuses.Deserialize(reader); SandCount = reader.GetInt(); CoreEnergy = reader.GetDouble(); ReactorEnergy = reader.GetDouble(); bool isPayloadPresent = reader.GetBool(); if (isPayloadPresent) { int mechaLength = reader.GetInt(); byte[] mechaBytes = new byte[mechaLength]; reader.GetBytes(mechaBytes, mechaLength); using (MemoryStream ms = new MemoryStream(mechaBytes)) using (BinaryReader br = new BinaryReader(ms)) { Inventory.Import(br); ReactorStorage.Import(br); WarpStorage.Import(br); Forge.Import(br); } } }
public void Deserialize(NetDataReader reader) { Bounds = new Quad(reader.GetDouble(), reader.GetDouble(), reader.GetDouble()); Path = new PathString(); Path.Deserialize(reader); byte[] ipBytes = reader.GetBytesWithLength(); BusAddress = new IPAddress(ipBytes); BusPort = reader.GetUInt(); ApiUrl = reader.GetString(); }
public void Deserialize(NetDataReader reader) { Originator = reader.GetString(64); OriginatorAreaGain = reader.GetDouble(); int infoCount = reader.GetInt(); ShipsInfo = Enumerable.Range(0, infoCount).Select((i) => { Spaceship ship = new Spaceship(); ship.Deserialize(reader); return(new ShipInfo() { Ship = ship, Damage = reader.GetDouble(), }); }).ToList(); }
public void WriteReadDouble() { var ndw = new NetDataWriter(); ndw.Put(3.1415); var ndr = new NetDataReader(ndw.Data); var readDouble = ndr.GetDouble(); Assert.AreEqual(readDouble, 3.1415); }
public void Deserialize(NetDataReader reader) { Token = reader.GetString(); Energy = reader.GetDouble(); Area = reader.GetDouble(); Pos = new Vector2(reader.GetDouble(), reader.GetDouble()); ShieldDir = reader.GetDouble(); ShieldWidth = reader.GetDouble(); KillReward = reader.GetDouble(); }
public void Deserialize(NetDataReader reader) { Originator = reader.GetString(); Origin.X = reader.GetDouble(); Origin.Y = reader.GetDouble(); Direction = reader.GetDouble(); Width = reader.GetDouble(); Radius = reader.GetDouble(); ScaledShotEnergy = reader.GetDouble(); }
public static bool TryParse(byte[] data, out JoinSecret result, out Version version) { var reader = new NetDataReader(data); try { version = reader.GetVersion(); } catch { result = default; version = default; return(false); } IPEndPoint endPoint; Key32 key; double tickDeltaTime; try { endPoint = reader.GetIPEndPoint(); key = reader.GetKey32(); tickDeltaTime = reader.GetDouble(); } catch { result = default; return(false); } if (tickDeltaTime <= 0) { result = default; return(false); } result = new JoinSecret(version, endPoint, key, tickDeltaTime); if (reader.AvailableBytes > 0) { return(false); } return(true); }
public void Deserialize(NetDataReader reader) { X = reader.GetDouble(); Y = reader.GetDouble(); }
public override void Deserialize(NetDataReader reader) { Value = reader.GetDouble(); }
public override void ReadPayload(NetDataReader message) { base.ReadPayload(message); X = message.GetDouble(); Y = message.GetDouble(); }
public void Deserialize(NetDataReader reader) { Timestamp = reader.GetDouble(); Content = reader.Get <TContent>(); }
public void Deserialize(NetDataReader reader) { Timestamp = reader.GetDouble(); }
private static object GetObject(this NetDataReader reader, Type type) { if (type == null) { return(null); } if (type.GetInterface("INetSerializable") != null) { var result = (INetSerializable)Activator.CreateInstance(type); result.Deserialize(reader); return(result); } else if (type.GetInterface("ISyncObject") != null) { return(reader.GetByte()); } else if (type.IsEnum) { return(Enum.Parse(type, type.GetEnumName(reader.GetObject(type.GetEnumUnderlyingType())))); } else if (type == typeof(bool)) { return(reader.GetBool()); } else if (type == typeof(byte)) { return(reader.GetByte()); } else if (type == typeof(sbyte)) { return(reader.GetSByte()); } else if (type == typeof(char)) { return(reader.GetChar()); } else if (type == typeof(short)) { return(reader.GetShort()); } else if (type == typeof(ushort)) { return(reader.GetUShort()); } else if (type == typeof(int)) { return(reader.GetInt()); } else if (type == typeof(uint)) { return(reader.GetUInt()); } else if (type == typeof(long)) { return(reader.GetLong()); } else if (type == typeof(ulong)) { return(reader.GetULong()); } else if (type == typeof(float)) { return(reader.GetFloat()); } else if (type == typeof(double)) { return(reader.GetBool()); } else if (type == typeof(string)) { return(reader.GetDouble()); } else if (type == typeof(IPEndPoint)) { return(reader.GetNetEndPoint()); } else { throw new Exception("Unable to deserialize object of type " + type); } }
public void Deserialize(NetDataReader reader) { AccessKey = reader.GetKey32(); HostKey = reader.GetNullable <Key32>(NetDataReaderExtensions.GetKey32); ClientTime = reader.GetDouble(); }
/// <inheritdoc /> public virtual void TinyDeserialize(NetDataReader reader, bool firstStateUpdate) { if (firstStateUpdate) { NetworkID = reader.GetInt(); } if (!firstStateUpdate) { int dFlag = reader.GetInt(); TinyNetStateSyncer.IntToDirtyFlag(dFlag, _dirtyFlag); } Type type; int maxSyncVar = propertiesName.Length; for (int i = 0; i < maxSyncVar; i++) { if (!firstStateUpdate && _dirtyFlag[i] == false) { continue; } type = propertiesTypes[i]; if (type == typeof(byte)) { byteAccessor[propertiesName[i]].Set(this, reader.GetByte()); } else if (type == typeof(sbyte)) { sbyteAccessor[propertiesName[i]].Set(this, reader.GetSByte()); } else if (type == typeof(short)) { shortAccessor[propertiesName[i]].Set(this, reader.GetShort()); } else if (type == typeof(ushort)) { ushortAccessor[propertiesName[i]].Set(this, reader.GetUShort()); } else if (type == typeof(int)) { intAccessor[propertiesName[i]].Set(this, reader.GetInt()); } else if (type == typeof(uint)) { uintAccessor[propertiesName[i]].Set(this, reader.GetUInt()); } else if (type == typeof(long)) { longAccessor[propertiesName[i]].Set(this, reader.GetLong()); } else if (type == typeof(ulong)) { ulongAccessor[propertiesName[i]].Set(this, reader.GetULong()); } else if (type == typeof(float)) { floatAccessor[propertiesName[i]].Set(this, reader.GetFloat()); } else if (type == typeof(double)) { doubleAccessor[propertiesName[i]].Set(this, reader.GetDouble()); } else if (type == typeof(bool)) { boolAccessor[propertiesName[i]].Set(this, reader.GetBool()); } else if (type == typeof(string)) { stringAccessor[propertiesName[i]].Set(this, reader.GetString()); } } }
public void Deserialize(NetDataReader reader) { coreEnergyCap = reader.GetDouble(); corePowerGen = reader.GetDouble(); reactorPowerGen = reader.GetDouble(); walkPower = reader.GetDouble(); jumpEnergy = reader.GetDouble(); thrustPowerPerAcc = reader.GetDouble(); warpKeepingPowerPerSpeed = reader.GetDouble(); warpStartPowerPerSpeed = reader.GetDouble(); miningPower = reader.GetDouble(); replicatePower = reader.GetDouble(); researchPower = reader.GetDouble(); droneEjectEnergy = reader.GetDouble(); droneEnergyPerMeter = reader.GetDouble(); coreLevel = reader.GetInt(); thrusterLevel = reader.GetInt(); miningSpeed = reader.GetFloat(); replicateSpeed = reader.GetFloat(); walkSpeed = reader.GetFloat(); jumpSpeed = reader.GetFloat(); maxSailSpeed = reader.GetFloat(); maxWarpSpeed = reader.GetFloat(); buildArea = reader.GetFloat(); droneCount = reader.GetInt(); droneSpeed = reader.GetFloat(); droneMovement = reader.GetInt(); inventorySize = reader.GetInt(); }
public void Deserialize(NetDataReader reader) { Player = reader.GetInt(); TargetX = reader.GetDouble(); TargetY = reader.GetDouble(); }
public void Deserialize(NetDataReader reader) { x = reader.GetDouble(); y = reader.GetDouble(); z = reader.GetDouble(); }
public static JoinSecret GetJoinSecret(this NetDataReader @this) { return(new JoinSecret(@this.GetVersion(), @this.GetIPEndPoint(), @this.GetKey32(), @this.GetDouble())); }