Small enhancements introduced from Rbx2Source migration.
This commit is contained in:
parent
7252e96c03
commit
d1535c9a15
@ -353,11 +353,22 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
try
|
||||
{
|
||||
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());
|
||||
}
|
||||
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;
|
||||
}
|
||||
});
|
||||
@ -522,7 +533,9 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
|
||||
break;
|
||||
default:
|
||||
Console.Error.WriteLine("Unhandled property type: {0}!", Type);
|
||||
if (RobloxFile.LogErrors)
|
||||
Console.Error.WriteLine("Unhandled property type: {0}!", Type);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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 cfy = FromAxisAngle(Vector3.Up, y);
|
||||
CFrame cfz = FromAxisAngle(Vector3.Back, z);
|
||||
CFrame cfx = FromAxisAngle(Vector3.Right, x),
|
||||
cfy = FromAxisAngle(Vector3.Up, y),
|
||||
cfz = FromAxisAngle(Vector3.Back, z);
|
||||
|
||||
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)
|
||||
{
|
||||
if (t == 0f)
|
||||
|
@ -65,20 +65,13 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
return new Color3(v, k, m);
|
||||
case 1:
|
||||
return new Color3(n, v, m);
|
||||
case 2:
|
||||
return new Color3(m, v, k);
|
||||
case 3:
|
||||
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();
|
||||
case 0 : return new Color3(v, k, m);
|
||||
case 1 : return new Color3(n, v, m);
|
||||
case 2 : return new Color3(m, v, k);
|
||||
case 3 : 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(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>1</WarningLevel>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
|
Binary file not shown.
@ -56,6 +56,9 @@ namespace RobloxFiles
|
||||
/// <summary>Indicates whether this Instance is a Service.</summary>
|
||||
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>
|
||||
public List<string> Tags { get; } = new List<string>();
|
||||
|
||||
@ -200,12 +203,9 @@ namespace RobloxFiles
|
||||
if (Parent == this)
|
||||
throw new InvalidOperationException($"Attempt to set {Name} as its own parent");
|
||||
|
||||
lock (ParentUnsafe)
|
||||
{
|
||||
ParentUnsafe?.Children.Remove(this);
|
||||
value?.Children.Add(this);
|
||||
ParentUnsafe = value;
|
||||
}
|
||||
ParentUnsafe?.Children.Remove(this);
|
||||
value?.Children.Add(this);
|
||||
ParentUnsafe = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,6 +418,28 @@ namespace RobloxFiles
|
||||
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>
|
||||
/// 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.
|
||||
|
@ -114,7 +114,7 @@ namespace RobloxFiles.XmlFormat
|
||||
}
|
||||
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 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)
|
||||
{
|
||||
@ -21,7 +21,15 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
try
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
if (!RobloxFile.LogErrors)
|
||||
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