internal SelectVariable(ConfigNode node, RasterPropMonitorComputer rpmComp) { name = node.GetValue("name"); foreach (ConfigNode sourceVarNode in node.GetNodes("VARIABLE_DEFINITION")) { bool reverseVal; VariableOrNumberRange vonr = ProcessSourceNode(sourceVarNode, rpmComp, out reverseVal); sourceVariables.Add(vonr); reverse.Add(reverseVal); VariableOrNumber val = rpmComp.InstantiateVariableOrNumber(sourceVarNode.GetValue("value")); result.Add(val); } if (node.HasValue("defaultValue")) { VariableOrNumber val = rpmComp.InstantiateVariableOrNumber(node.GetValue("defaultValue")); result.Add(val); } else { throw new Exception(string.Format("Select variable {0} is missing its defaultValue", name)); } if (sourceVariables.Count == 0) { throw new ArgumentException("Did not find any VARIABLE_DEFINITION nodes in RPM_SELECT_VARIABLE", name); } }
public void Load(ConfigNode node) { if(node.HasValue("ConversionRate")) ConversionRate = float.Parse(node.GetValue("ConversionRate")); if(node.HasValue("ConsumptionRate")) ConsumptionRate = float.Parse(node.GetValue("ConsumptionRate")); }
public MappedVariable(ConfigNode node) { if (!node.HasValue("mappedVariable") || !node.HasValue("mappedRange") || !node.HasValue("sourceVariable") || !node.HasValue("sourceRange")) { throw new ArgumentException("MappedVariable missing required values"); } sourceVariable = node.GetValue("sourceVariable"); string sourceRange = node.GetValue("sourceRange"); string[] sources = sourceRange.Split(','); if (sources.Length != 2) { throw new ArgumentException("MappedVariable sourceRange does not have exactly two values"); } if (!float.TryParse(sources[0].Trim(), out sourceMin)) { sourceMinStr = sources[0].Trim(); } if (!float.TryParse(sources[1].Trim(), out sourceMax)) { sourceMaxStr = sources[1].Trim(); } mappedVariable = node.GetValue("mappedVariable"); mappedRange = ConfigNode.ParseVector2(node.GetValue("mappedRange")); }
/// <summary>Creates a new part from save.</summary> public KIS_Item(AvailablePart availablePart, ConfigNode itemNode, ModuleKISInventory inventory, float quantity = 1) { // Get part node this.availablePart = availablePart; partNode = new ConfigNode(); itemNode.GetNode("PART").CopyTo(partNode); // init config this.InitConfig(availablePart, inventory, quantity); // Get mass if (itemNode.HasValue("resourceMass")) { resourceMass = float.Parse(itemNode.GetValue("resourceMass")); } else { resourceMass = availablePart.partPrefab.GetResourceMass(); } if (itemNode.HasValue("contentMass")) { contentMass = float.Parse(itemNode.GetValue("contentMass")); } if (itemNode.HasValue("contentCost")) { contentCost = float.Parse(itemNode.GetValue("contentCost")); } if (itemNode.HasValue("inventoryName")) { inventoryName = itemNode.GetValue("inventoryName"); } }
public SatSettingNode(ProtoPartModuleSnapshot s, Vessel v, ProtoPartSnapshot sn) { this.protoPartModule = s; this.vessel = v; this.snapshot = sn; isLoaded = false; ConfigNode n = new ConfigNode(); protoPartModule.Save(n); if (n.HasValue("pointedAt")) this.pointedAt = new Target(n.GetValue("pointedAt")); else this.pointedAt = new Target(); if (n.HasValue("dishRange")) this.dishRange = float.Parse(n.GetValue("dishRange")); else this.dishRange = 0; if (n.HasValue("antennaName")) this.antennaName = n.GetValue("antennaName"); for (int i = 0; i < RTGlobals.targets.Count; i++) { if (pointedAt.Equals(RTGlobals.targets[i])) { selectedTarget = i; break; } } }
public CustomVariable(ConfigNode node) { name = node.GetValue("name"); foreach (ConfigNode sourceVarNode in node.GetNodes("SOURCE_VARIABLE")) { SourceVariable sourceVar = new SourceVariable(sourceVarNode); sourceVariables.Add(sourceVar); } if(sourceVariables.Count == 0) { throw new ArgumentException("Did not find any SOURCE_VARIABLE nodes in RPM_CUSTOM_VARIABLE", name); } string oper = node.GetValue("operator"); if (oper == Operator.NONE.ToString()) { op = Operator.NONE; } else if (oper == Operator.AND.ToString()) { op = Operator.AND; } else if (oper == Operator.OR.ToString()) { op = Operator.OR; } else if (oper == Operator.XOR.ToString()) { op = Operator.XOR; } else { throw new ArgumentException("Found an invalid operator type in RPM_CUSTOM_VARIABLE", oper); } }
/// <summary> /// Load the saved CancelCommand and find the element to cancel, based on the saved queue position /// </summary> /// <returns>true - loaded successfull</returns> public override bool Load(ConfigNode n, FlightComputer computer) { if(base.Load(n, computer)) { if (n.HasValue("CancelCmdGuid")) { this.CancelCmdGuid = new Guid(n.GetValue("CancelCmdGuid")); } // old way to cancel a command if (n.HasValue("queueIndex")) { try { int queueIndex = int.Parse(n.GetValue("queueIndex")); // try to find the command to cancel this.CancelCmdGuid = computer.QueuedCommands.ElementAt(queueIndex).CmdGuid; } catch (Exception) { } } // loaded successfull if (this.CancelCmdGuid != Guid.Empty) return true; } return false; }
public void Awake() { // Debug.Log("********************************************************************" + HighLogic.LoadedScene + "*********************************************************************"); settings = ConfigNode.Load("GameData/CustomerSatisfactionProgram/Config.cfg"); if (settings.HasNode("SETTINGS")) { Debug.Log("Loading Settings"); settings = settings.GetNode("SETTINGS"); if (settings.HasValue("VERSION")) { version = (settings.GetValue("VERSION")); } if (settings.HasValue("CAP")) { cap = (int.Parse(settings.GetValue("CAP"))); } if (settings.HasValue("CLEANUP")) { cleanup = (int.Parse(settings.GetValue("CLEANUP"))); if (cleanup == 2) { settings.AddValue("CLEANUP", 0); } } } GameEvents.onKerbalRemoved.Add(OnKerbalRemoved); GameEvents.onKerbalAdded.Add(OnKerbalAdded); GameEvents.onKerbalTypeChange.Add(OnKerbalTypeChange); GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequested); }
public BitmapFont(ConfigNode node, string nodeUrl) { id = node.GetValue("id"); name = node.GetValue("name"); displayName = node.GetValue("displayName"); size = int.Parse(node.GetValue("size")); UnityEngine.Texture2D texture = Utils.LoadTexture("GameData/" + nodeUrl + ".pngmap", false); characterMap = new Dictionary<char, BitmapChar>(); float h = 0; foreach(ConfigNode n in node.GetNodes("ASP_BITMAP_CHAR")) { BitmapChar cMap = new BitmapChar(n, texture); characterMap[cMap.character] = cMap; // vh is -ve if (cMap.vh < height) h = cMap.vh; } height = (int) Math.Abs(h); UnityEngine.Object.Destroy(texture); }
public ReactorFuel(ConfigNode node) { _fuel_name = node.GetValue("FuelName"); _fuel_usege_per_mw = Convert.ToDouble(node.GetValue("UsagePerMW")); _unit = node.GetValue("Unit"); _density = PartResourceLibrary.Instance.GetDefinition(_fuel_name).density; }
/// <summary> /// Loads any additional fields not loaded automatically. /// </summary> /// <param name="node">The config node for this module.</param> public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (node.HasValue("chanceToFailPerfect")) { chanceToFailPerfect = double.Parse(node.GetValue("chanceToFailPerfect")); } if (node.HasValue("chanceToFailTerrible")) { chanceToFailTerrible = double.Parse(node.GetValue("chanceToFailTerrible")); } }
public MappedVariable(ConfigNode node, RasterPropMonitorComputer rpmComp) { if (!node.HasValue("mappedVariable") || !node.HasValue("mappedRange") || !node.HasValue("sourceVariable") || !node.HasValue("sourceRange")) { throw new ArgumentException("MappedVariable missing required values"); } string sourceVariableStr = node.GetValue("sourceVariable"); string sourceRange = node.GetValue("sourceRange"); string[] sources = sourceRange.Split(','); if (sources.Length != 2) { throw new ArgumentException("MappedVariable sourceRange does not have exactly two values"); } sourceVariable = new VariableOrNumberRange(rpmComp, sourceVariableStr, sources[0], sources[1]); mappedVariable = node.GetValue("mappedVariable"); string[] destinations = node.GetValue("mappedRange").Split(','); if (destinations.Length != 2) { throw new ArgumentException("MappedVariable mappedRange does not have exactly two values"); } mappedExtent1 = rpmComp.InstantiateVariableOrNumber(destinations[0]); mappedExtent2 = rpmComp.InstantiateVariableOrNumber(destinations[1]); }
public ProtoAntenna(Vessel v, ProtoPartSnapshot p, ProtoPartModuleSnapshot ppms) { ConfigNode n = new ConfigNode(); ppms.Save(n); Name = p.partInfo.title; try { mTarget = new Guid(n.GetValue("RTAntennaTarget")); DishRange = Single.Parse(n.GetValue("RTDishRange")); DishFactor = Double.Parse(n.GetValue("RTDishFactor")); OmniRange = Single.Parse(n.GetValue("RTOmniRange")); } catch (ArgumentException) { mTarget = Guid.Empty; DishRange = 0.0f; DishFactor = 1.0f; OmniRange = 0.0f; RTUtil.Log("ProtoAntenna parsing error. Default values assumed."); } mProtoPart = p; mProtoModule = ppms; Vessel = v; RTUtil.Log("ProtoAntenna: DishRange: {0}, OmniRange: {1}, Name: {2}, DishTarget: {3})", DishRange, OmniRange, Vessel.vesselName, DishTarget); }
protected override void OnParameterLoad(ConfigNode node) { duration = Convert.ToDouble(node.GetValue("duration")); endTime = Convert.ToDouble(node.GetValue("endTime")); timerType = ConfigNodeUtil.ParseValue<TimerType>(node, "timerType", TimerType.CONTRACT_ACCEPTANCE); parameter = ConfigNodeUtil.ParseValue<string>(node, "parameter", ""); }
public Beacon(ConfigNode node) { name = node.GetValue("name"); double.TryParse(node.GetValue("latitude"), out latitude); double.TryParse(node.GetValue("longitude"), out longitude); double.TryParse(node.GetValue("range"), out range); }
public override void OnLoad(ConfigNode node) { string value; base.OnLoad(node); value = node.GetValue("isDeployed"); if (string.IsNullOrEmpty(value) == false) isDeployed = bool.Parse(value); value = node.GetValue("isInflatable"); if (string.IsNullOrEmpty(value) == false) isInflatable = bool.Parse(value); value = node.GetValue("inflatedCrewCapacity"); if (string.IsNullOrEmpty(value) == false) inflatedCrewCapacity = int.Parse(value); try { SetupAnimations(); } catch (Exception ex) { Log("Error encountered while attempting to setup animations: " + ex.ToString()); } }
public ReactorFuel(ConfigNode node) { _fuel_name = node.GetValue("name"); _fuel_usege_per_mw = Convert.ToDouble(node.GetValue("UsagePerMW")); _unit = node.GetValue("Unit"); _density = PartResourceLibrary.Instance.GetDefinition(_fuel_name).density; _consumeGlobal = node.HasValue("consumeGlobal") ? Boolean.Parse(node.GetValue("consumeGlobal")) : true; }
public override void OnLoad(ConfigNode node) { return; if (node.HasValue ("difficultySetting")) difficultySetting = int.Parse (node.GetValue ("difficultySetting")); if (node.HasValue("displayParachuteWarning")) bool.TryParse(node.GetValue("displayParachuteWarning"), out displayParachuteWarning); }
public override void Load(ConfigNode node) { ConfigNode metric_node = node.GetNode("METRIC"); vessel_node = node.GetNode("VESSEL"); metric = new Metric(metric_node); name = node.GetValue("name"); flag = node.GetValue("flag"); id = new Guid(node.GetValue("id")); }
public void OnLoad(ConfigNode node) { if (node.HasValue("cancerTime")) Double.TryParse(node.GetValue("cancerTime"), out mCancerTime); if (node.HasValue("softDose")) Double.TryParse(node.GetValue("softDose"), out softDose); if (node.HasValue("hardDose")) Double.TryParse(node.GetValue("hardDose"), out hardDose); }
public void Load(ConfigNode node) { string resourceID = node.GetValue("name"); if (PartResourceLibrary.Instance.resourceDefinitions.Contains(resourceID)) { resource = PartResourceLibrary.Instance.resourceDefinitions[resourceID]; float.TryParse(node.GetValue("ratio"), out ratio); } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (node.HasValue("chargeRate")) Single.TryParse(node.GetValue("chargeRate"), out chargeRate); if (node.HasValue("initChargeRate")) Single.TryParse(node.GetValue("initChargeRate"), out initChargeRate); else initChargeRate = chargeRate; }
public ResourceDefinition(ConfigNode node) { Resource = node.GetValue("Resource"); var colorFull = node.GetValue("ColorFull"); ColorFull = colorFull != null ? ConfigNode.ParseColor(colorFull) : Color.white; var colorEmpty = node.GetValue("ColorEmpty"); ColorEmpty = colorEmpty != null ? ConfigNode.ParseColor(colorEmpty) : Color.white; Generator = node.GetNode("Generator") ?? new ConfigNode(); }
protected override void OnLoad(ConfigNode node) { int bodyID = int.Parse(node.GetValue(KEESExperimentContract.TARGET_BODY)); foreach (var body in FlightGlobals.Bodies) { if (body.flightGlobalsIndex == bodyID) targetBody = body; } setTargetExperiment(node.GetValue(KEESExperimentContract.EXPERIMENT_STRING)); }
public void FromConfigNode(ConfigNode node) { if (node.HasValue("Name")) Name = node.GetValue("Name"); if (node.HasValue("LastUpdated")) double.TryParse(node.GetValue("LastUpdated"), out LastUpdated); if (node.HasValue("LastSated")) double.TryParse(node.GetValue("LastSated"), out LastSated); }
/* * Returns the internal name of a part given a valid ConfigNode of the part. Parts saved to a craft file are saved as "part = $partname_$idNumber", * while parts from an active Vessel are saved as "name = $partname". This can handle both situations * */ public static string PartNameFromNode(ConfigNode part) { string name = ""; if (part.HasValue("part")) { name = part.GetValue("part"); name = name.Split('_')[0]; } else if (part.HasValue("name")) name = part.GetValue("name"); return name; }
public Harddisk(ConfigNode node) { Capacity = 10000; if (node.HasValue("capacity")) Capacity = int.Parse(node.GetValue("capacity")); if (node.HasValue("volumeName")) Name = node.GetValue("volumeName"); foreach (ConfigNode fileNode in node.GetNodes("file")) { Add(new ProgramFile(fileNode)); } }
internal CustomVariable(ConfigNode node, RasterPropMonitorComputer rpmComp) { name = node.GetValue("name"); foreach (ConfigNode sourceVarNode in node.GetNodes("SOURCE_VARIABLE")) { bool reverseVal; VariableOrNumberRange vonr = ProcessSourceNode(sourceVarNode, rpmComp, out reverseVal); sourceVariables.Add(vonr); reverse.Add(reverseVal); } if (sourceVariables.Count == 0) { throw new ArgumentException("Did not find any SOURCE_VARIABLE nodes in RPM_CUSTOM_VARIABLE", name); } string oper = node.GetValue("operator"); if (oper == Operator.NONE.ToString()) { op = Operator.NONE; } else if (oper == Operator.AND.ToString()) { op = Operator.AND; } else if (oper == Operator.OR.ToString()) { op = Operator.OR; } else if (oper == Operator.NAND.ToString()) { op = Operator.NAND; } else if (oper == Operator.NOR.ToString()) { op = Operator.NOR; } else if (oper == Operator.XOR.ToString()) { op = Operator.XOR; } else if (oper == Operator.ISNANORINF.ToString()) { op = Operator.ISNANORINF; } else { throw new ArgumentException("Found an invalid operator type in RPM_CUSTOM_VARIABLE", oper); } }
public static ExperimentStep getExperimentStepFromConfigNode(ConfigNode node, ExperimentData exp) { if (node.name != CONFIG_NODE_NAME) { NE_Helper.logError("getExperimentStepFromConfigNode: invalid Node: " + node.name); return new ExperimentStep(exp, "", ""); } int index = int.Parse(node.GetValue(INDEX_VALUE)); string name = node.GetValue(NAME_VALUE); ExperimentStep step = createExperimentStep(node.GetValue(TYPE_VALUE), exp, name, index); step.load(node); return step; }
internal MathVariable(ConfigNode node) { name = node.GetValue("name"); string[] sources = node.GetValues("sourceVariable"); for (int i = 0; i < sources.Length; ++i) { VariableOrNumber sv = VariableOrNumber.Instantiate(sources[i]); sourceVariables.Add(sv); } if (sourceVariables.Count == 0) { throw new ArgumentException("Did not find any SOURCE_VARIABLE nodes in RPM_CUSTOM_VARIABLE", name); } string oper = node.GetValue("operator"); if (oper == Operator.NONE.ToString()) { op = Operator.NONE; } else if (oper == Operator.ADD.ToString()) { op = Operator.ADD; } else if (oper == Operator.SUBTRACT.ToString()) { op = Operator.SUBTRACT; } else if (oper == Operator.MULTIPLY.ToString()) { op = Operator.MULTIPLY; } else if (oper == Operator.DIVIDE.ToString()) { op = Operator.DIVIDE; } else if (oper == Operator.MAX.ToString()) { op = Operator.MAX; } else if (oper == Operator.MIN.ToString()) { op = Operator.MIN; } else { throw new ArgumentException("Found an invalid operator type in RPM_CUSTOM_VARIABLE", oper); } }