Esempio n. 1
0
        public static FrameItem Create(BinaryReader reader)
        {
            FrameItem frameItem = null;

            var type = reader.ReadUInt32AsEnum <FrameItemType>();

            switch (type)
            {
            case FrameItemType.Action:
                frameItem = Action.Parse(reader);
                break;

            case FrameItemType.FrameLabel:
                frameItem = FrameLabel.Parse(reader);
                break;

            case FrameItemType.PlaceObject:
                frameItem = PlaceObject.Parse(reader);
                break;

            case FrameItemType.RemoveObject:
                frameItem = RemoveObject.Parse(reader);
                break;

            case FrameItemType.BackgroundColor:
                frameItem = BackgroundColor.Parse(reader);
                break;

            case FrameItemType.InitAction:
                frameItem = InitAction.Parse(reader);
                break;
            }

            return(frameItem);
        }
Esempio n. 2
0
        public static PlaceObject Create(int depth, int character)
        {
            var placeObject = new PlaceObject
            {
                Flags     = PlaceObjectFlags.HasCharacter,
                Depth     = depth,
                Character = character
            };

            return(placeObject);
        }
Esempio n. 3
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);
        }