diff options
Diffstat (limited to 'Scripts/GodotExtensions')
| -rw-r--r-- | Scripts/GodotExtensions/ArrayExtensions.cs | 13 | ||||
| -rw-r--r-- | Scripts/GodotExtensions/NodeExtensions.cs | 14 |
2 files changed, 27 insertions, 0 deletions
diff --git a/Scripts/GodotExtensions/ArrayExtensions.cs b/Scripts/GodotExtensions/ArrayExtensions.cs new file mode 100644 index 0000000..aa3a9c4 --- /dev/null +++ b/Scripts/GodotExtensions/ArrayExtensions.cs @@ -0,0 +1,13 @@ +using System; +using Godot.Collections; + +namespace Texty.Scripts.GodotExtensions +{ + public static class ArrayExtensions + { + public static void ForEach<T>(this Array<T> array, Action<T> action) + { + foreach (var element in array) action.Invoke(element); + } + } +}
\ No newline at end of file diff --git a/Scripts/GodotExtensions/NodeExtensions.cs b/Scripts/GodotExtensions/NodeExtensions.cs new file mode 100644 index 0000000..b398985 --- /dev/null +++ b/Scripts/GodotExtensions/NodeExtensions.cs @@ -0,0 +1,14 @@ +using System.Linq; +using Godot; +using Godot.Collections; + +namespace Texty.Scripts.GodotExtensions +{ + public static class NodeExtensions + { + public static Array<T> GetChildren<T>(this Node node) + { + return new Array<T>(node.GetChildren().OfType<T>()); + } + } +}
\ No newline at end of file |
