using System;
using DefaultNamespace;
using DefaultNamespace.ProcessMode;
// using HighlightPlus;
using MotionFramework;
using UnityEngine;
using UnityEngine.EventSystems;

//public enum ToolProperties
//{
//    默认,
//    穿戴,
//    工具
//}

namespace ToolsPack
{
    /// <summary>
    /// 附着在工具模型上
    /// </summary>
    [RequireComponent(typeof(BoxCollider))]
    // [RequireComponent(typeof(HighlightEffect))]
    public class ToolsPackGameObjectComponent : MonoBehaviour
    {
        // private HighlightEffect _highlight;
        private int index;
        [SerializeField] private ModelTypeEnum _modelTypeEnum;
        [SerializeField] private ToolsPackScene _toolsPackScene;
        [SerializeField] private bool IsClick = true;
        //public ToolProperties _ToolProperties = ToolProperties.默认;
        private void Awake()
        {
            // _highlight = this.GetComponent<HighlightEffect>();
        }

        private void Start()
        {
            // _toolsPackScene = MotionEngine.GetModule<ToolsPackManager>().GetToolsPackScene();
        }

        private void OnEnable()
        {
            // _highlight.highlighted = false;
        }

        private void OnMouseDown()
        {
            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }


            if (MotionEngine.GetModule<ToolsPackManager>().GetToolsPackScene() == ToolsPackScene.工具间)
            {
                bool b = MotionEngine.GetModule<ProcessManager>().HandleClick(this.gameObject.name);

                if (b)
                {
                    if (IsClick)
                        MotionEngine.GetModule<ToolsPackManager>().AddToolsPack(this.name, this.gameObject);
                    this.gameObject.SetActive(false);

                }

            }
        }

        private void OnMouseEnter()
        {
            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }

            // _highlight.highlighted = true;
        }

        private void OnMouseExit()
        {
            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }

            // _highlight.highlighted = false;
        }

        public void SetIndex(int inde)
        {
            index = inde;
        }

        public int GetIndex()
        {
            return index;
        }

        // public void SetModelTypeEnum(ModelTypeEnum mo)
        // {
        //     _modelTypeEnum = mo;
        // }

        public ModelTypeEnum GetModelTypeEnum()
        {
            return _modelTypeEnum;
        }
    }
}