#pragma warning restore 659
        #endregion



        // Multiply this MoveCubes cube with another MoveCubes cube b, restricted to the corners. Does not change b.
        public void CornerMultiply(ICubieCube b)
        {
            var cPerm = new Corner[8]; //TODO stackalloc
            var cOri  = new int[8];
            var ori   = 0;

            foreach (var c in Extensions.GetEnumValues <Corner>().Cast <int>())
            {
                cPerm[c] = _cornerPositions[(int)b.CornerPositions[c]];
                var oriA = _cornerOrientations[(int)b.CornerPositions[c]];
                var oriB = b.CornerOrientations[c];
                if (oriA < 3 && oriB < 3)
                {
                    // two regular cubes
                    ori = oriA + oriB;
                    if (ori >= 3)
                    {
                        ori -= 3;
                    }
                }
                else if (oriA < 3 && 3 <= oriB)
                {
                    // cube b is in a mirrored state
                    ori = oriA + oriB;
                    if (ori >= 6)
                    {
                        ori -= 3;
                    }
                }
                else if (oriA >= 3 && 3 > oriB)
                {
                    // cube a is in a mirrored state
                    ori = oriA - oriB;
                    if (ori < 3)
                    {
                        ori += 3;
                    }
                }
                else if (oriA >= 3 && oriB >= 3)
                {
                    // if both cubes are in mirrored states
                    ori = oriA - oriB;
                    if (ori < 0)
                    {
                        ori += 3;
                    }
                }
                cOri[c] = ori;
            }
            cPerm.CopyTo(_cornerPositions, 0);
            cOri.CopyTo(_cornerOrientations, 0);
        }