C2G_RemoveUnitHandler.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. namespace ET.Server
  3. {
  4. /// <summary>
  5. /// 移除场景单位
  6. /// </summary>
  7. [MessageHandler(SceneType.Game)]
  8. public class C2G_RemoveUnitHandler: AMRpcHandler<C2G_RemoveUnit, G2C_RemoveUnit>
  9. {
  10. protected override async ETTask Run(Session session, C2G_RemoveUnit request, G2C_RemoveUnit response, Action reply)
  11. {
  12. WNPlayer player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
  13. if (player == null)
  14. {
  15. Log.Debug($"操作错误, player is null");
  16. response.Error = ErrorCode.ERR_OperationError;
  17. reply();
  18. return;
  19. }
  20. // 参数判断
  21. if (request.UnitId <= 0)
  22. {
  23. Log.Debug($"参数错误...unitId={request.UnitId}");
  24. response.Error = ErrorCode.ERR_ParameterError;
  25. reply();
  26. return;
  27. }
  28. await player.Map.RemovePointUnit(request.UnitId);
  29. reply();
  30. }
  31. }
  32. }