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

namespace Onward.CustomContent.Assets
{
    public class ObjectiveOpEvac : Objective
    {
        public override void Validate()
        {
            // Rules are different for this objective.
            //base.Validate();

            ValidateSpawnSystemEntries(ref AttackingTeamSpawns, gameObject);
            ValidateSpawnSystemEntries(ref DefendingTeamSpawns, gameObject);

            if (DefendingTeamSpawns.Length <= 0)
                throw new ContentExceptionWithGameObject(gameObject, "No spawns for defending team.");

            if (AttackingTeamSpawns.Length > 0)
            {
                AttackingTeamSpawns = new SpawnSystem[] { };

#if UNITY_EDITOR
                UnityEditor.EditorUtility.SetDirty(this);
                UnityEditor.EditorUtility.SetDirty(gameObject);
#endif

                throw new ContentExceptionWithGameObject(gameObject, "Attacking team must not have spawns, clearing. Please rebuild.");
            }
        }

#if UNITY_EDITOR
        private void OnDrawGizmos()
        {
            Gizmos.matrix = transform.localToWorldMatrix;

            const float Height = 50f;
            const float TotalHeight = 7.22f + Height;

            Gizmos.DrawWireCube(new Vector3(0.015f, 0f + 0.5f * TotalHeight, -2.556f), new Vector3(21.24801f, TotalHeight, 33.37091f));

            Gizmos.DrawWireSphere(Vector3.zero, 1.5f);
        }
#endif
    }
}