Three-agent fan-out reusing the contracts-first pattern: Opus pre-wrote
EventDef class + 5 EventBus signals + Storyteller autoload stub before
dispatch. Pattern proven across Phases 12/13/14/15.
EventDef + 25-event corpus (Agent A):
- scenes/storyteller/event_def.gd — data class with id/title/body/
category/display/cooldown_days/base_weight/choices/auto_pause/
focus_tile/trigger_predicate/on_resolve
- scenes/storyteller/event_catalog.gd — class_name EventCatalog with
register_all() dispatcher + 25 _event_NN() static factories covering
all 8 categories (nudge×4, seasonal×4, wanderer×4, threat×4, disease×3,
resource×3, lore×2, milestone×1)
- Strings catalog: 50 keys added (event.<id>.title + event.<id>.body)
+ ui.go_there / ui.dismiss for UI buttons
- on_resolve effects: real-wired for a_bad_cut (StatusCatalog.bleeding),
one_year_survived + refugee_family + sleeplessness (colony mood thoughts);
stubbed-with-log for wanderer spawns (Phase 17 recruit UI), resource
buffs (Phase 17 work-buff system), wolf spawn (EventBus signal pending),
fever (StatusCatalog.sick pending), seasonal effects
Storyteller real implementation (Agent B):
- autoload/storyteller.gd — replaced stub with full logic:
* Daily 6 AM roll via Clock.phase_changed(&dawn), one-per-day guard
* Per-event cooldown via _event_last_fired Dict; per-category via
_category_last_fired Dict + CATEGORY_COOLDOWN_DAYS (nudge=2,
seasonal=12, wanderer=5, threat=3, disease=4, resource=3, lore=6,
milestone=30) — both gates must pass
* Tension model: 0..100, −3/roll decay, +15 on THREAT fire (net +12)
Category multipliers: THREAT = lerp(2.0, 0.3, t/100),
RESOURCE = lerp(0.5, 1.5, t/100), others = 1.0
* State-trigger 3× weight boost when predicate currently true
* Auto-pause Sim before showing UI for auto_pause events
* Ghost state: _on_pawn_died flips on World.pawns empty,
_ghost_wanderer_target_day = today + randi_range(3, 5),
daily roll bypasses pool and force-fires WANDERER (prefers a_traveler)
* Full save/load round-trip incl. cooldown dicts (StringName↔String)
Banner + Modal UI (Agent C):
- scenes/ui/storyteller_banner.gd — class_name StorytellerBanner extends
CanvasLayer (layer 15), top-center under top-bar, 6-sec auto-dismiss
Timer, tap-to-dismiss-early, internal queue for back-to-back events
- scenes/ui/storyteller_modal.gd — class_name StorytellerModal extends
CanvasLayer (layer 20), center PanelContainer, full-screen 0.45 dim
ColorRect, 0/1/2 choice button layouts
- camera_rig.gd: pan_to_tile(tile) public helper using existing
_centre_on tween slot
- Both UI scenes runtime-instantiated in main.gd as CanvasLayer children
(no .tscn edit needed)
- %pawn% substitution at display time (World.pawns[0].pawn_name fallback)
Modal auto-hide-on-resolve fix (Opus mid-flight):
- Original Agent C modal only hid on internal button click. Added
EventBus.storyteller_event_resolved subscriber → _set_visible(false)
so external resolve_current calls (test scripts, ghost-state auto-fire)
also dismiss the dialog.
MCP runtime verified across two boots:
- Boot 1: day 0 roll → lone_wolf THREAT, modal 'A starving wolf circles
your livestock.' with Prepare/Dismiss + auto-pause (tick 1 frozen).
Resolve → tension 27→42, sim resumed.
- Boot 2: day 0 roll → an_old_map LORE, top-center banner, non-blocking.
Banner path + modal path both visually confirmed.
Deferred to Phase 17 polish:
- EventBus.request_wolf_spawn signal — wolf-spawn effects log-stub today
- Wanderer recruit UI (modal currently dismisses, pawn add deferred)
- Resource buff system (next-N-jobs multipliers)
- 3+ choice modals (current UI renders first 2)
- .tres event resources (currently code-as-data factories)
Delegation: 3× gdscript-refactor (Sonnet) agents in parallel;
modal-hide fix on Opus; integration + MCP verify on Opus.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
47 lines
3.5 KiB
GDScript
47 lines
3.5 KiB
GDScript
extends Node
|
|
## Pure signal hub — notification-only, no state, no callbacks back into singletons.
|
|
##
|
|
## Subsystems mutate themselves; this bus only spreads the news. Add signals as
|
|
## features land — keep this file readable. See docs/architecture.md.
|
|
|
|
# Sim
|
|
signal sim_tick(tick_number: int) ## Emitted once per sim tick at the current speed.
|
|
signal speed_changed(new_speed: int) ## Emitted when Sim.current_speed changes; value is Speed enum cast to int.
|
|
|
|
# Phase 2 will add pawn-state signals (selected, deselected, walking, …).
|
|
|
|
# Phase 5 — Designation paint mode.
|
|
signal designation_added(cell: Vector2i, tool: StringName) ## Ghost placed + job queued.
|
|
signal designation_cleared(cell: Vector2i) ## Ghost removed (job cancelled).
|
|
|
|
# Phase 8 — Mood system.
|
|
signal pawn_mood_changed(pawn, mood: float) ## Emitted by Pawn._recompute_mood() whenever mood is recalculated.
|
|
|
|
# Phase 9 — HP + Status system.
|
|
signal pawn_took_damage(pawn, amount: float) ## Emitted by Pawn.take_damage() after HP is reduced.
|
|
signal pawn_status_added(pawn, status) ## Emitted by Pawn.add_status() when a new status is appended.
|
|
signal pawn_status_removed(pawn, status) ## Emitted by Pawn.remove_status_by_id() when a status is dropped.
|
|
|
|
# Phase 12 — Seasons + Weather.
|
|
signal season_changed(season: StringName) ## Emitted by Clock when current_season() rolls over (Spring → Summer → Autumn → Winter).
|
|
signal weather_changed(weather: StringName) ## Emitted by Weather autoload when the daily roll resolves to a new weather kind.
|
|
|
|
# Phase 13 — Rooms + Roofing + Beauty + Dirtiness + Cleaning.
|
|
signal room_changed(room_id: int) ## Emitted when a room is created, destroyed, or recomputed (id may be invalid post-destroy).
|
|
signal room_too_large(top_left: Vector2i, cell_count: int) ## Emitted when BFS hits ROOM_MAX_CELLS — surfaces the "split with interior wall" banner.
|
|
signal tile_beauty_changed(tile: Vector2i, beauty: float) ## Emitted when beauty recomputes for a tile (Phase 13 beauty system).
|
|
signal tile_dirtiness_changed(tile: Vector2i, dirt: float) ## Emitted when dirtiness crosses a tier threshold (clean/dirty/filthy).
|
|
|
|
# Phase 14 — Death + corpses + burial.
|
|
signal pawn_died(pawn, cause: StringName) ## Emitted right before Pawn is unregistered; corpse spawn handler listens here.
|
|
signal corpse_spawned(corpse) ## Emitted when a Corpse entity is added to the world (right after pawn_died handler).
|
|
signal corpse_buried(corpse, grave_marker) ## Emitted when a corpse reaches a GraveSlot and converts to a permanent GraveMarker.
|
|
signal corpse_cremated(corpse, pyre) ## Emitted when a corpse is consumed by a cremation pyre recipe.
|
|
signal corpse_rotted_away(corpse) ## Emitted when an un-handled corpse hits decay 100 and is destroyed.
|
|
|
|
# Phase 15 — Storyteller.
|
|
signal storyteller_event_fired(event) ## Emitted when Storyteller selects an event and is about to display it (carries EventDef).
|
|
signal storyteller_event_resolved(event, choice_index: int) ## Emitted after the player dismisses or chooses (choice 0 = dismiss/first option).
|
|
signal storyteller_tension_changed(tension: float) ## Emitted when running tension score changes (0..100).
|
|
signal storyteller_ghost_state_entered ## Emitted when all colonists are dead/gone — wanderer recovery clock starts.
|
|
signal storyteller_ghost_state_exited ## Emitted when a wanderer joins and the colony is alive again.
|