60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using AirBomber.DrawningObjects;
|
|
using AirBomber.Entities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AirBomber
|
|
{
|
|
internal class DrawningBomberEqutables : IEqualityComparer<DrawningBomber?>
|
|
{
|
|
public bool Equals(DrawningBomber? x, DrawningBomber? y)
|
|
{
|
|
if (x == null || x.EntityBomber == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(x));
|
|
}
|
|
if (y == null || y.EntityBomber == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(y));
|
|
}
|
|
if (x.GetType().Name != y.GetType().Name)
|
|
{
|
|
return false;
|
|
}
|
|
if (x.EntityBomber.Speed != y.EntityBomber.Speed)
|
|
{
|
|
return false;
|
|
}
|
|
if (x.EntityBomber.Weight != y.EntityBomber.Weight)
|
|
{
|
|
return false;
|
|
}
|
|
if (x.EntityBomber.BodyColor != y.EntityBomber.BodyColor)
|
|
{
|
|
return false;
|
|
}
|
|
if (x is EntityAirBomber && y is EntityAirBomber)
|
|
{
|
|
EntityAirBomber EntityX = (EntityAirBomber)x.EntityBomber;
|
|
EntityAirBomber EntityY = (EntityAirBomber)y.EntityBomber;
|
|
if (EntityX.DopColor != EntityY.DopColor)
|
|
return false;
|
|
if (EntityX.Toplivo != EntityY.Toplivo)
|
|
return false;
|
|
if (EntityX.Rocket != EntityY.Rocket)
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public int GetHashCode([DisallowNull] DrawningBomber obj)
|
|
{
|
|
return obj.GetHashCode();
|
|
}
|
|
}
|
|
}
|