using UnityEngine;

namespace TD.Core
{
    /// <summary>
    /// Canonical RGB values for the tower Paint tool. Saturated primaries so a painted
    /// tower reads clearly against any owner color. Mirrors the <see cref="PlayerColors"/>
    /// style (HexRGB constants + a switch lookup).
    /// </summary>
    /// <remarks>
    /// <see cref="PaintColor.None"/> has no color of its own — it means "unpainted", and
    /// callers fall back to the owner color (<see cref="PlayerColors.Get"/>) in that case.
    /// <see cref="Get"/> returns a neutral gray for <c>None</c> only so the Reset brush /
    /// swatch has something to render; tinting code should branch on <c>None</c> before
    /// calling this.
    /// </remarks>
    public static class PaintColors
    {
        private static readonly Color PaintRed   = HexRGB(0xD8, 0x2A, 0x2A);
        private static readonly Color PaintGreen = HexRGB(0x2E, 0xC0, 0x3A);
        private static readonly Color PaintBlue  = HexRGB(0x2E, 0x6A, 0xE0);

        // Neutral gray used to represent the Reset / "None" brush in UI swatches and the
        // paint cursor. Not applied as a tower tint (None towers revert to owner color).
        private static readonly Color ResetGray  = HexRGB(0xB0, 0xB0, 0xB8);

        /// <summary>
        /// Returns the color for a <see cref="PaintColor"/>. <see cref="PaintColor.None"/>
        /// returns a neutral gray (for the Reset swatch/cursor) — actual tower tinting
        /// should treat <c>None</c> as "use owner color" and not call this for that case.
        /// </summary>
        public static Color Get(PaintColor color)
        {
            switch (color)
            {
                case PaintColor.Red:   return PaintRed;
                case PaintColor.Green: return PaintGreen;
                case PaintColor.Blue:  return PaintBlue;
                case PaintColor.None:
                default:
                    return ResetGray;
            }
        }

        private static Color HexRGB(byte r, byte g, byte b)
        {
            return new Color(r / 255f, g / 255f, b / 255f, 1f);
        }
    }
}
