65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
|
using Cruiser.Entities;
|
|||
|
using Cruiser.Drawing;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Diagnostics.CodeAnalysis;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Cruiser.Generics
|
|||
|
{
|
|||
|
internal class DrawiningCruiserEqutables : IEqualityComparer<DrawingCruiser?>
|
|||
|
{
|
|||
|
public bool Equals(DrawingCruiser? x, DrawingCruiser? y)
|
|||
|
{
|
|||
|
if (x == null || x.EntityCruiser == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(x));
|
|||
|
}
|
|||
|
if (y == null || y.EntityCruiser == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(y));
|
|||
|
}
|
|||
|
if (x.GetType().Name != y.GetType().Name)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityCruiser.Speed != y.EntityCruiser.Speed)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityCruiser.Weight != y.EntityCruiser.Weight)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityCruiser.BodyColor != y.EntityCruiser.BodyColor)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x is DrawingProCruiser && y is DrawingProCruiser)
|
|||
|
{
|
|||
|
EntityProCruiser _cruiserX = (EntityProCruiser)x.EntityCruiser;
|
|||
|
EntityProCruiser _cruiserY = (EntityProCruiser)y.EntityCruiser;
|
|||
|
if (_cruiserX.Helipad != _cruiserY.Helipad)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (_cruiserX.RocketMines != _cruiserY.RocketMines)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (_cruiserX.ElementsColor != _cruiserY.ElementsColor)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
public int GetHashCode([DisallowNull] DrawingCruiser obj)
|
|||
|
{
|
|||
|
return obj.GetHashCode();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|