本文整理汇总了C#中Vessel.GetActiveParts方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.GetActiveParts方法的具体用法?C# Vessel.GetActiveParts怎么用?C# Vessel.GetActiveParts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.GetActiveParts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnVesselRecoveryRequested
public void OnVesselRecoveryRequested(Vessel v)
{
//Get total ship cost
KerbalGUIManager.print("[rusty] OnVesselRecoveryRequested");
KerbalGUIManager.print("[rusty] parts.Count: " + v.parts.Count);
KerbalGUIManager.print("[rusty] Parts.Count: " + v.Parts.Count);
KerbalGUIManager.print("[rusty] GetActiveParts().Count: " + v.GetActiveParts().Count);
if (v.rootPart != null)
{
KerbalGUIManager.print("[rusty] Root part is alive");
}
else
{
KerbalGUIManager.print("[rusty] Root part is NULL");
}
ShipConstruct ship = new ShipConstruct(v.vesselName, "", v.rootPart);
ship.shipFacility = EditorFacility.VAB;
saveVesselLater = ship.SaveShip();
}
示例2: FixedUpdate
void FixedUpdate()
{
time = Planetarium.GetUniversalTime();
fixedDeltaTime = TimeWarp.fixedDeltaTime;
vesselName = null;
engineName = null;
vessel = FlightGlobals.ActiveVessel;
if (wireVessel != vessel)
{
if (wireVessel != null) wireVessel.OnFlyByWire -= FlyByWire;
wireVessel = vessel;
if (wireVessel != null) wireVessel.OnFlyByWire += FlyByWire;
}
if (vessel == null) return;
vesselName = vessel.vesselName;
var engine = vessel.GetActiveParts().SelectMany(part => part.Modules.OfType<ModuleEngines>()).FirstOrDefault();
if (engine == null) return;
engineName = engine.name;
finalThrust = engine.finalThrust;
fuelFlowGui = engine.fuelFlowGui;
status = engine.status;
statusL2 = engine.statusL2;
thrustPercentage = engine.thrustPercentage;
currentThrottle = engine.currentThrottle;
EngineIgnited = engine.EngineIgnited;
maxThrust = engine.maxThrust;
minThrust = engine.minThrust;
requestedThrottle = engine.requestedThrottle;
requestedThrust = engine.requestedThrust;
useEngineResponseTime = engine.useEngineResponseTime;
engineAccelerationSpeed = engine.engineAccelerationSpeed;
engineDecelerationSpeed = engine.engineDecelerationSpeed;
useVelocityCurve = engine.useVelocityCurve;
com = vessel.findWorldCenterOfMass();
up = (com - vessel.mainBody.position).normalized;
east = vessel.mainBody.getRFrmVel(com).normalized;
north = -Vector3.Cross(up, east);
var headingDir = vessel.GetSrfVelocity();
headingDir -= Vector3.Dot(headingDir, up) * up;
if (headingDir.sqrMagnitude > 0.5f)
{
headingDir = headingDir.normalized;
heading = Mathf.Acos(Vector3.Dot(north, headingDir)) * Mathf.Rad2Deg;
if (Vector3.Dot(east, headingDir) < 0) heading = -heading;
}
var pitchDir = vessel.GetSrfVelocity();
if (pitchDir.sqrMagnitude > 0.5f)
{
pitchDir = pitchDir.normalized;
pitch = Mathf.Acos(Vector3.Dot(up, pitchDir)) * Mathf.Rad2Deg;
}
//if (useCamera)
//{
// var q = vessel.VesselSAS.lockedHeading;
// var forward = q * Vector3.up;
// q = Quaternion.LookRotation(forward, up);
// vessel.VesselSAS.LockHeading(q);
//}
thrustMultiplier = thrustPercentage / 100f;
thrustEfficiency = 1;
if (useVelocityCurve) thrustEfficiency *= engine.velocityCurve.Evaluate((float)vessel.srf_velocity.magnitude);
up = (vessel.findWorldCenterOfMass() - vessel.mainBody.position).normalized;
thrustDirection = Vector3.zero;
foreach (var thrust in engine.thrustTransforms) thrustDirection += thrust.forward;
if (engine.thrustTransforms.Count > 0) thrustDirection = thrustDirection.normalized;
thrustEfficiency *= Vector3.Dot(-thrustDirection, up);
//if (desire)
//{
// desireCrank = Mathf.Round((desiredThrottle * thrustPercentage / 100f - currentThrottle) * 10000f) / 10000f;
// if (desireCrank > 0) desireCrank /= engineAccelerationSpeed * fixedDeltaTime;
// else if (desireCrank < 0) desireCrank /= engineDecelerationSpeed * fixedDeltaTime;
// if (currentThrottle + desireCrank >= 1) desireCrank = 1;
// else if (currentThrottle + desireCrank <= 0) desireCrank = 0;
// else if (desireCrank > 0) desireCrank = currentThrottle + desireCrank * desireCrank;
// else if (desireCrank < 0) desireCrank = currentThrottle - desireCrank * desireCrank;
// else desireCrank = desiredThrottle;
// desireCrank = Mathf.Clamp01(desireCrank * 100f / thrustPercentage);
//}
var deadzone = 0.01f;
var ascend = Mathf.Clamp01((Input.GetAxis("joy0.9") - deadzone) / (1.0f - deadzone));
var descend = Mathf.Clamp01((Input.GetAxis("joy0.8") - deadzone) / (1.0f - deadzone));
if (ascend > 0 || descend > 0 || mode == Mode.CONTROLLED)
{
mode = Mode.CONTROLLED;
desiredVelocity = (ControlMap(ascend) - ControlMap(descend)) * 30f;
}
//.........这里部分代码省略.........