selectChoice method

void selectChoice(
  1. int index
)

Selects a player choice by zero-based index.

Only has effect when signals.hasChoices is true, and only for an index in range whose choice is available: anything else is ignored (and said in the log in a debug build), and the choices stay up.

Implementation

void selectChoice(int index) {
  final session = _session;
  final waiting = session?.choice;
  if (session == null || waiting == null || waiting.isCompleted) return;
  final offered = session.offered;
  if (index < 0 || index >= offered.length || !offered[index].isAvailable) {
    if (kDebugMode) {
      debugPrint(
        'DialogueRunner: choice $index cannot be picked '
        '(${offered.length} offered); ignored.',
      );
    }
    return;
  }
  waiting.complete(index);
}