2019-01-30 06:36:56 +00:00
|
|
|
|
using System.Xml;
|
2019-02-01 17:19:20 +00:00
|
|
|
|
using RobloxFiles.DataTypes;
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
2019-02-01 17:19:20 +00:00
|
|
|
|
namespace RobloxFiles.XmlFormat.PropertyTokens
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
|
|
|
|
public class NumberSequenceToken : IXmlPropertyToken
|
|
|
|
|
{
|
|
|
|
|
public string Token => "NumberSequence";
|
|
|
|
|
|
2019-05-17 12:08:06 +00:00
|
|
|
|
public bool ReadProperty(Property prop, XmlNode token)
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
|
|
|
|
string contents = token.InnerText.Trim();
|
|
|
|
|
string[] buffer = contents.Split(' ');
|
|
|
|
|
|
|
|
|
|
int length = buffer.Length;
|
|
|
|
|
bool valid = (length % 3 == 0);
|
|
|
|
|
|
|
|
|
|
if (valid)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
NumberSequenceKeypoint[] keypoints = new NumberSequenceKeypoint[length / 3];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < length; i += 3)
|
|
|
|
|
{
|
2019-05-17 12:08:06 +00:00
|
|
|
|
float Time = Formatting.ParseFloat(buffer[ i ]);
|
|
|
|
|
float Value = Formatting.ParseFloat(buffer[i + 1]);
|
|
|
|
|
float Envelope = Formatting.ParseFloat(buffer[i + 2]);
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
|
|
|
|
keypoints[i / 3] = new NumberSequenceKeypoint(Time, Value, Envelope);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prop.Type = PropertyType.NumberSequence;
|
|
|
|
|
prop.Value = new NumberSequence(keypoints);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
valid = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
|
}
|
2019-05-17 12:08:06 +00:00
|
|
|
|
|
|
|
|
|
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
|
|
|
|
|
{
|
|
|
|
|
node.InnerText = prop.Value.ToString() + ' ';
|
|
|
|
|
}
|
2019-01-30 06:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|