[ISSUE-1] Refactor NPC forms to modular node-based system #2
98
src/types/nodes.ts
Normal file
98
src/types/nodes.ts
Normal file
@@ -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<string, unknown> {
|
||||
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<string, unknown> {
|
||||
type: 'battleConfig';
|
||||
canBattle?: boolean;
|
||||
canChallenge?: boolean;
|
||||
battleTheme?: string;
|
||||
victoryTheme?: string;
|
||||
defeatTheme?: string;
|
||||
simultaneousBattles?: boolean;
|
||||
healAfterwards?: boolean;
|
||||
}
|
||||
|
||||
export interface PartyNodeData extends Record<string, unknown> {
|
||||
type: 'party';
|
||||
partyConfig: NPCConfiguration['party'];
|
||||
}
|
||||
|
||||
export interface InteractionNodeData extends Record<string, unknown> {
|
||||
type: 'interaction';
|
||||
interactionType: string;
|
||||
interactionData?: Record<string, unknown>;
|
||||
dialogueReference?: string;
|
||||
scriptReference?: string;
|
||||
}
|
||||
|
||||
export interface VariablesNodeData extends Record<string, unknown> {
|
||||
type: 'variables';
|
||||
configVariables: NPCConfiguration['config'];
|
||||
}
|
||||
|
||||
export interface DialogueNodeData extends Record<string, unknown> {
|
||||
type: 'dialogue';
|
||||
dialogueConfig: DialogueConfiguration | null;
|
||||
}
|
||||
|
||||
export interface OutputNodeData extends Record<string, unknown> {
|
||||
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<ModularNodeData>;
|
||||
|
||||
// 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<ModularNodeData>;
|
||||
}
|
||||
Reference in New Issue
Block a user