diff --git a/scenes/node_3d.tscn b/scenes/node_3d.tscn index 3c113ce..d4874c0 100644 --- a/scenes/node_3d.tscn +++ b/scenes/node_3d.tscn @@ -52,7 +52,6 @@ transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, [node name="Door" type="Node3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10, 1, 0) -visible = false script = ExtResource("3_imxmk") locked = true requires_key = true @@ -78,7 +77,6 @@ outline_size = 32 [node name="DoorKey" type="Node3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -5) -visible = false script = ExtResource("6_qe67v") resource = ExtResource("4_3rynd") diff --git a/src/inventory.ts b/src/inventory.ts index ff7fe52..704aa71 100644 --- a/src/inventory.ts +++ b/src/inventory.ts @@ -2,6 +2,7 @@ import { clampi, Node, StringName } from 'godot' import ItemData from './item' import { GArrayEnumerator } from './collection/enumerable' import { Enumerable } from '../addons/enumerable-ts/src/index' +import { find_in_descendents } from './node' class ItemInstance { readonly resource: ItemData @@ -48,9 +49,7 @@ export default class Inventory extends Node { return Inventory.cache.get(root) } - const child_enumerator: GArrayEnumerator = new GArrayEnumerator(root.get_children()) - const children = Enumerable.from(child_enumerator) - const inventory = children.find(child => child instanceof Inventory) as Inventory + const inventory = find_in_descendents(root, n => n instanceof Inventory) as Inventory if (inventory != null) { Inventory.cache.set(root, inventory)