32 lines
1.2 KiB
C#
Raw Normal View History

2023-11-03 21:51:37 +04:00
using WarmlyLocomotive.DrawningObjects;
2023-10-31 15:28:54 +04:00
namespace WarmlyLocomotive.MovementStrategy
{
internal class DrawningObjectCar : IMoveableObject
{
2023-11-03 21:51:37 +04:00
private readonly DrawningWarmlyLocomotive? _drawningWarmlyLocomotive = null;
2023-10-31 15:28:54 +04:00
public DrawningObjectCar(DrawningWarmlyLocomotive drawningCar)
{
2023-11-03 21:51:37 +04:00
_drawningWarmlyLocomotive = drawningCar;
2023-10-31 15:28:54 +04:00
}
public ObjectParameters? GetObjectPosition
{
get
{
2023-11-03 21:51:37 +04:00
if (_drawningWarmlyLocomotive == null || _drawningWarmlyLocomotive.EntityWarmlyLocomotive ==
2023-10-31 15:28:54 +04:00
null)
{
return null;
}
2023-11-03 21:51:37 +04:00
return new ObjectParameters(_drawningWarmlyLocomotive.GetPosX,
_drawningWarmlyLocomotive.GetPosY, _drawningWarmlyLocomotive.GetWidth, _drawningWarmlyLocomotive.GetHeight);
2023-10-31 15:28:54 +04:00
}
}
2023-11-03 21:51:37 +04:00
public int GetStep => (int)(_drawningWarmlyLocomotive?.EntityWarmlyLocomotive?.Step ?? 0);
2023-10-31 15:28:54 +04:00
public bool CheckCanMove(Direction direction) =>
2023-11-03 21:51:37 +04:00
_drawningWarmlyLocomotive?.CanMove(direction) ?? false;
2023-10-31 15:28:54 +04:00
public void MoveObject(Direction direction) =>
2023-11-03 21:51:37 +04:00
_drawningWarmlyLocomotive?.MoveTransport(direction);
2023-10-31 15:28:54 +04:00
}
}