Пример #1
0
        public static void AddNodeRawToFlightPlanNode(Vessel vessel, Vector3d nodeDeltaV, double UT)
        {
            var newNodeCfg = new ConfigNode("MANEUVER");
            var newNode    = new ManeuverNode {
                UT = UT, DeltaV = nodeDeltaV
            };

            newNode.Save(newNodeCfg);
            var newFlightPlan = new ConfigNode("FLIGHTPLAN");

            if (vessel.flightPlanNode.CountNodes > 0)
            {
                foreach (ConfigNode n in vessel.flightPlanNode.nodes)
                {
                    var nodeUTs = n.GetValue("UT");
                    if (string.IsNullOrEmpty(nodeUTs))
                    {
                        continue;
                    }
                    if (!double.TryParse(nodeUTs, out var nodeUT))
                    {
                        continue;
                    }
                    if (nodeUT < UT)
                    {
                        newFlightPlan.AddNode(n);
                    }
                    else
                    {
                        newFlightPlan.AddNode(newNodeCfg);
                        newFlightPlan.AddNode(n);
                    }
                }
            }
            else
            {
                newFlightPlan.AddNode(newNodeCfg);
            }
            vessel.flightPlanNode = newFlightPlan;
            vessel.Debug($"New flightPlanNode: {vessel.flightPlanNode}");
        }