using System;
using UnityEngine;

namespace pdinklag.CPW.Common
{
    /// <summary>
    /// Describes a ring.
    /// </summary>
    [CreateAssetMenu(fileName = "Ring", menuName = "Wrestle/Ring Descriptor")]
    public class RingDescriptor : ScriptableObject
    {
        [Header("Info")]
        [Tooltip("The display name.")]
        public string DisplayName = "Ring";

        [Tooltip("A description text.")]
        [TextArea]
        public string Description;

        [Tooltip("Should this ring be hidden from the player?")]
        public bool Hidden;

        [Header("Basic Measures")]
        [Tooltip("The amount of sides.")]
        public int Sides = 4;

        [Tooltip("The distance from the ring's center to any corner.")]
        public float Radius = 4.5f;

        [Tooltip("The height of the ring mat above the floor.")]
        public float Height = 0.7f;

        [Header("Aprons")]
        public AssetAddress ApronMaterial;

        [Header("Mat")]
        public AssetAddress MatMaterial;

        [Header("Corners")]
        [Tooltip("The prefab for the ring posts - its inside should face positive Z direction.")]
        public AssetAddress PostPrefab;

        [Tooltip("The prefab for the turnbuckles - its inside should face positive Z direction.")]
        public AssetAddress BucklePrefab;

        [Header("Outside")]
        [Tooltip("Whether to generate stairs to the ring.")]
        public bool GenerateStairs = true;

        [Tooltip("Whether to generate protective floor mats around the ring.")]
        public bool GenerateFloorMats = true;

        [Tooltip("The material to use for floor mats.")]
        public AssetAddress FloorMatMaterial;

        [Tooltip("The color of the floor mats.")]
        public Color FloorMatColor = new Color(16, 16, 16);

        [Tooltip("The number of floor mats per ring side.")]
        public int FloorMatsPerSide = 4;

        [Tooltip("The length of the floor mats.")]
        public float FloorMatLength = 3;

        [Serializable]
        public struct RopeStruct
        {
            [Tooltip("The rope's color.")]
            public Color Color;

            [Tooltip("The height of the rope's turnbuckle above the ring mat.")]
            public float BuckleHeight;

            public RopeStruct(Color color, float buckleHeight)
            {
                Color = color;
                BuckleHeight = buckleHeight;
            }
        }

        [Header("Ropes")]
        [Tooltip("The material to use for ring ropes.")]
        public AssetAddress RopeMaterial;

        [Tooltip("The ropes that this ring has.")]
        public RopeStruct[] Ropes =
        {
            new RopeStruct(Color.red, 1.2f),
            new RopeStruct(Color.red, 0.8f),
            new RopeStruct(Color.red, 0.4f)
        };

        [Range(0.25f, 8.0f)]
        [Tooltip("How tight the ropes are.")]
        public float RopeTightness = 1.0f;

        [Header("Advanced Generation Options")]
        [Tooltip("The angle offset for the first corner.")]
        [Range(0, 360)]
        public float AngleOffset = 0;

        [Tooltip("The distance of the spawn points from the center (relative to ring radius).")]
        [Range(0, 1)]
        public float SpawnDistance = 0.5f;
    }
}
