public NavPath Copy()
        {
            var node = new ConfigNode(NODE_NAME);
            var path = new NavPath();

            Save(node);
            path.Load(node);
            return(path);
        }
Example #2
0
        public override void Load(ConfigNode node)
        {
            base.Load(node);
            var path = node.GetNode(NavPath.NODE_NAME) ?? node.GetNode("Waypoints"); //deprecated: old config conversion

            if (path != null)
            {
                Path.Load(path);
            }
        }
        public override void Load(ConfigNode node)
        {
            LoadedConfig = node;
            base.Load(node);
            //restore vessel ID
            var val = node.GetValue(Utils.PropertyName(new { VesselID }));

            if (!string.IsNullOrEmpty(val))
            {
                VesselID = new Guid(val);
            }
            //restore module configs
            var mcn = node.GetNode("ModuleConfigs");

            if (mcn != null)
            {
                ModuleConfigs.Clear();
                foreach (var n in mcn.GetNodes())
                {
                    ModuleConfigs.Add(n.name, n);
                }
            }

            //deprecated: old config conversion
            var path = node.GetNode("Waypoints");

            if (path != null)
            {
                Path.Load(path);
            }
            ///////////////////////////////////

            //initialize saved waypoints
            if (Anchor != null && string.IsNullOrEmpty(Anchor.Name))
            {
                Anchor = null;
            }
            if (Target != null && string.IsNullOrEmpty(Target.Name))
            {
                Target = null;
            }
            //initialize saved selected macro
            if (SelectedMacro != null && !SelectedMacro.Block.HasSubnodes)
            {
                SelectedMacro = null;
            }
            //FIXME: have to save/load HashSet manually until Squad fixes http://bugs.kerbalspaceprogram.com/issues/13670
            var parts_node = node.GetNode("EnabledTCAParts");

            if (parts_node != null)
            {
                EnabledTCAParts.Clear();
                parts_node.GetValues().ForEach(pname => EnabledTCAParts.Add(pname));
            }
        }
Example #4
0
 public override void Load(ConfigNode node)
 {
     DB.Clear();
     base.Load(node);
     foreach (var n in node.GetNodes(NavPath.NODE_NAME))
     {
         var path = new NavPath();
         path.Load(n);
         DB[path.Name] = path;
     }
 }