本文整理汇总了C#中Vessel.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.GetComponent方法的具体用法?C# Vessel.GetComponent怎么用?C# Vessel.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.GetComponent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetModifiedSignature
public static float GetModifiedSignature(Vessel vessel, Vector3 origin)
{
//float sig = GetBaseRadarSignature(vessel);
float sig = GetRadarSnapshot(vessel, origin, 0.1f);
Vector3 upVector = VectorUtils.GetUpDirection(origin);
//sig *= Mathf.Pow(15000,2)/(vessel.transform.position-origin).sqrMagnitude;
if(vessel.Landed)
{
sig *= 0.25f;
}
if(vessel.Splashed)
{
sig *= 0.4f;
}
//notching and ground clutter
Vector3 targetDirection = (vessel.transform.position-origin).normalized;
Vector3 targetClosureV = Vector3.ProjectOnPlane(Vector3.Project(vessel.srf_velocity,targetDirection), upVector);
float notchFactor = 1;
float angleFromUp = Vector3.Angle(targetDirection,upVector);
float lookDownAngle = angleFromUp-90;
if(lookDownAngle > 5)
{
notchFactor = Mathf.Clamp(targetClosureV.sqrMagnitude / 3600f, 0.1f, 1f);
}
else
{
notchFactor = Mathf.Clamp(targetClosureV.sqrMagnitude / 3600f, 0.8f, 3f);
}
float groundClutterFactor = Mathf.Clamp((90/angleFromUp), 0.25f, 1.85f);
sig *= groundClutterFactor;
sig *= notchFactor;
var vci = vessel.GetComponent<VesselChaffInfo>();
if(vci) sig *= vci.GetChaffMultiplier();
/*
if(Mathf.Round(Time.time)%2 == 0)
{
Debug.Log ("================================");
Debug.Log ("targetAxV: "+targetClosureV.magnitude);
Debug.Log ("lookdownAngle: "+lookDownAngle);
Debug.Log ("notchFactor: "+notchFactor);
Debug.Log ("groundClutterFactor: "+groundClutterFactor);
}
*/
return sig;
}
示例2: GetInstance
/// <summary>
/// Return the kOSVesselModule instance associated with the given Vessel object
/// </summary>
/// <param name="vessel">the vessel for which the module should be returned</param>
/// <returns></returns>
public static kOSVesselModule GetInstance(Vessel vessel)
{
kOSVesselModule ret;
if (!allInstances.TryGetValue(vessel.id, out ret))
{
ret = vessel.GetComponent<kOSVesselModule>();
if (ret == null)
throw new kOS.Safe.Exceptions.KOSException("Cannot find kOSVesselModule on vessel " + vessel.name);
allInstances.Add(vessel.id, ret);
}
return ret;
}
示例3: GetEffectiveInertia
public static Vector3d GetEffectiveInertia(Vessel vessel, Vector3d torque)
{
Vector3 centerOfMass = vessel.CoM;
Vector3 momentOfInertia = vessel.localCoM; // was .findLocalMOI(centerOfMass);
Vector3 angularVelocity = Quaternion.Inverse(vessel.ReferenceTransform.rotation) * vessel.GetComponent<Rigidbody>().angularVelocity;
Vector3d angularMomentum = new Vector3d(angularVelocity.x * momentOfInertia.x, angularVelocity.y * momentOfInertia.y, angularVelocity.z * momentOfInertia.z);
Vector3d retVar = Vector3d.Scale
(
Sign(angularMomentum) * 2.0f,
Vector3d.Scale(Pow(angularMomentum, 2), Inverse(Vector3d.Scale(torque, momentOfInertia)))
);
retVar.y *= 10;
return retVar;
}
示例4: GetRadarSnapshot
public static float GetRadarSnapshot(Vessel v, Vector3 origin, float camFoV)
{
TargetInfo ti = v.GetComponent<TargetInfo>();
if(ti && ti.isMissile)
{
return 600;
}
float distance = (v.transform.position - origin).magnitude;
radarCam.nearClipPlane = Mathf.Clamp(distance - 200, 20, 40000);
radarCam.farClipPlane = Mathf.Clamp(distance + 200, 20, 40000);
radarCam.fieldOfView = camFoV;
radarCam.transform.position = origin;
radarCam.transform.LookAt(v.CoM+(v.rb_velocity*Time.fixedDeltaTime));
float pixels = 0;
RenderTexture.active = radarRT;
radarCam.Render();
radarTex2D.ReadPixels(new Rect(0,0,radarResolution,radarResolution), 0,0);
for(int x = 0; x < radarResolution; x++)
{
for(int y = 0; y < radarResolution; y++)
{
if(radarTex2D.GetPixel(x,y).r<1)
{
pixels++;
}
}
}
return pixels*4;
}
示例5: InstanceCalcVesselAeroForces
private void InstanceCalcVesselAeroForces(Vessel vessel, out Vector3 aeroForce, out Vector3 aeroTorque, Vector3 velocityWorldVector, double altitude)
{
aeroForce = aeroTorque = Vector3.zero;
if (vessel == null)
{
Debug.LogError("FAR API Error: attempted to simulate aerodynamics of null vessel");
return;
}
FARVesselAero vesselAero = vessel.GetComponent<FARVesselAero>();
if (vesselAero == null)
{
Debug.LogError("FAR API Error: vessel does not have FARVesselAero aerocomponent for simulation");
return;
}
vesselAero.SimulateAeroProperties(out aeroForce, out aeroTorque, velocityWorldVector, altitude);
}
示例6: GetActorForVessel
private KerbalActor GetActorForVessel(Vessel vessel)
{
if (vessel == null)
{
return null;
}
var eva = vessel.GetComponent<KerbalEVA>();
if (eva != null)
{
List<ProtoCrewMember> crew = vessel.rootPart.protoModuleCrew;
if (crew.Count > 0)
{
return new KerbalActor(vessel.rootPart, crew[0]);
}
}
return null;
}
示例7: Load
public void Load(Vessel vessel)
{
if (!vessel.isEVA)
{
EvaDebug.DebugWarning("Tried loading a non eva.");
return;
}
KerbalEVA currentEVA = vessel.GetComponent<KerbalEVA>();
if (!Contains(vessel.id))
{
EvaContainer container = new EvaContainer(vessel.id);
//load the vessel here.
container.Load(currentEVA);
EvaSettings.LoadEva(container);
collection.Add(container);
}
else
{
//Reload
EvaContainer container = GetEva(vessel.id);
container.Load(currentEVA);
EvaSettings.LoadEva(container);
}
}
示例8: OnVesselChange
protected void OnVesselChange(Vessel vessel) {
Print("Vessel was changed");
if(FlightGlobals.ActiveVessel == vessel) {
vesselSettings = vessel.GetComponent<VesselSettings>();
isVisable = vesselSettings.containers.Count() > 0;
}
}
示例9: VesselReynoldsNumber
public static double VesselReynoldsNumber (Vessel vessel)
{
var aero = vessel.GetComponent ("FARVesselAero");
return (double)aero.GetType ().GetProperty ("ReynoldsNumber").GetValue (aero, null);
}