public ProtoGroundWorkshop(Guid vID, string vesselName, uint flightID, string partName, ConfigNode protoModuleValues) { vesselID = vID; VesselName = vesselName; id = flightID; PartName = partName; State = Status.IDLE; Workforce = protoModuleValues.GetValue("Workforce_Display"); var val = protoModuleValues.GetValue("EndUT"); if (string.IsNullOrEmpty(val) || !double.TryParse(val, out EndUT)) { EndUT = -1; } var node = protoModuleValues.GetNode("KitUnderConstruction"); if (node != null) { var kit = ConfigNodeObject.FromConfig <GroundWorkshop.KitInfo>(node); if (kit.Valid) { update_from_kit(kit); } } }
public override void Load(ConfigNode node) { base.Load(node); DB.Clear(); foreach (var n in node.GetNodes()) { var c = ConfigNodeObject.FromConfig <EnginesProfile>(n); if (c.Active) { Active = c; } if (c.Default) { Default = c; } DB.Add(c); } if (!Empty) { if (Default == null) { Default = DB[0]; Default.Default = true; } if (Active == null) { Active = Default; Active.Active = true; } } }
public override void Load(ConfigNode node) { Volumes.Clear(); base.Load(node); var volumes = node.GetNodes(); for (int i = 0; i < volumes.Length; i++) { var v = volumes[i]; if (v.name == TankVolume.NODE_NAME) { var preset = VolumeConfigsLibrary.GetConfig(v.GetValue("name")); if (preset != null) { float volume; if (!float.TryParse(v.GetValue("Volume"), out volume)) { volume = 100f; } var cfg = preset.Clone <VolumeConfiguration>(); cfg.Volume = volume; Volumes.Add(cfg); } else { Volumes.Add(ConfigNodeObject.FromConfig <TankVolume>(v)); } } else if (v.name == NODE_NAME) { Volumes.Add(ConfigNodeObject.FromConfig <VolumeConfiguration>(v)); } } }
public override void Load(ConfigNode node) { LoadedConfig = node; base.Load(node); var val = node.GetValue(Utils.PropertyName(new { VesselID })); if (!string.IsNullOrEmpty(val)) { VesselID = new Guid(val); } var mcn = node.GetNode("ModuleConfigs"); if (mcn != null) { ModuleConfigs.Clear(); foreach (var n in mcn.GetNodes()) { ModuleConfigs.Add(n.name, n); } } Waypoints.Clear(); var wpn = node.GetNode("Waypoints"); if (wpn == null) { wpn = node; //deprecated: Old config conversion } foreach (var n in wpn.GetNodes(WayPoint.NODE_NAME)) { Waypoints.Enqueue(ConfigNodeObject.FromConfig <WayPoint>(n)); } if (Anchor != null && string.IsNullOrEmpty(Anchor.Name)) { Anchor = null; } if (Target != null && string.IsNullOrEmpty(Target.Name)) { Target = null; } if (SelectedMacro != null && !SelectedMacro.Block.HasSubnodes) { SelectedMacro = null; } //deprecated: Old config conversion val = node.GetValue("VSControlSensitivity"); if (!string.IsNullOrEmpty(val)) { if (!float.TryParse(val, out ControlSensitivity)) { ControlSensitivity = 0.01f; } } }
public override void Load(ConfigNode node) { base.Load(node); Resources.Clear(); foreach (var n in node.GetNodes(CryoResource.NODE_NAME)) { var res = ConfigNodeObject.FromConfig <CryoResource>(n); Resources.Add(res.name, res); } }
protected override float ResourcesMass(bool maxAmount = true) { if (ModuleSave == null || tank_manager != null) { return(0); } var volumes = ConfigNodeObject.FromConfig <VolumeConfiguration>(ModuleSave); return(volumes.ResourceMass(maxAmount)); }
protected override float TankMass(float defaultMass) { if (ModuleSave == null || tank_manager != null) { return(0); } var volumes = ConfigNodeObject.FromConfig <VolumeConfiguration>(ModuleSave); return(volumes.AddMass()); }
public void Load(ConfigNode node) { Clear(); foreach (var n in node.GetNodes()) { var item = ConfigNodeObject.FromConfig <KitResourceInfo>(n); if (item != null) { Add(item.name, item); } } }
public virtual void Load(ConfigNode node) { Clear(); Name = node.GetValue("Name") ?? ""; foreach (var n in node.GetNodes(WayPoint.NODE_NAME)) { var wp = ConfigNodeObject.FromConfig <WayPoint>(n); if (wp != null) { Enqueue(wp); } } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); var SavedCFG = node.GetNode(VesselConfig.NODE_NAME); if (SavedCFG != null) { CFG = ConfigNodeObject.FromConfig <VesselConfig>(SavedCFG); if (vessel != null) { CFG.VesselID = vessel.id; } } }
void volume_configs_gui() { if (!AddRemoveEnabled) { return; } GUILayout.BeginHorizontal(); VolumeConfiguration cfg = null; GUILayout.Label("Configuration Name:", GUILayout.ExpandWidth(false)); config_name = GUILayout.TextField(config_name, GUILayout.ExpandWidth(true), GUILayout.MinWidth(50)); if (GUILayout.Button(VolumeConfigsLibrary.HaveUserConfig(config_name)? "Save" : "Add", Styles.add_button, GUILayout.ExpandWidth(false)) && !string.IsNullOrEmpty(config_name)) { //add new config var node = new ConfigNode(); Save(node); cfg = ConfigNodeObject.FromConfig <VolumeConfiguration>(node); if (cfg.Valid) { cfg.name = config_name; cfg.Volume = TotalVolume; VolumeConfigsLibrary.AddOrSave(cfg); init_supported_types(); } else { Utils.Log("Configuration is invalid:\n{}\nThis should never happen!", node); } } config_name = Utils.LeftRightChooser(config_name, VolumeConfigsLibrary.UserConfigs, "Select tank configuration to edit", 200); if (config_name == null) { config_name = ""; } if (GUILayout.Button("Delete", Styles.danger_button, GUILayout.ExpandWidth(false)) && !string.IsNullOrEmpty(config_name)) { //remove config if (VolumeConfigsLibrary.RemoveConfig(config_name)) { init_supported_types(); } config_name = ""; } GUILayout.EndHorizontal(); }
public override void Load(ConfigNode node) { base.Load(node); Waypoints.Clear(); var wpn = node.GetNode("Waypoints"); if (wpn == null) { return; } foreach (var n in wpn.GetNodes(WayPoint.NODE_NAME)) { Waypoints.Enqueue(ConfigNodeObject.FromConfig <WayPoint>(n)); } }
public override void Load(ConfigNode node) { base.Load(node); tanks.Clear(); total_volume = -1; init_supported_types(); if (node.HasValue(SwitchableTankManager.MANAGED)) { var existing_tanks = part.Modules.GetModules <ModuleSwitchableTank>(); foreach (var n in node.GetNodes(TankVolume.NODE_NAME)) { n.AddValue(MANAGED, true); n.AddValue("name", typeof(ModuleSwitchableTank).Name); n.SetValue("ExcludeTankTypes", ExcludeTankTypes); n.SetValue("IncludeTankTypes", IncludeTankTypes); ModuleSwitchableTank tank; var id = n.HasValue("id")? int.Parse(n.GetValue("id")) : -1; if (id >= 0 && (tank = existing_tanks.Find(t => t.id == id)) != null) { tank.Load(n); max_id = Mathf.Max(max_id, id); } else { tank = part.AddModule(n) as ModuleSwitchableTank; tank.id = ++max_id; } if (tank != null) { tank.EnablePartControls = EnablePartControls; tanks.Add(new TankWrapper(tank, this)); } else { Utils.Log("SwitchableTankManager: unable to load module from config:\n{}", n); } } tanks.ForEach(t => t.Tank.OnStart(part.StartState())); } else if (node.HasValue("Volume")) { var cfg = ConfigNodeObject.FromConfig <VolumeConfiguration>(node); var add_remove = AddRemoveEnabled; AddRemoveEnabled = true; AddConfiguration(cfg, cfg.Volume, false); AddRemoveEnabled = add_remove; } }
public override void Load(ConfigNode node) { base.Load(node); DB.Clear(); if (node == null) { return; } foreach (var n in node.GetNodes()) { K k; if (TryParseK(n.name, out k)) { DB[k] = ConfigNodeObject.FromConfig <EngineConfig>(n); } } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); var SavedCFG = node.GetNode(VesselConfig.NODE_NAME); if (SavedCFG != null) { CFG = ConfigNodeObject.FromConfig <VesselConfig>(SavedCFG); GroupMaster = true; //this.Log("OnLoad: GroupMaster: {}", this);//debug } if (!string.IsNullOrEmpty(GID)) { SetGID(GID); } //deprecated config conversion enabled = isEnabled = true; }
public string GetInfo(ConfigNode node) { base.Load(node); init_supported_types(); var info = ""; if (TypeChangeEnabled) { info += SwitchableTankType.TypesInfo(include, exclude); } var volumes = ConfigNodeObject.FromConfig <VolumeConfiguration>(node); if (volumes.Valid) { info = string.Concat(info, "Preconfigured Tanks:\n", volumes.Info()); } return(info); }
private void loadConstructionState(ConfigNode node) { // node.TryGetValue(nameof(constructedMass), ref constructedMass); if (constructionRecipe != null) { return; } var recipeNode = node.GetNode(nameof(constructionRecipe)); if (recipeNode != null) { constructionRecipe = ConfigNodeObject.FromConfig <ConstructionRecipe>(recipeNode); } else { this.Error($"Unable to find {nameof(constructionRecipe)} node in: {node}"); } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); var payload_node = node.GetNode("PAYLOAD_RESOURCES"); // ReSharper disable once InvertIf if (payload_node != null) { foreach (var rn in payload_node.GetNodes("RESOURCE")) { var res = ConfigNodeObject.FromConfig <PayloadRes>(rn); if (res != null) { payload_resources.Add(res); } } } }
public static VesselConfig Clone(VesselConfig config) { return(ConfigNodeObject.FromConfig <VesselConfig>(config.Configuration)); }