void HandleUnlinkRequest(Improbable.Entity.Component.ResponseHandle <Controller.Commands.UnlinkDrone, UnlinkRequest, UnlinkResponse> handle) { DeliveryInfo droneInfo; if (deliveriesMap.TryGetValue(handle.Request.droneId, out droneInfo)) { DestroyDrone(handle.Request.droneId, droneInfo.slot); DroneRetrieval(handle.Request.location.ToUnityVector()); if (droneInfo.returning) { MetricsWriter.Send(new ControllerMetrics.Update() .SetFailedReturns(++failedReturns) .SetCosts(costs) .SetPenalties(penalties)); } else { penalties += SimulationSettings.FailedDeliveryPenalty; MetricsWriter.Send(new ControllerMetrics.Update() .SetFailedDeliveries(++failedDeliveries) .SetCosts(costs) .SetPenalties(penalties)); } UpdateDroneSlotsAndMap(); } else { MetricsWriter.Send(new ControllerMetrics.Update().SetUnknownRequests(++unknownRequests)); } handle.Respond(new UnlinkResponse()); }
private GridType getGridCell(int x, int z) { GridType gridCell; int index = z * GridWidth + x; if (Grid.TryGetValue(index, out gridCell)) { return(gridCell); } return(GridType.OUT); }