57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using ProjectLainer.DrawningObjects;
|
|
using ProjectLainer.Entities;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
namespace ProjectLainer.Generics
|
|
{
|
|
internal class DrawiningLainerEqutables : IEqualityComparer<DrawingEntity?>
|
|
{
|
|
public bool Equals(DrawingEntity? x, DrawingEntity? y)
|
|
{
|
|
if (x == null || x.EntityLainer == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(x));
|
|
}
|
|
if (y == null || y.EntityLainer == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(y));
|
|
}
|
|
if (x.GetType().Name != y.GetType().Name)
|
|
{
|
|
return false;
|
|
}
|
|
if (x.EntityLainer.Speed != y.EntityLainer.Speed)
|
|
{
|
|
return false;
|
|
}
|
|
if (x.EntityLainer.Weight != y.EntityLainer.Weight)
|
|
{
|
|
return false;
|
|
}
|
|
if (x.EntityLainer.BodyColor != y.EntityLainer.BodyColor)
|
|
{
|
|
return false;
|
|
}
|
|
if (x is DrawningSuperLainer && y is DrawningSuperLainer)
|
|
{
|
|
EntitySuperLainer entityX = (EntitySuperLainer)x.EntityLainer;
|
|
EntitySuperLainer entityY = (EntitySuperLainer)y.EntityLainer;
|
|
if(entityX.Pools != entityY.Pools)
|
|
{
|
|
return false;
|
|
}
|
|
if(entityX.Decks != entityY.Decks)
|
|
{
|
|
return false;
|
|
}
|
|
if(entityX.AdditionalColor != entityY.AdditionalColor) { return false; }
|
|
}
|
|
return true;
|
|
}
|
|
public int GetHashCode([DisallowNull] DrawingEntity obj)
|
|
{
|
|
return obj.GetHashCode();
|
|
}
|
|
}
|
|
}
|
|
|