64 lines
1.6 KiB
C#

using ProjectLinkor.Entities;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLinkor.Drawnings;
public class DrawingShipEqutables : IEqualityComparer<DrawingShip?>
{
public bool Equals(DrawingShip? x, DrawingShip? y)
{
if (x == null || x.EntityShip == null)
{
return false;
}
if (y == null || y.EntityShip == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityShip.Speed != y.EntityShip.Speed)
{
return false;
}
if (x.EntityShip.Weight != y.EntityShip.Weight)
{
return false;
}
if (x.EntityShip.BodyColor != y.EntityShip.BodyColor)
{
return false;
}
if (x is DrawingLinkor && y is DrawingLinkor)
{
// TODO доделать логику сравнения дополнительных параметров
EntityLinkor entityX = (EntityLinkor)x.EntityShip;
EntityLinkor entityY = (EntityLinkor)y.EntityShip;
if (entityX.Rocket != entityY.Rocket)
{
return false;
}
if (entityX.Gun != entityY.Gun)
{
return false;
}
if (entityX.AdditionalColor != entityY.AdditionalColor)
{
return false;
}
}
return true;
}
public int GetHashCode([DisallowNull] DrawingShip? obj)
{
return obj.GetHashCode();
}
}