This commit is contained in:
Кашин Максим 2022-11-29 11:11:20 +04:00
parent d78e351907
commit d628bda63b
2 changed files with 28 additions and 1 deletions

View File

@ -38,5 +38,32 @@ namespace GasolineTanker
} }
public string GetInfo() => _gasolineTanker?.GetDataForSave(); public string GetInfo() => _gasolineTanker?.GetDataForSave();
public static IDrawingObject Create(string data) => new DrawingObjectGasolineTanker(data.CreateDrawingGasolineTanker()); public static IDrawingObject Create(string data) => new DrawingObjectGasolineTanker(data.CreateDrawingGasolineTanker());
public bool Equals(IDrawingObject? other)
{
if (other is not DrawingObjectGasolineTanker otherGasolineTanker)
{
return false;
}
var entity = ;
var otherEntity = otherGasolineTanker.;
if (entity.GetType() != otherEntity.GetType() ||
entity.Speed != otherEntity.Speed ||
entity.Weight != otherEntity.Weight ||
entity.BodyColor != otherEntity.BodyColor)
{
return false;
}
if (entity is EntityImprovedGasolineTanker entityImprovedGasolineTanker &&
otherEntity is EntityImprovedGasolineTanker otherEntityWarmlyShip && (
entityImprovedGasolineTanker.BodyColor != otherEntityWarmlyShip.BodyColor ||
entityImprovedGasolineTanker.DopColor != otherEntityWarmlyShip.DopColor ||
entityImprovedGasolineTanker.BodyKit != otherEntityWarmlyShip.BodyKit))
{
return false;
}
return true;
}
} }
} }
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace GasolineTanker namespace GasolineTanker
{ {
internal interface IDrawingObject internal interface IDrawingObject : IEquatable<IDrawingObject>
{ {
public float Step { get; } public float Step { get; }
void SetObject(int x, int y, int width, int height); void SetObject(int x, int y, int width, int height);