コード例 #1
0
        public static void Learned(this ResearchProjectDef tech, float amount, float recipeCost, Pawn researcher, bool research = false)
        {
            float total = research ? tech.baseCost : recipeCost *tech.StuffCostFactor();

            amount *= research ? ResearchPointsPerWorkTick : StudyPointsPerWorkTick;
            Dictionary <ResearchProjectDef, float> expertise = researcher.TryGetComp <CompKnowledge>().expertise;

            foreach (ResearchProjectDef ancestor in expertise.Keys)
            {
                if (!tech.prerequisites.NullOrEmpty() && tech.prerequisites.Contains(ancestor))
                {
                    amount *= 2;
                    break;
                }
            }
            if (researcher != null && researcher.Faction != null)
            {
                amount /= tech.CostFactor(researcher.Faction.def.techLevel);
            }
            if (DebugSettings.fastResearch)
            {
                amount *= 500f;
            }
            if (researcher != null && research)
            {
                researcher.records.AddTo(RecordDefOf.ResearchPointsResearched, amount);
            }
            float num = tech.GetProgress(expertise);

            num += amount / total;
            //Log.Warning(tech + " research performed by " + researcher + ": " + amount + "/" + total);
            expertise[tech] = num;
        }
コード例 #2
0
        public static void Learned(this ResearchProjectDef tech, float amount, float recipeCost, Pawn researcher, bool research = false)
        {
            float total = research ? tech.baseCost : recipeCost *tech.StuffCostFactor();

            amount *= research ? ResearchPointsPerWorkTick : StudyPointsPerWorkTick;
            amount *= researcher.GetStatValue(StatDefOf.GlobalLearningFactor, true); //Because, why not?
            CompKnowledge techComp = researcher.TryGetComp <CompKnowledge>();
            Dictionary <ResearchProjectDef, float> expertise = techComp.expertise;

            foreach (ResearchProjectDef sucessor in expertise.Keys.Where(x => x.IsKnownBy(researcher)))
            {
                if (!sucessor.prerequisites.NullOrEmpty() && sucessor.prerequisites.Contains(tech))
                {
                    amount *= 2;
                    break;
                }
            }
            if (researcher != null && researcher.Faction != null)
            {
                amount /= tech.CostFactor(techComp.techLevel);
            }
            if (DebugSettings.fastResearch)
            {
                amount *= 500f;
            }
            if (researcher != null && research)
            {
                researcher.records.AddTo(RecordDefOf.ResearchPointsResearched, amount);
            }
            float num = tech.GetProgress(expertise);

            num            += amount / total;
            expertise[tech] = num;
        }