The_Dark_Side_of_Earth/petal.gd

32 lines
1,000 B
GDScript3
Raw Normal View History

2025-10-11 12:47:24 +02:00
class_name Petal extends Node2D
2025-10-05 15:01:51 +02:00
@onready var grid : Grid = get_tree().get_root().get_node("main/Earth/Grid")
2025-10-11 12:47:24 +02:00
@onready var location : Vector2 = grid.get_location_from_world_pos(global_position)
@onready var offset : Vector2 = grid.get_offset_from_world_pos(global_position)
2025-10-05 15:01:51 +02:00
@export var vine_resource : PackedScene
var vine : Vine
2025-10-11 12:47:24 +02:00
var activated = false
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
func _ready() -> void:
await get_tree().create_timer(1).timeout
vine = vine_resource.instantiate()
vine.petal_location = Global.vec_mod(location, grid.num_collumns)
vine.petal_offset = offset
get_parent().call_deferred("add_child",vine)
await get_tree().create_timer(1).timeout
vine.init_random()
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