harvest/game/scripts/conversation.gd
Forrest 1d92f49d96 Talking-head dialogue: DialogueDirector, DialogueBox, conversations and speakers
Conversations saved in game/resources/dialogue/ play once at their night and
phase in a paper box with talking heads; example: the morning of day 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 21:33:54 -04:00

36 lines
1.8 KiB
GDScript

class_name Conversation
extends Resource
## A talking-head conversation: its lines (DialogueLine), shown one at a time in the DialogueBox,
## and when it plays. Saved in game/resources/dialogue/, it plays by itself (DialogueDirector)
## once, delay seconds into the phase of its night: the morning of day 2 is night 2, MORNING;
## night 18 is night 18, NIGHT. The morning isn't timed, so its conversations start at once
## (the morning sign waits until they're done). From code, sim.dialogue.play(conversation) shows
## one at any time.
## The phases of a night (CampaignController.Phase, in the same order).
enum Phase { MORNING, DAY, DUSK, NIGHT, DAWN }
## Seconds a line stays when the game isn't paused and auto_advance is 0.
const AUTO_ADVANCE := 3.0
## Off: it never plays by itself (play() still shows it).
@export var enabled := true
@export_range(1, 99) var night := 1
@export var phase: Phase = Phase.MORNING
## Seconds into the phase (timed phases only).
@export_range(0.0, 600.0, 0.5, "suffix:s") var delay := 0.0
## Stops the farm while it's up, and the player goes through the lines. In co-op the farm can't
## stop: the player's scarecrow stands still instead. Off: the farm plays on, the box takes no
## input (the player is busy), and the lines go on by themselves.
@export var pause_game := true
## Seconds a line stays once it's written before the next one comes by itself; 0 waits for the
## player (AUTO_ADVANCE when the game isn't paused).
@export_range(0.0, 30.0, 0.1, "suffix:s") var auto_advance := 0.0
@export var lines: Array[DialogueLine] = []
## Seconds a written line stays before the next one comes by itself (INF: until the player goes
## on).
func line_hold() -> float:
if auto_advance > 0.0:
return auto_advance
return INF if pause_game else AUTO_ADVANCE