feat: add knowledge-gated pantry opportunities
This commit is contained in:
@@ -9,7 +9,7 @@ var known_events: Dictionary = {}
|
||||
|
||||
func observe_event(event: EconomicEventRecord, npcs: Array[SimNPC]) -> Array[KnownEventStateRecord]:
|
||||
var learned: Array[KnownEventStateRecord] = []
|
||||
if not _is_witnessable(event):
|
||||
if not is_knowable_event(event):
|
||||
return learned
|
||||
var actor := _find_npc(int(event.data["actor_id"]), npcs)
|
||||
if actor == null:
|
||||
@@ -44,7 +44,7 @@ func communicate_event(
|
||||
event == null
|
||||
or speaker_id == listener_id
|
||||
or listener_id == int(event.data["actor_id"])
|
||||
or not _is_witnessable(event)
|
||||
or not is_knowable_event(event)
|
||||
):
|
||||
return null
|
||||
var event_id := int(event.data["event_id"])
|
||||
@@ -221,11 +221,21 @@ func _remember(
|
||||
return record
|
||||
|
||||
|
||||
func _is_witnessable(event: EconomicEventRecord) -> bool:
|
||||
static func is_knowable_event(event: EconomicEventRecord) -> bool:
|
||||
if event == null or float(event.data["amount"]) <= 0.0:
|
||||
return false
|
||||
var event_type := StringName(event.data["event_type"])
|
||||
var item_id := StringName(event.data["item_id"])
|
||||
if event_type == SimulationIds.EVENT_STORAGE_DEPOSITED:
|
||||
return item_id == SimulationIds.RESOURCE_FOOD
|
||||
if event_type != SimulationIds.EVENT_STORAGE_WITHDRAWN:
|
||||
return false
|
||||
var actor_id := int(event.data["actor_id"])
|
||||
return (
|
||||
StringName(event.data["event_type"]) == SimulationIds.EVENT_STORAGE_DEPOSITED
|
||||
and StringName(event.data["item_id"]) == SimulationIds.RESOURCE_FOOD
|
||||
and float(event.data["amount"]) > 0.0
|
||||
actor_id >= 0
|
||||
and item_id == SimulationIds.RESOURCE_FOOD
|
||||
and StringName(event.data["source_id"]) == SimulationIds.STORAGE_VILLAGE_PANTRY
|
||||
and (StringName(event.data["destination_id"]) == SimulationIds.npc_inventory_id(actor_id))
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user