本文整理汇总了C#中System.ConfigNode.SetAddValue方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.SetAddValue方法的具体用法?C# ConfigNode.SetAddValue怎么用?C# ConfigNode.SetAddValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.SetAddValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetConfiguration
//.........这里部分代码省略.........
DoConfig(config);
// Handle Engine Ignitor
if (config.HasNode("ModuleEngineIgnitor"))
{
if (part.Modules.Contains("ModuleEngineIgnitor"))
{
ConfigNode eiNode = config.GetNode("ModuleEngineIgnitor");
if (eiNode.HasValue("ignitionsAvailable"))
{
int ignitions;
if (int.TryParse(eiNode.GetValue("ignitionsAvailable"), out ignitions))
{
ignitions = ConfigIgnitions(ignitions);
eiNode.SetValue("ignitionsAvailable", ignitions.ToString());
if (eiNode.HasValue("ignitionsRemained"))
eiNode.SetValue("ignitionsRemained", ignitions.ToString());
else
eiNode.AddValue("ignitionsRemained", ignitions.ToString());
}
}
if (!HighLogic.LoadedSceneIsEditor && !(HighLogic.LoadedSceneIsFlight && vessel != null && vessel.situation == Vessel.Situations.PRELAUNCH)) // fix for prelaunch
{
int remaining = (int)(part.Modules["ModuleEngineIgnitor"].GetType().GetField("ignitionsRemained").GetValue(part.Modules["ModuleEngineIgnitor"]));
if (eiNode.HasValue("ignitionsRemained"))
eiNode.SetValue("ignitionsRemained", remaining.ToString());
else
eiNode.AddValue("ignitionsRemained", remaining.ToString());
}
ConfigNode tNode = new ConfigNode("MODULE");
eiNode.CopyTo(tNode);
tNode.SetAddValue("name", "ModuleEngineIgnitor");
part.Modules["ModuleEngineIgnitor"].Load(tNode);
}
else // backwards compatible with EI nodes when using RF ullage etc.
{
ConfigNode eiNode = config.GetNode("ModuleEngineIgnitor");
if (eiNode.HasValue("ignitionsAvailable") && !config.HasValue("ignitions"))
{
config.AddValue("ignitions", eiNode.GetValue("ignitionsAvailable"));
}
if (eiNode.HasValue("useUllageSimulation") && !config.HasValue("ullage"))
config.AddValue("ullage", eiNode.GetValue("useUllageSimulation"));
if (eiNode.HasValue("isPressureFed") && !config.HasValue("pressureFed"))
config.AddValue("pressureFed", eiNode.GetValue("isPressureFed"));
if (!config.HasNode("IGNITOR_RESOURCE"))
foreach (ConfigNode resNode in eiNode.GetNodes("IGNITOR_RESOURCE"))
config.AddNode(resNode);
}
}
if (config.HasValue("ignitions"))
{
int ignitions;
if ((!HighLogic.LoadedSceneIsFlight || (vessel != null && vessel.situation == Vessel.Situations.PRELAUNCH)))
{
if (int.TryParse(config.GetValue("ignitions"), out ignitions))
{
ignitions = ConfigIgnitions(ignitions);
config.SetValue("ignitions", ignitions.ToString());
}
}
else
config.RemoveValue("ignitions");
}
示例2: DoConfig
//.........这里部分代码省略.........
}
else if (thrustRating.Equals("thrusterPower"))
{
configMinThrust = configMaxThrust * 0.5f;
}
else
{
configMinThrust = configMaxThrust;
if (configThrottle > 1.0f)
{
if (techLevel >= configThrottle)
configThrottle = 1.0f;
else
configThrottle = -1.0f;
}
if (configThrottle >= 0.0f)
{
configThrottle = (float)((double)configThrottle * cTL.Throttle());
configMinThrust *= configThrottle;
}
}
configThrottle = configMinThrust / configMaxThrust;
if (origMass > 0)
TLMassMult = MassTL(1.0f);
}
// Don't want to change gimbals on TL-enabled engines willy-nilly
// So we don't unless either a transform is specified, or we override.
// We assume if it was specified in the CONFIG that we should use it anyway.
if (gimbal < 0 && (!gimbalTransform.Equals("") || useGimbalAnyway))
gimbal = cTL.GimbalRange;
if (gimbal >= 0)
{
// allow local override of gimbal mult
if (cfg.HasValue("gimbalMult"))
gimbal *= float.Parse(cfg.GetValue("gimbalMult"));
}
// Cost (multiplier will be 1.0 if unspecified)
cost = scale * CostTL(cost, cfg);
}
else
{
if (cfg.HasValue(thrustRating) && configThrottle > 0f && !cfg.HasValue("minThrust"))
{
configMinThrust = configThrottle * configMaxThrust;
}
}
// Now update the cfg from what we did.
// thrust updates
if(configMaxThrust >= 0f)
cfg.SetAddValue(thrustRating, configMaxThrust.ToString("0.0000"));
if(configMinThrust >= 0f)
cfg.SetAddValue("minThrust", configMinThrust.ToString("0.0000")); // will be ignored by RCS, so what.
// heat update
if(configHeat >= 0f)
cfg.SetAddValue("heatProduction", configHeat.ToString("0"));
// mass change
if (origMass > 0)
{
float ftmp;
configMassMult = scale;
if (cfg.HasValue("massMult"))
if (float.TryParse(cfg.GetValue("massMult"), out ftmp))
configMassMult *= ftmp;
part.mass = origMass * configMassMult * RFSettings.Instance.EngineMassMultiplier * TLMassMult;
massDelta = 0;
if ((object)(part.partInfo) != null)
if ((object)(part.partInfo.partPrefab) != null)
massDelta = part.mass - part.partInfo.partPrefab.mass;
}
// KIDS integration
if (cfg.HasNode("atmosphereCurve"))
{
ConfigNode newCurveNode = new ConfigNode("atmosphereCurve");
FloatCurve oldCurve = new FloatCurve();
oldCurve.Load(cfg.GetNode("atmosphereCurve"));
FloatCurve newCurve = Utilities.Mod(oldCurve, ispSLMult, ispVMult);
newCurve.Save(newCurveNode);
cfg.RemoveNode("atmosphereCurve");
cfg.AddNode(newCurveNode);
}
// gimbal change
if (gimbal >= 0 && !cfg.HasValue("gimbalRange")) // if TL set a gimbal
{
// apply module-wide gimbal mult on top of any local ones
cfg.AddValue("gimbalRange", (gimbal * gimbalMult).ToString("N4"));
}
if (cost != 0f)
{
if (cfg.HasValue("cost"))
cfg.SetValue("cost", cost.ToString("N3"));
else
cfg.AddValue("cost", cost.ToString("N3"));
}
}