Added this[]
overloads to Instance & RobloxFile.
This commit is contained in:
parent
f7184eb8f8
commit
23c222338a
@ -8,6 +8,7 @@ namespace RobloxFiles
|
||||
/// Describes an object in Roblox's DataModel hierarchy.
|
||||
/// Instances can have sets of properties loaded from *.rbxl/*.rbxm files.
|
||||
/// </summary>
|
||||
|
||||
public class Instance
|
||||
{
|
||||
/// <summary>The ClassName of this Instance.</summary>
|
||||
@ -239,5 +240,32 @@ namespace RobloxFiles
|
||||
{
|
||||
Properties.Add(prop);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Treats the provided string as if you were indexing a specific child or descendant of this Instance.<para/>
|
||||
/// The provided string can either be:<para/>
|
||||
/// - The name of a child that is parented to this Instance. ( Example: game["Workspace"] )<para/>
|
||||
/// - A period-separated path to a descendant of this Instance. ( Example: game["Workspace.Terrain"] )<para/>
|
||||
/// This will throw an exception if any instance in the traversal is not found.
|
||||
/// </summary>
|
||||
public Instance this[string accessor]
|
||||
{
|
||||
get
|
||||
{
|
||||
Instance result = this;
|
||||
|
||||
foreach (string name in accessor.Split('.'))
|
||||
{
|
||||
Instance next = result.FindFirstChild(name);
|
||||
|
||||
if (next == null)
|
||||
throw new Exception(name + " is not a valid member of " + result.Name);
|
||||
|
||||
result = next;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -78,5 +78,14 @@ namespace RobloxFiles
|
||||
byte[] buffer = File.ReadAllBytes(filePath);
|
||||
ReadFile(buffer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Treats the provided string as if you were indexing a specific child or descendant of the `RobloxFile.Contents` folder.<para/>
|
||||
/// The provided string can either be:<para/>
|
||||
/// - The name of a child that is parented to RobloxFile.Contents ( Example: RobloxFile["Workspace"] )<para/>
|
||||
/// - A period (.) separated path to a descendant of RobloxFile.Contents ( Example: RobloxFile["Workspace.Terrain"] )<para/>
|
||||
/// This will throw an exception if any instance in the traversal is not found.
|
||||
/// </summary>
|
||||
public Instance this[string accessor] => Contents[accessor];
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ namespace RobloxFiles.DataTypes
|
||||
return new float[] { m14, m24, m34, m11, m12, m13, m21, m22, m23, m31, m32, m33 };
|
||||
}
|
||||
|
||||
public float[] toEulerAnglesXYZ()
|
||||
public float[] ToEulerAnglesXYZ()
|
||||
{
|
||||
float x = (float)Math.Atan2(-m23, m33);
|
||||
float y = (float)Math.Asin(m13);
|
||||
|
@ -25,6 +25,8 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
try
|
||||
{
|
||||
bool custom = readBool("CustomPhysics");
|
||||
prop.Type = PropertyType.PhysicalProperties;
|
||||
|
||||
if (custom)
|
||||
{
|
||||
prop.Value = new PhysicalProperties
|
||||
@ -35,8 +37,6 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
||||
readFloat("FrictionWeight"),
|
||||
readFloat("ElasticityWeight")
|
||||
);
|
||||
|
||||
prop.Type = PropertyType.PhysicalProperties;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user