Пример #1
0
        public static Dictionary <string, HashSet <AchievementCard> > GenerateAchievementLinks(HashSet <AchievementCard> cards)
        {
            var lookup = new Dictionary <string, HashSet <AchievementCard> >();

            DebugWriter.Log("Generating Achievement Links...");
            AchievementCard currentCard = null;

            try
            {
                foreach (AchievementCard card in cards)
                {
                    currentCard = card;
                    DebugWriter.Log($"Linking card {card.def.label} to {card.tracker.Key}");
                    if (lookup.TryGetValue(card.tracker.Key, out var hash))
                    {
                        hash.Add(card);
                    }
                    else
                    {
                        lookup.Add(card.tracker.Key, new HashSet <AchievementCard>()
                        {
                            card
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                string error = $"Failed to generate Achievement Links for {currentCard?.def.label ?? "[Null Card]"}. Exception: {ex.Message}";
                Log.Error(error);
                DebugWriter.Log(error);
                return(new Dictionary <string, HashSet <AchievementCard> >());
            }
            return(lookup);
        }
Пример #2
0
        private static void OutputAchievementKey()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();
            var keys = AchievementPointManager.AchievementList.Select(a => a.tracker.Key).ToHashSet();

            if (!keys.EnumerableNullOrEmpty())
            {
                foreach (string key in keys)
                {
                    list.Add(new DebugMenuOption(key, DebugMenuOptionMode.Action, delegate()
                    {
                        DebugWriter.Log($"Outputting Achievements with key: {key}");
                        Log.Message($"Outputting Achievements with key: {key}");
                        foreach (var card in AchievementPointManager.AchievementList.Where(a => a.tracker.Key == key))
                        {
                            DebugWriter.Log(card.def.label);
                            Log.Message(card.def.label);
                        }
                    }));
                }
                Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
            }
            else
            {
                Messages.Message("No AchievementKeys To Check", MessageTypeDefOf.RejectInput);
            }
        }
Пример #3
0
 internal void HardReset()
 {
     achievementLookup = null;
     achievementList   = null;
     unlockedCards     = new Stack <AchievementCard>();
     DebugWriter.Log($"Regenerating achievements...\n");
     PreInit(true);
     ResetPoints();
 }
Пример #4
0
 private static void OutputAchievementTickerCards()
 {
     DebugWriter.Log("---- ACHIEVEMENT TICKER CARDS ----");
     Log.Message("---- ACHIEVEMENT TICKER CARDS ----");
     foreach (AchievementCard card in AchievementPointManager.tickerAchievements)
     {
         string text = string.Concat(new object[]
         {
             "Card: ",
             card.def.label + "\n",
             "Tracker: ",
             card.tracker + "\n"
         });
         DebugWriter.Log(text);
         Log.Message(text);
     }
     DebugWriter.Log("--------------------------");
     Log.Message("--------------------------");
 }
        public virtual void UnlockCard(bool debugTools = false)
        {
            if (!unlocked)
            {
                unlocked = true;

                var vector = Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile);
                dateUnlocked = (Prefs.DevMode || debugTools) ? "UnlockedDevMode".Translate().ToString() : GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, vector);

                Current.Game.GetComponent <AchievementPointManager>().AddPoints(def.points);
                DefDatabase <SoundDef> .GetNamed("LetterArrive_Good").PlayOneShotOnCamera();

                DebugWriter.Log($"Unlocking: {GetUniqueLoadID()} Card: {def.label}");
                if (debugTools)
                {
                    DebugWriter.Log($"[Unlocked with DebugTools]");
                }
                Current.Game.GetComponent <AchievementPointManager>().DisplayCardWindow(this);
            }
        }
Пример #6
0
        private void PreInit(bool debug = false)
        {
            if (achievementLookup is null)
            {
                achievementLookup = new Dictionary <string, HashSet <AchievementCard> >();
            }
            if (achievementList is null)
            {
                achievementList = new HashSet <AchievementCard>();
            }
            if (unlockedCards is null)
            {
                unlockedCards = new Stack <AchievementCard>();
            }

            if (!UtilityMethods.BaseModActive)
            {
                return;
            }

            DebugWriter.ResetRootDir();
            if (debug)
            {
                DebugWriter.Log($"Resetting AchievementLinks");
            }
            achievementLookup = AchievementGenerator.GenerateAchievementLinks(achievementList);
            typeToKey.Clear();
            tickerAchievements.Clear();
            if (debug)
            {
                DebugWriter.Log($"Verifying Achievement List");
            }
            AchievementGenerator.VerifyAchievementList(ref achievementList, debug);

            CheckUnlocks();
        }