42 lines
1.0 KiB
GDScript
42 lines
1.0 KiB
GDScript
class_name HarvestableTreePresentation
|
|
extends ResourceAmountVisual
|
|
|
|
const THINNED_CANOPIES := [&"CanopyLeft", &"CanopyRight"]
|
|
|
|
@onready var standing_tree: Node3D = $StandingTree
|
|
@onready var stump: Node3D = $Stump
|
|
|
|
|
|
func _ready() -> void:
|
|
super()
|
|
|
|
|
|
func is_standing_visible() -> bool:
|
|
return standing_tree.visible
|
|
|
|
|
|
func is_stump_visible() -> bool:
|
|
return stump.visible
|
|
|
|
|
|
func get_visible_canopy_count() -> int:
|
|
if not standing_tree.visible:
|
|
return 0
|
|
var visible_count := 0
|
|
for child in standing_tree.get_children():
|
|
if String(child.name).begins_with("Canopy") and child.visible:
|
|
visible_count += 1
|
|
return visible_count
|
|
|
|
|
|
func _apply_resource_amount_visual(
|
|
_amount_remaining: float, _remaining_ratio: float, tier: AmountTier
|
|
) -> void:
|
|
var depleted := tier == AmountTier.DEPLETED
|
|
standing_tree.visible = not depleted
|
|
stump.visible = depleted
|
|
for canopy_name in THINNED_CANOPIES:
|
|
var canopy := standing_tree.get_node_or_null(NodePath(canopy_name)) as Node3D
|
|
if canopy != null:
|
|
canopy.visible = tier == AmountTier.FULL
|