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:
parent
de8df15d3f
commit
4e1fdc0a22
@ -6,7 +6,6 @@ using System.Text;
|
||||
|
||||
using RobloxFiles.Enums;
|
||||
using RobloxFiles.DataTypes;
|
||||
using RobloxFiles.Utility;
|
||||
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using RobloxFiles.Utility;
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using RobloxFiles.DataTypes;
|
||||
|
||||
namespace RobloxFiles.Utility
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Quaternion is a utility used by the CFrame DataType to handle rotation interpolation.
|
||||
|
@ -644,7 +644,6 @@ namespace RobloxFiles
|
||||
{
|
||||
IsService = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ContextActionService : Instance
|
||||
@ -723,6 +722,9 @@ namespace RobloxFiles
|
||||
|
||||
public abstract class BevelMesh : DataModelMesh
|
||||
{
|
||||
public float Bevel = 0;
|
||||
public float Bevel_Roundness = 0;
|
||||
public float Bulge = 0;
|
||||
}
|
||||
|
||||
public class BlockMesh : BevelMesh
|
||||
@ -1758,7 +1760,6 @@ namespace RobloxFiles
|
||||
{
|
||||
IsService = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class LocalizationTable : Instance
|
||||
@ -1866,7 +1867,6 @@ namespace RobloxFiles
|
||||
{
|
||||
IsService = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public abstract class PVInstance : Instance
|
||||
@ -2065,6 +2065,7 @@ namespace RobloxFiles
|
||||
{
|
||||
public Content AssetId = "";
|
||||
public byte[] ChildData = new byte[0];
|
||||
public FormFactor FormFactor = FormFactor.Custom;
|
||||
public byte[] MeshData = new byte[0];
|
||||
public RenderFidelity RenderFidelity = RenderFidelity.Precise;
|
||||
public bool UsePartColor = false;
|
||||
@ -2728,7 +2729,6 @@ namespace RobloxFiles
|
||||
{
|
||||
IsService = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class StudioData : Instance
|
||||
@ -2748,7 +2748,6 @@ namespace RobloxFiles
|
||||
{
|
||||
IsService = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Team : Instance
|
||||
@ -2983,7 +2982,6 @@ namespace RobloxFiles
|
||||
{
|
||||
IsService = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public abstract class ValueBase : Instance
|
||||
|
Binary file not shown.
@ -391,7 +391,6 @@ local function generateClasses()
|
||||
local firstLine = true
|
||||
table.sort(propNames)
|
||||
|
||||
|
||||
if classTags.Service then
|
||||
writeLine("public %s()", className)
|
||||
openStack()
|
||||
@ -399,8 +398,14 @@ local function generateClasses()
|
||||
writeLine("IsService = true;")
|
||||
closeStack()
|
||||
|
||||
if #propNames > 0 then
|
||||
writeLine()
|
||||
for i, propName in ipairs(propNames) do
|
||||
local prop = propMap[propName]
|
||||
local serial = prop.Serialization
|
||||
|
||||
if serial.CanLoad then
|
||||
writeLine()
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -84,6 +84,23 @@ return
|
||||
}
|
||||
};
|
||||
|
||||
BevelMesh =
|
||||
{
|
||||
Add =
|
||||
{
|
||||
Bevel = "float";
|
||||
Bevel_Roundness = "float";
|
||||
Bulge = "float";
|
||||
};
|
||||
|
||||
Defaults =
|
||||
{
|
||||
Bevel = 0;
|
||||
Bevel_Roundness = 0;
|
||||
Bulge = 0;
|
||||
}
|
||||
};
|
||||
|
||||
BinaryStringValue =
|
||||
{
|
||||
Add =
|
||||
@ -387,6 +404,7 @@ return
|
||||
AssetId = "Content";
|
||||
ChildData = "BinaryString";
|
||||
MeshData = "BinaryString";
|
||||
FormFactor = "Enum:FormFactor";
|
||||
};
|
||||
|
||||
Defaults =
|
||||
@ -394,6 +412,7 @@ return
|
||||
AssetId = "";
|
||||
ChildData = "";
|
||||
MeshData = "";
|
||||
FormFactor = Enum.FormFactor.Custom;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace RobloxFiles
|
||||
/// <summary>The ClassName of this Instance.</summary>
|
||||
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>();
|
||||
|
||||
/// <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>
|
||||
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;
|
||||
|
||||
/// <summary>The name of this Instance.</summary>
|
||||
|
@ -6,7 +6,6 @@ using RobloxFiles.BinaryFormat;
|
||||
using RobloxFiles.BinaryFormat.Chunks;
|
||||
|
||||
using RobloxFiles.DataTypes;
|
||||
using RobloxFiles.Utility;
|
||||
|
||||
namespace RobloxFiles
|
||||
{
|
||||
@ -140,6 +139,12 @@ namespace RobloxFiles
|
||||
}
|
||||
}
|
||||
|
||||
if (Name.Contains(" "))
|
||||
{
|
||||
var implicitName = Name.Replace(' ', '_');
|
||||
return implicitName;
|
||||
}
|
||||
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
@ -188,13 +193,42 @@ namespace RobloxFiles
|
||||
FieldInfo field = Instance.GetType()
|
||||
.GetField(ImplicitName, BindingFlags);
|
||||
|
||||
try
|
||||
if (field != null)
|
||||
{
|
||||
field?.SetValue(Instance, value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine($"RobloxFiles.Property - Failed to cast value {value} into property {Instance.ClassName}.{Name}");
|
||||
Type fieldType = field.FieldType;
|
||||
Type valueType = value?.GetType();
|
||||
|
||||
if (fieldType == valueType || value == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
field.SetValue(Instance, value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user