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.
 
 
 
 
 
 

52 lines
1.6 KiB

using System;
namespace ET
{
public class C2M_CabinAddFarmlandHandler: AMActorLocationRpcHandler<Unit, C2M_CabinAddFarmland, M2C_CabinAddFarmland>
{
protected async override ETTask Run(Unit unit, C2M_CabinAddFarmland request, M2C_CabinAddFarmland response, Action reply)
{
try
{
var farmland = unit.GetGrandChild<Farmland>(request.FarmlandId);
if (farmland == null)
{
response.Error = ErrorCode.ERR_FarmlandNotFound;
}
else
{
var cabin = unit.GetGrandChild<Cabin>(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;
}
}
}