Exemple #1
0
        /// <summary>
        /// Kills and unloads a vessel.
        /// </summary>
        public void KillVessel(Guid vesselId, string reason, bool switchVessel = true, bool removeFromStore = true)
        {
            //ALWAYS remove it from the proto store as this dictionary is maintained even if we are in the KSC
            //This means that while in KSC if we receive a vessel remove msg, our FlightGlobals.Vessels will be empty
            //But our VesselsProtoStore probably contains that vessel that must be removed.
            if (removeFromStore)
            {
                VesselsProtoStore.RemoveVessel(vesselId);
                VesselPositionSystem.Singleton.RemoveVessel(vesselId);
                VesselFlightStateSystem.Singleton.RemoveVessel(vesselId);
            }
            var killVessel = FlightGlobals.FindVessel(vesselId);

            if (killVessel == null || killVessel.state == Vessel.State.DEAD)
            {
                return;
            }

            LunaLog.Log($"[LMP]: Killing vessel {killVessel.id}. Reason: {reason}");
            if (switchVessel)
            {
                SwitchVesselIfSpectating(killVessel);
            }

            UnloadVesselFromGame(killVessel);
            KillGivenVessel(killVessel);
            UnloadVesselFromScenario(killVessel);

            //When vessel.Die() is called, KSP calls RefreshMarkers() so no need to call it ourselves
        }
Exemple #2
0
        /// <summary>
        /// Kills and unloads a vessel.
        /// </summary>
        public void KillVessel(Guid vesselId)
        {
            //ALWAYS remove it from the proto store as this dictionary is maintained even if we are in the KSC
            //This means that while in KSC if we receive a vessel remove msg, our FlightGlobals.Vessels will be empty
            //But our VesselsProtoStore probably contains that vessel that must be removed.
            VesselsProtoStore.RemoveVessel(vesselId);

            var killVessel = FlightGlobals.FindVessel(vesselId);

            if (killVessel == null || killVessel.state == Vessel.State.DEAD)
            {
                return;
            }

            LunaLog.Log($"[LMP]: Killing vessel {killVessel.id}");
            SwitchVesselIfSpectating(killVessel);
            UnloadVesselFromGame(killVessel);
            KillGivenVessel(killVessel);
            UnloadVesselFromScenario(killVessel);
        }