Esempio n. 1
0
        public void AddPartCourses(AvailablePart ap, bool isKCTExperimentalNode = false)
        {
            if (ap.partPrefab.isVesselEVA || ap.name.StartsWith("kerbalEVA", StringComparison.OrdinalIgnoreCase) ||
                ap.partPrefab.Modules.Contains <KerbalSeat>() ||
                ap.partPrefab.Modules.Contains <LaunchClamp>() || ap.partPrefab.HasTag("PadInfrastructure"))
            {
                return;
            }

            TrainingDatabase.SynonymReplace(ap.name, out string name);
            if (!_partSynsHandled.TryGetValue(name, out var coursePair))
            {
                bool isPartUnlocked = !isKCTExperimentalNode && ResearchAndDevelopment.GetTechnologyState(ap.TechRequired) == RDTech.State.Available;

                CourseTemplate profCourse = GenerateCourseProf(ap, !isPartUnlocked);
                AppendToPartTooltip(ap, profCourse);
                CourseTemplate missionCourse = null;
                if (isPartUnlocked && IsMissionTrainingEnabled)
                {
                    missionCourse = GenerateCourseMission(ap);
                    AppendToPartTooltip(ap, missionCourse);
                }
                _partSynsHandled.Add(name, new Tuple <CourseTemplate, CourseTemplate>(profCourse, missionCourse));
            }
            else
            {
                CourseTemplate pc = coursePair.Item1;
                CourseTemplate mc = coursePair.Item2;
                AppendToPartTooltip(ap, pc);
                if (mc != null)
                {
                    AppendToPartTooltip(ap, mc);
                }
            }
        }
Esempio n. 2
0
        public Dictionary <AvailablePart, PartPurchasability> GetPartsWithPurchasability()
        {
            var res = new Dictionary <AvailablePart, PartPurchasability>();

            if (ResearchAndDevelopment.Instance == null)
            {
                return(res);
            }

            foreach (ConfigNode pNode in ShipNode.GetNodes("PART"))
            {
                string        partName = Utilities.GetPartNameFromNode(pNode);
                AvailablePart part     = PartLoader.getPartInfoByName(partName);
                if (res.TryGetValue(part, out PartPurchasability pp))
                {
                    pp.PartCount++;
                }
                else
                {
                    PurchasabilityStatus status = PurchasabilityStatus.Unavailable;
                    if (Utilities.PartIsUnlocked(part))
                    {
                        status = PurchasabilityStatus.Purchased;
                    }
                    else if (ResearchAndDevelopment.GetTechnologyState(part.TechRequired) == RDTech.State.Available)
                    {
                        status = PurchasabilityStatus.Purchasable;
                    }

                    res.Add(part, new PartPurchasability(status, 1));
                }
            }
            return(res);
        }
Esempio n. 3
0
        public int GetHoltzmanTechEfficiency()
        {
            if (core.IsCareer)
            {
                if (ResearchAndDevelopment.GetTechnologyState("start") == RDTech.State.Available)
                {
                    return(5);
                }

                if (ResearchAndDevelopment.GetTechnologyState("scienceTech") == RDTech.State.Available)
                {
                    return(25);
                }

                if (ResearchAndDevelopment.GetTechnologyState("fieldScience") == RDTech.State.Available)
                {
                    return(50);
                }

                if (ResearchAndDevelopment.GetTechnologyState("advScienceTech") == RDTech.State.Available)
                {
                    return(75);
                }

                if (ResearchAndDevelopment.GetTechnologyState("experimentalScience") == RDTech.State.Available)
                {
                    return(100);
                }
            }

            return(100);
        }
Esempio n. 4
0
        private static string ConstructUnlockablePartsWarning(IEnumerable <KeyValuePair <AvailablePart, PartPurchasability> > unlockablePartsOnShip)
        {
            var sb = StringBuilderCache.Acquire();

            sb.Append("This vessel contains parts that are still in development. ");
            if (unlockablePartsOnShip.Any(kvp => ResearchAndDevelopment.GetTechnologyState(kvp.Key.TechRequired) == RDTech.State.Available))
            {
                sb.Append("Green parts have been researched and can be unlocked.\n");
            }
            else
            {
                sb.Append("\n");
            }

            foreach (KeyValuePair <AvailablePart, PartPurchasability> kvp in unlockablePartsOnShip)
            {
                if (ResearchAndDevelopment.GetTechnologyState(kvp.Key.TechRequired) == RDTech.State.Available)
                {
                    sb.Append($" <color=green><b>{kvp.Value.PartCount}x {kvp.Key.title}</b></color>\n");
                }
                else
                {
                    sb.Append($" <color=orange><b>{kvp.Value.PartCount}x {kvp.Key.title}</b></color>\n");
                }
            }

            return(sb.ToStringAndRelease());
        }
        public override bool MeetRequirements()
        {
            generateExperimentIfNeeded();

            //Has the target body been orbited?
            bool targetBodyOrbited = false;

            foreach (CelestialBodySubtree subtree in ProgressTracking.Instance.celestialBodyNodes)
            {
                if (subtree.Body == targetBody)
                {
                    targetBodyOrbited = true;
                    break;
                }
            }
            if (!targetBodyOrbited)
            {
                return(false);
            }

            //If the experiment has a minimum tech requirement, make sure we've met the requirement.
            if (experimentNode.HasValue("techRequired") == false)
            {
                return(true);
            }

            string value = experimentNode.GetValue("techRequired");

            if (ResearchAndDevelopment.GetTechnologyState(value) != RDTech.State.Available)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
        public override void OnStart(StartState state)
        {
            decouple = part.FindModuleImplementing <ModuleDecouple>();
            if (decouple == null)
            {
                Debug.LogError($"[ProceduralParts] No ModuleDecouple found on {part}");
                isEnabled = enabled = false;
                return;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                Fields[nameof(isOmniDecoupler)].guiActiveEditor =
                    string.IsNullOrEmpty(separatorTechRequired) || ResearchAndDevelopment.GetTechnologyState(separatorTechRequired) == RDTech.State.Available;

                if (ejectionImpulse < float.Epsilon || float.IsNaN(ejectionImpulse))
                {
                    ejectionImpulse = decouple.ejectionForce * ImpulsePerForceUnit;
                }

                (Fields[nameof(ejectionImpulse)].uiControlEditor as UI_FloatEdit).maxValue = maxImpulse;
            }
            else if (HighLogic.LoadedSceneIsFlight)
            {
                if (float.IsNaN(ejectionImpulse))
                {
                    ejectionImpulse = 0;
                }
                decouple.isOmniDecoupler = isOmniDecoupler;
                decouple.ejectionForce   = ejectionImpulse / TimeWarp.fixedDeltaTime;
                GameEvents.onTimeWarpRateChanged.Add(OnTimeWarpRateChanged);
            }
        }
        public override void OnStart(StartState state)
        {
            if (!FindDecoupler())
            {
                Debug.LogError("Unable to find any decoupler modules");
                isEnabled = enabled = false;
                return;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (mass != 0)
                {
                    UpdateMass(mass);
                }

                Fields["isOmniDecoupler"].guiActiveEditor =
                    string.IsNullOrEmpty(separatorTechRequired) || ResearchAndDevelopment.GetTechnologyState(separatorTechRequired) == RDTech.State.Available;

                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (ejectionImpulse == 0)
                {
                    ejectionImpulse = (float)Math.Round(decouple.ejectionForce * ImpulsePerForceUnit, 1);
                }

                UI_FloatEdit ejectionImpulseEdit = (UI_FloatEdit)Fields["ejectionImpulse"].uiControlEditor;
                ejectionImpulseEdit.maxValue = maxImpulse;
            }
            else if (HighLogic.LoadedSceneIsFlight)
            {
                decouple.isOmniDecoupler = isOmniDecoupler;
            }
        }
Esempio n. 8
0
        public void NewRecoveryFunctionTrackingStation()
        {
            if (!(FindObjectOfType(typeof(SpaceTracking)) is SpaceTracking ts &&
                  ts.SelectedVessel is Vessel _selectedVessel))
            {
                Debug.LogError("[KCT] No Vessel selected.");
                return;
            }

            bool canRecoverToSPH = _selectedVessel.IsRecoverable && _selectedVessel.IsClearToSave() == ClearToSaveStatus.CLEAR;

            string reqTech         = PresetManager.Instance.ActivePreset.GeneralSettings.VABRecoveryTech;
            bool   canRecoverToVAB = _selectedVessel.IsRecoverable &&
                                     _selectedVessel.IsClearToSave() == ClearToSaveStatus.CLEAR &&
                                     (_selectedVessel.situation == Vessel.Situations.PRELAUNCH ||
                                      string.IsNullOrEmpty(reqTech) ||
                                      ResearchAndDevelopment.GetTechnologyState(reqTech) == RDTech.State.Available);

            var options = new List <DialogGUIBase>();

            if (canRecoverToSPH)
            {
                options.Add(new DialogGUIButton("Recover to SPH", RecoverToSPH));
            }
            if (canRecoverToVAB)
            {
                options.Add(new DialogGUIButton("Recover to VAB", RecoverToVAB));
            }
            options.Add(new DialogGUIButton("Normal recovery", DoNormalRecovery));
            options.Add(new DialogGUIButton("Cancel", () => { }));

            var diag = new MultiOptionDialog("scrapVesselPopup", "Do you want KCT to do the recovery?", "Recover Vessel", null, options: options.ToArray());

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
        }
Esempio n. 9
0
        protected bool canLoadModule(ConfigNode node)
        {
            string value;

            //If we are in career mode, make sure we have unlocked the tech node.
            if (ResearchAndDevelopment.Instance != null)
            {
                value = node.GetValue("TechRequired");
                if (!string.IsNullOrEmpty(value) && (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX))
                {
                    if (ResearchAndDevelopment.GetTechnologyState(value) != RDTech.State.Available)
                    {
                        return(false);
                    }
                }
            }

            //Now check for required mod
            value = node.GetValue("needs");
            if (!string.IsNullOrEmpty(value))
            {
                if (TemplateManager.CheckNeeds(value) != EInvalidTemplateReasons.TemplateIsValid)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 10
0
        private void GenerateOfferedCourses()
        {
            Profiler.BeginSample("RP0 GenerateOfferedCourses");
            OfferedCourses.Clear();
            _partSynsHandled.Clear();

            if (!CurrentSceneAllowsCrewManagement)
            {
                Profiler.EndSample();
                return;    // Course UI is only available in those 2 scenes so no need to generate them for any other
            }

            //convert the saved configs to course offerings
            foreach (CourseTemplate template in CourseTemplates)
            {
                var duplicate = new CourseTemplate(template.sourceNode, true); //creates a duplicate so the initial template is preserved
                duplicate.PopulateFromSourceNode();
                if (duplicate.Available)
                {
                    OfferedCourses.Add(duplicate);
                }
            }

            foreach (AvailablePart ap in PartLoader.LoadedPartsList)
            {
                if (!ap.TechHidden && ap.partPrefab.CrewCapacity > 0 &&
                    ResearchAndDevelopment.GetTechnologyState(ap.TechRequired) == RDTech.State.Available)
                {
                    AddPartCourses(ap);
                }
            }
            Profiler.EndSample();
        }
Esempio n. 11
0
 public static bool haveTech(string name)
 {
     if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
     {
         return(name == "sandbox");
     }
     return(ResearchAndDevelopment.GetTechnologyState(name) == RDTech.State.Available);
 }
Esempio n. 12
0
 public static bool IsTechUnlocked(string techid)
 {
     if (techid.Equals("None"))
     {
         return(true);
     }
     return(HighLogic.CurrentGame == null || HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX ||
            ResearchAndDevelopment.GetTechnologyState(techid) == RDTech.State.Available);
 }
Esempio n. 13
0
        private static void RefreshInventoryAvailability()
        {
            AvailablePart ap = PartLoader.getPartInfoByName(ChutePartName);

            _chutePartAvailable = ResearchAndDevelopment.GetTechnologyState(ap.TechRequired) == RDTech.State.Available;

            ap = PartLoader.getPartInfoByName(JetpackPartName);
            _jetpackPartAvailable = ResearchAndDevelopment.GetTechnologyState(ap.TechRequired) == RDTech.State.Available;
        }
Esempio n. 14
0
        private void InitializeShapes()
        {
            List <string> shapeNames = new List <string>();

            availableShapes.Clear();
            foreach (ProceduralAbstractShape compShape in GetComponents <ProceduralAbstractShape>())
            {
                if (!string.IsNullOrEmpty(compShape.techRequired) && ResearchAndDevelopment.GetTechnologyState(compShape.techRequired) != RDTech.State.Available)
                {
                    goto disableShape;
                }
                if (!string.IsNullOrEmpty(compShape.techObsolete) && ResearchAndDevelopment.GetTechnologyState(compShape.techObsolete) == RDTech.State.Available)
                {
                    goto disableShape;
                }

                availableShapes.Add(compShape.displayName, compShape);
                shapeNames.Add(compShape.displayName);

                if (string.IsNullOrEmpty(shapeName) ? (availableShapes.Count == 1) : compShape.displayName == shapeName)
                {
                    shape           = compShape;
                    oldShapeName    = shapeName = shape.displayName;
                    shape.isEnabled = shape.enabled = true;
                    continue;
                }

disableShape:
                compShape.isEnabled = compShape.enabled = false;
            }

            BaseField field = Fields["shapeName"];

            switch (availableShapes.Count)
            {
            case 0:
                throw new InvalidProgramException("No shapes available");

            case 1:
                field.guiActiveEditor = false;
                break;

            default:
                field.guiActiveEditor = true;
                UI_ChooseOption range = (UI_ChooseOption)field.uiControlEditor;
                range.options = shapeNames.ToArray();
                break;
            }

            if (string.IsNullOrEmpty(shapeName) || !availableShapes.ContainsKey(shapeName))
            {
                oldShapeName    = shapeName = shapeNames[0];
                shape           = availableShapes[shapeName];
                shape.isEnabled = shape.enabled = true;
            }
        }
Esempio n. 15
0
        // return number of techs researched among the list specified
        public static int CountTechs(string[] techs)
        {
            int n = 0;

            foreach (string tech in techs)
            {
                n += ResearchAndDevelopment.GetTechnologyState(tech) == RDTech.State.Available ? 1 : 0;
            }
            return(n);
        }
        private void wip(Func <string, EventVoid> doWithApart)
        {
            foreach (AvailablePart aPart in PartLoader.Instance.parts)
            {
                if (aPart.partPrefab != null && aPart.partPrefab.Modules != null)
                {
                    foreach (PartModule pm in aPart.partPrefab.Modules)
                    {
                        if (pm.moduleName.Equals("MerillMissionStub"))
                        {
                            if (((MerillMissionStub)pm).missionName.Equals(this.GetType().Name))
                            {
                                if (ResearchAndDevelopment.GetTechnologyState(((MerillMissionStub)pm).techRequired) == RDTech.State.Available)
                                {
                                    MerillData.log(" RD purchased, is experimental? "
                                                   + ResearchAndDevelopment.IsExperimentalPart(
                                                       PartLoader.getPartInfoByName(((MerillMissionStub)pm).partUnlock)));
                                    //check if already experimental
                                    if (ResearchAndDevelopment.IsExperimentalPart(PartLoader.getPartInfoByName(((MerillMissionStub)pm).partUnlock)))
                                    {
                                        doWithApart(((MerillMissionStub)pm).partUnlock);
                                    }
                                }
                                else if (aPart.TechRequired != "specializedControl")
                                {
                                    try
                                    {
                                        //try to remove the stub to a research node
                                        MerillData.log(" RD find a part with r&d node " + pm.name);

                                        RDTech tech = AssetBase.RnDTechTree.FindTech(
                                            ((MerillMissionStub)pm).techRequired);
                                        if (tech != null)
                                        {
                                            MerillData.log(" RD find good tech " + tech.name);
                                            aPart.TechRequired = "specializedControl";
                                            tech.partsAssigned.Remove(aPart);
                                            MerillData.log(" RD find tech assigned ");
                                            if (ResearchAndDevelopment.GetTechnologyState(((MerillMissionStub)pm).techRequired) == RDTech.State.Available)
                                            {
                                                doWithApart(((MerillMissionStub)pm).partUnlock);
                                            }
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        MerillData.log(" RD Exeption:  " + e);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        private int maxPartCount()
        {
            int partsAllowed = 200;

            if (ResearchAndDevelopment.GetTechnologyState("veryHeavyRocketry") == RDTech.State.Available)
            {
                partsAllowed += 25;
            }

            return(partsAllowed);
        }
Esempio n. 18
0
        public void NewRecoveryFunctionTrackingStation()
        {
            selectedVessel = null;
            SpaceTracking trackingStation = (SpaceTracking)FindObjectOfType(typeof(SpaceTracking));

            selectedVessel = trackingStation.SelectedVessel;

            if (selectedVessel == null)
            {
                Debug.Log("[KCT] Error! No Vessel selected.");
                return;
            }



            bool sph = (selectedVessel.IsRecoverable && selectedVessel.IsClearToSave() == ClearToSaveStatus.CLEAR);

            string reqTech = KCT_PresetManager.Instance.ActivePreset.generalSettings.VABRecoveryTech;
            bool   vab     =
                selectedVessel.IsRecoverable &&
                selectedVessel.IsClearToSave() == ClearToSaveStatus.CLEAR &&
                (selectedVessel.situation == Vessel.Situations.PRELAUNCH ||
                 string.IsNullOrEmpty(reqTech) ||
                 ResearchAndDevelopment.GetTechnologyState(reqTech) == RDTech.State.Available);

            int cnt = 2;

            if (sph)
            {
                cnt++;
            }
            if (vab)
            {
                cnt++;
            }

            DialogGUIBase[] options = new DialogGUIBase[cnt];
            cnt = 0;
            if (sph)
            {
                options[cnt++] = new DialogGUIButton("Recover to SPH", RecoverToSPH);
            }
            if (vab)
            {
                options[cnt++] = new DialogGUIButton("Recover to VAB", RecoverToVAB);
            }
            options[cnt++] = new DialogGUIButton("Normal recovery", DoNormalRecovery);
            options[cnt]   = new DialogGUIButton("Cancel", Cancel);

            MultiOptionDialog diag = new MultiOptionDialog("scrapVesselPopup", "Do you want KCT to do the recovery?", "Recover Vessel", null, options: options);

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
        }
Esempio n. 19
0
        public string ContextRedirect(string destination)
        {
            foreach (string techName in techsRequired)
            {
                if (ResearchAndDevelopment.GetTechnologyState(techName) == RDTech.State.Unavailable)
                {
                    return(fallbackPageName);
                }
            }

            return(redirectPages[destination]);
        }
Esempio n. 20
0
        public void switchMode()
        {
            try
            {
                if (mode == "")
                {
                    switchToRadiative();
                }

                if (mode == "ablator")
                {
                    switchFromAblator();
                }

                switch (mode)
                {
                case "radiative":
                    mode = "ablator";
                    if (techAblator == null || ResearchAndDevelopment.GetTechnologyState(techAblator) == RDTech.State.Available)
                    {
                        switchToAblator();
                    }
                    else
                    {
                        switchMode();
                    }
                    break;

                case "ablator":
                    mode = "regenerative";
                    if (techRegenerative == null || ResearchAndDevelopment.GetTechnologyState(techRegenerative) == RDTech.State.Available)
                    {
                        switchToRegenerative();
                    }
                    else
                    {
                        switchMode();
                    }
                    break;

                case "regenerative":
                    mode = "radiative";
                    switchToRadiative();
                    break;
                }
            }
            catch (Exception e)
            {
                Debug.LogError("[EngineCoolerModule]ERROR " + e);
            }
            GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
        }
Esempio n. 21
0
 protected void checkForUpgrade()
 {
     //If the player hasn't unlocked the upgradeTech node yet, then hide the RCS functionality.
     if (ResearchAndDevelopment.Instance != null && !string.IsNullOrEmpty(techRequired))
     {
         //If the tech node hasn't been researched yet then hide the switch capability
         if (ResearchAndDevelopment.GetTechnologyState(techRequired) != RDTech.State.Available)
         {
             Events["ToggleTemplate"].active = false;
             allowSwitch = false;
         }
     }
 }
        private void Start()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                running = false;
                Destroy(gameObject);
            }

            if (!SEP_Utilities.partModulesLoaded)
            {
                SEP_Utilities.loadPartModules();
            }

            if (!SEP_Utilities.antennaModulesLoaded)
            {
                SEP_Utilities.loadAntennaParts();
            }

            if (!SEP_Utilities.spritesLoaded)
            {
                StartCoroutine(loadSprites());
            }

            if (ResearchAndDevelopment.GetTechnologyState(transmissionNode) == RDTech.State.Available)
            {
                transmissionUpgrade = true;
            }
            else
            {
                transmissionUpgrade = false;
            }

            if (running)
            {
                Destroy(gameObject);
            }

            if (HighLogic.LoadedSceneIsFlight)
            {
                StartCoroutine(attachWindowListener());
            }

            instance = this;

            running = true;

            usingCommNet = HighLogic.CurrentGame.Parameters.Difficulty.EnableCommNet;

            GameEvents.onLevelWasLoaded.Add(onReady);
            GameEvents.OnGameSettingsApplied.Add(onSettingsApplied);
        }
Esempio n. 23
0
        private static bool HasTech(string id)
        {
            if (string.IsNullOrEmpty(id) || id == "none")
            {
                return(false);
            }

            if (ResearchAndDevelopment.Instance == null)
            {
                return(HasTechFromSaveFile(id));
            }

            return(ResearchAndDevelopment.GetTechnologyState(id) == RDTech.State.Available);
        }
Esempio n. 24
0
        public virtual void UnlockCheck()
        {
            if (!unlockChecked)
            {
                bool unlock = true;

                if (ResearchAndDevelopment.Instance != null)
                {
                    string[] parts = unlockParts.Split(new char[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length > 0)
                    {
                        unlock = false;
                        foreach (string p in parts)
                        {
                            if (PartLoader.LoadedPartsList.Count(a => a.name == p) > 0 && ResearchAndDevelopment.PartModelPurchased(PartLoader.LoadedPartsList.First(a => a.name == p)))
                            {
                                unlock = true;
                                break;
                            }
                        }
                    }

                    string[] techs = unlockTechs.Split(new char[] { ' ', ',', ';', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    if (techs.Length > 0)
                    {
                        if (parts.Length == 0)
                        {
                            unlock = false;
                        }
                        foreach (string t in techs)
                        {
                            if (ResearchAndDevelopment.GetTechnologyState(t) == RDTech.State.Available)
                            {
                                unlock = true;
                                break;
                            }
                        }
                    }
                }

                unlock = unlock && IsSpaceCenterUpgradeUnlocked();

                unlockChecked = true;
                if (!unlock)
                {
                    enabled = false;
                    core.someModuleAreLocked = true;
                }
            }
        }
Esempio n. 25
0
        public bool haveTechRequired(int tl)
        {
            string tech = getTechRequired(tl);

            if (tech == null || tech.Equals(""))
            {
                return(true);
            }
            if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX)
            {
                return(true);
            }
            return(ResearchAndDevelopment.GetTechnologyState(tech) == RDTech.State.Available);
        }
Esempio n. 26
0
        /// <summary>
        /// Updates the mode based on R&D unlocks
        /// </summary>
        /// <returns>true if there was a change</returns>
        private Modes CheckMode()
        {
//			Log.Write($"Checking tech tree for mode unlocks...");
            if (ResearchAndDevelopment.Instance == null)
            {
                Log.Write($"ResearchAndDevelopment.Instance is null!", Log.LogFormat.Error);
                return(Modes.None);
            }
            else
            {
                return(ResearchAndDevelopment.GetTechnologyState("advUnmanned") == RDTech.State.Available ? Modes.All :
                       ResearchAndDevelopment.GetTechnologyState("basicScience") == RDTech.State.Available ? Modes.RerunnableAndResettableWithScientist :
                       ResearchAndDevelopment.GetTechnologyState("engineering101") == RDTech.State.Available ? Modes.RerunnableOnly : Modes.None);
            }
        }
Esempio n. 27
0
        public static AirlaunchTechLevel GetCurrentLevel()
        {
            EnsureLevelsLoaded();
            for (int i = _techLevels.Count - 1; i >= 0; i--)
            {
                // Assume that levels are configured in the order of progression
                var level = _techLevels[i];
                if (ResearchAndDevelopment.GetTechnologyState(level.TechRequired) == RDTech.State.Available)
                {
                    return(level);
                }
            }

            return(null);
        }
Esempio n. 28
0
		// -- TECH ------------------------------------------------------------------

		// return true if the tech has been researched
		public static bool HasTech(string tech_id)
		{
			// if science is disabled, all technologies are considered available
			if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX) return true;

			// if RnD is not initialized
			if (ResearchAndDevelopment.Instance == null)
			{
				// this should not happen, throw exception
				throw new Exception("querying tech '" + tech_id + "' while TechTree is not ready");
			}

			// get the tech
			return ResearchAndDevelopment.GetTechnologyState(tech_id) == RDTech.State.Available;
		}
Esempio n. 29
0
        private void CheckTech(ref string[] arrEngineAvailable, Utilities Util)
        {
            if (engineAvailableEmpty)
            {
                Debug.Log("Check ResearchAndDevelopment.GetTechnologyState for engineList");
                foreach (var item in engineList)
                {
                    //Debug.Log(
                    //"\n(ResearchAndDevelopment.GetTechnologyState(item.minReqTech) == RDTech.State.Unavailable) && !minReqTechEmpty" +
                    //"\nResearchAndDevelopment.GetTechnologyState(item.minReqTech): " + ResearchAndDevelopment.GetTechnologyState(item.minReqTech) +
                    //"\n!minReqTechEmpty: " + !minReqTechEmpty
                    //);
                    //Debug.Log(
                    //"\n(ResearchAndDevelopment.GetTechnologyState(item.maxReqTech) == RDTech.State.Available) && !maxReqTechEmpty && (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX || applyTechReqToSandbox)" +
                    //"\nResearchAndDevelopment.GetTechnologyState(item.maxReqTech): " + ResearchAndDevelopment.GetTechnologyState(item.maxReqTech) +
                    //"\n!maxReqTechEmpty: " + !maxReqTechEmpty +
                    //"\nHighLogic.CurrentGame.Mode: " + HighLogic.CurrentGame.Mode +
                    //"\napplyTechReqToSandbox: " + applyTechReqToSandbox
                    //);
                    if ((ResearchAndDevelopment.GetTechnologyState(item.minReqTech) == RDTech.State.Unavailable) && !minReqTechEmpty)
                    {
                        Debug.Log("(ResearchAndDevelopment.GetTechnologyState(item.minReqTech) == RDTech.State.Unavailable) && !minReqTechEmpty\ntrue");
                        item.engineAvailable = false;
                    }
                    else if ((ResearchAndDevelopment.GetTechnologyState(item.maxReqTech) == RDTech.State.Available) && (!maxReqTechEmpty) && (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX || applyTechReqToSandbox))
                    {
                        Debug.Log("(ResearchAndDevelopment.GetTechnologyState(item.maxReqTech) == RDTech.State.Available) && !maxReqTechEmpty && (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX || applyTechReqToSandbox)\ntrue");
                        item.engineAvailable = false;
                    }
                    else
                    {
                        item.engineAvailable = true;
                    }
                    engineAvailable += item.engineAvailable.ToString() + ";";
                }
                engineAvailable = engineAvailable.Substring(0, engineAvailable.Length - 1);   //Remove the last and redundant ";"
                Debug.Log("engineAvailable: \n'" + engineAvailable + "' \nbuild from the engineList");
            }
            else
            {
                //TAKE THE KSPFIELD AND LOAD INTO engineList
                //At this point the engineList has all engineID's and the engineAvailable list is supposed to follow that at this point. That way we can now use it to select what is available, based on it.
                //engineAvailable is persistent, hence loaded from the save file of any active vessel, and recalculated for any new vessels.

                //engineAvailableEmpty = Util.ArraySplitEvaluate(engineAvailable, out arrEngineAvailable, ';');
                Debug.Log("engineAvailable: '" + engineAvailable + "' based on the [KSPField]");
            }
        }
        private void Start()
        {
            GameScenes scene = HighLogic.LoadedScene;

            if (scene == GameScenes.MAINMENU)
            {
                if (!SEP_Utilities.partModulesLoaded)
                {
                    SEP_Utilities.loadPartModules();
                }

                if (!SEP_Utilities.UIWindowReflectionLoaded)
                {
                    SEP_Utilities.assignReflectionMethod();
                }
            }

            if (!(scene == GameScenes.FLIGHT || scene == GameScenes.TRACKSTATION || scene == GameScenes.SPACECENTER))
            {
                running = false;
                Destroy(gameObject);
            }

            if (ResearchAndDevelopment.GetTechnologyState(transmissionNode) == RDTech.State.Available)
            {
                transmissionUpgrade = true;
            }
            else
            {
                transmissionUpgrade = false;
            }

            if (running)
            {
                Destroy(gameObject);
            }

            if (scene == GameScenes.FLIGHT)
            {
                StartCoroutine(attachWindowListener());
            }

            instance = this;

            running = true;

            GameEvents.onLevelWasLoaded.Add(onReady);
        }