新定义

This commit is contained in:
bob
2025-07-30 20:35:38 +08:00
parent e612d8fe38
commit 6b113cf32b
18 changed files with 646 additions and 94 deletions

View File

@@ -17,7 +17,7 @@ public class G2Game_EnterRequestHandler : RouteRPC<Scene, G2Game_EnterRequest, G
Log.Debug("收到 G2Game_EnterRequestHandler");
var accountId = request.AccountId;
// 在缓存中检查该账号是否存在
var gameAccountManageComponent = scene.GetComponent<PlayerManageComponent>();
Log.Debug("检查账号是否在缓存中");
@@ -32,16 +32,30 @@ public class G2Game_EnterRequestHandler : RouteRPC<Scene, G2Game_EnterRequest, G
// 如果没有,就要创建一个新的并且保存到数据库。
// 如果不存在,表示这是一个新的账号,需要创建一下这个账号。
account = await PlayerFactory.Create(scene, accountId);
// account.
account.Basic.Level = 99;
account.Basic.NickName = "王麻子";
account.Basic.Country = "cn";
account.Basic.Exp = 999;
account.Basic.Head = "xxx.png";
for (int i = 0; i < 500; i++)
{
var item = Entity.Create<Item>(scene, true, true);
account.Items.Add(item.Id, item);
}
for (int i = 0; i < 500; i++)
{
var item = Entity.Create<Fish>(scene, true, true);
account.Fishes.Add(item.Id, item);
}
// account.Items
account.NeedSave = true;
await account.SaveDataBase();
}
else
{
@@ -68,11 +82,11 @@ public class G2Game_EnterRequestHandler : RouteRPC<Scene, G2Game_EnterRequest, G
return;
}
}
account.LoginTime = TimeHelper.Now;
response.RoleRouteId = account.RuntimeId;
await FTask.CompletedTask;
}
}

View File

@@ -19,8 +19,7 @@ public static class PlayerFactory
{
var gameAccount = Entity.Create<Player>(scene, aId, false, false);
gameAccount.LoginTime = gameAccount.CreateTime = TimeHelper.Now;
var info = gameAccount.AddComponent<PlayerInfo>();
if (isSaveDataBase)
{

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<Nullable>enable</Nullable>
<LangVersion>default</LangVersion>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>