using System; using System.Collections.Generic; namespace ET { public class C2M_CabinAddFarmlandHandler: AMActorLocationRpcHandler { protected async override ETTask Run(Unit unit, C2M_CabinAddFarmland request, M2C_CabinAddFarmland response, Action reply) { try { List sucList = new List(); var cabin = unit.GetGrandChild(request.CabinId); if (cabin != null) { for (int i = 0; i < request.FarmlandIds.Count; i++) { var farmland = unit.GetGrandChild(request.FarmlandIds[i]); if (farmland != null) { if (cabin.AddFarmland(request.FarmlandIds[i])) { farmland.SetCabinId(request.CabinId); response.FarmlandIds.Add(request.FarmlandIds[i]); } } } } reply(); } catch (Exception e) { response.Message = e.ToString(); response.Error = ErrorCode.ERR_OperateFail; reply(); } await ETTask.CompletedTask; } } }