feat: let villagers witness and trust the player restock
This commit is contained in:
@@ -4,6 +4,7 @@ const AID_HUNGER_THRESHOLD := 80.0
|
||||
const TRUSTED_HELP_THRESHOLD := 0.6
|
||||
const FOOD_AID_TRUST_GAIN := 0.15
|
||||
const SHARED_WORK_FAMILIARITY_GAIN := 0.1
|
||||
const PLAYER_FAMILIARITY_SEED := 0.5
|
||||
|
||||
var relationships: Dictionary = {}
|
||||
|
||||
@@ -58,23 +59,47 @@ func apply_event(
|
||||
event: EconomicEventRecord, npcs: Array[SimNPC], knower_ids: Array[int]
|
||||
) -> Array[RelationshipStateRecord]:
|
||||
var changed: Array[RelationshipStateRecord] = []
|
||||
if StringName(event.data["event_type"]) != SimulationIds.EVENT_STORAGE_DEPOSITED:
|
||||
return changed
|
||||
if StringName(event.data["item_id"]) != SimulationIds.RESOURCE_FOOD:
|
||||
var event_type := StringName(event.data["event_type"])
|
||||
var item_id := StringName(event.data["item_id"])
|
||||
if item_id != SimulationIds.RESOURCE_FOOD:
|
||||
return changed
|
||||
var contributor_id := int(event.data["actor_id"])
|
||||
var event_id := int(event.data["event_id"])
|
||||
if contributor_id < 0 or event_id < 0 or float(event.data["amount"]) <= 0.0:
|
||||
var is_food_supply := false
|
||||
if event_type == SimulationIds.EVENT_STORAGE_DEPOSITED:
|
||||
is_food_supply = true
|
||||
elif (
|
||||
event_type == SimulationIds.EVENT_RESOURCE_EXTRACTED
|
||||
and contributor_id == SimulationIds.PLAYER_ACTOR_ID
|
||||
):
|
||||
is_food_supply = (
|
||||
StringName(event.data["destination_id"]) == SimulationIds.STORAGE_VILLAGE_PANTRY
|
||||
)
|
||||
if (
|
||||
not is_food_supply
|
||||
or event_id < 0
|
||||
or float(event.data["amount"]) <= 0.0
|
||||
or (contributor_id < 0 and contributor_id != SimulationIds.PLAYER_ACTOR_ID)
|
||||
):
|
||||
return changed
|
||||
for observer in npcs:
|
||||
if observer.id == contributor_id or observer.is_dead:
|
||||
if observer.is_dead:
|
||||
continue
|
||||
if contributor_id != SimulationIds.PLAYER_ACTOR_ID and observer.id == contributor_id:
|
||||
continue
|
||||
if observer.id not in knower_ids:
|
||||
continue
|
||||
if observer.hunger < AID_HUNGER_THRESHOLD:
|
||||
continue
|
||||
var relationship := get_relationship(observer.id, contributor_id)
|
||||
if relationship == null or relationship.get_familiarity() <= 0.0:
|
||||
if relationship == null:
|
||||
if contributor_id != SimulationIds.PLAYER_ACTOR_ID:
|
||||
continue
|
||||
relationship = RelationshipStateRecord.create(
|
||||
observer.id, contributor_id, PLAYER_FAMILIARITY_SEED
|
||||
)
|
||||
_add(relationship)
|
||||
if relationship.get_familiarity() <= 0.0:
|
||||
continue
|
||||
if event_id <= relationship.get_last_trust_cause_event_id():
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user