diff --git a/BinaryFormat/Chunks/PRNT.cs b/BinaryFormat/Chunks/PRNT.cs index 0803c48..12e6819 100644 --- a/BinaryFormat/Chunks/PRNT.cs +++ b/BinaryFormat/Chunks/PRNT.cs @@ -27,7 +27,6 @@ namespace RobloxFiles.BinaryFormat.Chunks Instance child = file.Instances[childId]; child.Parent = (parentId >= 0 ? file.Instances[parentId] : file); - child.ParentLocked = child.IsService; } } diff --git a/BinaryFormat/Chunks/PROP.cs b/BinaryFormat/Chunks/PROP.cs index e622502..a8f9536 100644 --- a/BinaryFormat/Chunks/PROP.cs +++ b/BinaryFormat/Chunks/PROP.cs @@ -362,7 +362,12 @@ namespace RobloxFiles.BinaryFormat.Chunks readProperties(i => { int instId = instIds[i]; - return instId >= 0 ? file.Instances[instId] : null; + Instance result = null; + + if (instId >= 0) + result = file.Instances[instId]; + + return result; }); break; diff --git a/RobloxFileFormat.dll b/RobloxFileFormat.dll index f0c6bad..2a55268 100644 Binary files a/RobloxFileFormat.dll and b/RobloxFileFormat.dll differ diff --git a/Tree/Instance.cs b/Tree/Instance.cs index 49121d2..add63e0 100644 --- a/Tree/Instance.cs +++ b/Tree/Instance.cs @@ -53,11 +53,8 @@ namespace RobloxFiles /// Indicates whether this Instance is a Service. public bool IsService { get; internal set; } - /// Raw list of CollectionService tags assigned to this Instance. - private List RawTags = new List(); - /// A list of CollectionService tags assigned to this Instance. - public List Tags => RawTags; + public List Tags { get; } = new List(); /// The attributes defined for this Instance. public Attributes Attributes { get; private set; } @@ -144,6 +141,7 @@ namespace RobloxFiles /// /// Returns true if the provided instance inherits from the provided instance type. /// + [Obsolete("Use the `is` operator instead.")] public bool IsA() where T : Instance { Type myType = GetType(); @@ -161,7 +159,7 @@ namespace RobloxFiles { T result = null; - if (IsA()) + if (this is T) result = this as T; return result; @@ -212,7 +210,7 @@ namespace RobloxFiles public T[] GetChildrenOfType() where T : Instance { T[] ofType = GetChildren() - .Where(child => child.IsA()) + .Where(child => child is T) .Cast() .ToArray(); @@ -224,7 +222,7 @@ namespace RobloxFiles /// public Instance[] GetDescendants() { - List results = new List(); + var results = new List(); foreach (Instance child in Children) { @@ -245,7 +243,7 @@ namespace RobloxFiles public T[] GetDescendantsOfType() where T : Instance { T[] ofType = GetDescendants() - .Where(desc => desc.IsA()) + .Where(desc => desc is T) .Cast() .ToArray(); @@ -361,9 +359,9 @@ namespace RobloxFiles while (check != null) { - if (check.IsA()) + if (check is T) { - ancestor = (T)check; + ancestor = check as T; break; } @@ -415,30 +413,26 @@ namespace RobloxFiles public T FindFirstChildWhichIsA(bool recursive = false) where T : Instance { var query = Children - .Where(child => child.IsA()) + .Where(child => child is T) .Cast(); - T result = null; - if (query.Any()) - { - result = query.First(); - } - else if (recursive) + return query.First(); + + if (recursive) { foreach (Instance child in Children) { T found = child.FindFirstChildWhichIsA(true); - if (found != null) - { - result = found; - break; - } + if (found == null) + continue; + + return found; } } - return result; + return null; } /// @@ -539,6 +533,7 @@ namespace RobloxFiles { case "String": case "Double": + case "Int64": xmlToken = xmlToken.ToLowerInvariant(); break; case "Boolean": @@ -550,9 +545,6 @@ namespace RobloxFiles case "Int32": xmlToken = "int"; break; - case "Int64": - xmlToken = "int64"; - break; case "Rect": xmlToken = "Rect2D"; break; @@ -564,7 +556,7 @@ namespace RobloxFiles if (!props.ContainsKey(fieldName)) { - Property newProp = new Property() + var newProp = new Property() { Value = field.GetValue(this), XmlToken = xmlToken, diff --git a/Tree/Property.cs b/Tree/Property.cs index 3e6ffb7..a2a3989 100644 --- a/Tree/Property.cs +++ b/Tree/Property.cs @@ -228,7 +228,7 @@ namespace RobloxFiles var valueType = value?.GetType(); Type memberType = member.MemberType; - if (memberType == valueType || value == null) + if (value == null || memberType.IsAssignableFrom(valueType)) { try {