示例#1
0
 public static void LoadConfigs(ConfigNode node)
 {
     if (ConfigsLoaded)
     {
         return;
     }
     Configs.Clear();
     NamedConfigs.Clear();
     foreach (var n in node.GetNodes())
     {
         if (n.name == VSL_NODE)
         {
             foreach (var c in n.GetNodes(VesselConfig.NODE_NAME))
             {
                 var config = new VesselConfig();
                 config.Load(c);
                 Configs[config.VesselID] = config;
             }
         }
         else if (n.name == NAMED_NODE)
         {
             foreach (var c in n.GetNodes(NamedConfig.NODE_NAME))
             {
                 var config = new NamedConfig();
                 config.Load(c);
                 NamedConfigs[config.Name] = config;
             }
         }
     }
     VAB_DefaultConfig.LoadFrom(node, "VAB_DefaultConfig");
     SPH_DefaultConfig.LoadFrom(node, "SPH_DefaultConfig");
     ConfigsLoaded = true;
 }
示例#2
0
 public static void UpdateDefaultConfig(EditorFacility facility, VesselConfig config)
 {
     if (facility == EditorFacility.SPH)
     {
         SPH_DefaultConfig.CopyFrom(config);
     }
     else
     {
         VAB_DefaultConfig.CopyFrom(config);
     }
 }
示例#3
0
        public static void SaveConfigs(ConfigNode node)
        {
            var current_vessels = new HashSet <Guid>(HighLogic.CurrentGame.flightState.protoVessels.Select(p => p.vesselID));
            var fg = FlightGlobals.fetch;

            if (fg != null)
            {
                fg.vessels.ForEach(v => current_vessels.Add(v.id));
            }
            if (NamedConfigs.Count > 0)
            {
                var n = node.AddNode(NAMED_NODE);
                foreach (var c in NamedConfigs.Keys)
                {
                    NamedConfigs[c].SaveInto(n);
                }
            }
            VAB_DefaultConfig.SaveInto(node, "VAB_DefaultConfig");
            SPH_DefaultConfig.SaveInto(node, "SPH_DefaultConfig");
        }
示例#4
0
        public static void SaveConfigs(ConfigNode node)
        {
            //save per-vessel configurations into the current game's node
            var current_vessels = new HashSet <Guid>(HighLogic.CurrentGame.flightState.protoVessels.Select(p => p.vesselID));
            var fg = FlightGlobals.fetch;

            if (fg != null)
            {
                fg.vessels.ForEach(v => current_vessels.Add(v.id));
            }
            var configs = new List <VesselConfig>(Configs.Values);

            configs.Sort();
            if (configs.Count > 0)
            {
                var n = node.AddNode(VSL_NODE);
                foreach (var c in configs)
                {
                    if (current_vessels.Contains(c.VesselID))
                    {
                        c.SaveInto(n);
                    }
//                    else Utils.Log("TCAScenario: SaveConfigs: vessel {} is not present in the game. " +
//                                   "Removing orphan configuration.", c.VesselID);
                }
            }
            if (NamedConfigs.Count > 0)
            {
                var n = node.AddNode(NAMED_NODE);
                foreach (var c in NamedConfigs.Keys)
                {
                    NamedConfigs[c].SaveInto(n);
                }
            }
            VAB_DefaultConfig.SaveInto(node, "VAB_DefaultConfig");
            SPH_DefaultConfig.SaveInto(node, "SPH_DefaultConfig");
        }