Exemple #1
0
        void VesselTerminated(ProtoVessel pv)
        {
            // forget all kerbals data
            foreach (ProtoCrewMember c in pv.GetVesselCrew())
            {
                DB.KillKerbal(c.name, true);
            }

            // purge the caches
            ResourceCache.Purge(pv);
            Cache.PurgeVesselCaches(pv);

            // delete data on unloaded vessels only (this is handled trough OnPartWillDie for loaded vessels)
            if (pv.vesselRef != null && !pv.vesselRef.loaded)
            {
                Drive.DeleteDrivesData(pv.vesselRef);
            }
        }
Exemple #2
0
        void VesselDestroyed(Vessel v)
        {
            // rescan the damn kerbals
            // - vessel crew is empty at destruction time
            // - we can't even use the flightglobal roster, because sometimes it isn't updated yet at this point
            HashSet <string> kerbals_alive = new HashSet <string>();
            HashSet <string> kerbals_dead  = new HashSet <string>();

            foreach (Vessel ov in FlightGlobals.Vessels)
            {
                foreach (ProtoCrewMember c in Lib.CrewList(ov))
                {
                    kerbals_alive.Add(c.name);
                }
            }
            foreach (string key in DB.Kerbals().Keys)
            {
                if (!kerbals_alive.Contains(key))
                {
                    kerbals_dead.Add(key);
                }
            }
            foreach (string n in kerbals_dead)
            {
                // we don't know if the kerbal really is dead, or if it is just not currently assigned to a mission
                DB.KillKerbal(n, false);
            }

            // purge the caches
            ResourceCache.Purge(v);                 // works with loaded and unloaded vessels
            Cache.PurgeVesselCaches(v);             // works with loaded and unloaded vessels

            // delete data on unloaded vessels only (this is handled trough OnPartWillDie for loaded vessels)
            if (!v.loaded)
            {
                Drive.DeleteDrivesData(v);
            }
        }