feat: wood inventory, carrying, and woodpile storage
Wood now follows the same gather-carry-deposit pattern as food. NPCs put harvested wood into inventory, walk to the VillageWoodpile StorageNode, and deposit it. Village wood syncs from storage. Player harvesting also routes wood to the woodpile. ActiveWorldAdapter exposes woodpile routing for DEPOSIT_WOOD action targeting. WorldViewManager recognizes wood inventory changes. Tests verify woodpile node existence, storage ID, navigation reachability, and adapter routing.
This commit is contained in:
@@ -2,6 +2,7 @@ class_name ActiveWorldAdapter
|
||||
extends Node
|
||||
|
||||
@export var pantry_storage: StorageNode
|
||||
@export var woodpile_storage: StorageNode
|
||||
|
||||
|
||||
func get_resource_candidates(action_id: StringName) -> Array[Dictionary]:
|
||||
@@ -38,6 +39,8 @@ func get_activity_target(action_id: StringName, origin: Vector3 = Vector3.ZERO)
|
||||
return _get_storage_target(pantry_storage)
|
||||
SimulationIds.ACTION_DEPOSIT_FOOD, SimulationIds.ACTION_WITHDRAW_FOOD:
|
||||
return _get_storage_target(pantry_storage)
|
||||
SimulationIds.ACTION_DEPOSIT_WOOD:
|
||||
return _get_storage_target(woodpile_storage)
|
||||
return {}
|
||||
|
||||
|
||||
|
||||
@@ -473,6 +473,10 @@ discovery_priority = 0.45
|
||||
[node name="VillagePantry" parent="WorldObjects/StorageSites" instance=ExtResource("14_storage")]
|
||||
position = Vector3(0, 0, -8)
|
||||
|
||||
[node name="VillageWoodpile" parent="WorldObjects/StorageSites" instance=ExtResource("14_storage")]
|
||||
position = Vector3(8, 0, -12)
|
||||
storage_id = &"village_woodpile"
|
||||
|
||||
[node name="PantrySignPole" type="MeshInstance3D" parent="WorldObjects/StorageSites/VillagePantry"]
|
||||
position = Vector3(-1.05, 1.1, 1.25)
|
||||
mesh = SubResource("Mesh_site_pole")
|
||||
|
||||
@@ -161,15 +161,15 @@ func _on_npc_died(npc: SimNPC) -> void:
|
||||
|
||||
|
||||
func _on_npc_inventory_changed(npc: SimNPC, item_id: StringName, amount: float) -> void:
|
||||
if item_id != SimulationIds.RESOURCE_FOOD:
|
||||
return
|
||||
var visual = active_npc_visuals.get(npc.id)
|
||||
if visual == null:
|
||||
return
|
||||
if visual.has_method("set_carried_food_visible"):
|
||||
visual.set_carried_food_visible(amount > 0.0)
|
||||
else:
|
||||
push_error("WorldViewManager: NPCVisual has no set_carried_food_visible method")
|
||||
if item_id == SimulationIds.RESOURCE_FOOD:
|
||||
if visual.has_method("set_carried_food_visible"):
|
||||
visual.set_carried_food_visible(amount > 0.0)
|
||||
elif item_id == SimulationIds.RESOURCE_WOOD:
|
||||
if visual.has_method("set_carried_wood_visible"):
|
||||
visual.set_carried_wood_visible(amount > 0.0)
|
||||
|
||||
|
||||
func _on_npc_task_changed(npc: SimNPC, _old_task: StringName, _new_task: StringName) -> void:
|
||||
|
||||
Reference in New Issue
Block a user