feat: add player resource node harvesting

This commit is contained in:
2026-07-04 19:47:31 +02:00
parent f5e7326d49
commit 326df51cbe
6 changed files with 117 additions and 18 deletions
+15
View File
@@ -67,6 +67,9 @@ func extract(requested_amount: float = yield_per_action) -> float:
amount_remaining -= extracted
amount_changed.emit(node_id, amount_remaining)
if is_depleted():
if reserved_by >= 0:
reserved_by = -1
reservation_changed.emit(node_id, -1)
depleted.emit(node_id)
if hide_visual_when_depleted and has_node("Visual"):
$Visual.visible = false
@@ -104,3 +107,15 @@ static func find_available(action: StringName, agent_id: int, from_position: Vec
best_dist = dist
best = node
return best
static func find_nearest_for_player(from_position: Vector3, max_distance: float) -> ResourceNode:
var best: ResourceNode
var best_dist := max_distance * max_distance
for node in _all:
if not node.can_player_use:
continue
var dist := from_position.distance_squared_to(node.interaction_point.global_position)
if dist <= best_dist:
best_dist = dist
best = node
return best