feat: add missing wood opportunities
This commit is contained in:
@@ -4,9 +4,6 @@ const SimulationEventLogScript := preload("res://simulation/events/SimulationEve
|
||||
const VillageEconomyScript := preload("res://simulation/economy/VillageEconomy.gd")
|
||||
const RelationshipSystemScript := preload("res://simulation/relationships/RelationshipSystem.gd")
|
||||
const EventKnowledgeSystemScript := preload("res://simulation/knowledge/EventKnowledgeSystem.gd")
|
||||
const FoodShortageOpportunitySystemScript := preload(
|
||||
"res://simulation/opportunities/FoodShortageOpportunitySystem.gd"
|
||||
)
|
||||
|
||||
signal npc_task_changed(npc: SimNPC, old_task: StringName, new_task: StringName)
|
||||
signal village_changed(village: SimVillage)
|
||||
@@ -23,6 +20,7 @@ signal event_knowledge_transferred(speaker_id: int, listener_id: int, event: Eco
|
||||
signal event_knowledge_forgotten(knower_id: int, event: EconomicEventRecord)
|
||||
signal opportunity_opened(opportunity: OpportunityStateRecord)
|
||||
signal opportunity_resolved(opportunity: OpportunityStateRecord, cause_event: EconomicEventRecord)
|
||||
signal opportunity_invalidated(opportunity: OpportunityStateRecord)
|
||||
|
||||
var village := SimVillage.new()
|
||||
|
||||
@@ -42,7 +40,7 @@ var event_log := SimulationEventLogScript.new()
|
||||
var economy := VillageEconomyScript.new()
|
||||
var relationship_system := RelationshipSystemScript.new()
|
||||
var event_knowledge_system := EventKnowledgeSystemScript.new()
|
||||
var opportunity_system := FoodShortageOpportunitySystemScript.new()
|
||||
var opportunity_system := VillageOpportunitySystem.new()
|
||||
var storage_states: Dictionary:
|
||||
get:
|
||||
return economy.storage_states
|
||||
@@ -162,12 +160,15 @@ func simulate_tick() -> void:
|
||||
var village_was_changed := false
|
||||
for npc in npcs:
|
||||
village_was_changed = _simulate_npc_tick(npc) or village_was_changed
|
||||
|
||||
if village_was_changed:
|
||||
village_changed.emit(village)
|
||||
var invalidated: OpportunityStateRecord = opportunity_system.maintain_open_opportunity(
|
||||
tick_count, get_knowledge_review_interval(), npcs, get_pantry(), get_woodpile()
|
||||
)
|
||||
if invalidated != null:
|
||||
opportunity_invalidated.emit(invalidated)
|
||||
if tick_count % get_knowledge_review_interval() == 0:
|
||||
_maintain_event_knowledge(true)
|
||||
|
||||
if debug_logs:
|
||||
print(village.get_summary())
|
||||
|
||||
@@ -552,14 +553,23 @@ func _record_economic_event_at(
|
||||
|
||||
|
||||
func record_narrative_event(
|
||||
event_type: StringName, actor_id: int, source_id: StringName = &"", action_display: String = ""
|
||||
event_type: StringName,
|
||||
actor_id: int,
|
||||
source_id: StringName = &"",
|
||||
action_display: String = "",
|
||||
action_id: StringName = &"",
|
||||
item_id: StringName = &"",
|
||||
required_amount: float = 0.0
|
||||
) -> void:
|
||||
_record_narrative_event_at(
|
||||
event_type,
|
||||
actor_id,
|
||||
source_id,
|
||||
action_display,
|
||||
_get_event_world_position(actor_id, source_id, &"")
|
||||
_get_event_world_position(actor_id, source_id, &""),
|
||||
action_id,
|
||||
item_id,
|
||||
required_amount
|
||||
)
|
||||
|
||||
|
||||
@@ -568,10 +578,21 @@ func _record_narrative_event_at(
|
||||
actor_id: int,
|
||||
source_id: StringName,
|
||||
action_display: String,
|
||||
world_position: Vector3
|
||||
world_position: Vector3,
|
||||
action_id: StringName = &"",
|
||||
item_id: StringName = &"",
|
||||
required_amount: float = 0.0
|
||||
) -> void:
|
||||
event_log.record_narrative(
|
||||
tick_count, event_type, actor_id, source_id, action_display, world_position
|
||||
tick_count,
|
||||
event_type,
|
||||
actor_id,
|
||||
source_id,
|
||||
action_display,
|
||||
world_position,
|
||||
action_id,
|
||||
item_id,
|
||||
required_amount
|
||||
)
|
||||
|
||||
|
||||
@@ -673,7 +694,13 @@ func _apply_new_event_knowledge(
|
||||
|
||||
func _update_opportunity_from_event(event: EconomicEventRecord) -> void:
|
||||
var changed: OpportunityStateRecord = opportunity_system.consider_event(
|
||||
event, tick_count, get_pantry(), npcs, event_knowledge_system, resource_states
|
||||
event,
|
||||
tick_count,
|
||||
get_pantry(),
|
||||
npcs,
|
||||
event_knowledge_system,
|
||||
resource_states,
|
||||
get_woodpile()
|
||||
)
|
||||
if changed == null:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user