using UnityEngine;

namespace WS
{
    [ObjectSystem]
    public class TeleportPointControllerAwakeSystem : AwakeSystem<TeleportPointController>
    {
        public override void Awake(TeleportPointController self)
        {
            self.RefreshTeleport();
        }
    }

    [ObjectSystem]
    public class TeleportPointControllerUpdataSystem : UpdateSystem<TeleportPointController>
    {
        public override void Update(TeleportPointController self)
        {
            //if (GameManager.Instance.Data.Pattern != PatternType.引导)
            //{
            //    if (VRInputComponent.Instance.Getkey(VRKey.圆盘, VRHand.Any))
            //    {
            //        self.ShowTeleportTarget(true);
            //    }
            //    else
            //    {
            //        self.ShowTeleportTarget(false);
            //    }
            //}
        }
    }

    public class TeleportPointController : WSComponent
    {
        //public TeleportTargetBase[] points;
        public GameObject[] UnMoveAreas;

        public void RefreshTeleport()
        {
            //points = GameObject.FindObjectsOfType<TeleportTargetBase>();
            //UnMoveAreas = GameObject.FindGameObjectsWithTag("UnMoveArea");
            //for (int i = 0; i < points.Length; i++)
            //{
            //    points[i].GetComponent<MeshRenderer>().enabled = false;
            //    points[i].GetComponent<Collider>().enabled = false;
            //}
            //for (int i = 0; i < UnMoveAreas.Length; i++)
            //{
            //    UnMoveAreas[i].GetComponent<Collider>().enabled = false;
            //}
        }

        public void ShowTeleportTarget(bool isShow)
        {
            //points = GameObject.FindObjectsOfType<TeleportTargetBase>();
            //UnMoveAreas = GameObject.FindGameObjectsWithTag("UnMoveArea");
            //for (int i = 0; i < points.Length; i++)
            //{
            //    if (points[i]==null)
            //    {
            //        return;
            //    }
            //    points[i].GetComponent<MeshRenderer>().enabled = isShow;
            //    points[i].GetComponent<Collider>().enabled = isShow;
            //}
            //for (int i = 0;i < UnMoveAreas.Length; i++)
            //{
            //    UnMoveAreas[i].GetComponent<Collider>().enabled =isShow;
            //}
        }

        public void InitTeleportArea()
        {
            //for (int i = 0; i < points.Length; i++)
            //{
            //    points[i].GetComponent<MeshRenderer>().enabled = false;
            //    points[i].GetComponent<Collider>().enabled = false;
            //}
            //for (int i = 0; i < UnMoveAreas.Length; i++)
            //{
            //    UnMoveAreas[i].GetComponent<Collider>().enabled = false;
            //}
        }

        public override void Dispose()
        {
            base.Dispose();
            //points = null;
        }
    }
}
