/// <summary> /// Converts raP entry in to a IRapEntry object. /// </summary> /// <param name="reader">Reader used for reading entry.</param> /// <param name="parent">Used for reading arrays recursive.</param> /// <returns>Returns a IRapEntry object.</returns> public IRapEntry FromBinary(RapBinaryReader reader, bool parent = false) { var array = reader.ReadRapArray(parent); // Empty array. if (array.Entries == 0) { return(array); } for (var i = 0; i < array.Entries; ++i) { var type = (RapValueType)reader.ReadByte(); if (type == RapValueType.String) { array.Strings.Add('"' + reader.ReadAsciiz() + '"'); } else if (type == RapValueType.Float) { array.Floats.Add(reader.ReadFloat()); } else if (type == RapValueType.Long) { array.Longs.Add(reader.ReadUint()); } else if (type == RapValueType.Array) { array.Arrays.Add((RapArray)FromBinary(reader, true)); } else if (type == RapValueType.Variable) { array.Variables.Add(reader.ReadAsciiz()); } } return(array); }
/// <summary> /// Converts raP entry in to a IRapEntry object. /// </summary> /// <param name="reader">Reader used for reading entry.</param> /// <param name="parent">Used for reading arrays recursive.</param> /// <returns>Returns a IRapEntry object.</returns> public IRapEntry FromBinary(RapBinaryReader reader, bool parent = false) => new RapClass { Name = reader.ReadAsciiz(), Offset = reader.ReadUint() };