Esempio n. 1
0
        /// <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 GroundTilePermission g)
        {
            int val = (int)g;

            for (byte i = 0; i < 8 * sizeof(GroundTilePermission); i++)
            {
                val >>= 1;
                if (val == 0)
                {
                    return((GroundTileType)i);
                }
            }
            return(0);
        }
Esempio n. 2
0
 public static bool Contains(this GroundTilePermission g1, GroundTileType g2) => (g1 & (GroundTilePermission)(1 << (int)g2)) != 0;