/// <summary> /// Grabs the highest set bit from the tile value. /// </summary> /// <param name="g">Tile bit-permission value</param> /// <returns>Bit index</returns> public static GroundTileType GetIndex(this GroundTileAllowed g) { int val = (int)g; for (byte i = 0; i < 8 * sizeof(GroundTileAllowed); i++) { val >>= 1; if (val == 0) { return((GroundTileType)i); } } return(0); }
public static bool Contains(this GroundTileAllowed g1, GroundTileType g2) => (g1 & (GroundTileAllowed)(1 << (int)g2)) != 0;