feat: resource depletion events and village event feed
Record resource_depleted narrative events when NPC or player extraction exhausts a ResourceNode. Add get_recent_events() for cross-NPC event queries. Village panel now shows the last 3 village-wide events as a readable feed below the resource counters, making shortages and depletion visible without opening the inspector.
This commit is contained in:
@@ -195,6 +195,12 @@ func simulate_tick() -> void:
|
||||
resource_state.get_resource_id(),
|
||||
extracted
|
||||
)
|
||||
if resource_state.get_amount_remaining() <= 0.0:
|
||||
record_narrative_event(
|
||||
SimulationIds.EVENT_RESOURCE_DEPLETED,
|
||||
npc.id,
|
||||
resource_state.get_node_id()
|
||||
)
|
||||
if debug_logs:
|
||||
print(
|
||||
"[SimulationManager] ",
|
||||
@@ -495,6 +501,14 @@ func get_npc_events(npc_id: int, max_count: int = 8) -> Array[EconomicEventRecor
|
||||
return results
|
||||
|
||||
|
||||
func get_recent_events(max_count: int = 5) -> Array[EconomicEventRecord]:
|
||||
var results: Array[EconomicEventRecord] = []
|
||||
var start := maxi(economic_events.size() - max_count, 0)
|
||||
for i in range(start, economic_events.size()):
|
||||
results.append(economic_events[i])
|
||||
return results
|
||||
|
||||
|
||||
func _initialize_storage() -> void:
|
||||
if not storage_states.has(SimulationIds.STORAGE_VILLAGE_PANTRY):
|
||||
storage_states[SimulationIds.STORAGE_VILLAGE_PANTRY] = (StorageStateRecord.create(
|
||||
@@ -727,6 +741,10 @@ func harvest_resource_node(node: ResourceNode) -> float:
|
||||
resource_state.get_resource_id(),
|
||||
extracted
|
||||
)
|
||||
if resource_state.get_amount_remaining() <= 0.0:
|
||||
record_narrative_event(
|
||||
SimulationIds.EVENT_RESOURCE_DEPLETED, -1, resource_state.get_node_id()
|
||||
)
|
||||
village_changed.emit(village)
|
||||
|
||||
if debug_logs:
|
||||
|
||||
Reference in New Issue
Block a user