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.
51 lines
1.6 KiB
51 lines
1.6 KiB
3 years ago
|
using System;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
public class C2M_ArriveCabinHandler: AMActorLocationRpcHandler<Unit, C2M_ArriveCabin, M2C_ArriveCabin>
|
||
|
{
|
||
|
protected async override ETTask Run(Unit unit, C2M_ArriveCabin request, M2C_ArriveCabin response, Action reply)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
|
||
|
var people = unit.GetComponent<PeopleComponent>().GetChild<People>(request.PeopleId);
|
||
|
if (people == null)
|
||
|
{
|
||
|
response.Error = ErrorCode.ERR_PeopleNotFound;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
var cabin = unit.GetGrandChild<Cabin>(request.CabinId);
|
||
|
if (cabin == null)
|
||
|
{
|
||
|
response.Error = ErrorCode.ERR_CabinNotFound;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
if (cabin.PeopleArrive(request.PeopleId))
|
||
|
{
|
||
|
people.SetBehaveType(ConstBehaveType.BEHAVE_CABIN);
|
||
|
response.Error = ErrorCode.ERR_Success;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
response.Error = ErrorCode.ERR_ArriveCabinFail;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
reply();
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
response.Message = e.ToString();
|
||
|
response.Error = ErrorCode.ERR_OperateFail;
|
||
|
reply();
|
||
|
}
|
||
|
|
||
|
await ETTask.CompletedTask;
|
||
|
}
|
||
|
}
|
||
|
}
|