Beispiel #1
0
        public void Serialize(BinaryWriter writer)
        {
            writer.Write((byte)Type);

            switch (Type)
            {
            case Types.Null:
                break;

            case Types.LocalCoreUUID:
            case Types.UUIDRef:
                GUID.ToData(writer);
                break;

            case Types.ExternalCoreUUID:
            case Types.StreamingRef:
                GUID.ToData(writer);

                ExternalFile.Serialize(writer);
                break;

            default:
                throw new NotImplementedException();
            }
        }
        public void SerializeExtraData(BinaryWriter writer)
        {
            var dataFormat = Buffer.Format switch
            {
                EDataBufferFormat.R_UINT_16 => EIndexFormat.Index16,
                EDataBufferFormat.R_UINT_32 => EIndexFormat.Index32,
                _ => throw new NotSupportedException("Unknown index buffer type"),
            };

            uint elementCount = Buffer?.ElementCount ?? 0;

            writer.Write(elementCount);

            if (elementCount > 0)
            {
                writer.Write(Flags);
                writer.Write((uint)dataFormat);
                writer.Write((uint)(Buffer.IsStreamed() ? 1 : 0));
                ResourceGUID.ToData(writer);
                Buffer.ToData(writer);
            }
        }