本文整理汇总了C#中Part.FindModuleImplementing方法的典型用法代码示例。如果您正苦于以下问题:C# Part.FindModuleImplementing方法的具体用法?C# Part.FindModuleImplementing怎么用?C# Part.FindModuleImplementing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.FindModuleImplementing方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModuleWheelBaseAdaptor
public ModuleWheelBaseAdaptor(Part part)
{
_moduleWheelBase = part.FindModuleImplementing<ModuleWheelBase>();
_moduleWheelMotor = part.FindModuleImplementing<ModuleWheelMotor>();
_moduleWheelMotorSteering = part.FindModuleImplementing<ModuleWheelMotorSteering>();
_moduleWheelDamage = part.FindModuleImplementing<ModuleWheelDamage>();
}
示例2: FindThermalSource
public static ThermalSourceSearchResult FindThermalSource(Part currentpart, Func<IThermalSource, bool> condition, int stackdepth, int parentdepth, bool skipSelfContained )
{
if (stackdepth == 0)
{
var thermalsources = currentpart.FindModulesImplementing<IThermalSource>().Where(condition);
var source = skipSelfContained ? thermalsources.FirstOrDefault(s => !s.IsSelfContained) : thermalsources.FirstOrDefault();
if (source != null)
return new ThermalSourceSearchResult(source, 0);
else
return null;
}
var thermalcostModifier = currentpart.FindModuleImplementing<ThermalPowerTransport>();
float stackDepthCost = thermalcostModifier != null ? thermalcostModifier.thermalCost : 1;
foreach (var attachNodes in currentpart.attachNodes.Where(atn => atn.attachedPart != null))
{
var source = FindThermalSource(attachNodes.attachedPart, condition, (stackdepth - 1), parentdepth, skipSelfContained);
if (source != null)
return source.IncreaseCost(stackDepthCost);
}
if (parentdepth > 0 && currentpart.parent != null)
{
var source = FindThermalSource(currentpart.parent, condition, (stackdepth - 1), (parentdepth - 1), skipSelfContained);
if (source != null)
return source.IncreaseCost(2f);
}
return null;
}
示例3: PartUnpacked
public void PartUnpacked(Part part)
{
if (HighLogic.LoadedSceneIsFlight == false)
return;
WBIExtractionMonitor extractionMonitor = null;
if (part.FindModuleImplementing<ModuleResourceHarvester>() == null)
return;
//Add an extraction monitor if needed.
extractionMonitor = part.FindModuleImplementing<WBIExtractionMonitor>();
if (extractionMonitor == null)
{
extractionMonitor = (WBIExtractionMonitor)part.AddModule("WBIExtractionMonitor");
extractionMonitor.OnActive();
extractionMonitor.OnStart(PartModule.StartState.Landed);
extractionMonitor = null;
}
}
示例4: SetNewSection
private static void SetNewSection(Part part, string oldSectionName, string newSectionName)
{
var section = part.FindModuleImplementing<SectionInfo>();
if(section?.section == oldSectionName)
{
section.section = newSectionName;
foreach (var child in part.children)
{
SetNewSection(child, oldSectionName, newSectionName);
}
}
}
示例5: AttachCollector
void AttachCollector(Part toPart) {
toPart.AddModule("ModuleExhaustCapture");
ModuleExhaustCapture newModule = toPart.FindModuleImplementing<ModuleExhaustCapture>();
ModuleResource outPutRes = new ModuleResource();
if (primaryResourceName != null && primaryResourceRate != 0 && PartResourceLibrary.Instance.resourceDefinitions.Contains(primaryResourceName))
{
outPutRes.name = primaryResourceName;
outPutRes.id = PartResourceLibrary.Instance.GetDefinition(primaryResourceName).id; //Do I need this
outPutRes.rate = primaryResourceRate*thrustMultiplier;
newModule.outputResources.Add(outPutRes);
print("PZER: Capture " + outPutRes.name + " " + outPutRes.id + " added with a real rate of " + outPutRes.rate * thrustMultiplier);
}
else
{
print("PZER: " + part.partName + " has bad primary resource/rate: " + primaryResourceName +" rate: " + primaryResourceRate);
}
if (secondaryResourceName != null && secondaryResourceRate != 0 && PartResourceLibrary.Instance.resourceDefinitions.Contains(secondaryResourceName)) {
outPutRes.name = secondaryResourceName;
outPutRes.id = PartResourceLibrary.Instance.GetDefinition(secondaryResourceName).id; //see above
outPutRes.rate = secondaryResourceRate * thrustMultiplier;
newModule.outputResources.Add(outPutRes);
print("PZER: Secondary capture " + outPutRes.name + " " + outPutRes.id + " added with a real rate of " + outPutRes.rate * thrustMultiplier);
}
else
{
print("PZER: " + part.partName + " has bad secondary resource/rate: " + secondaryResourceName + " rate: " + secondaryResourceRate);
}
newModule.heatIncrease = (float)additionalHeatRate;
}
示例6: EditorPartEvent
private void EditorPartEvent(ConstructionEventType data0, Part data1)
{
var sectionInfo = data1.FindModuleImplementing<SectionInfo>();
if (data0 == ConstructionEventType.PartDetached)
{
CopySectionDataToOtherPartInSection(sectionInfo, true);
}
if (data0 == ConstructionEventType.PartCreated && data1 == EditorLogic.RootPart)
{
LogFormatted_DebugOnly("Initializing root section.");
sectionInfo.isSectionRoot = true;
sectionInfo.InitializeAsNewSection();
}
if(data0 == ConstructionEventType.PartAttached)
{
sectionInfo.TrySetSectionBasedOnParent();
if (EditorLogic.fetch.symmetryMode != 1 && sectionInfo.isSectionRoot)
EnsureOnlyOneSectionRoot(sectionInfo);
}
}
示例7: IsARadialDecoupler
private static bool IsARadialDecoupler(Part part)
{
return part.HasModule<ModuleAnchoredDecoupler>() ||
part.FindModuleImplementing<ModuleDecouple>()?.explosiveNodeID == "srf";
}
示例8: OnReferenceTransfomPartChange
// Psuedo-event from checking Update()
private void OnReferenceTransfomPartChange(Part part)
{
Log.Trace("Entering PlaneMode.OnReferenceTransfomPartChange()");
Log.Debug("ReferenceTransformPart has changed");
if (part != null)
{
Log.Debug("part is not null, finding ModulePlaneMode on: " + part.partInfo.title);
var modulePlaneMode = part.FindModuleImplementing<ModulePlaneMode>();
if (modulePlaneMode != null)
{
Log.Debug("Found ModulePlaneMode, updating _currentModulePlaneMode and calling SetControlMode()");
_currentModulePlaneMode = modulePlaneMode;
SetControlMode(_currentModulePlaneMode.ControlMode);
}
}
else
{
Log.Debug("part is null, updating _currentModulePlaneMode");
_currentModulePlaneMode = null;
}
Log.Trace("Leaving PlaneMode.OnReferenceTransfomPartChange()");
}
示例9: force_occlusion_update
public static void force_occlusion_update(Part p, bool overwrite = false)
{
if (p == null)
return;
if (!p.DragCubes.None)
{
ModuleParachute mp = p.FindModuleImplementing<ModuleParachute>();
if (mp != null)
{
p.DragCubes.SetCubeWeight("PACKED", 1.0f);
p.DragCubes.SetCubeWeight("SEMIDEPLOYED", 0.0f);
p.DragCubes.SetCubeWeight("DEPLOYED", 0.0f);
p.DragCubes.SetOcclusionMultiplier(1.0f);
}
if (overwrite)
p.DragCubes.ForceUpdate(true, true);
p.DragCubes.SetDragWeights();
p.DragCubes.RequestOcclusionUpdate();
p.DragCubes.SetPartOcclusion();
}
}