using System.Collections.Generic;
using UnityEngine;

public sealed class SystemMapView : MonoBehaviour
{
    [SerializeField]
    private NavigationPointView navPointPrefab = null;
    [SerializeField]
    private Profile profile = null;

    private List<NavigationPointView> navPointViews = new List<NavigationPointView>();

    private void Awake()
    {
        foreach (var point in profile.Player.NavigationPoints) {
            navPointViews.Add(CreateView(point));
        }
    }

    private NavigationPointView CreateView(NavigationPoint point)
    {
        var pointView = Instantiate(navPointPrefab, transform);
        pointView.Init(point);
        return pointView;
    }

    public NavigationPoint RaycastPoint(Ray ray) {
        if (Physics.Raycast(ray, out RaycastHit hitInfo)) {
            return hitInfo.collider.GetComponent<NavigationPointView>()?.Point;
        }
        return null;
    }
}
