PC-20230316NUNE\Administrator f99f10e237 提交
2023-12-11 10:42:36 +08:00

32 lines
756 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));
}
}