Exemplo n.º 1
0
        /// <summary>
        /// Set all other controlled vessels as packed so the movement is better.
        /// Our vessel must be always unpacked
        /// </summary>
        private void PackUnpackVessels()
        {
            if (Enabled && VesselRangeSystemReady)
            {
                var controlledVessels = VesselCommon.GetControlledVessels();

                foreach (var vessel in FlightGlobals.Vessels.Where(v => v.id != FlightGlobals.ActiveVessel.id &&
                                                                   !SystemsContainer.Get <VesselRemoveSystem>().VesselWillBeKilled(v.id)))
                {
                    if (controlledVessels.Contains(vessel))
                    {
                        if (!SettingsSystem.CurrentSettings.PackOtherControlledVessels)
                        {
                            UnPackVessel(vessel);
                            continue;
                        }

                        if (!vessel.packed)
                        {
                            PackVessel(vessel);
                        }
                    }
                    else
                    {
                        UnPackVessel(vessel);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Set all other vessels as packed so the movement is better
        /// </summary>
        private IEnumerator PackControlledVessels()
        {
            var seconds = new WaitForSeconds(VesselPackCheckSInterval);

            while (true)
            {
                try
                {
                    if (!Enabled)
                    {
                        break;
                    }

                    if (ProtoSystemReady)
                    {
                        var controlledVessels = VesselCommon.GetControlledVessels();

                        foreach (var vessel in FlightGlobals.Vessels.Where(v => v.id != FlightGlobals.ActiveVessel.id))
                        {
                            if (controlledVessels.Contains(vessel))
                            {
                                if (!vessel.packed)
                                {
                                    PackVessel(vessel);
                                }
                            }
                            else
                            {
                                UnPackVessel(vessel);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError($"[LMP]: Coroutine error in PackControlledVessels {e}");
                }

                yield return(seconds);
            }
        }