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

using System.IO;
using System.Xml.Linq;
using NodeCanvas.Framework;
using UnityEngine;
using Application = UnityEngine.Application;

namespace BansheeGz.BGDatabase
{
    public abstract class BGNCSaveLoadA : ActionTask
    {
        public const string FileExt = "sav";
        public BBParameter<string> fileName;
        public BBParameter<bool> useArray;
        public BBParameter<byte[]> array;
        public BBParameter<bool> debug;

        protected string FilePath => Path.ChangeExtension(Path.Combine(Application.persistentDataPath, fileName.value), FileExt);

        protected override void OnExecute()
        {
            if (useArray.value) ArrayAction();
            else FileAction();
            EndAction(true);
        }

        protected abstract void FileAction();

        protected abstract void ArrayAction();

        protected void Log(string message)
        {
            if (!debug.value) return;
            Debug.Log(message);
        }
    }
}