diff --git a/RobloxFileFormat.dll b/RobloxFileFormat.dll index 7be3824..d2a8680 100644 Binary files a/RobloxFileFormat.dll and b/RobloxFileFormat.dll differ diff --git a/Tokens/CFrame.cs b/Tokens/CFrame.cs index f79330d..842085e 100644 --- a/Tokens/CFrame.cs +++ b/Tokens/CFrame.cs @@ -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(); 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); } } } diff --git a/Tokens/OptionalCFrame.cs b/Tokens/OptionalCFrame.cs index 010ac80..6b0faa9 100644 --- a/Tokens/OptionalCFrame.cs +++ b/Tokens/OptionalCFrame.cs @@ -10,23 +10,29 @@ 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(value); + prop.Type = PropertyType.OptionalCFrame; + return true; } public void WriteProperty(Property prop, XmlDocument doc, XmlNode node) { - CFrame value = prop.CastValue(); - - if (value != null) + if (prop.Value is Optional optional) { - XmlElement cfNode = doc.CreateElement("CFrame"); - CFrameToken.WriteCFrame(prop, doc, cfNode); - node.AppendChild(cfNode); + if (optional.HasValue) + { + CFrame value = optional.Value; + XmlElement cfNode = doc.CreateElement("CFrame"); + + CFrameToken.WriteCFrame(value, doc, cfNode); + node.AppendChild(cfNode); + } } } }