示例#1
0
        void VesselDestroyed(Vessel v)
        {
            // for each part
            foreach (Part p in v.parts)
            {
                // forget all potential vessel data
                DB.vessels.Remove(p.flightID);
            }

            // 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 (KeyValuePair <string, KerbalData> p in DB.Kerbals())
            {
                if (!kerbals_alive.Contains(p.Key))
                {
                    kerbals_dead.Add(p.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
            Cache.Purge(v);
            ResourceCache.Purge(v);
        }
示例#2
0
        void VesselDestroyed(Vessel v)
        {
            // for each part
            foreach (Part p in v.parts)
            {
                // forget all potential vessel data
                DB.vessels.Remove(p.flightID);
            }

            // 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 (var p in DB.kerbals)
            {
                if (!kerbals_alive.Contains(p.Key))
                {
                    kerbals_dead.Add(p.Key);
                }
            }
            foreach (string n in kerbals_dead)
            {
                DB.kerbals.Remove(n);
            }

            // purge the caches
            Cache.Purge(v);
            ResourceCache.Purge(v);
        }
示例#3
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);
            }
        }