Exemplo n.º 1
0
        /// <summary>
        /// Updates the list of our vessels and other peoples vessel.
        /// We do this in another routine to improve performance
        /// </summary>
        private void UpdateOwnedAndOtherPeopleVesselList()
        {
            if (Enabled && VesselImmortalSystemReady)
            {
                OwnedVesselIds.Clear();
                OwnedVesselIds.AddRange(LockSystem.LockQuery.GetAllControlLocks(SettingsSystem.CurrentSettings.PlayerName)
                                        .Select(l => l.VesselId)
                                        .Union(LockSystem.LockQuery.GetAllUpdateLocks(SettingsSystem.CurrentSettings.PlayerName)
                                               .Select(l => l.VesselId))
                                        .Where(v => !SystemsContainer.Get <VesselRemoveSystem>().VesselWillBeKilled(v)));

                OwnedVessels.Clear();
                OwnedVessels.AddRange(OwnedVesselIds
                                      .Select(FlightGlobals.FindVessel)
                                      .Where(v => v != null));

                OtherPeopleVessels.Clear();
                OtherPeopleVessels.AddRange(LockSystem.LockQuery.GetAllControlLocks()
                                            .Union(LockSystem.LockQuery.GetAllUpdateLocks())
                                            .Select(l => l.VesselId)
                                            .Except(OwnedVesselIds)
                                            .Where(v => !SystemsContainer.Get <VesselRemoveSystem>().VesselWillBeKilled(v))
                                            .Select(FlightGlobals.FindVessel)
                                            .Where(v => v != null));
            }
        }
        protected override void OnDisabled()
        {
            base.OnDisabled();

            OwnedVessels.Clear();
            OtherPeopleVessels.Clear();

            //In case we disable this system, set all the vessels back as mortal...
            foreach (var vessel in FlightGlobals.Vessels)
            {
                SetVesselImmortalState(vessel, false);
            }
        }
        /// <summary>
        /// Make the other player vessels inmortal
        /// </summary>
        private void MakeOtherPlayerVesselsImmortal()
        {
            if (Enabled && VesselImmortalSystemReady)
            {
                foreach (var vessel in OwnedVessels.Where(v => v != null))
                {
                    SetVesselImmortalState(vessel, false);
                }

                foreach (var vessel in OtherPeopleVessels.Where(v => v != null))
                {
                    SetVesselImmortalState(vessel, true);
                }

                //If we are spectating set our own vessel as immortal
                SetVesselImmortalState(FlightGlobals.ActiveVessel, VesselCommon.IsSpectating);
            }
        }