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 RayToken : IXmlPropertyToken
|
|
|
|
|
{
|
|
|
|
|
public string Token => "Ray";
|
|
|
|
|
private static string[] Fields = new string[2] { "origin", "direction" };
|
|
|
|
|
|
|
|
|
|
public bool ReadToken(Property prop, XmlNode token)
|
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
try
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
Vector3[] read = new Vector3[Fields.Length];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < read.Length; i++)
|
2019-01-30 06:36:56 +00:00
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
string field = Fields[i];
|
2019-01-30 06:36:56 +00:00
|
|
|
|
var fieldToken = token[field];
|
2019-02-01 18:40:39 +00:00
|
|
|
|
read[i] = Vector3Token.ReadVector3(fieldToken);
|
2019-01-30 06:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-01 18:40:39 +00:00
|
|
|
|
Vector3 origin = read[0],
|
|
|
|
|
direction = read[1];
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
2019-02-01 18:40:39 +00:00
|
|
|
|
Ray ray = new Ray(origin, direction);
|
|
|
|
|
prop.Type = PropertyType.Ray;
|
|
|
|
|
prop.Value = ray;
|
2019-01-30 06:36:56 +00:00
|
|
|
|
|
2019-02-01 18:40:39 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-01-30 06:36:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|