33 lines
843 B
TypeScript
Raw Normal View History

2023-10-26 03:06:44 +08:00
import { TableGRole } from "../../../resources/config/ts/TableGRole";
2023-11-01 02:01:35 +08:00
import { GFSMAnimBase } from "../base/fsm/GFSMAnimBase";
import GFSMBase from "../base/fsm/GFSMBase";
2023-10-26 03:06:44 +08:00
import GRoleBase from "../base/role/GRoleBase";
//角色工具类
export class GRoleUtil{
//获取存活的玩家 如果不存活则返回 null
2023-11-01 02:01:35 +08:00
static get<T extends GRoleBase<{}>>(player:T):() => T{
2023-10-26 03:06:44 +08:00
if(!player) return null;
2023-11-01 02:01:35 +08:00
return ():T => {
2023-10-26 03:06:44 +08:00
if(player)
return player.get();
return null;
}
}
//通过Id 获取 GRole
2023-10-30 02:34:11 +08:00
static getGRole(id:number):TableGRole{
2023-10-26 03:06:44 +08:00
let info:TableGRole;
if(!(info = TableGRole.getConfig(id))) return null;
2023-10-30 02:34:11 +08:00
return info
2023-10-26 03:06:44 +08:00
}
2023-10-30 02:34:11 +08:00
static getGRoles(ids:number[]):TableGRole[]{
2023-10-26 03:06:44 +08:00
return ids.map(id => GRoleUtil.getGRole(id));
}
}