2025-10-21 16:06:16 +02:00
|
|
|
class_name Petal extends VineNode
|
2025-10-05 15:01:51 +02:00
|
|
|
@export var vine_resource : PackedScene
|
2025-10-11 12:47:24 +02:00
|
|
|
var activated = false
|
2025-10-21 16:06:16 +02:00
|
|
|
|
|
|
|
|
# Adding an item here automatically locks it inside the petal
|
2025-10-11 12:47:24 +02:00
|
|
|
var item : Item:
|
|
|
|
|
set(item_in):
|
|
|
|
|
item = item_in
|
|
|
|
|
if not activated and item is Item:
|
|
|
|
|
item.monitoring = false
|
|
|
|
|
item.monitorable = false
|
|
|
|
|
item.modulate = Color(1,1,1,0.8)
|
2025-10-05 15:01:51 +02:00
|
|
|
|
2025-10-21 16:06:16 +02:00
|
|
|
# Upon being placed inside a building, create a vine
|
|
|
|
|
func _enter_grid() -> void:
|
|
|
|
|
depth = 0
|
2025-10-05 15:01:51 +02:00
|
|
|
vine = vine_resource.instantiate()
|
2025-10-21 16:06:16 +02:00
|
|
|
vine.petal = self
|
2025-10-05 15:01:51 +02:00
|
|
|
get_parent().call_deferred("add_child",vine)
|
|
|
|
|
|
2025-10-21 16:06:16 +02:00
|
|
|
# Upon interaction, release the item and activate the vine
|
2025-10-05 15:01:51 +02:00
|
|
|
func _on_interaction() -> void:
|
2025-10-11 12:47:24 +02:00
|
|
|
activated = true
|
2025-10-05 15:01:51 +02:00
|
|
|
vine.activate()
|
2025-10-11 12:47:24 +02:00
|
|
|
if item != null:
|
|
|
|
|
item.monitorable = true
|
|
|
|
|
item.monitoring = true
|
|
|
|
|
item.modulate = Color.WHITE
|