fix item pickups wtf

This commit is contained in:
Rowan 2025-05-07 15:56:21 -05:00
parent d7e7a6156a
commit 0f1d693be6
2 changed files with 2 additions and 5 deletions

View file

@ -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")

View file

@ -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<Node> = 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)