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.
44 lines
1.4 KiB
44 lines
1.4 KiB
3 years ago
|
using System;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
|
||
|
[FriendClass(typeof(Unit))]
|
||
|
public class C2M_GoFarmlandHarvestHandler: AMActorLocationRpcHandler<Unit, C2M_GoFarmlandHarvest, M2C_GoFarmlandHarvest>
|
||
|
{
|
||
|
|
||
|
protected override async ETTask Run(Unit unit, C2M_GoFarmlandHarvest request, M2C_GoFarmlandHarvest response, Action reply)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
var people = unit.GetComponent<PeopleComponent>().GetChild<People>(request.PeopleId);
|
||
|
if (people == null)
|
||
|
{
|
||
|
response.Error = ErrorCode.ERR_PeopleNotFound;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Farmland farmland;
|
||
|
if (unit.FarmlandDic.TryGetValue(request.FarmlandId, out farmland))
|
||
|
{
|
||
|
response.Error=FarmlandOperate.GoHarvest(unit,farmland, people);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
response.Error = ErrorCode.ERR_FarmlandNotFound;
|
||
|
}
|
||
|
}
|
||
|
reply();
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
response.Message = e.ToString();
|
||
|
response.Error = ErrorCode.ERR_OperateFail;
|
||
|
reply();
|
||
|
throw;
|
||
|
}
|
||
|
|
||
|
await ETTask.CompletedTask;
|
||
|
}
|
||
|
}
|
||
|
}
|