/// <summary> /// Reads a short member from the given buffer. /// The modification flag is read also. /// </summary> /// <param name="buffer">The buffer where the member shall be read from.</param> /// <param name="member">The member where the read data shall be stored.</param> protected static void ReadMember(IORAMHelper.RAMBuffer buffer, DiffElement <short> member) { // Member must be defined if (member == null) { return; } // Read member if modified if (buffer.ReadByte() == 1) { member.Value = buffer.ReadShort(); } }
/// <summary> /// Reads a resource cost member from the given buffer. /// The modification flag is read also. /// </summary> /// <param name="buffer">The buffer where the member shall be read from.</param> /// <param name="member">The member where the read data shall be stored.</param> protected static void ReadMember(IORAMHelper.RAMBuffer buffer, DiffElement <ResourceCostEntry> member) { // Member must be defined if (member == null) { return; } // Read member if modified if (buffer.ReadByte() == 1) { member.Value = new ResourceCostEntry(buffer.ReadShort(), buffer.ReadShort(), buffer.ReadByte()); } }
/// <summary> /// Saves the given floating point member into the given buffer. /// The modification flag is written also. /// </summary> /// <param name="buffer">The buffer for the member to written to.</param> /// <param name="member">The member to be written.</param> protected static void SaveMember(IORAMHelper.RAMBuffer buffer, DiffElement <float> member) { // Member must be defined if (member == null) { return; } // Write modification flag buffer.WriteByte((byte)(member.Modified ? 1 : 0)); // Write member if (member.Modified) { buffer.WriteFloat(member); } }