using System;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
using VOID.Generic.World;

namespace VOID.ScriptableObjects.World
{
    [Serializable]
    public class WorldAreaGeneratorSettings
    {
        [RequiredListLength(MinLength = 1)]
        public List<ComplexArea> group;

        [HorizontalGroup("generic")]
        [LabelWidth(125)]
        public bool useRotatedVariants = true;
        
        [HorizontalGroup("generic")]
        [MinValue(0)]
        [LabelWidth(75)]
        public float weight = 1f;

        [HorizontalGroup("limit")]
        [OnValueChanged(nameof(OnIsLimitedChanged))]
        [LabelWidth(125)]
        public bool isLimited;
        
        [HorizontalGroup("limit")]
        [MinValue(1)]
        [EnableIf(nameof(isLimited))]
        [LabelWidth(75)]
        public int limit = 9999;

        [HorizontalGroup("distance")]
        [OnValueChanged(nameof(OnRequireDistanceChanged))]
        [LabelWidth(125)]
        public bool requireDistance;
        
        [HorizontalGroup("distance")]
        [EnableIf(nameof(requireDistance))]
        [MinMaxSlider(1, 999, true)]
        [LabelWidth(75)]
        public Vector2Int distance = new(1, 999);

        private void OnIsLimitedChanged()
        {
            if (!isLimited)
            {
                limit = 9999;
            }
        }

        private void OnRequireDistanceChanged()
        {
            if (!requireDistance)
            {
                distance = new Vector2Int(1, 999);
            }
        }
    }
}