using System.IO;
using HutongGames.PlayMaker;
using UnityEngine;

namespace BansheeGz.BGDatabase
{
    [ActionCategory("BansheeGz")]
    public class BGLoadGameWebGl : BGSaveGameWebGl
    {
        public override void OnEnter()
        {
            var fullFileName = FilePath;
            if(debug.Value) Debug.Log("BGLoadGameWebGl: Trying to load from : " + fullFileName);
            if (!File.Exists(fullFileName))
            {
                if(debug.Value) Debug.Log("BGLoadGameWebGl: File does not exist: " + fullFileName);
                return;
            }
            BGRepo.I.Addons.Get<BGAddonSaveLoad>().Load(File.ReadAllBytes(fullFileName));
            if(debug.Value) Debug.Log("BGLoadGameWebGl: Loaded ok-  " + fullFileName);
            Finish();
        }
    }
}