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


C# Vessel.GoOnRails方法代码示例

本文整理汇总了C#中Vessel.GoOnRails方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.GoOnRails方法的具体用法?C# Vessel.GoOnRails怎么用?C# Vessel.GoOnRails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vessel的用法示例。


在下文中一共展示了Vessel.GoOnRails方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: syncExtantVesselOrbit

        private void syncExtantVesselOrbit(KMPVessel kvessel, double fromTick, Vessel extant_vessel, double LAN)
        {
            KMPClientMain.DebugLog("updating Orbit: " + extant_vessel.id);

            bool victimAvailable = true;
            Vessel victim = FlightGlobals.ActiveVessel;

            foreach (ManeuverNode mNode in victim.patchedConicSolver.maneuverNodes)
            {
                if (mNode.attachedGizmo != null)
                {
                    ManeuverGizmo mGizmo = mNode.attachedGizmo;
                    if (mGizmo.handleAntiNormal.Drag) { victimAvailable = false; break; }
                    if (mGizmo.handleNormal.Drag) { victimAvailable = false; break; }
                    if (mGizmo.handlePrograde.Drag) { victimAvailable = false; break; }
                    if (mGizmo.handleRadialIn.Drag) { victimAvailable = false; break; }
                    if (mGizmo.handleRadialOut.Drag) { victimAvailable = false; break; }
                    if (mGizmo.handleRetrograde.Drag) { victimAvailable = false; break; }
                }
            }

            if (victimAvailable)
            {
                double tick = Planetarium.GetUniversalTime();
                KMPClientMain.DebugLog("current vel mag: " + extant_vessel.orbit.getOrbitalVelocityAtUT(tick).magnitude);

                extant_vessel.GoOnRails();

                //Update orbit
                Planetarium.SetUniversalTime(fromTick);
                Vector3 orbit_pos = kvessel.translationFromBody;
                Vector3 orbit_vel = kvessel.worldVelocity;

                //Swap the y and z values of the orbital position/velocities
                float temp = orbit_pos.y;
                orbit_pos.y = orbit_pos.z;
                orbit_pos.z = temp;

                temp = orbit_vel.y;
                orbit_vel.y = orbit_vel.z;
                orbit_vel.z = temp;

                OrbitDriver orbitDriver = extant_vessel.orbitDriver;
                orbitDriver.orbit.UpdateFromStateVectors(orbit_pos, orbit_vel, kvessel.mainBody, fromTick);
                Orbit newOrbit = orbitDriver.orbit;
                newOrbit.LAN = LAN;

                OrbitDriver oldDriver = victim.orbitDriver;
                victim.patchedConicSolver.obtDriver = orbitDriver;
                victim.orbitDriver = orbitDriver;
                victim.orbitDriver.UpdateOrbit();
                victim.patchedConicSolver.Update();

                newOrbit = victim.patchedConicSolver.orbit;

                if (newOrbit.referenceBody == null) newOrbit.referenceBody = FlightGlobals.Bodies.Find(b => b.name == "Sun");
            //				KMPClientMain.DebugLog("aP:" + newOrbit.activePatch);
            //				KMPClientMain.DebugLog("eUT:" + newOrbit.EndUT);
            //				KMPClientMain.DebugLog("sUT:" + newOrbit.StartUT);
            //				KMPClientMain.DebugLog("gOA:" + newOrbit.getObtAtUT(tick));
            //				KMPClientMain.DebugLog("nPnull:" + (newOrbit.nextPatch == null));
            //				KMPClientMain.DebugLog("pPnull:" + (newOrbit.previousPatch == null));
            //				KMPClientMain.DebugLog("sI:" + newOrbit.sampleInterval);
            //				KMPClientMain.DebugLog("UTsoi:" + newOrbit.UTsoi);
            //				KMPClientMain.DebugLog("body:" + newOrbit.referenceBody.name);
                if (newOrbit.EndUT > 0)
                {
                    double lastEndUT =  newOrbit.EndUT;
                    while (newOrbit.EndUT > 0 && newOrbit.EndUT < tick && newOrbit.EndUT > lastEndUT && newOrbit.nextPatch != null)
                    {
                        KMPClientMain.DebugLog("orbit EndUT < target: " + newOrbit.EndUT + " vs " + tick);
                        lastEndUT =  newOrbit.EndUT;
                        newOrbit = newOrbit.nextPatch;
                        if (newOrbit.referenceBody == null) newOrbit.referenceBody = FlightGlobals.Bodies.Find(b => b.name == "Sun");
                        KMPClientMain.DebugLog("updated to next patch");
                    }
                }
                newOrbit.UpdateFromUT(tick);

                //Swap orbits
                extant_vessel.orbitDriver = orbitDriver;
                extant_vessel.orbitDriver.orbit = newOrbit;
                victim.patchedConicSolver.obtDriver = oldDriver;
                victim.patchedConicRenderer.solver = victim.patchedConicSolver;
                victim.orbitDriver = oldDriver;
                victim.orbitDriver.UpdateOrbit();

                extant_vessel.orbitDriver.pos = extant_vessel.orbit.pos.xzy;
                extant_vessel.orbitDriver.vel = extant_vessel.orbit.vel;

                Planetarium.SetUniversalTime(tick);
                KMPClientMain.DebugLog("new vel mag: " + extant_vessel.orbit.getOrbitalVelocityAtUT(tick).magnitude);
                KMPClientMain.DebugLog("Orbit updated to target: " + tick);
            } else { KMPClientMain.DebugLog("no victim available!"); }
        }
开发者ID:Jumba,项目名称:KerbalMultiPlayer,代码行数:95,代码来源:KMPManager.cs

示例2: teleportToDockingPort

        // will only work for short distances (ie. less than 50km)
        // will rip the ship into little pieces if the distance is much bigger
        /*static public void teleportToVessel (Vessel vessel, Vessel targetVessel, float d)
        {
            Vector3 j = Util.nextVector3 ().normalized * d;
            Vector3 targetPos = targetVessel.orbit.pos + j;
            Vector3 relPos = targetPos - vessel.orbit.pos;
            if (relPos.magnitude > 50000) {
                UnityEngine.Debug.Log ("TeleporterLite: warning: distance > 50km");
            }

            // teleport & match velocity
            if (vessel.packed == false) {
                UnityEngine.Debug.Log ("teleportToVessel unpacked " + relPos.magnitude.ToString ("F1"));

                vessel.Translate(Util.reorder (relPos, 132));
                vessel.GoOnRails ();
                vessel.orbit.vel = targetVessel.orbit.vel;
                vessel.GoOffRails ();
            } else {
                UnityEngine.Debug.Log ("teleportToVessel packed " + relPos.magnitude.ToString ("F1"));

                vessel.SetPosition(targetVessel.transform.position + j);
                vessel.orbit.vel = targetVessel.orbit.vel;
            }
        }*/
        public static void teleportToDockingPort(Vessel vessel, Part vesselPort, Part targetPort, float distance)
        {
            // check orientation
            Vector3 rp = Vector3.zero;
            Vector3 euler = Vector3.zero;
            float d = 0;
            Util.getDockRelPosAndAtt(vesselPort, targetPort, out rp, out d, out euler);
            float roll = euler.y;
            euler.y = 0;
            if (Util.maxElement (euler) > 5) {
                UnityEngine.Debug.Log ("TeleporterLite: incorrect orientation!");
                return;
            }

            Vector3 dockPos = vesselPort.transform.position + vesselPort.transform.TransformDirection (new Vector3 (0, Util.getDockPosY(targetPort) + 1 + distance, 0));
            Vector3 relDockPos = targetPort.transform.position - dockPos;
            if (relDockPos.magnitude > 500) {
                UnityEngine.Debug.Log ("TeleporterLite: distance > 500m");
                return;
            }

            // teleport
            vessel.Translate(relDockPos);

            // match velocity
            vessel.GoOnRails();
            vessel.orbit.vel = targetPort.vessel.orbit.vel;
            vessel.GoOffRails();
        }
开发者ID:rjohnson72,项目名称:ORDA,代码行数:55,代码来源:Teleporter.cs

示例3: CalculateOrbit

        public static void CalculateOrbit(Vessel vessel, Orbit oldOrbit, OrbitDriver driver)
        {
            VesselDied = false;

            if (!VesselData.Message.ContainsKey(vessel.id))
            {
                VesselData.Message.Add(vessel.id, false);
                VesselData.DisplayedMessage = false;
            }
            else
            {
                VesselData.Message.TryGetValue(vessel.id, out VesselData.DisplayedMessage);
            }

            vessel.GoOnRails();

            var oldBody = vessel.orbitDriver.orbit.referenceBody;

               // The ISS decays at about 2km/month = 2000/30*24*60*60 == 7.7x10^-4 m/s

            double BodyGravityConstant = vessel.orbitDriver.orbit.referenceBody.GeeASL;
            double AtmosphereMultiplier;
            double MaxDecayInfluence = vessel.orbitDriver.orbit.referenceBody.Radius * 10;
            if (vessel.orbitDriver.orbit.referenceBody.atmosphere)
            {
                AtmosphereMultiplier = vessel.orbitDriver.orbit.referenceBody.atmospherePressureSeaLevel / 101.325;
            }
            else
            {
                 AtmosphereMultiplier = 0.5;
            }

            if (vessel.orbitDriver.orbit.semiMajorAxis + 50 < MaxDecayInfluence )
            {
                double Lambda = 0.000000000133913 * UI.DifficultySetting;                           //0.000000000133913;
                double Sigma = MaxDecayInfluence - vessel.orbitDriver.orbit.altitude;
                DecayValue = (double)TimeWarp.CurrentRate * Sigma * BodyGravityConstant * AtmosphereMultiplier * Lambda;

                if (vessel.orbitDriver.orbit.referenceBody.atmosphere)
                {
                    if (vessel.orbitDriver.orbit.PeA < vessel.orbitDriver.orbit.referenceBody.atmosphereDepth)
                    {
                        DecayValue = DecayValue * (Math.Pow(Math.E, vessel.orbitDriver.orbit.referenceBody.atmosphereDepth - vessel.orbitDriver.orbit.PeA)); // Have it increase alot more as we enter the hard atmosphere
                    }

                    //EstimatedTimeUntilDeorbit = (float)(vessel.orbitDriver.orbit.altitude - (float)vessel.orbitDriver.orbit.referenceBody.atmosphereDepth) / (float)DecayValue;
                     MaxDecayValue = ((vessel.orbitDriver.orbit.referenceBody.Radius + vessel.orbitDriver.orbit.referenceBody.atmosphereDepth) * BodyGravityConstant * AtmosphereMultiplier * Lambda);
                     EstimatedTimeUntilDeorbit = ((float)(vessel.orbitDriver.orbit.semiMajorAxis - (float)vessel.orbitDriver.orbit.referenceBody.atmosphereDepth)) / (float)MaxDecayValue;
                   // EstimatedTimeUntilDeorbit = (float)(vessel.orbitDriver.orbit.PeA - (((vessel.orbitDriver.referenceBody.atmosphereDepth)/((MaxDecayValue+DecayValue)/2) - vessel.orbitDriver.orbit.PeA)) *((MaxDecayValue + DecayValue) / 2));
                }
                else
                {
                   //EstimatedTimeUntilDeorbit = (float)(vessel.orbitDriver.orbit.altitude - 100) / (float)DecayValue;
                    MaxDecayValue = ((vessel.orbitDriver.orbit.referenceBody.Radius + 100) * BodyGravityConstant * AtmosphereMultiplier * Lambda);
                    EstimatedTimeUntilDeorbit = ((float)(vessel.orbitDriver.orbit.semiMajorAxis - (float)vessel.orbitDriver.orbit.referenceBody.atmosphereDepth)) / (float)MaxDecayValue;
                }
                if (VesselData.DecayTimes.ContainsKey(vessel.id))
                {
                    VesselData.DecayTimes.Remove(vessel.id);
                    VesselData.DecayTimes.Add(vessel.id, EstimatedTimeUntilDeorbit);
                }
                else
                {
                    VesselData.DecayTimes.Add(vessel.id, EstimatedTimeUntilDeorbit);
                }

               // print(vessel.name + " Semi major axis reduced by: " + (DecayValue));
            }
            else
            {
                DecayValue = 0;

                if (VesselData.DecayTimes.ContainsKey(vessel.id))
                {
                    VesselData.DecayTimes.Remove(vessel.id);
                    VesselData.DecayTimes.Add(vessel.id, 0.5f);
                }
                else
                {
                    VesselData.DecayTimes.Add(vessel.id, 0.5f);
                }
            }

            if (VesselDied == false)         // Just Incase the vessel is destroyed part way though the check.
            {
                if (vessel.orbitDriver.orbit.referenceBody.GetInstanceID() != 0 || vessel.orbitDriver.orbit.semiMajorAxis > vessel.orbitDriver.orbit.referenceBody.Radius + 5)
                {
                    SetNewOrbit(driver, oldOrbit);
                }
            }

            if (vessel.orbitDriver.orbit.referenceBody.atmosphere) // Big problem ( Jool, Eve, Duna, Kerbin, Laythe)
            {
                if (vessel.orbitDriver.orbit.semiMajorAxis < vessel.orbitDriver.orbit.referenceBody.Radius + vessel.orbitDriver.referenceBody.atmosphereDepth + 500)
                {
                    FlightDriver.SetPause(true);
                    TimeWarp.SetRate(1, true);
                    FlightDriver.SetPause(false);
                    print("Warning: " + vessel.name + " is approaching " + oldOrbit.referenceBody.name + "'s hard atmosphere");
                    ScreenMessages.PostScreenMessage("Warning: " + vessel.name + " is approaching " + oldOrbit.referenceBody.name + "'s hard atmosphere");
//.........这里部分代码省略.........
开发者ID:Whitecat106,项目名称:KSP-Orbital-Decay-,代码行数:101,代码来源:DecayController.cs

示例4: KillVessel

 private void KillVessel(Vessel killVessel)
 {
     if (killVessel != null)
     {
         bool oldDestroyIsValid = destroyIsValid;
         destroyIsValid = false;
         if (oldDestroyIsValid)
         {
             DarkLog.Debug("Disabling vessel destroy for vessel killing");
         }
         DarkLog.Debug("Killing vessel: " + killVessel.id.ToString());
         try
         {
             if (!killVessel.packed)
             {
                 killVessel.GoOnRails();
             }
             if (killVessel.loaded)
             {
                 killVessel.Unload();
             }
             killVessel.Die();
         }
         catch (Exception e)
         {
             DarkLog.Debug("Error destroying vessel: " + e);
         }
         if (oldDestroyIsValid)
         {
             reenableDestroyInFixedUpdates = 5;
         }
     }
 }
开发者ID:Norgg,项目名称:DarkMultiPlayer,代码行数:33,代码来源:VesselWorker.cs


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