67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using AntiAircraftGun.Entities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AntiAircraftGun.Drawnings;
|
|
|
|
public class DrawningArmoredCarEqutables : IEqualityComparer<DrawningArmoredCar?>
|
|
{
|
|
public bool Equals(DrawningArmoredCar? x, DrawningArmoredCar? 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.EntityAircraftGun != null && y.EntityAircraftGun != null && x.EntityAircraftGun.Speed != y.EntityAircraftGun.Speed)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (x.EntityAircraftGun.Weight != y.EntityAircraftGun.Weight)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (x.EntityAircraftGun.BodyColor != y.EntityAircraftGun.BodyColor)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (x is DrawningAntiAircraftGun && y is DrawningAntiAircraftGun)
|
|
{
|
|
if (((EntityAntiAircraftGun)x.EntityAircraftGun).AdditionalColor !=
|
|
((EntityAntiAircraftGun)y.EntityAircraftGun).AdditionalColor)
|
|
{
|
|
return false;
|
|
}
|
|
if (((EntityAntiAircraftGun)x.EntityAircraftGun).Tower !=
|
|
((EntityAntiAircraftGun)y.EntityAircraftGun).Tower)
|
|
{
|
|
return false;
|
|
}
|
|
if (((EntityAntiAircraftGun)x.EntityAircraftGun).Radar !=
|
|
((EntityAntiAircraftGun)y.EntityAircraftGun).Radar)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public int GetHashCode([DisallowNull] DrawningArmoredCar obj)
|
|
{
|
|
return obj.GetHashCode();
|
|
|
|
}
|
|
}
|