private void SetInitialState()
    {
        Scaffold.SetAllButtonsBlack();

        // Decide which color is the “neutral” color (the remaining four are the “live” ones)
        var colors = _usefulColors.ToArray().Shuffle();

        _rememberedColors    = colors.Subarray(0, 4);                                      // this array will be reordered as the player presses them
        _rememberedPositions = Enumerable.Range(0, 16).ToArray().Shuffle().Subarray(0, 4); // will be re-populated as the player presses them
        _neutralColor        = colors[4];
        _stage       = 0;
        _subprogress = 0;

        for (int i = 0; i < 16; i++)
        {
            _colors[i] = _neutralColor;
        }
        for (int i = 0; i < 4; i++)
        {
            _colors[_rememberedPositions[i]] = _rememberedColors[i];
        }

        Log("Initial colors are: {0}", _rememberedColors.Select((c, cIx) => string.Format("{0} at {1}", c, coord(_rememberedPositions[cIx]))).Join(", "));
        Scaffold.StartSquareColorsCoroutine(_colors, delay: true);
    }
    private void Awake()
    {
        if (!_moduleIdCounters.ContainsKey(Name))
        {
            _moduleIdCounters[Name] = 1;
        }

        _moduleId = _moduleIdCounters[Name]++;
        _module   = GetComponent <KMBombModule>();

        Scaffold = Instantiate(ScaffoldPrefab, transform);
        var moduleSelectable = GetComponent <KMSelectable>();

        foreach (var btn in Scaffold.Buttons)
        {
            btn.Parent = moduleSelectable;
        }
        moduleSelectable.Children = Scaffold.Buttons;
        moduleSelectable.UpdateChildren();
        for (int i = 0; i < 16; i++)
        {
            Scaffold.Buttons[i].OnInteract = MakeButtonHandler(i);
        }
        Scaffold.SetAllButtonsBlack();
        Scaffold.FixLightSizes(_module.transform.lossyScale.x);
    }
    protected override void ButtonPressed(int index)
    {
        if (_stage == 0)
        {
            // Preliminary stage in which the player presses the four “live” colors in any order of their choice
            if (_colors[index] == SquareColor.White)    // ignore re-presses
            {
                return;
            }
            if (_colors[index] == _neutralColor)
            {
                Log("During the preliminary stage, you pressed a square that wasn’t one of the singular colors. Strike.");
                Strike();
                SetInitialState();
                return;
            }
            PlaySound(index);
            _rememberedColors[_subprogress]    = _colors[index];
            _rememberedPositions[_subprogress] = index;
            _subprogress++;

            // If all colors have been pressed, initialize stage 1
            if (_subprogress == 4)
            {
                Log("You pressed them in this order: {0}", Enumerable.Range(0, 4).Select(ix => string.Format("{0} ({1})", coord(_rememberedPositions[ix]), _rememberedColors[ix])).Join(", "));
                Scaffold.SetAllButtonsBlack();
                SetStage(1);
            }
            else
            {
                _colors[index] = SquareColor.White;
                Scaffold.SetButtonColor(index, SquareColor.White);
            }
            return;
        }

        if (index != _expectedPresses[_subprogress])
        {
            Log("Expected {0}, but you pressed {1}. Strike. Module resets.", coord(_expectedPresses[_subprogress]), coord(index));
            Strike();
            SetInitialState();
            return;
        }

        PlaySound(index);
        _subprogress++;
        _colors[index] = SquareColor.White;
        Scaffold.SetButtonColor(index, SquareColor.White);
        Log("{0} was correct.", coord(index));
        if (_subprogress == _expectedPresses.Count)
        {
            SetStage(_stage + 1);
        }
    }
 protected void Strike()
 {
     _module.HandleStrike();
     Scaffold.SetAllButtonsBlack();
 }