本文整理汇总了C#中PartModule.Load方法的典型用法代码示例。如果您正苦于以下问题:C# PartModule.Load方法的具体用法?C# PartModule.Load怎么用?C# PartModule.Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PartModule
的用法示例。
在下文中一共展示了PartModule.Load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetConfiguration
public virtual void SetConfiguration(string newConfiguration = null, bool resetTechLevels = false)
{
if (newConfiguration == null)
newConfiguration = configuration;
ConfigSaveLoad();
ConfigNode newConfig = configs.Find (c => c.GetValue ("name").Equals (newConfiguration));
if (!UnlockedConfig(newConfig, part))
{
if(newConfig == null)
Debug.Log("*RFMEC* ERROR Can't find configuration " + newConfiguration + ", falling back to first tech-available config.");
foreach(ConfigNode cfg in configs)
if (UnlockedConfig(cfg, part))
{
newConfig = cfg;
newConfiguration = cfg.GetValue("name");
break;
}
}
if (newConfig != null)
{
if (configuration != newConfiguration && resetTechLevels)
techLevel = origTechLevel;
// for asmi
if (useConfigAsTitle)
part.partInfo.title = configuration;
configuration = newConfiguration;
config = new ConfigNode("MODULE");
newConfig.CopyTo(config);
config.name = "MODULE";
#if DEBUG
print ("replacing " + type + " with:");
print (newConfig.ToString ());
#endif
pModule = null;
// get correct module
pModule = GetSpecifiedModule(part, engineID, moduleIndex, type, useWeakType);
if ((object)pModule == null)
{
Debug.Log("*RFMEC* Could not find appropriate module of type " + type + ", with ID=" + engineID + " and index " + moduleIndex);
return;
}
Type mType = pModule.GetType();
config.SetValue("name", mType.Name);
// clear all FloatCurves we need to clear (i.e. if our config has one, or techlevels are enabled)
bool delAtmo = config.HasNode("atmosphereCurve") || techLevel >= 0;
bool delDens = config.HasNode("atmCurve") || techLevel >= 0;
bool delVel = config.HasNode("velCurve") || techLevel >= 0;
foreach (FieldInfo field in mType.GetFields())
{
if (field.FieldType == typeof(FloatCurve) &&
((field.Name.Equals("atmosphereCurve") && delAtmo)
|| (field.Name.Equals("atmCurve") && delDens)
|| (field.Name.Equals("velCurve") && delVel)))
{
field.SetValue(pModule, new FloatCurve());
}
}
// clear propellant gauges
foreach (FieldInfo field in mType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
{
if (field.FieldType == typeof(Dictionary<Propellant, VInfoBox>))
{
Dictionary<Propellant, VInfoBox> boxes = (Dictionary<Propellant, VInfoBox>)(field.GetValue(pModule));
if (boxes == null)
continue;
foreach (VInfoBox v in boxes.Values)
{
if (v == null) //just in case...
continue;
try
{
part.stackIcon.RemoveInfo(v);
}
catch (Exception e)
{
Debug.Log("*RFMEC* Trying to remove info box: " + e.Message);
}
}
boxes.Clear();
}
}
if (type.Equals("ModuleRCS") || type.Equals("ModuleRCSFX"))
{
ModuleRCS rcs = (ModuleRCS)pModule;
if (rcs != null)
{
DoConfig(config);
if (config.HasNode("PROPELLANT"))
{
rcs.propellants.Clear();
//.........这里部分代码省略.........