using System; namespace ET { [FriendClass(typeof (Unit))] public class C2M_GoFarmlandPlantHandler: AMActorLocationRpcHandler { protected override async ETTask Run(Unit unit, C2M_GoFarmlandPlant request, M2C_GoFarmlandPlant response, Action reply) { try { var people = unit.GetComponent().GetChild(request.PeopleId); if (people == null) { response.Error = ErrorCode.ERR_PeopleNotFound; } else { Farmland farmland; if (unit.FarmlandDic.TryGetValue(request.FarmlandId, out farmland)) { response.Error = FarmlandOperate.GoPlant(unit, farmland, people); } else { response.Error = ErrorCode.ERR_FarmlandNotFound; } } reply(); } catch (Exception e) { response.Message = e.ToString(); response.Error = ErrorCode.ERR_OperateFail; reply(); throw; } await ETTask.CompletedTask; } } }