2024-07-09 22:33:38 +02:00
|
|
|
@tool
|
|
|
|
class_name PickupItem
|
|
|
|
extends Node3D
|
|
|
|
|
|
|
|
var editor_child_scene:Node3D = null
|
|
|
|
|
|
|
|
@export var item:Item:
|
|
|
|
get:
|
|
|
|
return item
|
|
|
|
set(value):
|
|
|
|
if value != item:
|
|
|
|
item = value
|
|
|
|
|
|
|
|
if editor_child_scene != null:
|
|
|
|
editor_child_scene.queue_free()
|
2024-08-15 21:13:09 +02:00
|
|
|
|
|
|
|
if not Engine.is_editor_hint():
|
|
|
|
return
|
|
|
|
|
2024-07-09 22:33:38 +02:00
|
|
|
editor_child_scene = item.scene.instantiate()
|
|
|
|
add_child(editor_child_scene)
|
|
|
|
editor_child_scene.owner = self
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
var item_scene = item.scene.instantiate()
|
|
|
|
add_child(item_scene)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_area_3d_body_entered(body):
|
|
|
|
if body.has_method("on_item_picked_up"):
|
|
|
|
body.on_item_picked_up(item)
|
|
|
|
queue_free()
|