/*
<copyright file="BGBDLoad.cs" company="BansheeGz">
    Copyright (c) 2018-2021 All Rights Reserved
</copyright>
*/

using System.IO;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;

namespace BansheeGz.BGDatabase
{
    [TaskCategory("BansheeGz/SaveLoad")]
    [TaskName("BGDatabase: Load game")]
    [TaskDescription("Load game using SaveLoad addon. Provide fileName without extension and path, for example MySave")]
    public class BGBDLoad : BGBDSaveLoadA
    {
        protected override void FileAction()
        {
            var filePath = FilePath;
            if (!File.Exists(filePath))
            {
                Log("Unable to load game, cause file " + filePath + " does not exist!");
                return;
            }

            BGRepo.I.Addons.Get<BGAddonSaveLoad>().Load(File.ReadAllBytes(filePath));
            Log("Game is loaded from file " + filePath);
        }
    }
}