[+] 接入ET8服务端

[+] 接入ET8服务端
This commit is contained in:
ALEXTANG
2023-07-13 12:23:48 +08:00
parent e0be062006
commit 336d4b2eb9
1316 changed files with 130657 additions and 626 deletions

View File

@@ -0,0 +1,39 @@
using System.Collections.Generic;
using MongoDB.Bson;
namespace ET.Server
{
public static partial class TransferHelper
{
public static async ETTask TransferAtFrameFinish(Unit unit, ActorId sceneInstanceId, string sceneName)
{
await unit.Fiber().WaitFrameFinish();
await TransferHelper.Transfer(unit, sceneInstanceId, sceneName);
}
public static async ETTask Transfer(Unit unit, ActorId sceneInstanceId, string sceneName)
{
Scene root = unit.Root();
// location加锁
long unitId = unit.Id;
M2M_UnitTransferRequest request = M2M_UnitTransferRequest.Create();
request.OldActorId = unit.GetActorId();
request.Unit = unit.ToBson();
foreach (Entity entity in unit.Components.Values)
{
if (entity is ITransfer)
{
request.Entitys.Add(entity.ToBson());
}
}
unit.Dispose();
await root.GetComponent<LocationProxyComponent>().Lock(LocationType.Unit, unitId, request.OldActorId);
await root.GetComponent<ActorSenderComponent>().Call(sceneInstanceId, request);
}
}
}