Files
ChronicleOfTheImmortalClan/src/renderer/game/engine/kernel/plugin.ts
T
thzxx a7fe166e85 v0.1.34b: 插件新卡+MOD 功法效果口/patch 层/冲突日志
【插件】SYSTEM_DEFS + worldview 观察卡/tech 功法卡(14);PluginContext + addTechniqueDef(全字段入 PACK 数组, grade≤3 自动池) + onWorldSimTick 观察回调(零 rng 零时序——proxy 追踪注销);
【MOD】ModPackData.techniques 补 4 流派效果字段;新增 patch 层(target 数值 mult 0.5~2/add——install 应用 uninstall 复原,validate 规则进预检);同 id 功法冲突 warn 日志
【门面】Runtime 未动;卸载回滚栈 patchUndo
2026-08-23 22:09:38 +08:00

84 lines
3.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
/** MOD 插件溯源(0.1.27:导出/显示用——原始 ModPack 引用) */
source?: unknown
}
export interface PluginContext {
world: World
clock: GameClock
register: (phase: Parameters<GameClock['register']>[0], fn: SystemHook) => () => void
onYearStart: (fn: SystemHook) => () => void
/** 时轮 anchorphase 前/后挂勾(0.1.24;卸载时全摘) */
beforePhase: (phase: Parameters<GameClock['register']>[0], fn: SystemHook) => () => void
afterPhase: (phase: Parameters<GameClock['register']>[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[] }, source?: string) => void
addCalamity: (name: string, opts: { brief?: string; family?: Partial<Record<string, number>>; effect?: Partial<Record<string, number>> }) => boolean
/** 0.1.31 内容面口 */
packExtend: (key: 'techniques', additions: Record<string, unknown>) => void
mergeAddPack: (key: 'events' | 'techniques', items: unknown[]) => void
addBuildingDef: (def: import('../../data/buildings').BuildingDef) => void
addPostDef: (def: import('../../data/posts').PostDef) => void
addAspirationDef: (def: import('../../data/aspirations').AspirationDef) => void
addFormationDef: (def: import('../../data/formations').FormationDef) => void
/** 0.1.34 功法定义注册(全字段——含流派效果;grade≤3 入求学/秘境池) */
addTechniqueDef: (def: import('../../data/realms').TechniqueDef) => void
/** 0.1.34 世界观察回调(每世界 tick 后——只读记录,禁止写时轮/序;MOD 数值洞察口) */
onWorldSimTick: (fn: (year: number, month: number, gameState: unknown) => void) => () => void
addTraitDef: (def: import('../../data/traits').TraitDef) => 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<DataPack>) => void
resetPack: () => void
addEventPool: (id: string, events: EventDef[]) => void
removeEventPool: (id: string) => void
}
export interface PluginStatus {
id: string
name: string
version: string
author?: string
kind: PluginKind
installed: boolean
enabled: boolean
protected: boolean
description: string
dependencies?: string[]
conflicts?: string[]
}
export type PluginChange = { id: string; action: 'install' | 'remove' | 'enable' | 'disable' }