using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace SimplifyXR
{

    [DirectiveCategory(DirectiveCategories.Initiator,
        subCategory = DirectiveSubCategory.UI,
        directiveInfo = "This <i>initiator</i> starts a sequence when an <b>object anchor placement begins</b>.",
        prettyName = "Object Anchor Placement Started")]
    public class OnObjectAnchorPlacementStarted : Initiator
    {

        public ObjectAnchorPanelFeatures objectAnchorPanel;
        ObjectAnchorPanelFeatures objectAnchor ;

        public override List<KnobKeywords> ReceiveKeywords()
        {
            return new List<KnobKeywords>();
        }

        public override List<KnobKeywords> SendKeywords()
        {
            return new List<KnobKeywords>();
        }

        public new void Awake()
        {
            base.Awake();

            objectAnchorPanel =
                objectAnchorPanel == null ?
                Object.FindObjectOfType<ObjectAnchorPanelFeatures>() :
                objectAnchorPanel;


            objectAnchor = objectAnchorPanel.GetComponentInChildren<ObjectAnchorPanelFeatures>();

            objectAnchor?.ObjectAnchorPlacementStarted
                .AddListener(HandleObjectAnchorPlacementStarted);
        }

        public new void OnDestroy()
        {
            base.OnDestroy();
            objectAnchor?.ObjectAnchorPlacementStarted
                .RemoveListener(HandleObjectAnchorPlacementStarted);
        }

        public void HandleObjectAnchorPlacementStarted()
        {
            base.Initiate();
        }
    }
}