You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.7 KiB
53 lines
1.7 KiB
3 years ago
|
using System;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
[FriendClass(typeof (Farmland))]
|
||
|
[FriendClass(typeof (Cabin))]
|
||
|
public class C2M_CabinSeedHandler: AMActorLocationRpcHandler<Unit, C2M_CabinSeed, M2C_CabinSeed>
|
||
|
{
|
||
|
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<Farmland>(request.FarmlandId);
|
||
|
if (GameUtil.IsErrorSuc(res.Error) && farmland == null)
|
||
|
{
|
||
|
res.Error = ErrorCode.ERR_PeopleNotFound;
|
||
|
}
|
||
|
|
||
|
var cabin = unit.GetGrandChild<Cabin>(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;
|
||
|
}
|
||
|
}
|
||
|
}
|