Small enhancements introduced from Rbx2Source migration.
This commit is contained in:
parent
7252e96c03
commit
d1535c9a15
@ -353,11 +353,22 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var info = ImplicitMember.Get(instType, Name);
|
var info = ImplicitMember.Get(instType, Name);
|
||||||
|
|
||||||
|
if (info == null)
|
||||||
|
{
|
||||||
|
if (RobloxFile.LogErrors)
|
||||||
|
Console.Error.WriteLine($"Enum cast failed for {inst.ClassName}.{Name} using value {value}!");
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
return Enum.Parse(info.MemberType, value.ToInvariantString());
|
return Enum.Parse(info.MemberType, value.ToInvariantString());
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Enum cast failed for {inst.ClassName}.{Name} using value {value}!");
|
if (RobloxFile.LogErrors)
|
||||||
|
Console.Error.WriteLine($"Enum cast failed for {inst.ClassName}.{Name} using value {value}!");
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -522,7 +533,9 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (RobloxFile.LogErrors)
|
||||||
Console.Error.WriteLine("Unhandled property type: {0}!", Type);
|
Console.Error.WriteLine("Unhandled property type: {0}!", Type);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@ -346,20 +346,29 @@ namespace RobloxFiles.DataTypes
|
|||||||
return new CFrame(0, 0, 0, r.X, u.X, b.X, r.Y, u.Y, b.Y, r.Z, u.Z, b.Z);
|
return new CFrame(0, 0, 0, r.X, u.X, b.X, r.Y, u.Y, b.Y, r.Z, u.Z, b.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CFrame Angles(float x, float y, float z)
|
public static CFrame FromEulerAnglesXYZ(float x, float y, float z)
|
||||||
{
|
{
|
||||||
CFrame cfx = FromAxisAngle(Vector3.Right, x);
|
CFrame cfx = FromAxisAngle(Vector3.Right, x),
|
||||||
CFrame cfy = FromAxisAngle(Vector3.Up, y);
|
cfy = FromAxisAngle(Vector3.Up, y),
|
||||||
CFrame cfz = FromAxisAngle(Vector3.Back, z);
|
cfz = FromAxisAngle(Vector3.Back, z);
|
||||||
|
|
||||||
return cfx * cfy * cfz;
|
return cfx * cfy * cfz;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CFrame FromEulerAnglesXYZ(float x, float y, float z)
|
public static CFrame FromEulerAnglesXYZ(params float[] angles)
|
||||||
{
|
{
|
||||||
return Angles(x, y, z);
|
Contract.Requires(angles.Length == 3);
|
||||||
|
|
||||||
|
float x = angles[0],
|
||||||
|
y = angles[1],
|
||||||
|
z = angles[2];
|
||||||
|
|
||||||
|
return FromEulerAnglesXYZ(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CFrame Angles(float x, float y, float z) => FromEulerAnglesXYZ(x, y, z);
|
||||||
|
public static CFrame Angles(params float[] angles) => FromEulerAnglesXYZ(angles);
|
||||||
|
|
||||||
public CFrame Lerp(CFrame other, float t)
|
public CFrame Lerp(CFrame other, float t)
|
||||||
{
|
{
|
||||||
if (t == 0f)
|
if (t == 0f)
|
||||||
|
@ -65,20 +65,13 @@ namespace RobloxFiles.DataTypes
|
|||||||
|
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0 : return new Color3(v, k, m);
|
||||||
return new Color3(v, k, m);
|
case 1 : return new Color3(n, v, m);
|
||||||
case 1:
|
case 2 : return new Color3(m, v, k);
|
||||||
return new Color3(n, v, m);
|
case 3 : return new Color3(m, n, v);
|
||||||
case 2:
|
case 4 : return new Color3(k, m, v);
|
||||||
return new Color3(m, v, k);
|
case 5 : return new Color3(v, m, n);
|
||||||
case 3:
|
default : return new Color3(0, 0, 0);
|
||||||
return new Color3(m, n, v);
|
|
||||||
case 4:
|
|
||||||
return new Color3(k, m, v);
|
|
||||||
case 5:
|
|
||||||
return new Color3(v, m, n);
|
|
||||||
default:
|
|
||||||
return new Color3();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>1</WarningLevel>
|
<WarningLevel>1</WarningLevel>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<StartupObject />
|
<StartupObject />
|
||||||
|
Binary file not shown.
@ -56,6 +56,9 @@ namespace RobloxFiles
|
|||||||
/// <summary>Indicates whether this Instance is a Service.</summary>
|
/// <summary>Indicates whether this Instance is a Service.</summary>
|
||||||
public bool IsService { get; internal set; }
|
public bool IsService { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>Indicates whether this Instance has been destroyed.</summary>
|
||||||
|
public bool Destroyed { get; internal set; }
|
||||||
|
|
||||||
/// <summary>A list of CollectionService tags assigned to this Instance.</summary>
|
/// <summary>A list of CollectionService tags assigned to this Instance.</summary>
|
||||||
public List<string> Tags { get; } = new List<string>();
|
public List<string> Tags { get; } = new List<string>();
|
||||||
|
|
||||||
@ -200,14 +203,11 @@ namespace RobloxFiles
|
|||||||
if (Parent == this)
|
if (Parent == this)
|
||||||
throw new InvalidOperationException($"Attempt to set {Name} as its own parent");
|
throw new InvalidOperationException($"Attempt to set {Name} as its own parent");
|
||||||
|
|
||||||
lock (ParentUnsafe)
|
|
||||||
{
|
|
||||||
ParentUnsafe?.Children.Remove(this);
|
ParentUnsafe?.Children.Remove(this);
|
||||||
value?.Children.Add(this);
|
value?.Children.Add(this);
|
||||||
ParentUnsafe = value;
|
ParentUnsafe = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an array containing all the children of this Instance.
|
/// Returns an array containing all the children of this Instance.
|
||||||
@ -418,6 +418,28 @@ namespace RobloxFiles
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes of this instance and its descendants, and locks its parent.
|
||||||
|
/// All property bindings, tags, and attributes are cleared.
|
||||||
|
/// </summary>
|
||||||
|
public void Destroy()
|
||||||
|
{
|
||||||
|
Destroyed = true;
|
||||||
|
props.Clear();
|
||||||
|
|
||||||
|
Parent = null;
|
||||||
|
ParentLocked = true;
|
||||||
|
|
||||||
|
Tags?.Clear();
|
||||||
|
Attributes?.Clear();
|
||||||
|
|
||||||
|
while (Children.Any())
|
||||||
|
{
|
||||||
|
var child = Children.First();
|
||||||
|
child.Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the first child of this Instance which derives from the provided type <typeparamref name="T"/>.
|
/// Returns the first child of this Instance which derives from the provided type <typeparamref name="T"/>.
|
||||||
/// If the instance is not found, this returns null.
|
/// If the instance is not found, this returns null.
|
||||||
|
@ -114,7 +114,7 @@ namespace RobloxFiles.XmlFormat
|
|||||||
}
|
}
|
||||||
else if (RobloxFile.LogErrors)
|
else if (RobloxFile.LogErrors)
|
||||||
{
|
{
|
||||||
Console.WriteLine("No IXmlPropertyToken found for property type: " + propType + '!');
|
Console.Error.WriteLine("No IXmlPropertyToken found for property type: " + propType + '!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
public class Color3Token : IXmlPropertyToken
|
public class Color3Token : IXmlPropertyToken
|
||||||
{
|
{
|
||||||
public string Token => "Color3";
|
public string Token => "Color3";
|
||||||
private string[] Fields = new string[3] { "R", "G", "B" };
|
private readonly string[] Fields = new string[3] { "R", "G", "B" };
|
||||||
|
|
||||||
public bool ReadProperty(Property prop, XmlNode token)
|
public bool ReadProperty(Property prop, XmlNode token)
|
||||||
{
|
{
|
||||||
@ -21,7 +21,15 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var coord = token[key];
|
var coord = token[key];
|
||||||
fields[i] = Formatting.ParseFloat(coord.InnerText);
|
string text = coord?.InnerText;
|
||||||
|
|
||||||
|
if (text == null)
|
||||||
|
{
|
||||||
|
text = "0";
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fields[i] = Formatting.ParseFloat(text);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
if (!RobloxFile.LogErrors)
|
if (!RobloxFile.LogErrors)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Console.WriteLine("ContentToken: Got illegal base64 string: {0}", data);
|
Console.Error.WriteLine("ContentToken: Got illegal base64 string: {0}", data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user