2023-11-03 21:51:37 +04:00
|
|
|
|
using WarmlyLocomotive.DrawningObjects;
|
2023-10-31 15:28:54 +04:00
|
|
|
|
|
|
|
|
|
namespace WarmlyLocomotive.MovementStrategy
|
|
|
|
|
{
|
2023-11-11 21:26:13 +04:00
|
|
|
|
internal class DrawningObjectWarmlyLocomotive : IMoveableObject
|
2023-10-31 15:28:54 +04:00
|
|
|
|
{
|
2023-11-03 21:51:37 +04:00
|
|
|
|
private readonly DrawningWarmlyLocomotive? _drawningWarmlyLocomotive = null;
|
2023-11-11 21:26:13 +04:00
|
|
|
|
public DrawningObjectWarmlyLocomotive(DrawningWarmlyLocomotive drawningWarmlylocomotive)
|
2023-10-31 15:28:54 +04:00
|
|
|
|
{
|
2023-11-11 21:26:13 +04:00
|
|
|
|
_drawningWarmlyLocomotive = drawningWarmlylocomotive;
|
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
|
|
|
|
}
|
|
|
|
|
}
|