You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
3 years ago
|
using System;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
[ActorMessageHandler]
|
||
|
public class M2M_UnitTransferRequestHandler : AMActorRpcHandler<Scene, M2M_UnitTransferRequest, M2M_UnitTransferResponse>
|
||
|
{
|
||
|
protected override async ETTask Run(Scene scene, M2M_UnitTransferRequest request, M2M_UnitTransferResponse response, Action reply)
|
||
|
{
|
||
|
await ETTask.CompletedTask;
|
||
|
UnitComponent unitComponent = scene.GetComponent<UnitComponent>();
|
||
|
Unit unit = request.Unit;
|
||
|
|
||
|
unitComponent.AddChild(unit);
|
||
|
|
||
|
unit.AddComponent<UnitDBSaveComponent>();
|
||
|
|
||
|
foreach (Entity entity in request.Entitys)
|
||
|
{
|
||
|
unit.AddComponent(entity);
|
||
|
}
|
||
|
unit.Init();
|
||
|
|
||
|
// unit.AddComponent<MoveComponent>();
|
||
|
// unit.AddComponent<PathfindingComponent, string>(scene.Name);
|
||
|
// unit.Position = new Vector3(-10, 0, -10);
|
||
|
|
||
|
unit.AddComponent<MailBoxComponent>();
|
||
|
|
||
|
// 通知客户端创建My Unit
|
||
|
M2C_CreateMyUnit m2CCreateUnits = new M2C_CreateMyUnit();
|
||
|
m2CCreateUnits.Unit = UnitHelper.CreateUnitProto(unit);
|
||
|
m2CCreateUnits.SceneName = request.SceneName;
|
||
|
m2CCreateUnits.SceneInstanceId = request.SceneInstanceId;
|
||
|
MessageHelper.SendToClient(unit, m2CCreateUnits);
|
||
|
|
||
|
// 加入aoi
|
||
|
// unit.AddComponent<AOIEntity, int, Vector3>(9 * 1000, unit.Position);
|
||
|
|
||
|
response.NewInstanceId = unit.InstanceId;
|
||
|
|
||
|
reply();
|
||
|
}
|
||
|
}
|
||
|
}
|