using System; namespace ET { [FriendClass(typeof (Farmland))] [FriendClass(typeof (Cabin))] public class C2M_CabinSeedHandler: AMActorLocationRpcHandler { protected async override ETTask Run(Unit unit, C2M_CabinSeed request, M2C_CabinSeed res, Action reply) { try { res.Error = ErrorCode.ERR_Success; var farmland = unit.GetGrandChild(request.FarmlandId); if (GameUtil.IsErrorSuc(res.Error) && farmland == null) { res.Error = ErrorCode.ERR_PeopleNotFound; } var cabin = unit.GetGrandChild(farmland.CabinId); if (GameUtil.IsErrorSuc(res.Error) && cabin == null) { res.Error = ErrorCode.ERR_CabinNotFound; } if (GameUtil.IsErrorSuc(res.Error) && cabin.ResidentState == 0) { res.Error = ErrorCode.ERR_CabinNotPeople; } if (GameUtil.IsErrorSuc(res.Error) && farmland.FarmlandState != FarmlandState.FARMLAND_STATE_FREE) { res.Error = ErrorCode.ERR_FarmlandNotFree; } if (GameUtil.IsErrorSuc(res.Error)) { res.Error = FarmlandOperate.FarmlandSeed(unit, farmland, request.CropCfgId); } reply(); } catch (Exception e) { res.Message = e.ToString(); res.Error = ErrorCode.ERR_OperateFail; reply(); } await ETTask.CompletedTask; } } }