PIBD-14_Khalikova.A.R_Storm.../ProjectStormtrooper/Drawnings/DrawinigStormtrooperBaseEqutables.cs

65 lines
1.8 KiB
C#
Raw Normal View History

using ProjectStormtrooper.Entities;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectStormtrooper.Drawnings;
public class DrawinigStormtrooperBaseEqutables: IEqualityComparer<DrawningStormtrooperBase>
{
public bool Equals(DrawningStormtrooperBase? x, DrawningStormtrooperBase? y)
{
if (x == null || x.EntityStormtrooperBase == null)
{
return false;
}
if(y==null || y.EntityStormtrooperBase == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityStormtrooperBase.Speed!= y.EntityStormtrooperBase.Speed)
{
return false;
}
if (x.EntityStormtrooperBase.Weight != y.EntityStormtrooperBase.Weight)
{
return false;
}
if (x.EntityStormtrooperBase.BodyColor != y.EntityStormtrooperBase.BodyColor)
{
return false;
}
if (x is DrawingStormtrooper && y is DrawingStormtrooper)
{
EntityStormtrooper _x = (EntityStormtrooper)x.EntityStormtrooperBase;
EntityStormtrooper _y = (EntityStormtrooper)x.EntityStormtrooperBase;
if (_x.AdditionalColor != _y.AdditionalColor)
{
return false;
}
if (_x.Bombs != _y.Bombs)
{
return false;
}
if (_x.Rockets != _y.Rockets)
{
return false;
}
}
return true;
}
public int GetHashCode([DisallowNull] DrawningStormtrooperBase obj)
{
return obj.GetHashCode();
}
}