Ejemplo n.º 1
0
 public TestBenchView() :
     base("Blah", DialogWidth, DialogHeight)
 {
     WindowTitle = Localizer.Format(BARISScenario.TestBenchTitle);
     Resizable   = false;
 }
Ejemplo n.º 2
0
        public void FixedUpdate()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            if (activationCostEC <= 0.001f)
            {
                return;
            }
            if (!IsActivated)
            {
                status = Localizer.Format(kOffStatus);
                return;
            }

            //Catchup on data generation
            if (lastUpdateTime > 0f)
            {
                double elapsedTime = Planetarium.GetUniversalTime() - lastUpdateTime;
                if (elapsedTime > 1.0f)
                {
                    totalGuidanceData += dataGenerationRate * (float)elapsedTime;
                    if (totalGuidanceData > maxGuidanceData)
                    {
                        totalGuidanceData = maxGuidanceData;
                    }
                    lastUpdateTime = Planetarium.GetUniversalTime();
                }
            }

            //Request the required electric charge
            double currentAmount = 0f;
            double maxAmount     = 0;

            this.part.vessel.resourcePartSet.GetConnectedResourceTotals(resourceDef.id, out currentAmount, out maxAmount, true);
            currentAmount *= TimeWarp.deltaTime;
            double ecPerUpdate = activationCostEC * TimeWarp.deltaTime;

            if (currentAmount > ecPerUpdate)
            {
                //Pay the EC cost
                status = Localizer.Format(kNominalStatus);
                this.part.RequestResource(resourceDef.id, ecPerUpdate, ResourceFlowMode.ALL_VESSEL);

                //Generate trajectory data
                totalGuidanceData += dataGenerationRate * TimeWarp.deltaTime;
                if (totalGuidanceData > maxGuidanceData)
                {
                    totalGuidanceData = maxGuidanceData;
                }
                pipelineWidow.totalGuidanceData = this.totalGuidanceData;
                lastUpdateTime = Planetarium.GetUniversalTime();
            }

            //Not enough EC to run the pipe endpoint
            else
            {
                status = Localizer.Format(kNoECStatus);
            }
        }
Ejemplo n.º 3
0
        protected override void DrawWindowContents(int windowId)
        {
            float costScience = 0f;
            float costFunds = 0f;
            bool  canAffordScience, canAffordFunds;

            if (qualityControlModules == null)
            {
                GUILayout.Label("<color=yellow><b>" + Localizer.Format(BARISScenario.TestBenchWarning) + "</b></color>");
                return;
            }

            calculateCostsAndReliability();

            //Get science cost
            costScience = scienceCost * experienceModifier;

            //Get funds cost
            costFunds = fundsCost * experienceModifier;

            //Reputation gives a discount: 20% * (current rep / 1000)
            //Only applies in career mode.
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                float reputation = BARISScenario.ReputationCostModifier * (Reputation.Instance.reputation / Reputation.RepRange);
                if (reputation > 0.0f)
                {
                    costScience -= (costScience * reputation);
                    costFunds   -= (costFunds * reputation);
                }
            }

            //Part count & reliability
            GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.TestBenchPartCount) + "</b>" + qualityControlModules.Length + "</color>");

            GUILayout.BeginScrollView(originPoint, infoPanelOptions);
            GUILayout.Label("<color=white><b> " + Localizer.Format(BARISScenario.TestBenchReliabilityBefore) + "</b>" + reliability + "/" + maxReliability + "</color>");
            GUILayout.Label("<color=white><b> " + Localizer.Format(BARISScenario.TestBenchReliabilityAfter) + "</b>" + reliabilityAfter + "/" + maxReliabilityAfter + "</color>");
            GUILayout.EndScrollView();

            //Science cost to upgrade flight experience.
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                canAffordScience = ResearchAndDevelopment.CanAfford(costScience);

                GUILayout.BeginScrollView(originPoint, infoPanelOptions);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(scienceIcon, buttonOptions) && canAffordScience)
                {
                    ResearchAndDevelopment.Instance.AddScience(-costScience, TransactionReasons.Any);
                    addFlightExperience();
                }
                if (canAffordScience)
                {
                    GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.TestBenchScienceCost) + "</b>" + string.Format("{0:n2}", costScience) + "</color>");
                }
                else
                {
                    GUILayout.Label("<color=red><b>" + Localizer.Format(BARISScenario.TestBenchScienceCost) + "</b>" + string.Format("{0:n2}", costScience) + "</color>");
                }
                GUILayout.EndHorizontal();
                GUILayout.EndScrollView();
            }

            //Funds cost to upgrade flight experience.
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                canAffordFunds = Funding.CanAfford(costFunds);

                GUILayout.BeginScrollView(originPoint, infoPanelOptions);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(fundsIcon, buttonOptions) && canAffordFunds)
                {
                    Funding.Instance.AddFunds(-costFunds, TransactionReasons.Any);
                    addFlightExperience();
                }
                if (canAffordFunds)
                {
                    GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.TestBenchFundsCost) + "</b>" + string.Format("{0:n2}", costFunds) + "</color>");
                }
                else
                {
                    GUILayout.Label("<color=red><b>" + Localizer.Format(BARISScenario.TestBenchFundsCost) + "</b>" + string.Format("{0:n2}", costFunds) + "</color>");
                }
                GUILayout.EndHorizontal();
                GUILayout.EndScrollView();
            }

            //How much experience to add
            GUILayout.BeginHorizontal();
            GUILayout.Label("<color=white>" + Localizer.Format(BARISScenario.TestBenchExpToAdd) + "</color>");
            buttonIndex = GUILayout.SelectionGrid(buttonIndex, experienceModifiers, 3);
            GUILayout.EndHorizontal();

            switch (buttonIndex)
            {
            case 0:
                experienceModifier = 1;
                break;

            case 1:
                experienceModifier = 5;
                break;

            case 2:
                experienceModifier = 10;
                break;
            }
        }
Ejemplo n.º 4
0
 public VehicleIntegrationStatusView() :
     base("Blah", DialogWidth, DialogHeight)
 {
     WindowTitle = Localizer.Format(BARISScenario.EditorViewTitle);
     Resizable   = false;
 }
Ejemplo n.º 5
0
        protected override void PostProcess(ConverterResults result, double deltaTime)
        {
            base.PostProcess(result, deltaTime);
            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }

            //Check activation
            if (IsActivated == false)
            {
                lodeStatus = Localizer.Format(statusNAName);
                return;
            }

            //Check broken
            if (isBroken)
            {
                StopResourceConverter();
                return;
            }

            //Check situation
            if (this.part.vessel.situation != Vessel.Situations.PRELAUNCH && this.part.vessel.situation != Vessel.Situations.LANDED)
            {
                lodeStatus = Localizer.Format(statusNAName);

                //Record the time delta for catch-up purposes.
                if (deltaTime >= TimeWarp.fixedDeltaTime)
                {
                    totalDelta += deltaTime;
                }
                return;
            }

            //Check nearest lode
            if (nearestLode == null)
            {
                UpdateLode();
                if (nearestLode == null)
                {
                    lodeStatus = Localizer.Format(statusNoNearbyName);
                    totalDelta = 0;
                    return;
                }
            }

            //Check amount remaining
            if (nearestLode.amountRemaining == 0)
            {
                lodeStatus = Localizer.Format(statusDepletedName);
                return;
            }

            //Check storage space
            double currentAmount;
            double maxAmount;

            this.part.vessel.resourcePartSet.GetConnectedResourceTotals(outputDef.id, out currentAmount, out maxAmount, true);

            if (maxAmount < 0.0001)
            {
                lodeStatus = Localizer.Format(statusFullName);
                return;
            }
            if (currentAmount / maxAmount > 0.999999)
            {
                lodeStatus = Localizer.Format(statusFullName);
                return;
            }

            //Ok, we have some room. Calculate how much to request from the lode.
            //Base is 1 unit of resource per second, modified by efficiency and deltaTime.
            //Make sure we go through the processing loop at least once.
            totalDelta += deltaTime;
            double requestAmount = Efficiency * EfficiencyBonus * totalDelta;

            if (requestAmount < 0.0001f)
            {
                Debug.Log("No units of resource to request!");
                return;
            }

            //Make sure we don't pull more than we need.
            double maxRequestAmount = maxAmount - currentAmount;

            if (requestAmount > maxRequestAmount)
            {
                requestAmount = maxRequestAmount;
            }

            //Make sure the lode has enough
            if (nearestLode.amountRemaining < requestAmount)
            {
                requestAmount = nearestLode.amountRemaining;
            }

            //Now we can do our business. Add the resource to the vessel.
            double amountObtained = Math.Abs(this.part.RequestResource(outputDef.id, -requestAmount));

            totalDelta -= amountObtained;
            if (totalDelta < 0)
            {
                totalDelta = 0;
            }

            //Update the lode.
            nearestLode.amountRemaining -= amountObtained;
            if (nearestLode.amountRemaining < 0.0001)
            {
                nearestLode.amountRemaining = 0f;
            }

            //Status update
            lodeStatus = Localizer.Format(statusOKName);
        }
Ejemplo n.º 6
0
        public static string GetIntegrationStatusLabel(EditorBayItem editorBayItem)
        {
            //Build Time
            if (editorBayItem.totalIntegrationToAdd > 0 && editorBayItem.workerCount > 0)
            {
                int buildTime = editorBayItem.totalIntegrationToAdd / BARISScenario.Instance.GetWorkerProductivity(editorBayItem.workerCount, editorBayItem.isVAB);
                if (buildTime > 1)
                {
                    return("<color=white><b>" + Localizer.Format(BARISScenario.BuildTimeLabel) + "</b>" + buildTime + Localizer.Format(BARISScenario.BuildTimeLabelDays) + "</color>");
                }
                else if (buildTime == 1)
                {
                    return("<color=white><b>" + Localizer.Format(BARISScenario.BuildTimeLabel) + "</b>" + buildTime + Localizer.Format(BARISScenario.BuildTimeLabelOneDay) + "</color>");
                }
                else
                {
                    return("<color=white><b>" + Localizer.Format(BARISScenario.BuildTimeLabel) + "</b>" + Localizer.Format(BARISScenario.BuildTimeLabelLessDay) + "</color>");
                }
            }

            //Vessel is completed.
            else if (editorBayItem.totalIntegrationToAdd == 0)
            {
                return("<color=white><b>" + Localizer.Format(BARISScenario.BuildTimeLabelStatus) + "</b>" + Localizer.Format(BARISScenario.BuildTimeLabelDone) + "</color>");
            }

            //No workers.
            else
            {
                return("<color=white><b>" + Localizer.Format(BARISScenario.BuildTimeLabelStatus) + "</b>" + Localizer.Format(BARISScenario.BuildTimeLabelNeedsWorkers) + "</color>");
            }
        }
Ejemplo n.º 7
0
        public bool SituationIsValid()
        {
            debugLog("SituationIsValid: checking...");
            GoldStrikeLode lode = null;

            //Do we have enough crew?
            if (minimumCrew > 0)
            {
                if (this.part.protoModuleCrew.Count < minimumCrew)
                {
                    ScreenMessages.PostScreenMessage(this.part.partInfo.title + "Must be staffed with at least " + minimumCrew + " crewmembers.", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER);
                    status = Localizer.Format(statusInsufficientCrewName);
                    return(false);
                }
            }

            //Can we prospect the location?
            switch (WBIPathfinderScenario.Instance.GetProspectSituation(this.part.vessel, out lode))
            {
            case ProspectSituations.InvalidVesselSituation:
                debugLog("Vessel situation not valid");
                ScreenMessages.PostScreenMessage("Vessel must be landed or in orbit/docked with an asteroid attached", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER);
                status = Localizer.Format(statusNAName);
                return(false);

            case ProspectSituations.LodeAlreadyExists:
                if (lode != null)
                {
                    debugLog("Situation not valid, existing lode found: " + lode.ToString());
                    string message = string.Format("You already found a vein of {0:s} at this location. It has {1:f2} units remaining.", lode.resourceName, lode.amountRemaining);
                    ScreenMessages.PostScreenMessage(message, kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER);
                    status = Localizer.Format(statusAlreadyProspectedName);
                }
                return(false);

            case ProspectSituations.NotEnoughDistance:
                debugLog("Vessel has not traveled enough distance between prospects");
                ScreenMessages.PostScreenMessage("Vessel must travel further before prospecting again.", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER);
                status = Localizer.Format(statusGoFartherName);
                if (!WBIPathfinderScenario.debugProspectAlwaysSuccessful)
                {
                    return(false);
                }
                else
                {
                    debugLog("Debug: Prospect is guaranteed");
                    return(true);
                }

            case ProspectSituations.AsteroidProspected:
                debugLog("Asteroid has already been prospected");
                ScreenMessages.PostScreenMessage("Asteroid has already been prospected.", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER);
                status = Localizer.Format(statusAlreadyProspectedName);
                if (!WBIPathfinderScenario.debugProspectAlwaysSuccessful)
                {
                    return(false);
                }
                else
                {
                    debugLog("Debug: Prospect is guaranteed");
                    return(true);
                }

            //A-OK
            default:
                status = Localizer.Format(statusReadyName);
                return(true);
            }
        }
Ejemplo n.º 8
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }

            //If we don't have a last prospect location then the distance is zero.
            if (vesselModule.HasLastProspectLocation() == false)
            {
                status = Localizer.Format(statusReadyName);
                nextProspectDistance = 0f;
                return;
            }

            //If we have an asteroid, then check its prospect status.
            //Priority is to check for captured asteroids before checking to see if we've prospected a particular planetary biome.
            if (asteroid != null)
            {
                if (WBIPathfinderScenario.Instance.IsAsteroidProspected(asteroid))
                {
                    status = Localizer.Format(statusAlreadyProspectedName);
                    nextProspectDistance = 0;
                    return;
                }

                //Ready to be prospected.
                else
                {
                    status = Localizer.Format(statusReadyName);
                    nextProspectDistance = 0;
                }

                //Done
                return;
            }

            //No asteroid, check prospect distance if we're landed
            if (this.part.vessel.situation == Vessel.Situations.LANDED || this.part.vessel.situation == Vessel.Situations.PRELAUNCH)
            {
                double distance = getDistanceFromLastLocation();

                //Update distance to next prospect
                nextProspectDistance = (minTravelDistance - distance);
                if (nextProspectDistance <= 0.00001f)
                {
                    nextProspectDistance = 0f;
                    status = Localizer.Format(statusReadyName);
                }

                else
                {
                    status = Localizer.Format(statusGoFartherName);
                }
            }

            //No asteroid and not landed.
            else
            {
                status = Localizer.Format(statusNoAsteroidName);
                nextProspectDistance = 0;
            }
        }
Ejemplo n.º 9
0
 public BARISAppTrackingView() :
     base("Blah", DialogWidth, DialogHeight)
 {
     WindowTitle = Localizer.Format(BARISScenario.AppFlightViewTitle);
     Resizable   = false;
 }
Ejemplo n.º 10
0
        protected void drawTigerTeamRepairs(UnloadedQualitySummary qualitySummary)
        {
            bool canAffordScience = true;
            bool canAffordFunds   = true;
            bool commNetEnabled   = true;

            //Do we have a repair entry? If so, draw the progress.
            BARISRepairProject repairProject = BARISScenario.Instance.GetRepairProject(qualitySummary.vessel);

            if (repairProject != null)
            {
                GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.RepairTimeProgress) + "</b>" + string.Format("{0:f3}", repairProject.RepairProgress) + "%</color>");
                return;
            }

            //Calculate repair costs
            qualitySummary.CalculateRepairCosts();

            //If we don't then draw the repair costs and buttons.
            //Science cost to upgrade flight experience.
            GUILayout.BeginHorizontal();
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                canAffordScience = ResearchAndDevelopment.CanAfford(qualitySummary.repairCostScience);

                if (canAffordScience)
                {
                    GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.TestBenchScienceCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostScience) + "</color>");
                }
                else
                {
                    GUILayout.Label("<color=red><b>" + Localizer.Format(BARISScenario.TestBenchScienceCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostScience) + "</color>");
                }
            }

            //Funds cost to upgrade flight experience.
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                canAffordFunds = Funding.CanAfford(qualitySummary.repairCostFunds);

                if (canAffordFunds)
                {
                    GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.TestBenchFundsCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostFunds) + "</color>");
                }
                else
                {
                    GUILayout.Label("<color=red><b>" + Localizer.Format(BARISScenario.TestBenchFundsCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostFunds) + "</color>");
                }
            }

            //CommNet status
            if (CommNet.CommNetScenario.CommNetEnabled)
            {
                commNetEnabled = qualitySummary.vessel.connection.IsConnectedHome;
            }

            //Time to attempt repair
            GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.RepairTimeCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostTime) +
                            " " + Localizer.Format(BARISScenario.RepairTimeDays) + "</color>");

            //Repair button
            if (GUILayout.Button(wrenchIcon, buttonOptions))
            {
                //Can we afford the funds?
                if (!canAffordFunds)
                {
                    BARISScenario.Instance.LogPlayerMessage(Localizer.Format(BARISScenario.TigerTeamNoFunds));
                    GUILayout.EndHorizontal();
                    return;
                }

                //Can we afford the science?
                else if (!canAffordScience)
                {
                    GUILayout.EndHorizontal();
                    BARISScenario.Instance.LogPlayerMessage(Localizer.Format(BARISScenario.TigerTeamNoScience));
                    return;
                }

                //Do we have a CommNet connection?
                else if (!commNetEnabled)
                {
                    GUILayout.EndHorizontal();
                    BARISScenario.Instance.LogPlayerMessage(Localizer.Format(BARISScenario.TigerTeamNoComm));
                    return;
                }

                //Deduct the costs
                if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
                {
                    Funding.Instance.AddFunds(-qualitySummary.repairCostFunds, TransactionReasons.Any);
                }
                if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
                {
                    ResearchAndDevelopment.Instance.AddScience(-qualitySummary.repairCostScience, TransactionReasons.Any);
                }

                //Register the new project
                registerRepairProject(qualitySummary);
            }

            GUILayout.EndHorizontal();
        }