Files
BracerLib/Assets/Scripts/Data/Layer.cs
T
2026-06-02 18:57:47 -04:00

41 lines
1019 B
C#

using System;
using UnityEngine;
using UnityEngine.TestTools;
namespace BracerLib.Data
{
[Serializable, ExcludeFromCoverage]
public struct Layer : IEquatable<Layer>
{
public static implicit operator int(Layer layer)
{
return layer.layerIndex;
}
[SerializeField]
private int layerIndex;
public int LayerIndex
{
get => layerIndex;
set
{
if (value > 0 && value < 32)
layerIndex = value;
}
}
public int Mask => 1 << layerIndex;
public bool Equals(Layer other) => layerIndex == other.layerIndex;
public override bool Equals(object obj) => obj is Layer other && Equals(other);
public override int GetHashCode() => layerIndex;
public static bool operator ==(Layer left, Layer right) => left.Equals(right);
public static bool operator !=(Layer left, Layer right) => !left.Equals(right);
}
}