Пример #1
0
            /// <summary>
            /// Compares two POIs according to some pre-defined metrics
            /// </summary>
            private int ComparePointOfInterest(PointOfInterest poiA, PointOfInterest poiB)
            {
                // High alert POIs take priority
                bool highAlertA = IsPoiAtHighAlert(poiA);
                bool highAlertB = IsPoiAtHighAlert(poiB);
                int alertComparison = highAlertA.CompareTo(highAlertB);
                if (alertComparison != 0) return alertComparison;

                // Compare POI types
                if (poiA.POIType >= PointOfInterestType.UnknownEntity && poiB.POIType >= PointOfInterestType.UnknownEntity)
                {
                    int poiTypeComparison = poiA.POIType.CompareTo(poiB.POIType);
                    if (poiTypeComparison != 0)
                        return poiTypeComparison;
                }

                // If we get here, POI Type is equal or POI is considered a mostly irrelevant point

                // If both POIs are grids, return the largest grid size
                if (poiA.IsGrid() && poiB.IsGrid())
                {
                    MyCubeBlock blockA = poiA.Entity as MyCubeBlock;
                    MyCubeBlock blockB = poiB.Entity as MyCubeBlock;

                    if (blockA != null && blockB != null)
                    {
                        int gridSizeComparison = blockA.CubeGrid.BlocksCount.CompareTo(blockB.CubeGrid.BlocksCount);
                        if (gridSizeComparison != 0)
                            return gridSizeComparison;
                    }
                }

                // Closer by is more important than further away
                return poiB.Distance.CompareTo(poiA.Distance);
            }