DESKTOP-5RP3AKU\Jisol e24dded990 重置配置表
2023-11-06 02:25:02 +08:00

32 lines
757 B
TypeScript

import { TB } from "../../../resources/config/data/schema";
import { TD } from "../../App";
import GRoleBase from "../base/role/GRoleBase";
//角色工具类
export class GRoleUtil{
//获取存活的玩家 如果不存活则返回 null
static get<T extends GRoleBase<{}>>(player:T):() => T{
if(!player) return null;
return ():T => {
if(player)
return player.get();
return null;
}
}
//通过Id 获取 GRole
static getGRole(id:number):TB.TbGRole{
let info:TB.TbGRole;
if(!(info = TD.TbGRole.get(id))) return null;
return info
}
static getGRoles(ids:number[]):TB.TbGRole[]{
return ids.map(id => GRoleUtil.getGRole(id));
}
}