import { GameClock, SystemHook } from './clock' import { DataPack } from '../../data/registry' import { EventDef } from '../../data/events' import type { World } from '../runtime/World' export type PluginKind = 'system' | 'data' | 'events' | 'content' export interface PluginHookGuard { onLoad?(): void onDisable?(): void onEnable?(): void onUninstall?(): void } export interface CotycPlugin { id: string name: string version: string author?: string description: string kind: PluginKind dependencies?: string[] conflicts?: string[] install(ctx: PluginContext): void uninstall?(ctx: PluginContext): void hooks?: PluginHookGuard protected?: boolean } export interface PluginContext { world: World clock: GameClock register: (phase: Parameters[0], fn: SystemHook) => () => void onYearStart: (fn: SystemHook) => () => void /** 时轮 anchor:phase 前/后挂勾(0.1.24;卸载时全摘) */ beforePhase: (phase: Parameters[0], fn: SystemHook) => () => void afterPhase: (phase: Parameters[0], fn: SystemHook) => () => void /** 世界生成钩子:插件可注入 NPC 模板(worldgen 词库插件化) */ addNpcTemplate: (def: import('../../data/npcs').NpcFamilyDef) => void /** 配方注册(MOD/内容包扩展丹药/铸器表) */ addPillRecipe: (r: { output: string; name: string; danfangLevel: number; stones: number; lingcao: number; beastcore: number; desc: string }) => void addForgeRecipe: (r: { output: string; name: string; stones: number; lingkuang: number; beastcore: number; desc: string }) => void /** 世界生成词库池注入(styles/regions/fams/suffixes) */ addWorldGenPool: (part: { styles?: string[]; regions?: string[]; fams?: string[]; suffixes?: string[] }) => void addCapability: (cap: { id: string; name: string; version: string; desc: string }) => void removeCapability: (id: string) => void enableCapability: (id: string, enabled: boolean) => void overridePack: (partial: Partial) => void resetPack: () => void addEventPool: (id: string, events: EventDef[]) => void removeEventPool: (id: string) => void } export interface PluginStatus { id: string name: string version: string kind: PluginKind installed: boolean enabled: boolean protected: boolean description: string dependencies?: string[] } export type PluginChange = { id: string; action: 'install' | 'remove' | 'enable' | 'disable' }