@nice2dev/game-engine 1.3.13 → 1.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +2 -2
- package/dist/types/accessibility/index.d.ts +0 -1
- package/dist/types/ai/index.d.ts +0 -1
- package/dist/types/animation/index.d.ts +0 -1
- package/dist/types/audio/HRTFAudio.d.ts +0 -180
- package/dist/types/audio/index.d.ts +0 -2
- package/dist/types/community/Community.d.ts +0 -112
- package/dist/types/community/index.d.ts +0 -1
- package/dist/types/core/TypeSafety.d.ts +0 -190
- package/dist/types/core/index.d.ts +0 -7
- package/dist/types/devtools/AssetStore.d.ts +0 -133
- package/dist/types/devtools/index.d.ts +0 -3
- package/dist/types/dialogue/index.d.ts +0 -2
- package/dist/types/docs/APIPlayground.d.ts +0 -26
- package/dist/types/docs/Cookbook.d.ts +0 -18
- package/dist/types/docs/Guides.d.ts +0 -18
- package/dist/types/docs/index.d.ts +0 -4
- package/dist/types/ecs/ECSOptimized.d.ts +0 -131
- package/dist/types/ecs/index.d.ts +0 -2
- package/dist/types/editor/NiceAnimationTimeline.d.ts +0 -114
- package/dist/types/editor/NiceLevelEditor.d.ts +0 -232
- package/dist/types/editor/NiceMaterialEditor.d.ts +0 -105
- package/dist/types/editor/NiceNodeGraph.d.ts +0 -87
- package/dist/types/editor/NiceParticleEditor.d.ts +0 -127
- package/dist/types/editor/behavior-tree/BTDebugPanel.d.ts +0 -102
- package/dist/types/editor/behavior-tree/BTEditorCanvas.d.ts +0 -79
- package/dist/types/editor/behavior-tree/BTEditorNode.d.ts +0 -58
- package/dist/types/editor/behavior-tree/BTEditorToolbar.d.ts +0 -75
- package/dist/types/editor/behavior-tree/BTNodePalette.d.ts +0 -72
- package/dist/types/editor/behavior-tree/BTPropertyPanel.d.ts +0 -66
- package/dist/types/editor/behavior-tree/BehaviorTreeEditor.d.ts +0 -186
- package/dist/types/editor/behavior-tree/index.d.ts +0 -14
- package/dist/types/editor/behavior-tree/serialization.d.ts +0 -30
- package/dist/types/editor/behavior-tree/types.d.ts +0 -299
- package/dist/types/editor/index.d.ts +0 -20
- package/dist/types/editor/state-machine/SMEditorCanvas.d.ts +0 -61
- package/dist/types/editor/state-machine/StateMachineEditor.d.ts +0 -139
- package/dist/types/editor/state-machine/index.d.ts +0 -11
- package/dist/types/editor/state-machine/serialization.d.ts +0 -23
- package/dist/types/editor/state-machine/types.d.ts +0 -241
- package/dist/types/engine/index.d.ts +0 -2
- package/dist/types/enterprise/index.d.ts +0 -1
- package/dist/types/epic/index.d.ts +0 -10
- package/dist/types/i18n/index.d.ts +0 -2
- package/dist/types/input/index.d.ts +0 -3
- package/dist/types/kids/index.d.ts +0 -2
- package/dist/types/legendary/index.d.ts +0 -57
- package/dist/types/monetization/index.d.ts +0 -1
- package/dist/types/multiplayer/NiceNetcode.d.ts +0 -434
- package/dist/types/multiplayer/index.d.ts +0 -5
- package/dist/types/network/index.d.ts +0 -2
- package/dist/types/pathfinding/index.d.ts +0 -1
- package/dist/types/performance/AssetCompression.d.ts +0 -137
- package/dist/types/performance/WASMModules.d.ts +0 -65
- package/dist/types/performance/WebGPUCompute.d.ts +0 -71
- package/dist/types/performance/index.d.ts +0 -1
- package/dist/types/physics/RapierIntegration.d.ts +0 -404
- package/dist/types/physics/index.d.ts +0 -2
- package/dist/types/plugins/index.d.ts +0 -2
- package/dist/types/procedural/index.d.ts +0 -2
- package/dist/types/release/index.d.ts +0 -1
- package/dist/types/rendering/WebGPUv2.d.ts +0 -173
- package/dist/types/rendering/index.d.ts +0 -3
- package/dist/types/runtime3d/index.d.ts +0 -2
- package/dist/types/scene/index.d.ts +0 -2
- package/dist/types/scripting/WasmCompiler.d.ts +0 -182
- package/dist/types/scripting/index.d.ts +0 -19
- package/dist/types/social/index.d.ts +0 -1
- package/dist/types/systems/NiceAI.d.ts +0 -637
- package/dist/types/systems/NiceAbility.d.ts +0 -225
- package/dist/types/systems/NiceAccessibility.d.ts +0 -230
- package/dist/types/systems/NiceAchievement.d.ts +0 -153
- package/dist/types/systems/NiceAchievementUI.d.ts +0 -196
- package/dist/types/systems/NiceAchievements.d.ts +0 -230
- package/dist/types/systems/NiceAction.d.ts +0 -81
- package/dist/types/systems/NiceAlchemy.d.ts +0 -195
- package/dist/types/systems/NiceAnalytics.d.ts +0 -493
- package/dist/types/systems/NiceAnimation.d.ts +0 -350
- package/dist/types/systems/NiceArena.d.ts +0 -215
- package/dist/types/systems/NiceAssetLoader.d.ts +0 -136
- package/dist/types/systems/NiceAuction.d.ts +0 -157
- package/dist/types/systems/NiceAudio.d.ts +0 -224
- package/dist/types/systems/NiceAugment.d.ts +0 -187
- package/dist/types/systems/NiceAura.d.ts +0 -193
- package/dist/types/systems/NiceBank.d.ts +0 -158
- package/dist/types/systems/NiceBattlePass.d.ts +0 -150
- package/dist/types/systems/NiceBehavior.d.ts +0 -160
- package/dist/types/systems/NiceBinding.d.ts +0 -96
- package/dist/types/systems/NiceBlacksmith.d.ts +0 -221
- package/dist/types/systems/NiceBuff.d.ts +0 -177
- package/dist/types/systems/NiceBuilding.d.ts +0 -207
- package/dist/types/systems/NiceBullet.d.ts +0 -167
- package/dist/types/systems/NiceCamera.d.ts +0 -252
- package/dist/types/systems/NiceCard.d.ts +0 -171
- package/dist/types/systems/NiceChat.d.ts +0 -148
- package/dist/types/systems/NiceCheat.d.ts +0 -375
- package/dist/types/systems/NiceClimbing.d.ts +0 -186
- package/dist/types/systems/NiceCloud.d.ts +0 -422
- package/dist/types/systems/NiceCollision.d.ts +0 -238
- package/dist/types/systems/NiceCombo.d.ts +0 -131
- package/dist/types/systems/NiceCommand.d.ts +0 -112
- package/dist/types/systems/NiceCompanion.d.ts +0 -182
- package/dist/types/systems/NiceController.d.ts +0 -144
- package/dist/types/systems/NiceCooking.d.ts +0 -193
- package/dist/types/systems/NiceCoroutine.d.ts +0 -101
- package/dist/types/systems/NiceCrafting.d.ts +0 -228
- package/dist/types/systems/NiceCutscene.d.ts +0 -437
- package/dist/types/systems/NiceDaily.d.ts +0 -133
- package/dist/types/systems/NiceDamage.d.ts +0 -271
- package/dist/types/systems/NiceDayNight.d.ts +0 -126
- package/dist/types/systems/NiceDebug.d.ts +0 -255
- package/dist/types/systems/NiceDestructible.d.ts +0 -150
- package/dist/types/systems/NiceDialogue.d.ts +0 -629
- package/dist/types/systems/NiceDungeon.d.ts +0 -202
- package/dist/types/systems/NiceECS.d.ts +0 -151
- package/dist/types/systems/NiceEnchant.d.ts +0 -148
- package/dist/types/systems/NiceEntityPool.d.ts +0 -127
- package/dist/types/systems/NiceEquipment.d.ts +0 -137
- package/dist/types/systems/NiceEvent.d.ts +0 -202
- package/dist/types/systems/NiceEventBus.d.ts +0 -164
- package/dist/types/systems/NiceFaction.d.ts +0 -173
- package/dist/types/systems/NiceFarming.d.ts +0 -163
- package/dist/types/systems/NiceFishing.d.ts +0 -196
- package/dist/types/systems/NiceFlocking.d.ts +0 -156
- package/dist/types/systems/NiceFog.d.ts +0 -137
- package/dist/types/systems/NiceFormation.d.ts +0 -140
- package/dist/types/systems/NiceGacha.d.ts +0 -134
- package/dist/types/systems/NiceGambling.d.ts +0 -175
- package/dist/types/systems/NiceGem.d.ts +0 -165
- package/dist/types/systems/NiceGesture.d.ts +0 -502
- package/dist/types/systems/NiceGrappling.d.ts +0 -154
- package/dist/types/systems/NiceGrid.d.ts +0 -142
- package/dist/types/systems/NiceGuild.d.ts +0 -162
- package/dist/types/systems/NiceHaptics.d.ts +0 -112
- package/dist/types/systems/NiceHousing.d.ts +0 -197
- package/dist/types/systems/NiceInput.d.ts +0 -280
- package/dist/types/systems/NiceInventory.d.ts +0 -534
- package/dist/types/systems/NiceLOD.d.ts +0 -144
- package/dist/types/systems/NiceLeaderboard.d.ts +0 -191
- package/dist/types/systems/NiceLevel.d.ts +0 -304
- package/dist/types/systems/NiceLighting.d.ts +0 -214
- package/dist/types/systems/NiceLocalization.d.ts +0 -148
- package/dist/types/systems/NiceLocomotion.d.ts +0 -398
- package/dist/types/systems/NiceLogger.d.ts +0 -117
- package/dist/types/systems/NiceLoot.d.ts +0 -176
- package/dist/types/systems/NiceMail.d.ts +0 -164
- package/dist/types/systems/NiceMap.d.ts +0 -234
- package/dist/types/systems/NiceMarriage.d.ts +0 -150
- package/dist/types/systems/NiceMastery.d.ts +0 -171
- package/dist/types/systems/NiceMatch.d.ts +0 -196
- package/dist/types/systems/NiceMatch3.d.ts +0 -118
- package/dist/types/systems/NiceMessageBus.d.ts +0 -115
- package/dist/types/systems/NiceMinimap.d.ts +0 -258
- package/dist/types/systems/NiceMining.d.ts +0 -175
- package/dist/types/systems/NiceModding.d.ts +0 -452
- package/dist/types/systems/NiceMount.d.ts +0 -152
- package/dist/types/systems/NiceNavigation.d.ts +0 -307
- package/dist/types/systems/NiceNetwork.d.ts +0 -568
- package/dist/types/systems/NiceNotification.d.ts +0 -438
- package/dist/types/systems/NiceObjective.d.ts +0 -395
- package/dist/types/systems/NiceParticle.d.ts +0 -639
- package/dist/types/systems/NiceParty.d.ts +0 -168
- package/dist/types/systems/NicePerformance.d.ts +0 -144
- package/dist/types/systems/NicePet.d.ts +0 -167
- package/dist/types/systems/NicePhotoMode.d.ts +0 -270
- package/dist/types/systems/NicePhysics.d.ts +0 -326
- package/dist/types/systems/NicePlatformer.d.ts +0 -158
- package/dist/types/systems/NicePool.d.ts +0 -128
- package/dist/types/systems/NicePortal.d.ts +0 -178
- package/dist/types/systems/NicePostProcess.d.ts +0 -254
- package/dist/types/systems/NiceProcedural.d.ts +0 -202
- package/dist/types/systems/NiceProfile.d.ts +0 -223
- package/dist/types/systems/NiceProjectile.d.ts +0 -157
- package/dist/types/systems/NicePvP.d.ts +0 -199
- package/dist/types/systems/NiceQTE.d.ts +0 -160
- package/dist/types/systems/NiceQuest.d.ts +0 -620
- package/dist/types/systems/NiceRaid.d.ts +0 -215
- package/dist/types/systems/NiceRanking.d.ts +0 -399
- package/dist/types/systems/NiceReplay.d.ts +0 -180
- package/dist/types/systems/NiceReputation.d.ts +0 -151
- package/dist/types/systems/NiceResource.d.ts +0 -200
- package/dist/types/systems/NiceRhythm.d.ts +0 -148
- package/dist/types/systems/NiceRoguelike.d.ts +0 -276
- package/dist/types/systems/NiceRune.d.ts +0 -202
- package/dist/types/systems/NiceSaveSystem.d.ts +0 -194
- package/dist/types/systems/NiceSceneManager.d.ts +0 -112
- package/dist/types/systems/NiceScore.d.ts +0 -186
- package/dist/types/systems/NiceScreenFX.d.ts +0 -235
- package/dist/types/systems/NiceScreenshot.d.ts +0 -443
- package/dist/types/systems/NiceScribe.d.ts +0 -239
- package/dist/types/systems/NiceSeason.d.ts +0 -176
- package/dist/types/systems/NiceSerialization.d.ts +0 -89
- package/dist/types/systems/NiceServiceLocator.d.ts +0 -94
- package/dist/types/systems/NiceShop.d.ts +0 -528
- package/dist/types/systems/NiceSignal.d.ts +0 -112
- package/dist/types/systems/NiceSkillTree.d.ts +0 -237
- package/dist/types/systems/NiceSocial.d.ts +0 -580
- package/dist/types/systems/NiceSpawner.d.ts +0 -237
- package/dist/types/systems/NiceSpell.d.ts +0 -216
- package/dist/types/systems/NiceState.d.ts +0 -224
- package/dist/types/systems/NiceStateMachine.d.ts +0 -108
- package/dist/types/systems/NiceStatus.d.ts +0 -116
- package/dist/types/systems/NiceStealth.d.ts +0 -204
- package/dist/types/systems/NiceSteam.d.ts +0 -255
- package/dist/types/systems/NiceStreaming.d.ts +0 -173
- package/dist/types/systems/NiceSwimming.d.ts +0 -166
- package/dist/types/systems/NiceTalent.d.ts +0 -154
- package/dist/types/systems/NiceTarget.d.ts +0 -121
- package/dist/types/systems/NiceTerrain.d.ts +0 -143
- package/dist/types/systems/NiceTilemap.d.ts +0 -218
- package/dist/types/systems/NiceTimer.d.ts +0 -153
- package/dist/types/systems/NiceTournament.d.ts +0 -190
- package/dist/types/systems/NiceTrading.d.ts +0 -238
- package/dist/types/systems/NiceTransmog.d.ts +0 -142
- package/dist/types/systems/NiceTutorial.d.ts +0 -248
- package/dist/types/systems/NiceTween.d.ts +0 -164
- package/dist/types/systems/NiceUI.d.ts +0 -364
- package/dist/types/systems/NiceVFX.d.ts +0 -333
- package/dist/types/systems/NiceVehicle.d.ts +0 -176
- package/dist/types/systems/NiceVoice.d.ts +0 -502
- package/dist/types/systems/NiceWater.d.ts +0 -162
- package/dist/types/systems/NiceWave.d.ts +0 -174
- package/dist/types/systems/NiceWaypoint.d.ts +0 -165
- package/dist/types/systems/NiceWeather.d.ts +0 -225
- package/dist/types/systems/NiceXR.d.ts +0 -187
- package/dist/types/systems/index.d.ts +0 -182
- package/dist/types/templates/index.d.ts +0 -2
- package/dist/types/tilemap/index.d.ts +0 -1
- package/dist/types/tutorials/TutorialEditor.d.ts +0 -43
- package/dist/types/tutorials/VoiceNarration.d.ts +0 -75
- package/dist/types/tutorials/content/Tutorials_T04.d.ts +0 -3
- package/dist/types/tutorials/content/UITutorials.d.ts +0 -14
- package/dist/types/tutorials/content/index.d.ts +0 -5
- package/dist/types/tutorials/index.d.ts +0 -6
- package/dist/types/ui/index.d.ts +0 -2
- package/dist/types/visual-scripting/VisualScriptDebugger.d.ts +0 -145
- package/dist/types/visual-scripting/VisualScriptExecutor.d.ts +0 -100
- package/dist/types/visual-scripting/VisualScriptGraph.d.ts +0 -173
- package/dist/types/visual-scripting/VisualScriptNode.d.ts +0 -157
- package/dist/types/visual-scripting/index.d.ts +0 -6
- package/dist/types/visual-scripting/nodes/ActionNodes.d.ts +0 -152
- package/dist/types/visual-scripting/nodes/EventNodes.d.ts +0 -95
- package/dist/types/visual-scripting/nodes/FlowControlNodes.d.ts +0 -134
- package/dist/types/visual-scripting/nodes/LogicNodes.d.ts +0 -122
- package/dist/types/visual-scripting/nodes/MathNodes.d.ts +0 -170
- package/dist/types/visual-scripting/nodes/UtilityNodes.d.ts +0 -131
- package/dist/types/visual-scripting/nodes/VariableNodes.d.ts +0 -107
- package/dist/types/visual-scripting/nodes/index.d.ts +0 -21
- package/dist/types/visual-scripting/nodes/registerNodes.d.ts +0 -29
- package/dist/types/visual-scripting/types.d.ts +0 -402
- package/dist/types/xr/WebXRLayers.d.ts +0 -319
- package/dist/types/xr/index.d.ts +0 -2
|
@@ -1,629 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NiceDialogue - Comprehensive Dialogue System
|
|
3
|
-
*
|
|
4
|
-
* Professional dialogue system for RPGs and narrative games.
|
|
5
|
-
* Supports branching conversations, conditions, effects, voice, and localization.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Branching dialogue trees with conditions
|
|
9
|
-
* - Character/speaker management
|
|
10
|
-
* - Response choices with requirements
|
|
11
|
-
* - Variables and state tracking
|
|
12
|
-
* - Hooks for effects/consequences
|
|
13
|
-
* - Voice acting support
|
|
14
|
-
* - Localization integration
|
|
15
|
-
* - Ink/Yarn-like scripting support
|
|
16
|
-
* - Dialogue history
|
|
17
|
-
* - Skip/auto-advance modes
|
|
18
|
-
*
|
|
19
|
-
* @packageDocumentation
|
|
20
|
-
*/
|
|
21
|
-
import { EventEmitter } from 'eventemitter3';
|
|
22
|
-
/** Unique identifier for dialogues */
|
|
23
|
-
export type DialogueId = string;
|
|
24
|
-
/** Unique identifier for nodes */
|
|
25
|
-
export type NodeId = string;
|
|
26
|
-
/** Unique identifier for characters/speakers */
|
|
27
|
-
export type CharacterId = string;
|
|
28
|
-
/** Unique identifier for conversations */
|
|
29
|
-
export type ConversationId = string;
|
|
30
|
-
/** Unique identifier for response options */
|
|
31
|
-
export type ResponseId = string;
|
|
32
|
-
/** Node types in dialogue tree */
|
|
33
|
-
export type NodeType = 'text' | 'choice' | 'branch' | 'jump' | 'set' | 'event' | 'random' | 'sequence' | 'parallel' | 'wait' | 'end';
|
|
34
|
-
/** Comparison operators for conditions */
|
|
35
|
-
export type ComparisonOp = '==' | '!=' | '>' | '<' | '>=' | '<=' | 'contains' | 'startsWith' | 'endsWith';
|
|
36
|
-
/** Logical operators */
|
|
37
|
-
export type LogicalOp = 'and' | 'or' | 'not';
|
|
38
|
-
/** Variable types */
|
|
39
|
-
export type VariableType = 'string' | 'number' | 'boolean' | 'array';
|
|
40
|
-
/** Variable value */
|
|
41
|
-
export type VariableValue = string | number | boolean | VariableValue[];
|
|
42
|
-
/** Condition for branching */
|
|
43
|
-
export interface Condition {
|
|
44
|
-
type: 'variable' | 'function' | 'compound';
|
|
45
|
-
variable?: string;
|
|
46
|
-
operator?: ComparisonOp;
|
|
47
|
-
value?: VariableValue;
|
|
48
|
-
functionName?: string;
|
|
49
|
-
args?: VariableValue[];
|
|
50
|
-
logicalOp?: LogicalOp;
|
|
51
|
-
conditions?: Condition[];
|
|
52
|
-
}
|
|
53
|
-
/** Effect/action to execute */
|
|
54
|
-
export interface Effect {
|
|
55
|
-
type: 'setVariable' | 'addVariable' | 'triggerEvent' | 'callFunction' | 'startQuest' | 'giveItem' | 'playSound' | 'playAnimation';
|
|
56
|
-
target?: string;
|
|
57
|
-
value?: VariableValue;
|
|
58
|
-
eventName?: string;
|
|
59
|
-
eventData?: Record<string, VariableValue>;
|
|
60
|
-
functionName?: string;
|
|
61
|
-
args?: VariableValue[];
|
|
62
|
-
questId?: string;
|
|
63
|
-
itemId?: string;
|
|
64
|
-
amount?: number;
|
|
65
|
-
soundId?: string;
|
|
66
|
-
animationId?: string;
|
|
67
|
-
}
|
|
68
|
-
/** Character/speaker definition */
|
|
69
|
-
export interface Character {
|
|
70
|
-
id: CharacterId;
|
|
71
|
-
name: string;
|
|
72
|
-
displayName?: string;
|
|
73
|
-
portrait?: string;
|
|
74
|
-
color?: string;
|
|
75
|
-
voiceId?: string;
|
|
76
|
-
tags?: string[];
|
|
77
|
-
metadata?: Record<string, VariableValue>;
|
|
78
|
-
}
|
|
79
|
-
/** Response option for choice nodes */
|
|
80
|
-
export interface DialogueResponse {
|
|
81
|
-
id: ResponseId;
|
|
82
|
-
text: string;
|
|
83
|
-
shortText?: string;
|
|
84
|
-
targetNode: NodeId;
|
|
85
|
-
conditions?: Condition[];
|
|
86
|
-
effects?: Effect[];
|
|
87
|
-
isDefault?: boolean;
|
|
88
|
-
isOnce?: boolean;
|
|
89
|
-
wasSelected?: boolean;
|
|
90
|
-
priority?: number;
|
|
91
|
-
hints?: string[];
|
|
92
|
-
tags?: string[];
|
|
93
|
-
}
|
|
94
|
-
/** Base dialogue node */
|
|
95
|
-
export interface BaseDialogueNode {
|
|
96
|
-
id: NodeId;
|
|
97
|
-
type: NodeType;
|
|
98
|
-
tags?: string[];
|
|
99
|
-
metadata?: Record<string, VariableValue>;
|
|
100
|
-
}
|
|
101
|
-
/** Text node - displays dialogue */
|
|
102
|
-
export interface TextNode extends BaseDialogueNode {
|
|
103
|
-
type: 'text';
|
|
104
|
-
speaker?: CharacterId;
|
|
105
|
-
text: string;
|
|
106
|
-
voiceClip?: string;
|
|
107
|
-
duration?: number;
|
|
108
|
-
emotion?: string;
|
|
109
|
-
animation?: string;
|
|
110
|
-
nextNode?: NodeId;
|
|
111
|
-
effects?: Effect[];
|
|
112
|
-
autoAdvance?: boolean;
|
|
113
|
-
typewriterSpeed?: number;
|
|
114
|
-
}
|
|
115
|
-
/** Choice node - presents options */
|
|
116
|
-
export interface ChoiceNode extends BaseDialogueNode {
|
|
117
|
-
type: 'choice';
|
|
118
|
-
speaker?: CharacterId;
|
|
119
|
-
prompt?: string;
|
|
120
|
-
responses: DialogueResponse[];
|
|
121
|
-
timeout?: number;
|
|
122
|
-
defaultResponse?: ResponseId;
|
|
123
|
-
shuffleResponses?: boolean;
|
|
124
|
-
}
|
|
125
|
-
/** Branch node - conditional routing */
|
|
126
|
-
export interface BranchNode extends BaseDialogueNode {
|
|
127
|
-
type: 'branch';
|
|
128
|
-
branches: Array<{
|
|
129
|
-
condition: Condition;
|
|
130
|
-
targetNode: NodeId;
|
|
131
|
-
}>;
|
|
132
|
-
defaultNode?: NodeId;
|
|
133
|
-
}
|
|
134
|
-
/** Jump node - go to another node/dialogue */
|
|
135
|
-
export interface JumpNode extends BaseDialogueNode {
|
|
136
|
-
type: 'jump';
|
|
137
|
-
targetDialogue?: DialogueId;
|
|
138
|
-
targetNode: NodeId;
|
|
139
|
-
returnAfter?: boolean;
|
|
140
|
-
}
|
|
141
|
-
/** Set node - modify variables */
|
|
142
|
-
export interface SetNode extends BaseDialogueNode {
|
|
143
|
-
type: 'set';
|
|
144
|
-
effects: Effect[];
|
|
145
|
-
nextNode?: NodeId;
|
|
146
|
-
}
|
|
147
|
-
/** Event node - trigger game events */
|
|
148
|
-
export interface EventNode extends BaseDialogueNode {
|
|
149
|
-
type: 'event';
|
|
150
|
-
eventName: string;
|
|
151
|
-
eventData?: Record<string, VariableValue>;
|
|
152
|
-
nextNode?: NodeId;
|
|
153
|
-
waitForCompletion?: boolean;
|
|
154
|
-
}
|
|
155
|
-
/** Random node - random selection */
|
|
156
|
-
export interface RandomNode extends BaseDialogueNode {
|
|
157
|
-
type: 'random';
|
|
158
|
-
options: Array<{
|
|
159
|
-
weight: number;
|
|
160
|
-
targetNode: NodeId;
|
|
161
|
-
}>;
|
|
162
|
-
noRepeat?: boolean;
|
|
163
|
-
lastSelected?: NodeId;
|
|
164
|
-
}
|
|
165
|
-
/** Sequence node - play in order */
|
|
166
|
-
export interface SequenceNode extends BaseDialogueNode {
|
|
167
|
-
type: 'sequence';
|
|
168
|
-
nodes: NodeId[];
|
|
169
|
-
currentIndex?: number;
|
|
170
|
-
nextNode?: NodeId;
|
|
171
|
-
}
|
|
172
|
-
/** Parallel node - concurrent display */
|
|
173
|
-
export interface ParallelNode extends BaseDialogueNode {
|
|
174
|
-
type: 'parallel';
|
|
175
|
-
nodes: NodeId[];
|
|
176
|
-
nextNode?: NodeId;
|
|
177
|
-
}
|
|
178
|
-
/** Wait node - pause for condition */
|
|
179
|
-
export interface WaitNode extends BaseDialogueNode {
|
|
180
|
-
type: 'wait';
|
|
181
|
-
duration?: number;
|
|
182
|
-
condition?: Condition;
|
|
183
|
-
nextNode?: NodeId;
|
|
184
|
-
}
|
|
185
|
-
/** End node - terminate dialogue */
|
|
186
|
-
export interface EndNode extends BaseDialogueNode {
|
|
187
|
-
type: 'end';
|
|
188
|
-
effects?: Effect[];
|
|
189
|
-
}
|
|
190
|
-
/** Union of all node types */
|
|
191
|
-
export type DialogueNode = TextNode | ChoiceNode | BranchNode | JumpNode | SetNode | EventNode | RandomNode | SequenceNode | ParallelNode | WaitNode | EndNode;
|
|
192
|
-
/** Complete dialogue definition */
|
|
193
|
-
export interface Dialogue {
|
|
194
|
-
id: DialogueId;
|
|
195
|
-
name: string;
|
|
196
|
-
description?: string;
|
|
197
|
-
startNode: NodeId;
|
|
198
|
-
nodes: Map<NodeId, DialogueNode>;
|
|
199
|
-
characters?: CharacterId[];
|
|
200
|
-
tags?: string[];
|
|
201
|
-
priority?: number;
|
|
202
|
-
conditions?: Condition[];
|
|
203
|
-
onStart?: Effect[];
|
|
204
|
-
onEnd?: Effect[];
|
|
205
|
-
metadata?: Record<string, VariableValue>;
|
|
206
|
-
}
|
|
207
|
-
/** Active conversation state */
|
|
208
|
-
export interface ConversationState {
|
|
209
|
-
id: ConversationId;
|
|
210
|
-
dialogueId: DialogueId;
|
|
211
|
-
currentNode: NodeId;
|
|
212
|
-
nodeStack: NodeId[];
|
|
213
|
-
dialogueStack: DialogueId[];
|
|
214
|
-
startTime: number;
|
|
215
|
-
lastUpdateTime: number;
|
|
216
|
-
isPaused: boolean;
|
|
217
|
-
isComplete: boolean;
|
|
218
|
-
variables: Map<string, VariableValue>;
|
|
219
|
-
visitedNodes: Set<NodeId>;
|
|
220
|
-
selectedResponses: Map<NodeId, ResponseId>;
|
|
221
|
-
history: DialogueHistoryEntry[];
|
|
222
|
-
}
|
|
223
|
-
/** History entry */
|
|
224
|
-
export interface DialogueHistoryEntry {
|
|
225
|
-
timestamp: number;
|
|
226
|
-
nodeId: NodeId;
|
|
227
|
-
speaker?: CharacterId;
|
|
228
|
-
text?: string;
|
|
229
|
-
selectedResponse?: ResponseId;
|
|
230
|
-
effects?: Effect[];
|
|
231
|
-
}
|
|
232
|
-
/** Dialogue event types */
|
|
233
|
-
export type DialogueEventType = 'conversation:start' | 'conversation:end' | 'conversation:pause' | 'conversation:resume' | 'node:enter' | 'node:exit' | 'text:display' | 'text:complete' | 'choice:presented' | 'choice:selected' | 'effect:executed' | 'event:triggered' | 'variable:changed' | 'jump:executed' | 'timeout:occurred' | 'error';
|
|
234
|
-
/** Dialogue event */
|
|
235
|
-
export interface DialogueEvent {
|
|
236
|
-
type: DialogueEventType;
|
|
237
|
-
conversationId?: ConversationId;
|
|
238
|
-
dialogueId?: DialogueId;
|
|
239
|
-
nodeId?: NodeId;
|
|
240
|
-
speaker?: Character;
|
|
241
|
-
text?: string;
|
|
242
|
-
responses?: DialogueResponse[];
|
|
243
|
-
selectedResponse?: DialogueResponse;
|
|
244
|
-
effect?: Effect;
|
|
245
|
-
eventName?: string;
|
|
246
|
-
eventData?: Record<string, VariableValue>;
|
|
247
|
-
variable?: string;
|
|
248
|
-
oldValue?: VariableValue;
|
|
249
|
-
newValue?: VariableValue;
|
|
250
|
-
error?: Error;
|
|
251
|
-
timestamp: number;
|
|
252
|
-
}
|
|
253
|
-
/** Event callback */
|
|
254
|
-
export type DialogueEventCallback = (event: DialogueEvent) => void;
|
|
255
|
-
/** Function registry entry */
|
|
256
|
-
export interface FunctionDefinition {
|
|
257
|
-
name: string;
|
|
258
|
-
fn: (...args: VariableValue[]) => VariableValue | boolean | void;
|
|
259
|
-
description?: string;
|
|
260
|
-
}
|
|
261
|
-
/** Dialogue system configuration */
|
|
262
|
-
export interface DialogueConfig {
|
|
263
|
-
/** Default typewriter speed (characters per second) */
|
|
264
|
-
defaultTypewriterSpeed: number;
|
|
265
|
-
/** Auto-advance delay after text complete (ms) */
|
|
266
|
-
autoAdvanceDelay: number;
|
|
267
|
-
/** Enable dialogue history */
|
|
268
|
-
enableHistory: boolean;
|
|
269
|
-
/** Maximum history entries */
|
|
270
|
-
maxHistoryEntries: number;
|
|
271
|
-
/** Allow skipping text */
|
|
272
|
-
allowSkip: boolean;
|
|
273
|
-
/** Allow going back in conversation */
|
|
274
|
-
allowBack: boolean;
|
|
275
|
-
/** Default choice timeout (0 = no timeout) */
|
|
276
|
-
defaultChoiceTimeout: number;
|
|
277
|
-
/** Localization function */
|
|
278
|
-
localize?: (key: string, params?: Record<string, string>) => string;
|
|
279
|
-
/** Voice playback function */
|
|
280
|
-
playVoice?: (clipId: string) => Promise<void>;
|
|
281
|
-
/** Debug mode */
|
|
282
|
-
debug: boolean;
|
|
283
|
-
}
|
|
284
|
-
export declare const DEFAULT_DIALOGUE_CONFIG: DialogueConfig;
|
|
285
|
-
export declare class NiceDialogue extends EventEmitter<Record<DialogueEventType, [DialogueEvent]>> {
|
|
286
|
-
private config;
|
|
287
|
-
private dialogues;
|
|
288
|
-
private characters;
|
|
289
|
-
private conversations;
|
|
290
|
-
private globalVariables;
|
|
291
|
-
private functions;
|
|
292
|
-
private typewriterTimers;
|
|
293
|
-
private timeoutTimers;
|
|
294
|
-
private conversationCounter;
|
|
295
|
-
constructor(config?: Partial<DialogueConfig>);
|
|
296
|
-
/**
|
|
297
|
-
* Register a dialogue
|
|
298
|
-
*/
|
|
299
|
-
registerDialogue(dialogue: Dialogue): void;
|
|
300
|
-
/**
|
|
301
|
-
* Register multiple dialogues
|
|
302
|
-
*/
|
|
303
|
-
registerDialogues(dialogues: Dialogue[]): void;
|
|
304
|
-
/**
|
|
305
|
-
* Unregister a dialogue
|
|
306
|
-
*/
|
|
307
|
-
unregisterDialogue(id: DialogueId): boolean;
|
|
308
|
-
/**
|
|
309
|
-
* Get dialogue by ID
|
|
310
|
-
*/
|
|
311
|
-
getDialogue(id: DialogueId): Dialogue | undefined;
|
|
312
|
-
/**
|
|
313
|
-
* Register a character
|
|
314
|
-
*/
|
|
315
|
-
registerCharacter(character: Character): void;
|
|
316
|
-
/**
|
|
317
|
-
* Register multiple characters
|
|
318
|
-
*/
|
|
319
|
-
registerCharacters(characters: Character[]): void;
|
|
320
|
-
/**
|
|
321
|
-
* Get character by ID
|
|
322
|
-
*/
|
|
323
|
-
getCharacter(id: CharacterId): Character | undefined;
|
|
324
|
-
/**
|
|
325
|
-
* Set global variable
|
|
326
|
-
*/
|
|
327
|
-
setVariable(name: string, value: VariableValue): void;
|
|
328
|
-
/**
|
|
329
|
-
* Get global variable
|
|
330
|
-
*/
|
|
331
|
-
getVariable(name: string): VariableValue | undefined;
|
|
332
|
-
/**
|
|
333
|
-
* Check if variable exists
|
|
334
|
-
*/
|
|
335
|
-
hasVariable(name: string): boolean;
|
|
336
|
-
/**
|
|
337
|
-
* Delete variable
|
|
338
|
-
*/
|
|
339
|
-
deleteVariable(name: string): boolean;
|
|
340
|
-
/**
|
|
341
|
-
* Get all variables
|
|
342
|
-
*/
|
|
343
|
-
getAllVariables(): Map<string, VariableValue>;
|
|
344
|
-
/**
|
|
345
|
-
* Set multiple variables
|
|
346
|
-
*/
|
|
347
|
-
setVariables(variables: Record<string, VariableValue>): void;
|
|
348
|
-
/**
|
|
349
|
-
* Register a custom function
|
|
350
|
-
*/
|
|
351
|
-
registerFunction(name: string, fn: (...args: VariableValue[]) => VariableValue | boolean | void, description?: string): void;
|
|
352
|
-
/**
|
|
353
|
-
* Call a registered function
|
|
354
|
-
*/
|
|
355
|
-
callFunction(name: string, ...args: VariableValue[]): VariableValue | boolean | void;
|
|
356
|
-
/**
|
|
357
|
-
* Register built-in functions
|
|
358
|
-
*/
|
|
359
|
-
private registerBuiltInFunctions;
|
|
360
|
-
/**
|
|
361
|
-
* Start a new conversation
|
|
362
|
-
*/
|
|
363
|
-
startConversation(dialogueId: DialogueId, initialVariables?: Record<string, VariableValue>): ConversationId | null;
|
|
364
|
-
/**
|
|
365
|
-
* End a conversation
|
|
366
|
-
*/
|
|
367
|
-
endConversation(conversationId: ConversationId): void;
|
|
368
|
-
/**
|
|
369
|
-
* Pause a conversation
|
|
370
|
-
*/
|
|
371
|
-
pauseConversation(conversationId: ConversationId): void;
|
|
372
|
-
/**
|
|
373
|
-
* Resume a conversation
|
|
374
|
-
*/
|
|
375
|
-
resumeConversation(conversationId: ConversationId): void;
|
|
376
|
-
/**
|
|
377
|
-
* Get conversation state
|
|
378
|
-
*/
|
|
379
|
-
getConversation(conversationId: ConversationId): ConversationState | undefined;
|
|
380
|
-
/**
|
|
381
|
-
* Check if conversation is active
|
|
382
|
-
*/
|
|
383
|
-
isConversationActive(conversationId: ConversationId): boolean;
|
|
384
|
-
/**
|
|
385
|
-
* Get all active conversations
|
|
386
|
-
*/
|
|
387
|
-
getActiveConversations(): ConversationState[];
|
|
388
|
-
/**
|
|
389
|
-
* Clear conversation timers
|
|
390
|
-
*/
|
|
391
|
-
private clearConversationTimers;
|
|
392
|
-
/**
|
|
393
|
-
* Process current node in conversation
|
|
394
|
-
*/
|
|
395
|
-
private processNode;
|
|
396
|
-
/**
|
|
397
|
-
* Process text node
|
|
398
|
-
*/
|
|
399
|
-
private processTextNode;
|
|
400
|
-
/**
|
|
401
|
-
* Process choice node
|
|
402
|
-
*/
|
|
403
|
-
private processChoiceNode;
|
|
404
|
-
/**
|
|
405
|
-
* Select a response in choice node
|
|
406
|
-
*/
|
|
407
|
-
selectResponse(conversationId: ConversationId, responseId: ResponseId): void;
|
|
408
|
-
/**
|
|
409
|
-
* Process branch node
|
|
410
|
-
*/
|
|
411
|
-
private processBranchNode;
|
|
412
|
-
/**
|
|
413
|
-
* Process jump node
|
|
414
|
-
*/
|
|
415
|
-
private processJumpNode;
|
|
416
|
-
/**
|
|
417
|
-
* Process set node
|
|
418
|
-
*/
|
|
419
|
-
private processSetNode;
|
|
420
|
-
/**
|
|
421
|
-
* Process event node
|
|
422
|
-
*/
|
|
423
|
-
private processEventNode;
|
|
424
|
-
/**
|
|
425
|
-
* Process random node
|
|
426
|
-
*/
|
|
427
|
-
private processRandomNode;
|
|
428
|
-
/**
|
|
429
|
-
* Process sequence node
|
|
430
|
-
*/
|
|
431
|
-
private processSequenceNode;
|
|
432
|
-
/**
|
|
433
|
-
* Process wait node
|
|
434
|
-
*/
|
|
435
|
-
private processWaitNode;
|
|
436
|
-
/**
|
|
437
|
-
* Process end node
|
|
438
|
-
*/
|
|
439
|
-
private processEndNode;
|
|
440
|
-
/**
|
|
441
|
-
* Go to a specific node
|
|
442
|
-
*/
|
|
443
|
-
private goToNode;
|
|
444
|
-
/**
|
|
445
|
-
* Skip current text display
|
|
446
|
-
*/
|
|
447
|
-
skipText(conversationId: ConversationId): void;
|
|
448
|
-
/**
|
|
449
|
-
* Advance to next node (for non-auto text)
|
|
450
|
-
*/
|
|
451
|
-
advanceConversation(conversationId: ConversationId): void;
|
|
452
|
-
/**
|
|
453
|
-
* Evaluate a condition
|
|
454
|
-
*/
|
|
455
|
-
evaluateCondition(condition: Condition, state?: ConversationState): boolean;
|
|
456
|
-
/**
|
|
457
|
-
* Compare two values
|
|
458
|
-
*/
|
|
459
|
-
private compareValues;
|
|
460
|
-
/**
|
|
461
|
-
* Execute an effect
|
|
462
|
-
*/
|
|
463
|
-
private executeEffect;
|
|
464
|
-
/**
|
|
465
|
-
* Interpolate variables in text
|
|
466
|
-
*/
|
|
467
|
-
private interpolateText;
|
|
468
|
-
/**
|
|
469
|
-
* Add entry to conversation history
|
|
470
|
-
*/
|
|
471
|
-
private addToHistory;
|
|
472
|
-
/**
|
|
473
|
-
* Get conversation history
|
|
474
|
-
*/
|
|
475
|
-
getHistory(conversationId: ConversationId): DialogueHistoryEntry[];
|
|
476
|
-
/**
|
|
477
|
-
* Clear conversation history
|
|
478
|
-
*/
|
|
479
|
-
clearHistory(conversationId: ConversationId): void;
|
|
480
|
-
/**
|
|
481
|
-
* Shuffle array (Fisher-Yates)
|
|
482
|
-
*/
|
|
483
|
-
private shuffleArray;
|
|
484
|
-
/**
|
|
485
|
-
* Get dialogue statistics
|
|
486
|
-
*/
|
|
487
|
-
getStats(): {
|
|
488
|
-
dialogueCount: number;
|
|
489
|
-
characterCount: number;
|
|
490
|
-
activeConversations: number;
|
|
491
|
-
totalConversations: number;
|
|
492
|
-
variableCount: number;
|
|
493
|
-
functionCount: number;
|
|
494
|
-
};
|
|
495
|
-
/**
|
|
496
|
-
* Export state for saving
|
|
497
|
-
*/
|
|
498
|
-
exportState(): {
|
|
499
|
-
globalVariables: Record<string, VariableValue>;
|
|
500
|
-
conversations: Array<{
|
|
501
|
-
id: ConversationId;
|
|
502
|
-
dialogueId: DialogueId;
|
|
503
|
-
currentNode: NodeId;
|
|
504
|
-
variables: Record<string, VariableValue>;
|
|
505
|
-
visitedNodes: NodeId[];
|
|
506
|
-
selectedResponses: Array<[NodeId, ResponseId]>;
|
|
507
|
-
history: DialogueHistoryEntry[];
|
|
508
|
-
}>;
|
|
509
|
-
};
|
|
510
|
-
/**
|
|
511
|
-
* Import state
|
|
512
|
-
*/
|
|
513
|
-
importState(data: ReturnType<typeof this.exportState>): void;
|
|
514
|
-
/**
|
|
515
|
-
* Destroy the dialogue system
|
|
516
|
-
*/
|
|
517
|
-
destroy(): void;
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* Create a dialogue system
|
|
521
|
-
*/
|
|
522
|
-
export declare function createDialogueSystem(config?: Partial<DialogueConfig>): NiceDialogue;
|
|
523
|
-
/**
|
|
524
|
-
* Fluent builder for creating dialogues
|
|
525
|
-
*/
|
|
526
|
-
export declare class DialogueBuilder {
|
|
527
|
-
private dialogue;
|
|
528
|
-
private currentNodeId;
|
|
529
|
-
constructor(id: DialogueId, name: string);
|
|
530
|
-
description(desc: string): this;
|
|
531
|
-
characters(...ids: CharacterId[]): this;
|
|
532
|
-
tags(...tags: string[]): this;
|
|
533
|
-
priority(p: number): this;
|
|
534
|
-
conditions(...conditions: Condition[]): this;
|
|
535
|
-
onStart(...effects: Effect[]): this;
|
|
536
|
-
onEnd(...effects: Effect[]): this;
|
|
537
|
-
startAt(nodeId: NodeId): this;
|
|
538
|
-
text(id: NodeId, speaker: CharacterId | undefined, text: string, nextNode?: NodeId): this;
|
|
539
|
-
choice(id: NodeId, prompt?: string, speaker?: CharacterId): ChoiceBuilder;
|
|
540
|
-
branch(id: NodeId, defaultNode?: NodeId): BranchBuilder;
|
|
541
|
-
jump(id: NodeId, targetNode: NodeId, targetDialogue?: DialogueId): this;
|
|
542
|
-
set(id: NodeId, effects: Effect[], nextNode?: NodeId): this;
|
|
543
|
-
event(id: NodeId, eventName: string, eventData?: Record<string, VariableValue>, nextNode?: NodeId): this;
|
|
544
|
-
end(id: NodeId, effects?: Effect[]): this;
|
|
545
|
-
build(): Dialogue;
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* Choice node builder
|
|
549
|
-
*/
|
|
550
|
-
export declare class ChoiceBuilder {
|
|
551
|
-
private parent;
|
|
552
|
-
private node;
|
|
553
|
-
constructor(parent: DialogueBuilder, node: ChoiceNode);
|
|
554
|
-
response(id: ResponseId, text: string, targetNode: NodeId): ResponseBuilder;
|
|
555
|
-
timeout(ms: number, defaultResponse?: ResponseId): this;
|
|
556
|
-
shuffle(): this;
|
|
557
|
-
done(): DialogueBuilder;
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Response builder
|
|
561
|
-
*/
|
|
562
|
-
export declare class ResponseBuilder {
|
|
563
|
-
private parent;
|
|
564
|
-
private response;
|
|
565
|
-
constructor(parent: ChoiceBuilder, response: DialogueResponse);
|
|
566
|
-
shortText(text: string): this;
|
|
567
|
-
condition(condition: Condition): this;
|
|
568
|
-
effect(effect: Effect): this;
|
|
569
|
-
once(): this;
|
|
570
|
-
isDefault(): this;
|
|
571
|
-
priority(p: number): this;
|
|
572
|
-
done(): ChoiceBuilder;
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* Branch node builder
|
|
576
|
-
*/
|
|
577
|
-
export declare class BranchBuilder {
|
|
578
|
-
private parent;
|
|
579
|
-
private node;
|
|
580
|
-
constructor(parent: DialogueBuilder, node: BranchNode);
|
|
581
|
-
when(condition: Condition, targetNode: NodeId): this;
|
|
582
|
-
otherwise(targetNode: NodeId): this;
|
|
583
|
-
done(): DialogueBuilder;
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* Create a dialogue builder
|
|
587
|
-
*/
|
|
588
|
-
export declare function dialogue(id: DialogueId, name: string): DialogueBuilder;
|
|
589
|
-
/**
|
|
590
|
-
* Create a simple condition
|
|
591
|
-
*/
|
|
592
|
-
export declare function condition(variable: string, operator: ComparisonOp, value: VariableValue): Condition;
|
|
593
|
-
/**
|
|
594
|
-
* Create a function condition
|
|
595
|
-
*/
|
|
596
|
-
export declare function functionCondition(functionName: string, ...args: VariableValue[]): Condition;
|
|
597
|
-
/**
|
|
598
|
-
* Create an AND compound condition
|
|
599
|
-
*/
|
|
600
|
-
export declare function and(...conditions: Condition[]): Condition;
|
|
601
|
-
/**
|
|
602
|
-
* Create an OR compound condition
|
|
603
|
-
*/
|
|
604
|
-
export declare function or(...conditions: Condition[]): Condition;
|
|
605
|
-
/**
|
|
606
|
-
* Create a NOT condition
|
|
607
|
-
*/
|
|
608
|
-
export declare function not(c: Condition): Condition;
|
|
609
|
-
/**
|
|
610
|
-
* Create a set variable effect
|
|
611
|
-
*/
|
|
612
|
-
export declare function setVar(target: string, value: VariableValue): Effect;
|
|
613
|
-
/**
|
|
614
|
-
* Create an add variable effect
|
|
615
|
-
*/
|
|
616
|
-
export declare function addVar(target: string, value: number): Effect;
|
|
617
|
-
/**
|
|
618
|
-
* Create a trigger event effect
|
|
619
|
-
*/
|
|
620
|
-
export declare function triggerEvent(eventName: string, eventData?: Record<string, VariableValue>): Effect;
|
|
621
|
-
/**
|
|
622
|
-
* Create a give item effect
|
|
623
|
-
*/
|
|
624
|
-
export declare function giveItem(itemId: string, amount?: number): Effect;
|
|
625
|
-
/**
|
|
626
|
-
* Create a start quest effect
|
|
627
|
-
*/
|
|
628
|
-
export declare function startQuest(questId: string): Effect;
|
|
629
|
-
export { DialogueBuilder as Builder };
|