本文整理汇总了C#中System.ConfigNode.HasValue方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.HasValue方法的具体用法?C# ConfigNode.HasValue怎么用?C# ConfigNode.HasValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.HasValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
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);
}
示例2: KIS_Item
/// <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");
}
}
示例3: Load
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"));
}
示例4: SatSettingNode
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; }
}
}
示例5: MappedVariable
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"));
}
示例6: OnLoad
/// <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")); }
}
示例7: Load
/// <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;
}
示例8: Load
public override bool Load(ConfigNode configNode)
{
// Load base class
bool valid = base.Load(configNode);
// Check on active contracts too
checkOnActiveContract = configNode.HasValue("checkOnActiveContract") ? checkOnActiveContract : true;
valid &= ConfigNodeUtil.ParseValue<List<string>>(configNode, "tech", x => techs = x, this, new List<string>());
if (configNode.HasValue("part"))
{
List<AvailablePart> parts = new List<AvailablePart>();
valid &= ConfigNodeUtil.ParseValue<List<AvailablePart>>(configNode, "part", x => parts = x, this);
foreach (AvailablePart part in parts)
{
techs.AddUnique(part.TechRequired);
}
}
valid &= ConfigNodeUtil.AtLeastOne(configNode, new string[] { "tech", "part" }, this);
return valid;
}
示例9: Load
public override bool Load(ConfigNode configNode)
{
// Load base class
bool valid = base.Load(configNode);
valid &= ConfigNodeUtil.ParseValue<ExperimentalPart.UnlockCriteria>(configNode, "unlockCriteria", x => unlockCriteria = x, this, ExperimentalPart.UnlockCriteria.CONTRACT_ACCEPTANCE);
if (unlockCriteria == ExperimentalPart.UnlockCriteria.PARAMETER_COMPLETION)
{
valid &= ConfigNodeUtil.ParseValue<string>(configNode, "unlockParameter", x => unlockParameter = x, this);
}
valid &= ConfigNodeUtil.ParseValue<ExperimentalPart.LockCriteria>(configNode, "lockCriteria", x => lockCriteria = x, this, ExperimentalPart.LockCriteria.CONTRACT_COMPLETION);
if (lockCriteria == ExperimentalPart.LockCriteria.PARAMETER_COMPLETION)
{
valid &= ConfigNodeUtil.ParseValue<string>(configNode, "lockParameter", x => lockParameter = x, this);
}
valid &= ConfigNodeUtil.ParseValue<List<AvailablePart>>(configNode, "part", x => parts = x, this);
if (configNode.HasValue("add"))
{
LoggingUtil.LogWarning(this, "The 'add' attribute of ExperimentalPartFactory is deprecated. Use 'unlockCriteria' instead.");
valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "add", x => unlockCriteria = x ? ExperimentalPart.UnlockCriteria.CONTRACT_ACCEPTANCE : ExperimentalPart.UnlockCriteria.DO_NOT_UNLOCK, this);
}
if (configNode.HasValue("remove"))
{
LoggingUtil.LogWarning(this, "The 'remove' attribute of ExperimentalPartFactory is deprecated. Use 'lockCriteria' instead.");
valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "remove", x => lockCriteria = x ? ExperimentalPart.LockCriteria.CONTRACT_COMPLETION : ExperimentalPart.LockCriteria.DO_NOT_LOCK, this);
}
return valid;
}
示例10: MappedVariable
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]);
}
示例11: OnLoad
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);
}
示例12: OnLoad
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);
}
示例13: OnLoad
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;
}
示例14: FromConfigNode
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);
}
示例15: Harddisk
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));
}
}