本文整理汇总了C#中Part.FindModulesImplementing方法的典型用法代码示例。如果您正苦于以下问题:C# Part.FindModulesImplementing方法的具体用法?C# Part.FindModulesImplementing怎么用?C# Part.FindModulesImplementing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.FindModulesImplementing方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: DisableAnimateButton
/// <summary>Disables the "animate" button in the part context menu.</summary>
/// <param name="part">Part reference to affect.</param>
public static void DisableAnimateButton(Part part)
{
if (HighLogic.LoadedSceneIsEditor)
{
foreach (ModuleAnimateGeneric ma in part.FindModulesImplementing<ModuleAnimateGeneric>())
{
try
{
ma.Actions["ToggleAction"].active = false;
}
catch
{
//do nothing
}
try
{
ma.Events["Toggle"].guiActive = false;
}
catch
{
//do nothing
}
}
}
}
示例3: 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(s => s.IsThermalSource);
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;
}
int stackDepthCost = currentpart.partInfo.title.Contains("Non-androgynous") && currentpart.Modules.Contains("ModuleAdaptiveDockingNode") ? 0 : 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;
}
示例4: IsActiveDecoupler
private bool IsActiveDecoupler(Part thePart)
{
return thePart.FindModulesImplementing<ModuleDecouple>().Any(mod => !mod.isDecoupled) ||
thePart.FindModulesImplementing<ModuleAnchoredDecoupler>().Any(mod => !mod.isDecoupled);
}
示例5: PartInfo
protected void PartInfo(Part part)
{
Vector3 com;
part.GetCoM (out com);
GUILayout.Label (string.Format (
"phy: {0} rb: {1} m: {2:F3} cm: {3:F3}\n" +
"com: {4}",
part.physicalSignificance,
part.rb != null,
part.GetTotalMass(),
part.GetPhysicslessChildMassInEditor (),
com));
var engines = part.FindModulesImplementing<ModuleEngines> ();
foreach(var engine in engines) {
GUILayout.Label ("<b>ModuleEngine</b> " + engine.engineID);
GUILayout.Label (string.Format (
"min thrust: {0} max thrust: {1}\n" +
"vac isp: {2} asl isp: {3}",
engine.minThrust, engine.maxThrust,
engine.atmosphereCurve.Evaluate (0f),
engine.atmosphereCurve.Evaluate (1f)));
}
var enginesfx = part.FindModulesImplementing<ModuleEnginesFX> ();
foreach(var engine in enginesfx) {
GUILayout.Label ("<b>ModuleEngineFX</b> " + engine.engineID);
GUILayout.Label (string.Format (
"min thrust: {0} max thrust: {1}\n" +
"vac isp: {2} asl isp: {3}",
engine.minThrust, engine.maxThrust,
engine.atmosphereCurve.Evaluate (0f),
engine.atmosphereCurve.Evaluate (1f)));
}
}
示例6: CheckIfMissile
public static bool CheckIfMissile(Part p)
{
if(p.FindModulesImplementing<MissileLauncher>().Count > 0)
{
return true;
}
else return false;
}
示例7: get_part_torque
public static Vector3 get_part_torque(CenterOfLiftQuery qry, Part p, Vector3 CoM, ref float lift, ref float drag)
{
if (p == null || (p.Rigidbody != p.rb) && !PhysicsGlobals.ApplyDragToNonPhysicsParts)
return Vector3.zero;
Vector3 lift_pos = Vector3.zero;
Vector3 drag_pos = Vector3.zero;
if (!p.ShieldedFromAirstream)
{
var providers = p.FindModulesImplementing<ModuleLiftingSurface>();
if ((providers != null) && providers.Count > 0)
p.hasLiftModule = true;
Vector3 res = Vector3.zero;
if (p.hasLiftModule && providers[0] is ModuleControlSurface)
{
p.DragCubes.SetCubeWeight("neutral", 1.5f);
p.DragCubes.SetCubeWeight("fullDeflectionPos", 0.0f);
p.DragCubes.SetCubeWeight("fullDeflectionNeg", 0.0f);
}
// drag from drag-cubes
if (!p.DragCubes.None)
{
Vector3 drag_force = Vector3.zero;
p.dragVector = qry.refVector;
p.dragVectorSqrMag = p.dragVector.sqrMagnitude;
p.dragVectorMag = Mathf.Sqrt(p.dragVectorSqrMag);
p.dragVectorDir = p.dragVector / p.dragVectorMag;
p.dragVectorDirLocal = -p.partTransform.InverseTransformDirection(p.dragVectorDir);
p.dynamicPressurekPa = qry.refAirDensity * 0.0005 * p.dragVectorSqrMag;
if (p.rb != p.Rigidbody && PhysicsGlobals.ApplyDragToNonPhysicsPartsAtParentCoM)
{
drag_pos = p.Rigidbody.worldCenterOfMass;
lift_pos = drag_pos;
}
else
{
lift_pos = p.partTransform.TransformPoint(p.CoLOffset);
drag_pos = p.partTransform.TransformPoint(p.CoPOffset);
}
p.DragCubes.SetDrag(p.dragVectorDirLocal, mach);
float pseudoreynolds = (float)(density * Mathf.Abs(speed));
float pseudoredragmult = PhysicsGlobals.DragCurvePseudoReynolds.Evaluate(pseudoreynolds);
float drag_k = p.DragCubes.AreaDrag * PhysicsGlobals.DragCubeMultiplier * pseudoredragmult;
p.dragScalar = (float)(p.dynamicPressurekPa * drag_k * PhysicsGlobals.DragMultiplier);
drag_force = p.dragScalar * -p.dragVectorDir;
res += Vector3.Cross(drag_force, drag_pos - CoM);
Vector3 sum_force = drag_force;
drag += Vector3.Dot(sum_force, -p.dragVectorDir);
}
if (!p.hasLiftModule)
{
// stock aero lift
if (!p.DragCubes.None)
{
p.bodyLiftScalar = (float)(p.dynamicPressurekPa * p.bodyLiftMultiplier * PhysicsGlobals.BodyLiftMultiplier *
CorrectCoL.CoLMarkerFull.lift_curves.liftMachCurve.Evaluate(mach));
Vector3 lift_force = p.partTransform.rotation * (p.bodyLiftScalar * p.DragCubes.LiftForce);
lift_force = Vector3.ProjectOnPlane(lift_force, -p.dragVectorDir);
res += Vector3.Cross(lift_force, lift_pos - CoM);
Vector3 sum_force = lift_force;
lift += Vector3.Dot(sum_force, Vector3.Cross(p.dragVectorDir, EditorLogic.RootPart.transform.right).normalized);
}
return res;
}
else
{
double q = 0.5 * qry.refAirDensity * qry.refVector.sqrMagnitude;
for (int i = 0; i < providers.Count; i++)
{
Vector3 dragvect;
Vector3 liftvect;
Vector3 lift_force = Vector3.zero;
Vector3 drag_force = Vector3.zero;
float abs;
ModuleLiftingSurface lsurf = providers[i];
ModuleControlSurface csurf = lsurf as ModuleControlSurface;
lsurf.SetupCoefficients(qry.refVector, out dragvect, out liftvect, out lsurf.liftDot, out abs);
lift_pos = p.partTransform.TransformPoint(p.CoLOffset);
drag_pos = p.partTransform.TransformPoint(p.CoPOffset);
//.........这里部分代码省略.........
示例8: PartInfo
protected void PartInfo(Part part)
{
Vector3 com;
part.GetCoM (out com);
GUILayout.Label (string.Format (
"phy: {0} rb: {1} m: {2:F3}t cm: {3:F3}t\n" +
"pm: {4:F3}t rm: {5:F3} mm: {6:F3}t\n" +
"com: {7}\n" +
"max_drag: {8:F3} AreaDrag: {9:F3}\n" +
"dvector: {10}",
part.physicalSignificance,
part.rb != null,
part.GetTotalMass (),
part.GetPhysicslessChildMassInEditor (),
part.mass,
part.GetResourceMass (),
part.GetModuleMass (part.mass),
com,
part.maximum_drag,
part.DragCubes.AreaDrag,
part.DragCubes.DragVector
));
var engines = part.FindModulesImplementing<ModuleEngines> ();
foreach(var engine in engines) {
GUILayout.Label ("<b>ModuleEngine</b> " + engine.engineID);
GUILayout.Label (string.Format (
"min thrust: {0} max thrust: {1}\n" +
"vac isp: {2} asl isp: {3}",
engine.minThrust, engine.maxThrust,
engine.atmosphereCurve.Evaluate (0f),
engine.atmosphereCurve.Evaluate (1f)));
}
var enginesfx = part.FindModulesImplementing<ModuleEnginesFX> ();
foreach(var engine in enginesfx) {
GUILayout.Label ("<b>ModuleEngineFX</b> " + engine.engineID);
GUILayout.Label (string.Format (
"min thrust: {0} max thrust: {1}\n" +
"vac isp: {2} asl isp: {3}",
engine.minThrust, engine.maxThrust,
engine.atmosphereCurve.Evaluate (0f),
engine.atmosphereCurve.Evaluate (1f)));
}
}
示例9: startIVA
public bool startIVA(Part p)
{
ProbeControlRoomUtils.Logger.debug ("[ProbeControlRoom] startIVA(Part)");
Transform actualTransform;
refreshVesselRooms ();
if(vesselRooms.Contains(p))
{
aModule = p.FindModulesImplementing<ProbeControlRoomPart> ().First ();
aPart = p;
// TODO when currentReference its a dockingport, store and restore that instead?
p.MakeReferencePart ();
actualTransform = p.internalModel.FindModelTransform (aModule.seatTransformName);
if (Transform.Equals (actualTransform, null)) {
ProbeControlRoomUtils.Logger.error ("[ProbeControlRoom] startIVA(Part) - NULL on actualTransform-seatTransformName, using fallback...");
actualTransform = p.internalModel.FindModelTransform ("Seat");
} else {
ProbeControlRoomUtils.Logger.message ("[ProbeControlRoom] startIVA(Part) - Seat: "+aModule.seatTransformName.ToString());
}
ProbeControlRoomUtils.Logger.debug ("[ProbeControlRoom] startIVA(Part) - fire up IVA");
//disable sound
shipVolumeBackup = GameSettings.SHIP_VOLUME;
ambianceVolumeBackup = GameSettings.AMBIENCE_VOLUME;
//musicVolumeBackup = GameSettings.MUSIC_VOLUME;
//uiVolumeBackup = GameSettings.UI_VOLUME;
//voiceVolumeBackup = GameSettings.VOICE_VOLUME;
if (ProbeControlRoomSettings.Instance.DisableSounds) {
ProbeControlRoomUtils.Logger.message ("[ProbeControlRoom] startIVA(Part) - DisableSounds");
GameSettings.SHIP_VOLUME = 0f;
GameSettings.AMBIENCE_VOLUME = 0;
GameSettings.MUSIC_VOLUME = 0;
GameSettings.UI_VOLUME = 0;
GameSettings.VOICE_VOLUME = 0;
}
//disable camera wobble
cameraWobbleBackup = GameSettings.FLT_CAMERA_WOBBLE;
cameraFXInternalBackup = GameSettings.CAMERA_FX_INTERNAL;
cameraFXExternalBackup = GameSettings.CAMERA_FX_EXTERNAL;
if (ProbeControlRoomSettings.Instance.DisableWobble) {
ProbeControlRoomUtils.Logger.message ("[ProbeControlRoom] startIVA(Part) - DisableWobble");
GameSettings.FLT_CAMERA_WOBBLE = 0;
GameSettings.CAMERA_FX_INTERNAL = 0;
GameSettings.CAMERA_FX_EXTERNAL = 0;
}
// TODO: create cfg file with cached vars, on crash to be restored
CameraManager.ICameras_DeactivateAll ();
FlightCamera.fetch.EnableCamera ();
FlightCamera.fetch.DeactivateUpdate ();
FlightCamera.fetch.gameObject.SetActive (true);
FlightEVA.fetch.DisableInterface ();
InternalCamera.Instance.SetTransform(actualTransform, true);
InternalCamera.Instance.EnableCamera ();
FlightGlobals.ActiveVessel.SetActiveInternalPart (p.internalModel.part);
IVASun sunBehaviour;
sunBehaviour = (IVASun)FindObjectOfType(typeof(IVASun));
sunBehaviour.enabled = false;
isActive = true;
if(UIPartActionController.Instance != null)
UIPartActionController.Instance.Deactivate ();
CameraManager.Instance.currentCameraMode = CameraManager.CameraMode.Internal;
ProbeControlRoomUtils.Logger.debug ("[ProbeControlRoom] startIVA(Part) - DONE");
return true;
} else {
ProbeControlRoomUtils.Logger.error ("[ProbeControlRoom] startIVA(Part) - Cannot instantiate ProbeControlRoom in this location - Part/ModuleNotFound");
throw new ArgumentException("[ProbeControlRoom] startIVA(Part) - Cannot instantiate ProbeControlRoom in this location - Part/ModuleNotFound");
//return false;
}
}
示例10: FireMissile
public void FireMissile()
{
if(lastFiredSym != null && lastFiredSym.partInfo.title == selectedWeapon)
{
Part nextPart;
if(FindSym(lastFiredSym)!=null) nextPart = FindSym(lastFiredSym);
else nextPart = null;
foreach(MissileLauncher ml in lastFiredSym.FindModulesImplementing<MissileLauncher>())
{
if(guardTarget!=null)
{
ml.FireMissileOnTarget(guardTarget);
}
else
{
ml.FireMissile();
}
/*
if(BDACameraTools.lastProjectileFired != null)
{
BDACameraTools.lastProjectileFired.OnJustAboutToBeDestroyed -= new Callback(BDACameraTools.PostProjectileCamera);
}
BDACameraTools.lastProjectileFired = lastFiredSym;
*/
lastFiredSym = nextPart;
UpdateList ();
if(weaponIndex >= weaponArray.Length)
{
hasSingleFired = true;
triggerTimer = 0;
weaponIndex = Mathf.Clamp(weaponIndex, 0, weaponArray.Length - 1);
ScreenMessages.RemoveMessage(selectionMessage);
selectionText = "Selected Weapon: " + weaponArray[weaponIndex];
selectionMessage.message = selectionText;
ScreenMessages.PostScreenMessage(selectionMessage, true);
}
return;
}
foreach(RocketLauncher rl in lastFiredSym.FindModulesImplementing<RocketLauncher>())
{
rl.FireRocket();
rippleRPM = rl.rippleRPM;
if(nextPart!=null)
{
foreach(PartResource r in nextPart.Resources.list)
{
if(r.amount>0) lastFiredSym = nextPart;
else lastFiredSym = null;
}
}
UpdateList ();
if(weaponIndex >= weaponArray.Length)
{
hasSingleFired = true;
triggerTimer = 0;
weaponIndex = Mathf.Clamp(weaponIndex, 0, weaponArray.Length - 1);
ScreenMessages.RemoveMessage(selectionMessage);
selectionText = "Selected Weapon: " + weaponArray[weaponIndex];
selectionMessage.message = selectionText;
ScreenMessages.PostScreenMessage(selectionMessage, true);
}
return;
}
}
else
{
foreach(MissileLauncher ml in vessel.FindPartModulesImplementing<MissileLauncher>())
{
if(ml.part.partInfo.title == selectedWeapon)
{
lastFiredSym = FindSym(ml.part);
if(guardTarget!=null)
{
ml.FireMissileOnTarget(guardTarget);
}
else
{
ml.FireMissile();
}
/*
if(BDACameraTools.lastProjectileFired != null)
{
BDACameraTools.lastProjectileFired.OnJustAboutToBeDestroyed -= new Callback(BDACameraTools.PostProjectileCamera);
}
//.........这里部分代码省略.........
示例11: FindChargedParticleSource
private IChargedParticleSource FindChargedParticleSource(Part currentpart, int stackdepth, int parentdepth)
{
if (stackdepth == 0)
return currentpart.FindModulesImplementing<IChargedParticleSource>().FirstOrDefault();
foreach (var attachNodes in currentpart.attachNodes.Where(atn => atn.attachedPart != null))
{
IChargedParticleSource particleSource = FindChargedParticleSource(attachNodes.attachedPart, (stackdepth - 1), parentdepth);
if (particleSource != null)
return particleSource;
}
if (parentdepth > 0)
{
IChargedParticleSource particleSource = FindChargedParticleSource(currentpart.parent, (stackdepth - 1), (parentdepth - 1));
if (particleSource != null)
return particleSource;
}
return null;
}
示例12: onContainerSelect
private void onContainerSelect(Part p)
{
ModuleScienceContainer m = p.FindModulesImplementing<ModuleScienceContainer>().FirstOrDefault(c => c.capacity > c.GetScienceCount());
if (m == null)
{
ScreenMessages.PostScreenMessage(scienceTransferFailFullContainer, transferMessage);
return;
}
transferScience(m);
}
示例13: CenterOfLiftQuery
public static void CenterOfLiftQuery(Part p, CenterOfLiftQuery qry, CenterOfLiftQuery local_qry, float mach)
{
if (p == null)
return;
Vector3 pos = Vector3.zero;
Vector3 dir = Vector3.zero;
float abs_lift = 0.0f;
if (!p.ShieldedFromAirstream)
{
var providers = p.FindModulesImplementing<ILiftProvider>();
if ((providers != null) && providers.Count > 0)
p.hasLiftModule = true;
if (!p.hasLiftModule)
{
// stock aero shenanigans
if (!p.DragCubes.None)
{
p.dragVector = qry.refVector;
p.dragVectorSqrMag = p.dragVector.sqrMagnitude;
p.dragVectorMag = Mathf.Sqrt(p.dragVectorSqrMag);
p.dragVectorDir = p.dragVector / p.dragVectorMag;
p.dragVectorDirLocal = -p.partTransform.InverseTransformDirection(p.dragVectorDir);
p.dynamicPressurekPa = qry.refAirDensity * 0.0005 * p.dragVectorSqrMag;
p.bodyLiftScalar = (float)(p.dynamicPressurekPa * p.bodyLiftMultiplier * PhysicsGlobals.BodyLiftMultiplier *
lift_curves.liftMachCurve.Evaluate(mach));
pos = p.partTransform.TransformPoint(p.CoLOffset);
p.DragCubes.SetDrag(p.dragVectorDirLocal, mach);
dir = p.partTransform.rotation * (p.bodyLiftScalar * p.DragCubes.LiftForce);
dir = Vector3.ProjectOnPlane(dir, -p.dragVectorDir);
abs_lift = dir.magnitude;
qry.pos += pos * abs_lift;
qry.dir += dir;
qry.lift += abs_lift;
}
}
else
{
for (int i = 0; i < providers.Count; i++)
{
local_qry.lift = 0.0f;
local_qry.pos = Vector3.zero;
local_qry.dir = Vector3.zero;
providers[i].OnCenterOfLiftQuery(local_qry);
Vector3 corrected_lift = Vector3.ProjectOnPlane(local_qry.dir, qry.refVector);
local_qry.lift = Mathf.Abs(Vector3.Dot(corrected_lift, local_qry.dir)) * local_qry.lift;
pos += local_qry.pos * local_qry.lift;
dir += corrected_lift.normalized * local_qry.lift;
abs_lift += local_qry.lift;
}
qry.pos += pos;
qry.dir += dir;
qry.lift += abs_lift;
}
}
}