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

namespace Onward.CustomContent.Assets
{
    public class ObjectiveEscort : Objective
    {
        [Header("Spawn position for Objective A")]
        public Transform ObjectiveSpawnPosA;

        [Header("Spawn position for Objective B")]
        public Transform ObjectiveSpawnPosB;

        public override void Validate()
        {
            base.Validate();

            if (ObjectiveSpawnPosA == null)
                throw new ContentExceptionWithGameObject(gameObject, "Missing spawn pos for objective A.");

            if (ObjectiveSpawnPosB == null)
                throw new ContentExceptionWithGameObject(gameObject, "Missing spawn pos for objective B.");
        }

#if UNITY_EDITOR
        private void OnDrawGizmos()
        {
            Gizmos.color = Color.blue;

            if (ObjectiveSpawnPosA == null)
            {
                GameObject newGo = new GameObject("[Escort Obj Spawn Pos A]");

                newGo.transform.parent = transform;
                newGo.transform.localPosition = Vector3.zero;
                newGo.transform.localRotation = Quaternion.identity;
                ObjectiveSpawnPosA = newGo.transform;
            }

            Gizmos.DrawWireSphere(ObjectiveSpawnPosA.position, 0.5f);
            Gizmos.DrawLine(transform.position, ObjectiveSpawnPosA.position);

            if (ObjectiveSpawnPosB == null)
            {
                GameObject newGo = new GameObject("[Escort Obj Spawn Pos B]");

                newGo.transform.parent = transform;
                newGo.transform.localPosition = Vector3.zero;
                newGo.transform.localRotation = Quaternion.identity;
                ObjectiveSpawnPosB = newGo.transform;
            }

            Gizmos.DrawWireSphere(ObjectiveSpawnPosB.position, 0.5f);
            Gizmos.DrawLine(transform.position, ObjectiveSpawnPosB.position);
        }
#endif
    }
}