Exemplo n.º 1
0
        public static ClipEvent Parse(BinaryReader reader)
        {
            var ev = new ClipEvent();

            ev.Flags   = reader.ReadUInt24AsEnum <ClipEventFlags>();
            ev.KeyCode = reader.ReadByte();
            var offsetToNext = reader.ReadUInt32();
            //var keycode = reader.ReadByte();
            var instructionsPosition = reader.ReadUInt32();

            ev.Instructions = InstructionCollection.Parse(reader.BaseStream, instructionsPosition);
            return(ev);
        }
Exemplo n.º 2
0
        public static PlaceObject Parse(BinaryReader reader)
        {
            var placeobject = new PlaceObject();

            //read this as Uint32, because 3 bytes are reserved and always 0
            placeobject.Flags = reader.ReadUInt32AsEnumFlags <PlaceObjectFlags>();
            placeobject.Depth = reader.ReadInt32();

            //only read the values that are set by the flags
            if (placeobject.Flags.HasFlag(PlaceObjectFlags.HasCharacter))
            {
                placeobject.Character = reader.ReadInt32();
            }
            else
            {
                reader.ReadInt32();
            }

            if (placeobject.Flags.HasFlag(PlaceObjectFlags.HasMatrix))
            {
                placeobject.RotScale    = reader.ReadMatrix2x2();
                placeobject.Translation = reader.ReadVector2();
            }
            else
            {
                reader.ReadMatrix2x2();
                reader.ReadVector2();
            }

            if (placeobject.Flags.HasFlag(PlaceObjectFlags.HasColorTransform))
            {
                placeobject.TintColor     = reader.ReadColorRgba();
                placeobject.AdditiveColor = reader.ReadColorRgba();
            }
            else
            {
                reader.ReadColorRgba();
                reader.ReadColorRgba();
            }

            if (placeobject.Flags.HasFlag(PlaceObjectFlags.HasRatio))
            {
                placeobject.Ratio = reader.ReadSingle();
            }
            else
            {
                reader.ReadSingle();
            }

            if (placeobject.Flags.HasFlag(PlaceObjectFlags.HasName))
            {
                placeobject.Name = reader.ReadStringAtOffset();
            }
            else
            {
                reader.ReadUInt32();
            }

            placeobject.ClipDepth = reader.ReadInt32();

            if (placeobject.Flags.HasFlag(PlaceObjectFlags.HasClipAction))
            {
                var poaOffset = reader.ReadUInt32();
                if (poaOffset != 0)
                {
                    var oldOffset = reader.BaseStream.Position;
                    reader.BaseStream.Seek(poaOffset, SeekOrigin.Begin);
                    placeobject.ClipEvents = reader.ReadListAtOffset <ClipEvent>(() => ClipEvent.Parse(reader));
                    reader.BaseStream.Seek(oldOffset, SeekOrigin.Begin);
                }
            }

            return(placeobject);
        }