Пример #1
0
 public override void SerializeBlock(SerializerObject s)
 {
     s.DoEndian(R1Engine.Serialize.BinaryFile.Endian.Little, () => {
         Count = s.Serialize <ushort>(Count, name: nameof(Count));
     });
     if (Keyframes == null)
     {
         // To serialize the keyframes, we need to keep track of the layer sprite count changes between them
         Temp_LayerSpriteCountState = new List <int>();
         Keyframes = s.SerializeObjectArray <GBC_Keyframe>(Keyframes, Count - 1, onPreSerialize: x => x.ChannelData = this, name: nameof(Keyframes));
         Temp_LayerSpriteCountState = null;// We serialized this now, so we can remove this list
     }
     else
     {
         Keyframes = s.SerializeObjectArray <GBC_Keyframe>(Keyframes, Count - 1, name: nameof(Keyframes));
     }
 }
Пример #2
0
        public override void SerializeBlock(SerializerObject s)
        {
            var blockOffset = s.CurrentPointer;

            // Serialize data (always little endian)
            s.DoEndian(R1Engine.Serialize.BinaryFile.Endian.Little, () =>
            {
                // Parse data
                GameObjectsCount     = s.Serialize <ushort>(GameObjectsCount, name: nameof(GameObjectsCount));
                GameObjectsOffset    = s.Serialize <ushort>(GameObjectsOffset, name: nameof(GameObjectsOffset));
                KnotsHeight          = s.Serialize <byte>(KnotsHeight, name: nameof(KnotsHeight));
                KnotsWidth           = s.Serialize <byte>(KnotsWidth, name: nameof(KnotsWidth));
                KnotsOffset          = s.Serialize <ushort>(KnotsOffset, name: nameof(KnotsOffset));
                Height               = s.Serialize <ushort>(Height, name: nameof(Height));
                Width                = s.Serialize <ushort>(Width, name: nameof(Width));
                Timeout              = s.Serialize <byte>(Timeout, name: nameof(Timeout));
                Index_PlayField      = s.Serialize <byte>(Index_PlayField, name: nameof(Index_PlayField));
                IndexMin_ActorModels = s.Serialize <byte>(IndexMin_ActorModels, name: nameof(IndexMin_ActorModels));
                IndexMax_ActorModels = s.Serialize <byte>(IndexMax_ActorModels, name: nameof(IndexMax_ActorModels));
                ObjPalette           = s.SerializeObjectArray <RGBA5551Color>(ObjPalette, 8 * 4, name: nameof(ObjPalette));
                TilePalette          = s.SerializeObjectArray <RGBA5551Color>(TilePalette, 8 * 4, name: nameof(TilePalette));
                MainActor_0          = s.Serialize <ushort>(MainActor_0, name: nameof(MainActor_0));
                MainActor_1          = s.Serialize <ushort>(MainActor_1, name: nameof(MainActor_1));
                MainActor_2          = s.Serialize <ushort>(MainActor_2, name: nameof(MainActor_2));
                Index_SoundBank      = s.Serialize <byte>(Index_SoundBank, name: nameof(Index_SoundBank));

                // TODO: Parse data (UnkActorStructs?)
                UnknownData = s.SerializeArray <byte>(UnknownData, (blockOffset + GameObjectsOffset).AbsoluteOffset - s.CurrentPointer.AbsoluteOffset, name: nameof(UnknownData));

                // Parse from pointers
                GameObjects = s.DoAt(blockOffset + GameObjectsOffset, () => s.SerializeObjectArray <GBC_GameObject>(GameObjects, GameObjectsCount, name: nameof(GameObjects)));
                Knots       = s.DoAt(blockOffset + KnotsOffset, () => s.SerializeObjectArray <GBC_Knot>(Knots, KnotsHeight * KnotsWidth, name: nameof(Knots)));
                s.Goto(Knots.Last().Offset + Knots.Last().ActorsCount * 2 + 1); // Go to end of the block
            });

            // Parse data from pointers
            PlayField = s.DoAt(DependencyTable.GetPointer(Index_PlayField - 1), () => s.SerializeObject <GBC_PlayField>(PlayField, name: nameof(PlayField)));
            SoundBank = s.DoAt(DependencyTable.GetPointer(Index_SoundBank - 1), () => s.SerializeObject <GBC_SoundBank>(SoundBank, name: nameof(SoundBank)));

            // Parse actor models
            foreach (var actor in GameObjects.Where(x => x.Index_ActorModel > 1))
            {
                actor.ActorModel = s.DoAt(DependencyTable.GetPointer(actor.Index_ActorModel - 1), () => s.SerializeObject <GBC_ActorModelBlock>(actor.ActorModel, name: $"{nameof(actor.ActorModel)}[{actor.Index_ActorModel}]"));
            }
        }