feat: surface open opportunity need on villager field note
This commit is contained in:
+54
-1
@@ -142,6 +142,7 @@ func get_nearby_villager_inspection() -> VillagerInspectionResult:
|
||||
var decision: ActionSelectionResult = simulation_manager.get_latest_decision(npc.id)
|
||||
if decision != null and decision.action_id == npc.current_task:
|
||||
reason = decision.reason
|
||||
var opportunity_note := _build_opportunity_note(npc)
|
||||
return VillagerInspectionResult.new(
|
||||
npc.id,
|
||||
npc.npc_name,
|
||||
@@ -151,10 +152,62 @@ func get_nearby_villager_inspection() -> VillagerInspectionResult:
|
||||
npc.target_id,
|
||||
target_name,
|
||||
carried_amounts,
|
||||
reason
|
||||
reason,
|
||||
opportunity_note
|
||||
)
|
||||
|
||||
|
||||
func _build_opportunity_note(npc: SimNPC) -> VillagerOpportunityNote:
|
||||
if (
|
||||
simulation_manager == null
|
||||
or not simulation_manager.has_method("get_active_opportunity")
|
||||
or not simulation_manager.has_method("get_active_opportunity_player_response")
|
||||
or not simulation_manager.has_method("get_active_opportunity_helper")
|
||||
):
|
||||
return null
|
||||
var opportunity: OpportunityStateRecord = simulation_manager.get_active_opportunity()
|
||||
if (
|
||||
opportunity == null
|
||||
or opportunity.get_interested_npc_id() != npc.id
|
||||
or (
|
||||
opportunity.get_target_id()
|
||||
not in [SimulationIds.STORAGE_VILLAGE_PANTRY, SimulationIds.STORAGE_VILLAGE_WOODPILE]
|
||||
)
|
||||
):
|
||||
return null
|
||||
var player_response: OpportunityPlayerResponseResult = (
|
||||
simulation_manager.get_active_opportunity_player_response()
|
||||
)
|
||||
var helper: OpportunityHelperResult = simulation_manager.get_active_opportunity_helper()
|
||||
var helper_name := ""
|
||||
if helper != null:
|
||||
var helper_npc := _find_npc(helper.helper_npc_id)
|
||||
if helper_npc != null:
|
||||
helper_name = helper_npc.npc_name
|
||||
return VillagerOpportunityNote.derive(
|
||||
opportunity,
|
||||
player_response,
|
||||
helper,
|
||||
helper_name,
|
||||
_get_opportunity_storage(opportunity),
|
||||
_get_target_display_name(opportunity.get_target_id()),
|
||||
_display_id(opportunity.get_resource_id()).to_lower()
|
||||
)
|
||||
|
||||
|
||||
func _get_opportunity_storage(opportunity: OpportunityStateRecord) -> StorageStateRecord:
|
||||
if simulation_manager == null:
|
||||
return null
|
||||
if not simulation_manager.has_method("get_pantry"):
|
||||
return null
|
||||
if opportunity.get_target_id() == SimulationIds.STORAGE_VILLAGE_PANTRY:
|
||||
return simulation_manager.get_pantry() as StorageStateRecord
|
||||
if opportunity.get_target_id() == SimulationIds.STORAGE_VILLAGE_WOODPILE:
|
||||
if simulation_manager.has_method("get_woodpile"):
|
||||
return simulation_manager.get_woodpile() as StorageStateRecord
|
||||
return null
|
||||
|
||||
|
||||
func _find_feed_animal() -> AnimalNode:
|
||||
if not ("animal_care" in simulation_manager) or simulation_manager.animal_care == null:
|
||||
push_error("Player: SimulationManager has no animal-care service")
|
||||
|
||||
Reference in New Issue
Block a user