diff --git a/scripts/item/ItemTypeManager.cs b/scripts/item/ItemTypeManager.cs
index cf7261d..f91b4e2 100644
--- a/scripts/item/ItemTypeManager.cs
+++ b/scripts/item/ItemTypeManager.cs
@@ -67,12 +67,13 @@ public static class ItemTypeManager
/// 全局坐标中的位置
///
///
- public static void CreateItem(string id, Node? parent = null, Vector2? position = null)
+ public static IItem? CreateItem(string id, Node? parent = null, Vector2? position = null)
{
var item = NewItem(id);
- parent?.AddChild(item as Node);
- if (item is not Node2D node) return;
+ parent?.CallDeferred("add_child", (item as Node)!);
+ if (item is not Node2D node) return item;
if (position is { } pos) node.GlobalPosition = pos;
+ return item;
}
///
@@ -87,12 +88,16 @@ public static class ItemTypeManager
/// 全局坐标中的位置
///
///
- public static void CreateItems(string id, int amount, Node? parent = null, Vector2? position = null)
+ public static IList CreateItems(string id, int amount, Node? parent = null, Vector2? position = null)
{
+ IList result = [];
for (int i = 0; i < amount; i++)
{
- CreateItem(id, parent, position);
+ if (CreateItem(id, parent, position) is { } item)
+ result.Add(item);
}
+
+ return result;
}
///