Example #1
0
        public void SaveOrLoad(Serializer serializer)
        {
            var verbEntries = new[]
            {
                LoadAndSaveEntry.Create(reader => CurRect.Left   = reader.ReadInt16(), writer => writer.WriteInt16(CurRect.Left), 8),
                LoadAndSaveEntry.Create(reader => CurRect.Top    = reader.ReadInt16(), writer => writer.WriteInt16(CurRect.Top), 8),
                LoadAndSaveEntry.Create(reader => CurRect.Right  = reader.ReadInt16(), writer => writer.WriteInt16(CurRect.Right), 8),
                LoadAndSaveEntry.Create(reader => CurRect.Bottom = reader.ReadInt16(), writer => writer.WriteInt16(CurRect.Bottom), 8),
                LoadAndSaveEntry.Create(reader => OldRect.Left   = reader.ReadInt16(), writer => writer.WriteInt16(OldRect.Left), 8),
                LoadAndSaveEntry.Create(reader => OldRect.Top    = reader.ReadInt16(), writer => writer.WriteInt16(OldRect.Top), 8),
                LoadAndSaveEntry.Create(reader => OldRect.Right  = reader.ReadInt16(), writer => writer.WriteInt16(OldRect.Right), 8),
                LoadAndSaveEntry.Create(reader => OldRect.Bottom = reader.ReadInt16(), writer => writer.WriteInt16(OldRect.Bottom), 8),

                LoadAndSaveEntry.Create(reader => VerbId = reader.ReadByte(), writer => writer.WriteByte(VerbId), 8, 11),
                LoadAndSaveEntry.Create(reader => VerbId = reader.ReadUInt16(), writer => writer.WriteUInt16(VerbId), 12),

                LoadAndSaveEntry.Create(reader => Color     = reader.ReadByte(), writer => writer.WriteByte(Color), 8),
                LoadAndSaveEntry.Create(reader => HiColor   = reader.ReadByte(), writer => writer.WriteByte(HiColor), 8),
                LoadAndSaveEntry.Create(reader => DimColor  = reader.ReadByte(), writer => writer.WriteByte(DimColor), 8),
                LoadAndSaveEntry.Create(reader => BkColor   = reader.ReadByte(), writer => writer.WriteByte(BkColor), 8),
                LoadAndSaveEntry.Create(reader => Type      = (VerbType)reader.ReadByte(), writer => writer.WriteByte((byte)Type), 8),
                LoadAndSaveEntry.Create(reader => CharsetNr = reader.ReadByte(), writer => writer.WriteByte(CharsetNr), 8),
                LoadAndSaveEntry.Create(reader => CurMode   = reader.ReadByte(), writer => writer.WriteByte(CurMode), 8),
                LoadAndSaveEntry.Create(reader => SaveId    = reader.ReadByte(), writer => writer.WriteByte(SaveId), 8),
                LoadAndSaveEntry.Create(reader => Key       = reader.ReadByte(), writer => writer.WriteByte(Key), 8),
                LoadAndSaveEntry.Create(reader => Center    = reader.ReadBoolean(), writer => writer.WriteByte(Center), 8),
                LoadAndSaveEntry.Create(reader => Prep      = reader.ReadByte(), writer => writer.WriteByte(Prep), 8),
                LoadAndSaveEntry.Create(reader => ImgIndex  = reader.ReadUInt16(), writer => writer.WriteUInt16(ImgIndex), 8),
            };

            verbEntries.ForEach(e => e.Execute(serializer));
        }
Example #2
0
        public void SaveOrLoad(Serializer ser)
        {
            var playerEntries = new []
            {
                LoadAndSaveEntry.Create(r => _active    = r.ReadBoolean(), w => w.Write(_active), 8),
                LoadAndSaveEntry.Create(r => _id        = r.ReadUInt16(), w => w.WriteUInt16(_id), 8),
                LoadAndSaveEntry.Create(r => _priority  = r.ReadByte(), w => w.WriteByte(_priority), 8),
                LoadAndSaveEntry.Create(r => _volume    = r.ReadByte(), w => w.WriteByte(_volume), 8),
                LoadAndSaveEntry.Create(r => _pan       = r.ReadSByte(), w => w.Write(_pan), 8),
                LoadAndSaveEntry.Create(r => _transpose = r.ReadSByte(), w => w.Write(_transpose), 8),
                LoadAndSaveEntry.Create(r => _detune    = r.ReadSByte(), w => w.Write(_detune), 8),
                LoadAndSaveEntry.Create(r => VolChan    = r.ReadUInt16(), w => w.WriteUInt16(VolChan), 8),
                LoadAndSaveEntry.Create(r => _vol_eff   = r.ReadByte(), w => w.WriteByte(_vol_eff), 8),
                LoadAndSaveEntry.Create(r => _speed     = r.ReadByte(), w => w.WriteByte(_speed), 8),
                LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 19), //_song_index
                LoadAndSaveEntry.Create(r => _track_index = r.ReadUInt16(), w => w.WriteUInt16(_track_index), 8),
                LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 17), //_timer_counter
                LoadAndSaveEntry.Create(r => _loop_to_beat   = r.ReadUInt16(), w => w.WriteUInt16(_loop_to_beat), 8),
                LoadAndSaveEntry.Create(r => _loop_from_beat = r.ReadUInt16(), w => w.WriteUInt16(_loop_from_beat), 8),
                LoadAndSaveEntry.Create(r => _loop_counter   = r.ReadUInt16(), w => w.WriteUInt16(_loop_counter), 8),
                LoadAndSaveEntry.Create(r => _loop_to_tick   = r.ReadUInt16(), w => w.WriteUInt16(_loop_to_tick), 8),
                LoadAndSaveEntry.Create(r => _loop_from_tick = r.ReadUInt16(), w => w.WriteUInt16(_loop_from_tick), 8),
                LoadAndSaveEntry.Create(r => r.ReadUInt32(), w => w.WriteUInt32(0), 8, 19), //_tempo
                LoadAndSaveEntry.Create(r => r.ReadUInt32(), w => w.WriteUInt32(0), 8, 17), //_cur_pos
                LoadAndSaveEntry.Create(r => r.ReadUInt32(), w => w.WriteUInt32(0), 8, 17), //_next_pos
                LoadAndSaveEntry.Create(r => r.ReadUInt32(), w => w.WriteUInt32(0), 8, 17), //_song_offset
                LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 17), //_tick_index
                LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 17), //_beat_index
                LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 17), // _ticks_per_beat
                LoadAndSaveEntry.Create(r => _music_tick = r.ReadUInt32(), w => w.WriteUInt32(_music_tick), 19),
            };

            if (ser.IsLoading && _parser != null)
            {
                _parser = null;
            }
            _music_tick = _parser != null ? (uint)_parser.Tick : 0;

            int num;

            if (!ser.IsLoading)
            {
                num = _parts != null?Array.IndexOf(_se._parts, _parts) + 1 : 0;

                ser.Writer.WriteUInt16(num);
            }
            else
            {
                num    = ser.Reader.ReadUInt16();
                _parts = num != 0 ? _se._parts[num - 1] : null;
            }

            playerEntries.ForEach(e => e.Execute(ser));
            _hook.SaveOrLoad(ser);
            _parameterFaders.ForEach(pf => pf.SaveOrLoad(ser));
        }
Example #3
0
            public void SaveOrLoad(Serializer ser)
            {
                var instrumentEntries = new []
                {
                    LoadAndSaveEntry.Create(r => _pos    = r.ReadUInt32(), w => w.WriteUInt32(_pos), 94),
                    LoadAndSaveEntry.Create(r => _subPos = r.ReadUInt32(), w => w.WriteUInt32(_subPos), 94),
                };

                instrumentEntries.ForEach(e => e.Execute(ser));
            }
Example #4
0
        public void SaveOrLoad(Serializer serializer)
        {
            var nestedScriptEntries = new[]
            {
                LoadAndSaveEntry.Create(reader => Number = reader.ReadUInt16(), writer => writer.WriteUInt16(Number), 8),
                LoadAndSaveEntry.Create(reader => Where  = (WhereIsObject)reader.ReadByte(), writer => writer.WriteByte((byte)Where), 8),
                LoadAndSaveEntry.Create(reader => Slot   = reader.ReadByte(), writer => writer.WriteByte(Slot), 8),
            };

            nestedScriptEntries.ForEach(e => e.Execute(serializer));
        }
Example #5
0
        public void SaveOrLoad(Serializer serializer)
        {
            short _currentMusic = 0;
            var   soundEntries  = new[]
            {
                LoadAndSaveEntry.Create(r => _currentCDSound = r.ReadInt16(), writer => writer.WriteInt16(_currentCDSound), 35),
                LoadAndSaveEntry.Create(r => _currentMusic   = r.ReadInt16(), writer => writer.WriteInt16(_currentMusic), 35),
            };

            soundEntries.ForEach(e => e.Execute(serializer));
        }
Example #6
0
        public void SaveOrLoad(Serializer serializer)
        {
            var entries = new[]
            {
                LoadAndSaveEntry.Create(reader => _gfxUsageBits = reader.ReadUInt32s(200), writer => writer.WriteUInt32s(_gfxUsageBits, 200), 8, 9),
                LoadAndSaveEntry.Create(reader => _gfxUsageBits = reader.ReadUInt32s(410), writer => writer.WriteUInt32s(_gfxUsageBits, 410), 10, 13),
                LoadAndSaveEntry.Create(reader => _gfxUsageBits = reader.ReadUInt32s(3 * 410), writer => writer.WriteUInt32s(_gfxUsageBits, 3 * 410), 14)
            };

            entries.ForEach(entry => entry.Execute(serializer));
        }
Example #7
0
        public void SaveOrLoad(Serializer ser)
        {
            var parameterFaderEntries = new []  {
                LoadAndSaveEntry.Create(r => Param       = (ParameterFaderType)r.ReadInt16(), w => w.WriteInt16((short)Param), 17),
                LoadAndSaveEntry.Create(r => Start       = r.ReadInt16(), w => w.WriteInt16(Start), 17),
                LoadAndSaveEntry.Create(r => End         = r.ReadInt16(), w => w.WriteInt16(End), 17),
                LoadAndSaveEntry.Create(r => TotalTime   = r.ReadUInt32(), w => w.WriteUInt32(TotalTime), 17),
                LoadAndSaveEntry.Create(r => CurrentTime = r.ReadUInt32(), w => w.WriteUInt32(CurrentTime), 17)
            };

            parameterFaderEntries.ForEach(e => e.Execute(ser));
        }
Example #8
0
        public void SaveOrLoad(Serializer ser)
        {
            var snmTriggerEntries = new []
            {
                LoadAndSaveEntry.Create(r => Sound   = r.ReadInt16(), w => w.WriteInt16(Sound), 54),
                LoadAndSaveEntry.Create(r => Id      = r.ReadByte(), w => w.WriteByte(Id), 54),
                LoadAndSaveEntry.Create(r => Expire  = r.ReadUInt16(), w => w.WriteUInt16(Expire), 54),
                LoadAndSaveEntry.Create(r => Command = r.ReadUInt16s(8).Select(i => (int)i).ToArray(), w => w.WriteUInt16s(Command.Select(i => (ushort)i).ToArray(), 8), 54),
            };

            snmTriggerEntries.ForEach(e => e.Execute(ser));
        }
Example #9
0
        public void SaveOrLoad(Serializer ser)
        {
            lock (_mutex)
            {
                if (ser.Version < 94)
                {
                    if (_vm.Game.GameId == GameId.Monkey1 && ser.IsLoading)
                    {
                        var dummyImuse = IMuse.IMuse.Create(null, null);
                        dummyImuse.SaveOrLoad(ser);
                    }
                }
                else
                {
                    var musicEntries = new []
                    {
                        LoadAndSaveEntry.Create(r => _sampleRate   = r.ReadInt32(), w => w.WriteInt32(_sampleRate), 94),
                        LoadAndSaveEntry.Create(r => _soundPlaying = r.ReadInt16(), w => w.WriteInt16(_soundPlaying), 94),
                    };

                    int mixerSampleRate = _sampleRate;
                    int i;

                    musicEntries.ForEach(e => e.Execute(ser));

                    if (ser.IsLoading && _soundPlaying != -1)
                    {
                        var ptr = _vm.ResourceManager.GetSound(_vm.Sound.MusicType, _soundPlaying);
                        Debug.Assert(ptr != null);
                        LoadMusic(ptr);
                    }

                    _channel.ForEach(c => c.SaveOrLoad(ser));
                    _channel.ForEach(c => c._instrument.SaveOrLoad(ser));

                    if (ser.IsLoading)
                    {
                        // If necessary, adjust the channel data to fit the
                        // current sample rate.
                        if (_soundPlaying != -1 && _sampleRate != mixerSampleRate)
                        {
                            double mult = (double)_sampleRate / (double)mixerSampleRate;
                            for (i = 0; i < _numberOfChannels; i++)
                            {
                                _channel[i]._pitchModifier = (int)((double)_channel[i]._pitchModifier * mult);
                                _channel[i]._remaining     = (uint)((double)_channel[i]._remaining / mult);
                            }
                        }
                        _sampleRate = mixerSampleRate;
                    }
                }
            }
        }
Example #10
0
        public void SaveOrLoad(Serializer serializer)
        {
            var colorCycleEntries = new[]
            {
                LoadAndSaveEntry.Create(reader => Delay   = reader.ReadUInt16(), writer => writer.WriteUInt16(Delay), 8),
                LoadAndSaveEntry.Create(reader => Counter = reader.ReadUInt16(), writer => writer.WriteUInt16(Counter), 8),
                LoadAndSaveEntry.Create(reader => Flags   = reader.ReadUInt16(), writer => writer.WriteUInt16(Flags), 8),
                LoadAndSaveEntry.Create(reader => Start   = reader.ReadByte(), writer => writer.WriteByte(Start), 8),
                LoadAndSaveEntry.Create(reader => End     = reader.ReadByte(), writer => writer.WriteByte(End), 8),
            };

            colorCycleEntries.ForEach(e => e.Execute(serializer));
        }
Example #11
0
            public void SaveOrLoad(Serializer ser)
            {
                var channelEntries = new []
                {
                    LoadAndSaveEntry.Create(r => _pos           = r.ReadUInt16(), w => w.WriteUInt16(_pos), 94),
                    LoadAndSaveEntry.Create(r => _pitchModifier = r.ReadInt32(), w => w.WriteInt32(_pitchModifier), 94),
                    LoadAndSaveEntry.Create(r => _velocity      = r.ReadByte(), w => w.WriteByte(_velocity), 94),
                    LoadAndSaveEntry.Create(r => _remaining     = r.ReadUInt32(), w => w.WriteUInt32(_remaining), 94),
                    LoadAndSaveEntry.Create(r => _notesLeft     = r.ReadBoolean(), w => w.WriteByte(_notesLeft), 94),
                };

                channelEntries.ForEach(e => e.Execute(ser));
            }
Example #12
0
        public void SaveOrLoad(Serializer serializer)
        {
            var sentenceEntries = new[]
            {
                LoadAndSaveEntry.Create(reader => Verb        = reader.ReadByte(), writer => writer.WriteByte(Verb), 8),
                LoadAndSaveEntry.Create(reader => Preposition = reader.ReadBoolean(), writer => writer.WriteByte(Preposition), 8),
                LoadAndSaveEntry.Create(reader => ObjectA     = reader.ReadUInt16(), writer => writer.WriteUInt16(ObjectA), 8),
                LoadAndSaveEntry.Create(reader => ObjectB     = reader.ReadUInt16(), writer => writer.WriteUInt16(ObjectB), 8),
                LoadAndSaveEntry.Create(reader => freezeCount = reader.ReadByte(), writer => writer.WriteByte(freezeCount), 8),
            };

            sentenceEntries.ForEach(e => e.Execute(serializer));
        }
Example #13
0
        public void SaveOrLoad(Serializer ser)
        {
            var partEntries = new []
            {
                LoadAndSaveEntry.Create(r => _pitchbend        = r.ReadInt16(), w => w.WriteInt16(_pitchbend), 8),
                LoadAndSaveEntry.Create(r => _pitchbend_factor = r.ReadByte(), w => w.WriteByte(_pitchbend_factor), 8),
                LoadAndSaveEntry.Create(r => Transpose         = r.ReadSByte(), w => w.Write((sbyte)Transpose), 8),
                LoadAndSaveEntry.Create(r => _vol      = r.ReadByte(), w => w.WriteByte(_vol), 8),
                LoadAndSaveEntry.Create(r => _detune   = r.ReadSByte(), w => w.Write((sbyte)_detune), 8),
                LoadAndSaveEntry.Create(r => _pan      = r.ReadSByte(), w => w.Write((sbyte)_pan), 8),
                LoadAndSaveEntry.Create(r => On        = r.ReadBoolean(), w => w.Write(On), 8),
                LoadAndSaveEntry.Create(r => _modwheel = r.ReadByte(), w => w.WriteByte(_modwheel), 8),
                LoadAndSaveEntry.Create(r => Pedal     = r.ReadBoolean(), w => w.Write(Pedal), 8),
                LoadAndSaveEntry.Create(r => r.ReadByte(), w => w.WriteByte(0), 8, 16),
                LoadAndSaveEntry.Create(r => priority      = r.ReadByte(), w => w.WriteByte(priority), 8),
                LoadAndSaveEntry.Create(r => Channel       = r.ReadByte(), w => w.WriteByte(Channel), 8),
                LoadAndSaveEntry.Create(r => _effect_level = r.ReadByte(), w => w.WriteByte(_effect_level), 8),
                LoadAndSaveEntry.Create(r => _chorus       = r.ReadByte(), w => w.WriteByte(_chorus), 8),
                LoadAndSaveEntry.Create(r => Percussion    = r.ReadBoolean(), w => w.Write(Percussion), 8),
                LoadAndSaveEntry.Create(r => _bank         = r.ReadByte(), w => w.WriteByte(_bank), 8)
            };

            int num;

            if (!ser.IsLoading)
            {
                num = Next != null?Array.IndexOf(Se._parts, Next) + 1 : 0;

                ser.Writer.WriteUInt16(num);

                num = Previous != null?Array.IndexOf(Se._parts, Previous) + 1 : 0;

                ser.Writer.WriteUInt16(num);

                num = Player != null?Array.IndexOf(Se._players, Player) + 1 : 0;

                ser.Writer.WriteUInt16(num);
            }
            else
            {
                num  = ser.Reader.ReadUInt16();
                Next = num != 0 ? Se._parts[num - 1] : null;

                num      = ser.Reader.ReadUInt16();
                Previous = num != 0 ? Se._parts[num - 1] : null;

                num    = ser.Reader.ReadUInt16();
                Player = num != 0 ? Se._players[num - 1] : null;
            }
            partEntries.ForEach(e => e.Execute(ser));
        }
Example #14
0
        public void SaveOrLoad(Serializer serializer)
        {
            var scaleSlotsEntries = new[]
            {
                LoadAndSaveEntry.Create(reader => X1     = reader.ReadInt16(), writer => writer.WriteInt16(X1), 13),
                LoadAndSaveEntry.Create(reader => Y1     = reader.ReadInt16(), writer => writer.WriteInt16(Y1), 13),
                LoadAndSaveEntry.Create(reader => Scale1 = reader.ReadInt16(), writer => writer.WriteInt16(Scale1), 13),
                LoadAndSaveEntry.Create(reader => X2     = reader.ReadInt16(), writer => writer.WriteInt16(X2), 13),
                LoadAndSaveEntry.Create(reader => Y2     = reader.ReadInt16(), writer => writer.WriteInt16(Y2), 13),
                LoadAndSaveEntry.Create(reader => Scale2 = reader.ReadInt16(), writer => writer.WriteInt16(Scale2), 13),
            };

            scaleSlotsEntries.ForEach(e => e.Execute(serializer));
        }
Example #15
0
        public void SaveOrLoad(Serializer ser)
        {
            var hookEntries = new []
            {
                LoadAndSaveEntry.Create(r => Jump[0]       = r.ReadByte(), w => w.WriteByte(Jump[0]), 8),
                LoadAndSaveEntry.Create(r => Jump[0]       = r.ReadByte(), w => w.WriteByte(Jump[0]), 8),
                LoadAndSaveEntry.Create(r => Transpose     = r.ReadByte(), w => w.WriteByte(Transpose), 8),
                LoadAndSaveEntry.Create(r => PartOnOff     = r.ReadBytes(16), w => w.WriteBytes(PartOnOff, 16), 8),
                LoadAndSaveEntry.Create(r => PartVolume    = r.ReadBytes(16), w => w.WriteBytes(PartVolume, 16), 8),
                LoadAndSaveEntry.Create(r => PartProgram   = r.ReadBytes(16), w => w.WriteBytes(PartProgram, 16), 8),
                LoadAndSaveEntry.Create(r => PartTranspose = r.ReadBytes(16), w => w.WriteBytes(PartTranspose, 16), 8)
            };

            hookEntries.ForEach(e => e.Execute(ser));
        }
Example #16
0
 public void SaveOrLoad(Serializer ser)
 {
     LoadAndSaveEntry[] pcmEntries =
     {
         LoadAndSaveEntry.Create(r => index    = r.ReadUInt16(), w => w.WriteUInt16(index),    81),
         LoadAndSaveEntry.Create(r => chan     = r.ReadUInt16(), w => w.WriteUInt16(chan),     81),
         LoadAndSaveEntry.Create(r => note     = r.ReadByte(),   w => w.WriteByte(note),       81),
         LoadAndSaveEntry.Create(r => velo     = r.ReadByte(),   w => w.WriteByte(velo),       81),
         LoadAndSaveEntry.Create(r => pan      = r.ReadByte(),   w => w.WriteByte(pan),        81),
         LoadAndSaveEntry.Create(r => paused   = r.ReadByte(),   w => w.WriteByte(paused),     81),
         LoadAndSaveEntry.Create(r => looping  = r.ReadByte(),   w => w.WriteByte(looping),    81),
         LoadAndSaveEntry.Create(r => priority = r.ReadUInt32(), w => w.WriteUInt32(priority), 81),
     };
     pcmEntries.ForEach(e => e.Execute(ser));
 }
Example #17
0
        public void SaveOrLoad(Serializer serializer)
        {
            var entries = new LoadAndSaveEntry[]
            {
                LoadAndSaveEntry.Create(reader =>
                {
                    StackPointer       = reader.ReadByte();
                    var cutScenePtr    = reader.ReadInt32s(MaxCutsceneNum);
                    var cutSceneScript = reader.ReadBytes(MaxCutsceneNum);
                    var cutSceneData   = reader.ReadInt16s(MaxCutsceneNum);

                    // load Cut Scene Data
                    for (var i = 0; i < MaxCutsceneNum; i++)
                    {
                        var data = new CutSceneData
                        {
                            Pointer = cutScenePtr[i],
                            Script  = cutSceneScript[i],
                            Data    = cutSceneData[i]
                        };
                        Data[i] = data;
                    }
                    ScriptIndex = reader.ReadInt16();
                }, writer =>
                {
                    var cutScenePtr    = new int[MaxCutsceneNum];
                    var cutSceneScript = new byte[MaxCutsceneNum];
                    var cutSceneData   = new short[MaxCutsceneNum];
                    var cutSceneStack  = Data;
                    for (var i = 0; i < cutSceneStack.Length; i++)
                    {
                        cutScenePtr[i]    = cutSceneStack[i].Pointer;
                        cutSceneScript[i] = cutSceneStack[i].Script;
                        cutSceneData[i]   = (short)cutSceneStack[i].Data;
                    }
                    writer.WriteByte(StackPointer);
                    writer.WriteInt32s(cutScenePtr, MaxCutsceneNum);
                    writer.WriteBytes(cutSceneScript, MaxCutsceneNum);
                    writer.WriteInt16s(cutSceneData, MaxCutsceneNum);
                    writer.WriteInt16(ScriptIndex);
                }, 8)
            };

            entries.ForEach(e => e.Execute(serializer));
        }
Example #18
0
        public override void SaveOrLoad(Serializer serializer)
        {
            base.SaveOrLoad(serializer);

            var actorEntries = new[]
            {
                LoadAndSaveEntry.Create(reader => CostCommand        = reader.ReadByte(), writer => writer.WriteByte(CostCommand), 84),
                LoadAndSaveEntry.Create(reader => MiscFlags          = (ActorV0MiscFlags)reader.ReadByte(), writer => writer.WriteByte((byte)MiscFlags), 84),
                LoadAndSaveEntry.Create(reader => Speaking           = reader.ReadByte(), writer => writer.WriteByte(Speaking), 84),
                LoadAndSaveEntry.Create(reader => AnimFrameRepeat    = reader.ReadSByte(), writer => writer.WriteByte(AnimFrameRepeat), 89),
                LoadAndSaveEntry.Create(reader => LimbFrameRepeatNew = reader.ReadSBytes(8), writer => writer.WriteSBytes(LimbFrameRepeatNew, 8), 89),
                LoadAndSaveEntry.Create(reader => LimbFrameRepeat    = reader.ReadSBytes(8), writer => writer.WriteSBytes(LimbFrameRepeat, 8), 90),
                LoadAndSaveEntry.Create(reader =>
                {
                    CurrentWalkTo = new Point(reader.ReadInt16(), reader.ReadInt16());
                }, writer =>
                {
                    writer.WriteInt16(CurrentWalkTo.X);
                    writer.WriteInt16(CurrentWalkTo.Y);
                }, 97),
                LoadAndSaveEntry.Create(reader =>
                {
                    NewWalkTo = new Point(reader.ReadInt16(), reader.ReadInt16());
                }, writer =>
                {
                    writer.WriteInt16(NewWalkTo.X);
                    writer.WriteInt16(NewWalkTo.Y);
                }, 97),
                LoadAndSaveEntry.Create(reader => _walkCountModulo             = reader.ReadByte(), writer => writer.WriteByte(_walkCountModulo), 97),
                LoadAndSaveEntry.Create(reader => _walkDirX                    = reader.ReadByte(), writer => writer.WriteByte(_walkDirX), 97),
                LoadAndSaveEntry.Create(reader => _walkDirY                    = reader.ReadByte(), writer => writer.WriteByte(_walkDirY), 97),
                LoadAndSaveEntry.Create(reader => _walkYCountGreaterThanXCount = reader.ReadByte(), writer => writer.WriteByte(_walkYCountGreaterThanXCount), 97),
                LoadAndSaveEntry.Create(reader => _walkXCount                  = reader.ReadByte(), writer => writer.WriteByte(_walkXCount), 97),
                LoadAndSaveEntry.Create(reader => _walkXCountInc               = reader.ReadByte(), writer => writer.WriteByte(_walkXCountInc), 97),
                LoadAndSaveEntry.Create(reader => _walkYCount                  = reader.ReadByte(), writer => writer.WriteByte(_walkYCount), 97),
                LoadAndSaveEntry.Create(reader => _walkYCountInc               = reader.ReadByte(), writer => writer.WriteByte(_walkYCountInc), 97),
                LoadAndSaveEntry.Create(reader => _walkMaxXYCountInc           = reader.ReadByte(), writer => writer.WriteByte(_walkMaxXYCountInc), 97)
            };

            actorEntries.ForEach(e => e.Execute(serializer));
        }
Example #19
0
        public void SaveOrLoad(Serializer serializer)
        {
            if (serializer.IsLoading)
            {
                Images.Clear();
            }
            var objectEntries = new[]
            {
                LoadAndSaveEntry.Create(reader => reader.ReadUInt32(), writer => writer.WriteUInt32(0), 8),
                LoadAndSaveEntry.Create(reader => reader.ReadUInt32(), writer => writer.WriteUInt32(0), 8),
                LoadAndSaveEntry.Create(reader =>
                {
                    Walk = new Point(reader.ReadInt16(), reader.ReadInt16());
                }, writer =>
                {
                    writer.WriteInt16(Walk.X);
                    writer.WriteInt16(Walk.Y);
                }, 8),
                LoadAndSaveEntry.Create(reader => Number = reader.ReadUInt16(), writer => writer.Write(Number), 8),
                LoadAndSaveEntry.Create(reader =>
                {
                    Position = new Point(reader.ReadInt16(), reader.ReadInt16());
                }, writer =>
                {
                    writer.WriteInt16(Position.X);
                    writer.WriteInt16(Position.Y);
                }, 8),
                LoadAndSaveEntry.Create(reader => Width       = reader.ReadUInt16(), writer => writer.WriteUInt16(Width), 8),
                LoadAndSaveEntry.Create(reader => Height      = reader.ReadUInt16(), writer => writer.WriteUInt16(Height), 8),
                LoadAndSaveEntry.Create(reader => ActorDir    = reader.ReadByte(), writer => writer.WriteByte(ActorDir), 8),
                LoadAndSaveEntry.Create(reader => ParentState = reader.ReadByte(), writer => writer.WriteByte(ParentState), 8),
                LoadAndSaveEntry.Create(reader => Parent      = reader.ReadByte(), writer => writer.WriteByte(Parent), 8),
                LoadAndSaveEntry.Create(reader => State       = reader.ReadByte(), writer => writer.WriteByte(State), 8),
                LoadAndSaveEntry.Create(reader => reader.ReadByte(), writer => writer.WriteByte(0), 8),
                LoadAndSaveEntry.Create(reader => Flags = (DrawBitmaps)reader.ReadByte(), writer => writer.WriteByte((byte)Flags), 46),
            };

            objectEntries.ForEach(e => e.Execute(serializer));
        }
Example #20
0
        public void SaveOrLoad(Serializer serializer)
        {
            var stringTabEntries = new[]
            {
                LoadAndSaveEntry.Create(reader =>
                {
                    var xPos          = reader.ReadInt16();
                    var defaultXPos   = reader.ReadInt16();
                    var yPos          = reader.ReadInt16();
                    var defaultYPos   = reader.ReadInt16();
                    Position          = new Point(xPos, yPos);
                    _default.Position = new Point(defaultXPos, defaultYPos);
                }, writer =>
                {
                    writer.WriteInt16(Position.X);
                    writer.WriteInt16(_default.Position.X);
                    writer.WriteInt16(Position.Y);
                    writer.WriteInt16(_default.Position.Y);
                }, 8),
                LoadAndSaveEntry.Create(reader => Right               = reader.ReadInt16(), writer => writer.WriteInt16(Right), 8),
                LoadAndSaveEntry.Create(reader => _default.Right      = reader.ReadInt16(), writer => writer.WriteInt16(_default.Right), 8),
                LoadAndSaveEntry.Create(reader => Color               = reader.ReadByte(), writer => writer.WriteByte(Color), 8),
                LoadAndSaveEntry.Create(reader => _default.Color      = reader.ReadByte(), writer => writer.WriteByte(_default.Color), 8),
                LoadAndSaveEntry.Create(reader => Charset             = reader.ReadByte(), writer => writer.WriteByte(Charset), 8),
                LoadAndSaveEntry.Create(reader => _default.Charset    = reader.ReadByte(), writer => writer.WriteByte(_default.Charset), 8),
                LoadAndSaveEntry.Create(reader => Center              = reader.ReadBoolean(), writer => writer.WriteByte(Center), 8),
                LoadAndSaveEntry.Create(reader => _default.Center     = reader.ReadBoolean(), writer => writer.WriteByte(_default.Center), 8),
                LoadAndSaveEntry.Create(reader => Overhead            = reader.ReadBoolean(), writer => writer.WriteByte(Overhead), 8),
                LoadAndSaveEntry.Create(reader => _default.Overhead   = reader.ReadBoolean(), writer => writer.WriteByte(_default.Overhead), 8),
                LoadAndSaveEntry.Create(reader => NoTalkAnim          = reader.ReadBoolean(), writer => writer.WriteByte(NoTalkAnim), 8),
                LoadAndSaveEntry.Create(reader => _default.NoTalkAnim = reader.ReadBoolean(), writer => writer.WriteByte(_default.NoTalkAnim), 8),
                LoadAndSaveEntry.Create(reader => Wrapping            = reader.ReadBoolean(), writer => writer.WriteByte(Wrapping), 71),
                LoadAndSaveEntry.Create(reader => _default.Wrapping   = reader.ReadBoolean(), writer => writer.WriteByte(_default.Wrapping), 71)
            };

            stringTabEntries.ForEach(e => e.Execute(serializer));
        }
Example #21
0
        public void SaveOrLoad(Serializer serializer, System.Collections.Generic.IList <ScriptData> localScripts, int numGlobalScripts)
        {
            var scriptSlotEntries = new[]
            {
                LoadAndSaveEntry.Create(
                    reader => Offset = reader.ReadUInt32(),
                    writer =>
                {
                    var offsetToSave = Offset;
                    if (Where == WhereIsObject.Global)
                    {
                        offsetToSave += 6;
                    }
                    else if (Where == WhereIsObject.Local && Number >= numGlobalScripts && localScripts[Number - numGlobalScripts] != null)
                    {
                        offsetToSave = (uint)(Offset + localScripts[Number - numGlobalScripts].Offset);
                    }
                    writer.WriteUInt32(offsetToSave);
                }, 8),

                LoadAndSaveEntry.Create(reader => Delay            = reader.ReadInt32(), writer => writer.WriteInt32(Delay), 8),
                LoadAndSaveEntry.Create(reader => Number           = reader.ReadUInt16(), writer => writer.WriteUInt16(Number), 8),
                LoadAndSaveEntry.Create(reader => DelayFrameCount  = reader.ReadUInt16(), writer => writer.WriteUInt16(DelayFrameCount), 8),
                LoadAndSaveEntry.Create(reader => Status           = (ScriptStatus)reader.ReadByte(), writer => writer.WriteByte((byte)Status), 8),
                LoadAndSaveEntry.Create(reader => Where            = (WhereIsObject)reader.ReadByte(), writer => writer.WriteByte((byte)Where), 8),
                LoadAndSaveEntry.Create(reader => FreezeResistant  = reader.ReadBoolean(), writer => writer.WriteByte(FreezeResistant), 8),
                LoadAndSaveEntry.Create(reader => Recursive        = reader.ReadBoolean(), writer => writer.WriteByte(Recursive), 8),
                LoadAndSaveEntry.Create(reader => freezeCount      = reader.ReadByte(), writer => writer.WriteByte(freezeCount), 8),
                LoadAndSaveEntry.Create(reader => IsExecuted       = reader.ReadBoolean(), writer => writer.WriteByte(IsExecuted), 8),
                LoadAndSaveEntry.Create(reader => CutSceneOverride = reader.ReadByte(), writer => writer.WriteByte(CutSceneOverride), 8),
                LoadAndSaveEntry.Create(reader => reader.ReadByte(), writer => writer.WriteByte(0), 46),
                LoadAndSaveEntry.Create(reader => reader.ReadByte(), writer => writer.WriteByte(0), 8, 10),
            };

            scriptSlotEntries.ForEach(e => e.Execute(serializer));
        }
Example #22
0
 public void SaveOrLoad(Serializer ser)
 {
     LoadAndSaveEntry.Create(r => array = r.ReadInt16s(8).Select(i => (int)i).ToArray(), w => w.WriteInt16s(array.Cast <int>().ToArray(), 8), 54).Execute(ser);
 }