From d9f36896ad127231c88df523feced64ba065ba78 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Fri, 18 Oct 2024 15:02:05 -0700 Subject: [PATCH] Implement `Node.GetChildrenEnumerable` extension --- Extensions/Node.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Extensions/Node.cs b/Extensions/Node.cs index 757d6ee..8087a5b 100644 --- a/Extensions/Node.cs +++ b/Extensions/Node.cs @@ -1,4 +1,5 @@ using Godot; +using IEnumerableNode = System.Collections.Generic.IEnumerable; namespace SupaLidlGame.Extensions; @@ -55,4 +56,13 @@ public static class NodeExtensions return node.GetNode("/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); + } + } }