diff --git a/DataTypes/Optional.cs b/DataTypes/Optional.cs index 6476afa..20f7d6d 100644 --- a/DataTypes/Optional.cs +++ b/DataTypes/Optional.cs @@ -1,4 +1,6 @@ -namespace RobloxFiles.DataTypes +using System; + +namespace RobloxFiles.DataTypes { // Optional represents a value that can be explicitly // marked as an optional variant to a specified type. @@ -19,6 +21,29 @@ return Value?.ToString() ?? "null"; } + public override int GetHashCode() + { + if (HasValue) + return Value.GetHashCode(); + + var T = typeof(T); + return T.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (!(obj is Optional optional)) + return false; + + if (HasValue != optional.HasValue) + return false; + + if (HasValue) + return Value.Equals(optional.Value); + + return true; // Both have no value. + } + public static implicit operator T(Optional optional) { if (optional.HasValue) diff --git a/RobloxFileFormat.dll b/RobloxFileFormat.dll index b218631..7be3824 100644 Binary files a/RobloxFileFormat.dll and b/RobloxFileFormat.dll differ diff --git a/Tree/Instance.cs b/Tree/Instance.cs index 6dbca3f..401289b 100644 --- a/Tree/Instance.cs +++ b/Tree/Instance.cs @@ -644,6 +644,14 @@ namespace RobloxFiles xmlToken = "CoordinateFrame"; break; } + case "Optional`1": + { + // TODO: If more optional types are added, + // this needs disambiguation. + + xmlToken = "OptionalCoordinateFrame"; + break; + } } if (!props.ContainsKey(fieldName))