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.
50 lines
1.6 KiB
50 lines
1.6 KiB
3 years ago
|
using System;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
[FriendClass(typeof (Building))]
|
||
|
public class M2C_BuildingDurableHandler: AMActorLocationRpcHandler<Unit, C2M_BuildingDurable, M2C_BuildingDurable>
|
||
|
{
|
||
|
protected async override ETTask Run(Unit unit, C2M_BuildingDurable request, M2C_BuildingDurable response, Action reply)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
var bc = unit.GetComponent<BuildingComponent>();
|
||
|
if (request.BuildingId > 0)
|
||
|
{
|
||
|
Building building = bc.GetChild<Building>(request.BuildingId);
|
||
|
if (building == null)
|
||
|
{
|
||
|
response.Error = ErrorCode.ERR_NOT_FOUND_BUILD;
|
||
|
}
|
||
|
else
|
||
|
|
||
|
{
|
||
|
response.IdList.Add(building.Id);
|
||
|
response.Vs.Add(building.Durable);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
foreach (var v in bc.Children.Values)
|
||
|
{
|
||
|
response.IdList.Add(v.Id);
|
||
|
response.Vs.Add(((Building) v).Durable);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
response.Error = ErrorCode.ERR_Success;
|
||
|
reply();
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
response.Message = e.ToString();
|
||
|
response.Error = ErrorCode.ERR_BuildError;
|
||
|
reply();
|
||
|
throw;
|
||
|
}
|
||
|
|
||
|
await ETTask.CompletedTask;
|
||
|
}
|
||
|
}
|
||
|
}
|