Bug fixes and improvements.

- Fixed an issue pertaining to implicit value casting in the property
reflection.
- Removed some unnecessary generated whitespace in the class data.
- Added some missing properties to the generated class data.
- Moved the Quaternion type into the DataTypes namespace.
This commit is contained in:
CloneTrooper1019 2019-07-03 09:48:05 -05:00
parent de8df15d3f
commit 4e1fdc0a22
9 changed files with 75 additions and 22 deletions

View File

@ -6,7 +6,6 @@ using System.Text;
using RobloxFiles.Enums; using RobloxFiles.Enums;
using RobloxFiles.DataTypes; using RobloxFiles.DataTypes;
using RobloxFiles.Utility;
namespace RobloxFiles.BinaryFormat.Chunks namespace RobloxFiles.BinaryFormat.Chunks
{ {

View File

@ -1,5 +1,4 @@
using System; using System;
using RobloxFiles.Utility;
namespace RobloxFiles.DataTypes namespace RobloxFiles.DataTypes
{ {

View File

@ -1,7 +1,6 @@
using System; using System;
using RobloxFiles.DataTypes;
namespace RobloxFiles.Utility namespace RobloxFiles.DataTypes
{ {
/// <summary> /// <summary>
/// Quaternion is a utility used by the CFrame DataType to handle rotation interpolation. /// Quaternion is a utility used by the CFrame DataType to handle rotation interpolation.

View File

@ -644,7 +644,6 @@ namespace RobloxFiles
{ {
IsService = true; IsService = true;
} }
} }
public class ContextActionService : Instance public class ContextActionService : Instance
@ -723,6 +722,9 @@ namespace RobloxFiles
public abstract class BevelMesh : DataModelMesh public abstract class BevelMesh : DataModelMesh
{ {
public float Bevel = 0;
public float Bevel_Roundness = 0;
public float Bulge = 0;
} }
public class BlockMesh : BevelMesh public class BlockMesh : BevelMesh
@ -1758,7 +1760,6 @@ namespace RobloxFiles
{ {
IsService = true; IsService = true;
} }
} }
public class LocalizationTable : Instance public class LocalizationTable : Instance
@ -1866,7 +1867,6 @@ namespace RobloxFiles
{ {
IsService = true; IsService = true;
} }
} }
public abstract class PVInstance : Instance public abstract class PVInstance : Instance
@ -2065,6 +2065,7 @@ namespace RobloxFiles
{ {
public Content AssetId = ""; public Content AssetId = "";
public byte[] ChildData = new byte[0]; public byte[] ChildData = new byte[0];
public FormFactor FormFactor = FormFactor.Custom;
public byte[] MeshData = new byte[0]; public byte[] MeshData = new byte[0];
public RenderFidelity RenderFidelity = RenderFidelity.Precise; public RenderFidelity RenderFidelity = RenderFidelity.Precise;
public bool UsePartColor = false; public bool UsePartColor = false;
@ -2728,7 +2729,6 @@ namespace RobloxFiles
{ {
IsService = true; IsService = true;
} }
} }
public class StudioData : Instance public class StudioData : Instance
@ -2748,7 +2748,6 @@ namespace RobloxFiles
{ {
IsService = true; IsService = true;
} }
} }
public class Team : Instance public class Team : Instance
@ -2983,7 +2982,6 @@ namespace RobloxFiles
{ {
IsService = true; IsService = true;
} }
} }
public abstract class ValueBase : Instance public abstract class ValueBase : Instance

Binary file not shown.

View File

@ -391,7 +391,6 @@ local function generateClasses()
local firstLine = true local firstLine = true
table.sort(propNames) table.sort(propNames)
if classTags.Service then if classTags.Service then
writeLine("public %s()", className) writeLine("public %s()", className)
openStack() openStack()
@ -399,8 +398,14 @@ local function generateClasses()
writeLine("IsService = true;") writeLine("IsService = true;")
closeStack() closeStack()
if #propNames > 0 then for i, propName in ipairs(propNames) do
local prop = propMap[propName]
local serial = prop.Serialization
if serial.CanLoad then
writeLine() writeLine()
break
end
end end
end end

View File

@ -84,6 +84,23 @@ return
} }
}; };
BevelMesh =
{
Add =
{
Bevel = "float";
Bevel_Roundness = "float";
Bulge = "float";
};
Defaults =
{
Bevel = 0;
Bevel_Roundness = 0;
Bulge = 0;
}
};
BinaryStringValue = BinaryStringValue =
{ {
Add = Add =
@ -387,6 +404,7 @@ return
AssetId = "Content"; AssetId = "Content";
ChildData = "BinaryString"; ChildData = "BinaryString";
MeshData = "BinaryString"; MeshData = "BinaryString";
FormFactor = "Enum:FormFactor";
}; };
Defaults = Defaults =
@ -394,6 +412,7 @@ return
AssetId = ""; AssetId = "";
ChildData = ""; ChildData = "";
MeshData = ""; MeshData = "";
FormFactor = Enum.FormFactor.Custom;
}; };
}; };

View File

@ -21,7 +21,7 @@ namespace RobloxFiles
/// <summary>The ClassName of this Instance.</summary> /// <summary>The ClassName of this Instance.</summary>
public string ClassName => GetType().Name; public string ClassName => GetType().Name;
/// <summary>Internal list of Properties that are under this Instance.</summary> /// <summary>Internal list of properties that are under this Instance.</summary>
private Dictionary<string, Property> props = new Dictionary<string, Property>(); private Dictionary<string, Property> props = new Dictionary<string, Property>();
/// <summary>A list of properties that are defined under this Instance.</summary> /// <summary>A list of properties that are defined under this Instance.</summary>
@ -30,7 +30,7 @@ namespace RobloxFiles
/// <summary>The raw list of children for this Instance.</summary> /// <summary>The raw list of children for this Instance.</summary>
internal List<Instance> Children = new List<Instance>(); internal List<Instance> Children = new List<Instance>();
/// <summary>Raw value of the Instance's parent.</summary> /// <summary>The raw value of the Instance's parent.</summary>
private Instance RawParent; private Instance RawParent;
/// <summary>The name of this Instance.</summary> /// <summary>The name of this Instance.</summary>

View File

@ -6,7 +6,6 @@ using RobloxFiles.BinaryFormat;
using RobloxFiles.BinaryFormat.Chunks; using RobloxFiles.BinaryFormat.Chunks;
using RobloxFiles.DataTypes; using RobloxFiles.DataTypes;
using RobloxFiles.Utility;
namespace RobloxFiles namespace RobloxFiles
{ {
@ -140,6 +139,12 @@ namespace RobloxFiles
} }
} }
if (Name.Contains(" "))
{
var implicitName = Name.Replace(' ', '_');
return implicitName;
}
return Name; return Name;
} }
} }
@ -188,15 +193,44 @@ namespace RobloxFiles
FieldInfo field = Instance.GetType() FieldInfo field = Instance.GetType()
.GetField(ImplicitName, BindingFlags); .GetField(ImplicitName, BindingFlags);
if (field != null)
{
Type fieldType = field.FieldType;
Type valueType = value?.GetType();
if (fieldType == valueType || value == null)
{
try try
{ {
field?.SetValue(Instance, value); field.SetValue(Instance, value);
} }
catch catch
{ {
Console.WriteLine($"RobloxFiles.Property - Failed to cast value {value} into property {Instance.ClassName}.{Name}"); Console.WriteLine($"RobloxFiles.Property - Failed to cast value {value} into property {Instance.ClassName}.{Name}");
} }
} }
else if (valueType != null)
{
var typeWrapper = new Type[] { valueType };
MethodInfo implicitCast = fieldType.GetMethod("op_Implicit", typeWrapper);
if (implicitCast != null)
{
var valueWrapper = new object[] { value };
try
{
object castedValue = implicitCast.Invoke(null, valueWrapper);
field.SetValue(Instance, castedValue);
}
catch
{
Console.WriteLine($"RobloxFiles.Property - Failed to implicitly cast value {value} into property {Instance.ClassName}.{Name}");
}
}
}
}
}
} }
RawValue = value; RawValue = value;