From 60fdb95ce734f727e2a30f0b968de8b356371333 Mon Sep 17 00:00:00 2001 From: matthieu Date: Wed, 29 Oct 2025 16:26:08 +0100 Subject: [PATCH] [ISSUE-1] Add src/types/nodes.ts - Modular NPC system --- src/types/nodes.ts | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/types/nodes.ts diff --git a/src/types/nodes.ts b/src/types/nodes.ts new file mode 100644 index 0000000..39e0eca --- /dev/null +++ b/src/types/nodes.ts @@ -0,0 +1,98 @@ +import type { Node, Edge } from '@xyflow/react'; +import type { NPCConfiguration, DialogueConfiguration } from './npc'; + +// Define the types of nodes available in the modular system +export type NodeType = + | 'basicInfo' + | 'battleConfig' + | 'party' + | 'interaction' + | 'variables' + | 'dialogue' + | 'output'; + +// Data structure for each node type +export interface BasicInfoNodeData extends Record { + type: 'basicInfo'; + resourceIdentifier: string; + names: string[]; + hitbox: string | { width: number; height: number }; + modelScale?: number; + aspects?: string[]; + isInvulnerable?: boolean; + canDespawn?: boolean; + isMovable?: boolean; + isLeashable?: boolean; + allowProjectileHits?: boolean; + hideNameTag?: boolean; +} + +export interface BattleConfigNodeData extends Record { + type: 'battleConfig'; + canBattle?: boolean; + canChallenge?: boolean; + battleTheme?: string; + victoryTheme?: string; + defeatTheme?: string; + simultaneousBattles?: boolean; + healAfterwards?: boolean; +} + +export interface PartyNodeData extends Record { + type: 'party'; + partyConfig: NPCConfiguration['party']; +} + +export interface InteractionNodeData extends Record { + type: 'interaction'; + interactionType: string; + interactionData?: Record; + dialogueReference?: string; + scriptReference?: string; +} + +export interface VariablesNodeData extends Record { + type: 'variables'; + configVariables: NPCConfiguration['config']; +} + +export interface DialogueNodeData extends Record { + type: 'dialogue'; + dialogueConfig: DialogueConfiguration | null; +} + +export interface OutputNodeData extends Record { + type: 'output'; + previewData?: NPCConfiguration; +} + +// Union type for all node data types +export type ModularNodeData = + | BasicInfoNodeData + | BattleConfigNodeData + | PartyNodeData + | InteractionNodeData + | VariablesNodeData + | DialogueNodeData + | OutputNodeData; + +// Extended Node type with our custom data +export type ModularNode = Node; + +// Workflow state that contains all nodes and edges +export interface WorkflowState { + nodes: ModularNode[]; + edges: Edge[]; + npcConfig: NPCConfiguration; + dialogueConfig: DialogueConfiguration | null; +} + +// Node template for creating new nodes +export interface NodeTemplate { + type: NodeType; + label: string; + icon: string; + description: string; + color: string; + defaultData: Partial; +}