RemoteTech.FlightCtrlStateBuffer.pop C# (CSharp) Méthode

pop() public méthode

public pop ( FlightCtrlState controls, double time ) : void
controls FlightCtrlState
time double
Résultat void
        public void pop(FlightCtrlState controls, double time)
        {
            if (states.Count == 0 || states.Peek().ActTime > time)
            {
                setNeutral(controls);
                return; //returns neutral if no controls are entered or the entered controls are not within the signal delay
            }
            TimedCtrlState popState = states.Peek();
            while (states.Peek().ActTime < time)
            {
                popState = states.Dequeue();
            }

            controls.CopyFrom(popState.flightCtrlState);

            if (controls.killRot) // this overrides the delay in attitute control if SAS is activated. Thereby allowing SAS to make control changes without delay
            {
                controls.pitch = pitch;
                controls.roll = roll;
                controls.yaw = yaw;
            }
        }

Usage Example

Exemple #1
0
        public void drive(FlightCtrlState s)
        {
            if (!vessel.isActiveVessel)
            {
                delayedBuffer.setNeutral(s);
            }
            if (!localControl)
            {
                if (!InContact || !powered)
                {
                    //lock out the player if we are out of radio contact or out of power
                    delayedBuffer.setNeutral(s);
                }
                else
                if (vessel.isActiveVessel)
                {
                    //this is a somewhat crude fix for the buggy throttle controls introduced in KSP 0.17. It works nicely though.
                    if (GameSettings.AXIS_THROTTLE.GetAxis() == this.LastAxisThrottle)
                    {
                        if (!DockingMode)
                        {
                            if (GameSettings.THROTTLE_UP.GetKey())
                            {
                                lastThrottle = Mathf.Clamp(lastThrottle + 0.01f, 0, 1);
                            }
                            if (GameSettings.THROTTLE_DOWN.GetKey())
                            {
                                lastThrottle = Mathf.Clamp(lastThrottle - 0.01f, 0, 1);
                            }
                        }

                        lastThrottle = Mathf.Clamp(lastThrottle + GameSettings.AXIS_THROTTLE_INC.GetAxis() * 0.01f, 0, 1);

                        s.mainThrottle = lastThrottle;
                    }
                    else if (RTUtils.AppFocus)
                    {
                        LastAxisThrottle = GameSettings.AXIS_THROTTLE.GetAxis();
                        s.mainThrottle   = lastThrottle = Mathf.Clamp((LastAxisThrottle + 1) / 2, 0, 1);
                    }

                    if (GameSettings.THROTTLE_CUTOFF.GetKey())
                    {
                        s.mainThrottle = lastThrottle = 0;
                    }

                    delayedBuffer.push(s, Planetarium.GetUniversalTime() + path.ControlDelay);
                    delayedBuffer.pop(s, Planetarium.GetUniversalTime());
                }
            }

            s.killRot = flightComputerGUI.attitudeButtons[0].state.Active;
            vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, flightComputerGUI.attitudeButtons[0].state.Active);

            if (powered)
            {
                computer.drive(s);
            }

            //this makes sure that the navball readout shows the delayed throttle. Since it reads directly from the FlightInputHandlers throttle state.
            if (vessel.isActiveVessel)
            {
                FlightInputHandler.state.mainThrottle = s.mainThrottle;
            }
        }
FlightCtrlStateBuffer