/// <summary>
        /// Sets multi-mode engines to run in primary mode (true) or secondary
        /// mode (false).
        /// </summary>
        /// <param name="newstate"></param>
        public void SetEnginesPrimaryMode(bool newstate)
        {
            try
            {
                RPMVesselComputer comp = RPMVesselComputer.Instance(vessel);
                for (int i = 0; i < comp.availableMultiModeEngines.Count; ++i)
                {
                    if (comp.availableMultiModeEngines[i].runningPrimary ^ newstate)
                    {
                        if (newstate)
                        {
                            comp.availableMultiModeEngines[i].SetPrimary(true);
                        }
                        else
                        {
                            comp.availableMultiModeEngines[i].SetSecondary(true);
                        }
                        // Revised implementation:
                        //comp.availableMultiModeEngines[i].ModeEvent();

                        // original implementation:
                        //var ev = comp.availableMultiModeEngines[i].Events["ModeEvent"];
                        //if (ev != null)
                        //{
                        //    ev.Invoke();
                        //}
                    }
                }

                // Toggling modes changes which engines are enabled and which
                // are disabled.  Force a reset here.
                comp.InvalidateModuleLists();
            }
            catch { }
        }