using System; namespace ET { [FriendClass(typeof (Unit))] public class C2M_FarmlandHarvestHandler: AMActorLocationRpcHandler { protected override async ETTask Run(Unit unit, C2M_FarmlandHarvest request, M2C_FarmlandHarvest response, Action reply) { try { People people; Farmland farmland = unit.GetGrandChild(request.FarmlandId); if (farmland!=null) { people = unit.GetComponent().GetChild(request.PeopleId); if (people != null) { response.Error = FarmlandOperate.Harvest(unit, farmland, people); } else { response.Error = ErrorCode.ERR_PeopleNotFound; } } else { response.Error = ErrorCode.ERR_FarmlandNotFound; } } catch (Exception e) { response.Message = e.ToString(); response.Error = ErrorCode.ERR_OperateFail; reply(); } await ETTask.CompletedTask; } } }