Exemple #1
0
        /// <summary>
        /// Move and rotate a rover or a ship
        /// Process resources
        /// </summary>
        /// <param name="vessel"></param>
        public void OnVesselGoOffRails(Vessel vessel)
        {
            if ((vessel.situation == Vessel.Situations.LANDED) || (vessel.situation == Vessel.Situations.SPLASHED))
            {
                //if (vessel.isEVA) // Kerbals
                //    return;
                if (vessel.packed) // No physics
                {
                    return;
                }

                BVController controller = GetControllerOfVessel(vessel);

                if (controller != null)
                {
                    // Move only a rover or landed Kerbal
                    if ((controller is RoverController) || ((controller is KerbalController) && (vessel.situation == Vessel.Situations.LANDED)))
                    {
                        // Only rovers/Kerbals with active controller or rovers/Kerbals that just arrived at the destination
                        if (controller.Active || controller.Arrived)
                        {
                            // Stabilize only if another stabilizer is not present
                            if (!otherStabilizerPresent)
                            {
                                StabilizeVessel.AddVesselToStabilize(vessel, controller.RotationVector, Configuration.DisableRotation);
                            }
                            else // only rotate
                            {
                                if (!Configuration.DisableRotation)
                                {
                                    StabilizeVessel.Rotate(vessel, controller.RotationVector);
                                }
                            }
                        }
                    }

                    // Move only a ship or splashed Kerbal
                    if ((controller is ShipController) || ((controller is KerbalController) && (vessel.situation == Vessel.Situations.SPLASHED)))
                    {
                        // Only ships/Kerbals with active controller or ships/Kerbals that just arrived at the destination
                        if (controller.Active || controller.Arrived)
                        {
                            if (!Configuration.DisableRotation)
                            {
                                StabilizeVessel.Rotate(vessel, controller.RotationVector);
                            }
                        }
                    }

                    // Deduct resources
                    if (!vessel.isEVA)
                    {
                        controller.ProcessResources();
                    }
                }
            }
        }
        /// <summary>
        /// Move and rotate a rover
        /// </summary>
        /// <param name="vessel"></param>
        public void OnVesselGoOffRails(Vessel vessel)
        {
            if ((vessel.situation == Vessel.Situations.LANDED) || (vessel.situation == Vessel.Situations.SPLASHED))
            {
                if (vessel.isEVA) // Kerbals
                {
                    return;
                }
                if (vessel.packed) // No physics
                {
                    return;
                }

                BVController controller = null;
                for (int i = 0; i < BVControllers.Count; i++)
                {
                    if (BVControllers[i].vessel.id == vessel.id)
                    {
                        controller = BVControllers[i];
                        break;
                    }
                }

                if (controller != null)
                {
                    // Move only a rover
                    if (controller is RoverController)
                    {
                        // Only rovers with active controller or rovers that just arrived at the destination
                        if (controller.Active || controller.Arrived)
                        {
                            // Stabilize only if another stabilizer is not present
                            if (!otherStabilizerPresent)
                            {
                                StabilizeVessel.AddVesselToStabilize(vessel, controller.RotationVector, Configuration.DisableRotation);
                            }
                        }
                    }

                    if (controller is ShipController)
                    {
                        // Only ships with active controller or ships that just arrived at the destination
                        if (controller.Active || controller.Arrived)
                        {
                            if (!Configuration.DisableRotation)
                            {
                                StabilizeVessel.Rotate(vessel, controller.RotationVector);
                            }
                        }
                    }

                    // Deduct resources
                    controller.ProcessResources();
                }
            }
        }