The_Dark_Side_of_Earth/vines_petals/petal.gd

28 lines
756 B
GDScript

class_name Petal extends VineNode
@export var vine_resource : PackedScene
var activated = false
# Adding an item here automatically locks it inside the petal
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)
# Upon being placed inside a building, create a vine
func _enter_grid() -> void:
depth = 0
vine = vine_resource.instantiate()
vine.petal = self
get_parent().call_deferred("add_child",vine)
# Upon interaction, release the item and activate the vine
func _on_interaction() -> void:
activated = true
vine.activate()
if item != null:
item.monitorable = true
item.monitoring = true
item.modulate = Color.WHITE