feat: add paired goat care
This commit is contained in:
@@ -217,9 +217,9 @@ func _select_action_if_idle(npc: SimNPC, previous_state: StringName) -> void:
|
||||
if npc.task_state not in [SimNPC.TASK_STATE_IDLE, SimNPC.TASK_STATE_COMPLETE]:
|
||||
return
|
||||
var helper := get_active_opportunity_helper()
|
||||
var animal_feed_name := animal_care.get_available_feed_name(npc.id)
|
||||
var animal_feed_available := animal_care.has_available_feed_target(npc.id)
|
||||
var selection := action_selector.select_action(
|
||||
npc, village, clock.time_of_day(), npcs, helper, _population_view, animal_feed_name
|
||||
npc, village, clock.time_of_day(), npcs, helper, _population_view, animal_feed_available
|
||||
)
|
||||
if selection == null:
|
||||
return
|
||||
|
||||
@@ -24,7 +24,7 @@ func select_action(
|
||||
all_npcs: Array = [],
|
||||
opportunity_helper: OpportunityHelperResult = null,
|
||||
population_view: SimulationPopulationView = null,
|
||||
animal_feed_name: String = ""
|
||||
animal_feed_available: bool = false
|
||||
) -> ActionSelectionResult:
|
||||
if npc.is_dead:
|
||||
return null
|
||||
@@ -127,13 +127,13 @@ func select_action(
|
||||
return ActionSelectionResult.new(
|
||||
SimulationIds.ACTION_REST, -1.0, "Energy is below the rest threshold"
|
||||
)
|
||||
if not animal_feed_name.is_empty():
|
||||
if animal_feed_available:
|
||||
var feed_definition := SimulationDefinitions.get_action(SimulationIds.ACTION_FEED_ANIMAL)
|
||||
if _get_cost_rejection(feed_definition, village).is_empty():
|
||||
return ActionSelectionResult.new(
|
||||
SimulationIds.ACTION_FEED_ANIMAL,
|
||||
-1.0,
|
||||
"%s is hungry; pantry food is available" % animal_feed_name
|
||||
"A hungry animal is available; pantry food is available"
|
||||
)
|
||||
if village.food <= RELATIONSHIP_AID_PANTRY_THRESHOLD and relationship_system != null:
|
||||
var trusted_starving_npc: SimNPC = relationship_system.get_trusted_starving_subject(
|
||||
|
||||
@@ -119,9 +119,9 @@ func can_complete_feed(animal_id: StringName, agent_id: int) -> bool:
|
||||
)
|
||||
|
||||
|
||||
func get_available_feed_name(npc_id: int) -> String:
|
||||
func has_available_feed_target(npc_id: int) -> bool:
|
||||
if active_world_adapter == null or not active_world_adapter.has_method("get_animal_candidates"):
|
||||
return ""
|
||||
return false
|
||||
var candidates: Array[Dictionary] = active_world_adapter.get_animal_candidates(
|
||||
SimulationIds.ACTION_FEED_ANIMAL
|
||||
)
|
||||
@@ -132,8 +132,8 @@ func get_available_feed_name(npc_id: int) -> String:
|
||||
and animal_state.can_npc_feed()
|
||||
and animal_state.is_available_for(npc_id)
|
||||
):
|
||||
return animal_state.get_display_name()
|
||||
return ""
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func find_node_for_player(from_position: Vector3, max_distance: float) -> AnimalNode:
|
||||
@@ -250,7 +250,7 @@ func _begin_due_routine(animal_state: AnimalStateRecord) -> bool:
|
||||
if AnimalNode.get_by_id(animal_state.get_animal_id()) == null:
|
||||
return false
|
||||
var candidates: Array[Dictionary] = active_world_adapter.get_animal_routine_sites(
|
||||
animal_state.get_species_id()
|
||||
animal_state.get_species_id(), animal_state.get_animal_id()
|
||||
)
|
||||
if candidates.is_empty():
|
||||
return false
|
||||
|
||||
@@ -31,9 +31,11 @@ const RESOURCE_FOOD := &"food"
|
||||
const RESOURCE_WOOD := &"wood"
|
||||
|
||||
const ANIMAL_DUNJA := &"goat_dunja"
|
||||
const ANIMAL_ZORA := &"goat_zora"
|
||||
const SPECIES_GOAT := &"goat"
|
||||
const ANIMAL_SITE_DUNJA_PASTURE := &"dunja_pasture"
|
||||
const ANIMAL_SITE_DUNJA_SHELTER := &"dunja_shelter"
|
||||
const ANIMAL_SITE_ZORA_SHELTER := &"zora_shelter"
|
||||
|
||||
const STORAGE_VILLAGE_PANTRY := &"village_pantry"
|
||||
const STORAGE_VILLAGE_WOODPILE := &"village_woodpile"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
action_id = &"feed_animal"
|
||||
display_name = "Feed Dunja"
|
||||
display_name = "Feed animal"
|
||||
default_duration = 2.0
|
||||
preferred_profession_id = &"farmer"
|
||||
target_type = &"animal"
|
||||
|
||||
Reference in New Issue
Block a user