Convert datatypes to classes instead of structs.
This commit is contained in:
@ -20,7 +20,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
uint g = (value >> 8) & 0xFF;
|
||||
uint b = value & 0xFF;
|
||||
|
||||
prop.Value = Color3.fromRGB(r, g, b);
|
||||
prop.Value = Color3.FromRGB(r, g, b);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -10,31 +10,30 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadToken(Property prop, XmlNode token)
|
||||
{
|
||||
Vector3[] read = new Vector3[Fields.Length];
|
||||
|
||||
for (int i = 0; i < read.Length; i++)
|
||||
try
|
||||
{
|
||||
string field = Fields[i];
|
||||
try
|
||||
Vector3[] read = new Vector3[Fields.Length];
|
||||
|
||||
for (int i = 0; i < read.Length; i++)
|
||||
{
|
||||
string field = Fields[i];
|
||||
var fieldToken = token[field];
|
||||
Vector3? vector3 = Vector3Token.ReadVector3(fieldToken);
|
||||
read[i] = vector3.Value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
read[i] = Vector3Token.ReadVector3(fieldToken);
|
||||
}
|
||||
|
||||
Vector3 origin = read[0],
|
||||
direction = read[1];
|
||||
|
||||
Ray ray = new Ray(origin, direction);
|
||||
prop.Type = PropertyType.Ray;
|
||||
prop.Value = ray;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 origin = read[0],
|
||||
direction = read[1];
|
||||
|
||||
Ray ray = new Ray(origin, direction);
|
||||
prop.Type = PropertyType.Ray;
|
||||
prop.Value = ray;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,31 +10,30 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadToken(Property prop, XmlNode token)
|
||||
{
|
||||
Vector2[] read = new Vector2[Fields.Length];
|
||||
|
||||
for (int i = 0; i < read.Length; i++)
|
||||
try
|
||||
{
|
||||
string field = Fields[i];
|
||||
try
|
||||
Vector2[] read = new Vector2[Fields.Length];
|
||||
|
||||
for (int i = 0; i < read.Length; i++)
|
||||
{
|
||||
string field = Fields[i];
|
||||
var fieldToken = token[field];
|
||||
Vector2? vector2 = Vector2Token.ReadVector2(fieldToken);
|
||||
read[i] = vector2.Value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
read[i] = Vector2Token.ReadVector2(fieldToken);
|
||||
}
|
||||
|
||||
Vector2 min = read[0],
|
||||
max = read[1];
|
||||
|
||||
Rect rect = new Rect(min, max);
|
||||
prop.Type = PropertyType.Rect;
|
||||
prop.Value = rect;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2 min = read[0],
|
||||
max = read[1];
|
||||
|
||||
Rect rect = new Rect(min, max);
|
||||
prop.Type = PropertyType.Rect;
|
||||
prop.Value = rect;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
{
|
||||
public string Token => "UDim";
|
||||
|
||||
public static UDim? ReadUDim(XmlNode token, string prefix = "")
|
||||
public static UDim ReadUDim(XmlNode token, string prefix = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -27,13 +27,13 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadToken(Property property, XmlNode token)
|
||||
{
|
||||
UDim? result = ReadUDim(token);
|
||||
bool success = result.HasValue;
|
||||
UDim result = ReadUDim(token);
|
||||
bool success = (result != null);
|
||||
|
||||
if (success)
|
||||
{
|
||||
property.Type = PropertyType.UDim;
|
||||
property.Value = result.Value;
|
||||
property.Value = result;
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -9,13 +9,13 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadToken(Property property, XmlNode token)
|
||||
{
|
||||
UDim? xDim = UDimToken.ReadUDim(token, "X");
|
||||
UDim? yDim = UDimToken.ReadUDim(token, "Y");
|
||||
UDim xUDim = UDimToken.ReadUDim(token, "X");
|
||||
UDim yUDim = UDimToken.ReadUDim(token, "Y");
|
||||
|
||||
if (xDim != null && yDim != null)
|
||||
if (xUDim != null && yUDim != null)
|
||||
{
|
||||
property.Type = PropertyType.UDim2;
|
||||
property.Value = new UDim2(xDim.Value, yDim.Value);
|
||||
property.Value = new UDim2(xUDim, yUDim);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
public string Token => "Vector2";
|
||||
private static string[] Coords = new string[2] { "X", "Y" };
|
||||
|
||||
public static Vector2? ReadVector2(XmlNode token)
|
||||
public static Vector2 ReadVector2(XmlNode token)
|
||||
{
|
||||
float[] xy = new float[2];
|
||||
|
||||
@ -33,13 +33,13 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadToken(Property property, XmlNode token)
|
||||
{
|
||||
Vector2? result = ReadVector2(token);
|
||||
bool success = result.HasValue;
|
||||
Vector2 result = ReadVector2(token);
|
||||
bool success = (result != null);
|
||||
|
||||
if (success)
|
||||
{
|
||||
property.Type = PropertyType.Vector2;
|
||||
property.Value = result.Value;
|
||||
property.Value = result;
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -8,7 +8,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
public string Token => "Vector3";
|
||||
private static string[] Coords = new string[3] { "X", "Y", "Z" };
|
||||
|
||||
public static Vector3? ReadVector3(XmlNode token)
|
||||
public static Vector3 ReadVector3(XmlNode token)
|
||||
{
|
||||
float[] xyz = new float[3];
|
||||
|
||||
@ -32,13 +32,13 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
|
||||
public bool ReadToken(Property property, XmlNode token)
|
||||
{
|
||||
Vector3? result = ReadVector3(token);
|
||||
bool success = result.HasValue;
|
||||
Vector3 result = ReadVector3(token);
|
||||
bool success = (result != null);
|
||||
|
||||
if (success)
|
||||
{
|
||||
property.Type = PropertyType.Vector3;
|
||||
property.Value = result.Value;
|
||||
property.Value = result;
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -26,7 +26,7 @@ namespace RobloxFiles.XmlFormat
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new Exception("XmlRobloxFile: Could not read XML!");
|
||||
throw new Exception("XmlRobloxFile: Could not read provided buffer as XML!");
|
||||
}
|
||||
|
||||
XmlNode roblox = Root.FirstChild;
|
||||
|
Reference in New Issue
Block a user