public override void Write(Library.Collections.BitStream stream, ref T?value, MySerializeInfo info) { if (value.HasValue) { T val = value.Value; stream.WriteBool(true); m_serializer.Write(stream, ref val, info); } else { stream.WriteBool(false); } }
public override void Write(Library.Collections.BitStream stream, ref Quaternion value, MySerializeInfo info) { if (info.IsNormalized) { stream.WriteBool(value.W < 0.0f); stream.WriteBool(value.X < 0.0f); stream.WriteBool(value.Y < 0.0f); stream.WriteBool(value.Z < 0.0f); stream.WriteUInt16((ushort)(Math.Abs(value.X) * 65535.0)); stream.WriteUInt16((ushort)(Math.Abs(value.Y) * 65535.0)); stream.WriteUInt16((ushort)(Math.Abs(value.Z) * 65535.0)); } else { Debug.Fail("Not normalized quaternion?"); stream.WriteFloat(value.X); stream.WriteFloat(value.Y); stream.WriteFloat(value.Z); stream.WriteFloat(value.W); } }
public override void Write(Library.Collections.BitStream stream, ref TEnum value, MySerializeInfo info) { ulong val = MyEnum <TEnum> .GetValue(value); if (m_valueCount == 2) { stream.WriteBool(val == m_firstUlong); } else if (m_valueCount > 2) { if (HasNegativeValues) { stream.WriteVariantSigned((long)val); } else { stream.WriteUInt64(val, m_bitCount); } } }
public override void Write(Library.Collections.BitStream stream, ref bool value, MySerializeInfo info) { stream.WriteBool(value); }