29 lines
809 B
C#
29 lines
809 B
C#
using Fantasy;
|
|
using Fantasy.Async;
|
|
using Fantasy.Entitas;
|
|
using Fantasy.Helper;
|
|
|
|
namespace NB.Gate;
|
|
|
|
public static class PlayerFactory
|
|
{
|
|
/// <summary>
|
|
/// 创建一个新的Player
|
|
/// </summary>
|
|
/// <param name="scene"></param>
|
|
/// <param name="aId">ToKen令牌传递过来的aId</param>
|
|
/// <param name="isSaveDataBase">是否在创建的过程中保存到数据库</param>
|
|
/// <returns></returns>
|
|
public static async FTask<Player> Create(Scene scene, long aId, bool isSaveDataBase = true)
|
|
{
|
|
var gameAccount = Entity.Create<Player>(scene, aId, false, false);
|
|
gameAccount.LoginTime = gameAccount.CreateTime = TimeHelper.Now;
|
|
|
|
if (isSaveDataBase)
|
|
{
|
|
await gameAccount.SaveDataBase();
|
|
}
|
|
|
|
return gameAccount;
|
|
}
|
|
} |