Пример #1
0
        public static void HardAssign(ref Dictionary <ThingDef, ResearchProjectDef> thingDic, ref Dictionary <ResearchProjectDef, List <ThingDef> > researchDic)
        {
            foreach (string keyStr in hardAssignment.Keys)
            {
                if (overrideAssignment.ContainsKey(keyStr))
                {
                    continue;
                }
                ThingDef thing = DefDatabase <ThingDef> .GetNamedSilentFail(keyStr);

                if (thing != null)
                {
                    ResearchProjectDef rpd = DefDatabase <ResearchProjectDef> .GetNamedSilentFail(hardAssignment[keyStr]);

                    if (rpd != null)
                    {
                        CompProperties_DArcane comp = thing.GetCompProperties <CompProperties_DArcane>();
                        if (comp == null)
                        {
                            thing.comps.Add(new CompProperties_DArcane(rpd));
                        }

                        if (!thingDic.ContainsKey(thing))
                        {
                            thingDic.Add(thing, rpd);
                        }

                        if (!researchDic.ContainsKey(rpd))
                        {
                            researchDic.Add(rpd, new List <ThingDef> {
                                thing
                            });
                        }
                        else
                        {
                            if (!researchDic[rpd].Contains(thing))
                            {
                                researchDic[rpd].Add(thing);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        public static void MakeDictionaries()
        {
            thingDic    = new Dictionary <ThingDef, ResearchProjectDef>();
            researchDic = new Dictionary <ResearchProjectDef, List <ThingDef> >();

            foreach (RecipeDef recipe in DefDatabase <RecipeDef> .AllDefsListForReading)
            {
                ResearchProjectDef rpd = GetBestRPDForRecipe(recipe);
                if (rpd != null && recipe.ProducedThingDef != null)
                {
                    ThingDef producedThing = recipe.ProducedThingDef;

                    CompProperties_DArcane comp = producedThing.GetCompProperties <CompProperties_DArcane>();
                    if (comp == null)
                    {
                        producedThing.comps.Add(new CompProperties_DArcane(rpd));
                    }

                    thingDic.SetOrAdd(producedThing, rpd);

                    List <ThingDef> things;
                    if (researchDic.TryGetValue(rpd, out things))
                    {
                        things.Add(producedThing);
                    }
                    else
                    {
                        researchDic.Add(rpd, new List <ThingDef> {
                            producedThing
                        });
                    }
                }
            }

            GearAssigner.HardAssign(ref thingDic, ref researchDic);
            GearAssigner.OverrideAssign(ref thingDic, ref researchDic);
        }