Files
experiment-adventure-ai/cutscene_system_architecture.md
2025-07-30 21:52:27 -07:00

4.0 KiB

Cutscene System Architecture

Overview

This document provides a visual representation of the cutscene system architecture using Mermaid diagrams.

System Components

graph TD
    A[CutsceneManager] --> B[Sequential Actions Queue]
    A --> C[Parallel Actions Groups]
    A --> D[State Management]
    A --> E[Signal System]
    
    B --> F[Action 1]
    B --> G[Action 2]
    B --> H[Action 3]
    
    C --> I[Parallel Group 1]
    C --> J[Parallel Group 2]
    
    I --> K[Action A]
    I --> L[Action B]
    
    J --> M[Action C]
    J --> N[Action D]
    J --> O[Action E]
    
    F --> P[Action Base Class]
    G --> P
    H --> P
    K --> P
    L --> P
    M --> P
    N --> P
    O --> P
    
    P --> Q[Start Method]
    P --> R[Update Method]
    P --> S[Is Completed Method]
    P --> T[Stop Method]

Action State Flow

stateDiagram-v2
    [*] --> PENDING
    PENDING --> RUNNING: start()
    RUNNING --> COMPLETED: _set_completed()
    RUNNING --> FAILED: _set_failed()
    RUNNING --> STOPPED: stop()
    FAILED --> [*]
    STOPPED --> [*]
    COMPLETED --> [*]

CutsceneManager State Flow

stateDiagram-v2
    [*] --> IDLE
    IDLE --> RUNNING: start()
    RUNNING --> PAUSED: pause()
    PAUSED --> RUNNING: resume()
    RUNNING --> IDLE: stop() or completion
    PAUSED --> IDLE: stop()

Action Execution Flow

sequenceDiagram
    participant CM as CutsceneManager
    participant SA as SequentialAction
    participant PA as ParallelActionA
    participant PB as ParallelActionB
    
    CM->>SA: start()
    SA->>CM: started signal
    CM->>SA: update() each frame
    SA->>CM: completed signal
    
    CM->>PA: start()
    CM->>PB: start()
    PA->>CM: started signal
    PB->>CM: started signal
    CM->>PA: update() each frame
    CM->>PB: update() each frame
    PA->>CM: completed signal
    Note over CM: Waiting for all parallel actions
    PB->>CM: completed signal
    Note over CM: All parallel actions completed

Class Hierarchy

classDiagram
    class Action {
        +State state
        +String name
        +started()
        +completed()
        +failed()
        +start()
        +update()
        +is_completed()
        +stop()
    }
    
    class MoveAction {
        +Node2D character
        +Vector2 target_position
        +float speed
        +start()
        +update()
        +is_completed()
    }
    
    class TurnAction {
        +Node2D character
        +Variant target
        +float turn_speed
        +start()
        +update()
        +is_completed()
    }
    
    class DialogueAction {
        +Node2D character
        +String text
        +float duration
        +start()
        +update()
        +is_completed()
    }
    
    class AnimationAction {
        +Node2D character
        +String animation_name
        +bool loop
        +start()
        +update()
        +is_completed()
    }
    
    class WaitAction {
        +float duration
        +float elapsed_time
        +start()
        +update()
        +is_completed()
    }
    
    class CutsceneManager {
        +Array sequential_actions
        +Array parallel_groups
        +State state
        +start()
        +pause()
        +resume()
        +stop()
        +add_action()
        +add_parallel_actions()
        +_process()
    }
    
    Action <|-- MoveAction
    Action <|-- TurnAction
    Action <|-- DialogueAction
    Action <|-- AnimationAction
    Action <|-- WaitAction
    CutsceneManager --> Action

Signal Connection Flow

graph LR
    A[CutsceneManager] -- Connects to --> B[Action Signals]
    B -- started --> A
    B -- completed --> A
    B -- failed --> A
    B -- stopped --> A
    
    A -- Manages --> C[Sequential Execution]
    A -- Manages --> D[Parallel Execution]
    
    D -- Tracks Completion --> E[Parallel Group Counter]
    E -- Notifies When Complete --> A

This architecture provides a clear, modular design that supports both sequential and parallel action execution while maintaining extensibility for new action types.