using Godot; namespace Rokojori { public class Nodes { public static T GetSibling( Node node ) where T:Node { if ( node == null ) { return null; } var parent = node.GetParent(); if ( parent == null ) { return null; } return GetDirectChild( parent ); } public static T GetDirectChild( Node parent ) where T:Node { if ( parent == null ) { return null; } var numChildren = parent.GetChildCount(); for ( int i = 0; i < numChildren; i++ ) { var node = parent.GetChild( i ); if ( node is T ) { return (T)node; } } return null; } static NodesWalker nodesWalker = new NodesWalker(); public static T GetAnyChild( Node parent ) where T:Node { return (T) nodesWalker.Find( parent, ( n )=> n is T, true ); } /* public static void Enable( Node n, bool affectProcess = true, bool affectPhysicsProcess = true, bool affectInput = true ) { SetState.SetStateOfNode( NodeStateType.Enabled, n, affectProcess, affectPhysicsProcess, affectInput ); } public static void Disable( Node n, bool affectProcess = true, bool affectPhysicsProcess = true, bool affectInput = true ) { SetState.SetStateOfNode( NodeStateType.Disabled, n, affectProcess, affectPhysicsProcess, affectInput ); } public static void Iterate( Node[] nodes, System.Action callback ) { for ( int i = 0; i < nodes.Length; i++ ) { nodesWalker.Iterate( nodes[ i ], callback ); } } */ } }