M2M_TrasferUnitRequest.cs 731 B

1234567891011121314151617181920212223
  1. using System;
  2. using ETModel;
  3. namespace ETHotfix
  4. {
  5. [MessageHandler(AppType.Map)]
  6. public class M2M_TrasferUnitRequestHandler : AMRpcHandler<M2M_TrasferUnitRequest, M2M_TrasferUnitResponse>
  7. {
  8. protected override async ETTask Run(Session session, M2M_TrasferUnitRequest request, M2M_TrasferUnitResponse response, Action reply)
  9. {
  10. Unit unit = request.Unit;
  11. // 将unit加入事件系统
  12. Game.EventSystem.Add(unit);
  13. Log.Debug(MongoHelper.ToJson(request.Unit));
  14. // 这里不需要注册location,因为unlock会更新位置
  15. unit.AddComponent<MailBoxComponent>();
  16. Game.Scene.GetComponent<UnitComponent>().Add(unit);
  17. response.InstanceId = unit.InstanceId;
  18. reply();
  19. await ETTask.CompletedTask;
  20. }
  21. }
  22. }