using System.Collections;
using System.Collections.Generic;
namespace AssetRipper.MeshSharp.FBX
{
///
/// Base class for nodes and documents
///
public abstract class FbxNodeCollection : IEnumerable
{
///
/// The list of child/nested nodes
///
///
/// A list with one or more null elements is treated differently than an empty list,
/// and represented differently in all FBX output files.
///
public List Nodes { get; } = new List();
///
/// Gets a named child node
///
///
/// The child node, or null
public FbxNode this[string name] { get { return Nodes.Find(n => n != null && n.Name == name); } }
///
/// Gets a child node, using a '/' separated path
///
///
/// The child node, or null
public FbxNode GetRelative(string path)
{
string[] tokens = path.Split('/');
FbxNodeCollection n = this;
foreach (var t in tokens)
{
if (t == "")
continue;
n = n[t];
if (n == null)
break;
}
return n as FbxNode;
}
public IEnumerator GetEnumerator()
{
return Nodes.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return Nodes.GetEnumerator();
}
}
}