public static byte[] Serialize(this Vector3 v) { byte[] mem = new byte[4 * 3], xBin = BitConverterFloat.HostToNetworkOrder(v.x), yBin = BitConverterFloat.HostToNetworkOrder(v.y), zBin = BitConverterFloat.HostToNetworkOrder(v.z); xBin.CopyTo(mem, 0); yBin.CopyTo(mem, 4); zBin.CopyTo(mem, 8); return(mem); }
public byte[] Serialize() { byte[] mem = new byte[4 * 8 + 1], teamBin = BitConverter.GetBytes((byte)team), teammateHealthDeltaBin = BitConverterFloat.HostToNetworkOrder(teammateHealthDelta), enemyHealthDeltaBin = BitConverterFloat.HostToNetworkOrder(enemyHealthDelta), teammateKnockbackBin = BitConverterFloat.HostToNetworkOrder(teammateKnockback), enemyKnockbackBin = BitConverterFloat.HostToNetworkOrder(enemyKnockback), senderIdBin = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(senderId)), directionBin = direction.Serialize(); teamBin.CopyTo(mem, 0); teammateHealthDeltaBin.CopyTo(mem, 1); enemyHealthDeltaBin.CopyTo(mem, 5); teammateKnockbackBin.CopyTo(mem, 9); enemyKnockbackBin.CopyTo(mem, 13); senderIdBin.CopyTo(mem, 17); directionBin.CopyTo(mem, 21); return(mem); }