Пример #1
0
 public override void OnUpdate()
 {
     if (JUtil.RasterPropMonitorShouldUpdate(vessel) && UpdateCheck())
     {
         textObj.text.text = StringProcessor.ProcessString(labelsEx[activeLabel].label, rpmComp);
     }
 }
 public override void OnUpdate()
 {
     if (JUtil.RasterPropMonitorShouldUpdate(vessel) && UpdateCheck())
     {
         RPMVesselComputer comp = RPMVesselComputer.Instance(vessel);
         textObj.text.Text = StringProcessor.ProcessString(labelsEx[activeLabel].label, comp);
     }
 }
Пример #3
0
        public void FixedUpdate()
        {
            if (JUtil.RasterPropMonitorShouldUpdate(vessel) && timeToUpdate)
            {
                UpdateLocalVars();

                RPMVesselComputer comp = RPMVesselComputer.Instance(vid);

                for (int i = 0; i < periodicRandomVals.Count; ++i)
                {
                    periodicRandomVals[i].counter -= refreshDataRate;
                    if (periodicRandomVals[i].counter <= 0)
                    {
                        periodicRandomVals[i].counter = periodicRandomVals[i].period;
                        periodicRandomVals[i].value   = UnityEngine.Random.value;
                    }
                }

                for (int i = 0; i < updatableVariables.Count; ++i)
                {
                    VariableCache vc     = updatableVariables[i];
                    float         oldVal = vc.value.AsFloat();
                    double        newVal;

                    object evaluant = vc.evaluator(vc.value.variableName, comp);
                    if (evaluant is string)
                    {
                        vc.value.isNumeric   = false;
                        vc.value.stringValue = evaluant as string;
                        newVal = 0.0;
                    }
                    else
                    {
                        newVal             = evaluant.MassageToDouble();
                        vc.value.isNumeric = true;
                    }
                    vc.value.numericValue = newVal;

                    if (!Mathf.Approximately(oldVal, (float)newVal) || forceCallbackRefresh == true)
                    {
                        vc.FireCallbacks((float)newVal);
                    }
                }

                ++debug_fixedUpdates;

                forceCallbackRefresh = false;
                timeToUpdate         = false;

                Vessel v = vessel;
                for (int i = 0; i < activeTriggeredEvents.Count; ++i)
                {
                    activeTriggeredEvents[i].Update(v);
                }
            }
        }
Пример #4
0
        public override void OnUpdate()
        {
            if (oneshotComplete && oneshot)
            {
                return;
            }

            if (JUtil.RasterPropMonitorShouldUpdate(vessel) && UpdateCheck())
            {
                RPMVesselComputer comp = RPMVesselComputer.Instance(vessel);
                textObj.text.Text = StringProcessor.ProcessString(spf, comp);
                oneshotComplete   = true;
            }
        }
Пример #5
0
        public override void OnUpdate()
        {
            if (textObj == null)
            {
                // Shouldn't happen ... but it does, thanks to the quirks of
                // docking and undocking.
                return;
            }

            if (oneshotComplete && oneshot)
            {
                return;
            }

            if (JUtil.RasterPropMonitorShouldUpdate(vessel) && UpdateCheck())
            {
                textObj.text.text = StringProcessor.ProcessString(spf, rpmComp);
                oneshotComplete   = true;
            }
        }
        public void Update()
        {
            if (!JUtil.IsActiveVessel(vessel))
            {
                return;
            }

            if (!JUtil.VesselIsInIVA(vessel))
            {
                if (!muted)
                {
                    for (int unit = 0; unit < variableSets.Count; ++unit)
                    {
                        variableSets[unit].MuteSoundWhileOutOfIVA();
                    }
                }
                muted = true;
            }
            else if (muted)
            {
                for (int unit = 0; unit < variableSets.Count; ++unit)
                {
                    variableSets[unit].UnmuteSoundWhileInIVA();
                }
                muted = false;
            }

            if ((!alwaysActive && !JUtil.RasterPropMonitorShouldUpdate(vessel)) || !UpdateCheck())
            {
                return;
            }

            RPMVesselComputer comp          = RPMVesselComputer.Instance(vessel);
            double            universalTime = Planetarium.GetUniversalTime();

            for (int unit = 0; unit < variableSets.Count; ++unit)
            {
                variableSets[unit].Update(comp, universalTime);
            }
        }
Пример #7
0
        /// <summary>
        /// Do we need to update our text and shader?
        /// </summary>
        public override void OnUpdate()
        {
            if (textObj == null)
            {
                // Shouldn't happen ... but it does, thanks to the quirks of
                // docking and undocking.
                return;
            }

            // Update shader parameters
            UpdateShader();

            if (labels[activeLabel].oneshotComplete && labels[activeLabel].oneshot)
            {
                return;
            }

            if (JUtil.RasterPropMonitorShouldUpdate(vessel) && UpdateCheck())
            {
                textObj.text = StringProcessor.ProcessString(labels[activeLabel].spf, rpmComp);
                labels[activeLabel].oneshotComplete = true;
            }
        }
Пример #8
0
        public override void OnUpdate()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                return;
            }

            // If we didn't complete startup, we can't do anything anyway.
            // The only trouble is that situations where update happens before startup is complete do happen sometimes,
            // particularly when docking, so we can't use it to detect being broken by a third party plugin.
            if (!startupComplete)
            {
                return;
            }

            if (!JUtil.RasterPropMonitorShouldUpdate(vessel) && !JUtil.UserIsInPod(part))
            {
                return;
            }

            // Screenshots need to happen in at this moment, because otherwise they may miss.
            if (doScreenshots && GameSettings.TAKE_SCREENSHOT.GetKeyDown() && part.ActiveKerbalIsLocal())
            {
                // Let's try to save a screenshot.
                JUtil.LogMessage(this, "SCREENSHOT!");

                string screenshotName = string.Format("{0}{1}{2:yyyy-MM-dd_HH-mm-ss}_{4}_{3}.png",
                                                      KSPUtil.ApplicationRootPath, "Screenshots/monitor", DateTime.Now, internalProp.propID, part.GetInstanceID());
                var           screenshot          = new Texture2D(screenTexture.width, screenTexture.height);
                RenderTexture backupRenderTexture = RenderTexture.active;
                RenderTexture.active = screenTexture;
                screenshot.ReadPixels(new Rect(0, 0, screenTexture.width, screenTexture.height), 0, 0);
                RenderTexture.active = backupRenderTexture;
                var bytes = screenshot.EncodeToPNG();
                Destroy(screenshot);
                File.WriteAllBytes(screenshotName, bytes);
            }

            if (!UpdateCheck())
            {
                return;
            }

            if (!activePage.isMutable)
            {
                // In case the page is empty and has no camera, the screen is treated as turned off and blanked once.
                if (!firstRenderComplete)
                {
                    FillScreenBuffer();
                    RenderScreen();
                    firstRenderComplete = true;
                    textRefreshRequired = false;
                }
                else
                {
                    RenderScreen();
                }
            }
            else
            {
                if (textRefreshRequired)
                {
                    FillScreenBuffer();
                    textRefreshRequired = false;
                }
                RenderScreen();

                firstRenderComplete = true;
            }

            // Oneshot screens: We create a permanent texture from our RenderTexture if the first pass of the render is complete,
            // set it in place of the rendertexture -- and then we selfdestruct.
            // MOARdV: Except we don't want to self-destruct, because we will leak the frozenScreen texture.
            if (oneshot && firstRenderComplete)
            {
                frozenScreen = new Texture2D(screenTexture.width, screenTexture.height);
                RenderTexture backupRenderTexture = RenderTexture.active;
                RenderTexture.active = screenTexture;
                frozenScreen.ReadPixels(new Rect(0, 0, screenTexture.width, screenTexture.height), 0, 0);
                RenderTexture.active = backupRenderTexture;
                foreach (string layerID in textureLayerID.Split())
                {
                    screenMat.SetTexture(layerID.Trim(), frozenScreen);
                }
            }
        }