コード例 #1
0
        public void update()
        {
            if (sending && states.Peek().ActTime <= Planetarium.GetUniversalTime())
            {
                state = states.Dequeue();
                if (state.Bt)
                {
                    state.Target = state.Target + Planetarium.GetUniversalTime();
                }
                else
                {
                    speedT0 = RTUtils.ForwardSpeed(computer.core.vessel);
                }
            }

            if (burning)
            {
                if (!RTUtils.PhysicsActive)
                {
                    TimeWarp.SetRate(0, true);
                }
                doOnce = true;
                if (ThrottleIncrement < state.Throttle)
                {
                    ThrottleIncrement = Mathf.Clamp(ThrottleIncrement + 0.1F, 0, 1);
                    computer.core.computer.SetThrottle(ThrottleIncrement);
                }
                else
                {
                    computer.core.computer.SetThrottle(Mathf.Clamp(state.Throttle, 0, 1));
                }
            }
            else
            if (doOnce)
            {
                ThrottleIncrement = 0;
                computer.core.computer.SetThrottle(ThrottleIncrement);
                doOnce = false;
                if (!state.Bt)
                {
                    state.Target = -10;
                    state.Bt     = true;
                }
            }
        }
コード例 #2
0
        public void draw()
        {
            GUILayout.Label("Throttle: " + Mathf.RoundToInt(ThrottleBar * 100) + "%", GUI.skin.textField);
            ThrottleBar = GUILayout.HorizontalSlider(ThrottleBar, 0, 1);
            GUILayout.BeginHorizontal();

            if (GUILayout.Button(BT ? "Burn time (s)" : "ΔV (m/s)", GUI.skin.textField, GUILayout.Width(100)))
            {
                BT = !BT;
            }
            BTS = GUILayout.TextField(BTS, GUILayout.Width(50));
            BTS = RTUtils.FormatNumString(BTS, false);
            if (GUILayout.Button("Send", GUI.skin.textField) && (computer.core.localControl || computer.core.InContact))
            {
                ThrottleState tmp = new ThrottleState();
                tmp.Throttle = ThrottleBar;
                if (BTS.EndsWith("."))
                {
                    BTS = BTS.Substring(0, BTS.Length - 1);
                }
                tmp.Target  = Convert.ToSingle(BTS);
                tmp.Bt      = BT;
                lastActTime = tmp.ActTime = Planetarium.GetUniversalTime() + (computer.core.localControl ? (double)burnAt :
                                                                              (computer.core.path.ControlDelay <= (double)burnAt ? (double)burnAt : computer.core.path.ControlDelay)
                                                                              );
                states.Enqueue(tmp);
                BTS     = "";
                burnAts = "";
                burnAt  = 0;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label(sending ? "Sending " + computer.arrows : (burning && state.Bt ? "Burning" : (BTS == "" ? "" : "in HH:MM:SS")), GUI.skin.textField, GUILayout.Width(100));

            if (BTS == "")
            {
                GUILayout.Label(sending ? RTUtils.time((lastActTime - Planetarium.GetUniversalTime() > 0) ? lastActTime - Planetarium.GetUniversalTime() : 0) :
                                (burning && state.Bt ? RTUtils.time((state.Target - Planetarium.GetUniversalTime() > 0) ? state.Target - Planetarium.GetUniversalTime() : 0) : "")
                                , GUI.skin.textField, GUILayout.Width(100));
            }
            else
            {
                burnAts = GUILayout.TextField(burnAts, GUILayout.Width(100));
                List <String> temp = burnAts.Split(":".ToCharArray()).ToList();
                string        seconds = "", minutes = "", hours = "", days = "";

                while (temp.Count < 4)
                {
                    temp.Insert(0, "");
                }

                seconds = RTUtils.TFormat(temp[3]);
                burnAt  = Convert.ToSingle(seconds == "" ? "0" : seconds);
                burnAts = seconds;

                if (temp[2] != "")
                {
                    minutes = RTUtils.TFormat(temp[2]);
                    burnAt += Convert.ToSingle(minutes == "" ? "0" : minutes) * 60;
                    burnAts = minutes == "" ? burnAts : (minutes + ":" + burnAts);
                }

                if (temp[1] != "")
                {
                    hours   = RTUtils.TFormat(temp[1]);
                    burnAt += Convert.ToSingle(hours == "" ? "0" : hours) * 3600;
                    burnAts = hours == "" ? burnAts : (hours + ":" + burnAts);
                }

                if (temp[0] != "")
                {
                    days    = RTUtils.TFormat(temp[0]);
                    burnAt += Convert.ToSingle(days == "" ? "0" : days) * 86400;
                    burnAts = days == "" ? burnAts : (days + ":" + burnAts);
                }
            }

            GUILayout.EndHorizontal();
        }
コード例 #3
0
        public void update()
        {
            if (sending && states.Peek().ActTime <= Planetarium.GetUniversalTime())
            {
                state = states.Dequeue();
                if (state.Bt)
                    state.Target = state.Target + Planetarium.GetUniversalTime();
                else
                {
                    speedT0 = RTUtils.ForwardSpeed(computer.core.vessel);
                }
            }

            if (burning)
            {
                if (!RTUtils.PhysicsActive)
                    TimeWarp.SetRate(0, true);
                doOnce = true;
                if (ThrottleIncrement < state.Throttle)
                {
                    ThrottleIncrement = Mathf.Clamp(ThrottleIncrement + 0.1F, 0, 1);
                    computer.core.computer.SetThrottle(ThrottleIncrement);
                }
                else
                    computer.core.computer.SetThrottle(Mathf.Clamp(state.Throttle, 0, 1));
            }
            else
                if (doOnce)
                {
                    ThrottleIncrement = 0;
                    computer.core.computer.SetThrottle(ThrottleIncrement);
                    doOnce = false;
                    if (!state.Bt)
                    {
                        state.Target = -10;
                        state.Bt = true;
                    }
                }
        }
コード例 #4
0
        public void draw()
        {
            GUILayout.Label("Throttle: " + Mathf.RoundToInt(ThrottleBar * 100) + "%", GUI.skin.textField);
            ThrottleBar = GUILayout.HorizontalSlider(ThrottleBar, 0, 1);
            GUILayout.BeginHorizontal();

            if (GUILayout.Button(BT ? "Burn time (s)" : "ΔV (m/s)", GUI.skin.textField, GUILayout.Width(100)))
                BT = !BT;
            BTS = GUILayout.TextField(BTS, GUILayout.Width(50));
            BTS = RTUtils.FormatNumString(BTS, false);
            if (GUILayout.Button("Send", GUI.skin.textField) && (computer.core.localControl || computer.core.InContact))
            {
                ThrottleState tmp = new ThrottleState();
                tmp.Throttle = ThrottleBar;
                if (BTS.EndsWith("."))
                    BTS = BTS.Substring(0, BTS.Length - 1);
                tmp.Target = Convert.ToSingle(BTS);
                tmp.Bt = BT;
                lastActTime = tmp.ActTime = Planetarium.GetUniversalTime() + (computer.core.localControl ? (double)burnAt :
                    (computer.core.path.ControlDelay <= (double)burnAt ? (double)burnAt : computer.core.path.ControlDelay)
                    );
                states.Enqueue(tmp);
                BTS = "";
                burnAts = "";
                burnAt = 0;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label(sending ? "Sending " + computer.arrows : (burning && state.Bt ? "Burning" : (BTS == "" ? "" : "in HH:MM:SS")), GUI.skin.textField, GUILayout.Width(100));

            if (BTS == "")
            {
                GUILayout.Label(sending ? RTUtils.time((lastActTime - Planetarium.GetUniversalTime() > 0) ? lastActTime - Planetarium.GetUniversalTime() : 0) :
                    (burning && state.Bt ? RTUtils.time((state.Target - Planetarium.GetUniversalTime() > 0) ? state.Target - Planetarium.GetUniversalTime() : 0) : "")
                , GUI.skin.textField, GUILayout.Width(100));
            }
            else
            {
                burnAts = GUILayout.TextField(burnAts, GUILayout.Width(100));
                List<String> temp = burnAts.Split(":".ToCharArray()).ToList();
                string seconds = "", minutes = "", hours = "", days = "";

                while (temp.Count < 4) temp.Insert(0, "");

                seconds = RTUtils.TFormat(temp[3]);
                burnAt = Convert.ToSingle(seconds == "" ? "0" : seconds);
                burnAts = seconds;

                if (temp[2] != "")
                {
                    minutes = RTUtils.TFormat(temp[2]);
                    burnAt += Convert.ToSingle(minutes == "" ? "0" : minutes) * 60;
                    burnAts = minutes == "" ? burnAts : (minutes + ":" + burnAts);
                }

                if (temp[1] != "")
                {
                    hours = RTUtils.TFormat(temp[1]);
                    burnAt += Convert.ToSingle(hours == "" ? "0" : hours) * 3600;
                    burnAts = hours == "" ? burnAts : (hours + ":" + burnAts);
                }

                if (temp[0] != "")
                {
                    days = RTUtils.TFormat(temp[0]);
                    burnAt += Convert.ToSingle(days == "" ? "0" : days) * 86400;
                    burnAts = days == "" ? burnAts : (days + ":" + burnAts);
                }
            }

            GUILayout.EndHorizontal();
        }