88 lines
3.0 KiB
C#
88 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace WarmlyLocomotive
|
|
{
|
|
internal class DrawningObjectLocomotive : IDrawningObject
|
|
{
|
|
private DrawningLocomotive _locomotive = null;
|
|
public float Step => _locomotive?.Locomotive?.Step ?? 0;
|
|
public DrawningLocomotive GetLocomotive => _locomotive;
|
|
public DrawningObjectLocomotive(DrawningLocomotive locomotive)
|
|
{
|
|
_locomotive = locomotive;
|
|
}
|
|
public void DrawningObject(Graphics g)
|
|
{
|
|
_locomotive?.DrawTransport(g);
|
|
}
|
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
|
{
|
|
return _locomotive?.GetCurrentPosition() ?? default;
|
|
}
|
|
public void MoveObject(Direction direction)
|
|
{
|
|
_locomotive?.MoveTransport(direction);
|
|
}
|
|
public void SetObject(int x, int y, int width, int height)
|
|
{
|
|
_locomotive.SetPosition(x, y, width, height);
|
|
}
|
|
public string GetInfo() => _locomotive?.GetDataForSave();
|
|
public static IDrawningObject Create(string data) => new DrawningObjectLocomotive(data.CreateDrawningLocomotive());
|
|
public bool Equals(IDrawningObject? other)
|
|
{
|
|
if (other == null)
|
|
{
|
|
return false;
|
|
}
|
|
var otherLocomotive = other as DrawningObjectLocomotive;
|
|
if (otherLocomotive == null)
|
|
{
|
|
return false;
|
|
}
|
|
var locomotive = _locomotive.Locomotive;
|
|
var otherLocomotiveLocomotive = otherLocomotive._locomotive.Locomotive;
|
|
if (locomotive.Speed != otherLocomotiveLocomotive.Speed)
|
|
{
|
|
return false;
|
|
}
|
|
if (locomotive.Weight != otherLocomotiveLocomotive.Weight)
|
|
{
|
|
return false;
|
|
}
|
|
if (locomotive.BodyColor != otherLocomotiveLocomotive.BodyColor)
|
|
{
|
|
return false;
|
|
}
|
|
if(locomotive is EntityWarmlyLocomotive warmlyLocomotive && otherLocomotiveLocomotive is EntityWarmlyLocomotive otherWarmlyLocomotive)
|
|
{
|
|
if(warmlyLocomotive.Pipe != otherWarmlyLocomotive.Pipe)
|
|
{
|
|
return false;
|
|
}
|
|
if (warmlyLocomotive.FuelCompartment != otherWarmlyLocomotive.FuelCompartment)
|
|
{
|
|
return false;
|
|
}
|
|
if (warmlyLocomotive.WarmlyLines != otherWarmlyLocomotive.WarmlyLines)
|
|
{
|
|
return false;
|
|
}
|
|
if (warmlyLocomotive.DopColor != otherWarmlyLocomotive.DopColor)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else if(locomotive is EntityWarmlyLocomotive || otherLocomotiveLocomotive is EntityWarmlyLocomotive)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|