本文整理汇总了C#中Vessel.IsEvaKerbal方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.IsEvaKerbal方法的具体用法?C# Vessel.IsEvaKerbal怎么用?C# Vessel.IsEvaKerbal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.IsEvaKerbal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateVesselHeight
/// <summary>
/// This method calculates the height in meters from the ship's "current point" to its lowest
/// extent. Subtracting this number from vessel.altitude gives the altitude of the bottom
/// of the ship, in the ship's current orientation.
///
/// Thank you to SirDiazo's mod Landing Height for code that inspired this section.
/// Landing Height: https://kerbalstuff.com/mod/458/Landing%20Height
///
/// It's notable that this code is somewhat simplified from SirDiazo's because it's solving
/// a simpler problem (i.e. it's saving computation by giving more of an approximation).
///
/// This is a moderately expensive calculation to perform, so use sparingly (i.e. not on
/// every frame).
/// </summary>
/// <returns></returns>
private static double CalculateVesselHeight(Vessel vessel, out Part lowestPart)
{
lowestPart = null;
if (IsTimeWarp) return 0.0; // vessel is packed, can't do anything
if (vessel.IsEvaKerbal()) return 0.0; // we don't do this for kerbals
List<Part> parts = ChooseParts(vessel);
double minPartPosition = double.PositiveInfinity;
for (int partIndex = 0; partIndex < parts.Count; ++partIndex)
{
Part part = parts[partIndex];
if (!part.collider.enabled) continue;
double partPosition = Vector3.Distance(
part.collider.ClosestPointOnBounds(vessel.mainBody.position),
vessel.mainBody.position);
if (partPosition < minPartPosition)
{
minPartPosition = partPosition;
lowestPart = part;
}
}
if (lowestPart == null) return 0.0; // no usable parts
double vesselPosition = Vector3.Distance(
//vessel.GetReferenceTransformPart().transform.position,
vessel.transform.position,
vessel.mainBody.position);
return vesselPosition - minPartPosition;
}