mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
[+] 接入ET8服务端
[+] 接入ET8服务端
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user