Initial commit

This commit is contained in:
AXOLOTsh
2026-03-01 08:32:24 +03:00
commit 80e7624617
44 changed files with 2351 additions and 0 deletions

21
source/ComponentUtils.cs Normal file
View File

@@ -0,0 +1,21 @@
using Godot;
using Godot.Collections;
using System.ComponentModel;
namespace FactoryGame;
public class ComponentUtils {
public static Array<T> GetComponents<[MustBeVariant] T>(Node node, int iterations = 1) where T : IComponent {
var result = new Array<T>();
var children = node.GetChildren();
foreach (var item in children) {
if (item is T component)
result.Add(component);
}
return result;
}
public static T? GetComponent<[MustBeVariant] T>(Node node, int index = 0) where T : IComponent =>
GetComponents<T>(node)[index];
}