﻿using System.Collections.Generic;
using UnityEngine;

namespace JLGames.RocketDriver.Editor.Infra
{
    public class PropertyPaths
    {
        private readonly Component m_Component;
        private readonly List<string> m_Paths = new List<string>();

        public Component Component => m_Component;
        public List<string> Paths => m_Paths;
        public string[] PathArray => m_Paths.ToArray();
        public int PathSize => m_Paths.Count;

        public override string ToString()
        {
            return $"{{GameObject={m_Component.gameObject.name}, Component={m_Component.GetType()}, Path=[{string.Join(",", m_Paths)}]}}";
        }

        public PropertyPaths(Component component)
        {
            m_Component = component;
        }

        public PropertyPaths(Component component, string path)
        {
            m_Component = component;
            m_Paths.Add(path);
        }

        public bool ContainsPath(string path)
        {
            return !string.IsNullOrEmpty(path) && m_Paths.Contains(path);
        }

        public void AppendPath(string path)
        {
            m_Paths.Add(path);
        }

        public void ClearPaths()
        {
            m_Paths.Clear();
        }
    }
}