38 lines
932 B
GDScript
38 lines
932 B
GDScript
extends Node2D
|
|
|
|
const RESEARCH_GOAL_ID: StringName = &"gold_350k_wood_20k"
|
|
|
|
@onready var _research_panel: ResearchPanel = $ResearchPanel
|
|
@onready var _sprite: Sprite2D = $Sprite2D
|
|
@onready var _area: Area2D = $Area2D
|
|
@onready var game_state: LevelGameState = find_parent("LevelGameState")
|
|
|
|
|
|
func _ready() -> void:
|
|
_research_panel.visible = false
|
|
_sprite.visible = false
|
|
_area.monitoring = false
|
|
if game_state:
|
|
game_state.goal_completed.connect(_on_goal_completed)
|
|
if game_state.is_goal_completed(RESEARCH_GOAL_ID):
|
|
_unlock()
|
|
|
|
|
|
func _on_area_2d_mouse_entered() -> void:
|
|
if game_state and game_state.is_goal_completed(RESEARCH_GOAL_ID):
|
|
_research_panel.visible = true
|
|
|
|
|
|
func _on_area_2d_mouse_exited() -> void:
|
|
_research_panel.visible = false
|
|
|
|
|
|
func _on_goal_completed(goal_id: StringName) -> void:
|
|
if goal_id == RESEARCH_GOAL_ID:
|
|
_unlock()
|
|
|
|
|
|
func _unlock() -> void:
|
|
_sprite.visible = true
|
|
_area.monitoring = true
|