public void Update()
        {
            if (Controller == null || accelerator == null || accelerator.constructionRecipe == null)
            {
                return;
            }
            if (accelerator.vessel == null)
            {
                Controller.controlsPane.SetActive(false);
                Controller.constructionPane.SetActive(false);
                Controller.resourcesTitle.text = "Segment construction requirements";
                Controller.UpdateResources(
                    accelerator.constructionRecipe.GetResourceInfos(accelerator.SegmentMass));
            }
            else
            {
                Controller.controlsPane.SetActive(true);
                Controller.constructionPane.SetActive(true);
                Controller.UpdateWorkforce(accelerator.vessel.GetCrewCount(), accelerator.Workforce);
                var rem = accelerator.GetRemainingConstructionTime();
                Controller.remainingTime.text  = double.IsNaN(rem) ? "N/A" : Utils.formatTimeDelta(rem);
                Controller.resourcesTitle.text = "Remaining construction requirements";
                Controller.UpdateResources(
                    accelerator.constructionRecipe.GetResourceInfos(accelerator.SegmentMass
                                                                    - (float)accelerator.ConstructedMass));
                switch (accelerator.cState)
                {
                case OrbitalAccelerator.ConstructionState.IDLE:
                    Controller.state.text = accelerator.State == OrbitalAccelerator.AcceleratorState.IDLE
                            ? "Construction possible"
                            : "Accelerator is in use";
                    Controller.startStopButtonText.text = "Start";
                    Controller.startStopTooltip.text    = "Start construction";
                    Controller.startStopColorizer.SetColor(Colors.Good);
                    Controller.stateColorizer.SetColor(Colors.Neutral);
                    Controller.UpdateProgress(-1, 1);
                    break;

                case OrbitalAccelerator.ConstructionState.DEPLOYING:
                    Controller.state.text = "Deploying scaffold";
                    Controller.startStopButtonText.text = "Pause";
                    Controller.startStopTooltip.text    = "Pause deployment";
                    Controller.startStopColorizer.SetColor(Colors.Warning);
                    Controller.stateColorizer.SetColor(Colors.Warning);
                    Controller.UpdateProgress(accelerator.DeploymentProgress, 1);
                    break;

                case OrbitalAccelerator.ConstructionState.PAUSE:
                    Controller.state.text = accelerator.DeploymentProgress < 1
                            ? "Deployment paused"
                            : "Construction paused";
                    Controller.startStopButtonText.text = "Resume";
                    Controller.startStopTooltip.text    = accelerator.DeploymentProgress < 1
                            ? "Resume deployment"
                            : "Resume construction";
                    Controller.startStopColorizer.SetColor(Colors.Good);
                    Controller.stateColorizer.SetColor(Colors.Inactive);
                    if (accelerator.DeploymentProgress < 1)
                    {
                        Controller.UpdateProgress(accelerator.DeploymentProgress, 1);
                    }
                    else
                    {
                        Controller.UpdateProgress(accelerator.ConstructedMass, accelerator.SegmentMass);
                    }
                    break;

                case OrbitalAccelerator.ConstructionState.CONSTRUCTING:
                    Controller.state.text = "Construction in progress";
                    Controller.startStopButtonText.text = "Pause";
                    Controller.startStopTooltip.text    = "Pause construction";
                    Controller.startStopColorizer.SetColor(Colors.Warning);
                    Controller.stateColorizer.SetColor(Colors.Good);
                    Controller.UpdateProgress(accelerator.ConstructedMass, accelerator.SegmentMass);
                    break;

                case OrbitalAccelerator.ConstructionState.FINISHED:
                    Controller.state.text = "Construction complete";
                    Controller.startStopButtonText.text = "Start";
                    Controller.startStopTooltip.text    = "Start construction";
                    Controller.stateColorizer.SetColor(Colors.Good);
                    Controller.UpdateProgress(1, 1);
                    break;

                case OrbitalAccelerator.ConstructionState.ABORTED:
                    Controller.state.text = "Construction aborted";
                    Controller.startStopButtonText.text = "Start";
                    Controller.startStopTooltip.text    = "Start construction";
                    Controller.stateColorizer.SetColor(Colors.Danger);
                    Controller.UpdateProgress(-1, 1);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                var noDialogIsOpened = !DialogFactory.ContextIsActive(this);
                Controller.startStopButton.SetInteractable(accelerator.CanConstruct && noDialogIsOpened);
                Controller.abortButton.SetInteractable(accelerator.CanAbortConstruction && noDialogIsOpened);
            }
        }