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

namespace Onward.CustomContent.Assets
{
    public class MapQuad : Entity
    {
        [Header("Level Options")]
        public float LevelSize = 100f;
        public float LevelHeight = 100f;

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

            // Fix MapQuad to identity
#if UNITY_EDITOR
            if (transform.rotation != Quaternion.identity)
            {
                transform.rotation = Quaternion.identity;

                UnityEditor.EditorUtility.SetDirty(transform);
            }
#endif

            if (LevelSize <= 0)
                throw new ContentExceptionWithGameObject(gameObject, "LevelSize required to be > 0");

            if (LevelHeight <= 0)
                throw new ContentExceptionWithGameObject(gameObject, "LevelHeight required to be > 0");
        }

#if UNITY_EDITOR
        private void OnDrawGizmos()
        {
            Vector3 size = LevelSize * Vector3.one;

            size.y = LevelHeight;

            Gizmos.color = Color.magenta;

            Gizmos.DrawWireCube(transform.position, size);
        }
#endif
    }
}