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.
34 lines
1.0 KiB
34 lines
1.0 KiB
3 years ago
|
using System;
|
||
|
|
||
|
namespace ET.Handler
|
||
|
{
|
||
|
public class C2M_CreateResourceHandler : AMActorLocationRpcHandler<Unit, C2M_CreateResource, M2C_CreateResource>
|
||
|
{
|
||
|
protected override async ETTask Run(Unit unit, C2M_CreateResource request, M2C_CreateResource response, Action reply)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
var resource = ResourceOperate.CreateResource(unit, request.ResourceConfigId, request.X, request.Y);
|
||
|
if (resource != null)
|
||
|
{
|
||
|
response.ResourceId = resource.Id;
|
||
|
response.Error = ErrorCode.ERR_Success;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
response.Error = ErrorCode.ERR_AddResourceError;
|
||
|
}
|
||
|
|
||
|
reply();
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
response.Message = e.ToString();
|
||
|
response.Error = ErrorCode.ERR_AddResourceError;
|
||
|
reply();
|
||
|
}
|
||
|
|
||
|
await ETTask.CompletedTask;
|
||
|
}
|
||
|
}
|
||
|
}
|