Handle OptionalCFrame encoding in XML explicitly.
This commit is contained in:
parent
fb443cdf42
commit
71cd85513e
Binary file not shown.
@ -30,9 +30,8 @@ namespace RobloxFiles.Tokens
|
||||
return new CFrame(components);
|
||||
}
|
||||
|
||||
public static void WriteCFrame(Property prop, XmlDocument doc, XmlNode node)
|
||||
public static void WriteCFrame(CFrame cf, XmlDocument doc, XmlNode node)
|
||||
{
|
||||
CFrame cf = prop.CastValue<CFrame>();
|
||||
float[] components = cf.GetComponents();
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
@ -63,7 +62,8 @@ namespace RobloxFiles.Tokens
|
||||
|
||||
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
|
||||
{
|
||||
WriteCFrame(prop, doc, node);
|
||||
CFrame value = prop.Value as CFrame;
|
||||
WriteCFrame(value, doc, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,24 +10,30 @@ namespace RobloxFiles.Tokens
|
||||
public bool ReadProperty(Property prop, XmlNode token)
|
||||
{
|
||||
XmlNode first = token.FirstChild;
|
||||
prop.Type = PropertyType.OptionalCFrame;
|
||||
CFrame value = null;
|
||||
|
||||
if (first?.Name == "CFrame")
|
||||
prop.Value = CFrameToken.ReadCFrame(first);
|
||||
value = CFrameToken.ReadCFrame(first);
|
||||
|
||||
prop.Value = new Optional<CFrame>(value);
|
||||
prop.Type = PropertyType.OptionalCFrame;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
|
||||
{
|
||||
CFrame value = prop.CastValue<CFrame>();
|
||||
|
||||
if (value != null)
|
||||
if (prop.Value is Optional<CFrame> optional)
|
||||
{
|
||||
if (optional.HasValue)
|
||||
{
|
||||
CFrame value = optional.Value;
|
||||
XmlElement cfNode = doc.CreateElement("CFrame");
|
||||
CFrameToken.WriteCFrame(prop, doc, cfNode);
|
||||
|
||||
CFrameToken.WriteCFrame(value, doc, cfNode);
|
||||
node.AppendChild(cfNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user