using UnityEngine;

namespace KitsuneCafe.Sys
{
  [System.Serializable]
  public class Layer
  {
    [SerializeField]
    private int index = 0;

    public int Index => index;

    public Layer(int index)
    {
      this.index = index;
    }

    public void Set(int layerIndex)
    {
      if (layerIndex > 0 && layerIndex < 32)
      {
        index = layerIndex;
      }
    }

    public int Mask => 1 << index;

    public override string ToString()
    {
      return $"Layer {{ Index = {index} }}";
    }

    public static implicit operator int(Layer layer) => layer.Index;
    public static implicit operator Layer(int index) => new(index);
  }
}
