当前位置: 首页>>代码示例>>C#>>正文


C# Vessel.GetComponent方法代码示例

本文整理汇总了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;
        }
开发者ID:jediminer543,项目名称:BDArmory,代码行数:54,代码来源:RadarUtils.cs

示例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;
 }
开发者ID:KSP-KOS,项目名称:KOS,代码行数:17,代码来源:kOSVesselModule.cs

示例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;
        }
开发者ID:Kerbas-ad-astra,项目名称:BurnTogether,代码行数:17,代码来源:Utils.cs

示例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;
		}
开发者ID:tetryds,项目名称:BDArmory,代码行数:40,代码来源:RadarUtils.cs

示例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);
        }
开发者ID:Nitebomber,项目名称:Ferram-Aerospace-Research-x64-hack,代码行数:19,代码来源:FARAPI.cs

示例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;
        }
开发者ID:JoshBlake,项目名称:KerbExpressions,代码行数:19,代码来源:ExpressionController.cs

示例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);
            }
        }
开发者ID:MarijnStevens,项目名称:EvaFollower,代码行数:29,代码来源:EvaController.cs

示例8: OnVesselChange

		protected void OnVesselChange(Vessel vessel) {
			Print("Vessel was changed");
			if(FlightGlobals.ActiveVessel == vessel) {
				vesselSettings = vessel.GetComponent<VesselSettings>();
				isVisable = vesselSettings.containers.Count() > 0;
			}
		}
开发者ID:SirDargon,项目名称:ScienceHardDrives,代码行数:7,代码来源:HardDriveManager.cs

示例9: VesselReynoldsNumber

 public static double VesselReynoldsNumber (Vessel vessel)
 {
     var aero = vessel.GetComponent ("FARVesselAero");
     return (double)aero.GetType ().GetProperty ("ReynoldsNumber").GetValue (aero, null);
 }
开发者ID:paperclip,项目名称:krpc,代码行数:5,代码来源:FAR.cs


注:本文中的Vessel.GetComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。