protected override void OnUpdate()
        {
            base.OnUpdate();

            float partCurrentFlightData;
            float newFlightData;

            TestFlightPartData partData = TestFlightUtil.GetPartDataForPart(partName);

            if (partData == null)
            {
                return;
            }

            if (Planetarium.GetUniversalTime() - lastUpdate > 1.0f)
            {
                partCurrentFlightData = float.Parse(partData.GetValue("flightData"));
                newFlightData         = partCurrentFlightData - lastData;
                lastData   = partCurrentFlightData;
                lastUpdate = Planetarium.GetUniversalTime();

                if (ReadyToComplete())
                {
                    flightData = flightData + newFlightData;
                    titleTracker.UpdateContractWindow(GetTitle());
                }
            }
        }
Esempio n. 2
0
        protected override string GetTitle()
        {
            if (hidden)
            {
                return("");
            }

            if (Parent != null)
            {
                ContractConfiguratorParameter ccpParent = Parent as ContractConfiguratorParameter;
                if (ccpParent != null && ccpParent.hideChildren)
                {
                    return("");
                }
            }

            string output = (optional && !fakeOptional && string.IsNullOrEmpty(title) ? "(Optional) " : "") + GetParameterTitle();

            // Update the contract window title
            titleTracker.Add(output);
            if (lastTitle != output && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(output);
                lastTitle = output;
            }

            return(output);
        }
        protected override string GetTitle()
        {
            if (vessel == null)
            {
                return("");
            }

            string vesselName = vessel.GetDisplayName();

            if (vesselName == null)
            {
                vesselName = vessel.name;
            }

            string result;

            if (string.IsNullOrEmpty(statusLabel))
            {
                result = KERBALISM.Lib.Ellipsis(vesselName, 35);
            }
            else
            {
                result = KERBALISM.Lib.Ellipsis(vesselName, 35) + "\n" + statusLabel;
            }

            titleTracker.Add(result);
            if (lastTitle != result && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(result);
                lastTitle = result;
            }
            return(result);
        }
Esempio n. 4
0
 protected override void OnUpdate()
 {
     // Every second check the contract window for a title update.
     if (Time.fixedTime - lastUpdate > 1.0f)
     {
         lastUpdate = Time.fixedTime;
         titleTracker.UpdateContractWindow(this, GetTitle());
     }
 }
        protected override string GetTitle()
        {
            string result = subRequirement.GetTitle(context);

            titleTracker.Add(result);
            if (lastTitle != result && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(result);
                lastTitle = result;
            }
            return(result);
        }
Esempio n. 6
0
        protected override void OnUpdate()
        {
            if (waiting && Planetarium.GetUniversalTime() > completionTime)
            {
                waiting = false;
                SetState(ParameterState.Complete);
            }
            // Every time the clock ticks over, make an attempt to update the contract window
            // notes.  We do this because otherwise the window will only ever read the notes once,
            // so this is the only way to get our fancy timer to work.
            else if (waiting && trackedVessel != null && Planetarium.GetUniversalTime() - lastUpdate > 1.0f)
            {
                lastUpdate = Planetarium.GetUniversalTime();

                titleTracker.UpdateContractWindow(this, GetTitle());
            }
        }
Esempio n. 7
0
        protected override void OnUpdate()
        {
            base.OnUpdate();

            if (Planetarium.GetUniversalTime() - lastUpdate > 1.0f && (endTime != 0.0 || resetClock))
            {
                // Completed
                if (endTime != 0.0 && Planetarium.GetUniversalTime() > endTime)
                {
                    SetState(ParameterState.Complete);
                }
                lastUpdate = Planetarium.GetUniversalTime();

                titleTracker.UpdateContractWindow(this, GetTitle());
                resetClock = false;
            }
        }
Esempio n. 8
0
        protected override void OnUpdate()
        {
            base.OnUpdate();

            // Every time the clock ticks over, make an attempt to update the contract window
            // title.  We do this because otherwise the window will only ever read the title once,
            // so this is the only way to get our fancy timer to work.
            if (Planetarium.GetUniversalTime() - lastUpdate > 1.0f)
            {
                // Boom!
                if (Planetarium.GetUniversalTime() > endTime)
                {
                    SetState(ParameterState.Failed);
                }
                lastUpdate = Planetarium.GetUniversalTime();

                titleTracker.UpdateContractWindow(this, GetTitle());
            }
        }
        protected override string GetTitle()
        {
            string output = "";

            try
            {
                if (hidden)
                {
                    return("");
                }

                if (Parent != null)
                {
                    ContractConfiguratorParameter ccpParent = Parent as ContractConfiguratorParameter;
                    if (ccpParent != null && ccpParent.hideChildren)
                    {
                        return("");
                    }
                }

                // (Optional)
                output = (optional && !fakeOptional && string.IsNullOrEmpty(title) ?
                          StringBuilderCache.Format("{0} {1}", Localizer.GetStringByTag("#cc.param.optionalTag"), GetParameterTitle()) :
                          GetParameterTitle());

                // Update the contract window title
                titleTracker.Add(output);
                if (lastTitle != output && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
                {
                    titleTracker.UpdateContractWindow(output);
                    lastTitle = output;
                }
            }
            catch (Exception e)
            {
                // Don't let exceptions mess us up
                LoggingUtil.LogException(new ContractConfiguratorException(this, e));
            }

            return(output);
        }
Esempio n. 10
0
        protected override void OnUpdate()
        {
            if (RemoteTechProgressTracker.Instance != null)
            {
                double oldCoverage = currentCoverage;
                currentCoverage = RemoteTechProgressTracker.Instance.GetCoverage(targetBody);
                if (currentCoverage >= coverage)
                {
                    SetComplete();
                    RemoteTechProgressTracker.Instance.RemoveFromPriorityList(targetBody);
                }
                else
                {
                    SetIncomplete();
                    RemoteTechProgressTracker.Instance.AddToPriorityList(targetBody);
                }

                // Update contract window
                titleTracker.UpdateContractWindow(GetTitle());
            }
        }
        protected override void OnUpdate()
        {
            base.OnUpdate();
            if (targetBody == null)
            {
                return;
            }

            // Do a check if either:
            //   REAL_UPDATE_FREQUENCY of real time has elapsed
            //   GAME_UPDATE_FREQUENCY of game time has elapsed
            if (UnityEngine.Time.fixedTime - lastRealUpdate > REAL_UPDATE_FREQUENCY ||
                Planetarium.GetUniversalTime() - lastGameTimeUpdate > GAME_UPDATE_FREQUENCY)
            {
                lastRealUpdate     = UnityEngine.Time.fixedTime;
                lastGameTimeUpdate = Planetarium.GetUniversalTime();
                currentCoverage    = SCANsatUtil.GetCoverage(scanType, targetBody);

                // Count the number of sucesses
                if (currentCoverage > coverage)
                {
                    consecutive_successes++;
                }
                else
                {
                    consecutive_successes = 0;
                }

                // We've had enough successes to be sure that the scan is complete
                if (consecutive_successes >= CONSECUTIVE_SUCCESSES_REQUIRED)
                {
                    SetState(ParameterState.Complete);
                }

                // Update contract window
                titleTracker.UpdateContractWindow(this, GetTitle());
            }
        }
        protected override string GetTitle()
        {
            string result = "";
            double now    = Planetarium.GetUniversalTime();

            string remainingStr = durationType == DurationType.countdown
                                ? DurationUtil.StringValue(Math.Max(0, doneAfter - now))
                                : DurationUtil.StringValue(Math.Max(0, duration - accumulatedDuration));

            switch (durationState)
            {
            case DurationState.off:
                result = Localizer.Format("Duration: <<1>>", DurationUtil.StringValue(duration));
                if (waitDuration > 0)
                {
                    result += "\n\t - " + Localizer.Format("Time starts <<1>> after accepting the contract",
                                                           Lib.Color(DurationUtil.StringValue(waitDuration), Lib.Kolor.Yellow));
                }
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + Localizer.Format("Allows interruptions up to <<1>>",
                                                           DurationUtil.StringValue(allowedDowntime));
                }
                else
                {
                    result += "\n\t - " + "Does not allow interruptions";
                }
                if (!allowReset)
                {
                    result += "\n\t - " + Lib.Color("Will fail if interrupted beyond allowance", Lib.Kolor.Orange);
                }

                break;

            case DurationState.preRun:
                result  = Localizer.Format("Duration: <<1>>", DurationUtil.StringValue(duration));
                result += "\n\t - " + Localizer.Format("Time starts in <<1>>",
                                                       Lib.Color(DurationUtil.StringValue(Math.Max(0, startAfter - now)), Lib.Kolor.Yellow));
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + Localizer.Format("Allows interruptions up to <<1>>",
                                                           DurationUtil.StringValue(allowedDowntime));
                }

                break;

            case DurationState.running:
                result = Localizer.Format("Remaining: <<1>>", Lib.Color(remainingStr, Lib.Kolor.Green));
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + Localizer.Format("Allows interruptions up to <<1>>",
                                                           DurationUtil.StringValue(allowedDowntime));
                }

                break;

            case DurationState.preReset:
                result = Localizer.Format("Remaining: <<1>> (stop in: <<2>>)", Lib.Color(remainingStr, Lib.Kolor.Green),
                                          Lib.Color(DurationUtil.StringValue(Math.Max(0, failAfter - now)), allowReset ? Lib.Kolor.Yellow : Lib.Kolor.Red));

                break;

            case DurationState.done:
                result = "Done!";
                break;

            case DurationState.failed:
                result = "Time is up!";
                break;
            }

            titleTracker.Add(result);
            if (lastTitle != result && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(result);
                lastTitle = result;
            }
            return(result);
        }
Esempio n. 13
0
        protected override string GetTitle()
        {
            InitStrings();

            string result = "";
            double now    = Planetarium.GetUniversalTime();

            string remainingStr = durationType == DurationType.countdown
                                ? DurationUtil.StringValue(Math.Max(0, doneAfter - now))
                                : DurationUtil.StringValue(Math.Max(0, duration - accumulatedDuration));

            switch (durationState)
            {
            case DurationState.off:
                result = KerCon_Duration_X;                         // Duration: <<1>>
                if (waitDuration > 0)
                {
                    result += "\n\t - " + KerCon_TimeStartsAfterAccepting;
                }
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + KerCon_AllowsInterruptionsUpTo;
                }
                else if (durationType == DurationType.accumulating)
                {
                    result += "\n\t - " + KerCon_AccumulatingDuration;
                }
                else
                {
                    result += "\n\t - " + KerCon_DoesNotAllowInterruptions;                             // Does not allow interruptions
                }
                if (!allowReset)
                {
                    result += "\n\t - " + KerCon_WillFailIfInterrupted;                             // Will fail if interrupted beyond allowance
                }
                break;

            case DurationState.preRun:
                result  = KerCon_Duration_X;                                   // Duration: <<1>>
                result += "\n\t - " + Localizer.Format("#KerCon_TimeStartsIn", // Time starts in <<1>>
                                                       Lib.Color(DurationUtil.StringValue(Math.Max(0, startAfter - now)), Lib.Kolor.Yellow));
                if (allowedDowntime > 0)
                {
                    result += "\n\t - " + KerCon_AllowsInterruptionsUpTo;
                }

                break;

            case DurationState.running:
                result = Localizer.Format("#KerCon_Reamining_X", Lib.Color(remainingStr, Lib.Kolor.Green));                         // Remaining: <<1>>
                //if (allowedDowntime > 0)
                //	result += "\n\t - " + Localizer.Format("#KerCon_AllowsInterruptionsUpTo", // Allows interruptions up to <<1>>
                //		DurationUtil.StringValue(allowedDowntime));

                break;

            case DurationState.preReset:
                result = Localizer.Format("#KerCon_Reamining_X_stopIn_Y", Lib.Color(remainingStr, Lib.Kolor.Green),                         // Remaining: <<1>> (stop in: <<2>>)
                                          Lib.Color(DurationUtil.StringValue(Math.Max(0, failAfter - now)), allowReset ? Lib.Kolor.Yellow : Lib.Kolor.Red));

                break;

            case DurationState.done:
                result = "#autoLOC_135144";                         // Success!!
                break;

            case DurationState.failed:
                result = "#KerCon_TimeIsUp";                         // Time is up!
                break;
            }

            if (result.StartsWith("#"))
            {
                result = Localizer.Format(result);
            }

            titleTracker.Add(result);
            if (lastTitle != result && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(result);
                lastTitle = result;
            }
            return(result);
        }