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.
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
List<long> sucList = new List<long>();
|
|
|
|
var cabin = unit.GetGrandChild<Cabin>(request.CabinId);
|
|
|
|
if (cabin != null)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < request.FarmlandIds.Count; i++)
|
|
|
|
{
|
|
|
|
var farmland = unit.GetGrandChild<Farmland>(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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|