using System.Diagnostics.CodeAnalysis; using ProjectCruiser.Entities; namespace ProjectCruiser.DrawningSamples; // Реализация сравнения двух объектов класса-прорисовки public class DrawiningShipEqutables : IEqualityComparer { public bool Equals(DrawningBase? x, DrawningBase? y) { if (x == null || x.EntityTransport == null) return false; if (y == null || y.EntityTransport == null) return false; if (x.GetType().Name != y.GetType().Name) return false; if (x.EntityTransport.Speed != y.EntityTransport.Speed) return false; if (x.EntityTransport.Weight != y.EntityTransport.Weight) return false; if (x.EntityTransport.MainColor != y.EntityTransport.MainColor) return false; if (x is DrawningCruiser && y is DrawningCruiser) { /* public Color AdditionalColor { get; private set; } // доп. цвет // признаки (наличия) public bool HelicopterPads { get; private set; } // вертолетная площадка public bool Hangars { get; private set; } // ангар */ EntityCruiser EntityX = (EntityCruiser)x.EntityTransport; EntityCruiser EntityY = (EntityCruiser)y.EntityTransport; if (EntityX.AdditionalColor != EntityY.AdditionalColor) return false; if (EntityX.Hangars != EntityY.Hangars) return false; if (EntityX.HelicopterPads != EntityY.HelicopterPads) return false; } return true; } public int GetHashCode([DisallowNull] DrawningBase obj) { return obj.GetHashCode(); } }