@scml/addon-modded-clothes

Modded clothes addon 的 TypeScript 类型定义,用于添加并修补 modded 服装数据。

安装

npm
yarn
pnpm
bun
deno
npm install -D @scml/addon-modded-clothes

快速开始

添加类型引用

在项目中添加三斜杠指令以引入全局类型:

/// <reference types="@scml/addon-modded-clothes" />

使用全局实例

addonModdedClothesAddon 已挂载到 window 上,可直接调用其方法:

window.addonModdedClothesAddon.addClothes(info);

按需导入类型

若只需导入部分类型,可使用子路径:

import type { ModdedClothesAddon, ClothesAddInfo } from '@scml/addon-modded-clothes/ModdedClothesAddon';
import type { ModdedClothesAddonParams } from '@scml/addon-modded-clothes/ModdedClothesAddonParams';

全局类型 global

主入口通过 /// <reference types="..." /> 扩展 Window 接口。 global 以下属性挂载在 window 上:

属性类型说明
addonModdedClothesAddonModdedClothesAddonAddon 实例,管理服装添加与修补
/// <reference types="@scml/addon-modded-clothes" />

// 使用示例
window.addonModdedClothesAddon.addClothes({ modName: 'myMod', clothes: [], patch: [] });
主入口
子路径导入
/// <reference types="@scml/addon-modded-clothes" />

子路径导出

子路径描述
.主入口,增强 Window/全局
./ModdedClothesAddon主类、接口及工具函数
./ModdedClothesAddonParams配置参数与类型守卫

API 参考

./ModdedClothesAddon

ModdedClothesAddon

实现 LifeTimeCircleHookAddonPluginHookPointEx 的 Addon 插件类,管理 clothesAddInfo

构造函数

参数类型说明
gSC2DataManagerSC2DataManagerMod Loader 数据管理器
gModUtilsModUtilsMod 工具

属性

属性类型说明
gSC2DataManagerSC2DataManager数据管理器引用
gModUtilsModUtils工具引用
loggerLogWrapper日志
isInitboolean是否已初始化
changedPathsSet<string>变更路径集合
clothesAddInfoMap<string, ClothesAddInfo>按 mod 名存储的服装信息

方法

方法签名说明
registerMod(addonName: string, mod: ModInfo, modZip: ModZipReader) => Promise<void>注册 mod,加载服装配置
addClothes(info: ClothesAddInfo) => void添加服装数据
exportDataZip(zip: JSZip) => Promise<JSZip>导出数据到 zip
init() => void初始化

ClothesAddInfo 接口

属性类型说明
modNamestringmod 名称
clothesClothesInfo[]服装列表
patchClothesPatchInfo[]修补配置

ClothesInfo 接口

属性类型说明
keystring服装 key
dataClothesItem[]服装条目数组

searchClothesByName() 方法

  • 签名: searchClothesByName(name: string): { c: ClothesItem; t: string }[]
  • 参数: name - 服装名称
  • 返回值: 匹配的服装条目及对应 key

checkForOutfitWarmth() 方法

  • 签名: checkForOutfitWarmth(logger: LogWrapper): void
  • 说明: 为 window.getTrueWarmth() 执行服装保暖检查

./ModdedClothesAddonParams

ModdedClothesAddonParams 接口

mod 配置参数,用于 mod.json 或类似配置。

属性类型说明
clothesAddClothesItem[]要添加的服装
patchstring[]可选的修补文件路径列表

AddClothesItem 接口

属性类型说明
keystring服装 key
filePathstring文件路径
dataClothesItem[]可选的服装条目

ClothesPatchInfo 接口

属性类型说明
keystring服装 key
dataClothesPatchUpdateType[]修补更新数据

ClothesPatchUpdateType 类型

ClothesItem 的局部更新类型,键为 ClothesItem 属性,值为新值或 null

checkParams() / checkAddClothesItem() / checkClothesPatchInfo() 类型守卫

  • checkParams(a: any): a is ModdedClothesAddonParams
  • checkAddClothesItem(a: any): a is AddClothesItem
  • checkClothesPatchInfo(a: any): a is ClothesPatchInfo

类型定义来源

INFO