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 Vector2Token : IXmlPropertyToken
|
|
|
|
|
{
|
|
|
|
|
public string Token => "Vector2";
|
|
|
|
|
private static string[] Coords = new string[2] { "X", "Y" };
|
|
|
|
|
|
2019-02-01 18:40:39 +00:00
|
|
|
|
public static Vector2 ReadVector2(XmlNode token)
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
|
|
|
|
float[] xy = new float[2];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
|
{
|
|
|
|
|
string key = Coords[i];
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var coord = token[key];
|
|
|
|
|
string text = coord.InnerText;
|
|
|
|
|
xy[i] = XmlPropertyTokens.ParseFloat(text);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Vector2(xy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ReadToken(Property property, XmlNode token)
|
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
Vector2 result = ReadVector2(token);
|
|
|
|
|
bool success = (result != null);
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
|
{
|
|
|
|
|
property.Type = PropertyType.Vector2;
|
2019-02-01 18:40:39 +00:00
|
|
|
|
property.Value = result;
|
2019-01-30 06:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|