using System;
using UnityEngine;

namespace Assets.Common
{
    [Serializable]
    public class Map : IHasMetadata
    {
        [SerializeField]
        private Graph<MapSite> _sites = new Graph<MapSite>();
        
        public int Seed { get; }
        public Size Size { get; }

        public Graph<MapSite> Sites
        {
            get => _sites;
            set
            {
                _sites = value;
                int i = 0;
                foreach (var site in _sites.Vertices)
                {
                    site.Map = this;
                    site.Index = i++;
                }
            }
        }

        public Graph<Point> Boundaries { get; set; }

        public Metadata Metadata { get; } = new Metadata();

        public Map(int seed, Size size)
        {
            Seed = seed;
            Size = size;
        }
    }
}