59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
|
using lab1.Drawnings;
|
|||
|
using lab1.Entities;
|
|||
|
using System.Diagnostics.CodeAnalysis;
|
|||
|
|
|||
|
namespace lab1;
|
|||
|
|
|||
|
public class DrawningTrackedVehicleEqutables : IEqualityComparer<DrawningTrackedVehicle?>
|
|||
|
{
|
|||
|
public bool Equals(DrawningTrackedVehicle? x, DrawningTrackedVehicle? y)
|
|||
|
{
|
|||
|
if (x == null || x.EntityTrackedVehicle == null)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (y == null || y.EntityTrackedVehicle == null)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.GetType().Name != y.GetType().Name)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityTrackedVehicle.Speed != y.EntityTrackedVehicle.Speed)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityTrackedVehicle.Weight != y.EntityTrackedVehicle.Weight)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityTrackedVehicle.BodyColor != y.EntityTrackedVehicle.BodyColor)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x is DrawningEntityFighter && y is DrawningEntityFighter)
|
|||
|
{
|
|||
|
EntityFighter _x = (EntityFighter)x.EntityTrackedVehicle;
|
|||
|
EntityFighter _y = (EntityFighter)x.EntityTrackedVehicle;
|
|||
|
if (_x.AdditionalColor != _y.AdditionalColor)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (_x.Kovsh != _y.Kovsh)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (_x.Otval != _y.Otval)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
public int GetHashCode([DisallowNull] DrawningTrackedVehicle obj)
|
|||
|
{
|
|||
|
return obj.GetHashCode();
|
|||
|
}
|
|||
|
}
|