namespace NiAkaDev.EzMirror
{
    using UdonSharp;

    /// <summary>
    /// Use / Interact 入力を EzMirror 本体へ中継する軽量プロキシ。
    /// </summary>
    [UdonBehaviourSyncMode(BehaviourSyncMode.None)]
    public class EzMirrorInteractInputProxy : UdonSharpBehaviour
    {
        public EzMirror targetMirror;

        public void Start()
        {
            ResolveTargetMirror();
        }

        public override void Interact()
        {
            ResolveTargetMirror();
            if (targetMirror == null || !targetMirror.enableInteractInput)
                return;

            targetMirror.SelectNextFromInteract();
        }

        private void ResolveTargetMirror()
        {
            if (targetMirror != null)
                return;

            targetMirror = GetComponentInParent<EzMirror>();
        }
    }
}
