예제 #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 (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);
		}
예제 #2
0
		void VesselRecovered(ProtoVessel pv, bool b)
		{
			// note: this is called multiple times when a vessel is recovered

			// for each crew member
			foreach (ProtoCrewMember c in pv.GetVesselCrew())
			{
				// avoid creating kerbal data in db again,
				// as this function may be called multiple times
				if (!DB.kerbals.ContainsKey(c.name)) continue;

				// set roster status of eva dead kerbals
				if (DB.Kerbal(c.name).eva_dead)
				{
					c.rosterStatus = ProtoCrewMember.RosterStatus.Dead;
				}

				// forget kerbal data of recovered kerbals
				DB.kerbals.Remove(c.name);
			}

			// for each part
			foreach (ProtoPartSnapshot p in pv.protoPartSnapshots)
			{
				// forget all potential vessel data
				DB.vessels.Remove(p.flightID);
			}

			// purge the caches
			Cache.Purge(pv);
			ResourceCache.Purge(pv);
		}
예제 #3
0
		void VesselTerminated(ProtoVessel pv)
		{
			// forget all kerbals data
			foreach (ProtoCrewMember c in pv.GetVesselCrew()) DB.kerbals.Remove(c.name);

			// for each part
			foreach (ProtoPartSnapshot p in pv.protoPartSnapshots)
			{
				// forget all potential vessel data
				DB.vessels.Remove(p.flightID);
			}

			// purge the caches
			Cache.Purge(pv);
			ResourceCache.Purge(pv);
		}
예제 #4
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);
        }