37 lines
876 B
GDScript
37 lines
876 B
GDScript
@tool
|
|
extends Node3D
|
|
|
|
@export var is_chopped:bool = true:
|
|
get:
|
|
return is_chopped
|
|
set(value):
|
|
if value != is_chopped:
|
|
is_chopped = value
|
|
|
|
_update_geometry()
|
|
|
|
@onready var grass_large: Node3D = %grassLarge
|
|
@onready var grow_timer: Timer = %GrowTimer
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
_update_geometry()
|
|
|
|
func _update_geometry() -> void:
|
|
if grass_large == null:
|
|
return
|
|
|
|
if is_chopped:
|
|
grass_large.transform = Transform3D(Basis.IDENTITY, grass_large.position)
|
|
else:
|
|
grass_large.transform = Transform3D(Basis.IDENTITY.scaled(Vector3(1, 3, 1)), grass_large.position)
|
|
|
|
func _on_hitbox_area_shape_entered(area_rid: RID, area: Area3D, area_shape_index: int, local_shape_index: int) -> void:
|
|
is_chopped = true
|
|
grow_timer.start()
|
|
|
|
|
|
func _on_grow_timer_timeout() -> void:
|
|
if is_chopped:
|
|
is_chopped = false
|