194 lines
4.0 KiB
Markdown
194 lines
4.0 KiB
Markdown
# Cutscene System Architecture
|
|
|
|
## Overview
|
|
This document provides a visual representation of the cutscene system architecture using Mermaid diagrams.
|
|
|
|
## System Components
|
|
|
|
```mermaid
|
|
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
|
|
|
|
```mermaid
|
|
stateDiagram-v2
|
|
[*] --> PENDING
|
|
PENDING --> RUNNING: start()
|
|
RUNNING --> COMPLETED: _set_completed()
|
|
RUNNING --> FAILED: _set_failed()
|
|
RUNNING --> STOPPED: stop()
|
|
FAILED --> [*]
|
|
STOPPED --> [*]
|
|
COMPLETED --> [*]
|
|
```
|
|
|
|
## CutsceneManager State Flow
|
|
|
|
```mermaid
|
|
stateDiagram-v2
|
|
[*] --> IDLE
|
|
IDLE --> RUNNING: start()
|
|
RUNNING --> PAUSED: pause()
|
|
PAUSED --> RUNNING: resume()
|
|
RUNNING --> IDLE: stop() or completion
|
|
PAUSED --> IDLE: stop()
|
|
```
|
|
|
|
## Action Execution Flow
|
|
|
|
```mermaid
|
|
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
|
|
|
|
```mermaid
|
|
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
|
|
|
|
```mermaid
|
|
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. |