﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HutongGames.PlayMaker.Actions;
using HutongGames.PlayMaker;
using Tooltip = HutongGames.PlayMaker.TooltipAttribute;

namespace Bayat.SaveSystem.PlayMaker
{

    [ActionCategory(SaveSystemAction.ActionCategoryName)]
    [Tooltip("Deletes the storage item.")]
    public class SaveSystemDeleteAction : SaveSystemSettingsAction
    {

        [Tooltip("The unique identifier for the storage item.")]
        public FsmString identifier;

        public override void OnReset()
        {
            this.identifier = "hello-world";
        }

        public override void Enter()
        {
            if (this.settingsPreset)
            {
                SaveSystemAPI.DeleteAsync(this.identifier.Value, this.settingsPreset.CustomSettings).ContinueWith(HandleTask);
            }
            else
            {

                SaveSystemAPI.DeleteAsync(this.identifier.Value).ContinueWith(HandleTask);
            }
        }

    }

}