﻿using System.IO;
using Unity.VisualScripting;

namespace BansheeGz.BGDatabase
{
    [UnitCategory("BansheeGz")]
    public partial class LoadGame : SaveLoadWithNameA
    {
        protected override ControlOutput Enter(Flow flow)
        {
            var fullFileName = FullFileName(flow);
            if (File.Exists(fullFileName))
            {
                var data = File.ReadAllBytes(fullFileName);
                if (data.Length > 0)
                {
                    BGRepo.I.Addons.Get<BGAddonSaveLoad>().Load(data);
                    Log(flow,"Loaded OK. File at: $", fullFileName);
                }
                else Log(flow,"Can not load: file at: $ has no data", fullFileName);
            }
            else Log(flow,"Can not load: file is not found: $", fullFileName);

            return _out;
        }
    }
}