public override void Serialize(LittleEndianWriter writer) { writer.WriteShort((short)1); // Number of dashes writer.WriteByte((byte)4); // Waypoints size * 2 writer.WriteUInt((uint)sourceNetId); writer.WriteFloat((float)dashSpeed); writer.WriteFloat((float)leapHeight); writer.WriteFloat((float)unitPosition.X); writer.WriteFloat((float)unitPosition.Y); writer.WriteByte((byte)(keepFacingLastDirection ? 0x01 : 0x00)); writer.WriteUInt(targetNetId); writer.WriteFloat((float)followTargetMaxDistance); writer.WriteFloat((float)backDistance); writer.WriteFloat((float)travelTime); var waypoints = new List <Vector2> { new Vector2(unitPosition.X, unitPosition.Y), new Vector2(targetPosition.X, targetPosition.Y) }; writer.WriteBytes(MovementVector.EncodeWaypoints(waypoints.ToArray(), mapSize)); }
public static void WriteCompressedWaypoints(this LittleEndianWriter writer, GridPosition[] data) { int size = data.Length; if (size < 1) { throw new IOException("Need at least 1 waypoint!"); } byte[] flagsBuffer; if (size > 1) { flagsBuffer = new byte[(size - 2) / 4 + 1u]; } else { flagsBuffer = new byte[0]; } var flags = new BitArray(flagsBuffer); for (int i = 1, flag = 0; i < size; i++) { int relativeX = data[i].X - data[i - 1].X; flags[flag] = (relativeX <= SByte.MaxValue && relativeX >= SByte.MinValue); flag++; int realtiveZ = data[i].Y - data[i - 1].Y; flags[flag] = (realtiveZ <= SByte.MaxValue && realtiveZ >= SByte.MinValue); flag++; } flags.CopyTo(flagsBuffer, 0); writer.WriteBytes(flagsBuffer); writer.WriteShort(data[0].X); writer.WriteShort(data[0].Y); for (int i = 1, flag = 0; i < size; i++) { if (flags[flag]) { writer.WriteSByte((SByte)(data[i].X - data[i - 1].X)); } else { writer.WriteShort(data[i].X); } flag++; if (flags[flag]) { writer.WriteSByte((SByte)(data[i].Y - data[i - 1].Y)); } else { writer.WriteShort(data[i].Y); } flag++; } }
/// <summary> /// Writes this <see cref="MOBObject"/> into a <see cref="BinaryWriter"/> /// </summary> /// <param name="writer">The <see cref="BinaryWriter"/> to write to</param> public void Write(LittleEndianWriter writer) { writer.WriteBytes(Encoding.ASCII.GetBytes(this.Name.PadRight(60, '\u0000'))); writer.WriteUShort((ushort)0); writer.WriteUShort((ushort)this.Type); this.Position.Serialize(writer); this.Rotation.Serialize(writer); this.Scale.Serialize(writer); this.ReservedVector1.Serialize(writer); this.ReservedVector2.Serialize(writer); writer.WriteByte(0); }
/// <summary> /// Writes this <see cref="MOBFile"/> into a <see cref="Stream"/> /// </summary> /// <param name="stream">The <see cref="Stream"/> to write to</param> public void Write(Stream stream) { using (LittleEndianWriter bw = new LittleEndianWriter(stream)) { bw.WriteBytes(Encoding.ASCII.GetBytes("OPAM")); bw.WriteUInt((uint)2); bw.WriteInt(this.Objects.Count); bw.WriteUInt((uint)0); foreach (MOBObject mobObject in this.Objects) { mobObject.Write(bw); } } }
public override void Serialize(LittleEndianWriter writer) { writer.WriteInt(playerId); writer.WriteInt(botNetId); writer.WriteByte(isBotMessage); writer.WriteInt((int)channel); writer.WriteInt(unk1); writer.WriteInt(length); writer.WriteBytes(unk2); foreach (var b in Encoding.UTF8.GetBytes(content)) { writer.WriteByte((byte)b); } writer.WriteByte(0); }
} //42-46 public void Serialize(LittleEndianWriter writer2) { byte[] buffer; using (var stream = new MemoryStream()) { using (var writer = new LittleEndianWriter(stream)) { writer.WriteUInt(SpellHash); writer.WriteUInt(SpellNetID); writer.WriteByte(SpellLevel); writer.WriteFloat(AttackSpeedModifier); writer.WriteUInt(CasterNetID); writer.WriteUInt(SpellChainOwnerNetID); writer.WriteUInt(PackageHash); writer.WriteUInt(MissileNetID); TargetPosition.Serialize(writer); TargetPositionEnd.Serialize(writer); int targetCount = Targets.Count; if (targetCount > 32) { throw new IOException("CastInfo targets > 32!!!"); } writer.WriteByte((byte)targetCount); foreach (var target in Targets) { writer.WriteUInt(target.Item1); writer.WriteByte((byte)target.Item2); } writer.WriteFloat(DesignerCastTime); writer.WriteFloat(ExtraCastTime); writer.WriteFloat(DesignerTotalTime); writer.WriteFloat(Cooldown); writer.WriteFloat(StartCastTime); byte bitfield = 0; if (IsAutoAttack) { bitfield |= 1; } if (IsSecondAutoAttack) { bitfield |= 2; } if (IsForceCastingOrChannel) { bitfield |= 4; } if (IsOverrideCastPosition) { bitfield |= 8; } if (IsClickCasted) { bitfield |= 16; } writer.WriteByte(bitfield); writer.WriteByte(SpellSlot); writer.WriteFloat(ManaCost); SpellCastLaunchPosition.Serialize(writer); writer.WriteInt(AmmoUsed); writer.WriteFloat(AmmoRechargeTime); } buffer = new byte[stream.Length]; var data = stream.GetBuffer(); Buffer.BlockCopy(data, 0, buffer, 0, buffer.Length); } writer2.WriteUShort((ushort)(buffer.Length + 2)); writer2.WriteBytes(buffer); }
public override void Serialize(LittleEndianWriter writer) { writer.WriteBytes(Data); }
public override void Serialize(LittleEndianWriter writer) { writer.WriteInt(unk1); writer.WriteBytes(version); }
public override void Serialize(LittleEndianWriter writer) { int syncId = Environment.TickCount; writer.WriteInt(syncId); // syncID writer.WriteByte((byte)1); // updating 1 unit uint masterMask = 0; for (var i = 0; i < 6; i++) { for (var j = 0; j < 32; j++) { var rep = values[i, j]; if (rep == null || (!rep.Changed && partial)) { continue; } masterMask |= 1u << i; break; } } writer.WriteByte((byte)masterMask); writer.WriteUInt((uint)actorNetId); for (var i = 0; i < 6; i++) { uint fieldMask = 0; var stream = new MemoryStream(); var w = new LittleEndianWriter(stream); for (var j = 0; j < 32; j++) { var rep = values[i, j]; if (rep == null || (!rep.Changed && partial)) { continue; } fieldMask |= 1u << j; if (rep.IsFloat) { var source = BitConverter.GetBytes(rep.Value); if (source[0] >= 0xFE) { w.WriteByte((byte)0xFE); } w.WriteBytes(source); } else { uint num = rep.Value; while (num >= 0x80) { w.WriteByte((byte)(num | 0x80)); num >>= 7; } w.WriteByte((byte)num); } } var data = stream.ToArray(); if (data.Length > 0) { writer.WriteUInt(fieldMask); writer.WriteByte((byte)data.Length); writer.WriteBytes(data); } } }