2024-06-16 21:39:45 +04:00
|
|
|
|
namespace ProjectCruiser.DrawningSamples;
|
|
|
|
|
|
|
|
|
|
// Сравнение по типу, скорости, весу
|
|
|
|
|
public class DrawningShipCompare : IComparer<DrawningBase?>
|
|
|
|
|
{
|
|
|
|
|
public int Compare(DrawningBase? x, DrawningBase? y)
|
|
|
|
|
{
|
|
|
|
|
if (x == null || x.EntityTransport == null)
|
|
|
|
|
{
|
2024-06-17 09:44:23 +04:00
|
|
|
|
return 1;
|
2024-06-16 21:39:45 +04:00
|
|
|
|
}
|
2024-06-16 23:08:52 +04:00
|
|
|
|
|
2024-06-16 21:39:45 +04:00
|
|
|
|
if (y == null || y.EntityTransport == null)
|
|
|
|
|
{
|
2024-06-17 09:44:23 +04:00
|
|
|
|
return -1;
|
2024-06-16 21:39:45 +04:00
|
|
|
|
}
|
2024-06-16 23:08:52 +04:00
|
|
|
|
|
2024-06-16 21:39:45 +04:00
|
|
|
|
if (x.GetType().Name != y.GetType().Name)
|
|
|
|
|
{
|
|
|
|
|
return x.GetType().Name.CompareTo(y.GetType().Name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var speedCompare = x.EntityTransport.Speed.CompareTo(y.EntityTransport.Speed);
|
|
|
|
|
if (speedCompare != 0)
|
|
|
|
|
{
|
|
|
|
|
return speedCompare;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return x.EntityTransport.Weight.CompareTo(y.EntityTransport.Weight);
|
|
|
|
|
}
|
|
|
|
|
}
|