using System; namespace ET { public class C2M_CabinAddFarmlandHandler: AMActorLocationRpcHandler { protected async override ETTask Run(Unit unit, C2M_CabinAddFarmland request, M2C_CabinAddFarmland response, Action reply) { try { var farmland = unit.GetGrandChild(request.FarmlandId); if (farmland == null) { response.Error = ErrorCode.ERR_FarmlandNotFound; } else { var cabin = unit.GetGrandChild(request.CabinId); if (cabin == null) { response.Error = ErrorCode.ERR_CabinNotFound; } else { if (cabin.AddFarmland(request.FarmlandId)) { farmland.SetCabinId(request.CabinId); response.Error = ErrorCode.ERR_Success; } else { response.Error = ErrorCode.ERR_OperateFail; } } } reply(); } catch (Exception e) { response.Message = e.ToString(); response.Error = ErrorCode.ERR_OperateFail; reply(); } await ETTask.CompletedTask; } } }