protected void checkForUpgrade()
        {
            if (ResearchAndDevelopment.Instance == null)
            {
                return;
            }
            ModuleSAS sasModule = this.part.FindModuleImplementing <ModuleSAS>();

            if (sasModule == null)
            {
                return;
            }
            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }
            if (upgradeChecked)
            {
                return;
            }

            upgradeChecked = true;

            if (ResearchAndDevelopment.GetTechnologyState(levelThreeNode) == RDTech.State.Available)
            {
                sasModule.SASServiceLevel = 3;
            }

            else if (ResearchAndDevelopment.GetTechnologyState(levelTwoNode) == RDTech.State.Available)
            {
                sasModule.SASServiceLevel = 2;
            }

            else if (ResearchAndDevelopment.GetTechnologyState(levelOneNode) == RDTech.State.Available)
            {
                sasModule.SASServiceLevel = 1;
            }

            else
            {
                sasModule.SASServiceLevel = 0;
            }

            sasModule.OnAwake();
            sasModule.OnActive();
        }
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }

            if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX)
            {
                ModuleSAS sasModule = this.part.FindModuleImplementing <ModuleSAS>();
                if (sasModule != null)
                {
                    sasModule.SASServiceLevel = 3;
                    sasModule.OnAwake();
                    sasModule.OnActive();
                }
                return;
            }

            //Check for upgrade
            checkForUpgrade();
        }