Implement `Node.GetChildrenEnumerable` extension

master
John Montagu, the 4th Earl of Sandvich 2024-10-18 15:02:05 -07:00
parent b5b3f86fb6
commit d9f36896ad
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
1 changed files with 10 additions and 0 deletions

View File

@ -1,4 +1,5 @@
using Godot;
using IEnumerableNode = System.Collections.Generic.IEnumerable<Godot.Node>;
namespace SupaLidlGame.Extensions;
@ -55,4 +56,13 @@ public static class NodeExtensions
return node.GetNode<UI.UIController>("/root/BaseUI/" +
"SubViewportContainer/UIViewport/CanvasLayer/MainUILayer/Main");
}
public static IEnumerableNode GetChildrenEnumerable(this Node node)
{
int childCount = node.GetChildCount();
for (int i = 0; i < childCount; i++)
{
yield return node.GetChild(i);
}
}
}