using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Poco { public class AbstractDumper: IDumper { public virtual AbstractNode getRoot () { return null; } public Dictionary dumpHierarchy () { return dumpHierarchyImpl (getRoot (), true); } public Dictionary dumpHierarchy (bool onlyVisibleNode) { return dumpHierarchyImpl (getRoot (), onlyVisibleNode); } private Dictionary dumpHierarchyImpl (AbstractNode node, bool onlyVisibleNode) { if (node == null) { return null; } Dictionary payload = node.enumerateAttrs (); Dictionary result = new Dictionary (); string name = (string)node.getAttr ("name"); result.Add ("name", name); result.Add ("payload", payload); List children = new List (); foreach (AbstractNode child in node.getChildren()) { if (!onlyVisibleNode || (bool)child.getAttr ("visible")) { children.Add (dumpHierarchyImpl (child, onlyVisibleNode)); } } if (children.Count > 0) { result.Add ("children", children); } return result; } public virtual List getPortSize () { return null; } } public interface IDumper { AbstractNode getRoot (); Dictionary dumpHierarchy (); Dictionary dumpHierarchy (bool onlyVisibleNode); List getPortSize (); } }