示例#1
0
        public static void GoEVA()
        {
            List <ProtoCrewMember> crew = FlightGlobals.ActiveVessel.GetVesselCrew();

            for (int i = 0; i < crew.Count; i++)
            {
                ProtoCrewMember pcm = crew[i];
                if (pcm != null && HighLogic.CurrentGame.Parameters.Flight.CanEVA)
                {
                    if (pcm.KerbalRef.eyeTransform == InternalCamera.Instance.transform.parent)
                    {
                        if (!(pcm.KerbalRef.state == Kerbal.States.ALIVE &&
                              !pcm.KerbalRef.InPart.packed &&
                              HighLogic.CurrentGame.Parameters.Flight.CanEVA &&
                              !pcm.KerbalRef.InPart.NoAutoEVA &&
                              !pcm.inactive &&
                              pcm.type != ProtoCrewMember.KerbalType.Tourist &&
                              (GameVariables.Instance.UnlockedEVA(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex)) ||
                               (FlightGlobals.ActiveVessel.mainBody == Planetarium.fetch.Home && FlightGlobals.ActiveVessel.LandedOrSplashed))))
                        {
                            ScreenMessages.PostScreenMessage(GameVariables.Instance.GetEVALockedReason(FlightGlobals.ActiveVessel, pcm), 5);
                            return;
                        }
                        FlightEVA.SpawnEVA(pcm.KerbalRef);
                        CameraManager.Instance.SetCameraFlight();
                        pcm.KerbalRef.state = Kerbal.States.BAILED_OUT;
                        break;
                    }
                }
            }
        }
示例#2
0
#pragma warning disable IDE0051
        void Start()
        {
            windowId = this.GetInstanceID();
            GameEvents.onPlanetariumTargetChanged.Add(TargetChange);
            GameEvents.onGameSceneLoadRequested.Add(CloseWindow);
            trackingLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation);
        }
        public void Clear( )
        {
            var _logger = new Logger("UnlockedExperimentList");

            _unlockedExperiments = new Dictionary <string, bool>( );
            float RnDLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment);

            //			_logger.Trace( "RnDLevel " + RnDLevel );



/* According to the UI you need the AstronautComplex upgraded to do surface samples.  Turns out that is rubbish.
 *                      float AstroLevel = ScenarioUpgradeableFacilities.GetFacilityLevel( SpaceCenterFacility.AstronautComplex );*/



            _unlockedExperiments.Add("crewReport", true);
            _unlockedExperiments.Add("evaReport", true);
            if (RnDLevel >= 0.5)
            {
                _unlockedExperiments.Add("surfaceSample", true);
            }
            else
            {
                _unlockedExperiments.Add("surfaceSample", false);
            }
        }
示例#4
0
        public void DoAllScience()
        {
            foreach (Part eachPart in vessel.Parts)                                 //Cycle through each part on the vessel
            {
                foreach (ModuleScienceExperiment thisExperiment
                         in eachPart.FindModulesImplementing <ModuleScienceExperiment>()) //Cycle through each ModuleScienceExperiment module in the part
                {
                    if (thisExperiment != null)                                           //Only continue it if it's actually a ModuleScienceExperiment (which it should always be but hey)
                    {
//						print ("AYA: Start Experiment Dump");
//						print ("AYA: thisExperiment.ClassName " + thisExperiment.ClassName);
//						print ("AYA: thisExperiment.collectActionName " + thisExperiment.collectActionName);
//						print ("AYA: thisExperiment.collectWarningText " + thisExperiment.collectWarningText);
//						print ("AYA: thisExperiment.collectWarningText " + thisExperiment.collectWarningText);
//						print ("AYA: thisExperiment.cooldownString " + thisExperiment.cooldownString);
//						print ("AYA: thisExperiment.dataIsCollectable " + thisExperiment.dataIsCollectable);
//						print ("AYA: thisExperiment.deployableSeated " + thisExperiment.deployableSeated);
//						print ("AYA: thisExperiment.Deployed " + thisExperiment.Deployed);
//						print ("AYA: thisExperiment.enabled " + thisExperiment.enabled);
//						print ("AYA: thisExperiment.experimentActionName " + thisExperiment.experimentActionName);
//						print ("AYA: thisExperiment.experimentID " + thisExperiment.experimentID);
//						print ("AYA: thisExperiment.GUIName " + thisExperiment.GUIName);
//						print ("AYA: thisExperiment.Inoperable " + thisExperiment.Inoperable);
//						print ("AYA: thisExperiment.isActiveAndEnabled " + thisExperiment.isActiveAndEnabled);
//						print ("AYA: thisExperiment.isEnabled " + thisExperiment.isEnabled);
//						print ("AYA: thisExperiment.moduleName " + thisExperiment.moduleName);
//						print ("AYA: thisExperiment.name " + thisExperiment.name);
//						print ("AYA: thisExperiment.rerunnable " + thisExperiment.rerunnable);
//						print ("AYA: thisExperiment.resetActionName " + thisExperiment.resetActionName);
//						print ("AYA: thisExperiment.resettable " + thisExperiment.resettable);
//						print ("AYA: thisExperiment.resettableOnEVA " + thisExperiment.resettableOnEVA);
//						print ("AYA: thisExperiment.reviewActionName " + thisExperiment.reviewActionName);
//						print ("AYA: thisExperiment.experiment.experimentTitle " + thisExperiment.experiment.experimentTitle);
//						print ("AYA: thisExperiment.experiment.requiredExperimentLevel " + thisExperiment.experiment.requiredExperimentLevel);
                        if (thisExperiment.experimentActionName == "Take Surface Sample")                                       //If it's a surface sample, we need to make sure it's not locked out.
                        {
                            if (ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment) > 0) // Are you allowed to do surface samples? NOTE: 0 is tier 1. 0.5 is tier 2. 1 is tier 3. These could change if more tiers are added.
                            {
                                if (!thisExperiment.Deployed)
                                {
                                    thisExperiment.DeployExperiment();                                      //Deploy the experiment if it's not already deployed
//									print ("AYA: Deployed Surface Sample that had not yet been deployed");
                                }
//								else print ("AYA: Did not deploy Surface Sample as it had previously been deployed.");
                            }
//							else print ("AYA: Did not deploy Surface Sample as R&D is the lowest tier.");
                        }
                        else
                        {
                            if (!thisExperiment.Deployed)
                            {
                                thisExperiment.DeployExperiment();                                  //Deploy the experiment if it's not already deployed
//								print ("AYA: Deployed experiment that had not been previously deployed.");
                            }
//							else print ("AYA: Did not deploy experiment as it had previously been deployed.");
                        }
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// Check whether the mod should be available for use in the current save.
        /// We need patched conics and flight planning.
        /// </summary>
        /// <param name="reason">User friendly explanation of why we're not available</param>
        /// <returns>
        /// true if unlocked, false if locked
        /// </returns>
        private static bool unlocked(out string reason)
        {
            if (ScenarioUpgradeableFacilities.Instance == null)
            {
                reason = "";
                return(true);
            }
            var gVars        = GameVariables.Instance;
            var stationLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation);
            var stationOK    = gVars.GetOrbitDisplayMode(stationLevel) == GameVariables.OrbitDisplayMode.PatchedConics;
            var missionLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.MissionControl);
            var missionOK    = gVars.UnlockedFlightPlanning(missionLevel);

            if (!stationOK)
            {
                reason = !missionOK ? "PlanningNode_unlockBothTooltip"
                                                    : "PlanningNode_unlockStationTooltip";
                return(false);
            }
            else
            {
                if (!missionOK)
                {
                    reason = "PlanningNode_unlockMisConTooltip";
                    return(false);
                }
                else
                {
                    reason = "";
                    return(true);
                }
            }
        }
示例#6
0
        public void Clear( )
        {
// var _logger = new Logger( "UnlockedInstrumentList" );
            _unlockedInstruments = new Dictionary <string, bool>( );
            float RnDLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment);

//			_logger.Trace( "RnDLevel " + RnDLevel );



/* According to the UI you need the AstronautComplex upgraded to do surface samples.  Turns out that is rubbish.  You just need to upgrade the science lab.
 * Upgrading the AstronautComplex does help with EVAs.  But there are always cargo bays _grin_
 * float AstroLevel = ScenarioUpgradeableFacilities.GetFacilityLevel( SpaceCenterFacility.AstronautComplex );*/



            _unlockedInstruments.Add("crewReport", true);
            _unlockedInstruments.Add("evaReport", true);
            if (RnDLevel >= 0.5)
            {
                _unlockedInstruments.Add("surfaceSample", true);
            }
            else
            {
                _unlockedInstruments.Add("surfaceSample", false);
            }
        }
示例#7
0
        private static void UpdateBuildRates()
        {
            if (!_ratesUpdated)
            {
                if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
                {
                    if (ScenarioUpgradeableFacilities.GetFacilityLevelCount(SpaceCenterFacility.VehicleAssemblyBuilding) >= 0)
                    {
                        _ratesUpdated = true;
                        KCTDebug.Log("Updating build rates");
                        foreach (KSCItem KSC in KCTGameStates.KSCs)
                        {
                            KSC?.RecalculateBuildRates();
                            KSC?.RecalculateUpgradedBuildRates();
                        }

                        KCTDebug.Log("Rates updated");

                        foreach (SpaceCenterFacility facility in Enum.GetValues(typeof(SpaceCenterFacility)))
                        {
                            KCTGameStates.BuildingMaxLevelCache[facility.ToString()] = ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility);
                            KCTDebug.Log($"Cached {facility} max at {KCTGameStates.BuildingMaxLevelCache[facility.ToString()]}");
                        }
                    }
                }
                else
                {
                    _ratesUpdated = true;
                }
            }
        }
示例#8
0
        private float FacilityCosts()
        {
            // facility upkeep should represent personnel wages and things like repairs.
            // Each of these comes as a fraction of the maximum level so all we really have to do is figure the maximum cost for each.
            float total = 0.0f;

            // what if this useless example of shit gameplay did something for us? see below?
            float admin     = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Administration);
            float admAdjust = 10 - admin; // from less than 100% to 90% costs. Work smarter, not harder.

            admin = admin * 1.0f;         // figure the facility cost now.

            // you're cool, you're cool, you're cool...
            float astro   = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);
            float launch  = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.LaunchPad);
            float mission = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.MissionControl);
            float randd   = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment);
            float runway  = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway);
            float sph     = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar);
            float track   = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation);
            float vab     = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding);

            // hey look, upgrading that fuckery did something for us that makes sense.
            total = (admin + astro + launch + mission + randd + runway + sph + track + vab) * admAdjust;
            return(0.0f); // gonna take some time to figure this one out.
        }
        public override bool MeetRequirements()
        {
            // Must have the "KIS" mod installed (otherwise Kemini is disabled anyway)
            if (!DependancyChecker.HasKIS)
            {
                return(false);
            }

            // Must have successfully reached orbit and landed a kerballed craft
            var progress = ProgressTracking.Instance.GetBodyTree(Planetarium.fetch.Home);

            if (progress == null || !progress.returnFromOrbit.IsCompleteManned)
            {
                return(false);
            }

            // Must be able to perform EVAs
            if (ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex) < 0.1f)
            {
                return(false);
            }

            // And must have unlocked the tech-tiers for the first KEES experiment and the Exposure bracket
            return(NE_Helper.IsPartTechAvailable(KEES_PEC));  // && NE_Helper.IsPartTechAvailable(KEES_PPMD));
        }
示例#10
0
        void Accept()
        {
            if (MissionControl.Instance == null)
            {
                return;
            }
            if (!MissionControl.Instance.toggleDisplayModeAvailable.isOn)
            {
                Log("You are not on the Available contracts", "QGUI");
                return;
            }
            if (MissionControl.Instance.selectedMission == null)
            {
                Log("There's no selected contract", "QGUI");
                return;
            }
            if (!MissionControl.Instance.btnAccept.IsInteractable())
            {
                Log("Can't accept this contract", "QGUI");
                return;
            }
            int _active = ContractSystem.Instance.GetActiveContractCount();
            int _accept = GameVariables.Instance.GetActiveContractsLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.MissionControl));

            if (_active >= _accept)
            {
                Log("You can't accept a new contract, you have " + _active + " active contracts and you can accept " + _accept + " contracts.", "QGUI");
                return;
            }
            MissionControl.Instance.btnAccept.onClick.Invoke();
            Log("Accepted a contract", "QGUI");
        }
示例#11
0
        // Update the Asteroids
        public void UpdateAsteroid(Asteroid asteroid, Double time)
        {
            List <Vessel> spaceObjects = FlightGlobals.Vessels.Where(v => !v.DiscoveryInfo.HaveKnowledgeAbout(DiscoveryLevels.StateVectors) && Math.Abs(v.DiscoveryInfo.GetSignalLife(Planetarium.GetUniversalTime())) < 0.01).ToList();
            Int32         limit        = Random.Range(asteroid.SpawnGroupMinLimit, asteroid.SpawnGroupMaxLimit);

            if (spaceObjects.Any())
            {
                Vessel vessel = spaceObjects.First();
                Debug.Log("[Kopernicus] " + vessel.vesselName + " has been untracked for too long and is now lost.");
                vessel.Die();
            }
            else if (GameVariables.Instance.UnlockedSpaceObjectDiscovery(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation)))
            {
                Int32 untrackedCount = FlightGlobals.Vessels.Count(v => !v.DiscoveryInfo.HaveKnowledgeAbout(DiscoveryLevels.StateVectors)) - spaceObjects.Count;
                Int32 max            = Mathf.Max(untrackedCount, limit);
                if (max <= untrackedCount)
                {
                    return;
                }
                if (Random.Range(0, 100) < asteroid.Probability)
                {
                    UInt32 seed = (UInt32)Random.Range(0, Int32.MaxValue);
                    Random.InitState((Int32)seed);
                    SpawnAsteroid(asteroid, seed);
                }
                else
                {
                    Debug.Log("[Kopernicus] No new objects this time. (Probability is " + asteroid.Probability.Value + "%)");
                }
            }
        }
示例#12
0
            public LaunchConfig(string craftDirectory, string name, string launchSite, bool recover)
            {
                LaunchSite = launchSite;
                Recover    = recover;
                // Load the vessel and its default crew
                if (craftDirectory == "VAB")
                {
                    EditorDriver.editorFacility = EditorFacility.VAB;
                }
                else if (craftDirectory == "SPH")
                {
                    EditorDriver.editorFacility = EditorFacility.SPH;
                }
                else
                {
                    throw new ArgumentException("Invalid craftDirectory, should be VAB or SPH");
                }
                Path     = ShipConstruction.GetSavePath(name);
                template = ShipConstruction.LoadTemplate(Path);
                if (template == null)
                {
                    throw new InvalidOperationException("Failed to load template for vessel");
                }
                manifest = HighLogic.CurrentGame.CrewRoster.DefaultCrewForVessel(
                    template.config, VesselCrewManifest.FromConfigNode(template.config));

                facility      = (craftDirectory == "SPH") ? SpaceCenterFacility.SpaceplaneHangar : SpaceCenterFacility.VehicleAssemblyBuilding;
                facilityLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(facility);
                site          = (launchSite == "Runway") ? SpaceCenterFacility.Runway : SpaceCenterFacility.LaunchPad;
                siteLevel     = ScenarioUpgradeableFacilities.GetFacilityLevel(site);
                isPad         = (site == SpaceCenterFacility.LaunchPad);
            }
        public override Vector3 GetCraftSizeLimit(float editorNormLevel, bool isPad)
        {
            int levels = isPad
                ? (useBuildingLaunchPad ? levelsVAB : levelsLaunchPad)
                : (useBuildingRunway ? levelsSPH : levelsRunway);


            if (isPad && useBuildingLaunchPad)
            {
                editorNormLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding);
            }

            if (!isPad && useBuildingRunway)
            {
                editorNormLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar);
            }


            if (isPad && (craftSizeLimitLaunchPad == null || craftSizeLimitLaunchPad.Length != levels))
            {
                debugLog("craftSizeLimitLaunchPad wrong size");
                return(original.GetCraftSizeLimit(editorNormLevel, true));
            }
            if (!isPad && (craftSizeLimitRunway == null || craftSizeLimitRunway.Length != levels))
            {
                debugLog("craftSizeLimitRunway wrong size");
                return(original.GetCraftSizeLimit(editorNormLevel, false));
            }

            return(NormLevelToArrayValue(editorNormLevel, isPad ? craftSizeLimitLaunchPad : craftSizeLimitRunway));
        }
示例#14
0
        private IEnumerator UpdateBuildRates()
        {
            do
            {
                yield return(new WaitForFixedUpdate());    // No way to know when KSP has finally initialized the ScenarioUpgradeableFacilities data
            } while (HighLogic.LoadedScene == GameScenes.SPACECENTER && ScenarioUpgradeableFacilities.GetFacilityLevelCount(SpaceCenterFacility.VehicleAssemblyBuilding) < 0);

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER &&
                ScenarioUpgradeableFacilities.GetFacilityLevelCount(SpaceCenterFacility.VehicleAssemblyBuilding) >= 0)
            {
                KCTDebug.Log("Updating build rates");
                foreach (KSCItem KSC in KCTGameStates.KSCs)
                {
                    KSC?.RecalculateBuildRates();
                    KSC?.RecalculateUpgradedBuildRates();
                }

                KCTDebug.Log("Rates updated");

                foreach (SpaceCenterFacility facility in Enum.GetValues(typeof(SpaceCenterFacility)))
                {
                    KCTGameStates.BuildingMaxLevelCache[facility.ToString()] = ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility);
                    KCTDebug.Log($"Cached {facility} max at {KCTGameStates.BuildingMaxLevelCache[facility.ToString()]}");
                }
            }
        }
示例#15
0
        public void Start()
        {
            DiscoverProtoVesselAntennas(protoVesselAntennaCache);
            iTechLevel = RACommNetScenario.GroundStationTechLevel;
            float fTSLvl = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation);

            currentGroundStationTechLevel = Mathf.RoundToInt(RACommNetScenario.MaxTL * (HighLogic.CurrentGame.Mode == Game.Modes.CAREER ? fTSLvl : 1));
            GameEvents.onEditorPodDeleted.Add(OnEditorRestart);
            GameEvents.onEditorRestart.Add(OnEditorRestart);
            windowStyle = new GUIStyle(HighLogic.Skin.window)
            {
                alignment = TextAnchor.UpperLeft
            };
            boxStyle = new GUIStyle(HighLogic.Skin.box)
            {
                alignment = TextAnchor.UpperCenter
            };

            // Terminology: peer antenna is on the left of the GUI, and will move around.
            // Fixed antenna is on the right of the GUI, and will be positioned at/near homeworld surface.

            fixedGO      = new GameObject("Planning.Antenna.Fixed");
            peerNearGO   = new GameObject("Planning.Antenna.Near");
            peerFarGO    = new GameObject("Planning.Antenna.Far");
            fixedNode    = new RACommNode(fixedGO.transform);
            peerNearNode = new RACommNode(peerNearGO.transform);
            peerFarNode  = new RACommNode(peerFarGO.transform);

            ConvertDistance(distanceMax, out double tMax, out dMaxMultIndex);
            ConvertDistance(distanceMin, out double tMin, out dMinMultIndex);
            dMin = $"{tMin:F3}";
            dMax = $"{tMax:F3}";
        }
        public void Awake()
        {
            rect = this.GetComponent <RectTransform>();

            EnablePlanner  = GameObject.Find("EnablePlanner").GetComponent <Toggle>();
            DetectAntennas = GameObject.Find("DetectAntennas").GetComponent <Toggle>();
            DetectAntennas.onValueChanged.AddListener(delegate { onDetectAntennasValueChanged(DetectAntennas); });
            DetectRelays = GameObject.Find("DetectRelays").GetComponent <Toggle>();
            DetectRelays.onValueChanged.AddListener(delegate { onDetectRelaysValueChanged(DetectRelays); });

            CelestialBodies = GameObject.Find("PlannerPlanetDropdown").GetComponent <Dropdown>();
            CelestialBodies.onValueChanged.AddListener(delegate { onDropdownMenuValueChanged(CelestialBodies.value); });

            DistanceSlider = GameObject.Find("PlannerDistanceSlider").GetComponent <Slider>();
            DistanceSlider.onValueChanged.AddListener(delegate { onSliderValueChanged(DistanceSlider.value); });
            DistanceSliderLabel = GameObject.Find("CurrentDistance").GetComponent <Text>();

            DataRate                = GameObject.Find("PlannerDataRate");
            CurrentDataRateLabel    = DataRate.GetChild("CurrentDataRate").GetComponent <Text>();
            MaxDataRateLabel        = DataRate.GetChild("MaxDataRate").GetComponent <Text>();
            SignalStrengthLabel     = GameObject.Find("PlannerStrength").GetChild("signalstrength").GetComponent <Text>();
            ActiveTransmittersLabel = GameObject.Find("PlannerActiveTransmitters").GetChild("activeantennas").GetComponent <Text>();

            DSNLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation);
            DSNPower = GameVariables.Instance.GetDSNRange(DSNLevel);

            Bodies.ResearchBodiesAPI = Bodies.VerifyResearchBodiesAPI();
            celestialBodies          = Bodies.GetCelestialBodies();

            FillDropdownMenu(celestialBodies);

            ChangeSliderValues(Convert.ToSingle(Bodies.getMinDistance(FlightGlobals.GetHomeBody(), celestialBodies[0])),
                               Convert.ToSingle(Bodies.getMaxDistance(FlightGlobals.GetHomeBody(), celestialBodies[0])));
        }
示例#17
0
 public void UnlockTechnologies(bool all = true, int maxDepth = 999)
 {
     //bool flag = !this.RnDOpen;
     //if (!flag)
     if (this.RnDOpen)
     {
         this.unlockTechnology = TechnologyUnlock.OFF;
         float scienceCostLimit = GameVariables.Instance.GetScienceCostLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment));
         foreach (RDNode current in RDController.Instance.nodes)
         {
             if (NodeDepth(current) <= maxDepth)
             {
                 double currentFunds = 0;
                 if (!all)
                 {
                     currentFunds = Funding.Instance.Funds;
                     Funding.Instance.AddFunds(CareerManager.MONEY_LOCK - Funding.Instance.Funds, TransactionReasons.Cheating);
                 }
                 bool flag2 = current.tech != null && (float)current.tech.scienceCost < scienceCostLimit;
                 if (flag2)
                 {
                     current.tech.UnlockTech(true);
                 }
                 if (!all)
                 {
                     Funding.Instance.AddFunds(-Funding.Instance.Funds, TransactionReasons.Cheating);
                     Funding.Instance.AddFunds(currentFunds, TransactionReasons.Cheating);
                 }
             }
         }
     }
 }
示例#18
0
        public override ContractParameter Generate(Contract contract)
        {
            //ContractConfigurator.Duration value = new ContractConfigurator.Duration();
            double durationValue = 1;

            for (int i = 0; i < PSystemSetup.Instance.SpaceCenterFacilities.Length; i++)
            {
                if (PSystemSetup.Instance.SpaceCenterFacilities[i].name == facility)
                {
                    int level = Mathf.RoundToInt(ScenarioUpgradeableFacilities.GetFacilityLevel(facility) + 1);
                    if (level == 1)
                    {
                        durationValue = 0.5;
                        break;
                    }
                    if (level == 2)
                    {
                        durationValue = 0.25;
                        break;
                    }
                }
            }
            durationValue *= KSPUtil.dateTimeFormatter.Year;

            return(new ContractConfigurator.Parameters.Duration(durationValue, preWaitText, waitingText, completionText, startCriteria, parameter));
        }
示例#19
0
        private void Research()
        {
            if (m_node.state == RDTech.State.Available)
            {
                throw new KOSException("Node is already purchased");
            }

            var host = ResearchAndDevelopment.Instance;

            if (host != null)
            {
                if (!CurrencyModifierQuery.RunQuery(TransactionReasons.RnDTechResearch, 0f, -m_node.scienceCost, 0f).CanAfford(delegate(Currency c)
                {
                    throw new KOSException("Not enough science to research this node");
                }))
                {
                    throw new KOSException("Not enough funds");
                }
                float scienceCostLimit = GameVariables.Instance.GetScienceCostLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment));
                if ((float)m_node.scienceCost > scienceCostLimit)
                {
                    throw new KOSException("Node exceeds science cost limit");
                }
                host.AddScience(-m_node.scienceCost, TransactionReasons.RnDTechResearch);
            }
            ResearchAndDevelopment.Instance.UnlockProtoTechNode(m_node);
            m_node = ResearchAndDevelopment.Instance.GetTechState(m_node.techID);
        }
示例#20
0
        public static double GetREALSignal(CommNet.CommLink link, bool aIsRelay = true)
        {
            Vessel  vesselA = link.a.transform.GetComponent <Vessel> ();
            double  powerA  = GetActualVesselPower(vesselA, aIsRelay);
            double  powerB;
            Vector3 positionB;

            if (link.b.isHome)
            {
                positionB = link.b.position;
                powerB    = GameVariables.Instance.GetDSNRange
                                (ScenarioUpgradeableFacilities.GetFacilityLevel
                                    (SpaceCenterFacility.TrackingStation));
            }
            else
            {
                Vessel vesselB = link.b.transform.GetComponent <Vessel> ();
                powerB    = GetActualVesselPower(vesselB, true);
                positionB = vesselB.GetTransform().position;
            }

            double maxRange = GetRange(powerA, powerB);

            double distance = Vector3.Distance(vesselA.GetTransform().position, positionB);

            return(GetSignalStrength(maxRange, distance));
        }
示例#21
0
        public double GetTime(List <ProtoCrewMember> students)
        {
            double curTime = time;

            double level = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);

            curTime *= (1d - level * 0.5d);

            if (students == null || students.Count == 0 || !timeUseStupid)
            {
                return(curTime);
            }

            double averageStupid = 0d;
            int    sC            = students.Count;

            for (int i = sC; i-- > 0;)
            {
                averageStupid += students[i].stupidity;
            }

            averageStupid /= sC;

            return(curTime * UtilMath.Lerp(CrewHandler.Settings.trainingMissionStupidMin, CrewHandler.Settings.trainingMissionStupidMax, averageStupid));
        }
示例#22
0
        public void Start()
        {
            print($"AutoActions Version {Assembly.GetCallingAssembly().GetName().Version} loaded.");

            GameEvents.onEditorLoad.Add(OnShipLoad);

            bool isVab = EditorDriver.editorFacility == EditorFacility.VAB;

            _facilityName = isVab ? "VAB" : "SPH";

            LoadDefaultSettings();
            LoadPartModule();

            // Are action groups unlocked?
            if (_settings.GetValue("OverrideCareer").ParseNullableBool() == true)
            {
                _showCustomGroups = true;
                _showBasicGroups  = true;
            }
            else
            {
                var editorNormLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(
                    isVab
                                                ? SpaceCenterFacility.VehicleAssemblyBuilding
                                                : SpaceCenterFacility.SpaceplaneHangar);

                _showCustomGroups = GameVariables.Instance.UnlockedActionGroupsCustom(editorNormLevel, isVab);
                _showBasicGroups  = GameVariables.Instance.UnlockedActionGroupsStock(editorNormLevel, isVab);
            }
        }
示例#23
0
文件: Career.cs 项目: victorb/KOS
        /// <summary>
        /// Detect how good the tracking center is at seeing future SOI transfers (encounters, escapes, etc).
        /// </summary>
        /// <param name="reason">returns a string describing what would need upgrading to change the answer.</param>
        /// <returns>Maximum number of patches that can be predicted ahead (not including the current one).</returns>
        public static int PatchLimit(out string reason)
        {
            reason = "tracking station building";
            float buildingLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation);

            return(GameVariables.Instance.GetPatchesAheadLimit(buildingLevel));
        }
示例#24
0
        public void Start()
        {
            if (!HighLogic.CurrentGame.Parameters.CustomParams <AntennaHelperSettings> ().enableInEditor)
            {
                Destroy(this);
                return;
            }

            instance = this;

            trackingStationLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation);
            targetPower          = GameVariables.Instance.GetDSNRange(trackingStationLevel);
            targetName           = Localizer.Format("#autoLOC_AH_0015") + " " + (int)(trackingStationLevel * 2 + 1);

            GetShipList();

            GetAntennaPartList();

            CreateAntennaList();
            DoTheMath();

            GameEvents.onGUIApplicationLauncherReady.Add(AddToolbarButton);
            GameEvents.onGUIApplicationLauncherDestroyed.Add(RemoveToolbarButton);

            GameEvents.onEditorLoad.Add(VesselLoad);
            GameEvents.onEditorPartEvent.Add(PartEvent);
            GameEvents.onEditorPodPicked.Add(PodPicked);
            GameEvents.onEditorPodDeleted.Add(PodDeleted);

            GameEvents.onGameSceneSwitchRequested.Add(QuitEditor);
        }
示例#25
0
        public void OnContractAccepted(Contract contract)
        {
            //Only if we're restricting classes
            if (KolonyACOptions.KolonistRescueEnabled)
            {
                return;
            }

            ConfigNode contractData = new ConfigNode("CONTRACT");

            contract.Save(contractData);
            int type = contractData.HasValue("recoveryType") ? int.Parse(contractData.GetValue("recoveryType")) : 0;

            if (type != 1 && type != 3)
            {
                return;
            }

            string kerbalName = contractData.GetValue("kerbalName");

            if (!string.IsNullOrEmpty(kerbalName))
            {
                if (HighLogic.CurrentGame.CrewRoster.Exists(kerbalName))
                {
                    HighLogic.CurrentGame.CrewRoster.Remove(kerbalName);
                }

                string newTrait = getRandomTrait();
                var    newKerb  = HighLogic.CurrentGame.CrewRoster.GetNewKerbal(ProtoCrewMember.KerbalType.Crew);
                newKerb.ChangeName(kerbalName);
                if (KolonyACOptions.VeteranRescueEnabled)
                {
                    var KLevel  = rnd.Next(6);
                    var acLevel = 5;
                    if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
                    {
                        acLevel = (int)ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);
                    }
                    var xp = HighLogic.CurrentGame.Parameters.CustomParams <GameParameters.AdvancedParams>().KerbalExperienceEnabled(HighLogic.CurrentGame.Mode);

                    if (KLevel > 0)
                    {
                        var logName       = "RecruitementLevel" + KLevel;
                        var homeworldName = FlightGlobals.Bodies.Where(cb => cb.isHomeWorld).FirstOrDefault().name;
                        newKerb.flightLog.AddEntry(logName, homeworldName);
                        newKerb.ArchiveFlightLog();
                        newKerb.experience      = CustomAstronautComplexUI.GetExperienceNeededFor(KLevel);
                        newKerb.experienceLevel = KLevel;
                    }
                    if (acLevel == 5 || !xp)
                    {
                        newKerb.experience      = 9999;
                        newKerb.experienceLevel = 5;
                    }
                }
                KerbalRoster.SetExperienceTrait(newKerb, newTrait);
                newKerb.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;
            }
        }
示例#26
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary> Calculates the level (1..3) of the facility specified.</summary>
        ///
        /// <param name="facility"> The facility to fetch the level for.</param>
        ///
        /// <returns> The level of the facility. This will be 1..3 where 1 is the initial level on a new
        ///           career game and 3 is fully upgraded.</returns>
        private int FacilityLevel(SpaceCenterFacility facility)
        {
            var level = ScenarioUpgradeableFacilities.GetFacilityLevel(facility); // 0 .. 1
            var count = ScenarioUpgradeableFacilities
                        .GetFacilityLevelCount(facility);                         // max upgrades allowed (usually 2)

            return((int)(level * count) + 1);
        }
示例#27
0
        public bool RequirementMet(out string unmetReason)
        {
            int currentLevel = (int)Math.Round(ScenarioUpgradeableFacilities.GetFacilityLevel(facility) *
                                               ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility)) + 1;

            unmetReason = "Current level: " + currentLevel;
            return(currentLevel >= level);
        }
示例#28
0
        public override bool RequirementMet(ConfiguredContract contract)
        {
            int level = (int)Math.Round(ScenarioUpgradeableFacilities.GetFacilityLevel(facility) *
                                        ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility)) + 1;

            return(level == 0 && contract != null && contract.ContractState == Contracts.Contract.State.Active ||
                   level >= minLevel && level <= maxLevel);
        }
示例#29
0
文件: Career.cs 项目: victorb/KOS
        /// <summary>
        /// Detect whether we'll allow arbitrary use of :DOACTION from partmodules, which
        /// depends on whether at least one of the editors (VAB,SPH) allows custom action groups:
        /// </summary>
        /// <param name="reason">returns a string describing what would need upgrading to change the answer.</param>
        /// <returns>true if it can. false if it cannot.</returns>
        public static bool CanDoActions(out string reason)
        {
            reason = "vehicle assembly building or space plane hangar";
            float buildingLevel = Math.Max(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding),
                                           ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar));

            return(GameVariables.Instance.UnlockedActionGroupsCustom(buildingLevel));
        }
示例#30
0
        public void reloadUpgradeableAntennas(int techlvl = 0)
        {
            if (this.UpgradeableCosAngle != String.Empty && this.UpgradeableDish != String.Empty && this.UpgradeableOmni != String.Empty)
            {
                return;
            }

            int missionControlTechLevel = techlvl;

            if (missionControlTechLevel == 0)
            {
                missionControlTechLevel = (int)((2 * ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation)) + 1);
            }

            // when the option is disabled, use always the thrid tech lvl
            if (!RTSettings.Instance.UpgradeableMissionControlAntennas)
            {
                missionControlTechLevel = 3;
            }

            RTLog.Verbose("Reload upgradeable Antennas, TechLvl: {0}", RTLogLevel.LVL4, missionControlTechLevel);

            if (this.UpgradeableOmni != String.Empty)
            {
                int      missionControlTechLevelForOmni = missionControlTechLevel;
                string[] omniRanges = this.UpgradeableOmni.Split(';');
                if (missionControlTechLevelForOmni > omniRanges.Count())
                {
                    missionControlTechLevelForOmni = omniRanges.Count();
                }

                float.TryParse(omniRanges[missionControlTechLevelForOmni - 1], out this.Omni);
            }

            if (this.UpgradeableDish != String.Empty)
            {
                int      missionControlTechLevelForDish = missionControlTechLevel;
                string[] dishRanges = this.UpgradeableOmni.Split(';');
                if (missionControlTechLevelForDish > dishRanges.Count())
                {
                    missionControlTechLevelForDish = dishRanges.Count();
                }

                float.TryParse(dishRanges[missionControlTechLevelForDish - 1], out this.Dish);
            }

            if (this.UpgradeableCosAngle != String.Empty)
            {
                int      missionControlTechLevelForCAngle = missionControlTechLevel;
                string[] cAngleRanges = this.UpgradeableOmni.Split(';');
                if (missionControlTechLevelForCAngle > cAngleRanges.Count())
                {
                    missionControlTechLevelForCAngle = cAngleRanges.Count();
                }

                double.TryParse(cAngleRanges[missionControlTechLevelForCAngle - 1], out this.CosAngle);
            }
        }