예제 #1
0
        private static void WriteFrame(BinaryWriter writer, Animation.Frame frame)
        {
            if (frame.layerMetadata.count != frame.layers.Count)
            {
                throw new System.Exception("Recorded layer count must match number of written layers.");
            }

            frame.layerMetadata.Serialize(writer);
            frame.unknownBitfield.Serialize(writer);

            if (frame.layerMetadata.bReadOptionalData != 0)
            {
                writer.Write(frame.optional1);
                writer.Write(frame.optional2);
            }

            if (frame.unknownBitfield.bReadOptionalData != 0)
            {
                writer.Write(frame.optional3);
                writer.Write(frame.optional4);
            }

            for (int i = 0; i < frame.layers.Count; ++i)
            {
                frame.layers[i].Serialize(writer);
            }
        }
예제 #2
0
        private static Animation.Frame ReadFrame(BinaryReader reader)
        {
            Animation.Frame frame = new Animation.Frame();
            frame.optional1 = 0;
            frame.optional2 = 0;
            frame.optional3 = 0;
            frame.optional4 = 0;

            frame.layerMetadata   = new Animation.Frame.LayerMetadata(reader);
            frame.unknownBitfield = new Animation.Frame.LayerMetadata(reader);

            if (frame.layerMetadata.bReadOptionalData != 0)
            {
                frame.optional1 = reader.ReadByte();
                frame.optional2 = reader.ReadByte();
            }
            if (frame.unknownBitfield.bReadOptionalData != 0)
            {
                frame.optional3 = reader.ReadByte();
                frame.optional4 = reader.ReadByte();
            }

            frame.layers = new List <Animation.Frame.Layer>(frame.layerMetadata.count);
            for (int i = 0; i < frame.layerMetadata.count; ++i)
            {
                frame.layers.Add(new Animation.Frame.Layer(reader));
            }

            return(frame);
        }