mirror of
https://github.com/motajs/template.git
synced 2026-11-05 17:04:31 +08:00
refactor: 删除 setAttributeDefaults 接口
This commit is contained in:
1 parent
acfb9c117d
commit
8fb16a103d
3 files changed
-34
No files matched your search
@@ -17,8 +17,6 @@ export class EnemyManager<TEnemy> implements IEnemyManager<TEnemy> {
|
||||
number,
|
||||
SpecialCreation<any, TEnemy>
|
||||
> = new Map();
|
||||
/** 自定义怪物属性注册表,name -> 默认值 */
|
||||
private readonly attributeRegistry: Map<keyof TEnemy, any> = new Map();
|
||||
/** 怪物模板表,code -> IEnemy */
|
||||
private readonly prefabByCode: Map<number, IEnemy<TEnemy>> = new Map();
|
||||
/** 复用映射,reusedCode -> sourceCode */
|
||||
@@ -38,22 +36,6 @@ export class EnemyManager<TEnemy> implements IEnemyManager<TEnemy> {
|
||||
this.specialRegistry.set(code, cons);
|
||||
}
|
||||
|
||||
setAttributeDefaults<K extends keyof TEnemy>(
|
||||
name: K,
|
||||
defaultValue: TEnemy[K]
|
||||
): void {
|
||||
if (
|
||||
typeof defaultValue === 'function' ||
|
||||
typeof defaultValue === 'symbol' ||
|
||||
typeof defaultValue === 'bigint' ||
|
||||
typeof defaultValue === 'undefined'
|
||||
) {
|
||||
logger.error(53);
|
||||
return;
|
||||
}
|
||||
this.attributeRegistry.set(name, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据怪物的图块数字或 id 获取其模板
|
||||
* @param token 怪物的图块数字或 id
|
||||
|
||||
@@ -166,16 +166,6 @@ export interface IEnemyManager<TAttr> extends ISaveableContent<
|
||||
*/
|
||||
registerSpecial(code: number, cons: SpecialCreation<any, TAttr>): void;
|
||||
|
||||
/**
|
||||
* 注册一个怪物属性
|
||||
* @param name 属性名称
|
||||
* @param defaultValue 属性默认值
|
||||
*/
|
||||
setAttributeDefaults<K extends keyof TAttr>(
|
||||
name: K,
|
||||
defaultValue: TAttr[K]
|
||||
): void;
|
||||
|
||||
/**
|
||||
* 创建怪物对象,如果对应数字的怪物不存在则会返回 `null`
|
||||
* @param token 怪物图块数字或 id
|
||||
|
||||
Reference in new issue
Block a user