59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
|
using System.Diagnostics.CodeAnalysis;
|
|||
|
using ProjectElectroTrans.Entities;
|
|||
|
|
|||
|
namespace ProjectElectroTrans.Drawnings;
|
|||
|
|
|||
|
public class DrawingTransEquitables : IEqualityComparer<DrawingTrans?>
|
|||
|
{
|
|||
|
public bool Equals(DrawingTrans? x, DrawingTrans? y)
|
|||
|
{
|
|||
|
if (ReferenceEquals(x, null)) return false;
|
|||
|
if (ReferenceEquals(y, null)) return false;
|
|||
|
if (x.GetType() != y.GetType()) return false;
|
|||
|
|
|||
|
if (x.GetType().Name != y.GetType().Name)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
if (x.EntityTrans != null && y.EntityTrans != null && x.EntityTrans.Speed != y.EntityTrans.Speed)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
if (x.EntityTrans.Weight != y.EntityTrans.Weight)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
if (x.EntityTrans.BodyColor != y.EntityTrans.BodyColor)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x is DrawingElectroTrans && y is DrawingElectroTrans)
|
|||
|
{
|
|||
|
if (((EntityElectroTrans)x.EntityTrans).AdditionalColor !=
|
|||
|
((EntityElectroTrans)y.EntityTrans).AdditionalColor)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (((EntityElectroTrans)x.EntityTrans).Battery!=
|
|||
|
((EntityElectroTrans)y.EntityTrans).Battery)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (((EntityElectroTrans)x.EntityTrans).Horns!=
|
|||
|
((EntityElectroTrans)y.EntityTrans).Horns)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public int GetHashCode([DisallowNull] DrawingTrans obj)
|
|||
|
{
|
|||
|
return obj.GetHashCode();
|
|||
|
}
|
|||
|
}
|