0.476.0.421371

This commit is contained in:
Max
2021-05-01 17:40:09 -05:00
parent 31eddea24e
commit 009d84f49f
18 changed files with 2513 additions and 2694 deletions

View File

@ -30,6 +30,23 @@ namespace RobloxFiles.Tokens
return new CFrame(components);
}
public static void WriteCFrame(Property prop, XmlDocument doc, XmlNode node)
{
CFrame cf = prop.CastValue<CFrame>();
float[] components = cf.GetComponents();
for (int i = 0; i < 12; i++)
{
string coordName = Coords[i];
float coordValue = components[i];
XmlElement coord = doc.CreateElement(coordName);
coord.InnerText = coordValue.ToInvariantString();
node.AppendChild(coord);
}
}
public bool ReadProperty(Property prop, XmlNode token)
{
CFrame result = ReadCFrame(token);
@ -46,19 +63,7 @@ namespace RobloxFiles.Tokens
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
{
CFrame cf = prop.CastValue<CFrame>();
float[] components = cf.GetComponents();
for (int i = 0; i < 12; i++)
{
string coordName = Coords[i];
float coordValue = components[i];
XmlElement coord = doc.CreateElement(coordName);
coord.InnerText = coordValue.ToInvariantString();
node.AppendChild(coord);
}
WriteCFrame(prop, doc, node);
}
}
}

33
Tokens/OptionalCFrame.cs Normal file
View File

@ -0,0 +1,33 @@
using System.Xml;
using RobloxFiles.DataTypes;
namespace RobloxFiles.Tokens
{
public class OptionalCFrameToken : IXmlPropertyToken
{
public string XmlPropertyToken => "OptionalCoordinateFrame";
public bool ReadProperty(Property prop, XmlNode token)
{
XmlNode first = token.FirstChild;
prop.Type = PropertyType.OptionalCFrame;
if (first?.Name == "CFrame")
prop.Value = CFrameToken.ReadCFrame(first);
return true;
}
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
{
CFrame value = prop.CastValue<CFrame>();
if (value != null)
{
XmlElement cfNode = doc.CreateElement("CFrame");
CFrameToken.WriteCFrame(prop, doc, cfNode);
node.AppendChild(cfNode);
}
}
}
}

View File

@ -13,8 +13,8 @@ namespace RobloxFiles.Tokens
public bool ReadProperty(Property prop, XmlNode token)
{
ProtectedString contents = token.InnerText;
prop.Type = PropertyType.ProtectedString;
prop.Value = contents;
prop.Type = PropertyType.String;
prop.Value = contents.ToString();
return true;
}