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 Vector3Token : IXmlPropertyToken
|
|
|
|
|
{
|
|
|
|
|
public string Token => "Vector3";
|
|
|
|
|
private static string[] Coords = new string[3] { "X", "Y", "Z" };
|
|
|
|
|
|
|
|
|
|
public static Vector3? ReadVector3(XmlNode token)
|
|
|
|
|
{
|
|
|
|
|
float[] xyz = new float[3];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
{
|
|
|
|
|
string key = Coords[i];
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var coord = token[key];
|
|
|
|
|
xyz[i] = XmlPropertyTokens.ParseFloat(coord.InnerText);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Vector3(xyz);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ReadToken(Property property, XmlNode token)
|
|
|
|
|
{
|
|
|
|
|
Vector3? result = ReadVector3(token);
|
2019-02-01 16:15:55 +00:00
|
|
|
|
bool success = result.HasValue;
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
|
{
|
|
|
|
|
property.Type = PropertyType.Vector3;
|
2019-02-01 16:15:55 +00:00
|
|
|
|
property.Value = result.Value;
|
2019-01-30 06:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|