Пример #1
0
        /// <summary>
        /// Reads data from a SaveReader. Override this in a derived class to read object-specific data.
        /// </summary>
        /// <param name="reader">The SaveReader to read from. No guarantees can be made about its ending offset.</param>
        /// <param name="baseOffset">The offset of the start of the object data.</param>
        protected virtual void ReadFrom(SaveReader reader, long baseOffset)
        {
            _tag = DatumIndex.ReadFrom(reader);

            reader.SeekTo(baseOffset + StrengthInfoOffset);
            // Using the default Master Chief values is kind of hackish,
            // but at the same time it would be overkill to have a huge DB of original health/shield values.
            _healthInfo = new HealthInfo(reader, DefaultChiefHealthModifier, DefaultChiefShieldModifier);

            reader.SeekTo(baseOffset + PositionOffset1);
            _position.X = reader.ReadFloat();
            _position.Y = reader.ReadFloat();
            _position.Z = reader.ReadFloat();

            reader.SeekTo(baseOffset + PositionOffset2);
            _unkPosition.X = reader.ReadFloat();
            _unkPosition.Y = reader.ReadFloat();
            _unkPosition.Z = reader.ReadFloat();
            _unkPosition   = Vector3.Subtract(_unkPosition, _position);

            reader.SeekTo(baseOffset + CarryInfoOffset);
            _nextCarriedIndex  = DatumIndex.ReadFrom(reader);
            _firstCarriedIndex = DatumIndex.ReadFrom(reader);
            _carrierIndex      = DatumIndex.ReadFrom(reader);
        }
Пример #2
0
        protected override void ReadFrom(SaveReader reader, long baseOffset)
        {
            base.ReadFrom(reader, baseOffset);

            reader.SeekTo(baseOffset + WeaponsOffset);
            _primaryWeaponIndex    = DatumIndex.ReadFrom(reader);
            _secondaryWeaponIndex  = DatumIndex.ReadFrom(reader);
            _tertiaryWeaponIndex   = DatumIndex.ReadFrom(reader);
            _quaternaryWeaponIndex = DatumIndex.ReadFrom(reader);

            reader.SeekTo(baseOffset + GrenadesOffset);
            _fragGrenades   = reader.ReadSByte();
            _plasmaGrenades = reader.ReadSByte();
        }
Пример #3
0
        /// <summary>
        /// Read data from the mmiof.bmf file
        /// </summary>
        /// <param name="stream">Stream of the mmiof.bmf file.</param>
        private void ReadFromStream(Stream stream)
        {
            SaveIO.SaveReader reader = new SaveReader(stream);

            // Read save header
            _saveHeader.ReadFrom(reader);

            // Read the object list
            reader.SeekTo((long)TableOffset.Object);
            _objectList = new ObjectList(reader);

            // Read player info
            reader.SeekTo((long)TableOffset.Players);
            _player = new Player(reader, _objectList);
        }
Пример #4
0
        private bool ProcessObject(Table table, SaveReader reader, DatumIndex index, uint size, long offset)
        {
            if (!index.IsValid)
            {
                _objects.Add(null);
                return(true);
            }

            // Read the ObjectEntry and seek to the object's file offset
            ObjectEntry entry      = new ObjectEntry(index, reader);
            long        fileOffset = entry.ObjectAddress - table.Address + _entryTableOffset;

            reader.SeekTo(fileOffset);

            // Construct a specialized GameObject class depending on the tag group
            GameObject obj;

            switch (entry.TagGroup)
            {
            case TagGroup.Bipd:
                obj = new BipedObject(entry, reader);
                break;

            case TagGroup.Weap:
                obj = new WeaponObject(entry, reader);
                break;

            default:
                obj = new GameObject(entry, reader);
                break;
            }
            _objects.Add(obj);
            return(true);
        }
Пример #5
0
        private void ReadPlayerInfo(SaveReader reader, long baseOffset)
        {
            reader.SeekTo(baseOffset + PlayerBipedOffset);
            _bipedIndex = DatumIndex.ReadFrom(reader);

            reader.SeekTo(baseOffset + PlayerWeaponOffset);
            _bipedPrimaryWeaponIndex   = DatumIndex.ReadFrom(reader);
            _bipedSecondaryWeaponIndex = DatumIndex.ReadFrom(reader);
            _bipedThirdWeaponIndex     = DatumIndex.ReadFrom(reader);
            _bipedFourthWeaponIndex    = DatumIndex.ReadFrom(reader);

            reader.Seek(baseOffset + 0xB0, System.IO.SeekOrigin.Begin);
            _gamertag = reader.ReadUTF16();

            reader.Seek(baseOffset + 0xF4, System.IO.SeekOrigin.Begin);
            _serviceTag = reader.ReadUTF16();
        }
Пример #6
0
        protected override void ReadFrom(SaveReader reader, long baseOffset)
        {
            base.ReadFrom(reader, baseOffset);

            reader.SeekTo(baseOffset + AmmoOffset);
            _remainingAmmo = reader.ReadInt16();
            _clipAmmo      = reader.ReadInt16();
        }
Пример #7
0
        private void ReadFromStream(Stream stream)
        {
            SaveIO.SaveReader reader = new SaveReader(stream);
            _fileHeader.ReadFrom(reader);

            // Now read the save header
            long saveDataStart = stream.Length - SaveDataSize;

            reader.SeekTo(saveDataStart);
            _saveHeader.ReadFrom(reader);

            // Read the object list
            reader.SeekTo(saveDataStart + (long)TableOffset.Object);
            _objectList = new ObjectList(reader);

            // Read player info
            reader.SeekTo(saveDataStart + (long)TableOffset.Players);
            _player = new Player(reader, _objectList);
        }
Пример #8
0
        private void ReadPlayerInfo(SaveReader reader, long baseOffset)
        {
            reader.SeekTo(baseOffset + PlayerBipedOffset);
            _bipedIndex = DatumIndex.ReadFrom(reader);

            reader.Seek(baseOffset + 0x50, System.IO.SeekOrigin.Begin);
            _gamertag = reader.ReadUTF16();

            reader.Seek(baseOffset + 0x86, System.IO.SeekOrigin.Begin);
            _serviceTag = reader.ReadUTF16();
        }
Пример #9
0
        /// <summary>
        /// Reads data from a SaveReader. Override this in a derived class to read object-specific data.
        /// </summary>
        /// <param name="reader">The SaveReader to read from. No guarantees can be made about its ending offset.</param>
        /// <param name="baseOffset">The offset of the start of the object data.</param>
        protected virtual void ReadFrom(SaveReader reader, long baseOffset)
        {
            _tag = DatumIndex.ReadFrom(reader);

            reader.SeekTo(baseOffset + StrengthInfoOffset);
            _healthInfo = new HealthInfo(reader, DefaultChiefHealthModifier, DefaultChiefShieldModifier, float.MaxValue);

            // Read Position
            reader.SeekTo(baseOffset + PositionOffset1);
            _positionMain.X = reader.ReadFloat();
            _positionMain.Y = reader.ReadFloat();
            _positionMain.Z = reader.ReadFloat();

            // Read Position2
            Vector3 position2 = new Vector3();

            reader.SeekTo(baseOffset + PositionOffset2);
            position2.X = reader.ReadFloat();
            position2.Y = reader.ReadFloat();
            position2.Z = reader.ReadFloat();

            // Read Position3
            Vector3 position3 = new Vector3();

            reader.SeekTo(baseOffset + PositionOffset3);
            position3.X = reader.ReadFloat();
            position3.Y = reader.ReadFloat();
            position3.Z = reader.ReadFloat();

            // Compute position deltas
            _position2Delta = Vector3.Subtract(position2, _positionMain);
            _position3Delta = Vector3.Subtract(position3, _positionMain);

            reader.SeekTo(baseOffset + CarryInfoOffset);
            _nextCarriedIndex  = DatumIndex.ReadFrom(reader);
            _firstCarriedIndex = DatumIndex.ReadFrom(reader);
            _carrierIndex      = DatumIndex.ReadFrom(reader);
        }
Пример #10
0
        public void ReadEntries(SaveReader reader, ReadEntriesCallback callback)
        {
            long entryListStart     = reader.Position;
            long currentEntryOffset = entryListStart;

            for (ushort i = 0; i < _entryCount; i++)
            {
                reader.SeekTo(currentEntryOffset);
                ushort     salt  = reader.ReadUInt16();
                DatumIndex index = new DatumIndex(salt, i);
                if (!callback(this, reader, index, _entrySize, currentEntryOffset))
                {
                    break;
                }

                currentEntryOffset += _entrySize;
            }
        }
Пример #11
0
        /// <summary>
        /// Reads data from a SaveReader. Override this in a derived class to read object-specific data.
        /// </summary>
        /// <param name="reader">The SaveReader to read from. No guarantees can be made about its ending offset.</param>
        /// <param name="baseOffset">The offset of the start of the object data.</param>
        protected virtual void ReadFrom(SaveReader reader, long baseOffset)
        {
            _tag = DatumIndex.ReadFrom(reader);

            reader.SeekTo(baseOffset + StrengthInfoOffset);
            _healthInfo = new HealthInfo(reader, DefaultChiefHealthModifier, DefaultChiefShieldModifier, float.PositiveInfinity);

            //reader.SeekTo(baseOffset + 0x18);
            // TODO: get offset for BSP zone
            //_zone = (ushort)((reader.ReadUInt32() & 0xFFFF0000) >> 16);

            // Read Position
            reader.SeekTo(baseOffset + PositionOffset1);
            _positionMain.X = reader.ReadFloat();
            _positionMain.Y = reader.ReadFloat();
            _positionMain.Z = reader.ReadFloat();

            // Read Position2
            Vector3 position2 = new Vector3();

            reader.SeekTo(baseOffset + PositionOffset2);
            position2.X = reader.ReadFloat();
            position2.Y = reader.ReadFloat();
            position2.Z = reader.ReadFloat();

            // Read Position3
            Vector3 position3 = new Vector3();

            reader.SeekTo(baseOffset + PositionOffset3);
            position3.X = reader.ReadFloat();
            position3.Y = reader.ReadFloat();
            position3.Z = reader.ReadFloat();

            // Read Position4
            Vector3 position4 = new Vector3();

            reader.SeekTo(baseOffset + PositionOffset4);
            position4.X = reader.ReadFloat();
            position4.Y = reader.ReadFloat();
            position4.Z = reader.ReadFloat();

            // Compute position deltas
            _position2Delta = Vector3.Subtract(position2, _positionMain);
            _position3Delta = Vector3.Subtract(position3, _positionMain);
            _position4Delta = Vector3.Subtract(position4, _positionMain);

            reader.SeekTo(baseOffset + CarryInfoOffset);
            _nextCarriedIndex  = DatumIndex.ReadFrom(reader);
            _firstCarriedIndex = DatumIndex.ReadFrom(reader);
            _carrierIndex      = DatumIndex.ReadFrom(reader);
        }
Пример #12
0
 private void ReadPlayerInfo(SaveReader reader, long baseOffset)
 {
     reader.SeekTo(baseOffset + PlayerBipedOffset);
     _bipedIndex = DatumIndex.ReadFrom(reader);
 }