The_Dark_Side_of_Earth/vines_petals/petal.gd

30 lines
780 B
GDScript3
Raw Normal View History

2025-10-21 17:54:43 +02:00
class_name Petal extends GridNode
@export var vine : Vine
2025-10-05 15:01:51 +02:00
@export var vine_resource : PackedScene
2025-10-11 12:47:24 +02:00
var activated = false
# 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
# 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()
vine.petal = self
2025-10-05 15:01:51 +02:00
get_parent().call_deferred("add_child",vine)
# 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