Exemplo n.º 1
0
        public static bool SetSiteAndResetCamera(ConfigNode KSC, bool force = false)
        {
            bool b = SetSite(KSC);

            if (b && (force || (KSC.HasValue("name") && KSC.GetValue("name") != LastFloatingOriginKSC)))
            {
                FloatingOrigin.SetOffset(PSystemSetup.Instance.SCTransform.position);
                LastFloatingOriginKSC = KSC.GetValue("name");
                Debug.Log("KSCSwitcher set floating point origin offset");
            }

            return(b);
        }
Exemplo n.º 2
0
            private void MakeOrbit(OrbitDriver driver, CelestialBody reference)
            {
                Debug.Log("Jumping to " + partnerBody);

                CelestialBody oldBody = driver.referenceBody;

                FlightGlobals.overrideOrbit = true;
                FlightGlobals.fetch.Invoke("disableOverride", 2f);
                driver.vessel.Landed   = false;
                driver.vessel.Splashed = false;
                driver.vessel.SetLandedAt("");
                driver.vessel.KillPermanentGroundContact();
                driver.vessel.ResetGroundContact();
                FlightGlobals.currentMainBody = reference;
                OrbitPhysicsManager.SetDominantBody(reference);

                // Pack vessels
                foreach (Vessel vessel in FlightGlobals.Vessels)
                {
                    if (!vessel.packed)
                    {
                        vessel.GoOnRails();
                    }
                }

                // Disable inverse rotation
                foreach (CelestialBody body in PSystemManager.Instance.localBodies)
                {
                    body.inverseRotation = false;
                }

                driver.orbit.referenceBody = reference;
                driver.updateFromParameters();

                // Finalize Vessel Movement
                CollisionEnhancer.bypass = true;
                FloatingOrigin.SetOffset(driver.vessel.transform.position);
                OrbitPhysicsManager.CheckReferenceFrame();
                OrbitPhysicsManager.HoldVesselUnpack(10);
                if (reference != oldBody)
                {
                    GameEvents.onVesselSOIChanged.Fire(
                        new GameEvents.HostedFromToAction <Vessel, CelestialBody>(driver.vessel, oldBody,
                                                                                  reference));
                }

                driver.vessel.IgnoreGForces(20);
            }
Exemplo n.º 3
0
        private void FloatingOriginSection()
        {
            _displayFloatingOrigin = GUILayout.Toggle(_displayFloatingOrigin, "Floating Origin", ButtonStyle);
            if (_displayFloatingOrigin)
            {
                if (GUILayout.Button("Reset floating origin", ButtonStyle))
                {
                    FloatingOrigin.fetch.ResetOffset();
                }

                if (GUILayout.Button("Set random floating origin", ButtonStyle))
                {
                    FloatingOrigin.SetOffset(new Vector3d(Random.Range(0, FloatingOrigin.fetch.threshold),
                                                          Random.Range(0, FloatingOrigin.fetch.threshold),
                                                          Random.Range(0, FloatingOrigin.fetch.threshold)));
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Advance the orbit epoch to the specified time sent as parameter
        /// </summary>
        public static void AdvanceShipPosition(this Vessel vessel, double time)
        {
            //If we advance the orbit when flying, we risk going inside the terrain as the orbit goes deep down the planet!
            if (vessel.situation <= Vessel.Situations.FLYING)
            {
                return;
            }

            var obtPos = vessel.orbit.getRelativePositionAtUT(time);
            var obtVel = vessel.orbit.getOrbitalVelocityAtUT(time);

            if (!vessel.packed)
            {
                vessel.GoOnRails();
            }

            vessel.orbit.UpdateFromStateVectors(obtPos, obtVel, vessel.mainBody, time);
            vessel.orbitDriver.updateFromParameters();

            FloatingOrigin.SetOffset(vessel.transform.position);
            OrbitPhysicsManager.CheckReferenceFrame();
            OrbitPhysicsManager.HoldVesselUnpack(10);
            vessel.IgnoreGForces(20);
        }