Exemple #1
0
            public void RecordCustomRibbon(Ribbon ribbon)
            {
                CustomAchievement achievement = ribbon.GetAchievement() as CustomAchievement;

                if (achievement != null)
                {
                    int    nr  = achievement.GetIndex();
                    double now = HighLogic.CurrentGame.UniversalTime;
                    if (Log.IsLogable(Log.LEVEL.DETAIL))
                    {
                        Log.Detail("new or changed custom ribbon " + ribbon.GetName() + " recorded  at " + Utils.ConvertToKerbinTime(now));
                    }
                    string code = DataChange.DATACHANGE_CUSTOMRIBBON.GetCode() + nr;
                    TakeLog(now, code, achievement.GetName(), achievement.GetDescription());
                }
                else
                {
                    Log.Error("invalid custom ribbon achievement");
                }
            }
            private void AwardSelectedCustomRibbon()
            {
                if (selected == null)
                {
                    Log.Warning("no custom ribbon selected");
                    return;
                }

                CustomAchievement achievement = selected.GetAchievement() as CustomAchievement;

                if (achievement == null)
                {
                    Log.Warning("invalid custom ribbon");
                    return;
                }

                // changed name or text?
                if (!achievement.GetDescription().Equals(customRibbonText) || !achievement.GetName().Equals(customRibbonName))
                {
                    Log.Detail("name or text change of ribbon " + selected.GetCode());
                    // change name and text
                    achievement.SetName(customRibbonName);
                    achievement.SetDescription(customRibbonText);
                    // record changed ribbon
                    HallOfFame.Instance().RecordCustomRibbon(selected);
                }

                // assign ribbon to kerbal
                Log.Trace("assigning custom ribbon " + selected + " to kerbal " + entry.GetKerbal().name + " at game time " +
                          Planetarium.GetUniversalTime());
                HallOfFame.Instance().BeginArwardOfRibbons();
                HallOfFame.Instance().Record(entry.GetKerbal(), selected);
                HallOfFame.Instance().EndArwardOfRibbons();
                //
                // mark game as updated, if not in flight
                if (HighLogic.LoadedScene != GameScenes.FLIGHT)
                {
                    Log.Trace("mark game as updated");
                    HighLogic.CurrentGame.Updated();
                }
            }