コード例 #1
0
            private void CheckAchievementsForCrew(ProtoCrewMember kerbal)
            {
                // just for safety
                if (kerbal == null)
                {
                    return;
                }
                // we do not want to check tourists
                if (kerbal.IsTourist())
                {
                    return;
                }
                // ok, lets check the kerbal
                Log.Detail("EventObserver:: checkArchivements for kerbal " + kerbal.name);
                Stopwatch sw = new Stopwatch();

                sw.Start();
                //
                // first check all first achievements
                CheckAchievementsForCrew(kerbal, true);
                // now check the rest
                CheckAchievementsForCrew(kerbal, false);
                //
                sw.Stop();
                Log.Detail("EventObserver:: checkArchivements done in " + sw.ElapsedMilliseconds + " ms");
            }
コード例 #2
0
            private void CheckAchievementsForCrew(ProtoCrewMember kerbal, bool hasToBeFirst)
            {
                if (kerbal == null)
                {
                    return;
                }
                // we do not want to check tourists
                if (kerbal.IsTourist())
                {
                    return;
                }
                // ok, lets check this kerbal
                HallOfFameEntry entry = HallOfFame.Instance().GetOrCreateEntry(kerbal);

                if (entry != null)
                {
                    foreach (Ribbon ribbon in RibbonPool.Instance())
                    {
                        try
                        {
                            Achievement achievement = ribbon.GetAchievement();
                            if (achievement.HasToBeFirst() == hasToBeFirst)
                            {
                                if (achievement.Check(entry))
                                {
                                    recorder.Record(ribbon, kerbal);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Error("exception caught in crew check: " + e.Message + "(" + e.GetType() + ")");
                        }
                    }
                }
                else
                {
                    Log.Warning("no entry for kerbal " + kerbal.name + " in hall of fame");
                }
            }
コード例 #3
0
 private void CheckAchievementsForContracts(ProtoCrewMember kerbal, Contract contract, bool hasToBeFirst)
 {
     if (kerbal == null)
     {
         return;
     }
     // we do not want to check tourists
     if (kerbal.IsTourist())
     {
         return;
     }
     // ok, lets check the kerbal
     foreach (Ribbon ribbon in RibbonPool.Instance())
     {
         Achievement achievement = ribbon.GetAchievement();
         if (achievement.HasToBeFirst() == hasToBeFirst)
         {
             if (achievement.Check(contract))
             {
                 recorder.Record(ribbon, kerbal);
             }
         }
     }
 }
コード例 #4
0
 private void CheckAchievementsForCrew(ProtoCrewMember kerbal)
 {
    // just for safety
    if (kerbal == null) return;
    // we do not want to check tourists
    if (kerbal.IsTourist()) return;
    // ok, lets check the kerbal
    Log.Detail("EventObserver:: checkArchivements for kerbal " + kerbal.name);
    Stopwatch sw = new Stopwatch();
    sw.Start();
    //
    // first check all first achievements
    CheckAchievementsForCrew(kerbal, true);
    // now check the rest
    CheckAchievementsForCrew(kerbal, false);
    //
    sw.Stop();
    Log.Detail("EventObserver:: checkArchivements done in "+sw.ElapsedMilliseconds+" ms");
 }
コード例 #5
0
         private void CheckAchievementsForContracts(ProtoCrewMember kerbal, Contract contract, bool hasToBeFirst)
         {

            if (kerbal == null) return;
            // we do not want to check tourists
            if (kerbal.IsTourist()) return;
            // ok, lets check the kerbal
            foreach (Ribbon ribbon in RibbonPool.Instance())
            {
               Achievement achievement = ribbon.GetAchievement();
               if (achievement.HasToBeFirst() == hasToBeFirst)
               {
                  if (achievement.Check(contract))
                  {
                     recorder.Record(ribbon, kerbal);
                  }
               }
            }
         }
コード例 #6
0
 private void CheckAchievementsForCrew(ProtoCrewMember kerbal, bool hasToBeFirst)
 {
    if (kerbal == null) return;
    // we do not want to check tourists
    if (kerbal.IsTourist()) return;
    // ok, lets check this kerbal
    HallOfFameEntry entry = HallOfFame.Instance().GetOrCreateEntry(kerbal);
    if (entry != null)
    {
       foreach (Ribbon ribbon in RibbonPool.Instance())
       {
          try
          {
             Achievement achievement = ribbon.GetAchievement();
             if (achievement.HasToBeFirst() == hasToBeFirst)
             {
                if (achievement.Check(entry))
                {
                   recorder.Record(ribbon, kerbal);
                }
             }
          }
          catch (Exception e)
          {
             Log.Error("exception caught in crew check: " + e.Message + "(" + e.GetType() + ")");
          }
       }
    }
    else
    {
       Log.Warning("no entry for kerbal " + kerbal.name + " in hall of fame");
    }
 }