本文整理汇总了C#中System.ConfigNode.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.GetValues方法的具体用法?C# ConfigNode.GetValues怎么用?C# ConfigNode.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.GetValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public override bool Load(ConfigNode configNode)
{
// Load base class
bool valid = base.Load(configNode);
valid &= ConfigNodeUtil.ParseValue<List<VesselIdentifier>>(configNode, "vessel", x => vessels = x, this, new List<VesselIdentifier>());
valid &= ConfigNodeUtil.ParseValue<VesselIdentifier>(configNode, "defineDockedVessel", x => defineDockedVessel = x, this, (VesselIdentifier)null);
// Validate using the config node instead of the list as it may undergo deferred loading
if (parent is VesselParameterGroupFactory)
{
if (configNode.GetValues("vessel").Count() > 1)
{
LoggingUtil.LogError(this, ErrorPrefix() + ": When used under a VesselParameterGroup, no more than one vessel may be specified for the Docking parameter.");
valid = false;
}
}
else
{
if (configNode.GetValues("vessel").Count() == 0)
{
LoggingUtil.LogError(this, ErrorPrefix() + ": Need at least one vessel specified for the Docking parameter.");
valid = false;
}
if (configNode.GetValues("vessel").Count() > 2)
{
LoggingUtil.LogError(this, ErrorPrefix() + ": Cannot specify more than two vessels for the Docking parameter.");
valid = false;
}
}
return valid;
}
示例2: OnLoad
public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
//Load all the drill info
drillResources = node.GetValues("drillResource");
}
示例3: VariableHandler
public VariableHandler(ConfigNode node, RasterPropMonitorComputer ourComp)
{
handlerName = node.GetValue("name");
foreach (string variableRecord in node.GetValues("variable")) {
var record = new VariableRecord();
string[] tokens = variableRecord.Split(',');
if (tokens.Length >= 2) {
double defaultDouble;
if (double.TryParse(tokens[1], out defaultDouble)) {
record.defaultValue = defaultDouble;
} else {
if (tokens[1].Trim() == "fallback") {
record.fallback = true;
} else {
record.defaultString = tokens[1];
}
}
}
if (tokens.Length >= 3) {
record.cacheable = bool.Parse(tokens[2]);
}
handledVariables.Add(tokens[0], record);
}
active = InstantiateHandler(node, ourComp, out handlerFunction);
}
示例4: Load
public void Load(ConfigNode node)
{
if (!HighLogic.LoadedSceneIsFlight || FlightGlobals.ActiveVessel == null || parent.vessel == null) {
return;
}
string[] values = node.GetValues("node");
int max = values.Length;
for (int k = 0; k < max; k++) {
string[] info = values[k].Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
Vector3d deltav = new Vector3d();
double d = 0.0;
if (info.Length == 4) {
double.TryParse(info[0], out d);
deltav.x = d;
d = 0.0;
double.TryParse(info[1], out d);
deltav.y = d;
d = 0.0;
double.TryParse(info[2], out d);
deltav.z = d;
d = 0.0;
double.TryParse(info[3], out d);
// at the very least it'll /act/ like a proper maneuver node.
nodes.Add(new NodeState(deltav, d));
}
}
Debug.Log("Node Saver loaded " + max + " nodes.");
}
示例5: Harddisk
public Harddisk(ConfigNode node)
{
Capacity = 10000;
foreach (string s in node.GetValues("capacity"))
{
Capacity = Int32.Parse(s);
}
foreach (string s in node.GetValues("volumeName"))
{
Name = s;
}
foreach (var fileNode in node.GetNodes("file"))
{
Files.Add(new File(fileNode));
}
}
示例6: EngineMount
public EngineMount(ConfigNode node)
{
name = node.GetStringValue("name");
layoutNames = node.GetValues("layoutName");
defaultDiameter = node.GetFloatValue("size", defaultDiameter);
minDiameter = node.GetFloatValue("minSize", minDiameter);
maxDiameter = node.GetFloatValue("maxSize", maxDiameter);
engineSpacing = node.GetFloatValue("engineSpacing", engineSpacing);
canAdjustSize = node.GetBoolValue("canAdjustSize", canAdjustSize);
rotateEngineModels = node.GetBoolValues("rotateEngines");
mountDefinition = SSTUEngineMountDefinition.getMountDefinition(name);
}
示例7: MathVariable
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);
}
}
示例8: VariableHandler
public VariableHandler(ConfigNode node, Part ourPart)
{
handlerName = node.GetValue("name");
foreach (string variableRecord in node.GetValues("variable"))
{
var record = new VariableRecord();
string[] tokens = variableRecord.Split(',');
if (tokens.Length >= 2)
{
double defaultDouble;
if (double.TryParse(tokens[1], NumberStyles.Any, CultureInfo.InvariantCulture, out defaultDouble))
{
record.defaultValue = defaultDouble;
}
else
{
if (tokens[1].Trim() == "fallback")
{
record.fallback = true;
}
else
{
record.defaultValue = tokens[1];
//record.defaultString = tokens[1];
}
}
}
if (tokens.Length >= 3)
{
record.cacheable = bool.Parse(tokens[2]);
}
handledVariables.Add(tokens[0], record);
}
active = InstantiateHandler(node, ourPart, out handlerFunction);
}
示例9: LoadFromNode
public override void LoadFromNode(ConfigNode node)
{
base.LoadFromNode(node);
var values = node.GetValues(ConfigName);
if (values.Length == 0) return;
CreateListIfNecessary();
bool createNewItems = false;
if (Count != values.Length)
{
ClearList();
createNewItems = true;
}
for (int i = 0; i < values.Length; i++)
{
object obj = null;
if (!createNewItems)
obj = List[i];
CFGUtil.AssignConfigObject(this, values[i], ref obj);
if (createNewItems)
List.Add(obj);
else
List[i] = obj; // This may be self-assignment under certain circumstances
}
}
示例10: ParseCurve
public static AnimationCurve ParseCurve(ConfigNode node)
{
var values = node.GetValues("key");
int length = (int)values.Length;
var curve = new AnimationCurve();
for (int i = 0; i < length; i++)
{
string[] strArrays = values[i].Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
curve.AddKey(float.Parse(strArrays[0]), float.Parse(strArrays[1]));
}
return (curve);
}
示例11: loadCrew
private Notes_Archived_Crew_Container loadCrew(ConfigNode node)
{
Notes_Archived_Crew_Container c = new Notes_Archived_Crew_Container();
for (int i = 0; i < node.GetValues("KERBAL").Length; i++)
{
string k = node.GetValues("KERBAL")[i];
if (string.IsNullOrEmpty(k))
continue;
if (HighLogic.CurrentGame.CrewRoster == null)
break;
ProtoCrewMember p = HighLogic.CurrentGame.CrewRoster[k];
if (p == null)
continue;
c.addCrewObject(p);
}
return c;
}
示例12: ReadCurve
// Readers
List<double[]> ReadCurve(FloatCurve curve)
{
ConfigNode config = new ConfigNode();
List<double[]> list = new List<double[]>();
NumericCollectionParser<double> value = new NumericCollectionParser<double>();
curve.Save(config);
foreach (string k in config.GetValues("key"))
{
value.SetFromString(k);
list.Add(value.value.ToArray());
}
return list;
}
示例13: InsertValue
private static void InsertValue(ConfigNode newNode, int index, string name, string value)
{
string[] oldValues = newNode.GetValues(name);
if (index < oldValues.Length)
{
newNode.RemoveValues(name);
int i = 0;
for (; i < index; ++i)
newNode.AddValue(name, oldValues[i]);
newNode.AddValue(name, value);
for (; i < oldValues.Length; ++i)
newNode.AddValue(name, oldValues[i]);
return;
}
newNode.AddValue(name, value);
}
示例14: OnLoad
public override void OnLoad(ConfigNode node)
{
if (!compatible) {
return;
}
if (MFSSettings.tankDefinitions == null) {
MFSSettings.Initialize ();
}
// Load the volume. If totalVolume is specified, use that to calc the volume
// otherwise scale up the provided volume. No KSPField support for doubles
if (node.HasValue ("totalVolume") && double.TryParse (node.GetValue ("totalVolume"), out totalVolume)) {
ChangeTotalVolume (totalVolume);
} else if (node.HasValue ("volume") && double.TryParse (node.GetValue ("volume"), out volume)) {
totalVolume = volume * 100d / utilization;
}
if (isDatabaseLoad) {
MFSSettings.SaveOverrideList(part, node.GetNodes("TANK"));
ParseBaseMass(node);
ParseBaseCost(node);
ParseInsulationFactor(node);
typesAvailable = node.GetValues ("typeAvailable");
RecordManagedResources ();
} else if (isEditorOrFlight) {
// The amounts initialized flag is there so that the tank type loading doesn't
// try to set up any resources. They'll get loaded directly from the save.
UpdateTankType (false);
// Destroy any resources still hanging around from the LOADING phase
for (int i = part.Resources.Count - 1; i >= 0; --i) {
PartResource partResource = part.Resources[i];
if (!tankList.Contains (partResource.resourceName))
continue;
part.Resources.Remove(partResource.info.id);
}
RaiseResourceListChanged ();
// Setup the mass
massDirty = true;
CalculateMass();
}
}
示例15: ModifyCurveKeys
public static FloatCurve ModifyCurveKeys(FloatCurve initialCurve, float vacMult, float atmMult, bool extendToZero)
{
ConfigNode tempNode = new ConfigNode();
initialCurve.Save(tempNode);
string[] keyStrings = tempNode.GetValues("key");
float maxTime, ispAtMaxTime, secondTime, ispAtSecondTime, maxPressure;
maxTime = ispAtMaxTime = secondTime = ispAtSecondTime = maxPressure = 0;
FloatCurve newAtmosphereCurve = new FloatCurve();
maxTime = initialCurve.maxTime;
for (int i = 0; i < keyStrings.Length; i++)
{
string[] splitKey = keyStrings[i].Split(' ');
float scalar = vacMult + Convert.ToSingle(splitKey[0]) * (atmMult - vacMult);
if (!extendToZero)
scalar = Mathf.Clamp(scalar, Mathf.Min(atmMult, vacMult), Mathf.Max(atmMult, vacMult));
if (Convert.ToSingle(splitKey[0]) != 0)
newAtmosphereCurve.Add(Convert.ToSingle(splitKey[0]), Convert.ToSingle(splitKey[1]) * scalar, Convert.ToSingle(splitKey[2]) * scalar, Convert.ToSingle(splitKey[3]) * scalar);
else
newAtmosphereCurve.Add(Convert.ToSingle(splitKey[0]), Convert.ToSingle(splitKey[1]) * scalar, 0, 0);
if (i == keyStrings.Length - 2)
{
secondTime = Convert.ToSingle(splitKey[0]);
ispAtSecondTime = Convert.ToSingle(splitKey[1]) * scalar;
}
}
ispAtMaxTime = newAtmosphereCurve.Evaluate(maxTime);
if (extendToZero && (ispAtSecondTime - ispAtMaxTime) >= 0.0001f)
{
maxPressure = maxTime + (0.01f - ispAtMaxTime) / (ispAtSecondTime - ispAtMaxTime) * (secondTime - maxTime);
newAtmosphereCurve.Add(maxPressure, 0.01f, 0, 0);
}
return newAtmosphereCurve;
}