using UnityEngine;
using XGame.Framework.ObjectCollection;

namespace XGame.Framework.Map
{
    /// <summary>
    /// 地图根节点
    /// </summary>
    [DisallowMultipleComponent]
    [AddComponentMenu("XGame/Map/MapBehaviour")]
    public class MapBehaviour : MonoBehaviour
    {
        /// <summary>
        /// 序列化器
        /// </summary>
        [SerializeField]
        private ObjectCollector _collector = new ObjectCollector();
        /// <summary>
        /// 地图相机
        /// </summary>
        [SerializeField]
        private Camera _camera;
        /// <summary>
        /// 序列化器
        /// </summary>
        public IObjectCollector Collector => _collector;
        /// <summary>
        /// 地图相机
        /// </summary>
        public Camera Camera => _camera;
        private void Start()
        {
            if (_camera == null)
            {
                _camera = transform.GetComponentInChildren<Camera>();
            }
            if (_camera == null)
            {
                _camera = Camera.main;
            }
            if ( _camera == null)
            {
                Log.Error($"地图没有相机.Name:{gameObject.name}");
            }
        }
    }
}