using Bolt;
using Ludiq;
using UnityEngine;

namespace InfinityCode.OnlineMapsBolt
{
    [UnitTitle("Reset WWW Events")]
    public class ResetWWWEvents : OnlineMapsBoltEventBase
    {
        [DoNotSerialize]
        public ValueInput www { get; private set; }

        [DoNotSerialize]
        [PortLabel("Loaded From Cache")]
        public ValueInput OnComplete;

        protected override void OnDefinition()
        {
            www = ValueInput("www", (OnlineMapsWWW)null);
            OnComplete = ValueInput("OnComplete", false);
        }

        protected override void OnEnter(Flow flow)
        {
            OnlineMapsWWW w = flow.GetValue<OnlineMapsWWW>(www);
            if (w != null)
            {
                if (flow.GetValue<bool>(OnComplete)) w.OnComplete = null;
            }
            else Debug.Log("WWW is null");
        }
    }
}