﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Onward.CustomContent.Assets
{
    public class SpawnSystem : Entity
    {
        public Spawnpoint[] AllSpawns => GetComponentsInChildren<Spawnpoint>(true);
        public override void Validate()
        {
            base.Validate();

            Spawnpoint[] spawns = AllSpawns;
			
			if (spawns.Length < 5)
				throw new ContentExceptionWithGameObject(gameObject, "SpawnSystem requires a minimum of 5 spawn points.");
        }

#if UNITY_EDITOR
        public void DrawLinesTo(Vector3 pos)
        {
            Gizmos.color = new Color(0, 1, 0, 0.25f);

            foreach (var spawn in AllSpawns)
            {
                Gizmos.DrawLine(pos, spawn.transform.position);
            }
        }
#endif
    }
}