Exemple #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);
  }
Exemple #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);
  }
Exemple #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);
  }