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
This commit is contained in:
@@ -8,6 +8,7 @@ import { EventDef } from '../../data/events'
|
||||
import { findEvent } from './Systems/events'
|
||||
import { World } from './World'
|
||||
import { WorldGenPools } from '../sim/worldgen'
|
||||
import { pack as dataPack } from '../../data/registry'
|
||||
import { removeCalamityByName, overrideWorldNum, resetWorldNum } from '../sim/worldsim-data'
|
||||
import { removePillRecipe, removeForgeRecipe } from '../../data/items'
|
||||
import { registerBuildingDef } from '../../data/buildings'
|
||||
@@ -112,7 +113,12 @@ export function modToPlugin(pack: ModPack): CotycPlugin {
|
||||
for (const it of pack.data.items) base[it.id] = it
|
||||
ctx.overridePack({ items: base as never })
|
||||
}
|
||||
if (pack.data.techniques?.length) ctx.mergeAddPack('techniques', pack.data.techniques as never)
|
||||
if (pack.data.techniques?.length) {
|
||||
// 语义冲突日志:同 id 功法(mergeAdd 跳过内置——提示玩家谁改了什么)
|
||||
const seenT = new Set((dataPack().techniques as Array<{ id: string }>).map((x) => x.id))
|
||||
for (const t of pack.data.techniques) if (seenT.has(t.id)) ctx.world.log('info', `[MOD:${pack.id}] 功法 ${t.id} 同 id 已存在(内置优先,新增跳过)。`)
|
||||
ctx.mergeAddPack('techniques', pack.data.techniques as never)
|
||||
}
|
||||
for (const b of pack.data.buildings ?? []) ctx.addBuildingDef(toBuildingDef(b))
|
||||
for (const po of pack.data.posts ?? []) ctx.addPostDef({
|
||||
id: po.id, name: po.id, effect: { type: po.effectType, value: po.value }, max: po.max, desc: po.desc
|
||||
@@ -120,8 +126,11 @@ export function modToPlugin(pack: ModPack): CotycPlugin {
|
||||
for (const a of pack.data.aspirations ?? []) ctx.addAspirationDef(a as never)
|
||||
for (const f of pack.data.formations ?? []) ctx.addFormationDef({ ...f, retreatWound: f.retreatWound ?? 1 } as never)
|
||||
for (const t of pack.data.traits ?? []) ctx.addTraitDef({ ...t, danger: t.bonus?.danger ?? 0 } as never)
|
||||
// 0.1.34 MOD 数值 patch 层(仅新档生效;卸载复原——mult 0.5~2 / add 实数)
|
||||
ctx.world.applyModPatch(pack.data.patch ?? [])
|
||||
},
|
||||
uninstall(ctx2) {
|
||||
ctx2.world.patchUndo.splice(0).forEach((f) => f())
|
||||
// 0.1.28 精确回滚:词库池/灾因/配方/世界数值按来源摘除(其余 MOD 共享词条保留)
|
||||
WorldGenPools.removePool(`mod-${pack.id}`)
|
||||
for (const c of pack.data.calamities ?? []) removeCalamityByName(c.name)
|
||||
|
||||
Reference in New Issue
Block a user