using System; namespace ET { [FriendClass(typeof (Building))] public class M2C_BuildingDurableHandler: AMActorLocationRpcHandler { protected async override ETTask Run(Unit unit, C2M_BuildingDurable request, M2C_BuildingDurable response, Action reply) { try { var bc = unit.GetComponent(); if (bc == null || bc.Children == null) { reply(); return; } if (request.BuildingId > 0) { Building building = bc.GetChild(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; } } }