using System;
using Intrepid.Gameplay.Entities.Player.Sentinel.Events;
using Intrepid.Integration.Persistence.DTOs;

namespace Intrepid.Gameplay.Data.Conversion
{
    public class LatestSaveStationDTOConverter : Marshaler<LatestSaveStationDTO, LatestSaveStationEvent>
    {
        public LatestSaveStationDTO Marshal(LatestSaveStationEvent e)
        {
            if (e is null)
            {
                return null;
            }
            var data = new LatestSaveStationDTO();
            
            if (e.StageTag.IsNull() || string.IsNullOrWhiteSpace(e.StageTag.StageId))
            {
                data.StageId = null;
            }
            else
            {
                data.StageId = e.StageTag.StageId;
            }
            
            data.DeploymentPoint = Converters.Vector3.Marshal(e.DeploymentPoint);

            return data;
        }
    }
}