internal void Update(SaveIO.SaveWriter writer) { writer.Seek(_dataPosition + 0x28, SeekOrigin.Begin); writer.WriteUInt32(_biped.ID); writer.Seek(_dataPosition + 0x34, SeekOrigin.Begin); writer.WriteUInt32(_biped.ID); writer.Seek(_dataPosition + 0x5C, SeekOrigin.Begin); if (PrimaryWeapon != null) { writer.WriteUInt32(PrimaryWeapon.ID); } else { writer.WriteUInt32(0xFFFFFFFF); } if (SecondaryWeapon != null) { writer.WriteUInt32(SecondaryWeapon.ID); } else { writer.WriteUInt32(0xFFFFFFFF); } }
protected override void DoUpdate(SaveIO.SaveWriter writer, long start) { base.DoUpdate(writer, start); // Player data writer.Seek(start + 0xF0, SeekOrigin.Begin); if (_player != null) { writer.WriteUInt32(_player.ID); } else { writer.WriteUInt32(0xFFFFFFFF); } writer.Seek(start + 0x1B4, SeekOrigin.Begin); if (Carrier != null && Carrier.TagGroup == TagGroup.Bipd) { writer.WriteUInt32(Carrier.ID); writer.WriteUInt32(Carrier.ID); } else { writer.WriteUInt32(0xFFFFFFFF); writer.WriteUInt32(0xFFFFFFFF); } // This ID writer.WriteUInt32(ID); }
/// <summary> /// Updates and resigns the save data, writing any changes back to a stream. /// </summary> /// <exception cref="ArgumentException">Thrown if the stream cannot be written to or does not support seeking</exception> public void Update(Stream stream) { if (!stream.CanWrite || !stream.CanSeek) { throw new ArgumentException("Campaign save output streams must be writable and seekable"); } SaveIO.SaveWriter writer = new SaveIO.SaveWriter(stream); // Update each object Player.ResolvePlayerRefs(); foreach (GameObject obj in _objects) { if (obj != null) { obj.Update(writer); } } _objectChunk.Update(writer); // Update player information Player.Update(writer); // Update each squad foreach (Squad squad in _squads) { if (squad != null) { squad.Update(writer); } } // Update each actor foreach (Actor actor in _actors) { if (actor != null) { actor.Update(writer); } } // Gravity writer.Seek(0x68EBF4, SeekOrigin.Begin); writer.WriteFloat(_gravity); // Target locator ammo writer.Seek(0x915E1A, SeekOrigin.Begin); writer.WriteInt16(_targetLocatorAmmo); // Checkpoint message writer.Seek(0x9DF9E0, SeekOrigin.Begin); writer.WriteUTF16(_checkpointMsg); // Resign the file Resign(stream); }
/// <summary> /// Updates any changes made to this chunk. /// </summary> /// <param name="writer">The SaveWriter to write to.</param> public void Update(SaveIO.SaveWriter writer) { long baseAddress = _entryListStart - 0x54; writer.Seek(baseAddress + 0x34, SeekOrigin.Begin); writer.WriteUInt32(_firstDeleted); writer.WriteUInt32(_nextFree); writer.WriteUInt32(_activeEntries); // Null out deleted datum indices by setting their high word to 0 foreach (uint index in _deletedEntries) { writer.Seek(baseAddress + 0x54 + index * _entrySize, SeekOrigin.Begin); writer.WriteUInt16(0); } }
protected override void DoUpdate(SaveIO.SaveWriter writer, long start) { base.DoUpdate(writer, start); // Actor writer.Seek(start + 0x1BC, SeekOrigin.Begin); if (_actor != null) { writer.WriteUInt32(_actor.DatumIndex); } else { writer.WriteUInt32(0xFFFFFFFF); } // Unit flags writer.Seek(start + 0x1C4, SeekOrigin.Begin); writer.WriteInt32(_unitFlags.Data); // Team writer.Seek(start + 0x1C8, SeekOrigin.Begin); writer.WriteByte(_team); // Write weapon index info writer.Seek(start + 0x340, SeekOrigin.Begin); writer.WriteUInt16((ushort)(_weapons.Count + 2)); writer.WriteSByte(_currentWeaponIndex); writer.Skip(1); writer.WriteUInt16((ushort)(_weapons.Count + 2)); writer.WriteSByte(_backupWeaponIndex); writer.Skip(1); // Write the weapon list foreach (WeaponObject weapon in _weapons) { writer.WriteUInt32(weapon.ID); } // Write empty spots for (int i = _weapons.Count; i < 4; i++) { writer.WriteUInt32(0xFFFFFFFF); } }
public void Update(SaveIO.SaveWriter writer) { writer.Seek(_offset, SeekOrigin.Begin); writer.WriteUInt16((ushort)(_id >> 16)); writer.WriteUInt16((ushort)_flags.Data); writer.WriteUInt16((ushort)((ushort)_tagGroup << 8)); writer.WriteUInt16(_type); writer.WriteUInt32(_poolOffset); writer.WriteUInt32(_memAddress); }
protected override void DoUpdate(SaveIO.SaveWriter writer, long start) { base.DoUpdate(writer, start); writer.Seek(start + 0x388, SeekOrigin.Begin); if (_driver != null) { writer.WriteUInt32(_driver.ID); } else { writer.WriteUInt32(0xFFFFFFFF); } if (_controller != null) { writer.WriteUInt32(_controller.ID); } else { writer.WriteUInt32(0xFFFFFFFF); } }
/// <summary> /// Override this to write out any changed properties. /// </summary> /// <param name="writer">The SaveWriter to write to</param> /// <param name="start">The start of the object's data</param> protected virtual void DoUpdate(SaveIO.SaveWriter writer, long start) { // If the object's position has changed, awaken it if (_x != _originalX || _y != _originalY || _z != _originalZ || !_velocity.Equals(_originalVelocity)) { IsAwake = true; } writer.Seek(start + 0x4, SeekOrigin.Begin); writer.WriteInt32(_flags.Data); writer.WriteUInt16(_zone); writer.Seek(2, SeekOrigin.Current); if (_nextCarried != null) { writer.WriteUInt32(_nextCarried.ID); } else { writer.WriteUInt32(0xFFFFFFFF); } if (_firstCarried != null) { writer.WriteUInt32(_firstCarried.ID); } else { writer.WriteUInt32(0xFFFFFFFF); } if (_carrier != null) { writer.WriteUInt32(_carrier.ID); } else { writer.WriteUInt32(0xFFFFFFFF); } writer.WriteSByte(_parentNodeIndex); writer.Seek(start + 0x20, SeekOrigin.Begin); writer.WriteFloat(_x); writer.WriteFloat(_y); writer.WriteFloat(_z); /*writer.WriteFloat(_boundsX1); * writer.WriteFloat(_boundsY1); * writer.WriteFloat(_boundsZ1);*/ writer.Seek(4, SeekOrigin.Current); writer.WriteFloat(_x); writer.WriteFloat(_y); writer.WriteFloat(_z); /*writer.WriteFloat(_boundsX2); * writer.WriteFloat(_boundsY2); * writer.WriteFloat(_boundsZ2);*/ writer.Seek(8, SeekOrigin.Current); writer.WriteFloat(_x); writer.WriteFloat(_y); writer.WriteFloat(_z); writer.WriteFloat(_right.X); writer.WriteFloat(-_right.Y); // hax writer.WriteFloat(_right.Z); writer.WriteFloat(_up.X); writer.WriteFloat(-_up.Y); // hax writer.WriteFloat(_up.Z); writer.Seek(start + 0x68, SeekOrigin.Begin); writer.WriteFloat(_velocity.X); writer.WriteFloat(_velocity.Y); writer.WriteFloat(_velocity.Z); writer.Seek(start + 0x80, SeekOrigin.Begin); // Scale is stored twice?? writer.WriteFloat(_scale); writer.WriteFloat(_scale); writer.Seek(start + 0xDC, SeekOrigin.Begin); writer.WriteInt32(_physicsFlags.Data); writer.Seek(start + 0x13C, SeekOrigin.Begin); writer.WriteInt32(_invincibilityFlags.Data); // Write strength info writer.Seek(start + 0x110, SeekOrigin.Begin); _healthInfo.WriteTo(writer); if (_nodeDataOffset != 0xFFFF) { writer.Seek(start + _nodeDataOffset, SeekOrigin.Begin); foreach (ModelNode node in _nodes) { node.Update(writer, this); } } }