32 lines
819 B
C#
32 lines
819 B
C#
namespace ProjectCruiser.DrawningSamples;
|
|
|
|
// Сравнение по типу, скорости, весу
|
|
public class DrawningShipCompare : IComparer<DrawningBase?>
|
|
{
|
|
public int Compare(DrawningBase? x, DrawningBase? y)
|
|
{
|
|
if (x == null || x.EntityTransport == null)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
if (y == null || y.EntityTransport == null)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|