本文整理汇总了C#中Vessel.FindPartModulesImplementing方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.FindPartModulesImplementing方法的具体用法?C# Vessel.FindPartModulesImplementing怎么用?C# Vessel.FindPartModulesImplementing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.FindPartModulesImplementing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTorque
//from kOS
public static Vector3d GetTorque(Vessel vessel, float thrust)
{
Vector3 centerOfMass = vessel.CoM;
Vector3 rollaxis = vessel.ReferenceTransform.up;
rollaxis.Normalize ();
Vector3 pitchaxis = vessel.GetFwdVector ();
pitchaxis.Normalize ();
float pitch = 0.0f;
float yaw = 0.0f;
float roll = 0.0f;
//reaction wheel torque
foreach(ModuleReactionWheel wheel in vessel.FindPartModulesImplementing<ModuleReactionWheel>())
{
if (wheel == null) continue;
pitch += wheel.PitchTorque;
yaw += wheel.YawTorque;
roll += wheel.RollTorque;
}
//rcs torque
if (vessel.ActionGroups [KSPActionGroup.RCS])
{
foreach(ModuleRCS rcs in vessel.FindPartModulesImplementing<ModuleRCS>())
{
if (rcs == null || !rcs.rcsEnabled) continue;
Vector3 relCoM = rcs.part.Rigidbody.worldCenterOfMass - centerOfMass;
bool enoughfuel = rcs.propellants.All(p => (int) (p.totalResourceAvailable) != 0);
if (!enoughfuel) continue;
foreach (Transform thrustdir in rcs.thrusterTransforms)
{
float rcsthrust = rcs.thrusterPower;
//just counting positive contributions in one direction. This is incorrect for asymmetric thruster placements.
roll += Mathf.Max(rcsthrust * Vector3.Dot(Vector3.Cross(relCoM, thrustdir.up), rollaxis), 0.0f);
pitch += Mathf.Max(rcsthrust * Vector3.Dot(Vector3.Cross(Vector3.Cross(relCoM, thrustdir.up), rollaxis), pitchaxis), 0.0f);
yaw += Mathf.Max(rcsthrust * Vector3.Dot(Vector3.Cross(Vector3.Cross(relCoM, thrustdir.up), rollaxis), Vector3.Cross(rollaxis,pitchaxis)),0.0f);
}
}
}
return new Vector3d(pitch, roll, yaw);
}
示例2: getEnumeratedSolarPowerForVessel
public static double getEnumeratedSolarPowerForVessel(Vessel vess)
{
List<MicrowavePowerTransmitter> transmitters = vess.FindPartModulesImplementing<MicrowavePowerTransmitter>();
double total_solar_power = 0;
foreach (MicrowavePowerTransmitter transmitter in transmitters) {
total_solar_power += transmitter.getSolarPower();
}
return total_solar_power;
}
示例3: vesselIsRelay
public static bool vesselIsRelay(Vessel vess)
{
List<MicrowavePowerTransmitter> transmitters = vess.FindPartModulesImplementing<MicrowavePowerTransmitter>();
foreach (MicrowavePowerTransmitter transmitter in transmitters) {
if (transmitter.getIsRelay()) {
return true;
}
}
return false;
}
示例4: CalculateVesselHabExtraTime
public static double CalculateVesselHabExtraTime(Vessel v)
{
var habTime = 0d;
foreach (var hab in v.FindPartModulesImplementing<ModuleHabitation>())
{
//Next. Certain modules, in addition to crew capacity, have living space.
habTime += hab.KerbalMonths;
}
return habTime;
}
示例5: CalculateVesselHabMultiplier
public static double CalculateVesselHabMultiplier(Vessel v, int numCrew)
{
var habMulti = 0d;
foreach (var hab in v.FindPartModulesImplementing<ModuleHabitation>())
{
//Lastly. Some modules act more as 'multipliers', dramatically extending a hab's workable lifespan.
habMulti += (hab.HabMultiplier * Math.Min(1, hab.CrewCapacity / numCrew));
}
return habMulti;
}
示例6: getActiveExchangersForVessel
public static int getActiveExchangersForVessel(Vessel vess)
{
int activeExchangers = 0;
List<FNThermalHeatExchanger> mthes = vess.FindPartModulesImplementing<FNThermalHeatExchanger>();
foreach (FNThermalHeatExchanger mthe in mthes) {
if (mthe.isActive()) {
activeExchangers++;
}
}
return activeExchangers;
}
示例7: armNetwork
void armNetwork(Vessel v)
{
var massAccelerators = v.FindPartModulesImplementing<ModuleMassAccelerator>();
print("Network found modules " + massAccelerators.Count.ToString());
foreach (ModuleMassAccelerator a in massAccelerators)
{
print("module is master " + a.part.partName + a.master.ToString());
if (a.master == false)
a.ArmAccelerator();
}
}
示例8: getTemperatureofColdestReactor
public static double getTemperatureofColdestReactor(Vessel vess) {
List<FNReactor> reactors = vess.FindPartModulesImplementing<FNReactor> ();
double temp = double.MaxValue;
foreach (FNReactor reactor in reactors) {
if (reactor != null) {
if (reactor.getCoreTemp() < temp && reactor.isActive()) {
temp = reactor.getCoreTemp();
}
}
}
return temp;
}
示例9: hasActiveReactors
public static bool hasActiveReactors(Vessel vess) {
List<FNReactor> reactors = vess.FindPartModulesImplementing<FNReactor> ();
foreach (FNReactor reactor in reactors) {
if (reactor != null) {
if (reactor.IsEnabled) {
return true;
}
}
}
return false;
}
示例10: SetupRatios
// Determines how much this wheel should be steering according to its position in the craft. Returns a value -1 to 1.
public static float SetupRatios(int refIndex, Part thisPart, Vessel thisVessel, float groupNumber)
{
float myPosition = thisPart.orgPos[refIndex];
float maxPos = thisPart.orgPos[refIndex];
float minPos = thisPart.orgPos[refIndex];
float ratio = 1;
foreach (KFModuleWheel st in thisVessel.FindPartModulesImplementing<KFModuleWheel>()) //scan vessel to find fore or rearmost wheel.
{
if (Equals(st.groupNumber, groupNumber) && !Equals(groupNumber, 0))
{
float otherPosition = myPosition;
otherPosition = st.part.orgPos[refIndex];
if ((otherPosition + 1000) >= (maxPos + 1000)) // Dodgy hack. Make sure all values are positive or we struggle to evaluate < or >
maxPos = otherPosition; // Store transform y value
if ((otherPosition + 1000) <= (minPos + 1000))
minPos = otherPosition; // Store transform y value
}
}
float minToMax = maxPos - minPos;
float midPoint = minToMax / 2;
float offset = (maxPos + minPos) / 2;
float myAdjustedPosition = myPosition - offset;
ratio = myAdjustedPosition / midPoint;
if (Equals(ratio, 0) || float.IsNaN(ratio)) // Check is we managed to evaluate to zero or infinity somehow. Happens with less than three wheels, or all wheels mounted at the same position.
ratio = 1;
//KFLog.Log("ratio"); //Debugging
//KFLog.Log(string.Format("{0}", ratio));
return ratio;
}
示例11: on_create
// Triggered by creating a new vessel. Apparantelly we create a new mission. However, decoupling also create the new mission. Unfortunatelly, we cannot find the name here.
// Events
private void on_create(Vessel ves)
{
// This event should be called only if we have a new mission
KDebug.Log("on_create", KDebug.Type.CREATE);
Mission M = new Mission(ves); // Possible new mission (ves is check for null)
if (M.missionApproved) // Mission was created
{
KDebug.Log("on_create approved", KDebug.Type.CREATE);
int CM = ves.FindPartModulesImplementing<ModuleCommand>().Count();
KDebug.Log("Command Modules: " + CM.ToString(), KDebug.Type.CREATE); // should wotk!
//Entry E = new Entry();
if(ves.situation == Vessel.Situations.PRELAUNCH)
{
KDebug.Log("create " + M.get_name(), KDebug.Type.CREATE);
this.add_mission(M);
add_event(Entry.Situations.CREATE, ves, M.get_name());
//E.add(Entry.Situations.CREATE, M.get_name(), (double)0);
}
else if (CM > 0) // Additional check to exclude debrees
{
KDebug.Log("detached " + M.get_name(), KDebug.Type.CREATE);
// TODO
// Find the command module and name the mission by command module (if we cannot find how to name it wihtout commant module)
// Let's find the command module
Part P = ves.FindPartModulesImplementing<ModuleCommand>().Last().part;
this.add_mission(M);
M.rename(P.partInfo.title);
//add_event(Entry.Situations.DETACHED, ves, M.get_name());
add_event(Entry.Situations.DETACHED, ves, P.partInfo.title);
//E.add(Entry.Situations.DETACHED, M.get_name(), (double)0);
// To collect the name of the mission we probably need to listed Rename event
}
else
{
return;
}
// M.add_entry( E ); // I'm not sue I need this
}
}
示例12: vesselCanJoinNetwork
public static bool vesselCanJoinNetwork(Vessel v)
{
if (v.loaded)
{
var modules = v.FindPartModulesImplementing<xPipeLine2>();
foreach (var m in modules)
if (m.Connected)
return true;
return false;
}
foreach (var part in v.protoVessel.protoPartSnapshots)
{
foreach (var module in part.modules)
{
if (module.moduleName == "xPipeLine2")
{
print("vessel pipeline found");
if (module.moduleValues.GetValue("Connected").ToLower() == "true")
return true;
}
}
}
return false;
}
示例13: VesselChange
void VesselChange(Vessel v)
{
if(!v.isActiveVessel)
{
return;
}
/*
if(!FlightGlobals.ready)
{
return;
}
if(!FlightCamera.fetch)
{
return;
}
if(!FlightCamera.fetch.mainCamera)
{
return;
}
*/
bool moduleFound = false;
foreach(var mtc in v.FindPartModulesImplementing<ModuleTargetingCamera>())
{
Debug.Log ("Vessel switched to vessel with targeting camera. Refreshing camera state.");
if(mtc.cameraEnabled)
{
mtc.DelayedEnable();
}
else
{
mtc.DisableCamera();
}
moduleFound = true;
}
if(!moduleFound)
{
DisableCamera();
ModuleTargetingCamera.windowIsOpen = false;
}
}
示例14: onVesselLoad
private static void onVesselLoad(Vessel v)
{
IEnumerable<KeyValuePair<Guid, Notes_CheckListItem>> activeNotes;
IEnumerable<KeyValuePair<Guid, Notes_CheckListItem>> loadedNotes;
Vessel active = FlightGlobals.ActiveVessel;
if (active.FindPartModulesImplementing<ModuleAsteroid>().Count > 0)
{
activeNotes = rendezvousAsteroidNotes.Where(n => n.Value.Root.RootVessel.id == active.id);
}
else
{
activeNotes = rendezvousVesselNotes.Where(n => n.Value.Root.RootVessel.id == active.id);
}
if (v.FindPartModulesImplementing<ModuleAsteroid>().Count > 0)
{
loadedNotes = rendezvousAsteroidNotes.Where(n => n.Value.Root.RootVessel.id == v.id);
}
else
{
loadedNotes = rendezvousVesselNotes.Where(n => n.Value.Root.RootVessel.id == v.id);
}
if (activeNotes.Count() > 0)
{
for (int i = 0; i < activeNotes.Count(); i++)
{
Notes_CheckListItem n = activeNotes.ElementAt(i).Value;
if (n == null)
continue;
if (n.TargetVessel == null)
continue;
if (n.TargetVessel.id == v.id)
n.setComplete();
}
}
if (loadedNotes.Count() > 0)
{
for (int i = 0; i < loadedNotes.Count(); i++)
{
Notes_CheckListItem n = loadedNotes.ElementAt(i).Value;
if (n == null)
continue;
if (n.TargetVessel == null)
continue;
if (n.TargetVessel.id == active.id)
n.setComplete();
}
}
}
示例15: getEnginesRunningOfTypeForVessel
// enumeration of the fuel useage rates of all jets on a vessel
public static int getEnginesRunningOfTypeForVessel (Vessel vess, string resourcename) {
List<FNNozzleController> nozzles = vess.FindPartModulesImplementing<FNNozzleController> ();
int engines = 0;
foreach (FNNozzleController nozzle in nozzles) {
ConfigNode[] prop_node = nozzle.getPropellants ();
if (prop_node != null) {
ConfigNode[] assprops = prop_node [nozzle.fuel_mode].GetNodes ("PROPELLANT");
if (prop_node [nozzle.fuel_mode] != null) {
if (assprops [0].GetValue ("name").Equals (resourcename)) {
if (nozzle.getNozzleFlowRate () > 0) {
engines++;
}
}
}
}
}
return engines;
}