本文整理汇总了C#中Part.IsEngine方法的典型用法代码示例。如果您正苦于以下问题:C# Part.IsEngine方法的具体用法?C# Part.IsEngine怎么用?C# Part.IsEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.IsEngine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasDeactivatedEngineOrTankDescendant
//detect if a part is above a deactivated engine or fuel tank
public static bool HasDeactivatedEngineOrTankDescendant(Part p)
{
if ((p.State == PartStates.DEACTIVATED) && (p is FuelTank || p.IsEngine()) && !p.IsSepratron())
{
return true; // TODO: yet more ModuleEngine lazy checks
}
//check if this is a new-style fuel tank that's run out of resources:
bool hadResources = false;
bool hasResources = false;
foreach (PartResource r in p.Resources)
{
if (r.name == "ElectricCharge") continue;
if (r.maxAmount > 0) hadResources = true;
if (r.amount > 0) hasResources = true;
}
if (hadResources && !hasResources) return true;
if (p.IsEngine() && !p.EngineHasFuel()) return true;
foreach (Part child in p.children)
{
if (HasDeactivatedEngineOrTankDescendant(child)) return true;
}
return false;
}
示例2: HasActiveOrIdleEngineOrTankDescendant
//detect if a part is above an active or idle engine in the part tree
public static bool HasActiveOrIdleEngineOrTankDescendant(Part p, List<int> tankResources)
{
if ((p.State == PartStates.ACTIVE || p.State == PartStates.IDLE)
&& p.IsEngine() && !p.IsSepratron() && p.EngineHasFuel())
{
return true; // TODO: properly check if ModuleEngines is active
}
if ((p is FuelTank) && (((FuelTank)p).fuel > 0)) return true;
if (!p.IsSepratron())
{
for (int i = 0; i < p.Resources.Count; i++)
{
PartResource r = p.Resources[i];
if (r.amount > 0 && r.info.name != "ElectricCharge" && tankResources.Contains(r.info.id))
{
return true;
}
}
}
for (int i = 0; i < p.children.Count; i++)
{
if (HasActiveOrIdleEngineOrTankDescendant(p.children[i], tankResources))
{
return true;
}
}
return false;
}
示例3: PartIsEngine
// Find resources burned by engines that will remain after staging (so we wait until tanks are empty before releasing drop tanks)
bool PartIsEngine(Part p)
{
return p.inverseStage >= Staging.CurrentStage && p.IsEngine() && !p.IsSepratron() &&
!p.IsDecoupledInStage(Staging.CurrentStage - 1);
}