1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-22 15:54:20 +00:00
pineapple-surf/island/CropTile.gd

35 lines
650 B
GDScript3
Raw Normal View History

2023-01-07 22:56:57 +00:00
extends Node3D
signal on_planted()
signal on_complete()
@onready var growth_timer: Timer = $GrowthTimer
@onready var sprout_mesh: MeshInstance3D = $Plant/Sprout
2023-01-07 23:15:11 +00:00
@export var debug_growth: bool = false
2023-01-07 22:56:57 +00:00
func plant():
if growth_timer.is_stopped():
growth_timer.start()
emit_signal("on_planted")
2023-01-07 22:56:57 +00:00
func complete():
if not growth_timer.is_stopped():
growth_timer.stop()
emit_signal("on_complete")
2023-01-07 23:15:11 +00:00
if debug_growth:
plant()
2023-01-07 22:56:57 +00:00
func _process(_delta):
var scale_factor = 1 - (growth_timer.time_left / growth_timer.wait_time)
sprout_mesh.scale = Vector3(scale_factor, scale_factor, scale_factor)
2023-01-07 23:15:11 +00:00
func _ready():
if debug_growth:
plant()