using System.Collections; using System.Collections.Generic; using Godot; using System; namespace Rokojori { public class QuadTreeWalker:TreeWalker> { public override QuadTreeNode Parent( QuadTreeNode node ) { if ( node is QuadTree ) { return null; } var cell = node as QuadTreeCell; return cell.isRoot ? cell.tree : cell.parent; } public override int NumChildren( QuadTreeNode node ) { if ( node is QuadTree tree ) { return tree.rootCells.Count; } var cell = node as QuadTreeCell; return cell.numCells; } public override QuadTreeNode ChildAt( QuadTreeNode node, int index ) { if ( index < 0 || index >= NumChildren( node ) ) { return null; } if ( node is QuadTree tree ) { return tree.rootCells[ index ]; } var cell = node as QuadTreeCell; return cell.cells[ index ]; } } }