Example #1
0
 public ItemDescription(string Name, string Layer, float DamageAbsorbtion, Texture texture, ResearchProjectDef research)
 {
     this.Name = Name;
     this.Layer = Layer;
     this.DamageAbsorbtion = DamageAbsorbtion;
     this.texture = texture;
     this.research = research;
 }
Example #2
0
 public void LearnWeapons(ResearchProjectDef tech)
 {
     proficientWeapons.AddRange(tech.UnlockedWeapons());
 }
Example #3
0
        public IEnumerable <ResearchProjectDef> GetExpertiseDefsFor(Pawn pawn, FactionDef faction)
        {
            //1. Gather info on that pawn

            //a. tech level
            TechLevel factionTechLevel = faction?.techLevel ?? 0;
            TechLevel childhoodLevel   = 0;
            SkillDef  childhoodSkill   = null;
            bool      isPlayer         = pawn.Faction?.IsPlayer ?? false;

            techLevel = TechPoolIncludesBackground || !isPlayer?FindBGTechLevel(pawn, out childhoodLevel, out childhoodSkill) : factionTechLevel;

            TechLevel workingTechLevel = startingTechLevel = techLevel;

            //b. higest skills
            SkillRecord highestSkillRecord             = pawn.skills.skills.Aggregate(AccessHighestSkill);
            SkillDef    highestSkill                   = highestSkillRecord.def;
            IEnumerable <SkillRecord> secondCandidates = pawn.skills.skills.Except(highestSkillRecord).Where(x => SkillIsRelevant(x.def, techLevel));
            SkillDef secondSkill = secondCandidates.Aggregate(AccessHighestSkill).def;

            //c. age
            float middleAge    = pawn.RaceProps.lifeExpectancy / 2;
            int   matureAge    = pawn.RaceProps.lifeStageAges.FindLastIndex(x => x.minAge < middleAge); //not always the last possible age because there are mods with an "eldery" stage
            int   growthAdjust = 0;
            int   oldBonus     = 0;

            if (pawn.ageTracker.CurLifeStageIndex < matureAge)
            {
                growthAdjust = matureAge - pawn.ageTracker.CurLifeStageIndex;
            }
            else if (pawn.ageTracker.AgeBiologicalYears > middleAge)
            {
                oldBonus = 1;
            }

            //d. special cases
            isFighter = highestSkill == SkillDefOf.Melee;
            isShooter = highestSkill == SkillDefOf.Shooting;
            int  fighterHandicap = (isFighter | isShooter) ? 1 : 0;
            bool guru            = techLevel < TechLevel.Archotech && highestSkill == SkillDefOf.Intellectual && highestSkillRecord.Level >= Rand.Range(7, 10);

            //2. Calculate how many techs he should know
            int minSlots = techLevel > TechLevel.Medieval ? 1 : oldBonus;
            int slots    = Mathf.Max(minSlots, FactionExpertiseRange(techLevel) - growthAdjust + oldBonus - fighterHandicap);

            if (slots == 0)
            {
                if (Prefs.LogVerbose)
                {
                    Log.Warning($"... No slots for {pawn.gender.GetObjective()}, returning null. (StartingTechLevel is {techLevel}, CurLifeStageIndex is {pawn.ageTracker.CurLifeStageIndex}, fighterHandicap is {fighterHandicap})");
                }
                return(null);
            }

            //3. Info for debugging.

            if (Prefs.LogVerbose)
            {
                StringBuilder stringBuilder = new StringBuilder();
                string        factionName   = faction.label.ToLower() ?? pawn.Possessive().ToLower() + faction;
                if (TechPoolIncludesStarting)
                {
                    stringBuilder.Append($"default for {factionName}");
                }
                if (TechPoolIncludesTechLevel)
                {
                    stringBuilder.AppendWithComma($"{factionTechLevel.ToString().ToLower()} age");
                }
                if (TechPoolIncludesScenario)
                {
                    stringBuilder.AppendWithComma($"{Find.Scenario.name.ToLower()} scenario");
                }
                if (TechPoolIncludesBackground)
                {
                    stringBuilder.AppendWithComma($"{childhoodLevel.ToString().ToLower()} childhood & {techLevel.ToString().ToLower()} background");
                }
                Log.Message($"... Including technologies from: " + stringBuilder.ToString() + ".");
                stringBuilder.Clear();
                string guruText = guru ? " (allowing advanced knowledge)" : "";
                stringBuilder.Append($"... As {pawn.ageTracker.CurLifeStage.label}, {pawn.ProSubj()} gets {slots} slots. {pawn.Possessive().CapitalizeFirst()} highest relevant skills are {highestSkill.label}{guruText} & {secondSkill.label}.");
                Log.Message(stringBuilder.ToString());
            }

            //4. Finally, Distribute knowledge
            bool strict       = false;
            bool useChildhood = childhoodSkill != null && TechPoolIncludesBackground && SkillIsRelevant(childhoodSkill, childhoodLevel) && slots > 1;
            var  filtered     = TechTracker.FindTechs(x => TechPool(isPlayer, x, workingTechLevel, strict));
            int  pass         = 0;
            List <ResearchProjectDef> result = new List <ResearchProjectDef>();

            if (guru)
            {
                workingTechLevel++;
            }
            while (result.Count() < slots)
            {
                pass++;
                filtered.ExecuteEnumerable();
                if (filtered.EnumerableNullOrEmpty())
                {
                    Log.Warning("[HumanResources] Empty technology pool!");
                }
                var remaining = filtered.Where(x => !result.Contains(x));
                if (remaining.EnumerableNullOrEmpty())
                {
                    break;
                }
                SkillDef skill = null;
                if (pass == 1 && remaining.Any(x => x.Skills.Contains(highestSkill)))
                {
                    skill = highestSkill;
                }
                else if (pass == 2 && remaining.Any(x => x.Skills.Contains(secondSkill)))
                {
                    skill = useChildhood ? childhoodSkill : secondSkill;
                }
                ResearchProjectDef selected = remaining.RandomElementByWeightWithDefault(x => TechLikelihoodForSkill(pawn, x.Skills, slots, pass, skill), 1f) ?? remaining.RandomElement();
                result.Add(selected);

                //prepare next pass:
                strict = false;
                if ((guru && pass == 1) | result.NullOrEmpty())
                {
                    workingTechLevel--;
                }
                if (useChildhood)
                {
                    if (pass == 1)
                    {
                        strict           = true;
                        workingTechLevel = childhoodLevel;
                    }
                    if (pass == 2)
                    {
                        workingTechLevel = techLevel;
                    }
                }
                if (workingTechLevel == 0)
                {
                    break;
                }
            }
            if (!result.NullOrEmpty())
            {
                return(result);
            }
            Log.Error($"[HumanResources] Couldn't calculate any expertise for {pawn}");
            return(null);
        }
Example #4
0
        /// <summary>
        /// This creates new selection buttons with a new graphic
        /// </summary>
        /// <returns></returns>
        public override IEnumerable <Gizmo> GetGizmos()
        {
            List <Gizmo> baseGizmos = base.GetGizmos().ToList();

            for (int i = 0; i < baseGizmos.Count; i++)
            {
                Command baseGizmo = baseGizmos[i] as Command;
                if (baseGizmo != null && baseGizmo.defaultLabel == "CommandDesignateTogglePowerLabel".Translate())
                {
                    // Suppress base power on/off switch, as I need the functionality to disable the other functions
                    continue;
                }

                yield return(baseGizmos[i]);
            }


            // Key-Binding F - Manual On/Off
            Command_Action optF;

            optF = new Command_Action();
            if (flickableComp.SwitchIsOn)
            {
                optF.icon = texUI_Power;
            }
            else
            {
                optF.icon = texUI_NoPower;
            }
            optF.defaultLabel  = "CommandDesignateTogglePowerLabel".Translate();
            optF.defaultDesc   = "CommandDesignateTogglePowerDesc".Translate();
            optF.hotKey        = KeyBindingDefOf.Misc1; //KeyCode.F;
            optF.activateSound = SoundDef.Named("Click");
            optF.action        = switchPowerOnOff;
            optF.groupKey      = 313123001;
            yield return(optF);


            // Key-Binding C - Auto Pawn ON
            // Enabled when research is done.
            ResearchProjectDef researchProjectDef1 = DefDatabase <ResearchProjectDef> .GetNamedSilentFail("ResearchAutoPowerSwitch");

            if ((researchProjectDef1 != null) && (researchProjectDef1.IsFinished))
            {
                Command_Action optC;
                optC = new Command_Action();
                if (autoSwitchOnPawnActive)
                {
                    optC.icon = texUI_PowerPawnOn;
                }
                else
                {
                    optC.icon = texUI_NoPowerPawnOn;
                }
                optC.hotKey   = KeyBindingDefOf.Misc2; //KeyCode.C;
                optC.disabled = false;
                if (!pawnSearchModeDistanceActive)
                {
                    optC.defaultDesc = txtAutoOnMotionRoom;
                }
                else
                {
                    optC.defaultDesc = txtAutoOnMotionNearbyRange + " " + ((int)radarDistancePawn).ToString();
                }
                optC.activateSound = SoundDef.Named("Click");
                optC.action        = SwitchPawnActiveOnOff;
                optC.groupKey      = 313123002;
                yield return(optC);
            }


            // Key-Binding Y - Auto Enemy ON
            // Enabled when research is done.
            ResearchProjectDef researchProjectDef2 = DefDatabase <ResearchProjectDef> .GetNamedSilentFail("ResearchAutoEnemySwitch");

            if ((researchProjectDef2 != null) && (researchProjectDef2.IsFinished))
            {
                Command_Action optY;
                optY = new Command_Action();
                if (autoSwitchOnEnemyActive)
                {
                    optY.icon = texUI_PowerEnemyOn;
                }
                else
                {
                    optY.icon = texUI_NoPowerEnemyOn;
                }
                optY.hotKey        = KeyBindingDefOf.Misc3; //KeyCode.Y;
                optY.disabled      = false;
                optY.defaultDesc   = txtAutoOnEnemyNearbyRange + " " + ((int)radarDistance).ToString();
                optY.activateSound = SoundDef.Named("Click");
                optY.action        = SwitchEnemyOnActiveOnOff;
                optY.groupKey      = 313123003;
                yield return(optY);
            }


            // Key-Binding X - Auto Enemy OFF
            // Enabled when research is done.
            ResearchProjectDef researchProjectDef3 = DefDatabase <ResearchProjectDef> .GetNamedSilentFail("ResearchAutoEnemySwitch");

            if ((researchProjectDef3 != null) && (researchProjectDef3.IsFinished))
            {
                Command_Action optX;
                optX = new Command_Action();
                if (autoSwitchOffEnemyActive)
                {
                    optX.icon = texUI_PowerEnemyOff;
                }
                else
                {
                    optX.icon = texUI_NoPowerEnemyOff;
                }
                optX.hotKey        = KeyBindingDefOf.Misc4; //KeyCode.X;
                optX.disabled      = false;
                optX.defaultDesc   = txtAutoOffEnemyNearbyRange + " " + ((int)radarDistance).ToString();
                optX.activateSound = SoundDef.Named("Click");
                optX.action        = SwitchEnemyOffActiveOnOff;
                optX.groupKey      = 313123004;
                yield return(optX);
            }


            // Key-Binding M - SwitchOnTimer
            // Enabled when research is done.
            ResearchProjectDef researchProjectDef4 = DefDatabase <ResearchProjectDef> .GetNamedSilentFail("ResearchAutoPowerSwitch");

            if ((researchProjectDef4 != null) && (researchProjectDef4.IsFinished))
            {
                Command_Action optM;
                optM = new Command_Action();
                if (autoSwitchTimerActive)
                {
                    optM.icon = texUI_TimerOn;
                }
                else
                {
                    optM.icon = texUI_NoTimerOn;
                }
                optM.hotKey        = KeyBindingDefOf.Misc5; //KeyCode.M;
                optM.disabled      = false;
                optM.defaultDesc   = txtTimerClickSetOnTime;
                optM.activateSound = SoundDef.Named("Click");
                optM.action        = TimerOnClicked;
                optM.groupKey      = 313123005;
                yield return(optM);
            }

            // Key-Binding N - SwitchOffTimer
            // Enabled when research is done.
            ResearchProjectDef researchProjectDef5 = DefDatabase <ResearchProjectDef> .GetNamedSilentFail("ResearchAutoPowerSwitch");

            if ((researchProjectDef5 != null) && (researchProjectDef5.IsFinished))
            {
                Command_Action optN;
                optN = new Command_Action();
                if (autoSwitchTimerActive)
                {
                    optN.icon = texUI_TimerOff;
                }
                else
                {
                    optN.icon = texUI_NoTimerOff;
                }
                optN.hotKey        = KeyBindingDefOf.Misc6; //KeyCode.N;
                optN.disabled      = false;
                optN.defaultDesc   = txtTimerClickSetOffTime;
                optN.activateSound = SoundDef.Named("Click");
                optN.action        = TimerOffClicked;
                optN.groupKey      = 313123006;
                yield return(optN);
            }
        }
Example #5
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 4)
            {
                VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax, separateChannel);
                return(false);
            }

            string itemKey = command[2].ToLower();

            if (itemKey == null || itemKey == "")
            {
                VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax, separateChannel);
                return(false);
            }

            IEnumerable <Store.Item> itemSearch = StoreInventory.items.Where(s =>
                                                                             s.price > 0 &&
                                                                             (s.abr == itemKey ||
                                                                              s.defname.ToLower() == itemKey)
                                                                             );

            if (itemSearch.Count() > 0)
            {
                item = itemSearch.ElementAt(0);
            }

            if (item == null || item.price < 1)
            {
                Toolkit.client.SendMessage($"@{viewer.username} item not found.", separateChannel);
                return(false);
            }

            ThingDef itemThingDef = ThingDef.Named(item.defname);

            bool isResearched = true;
            ResearchProjectDef researchProject = null;

            Log.Warning("Checking researched");
            if (itemThingDef.recipeMaker != null &&
                itemThingDef.recipeMaker.researchPrerequisite != null &&
                !itemThingDef.recipeMaker.researchPrerequisite.IsFinished)
            {
                Log.Warning("Recipe not researched");
                isResearched    = false;
                researchProject = itemThingDef.recipeMaker.researchPrerequisite;
            }
            else if (!itemThingDef.IsResearchFinished)
            {
                Log.Warning("Building not researched");
                isResearched    = false;
                researchProject = itemThingDef.researchPrerequisites.ElementAt(0);
            }

            if (BuyItemSettings.mustResearchFirst && !isResearched)
            {
                string output = $"@{viewer.username} {itemThingDef.LabelCap} has not been researched yet, must finish research project {researchProject.LabelCap} first.";

                Toolkit.client.SendMessage(output, separateChannel);

                return(false);
            }

            string quantityKey = command[3];

            if (quantityKey == null || quantityKey == "")
            {
                VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax, separateChannel);
                return(false);
            }

            try
            {
                if (!int.TryParse(quantityKey, out checked (quantity)))
                {
                    return(false);
                }

                price = checked (item.price * quantity);
            }
            catch (OverflowException e)
            {
                Log.Warning(e.Message);
                return(false);
            }

            if (quantity < 1 || price < 1)
            {
                VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax, separateChannel);
                return(false);
            }

            if (!Purchase_Handler.CheckIfViewerHasEnoughCoins(viewer, price, separateChannel))
            {
                return(false);
            }

            if (price < ToolkitSettings.MinimumPurchasePrice)
            {
                Toolkit.client.SendMessage(Helper.ReplacePlaceholder(
                                               "TwitchToolkitMinPurchaseNotMet".Translate(),
                                               viewer: viewer.username,
                                               amount: price.ToString(),
                                               first: ToolkitSettings.MinimumPurchasePrice.ToString()
                                               ), separateChannel);
                return(false);
            }

            return(true);
        }
Example #6
0
        public static void DrawLinesCustomPrerequisites(ResearchProjectDef project, ResearchTabDef curTab, Vector2 start, Vector2 end, ResearchProjectDef selectedProject, int i)
        {
            List <ResearchProjectDef> projects = SRTSMod.mod.settings.defProperties[srtsDefProjects.FirstOrDefault(x => x.Value == project).Key.defName].CustomResearch;

            start.x = project.ResearchViewX * 190f + 140f;
            start.y = project.ResearchViewY * 100f + 25f;
            foreach (ResearchProjectDef proj in projects)
            {
                if (proj != null && proj.tab == curTab)
                {
                    end.x = proj.ResearchViewX * 190f;
                    end.y = proj.ResearchViewY * 100f + 25f;
                    if (selectedProject == project || selectedProject == proj)
                    {
                        if (i == 1)
                        {
                            Widgets.DrawLine(start, end, TexUI.HighlightLineResearchColor, 4f);
                        }
                    }
                    if (i == 0)
                    {
                        Widgets.DrawLine(start, end, new Color(255, 215, 0, 0.25f), 2f);
                    }
                }
            }
        }
        private void DrawResearchContent( Rect rect )
        {
            // Find the corresponding helpdef
            HelpDef helpDef = DefDatabase<HelpDef>.AllDefsListForReading.Find(hd => (
               (hd.keyDef == SelectedProject)
            ));

            if( SelectedProject == null )
            {
                return;
            }

            // Set up rects
            Rect descRect = rect.ContractedBy(_margin.x);
            descRect.height -= _buttonSize.y * 2 + _margin.y * 2;
            Rect controlRect = rect.ContractedBy(_margin.x);
            controlRect.yMin = descRect.yMax + _margin.y;

            #region description
            float paragraphMargin = 8f;
            float inset = 30f;

            var titleRect = new Rect(rect.xMin, rect.yMin, rect.width, 60f);
            Text.Font = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label( titleRect, SelectedProject.LabelCap );
            Text.Font = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            Rect outRect = rect.ContractedBy(2 * _margin.x); // double margin, this is a large UI block.
            outRect.yMin += 60f;
            Rect viewRect = outRect;
            viewRect.width -= 16f;
            viewRect.height = _contentHeight;

            GUI.BeginGroup( outRect );
            Widgets.BeginScrollView( outRect.AtZero(), ref _contentScrollPos, viewRect.AtZero() );

            Vector2 cur = Vector2.zero;

            HelpDetailSectionHelper.DrawText( ref cur, viewRect, SelectedProject.description );

            cur.y += paragraphMargin;

            if( helpDef != null )
            {
                foreach( HelpDetailSection section in helpDef.HelpDetailSections )
                {
                    cur.x = 0f;
                    if( !string.IsNullOrEmpty( section.Label ) )
                    {
                        HelpDetailSectionHelper.DrawText( ref cur, viewRect, section.Label );
                        cur.x = inset;
                    }
                    if( section.StringDescs != null )
                    {
                        foreach( string s in section.StringDescs )
                        {
                            HelpDetailSectionHelper.DrawText( ref cur, viewRect, s );
                        }
                    }
                    if( section.KeyDefs != null )
                    {
                        foreach( DefStringTriplet defStringTriplet in section.KeyDefs )
                        {
                            if( HelpDetailSectionHelper.DrawDefLink( ref cur, viewRect, defStringTriplet ) )
                            {
                                // Helper can only return true if helpDef exists.
                                // If this is a research, helpDef and researchDef should both exist.
                                if( defStringTriplet.Def is ResearchProjectDef )
                                {
                                    _showResearchedProjects = ShowResearch.All;
                                    RefreshSource();
                                    SelectedProject = (ResearchProjectDef)defStringTriplet.Def;
                                }
                                else
                                {
                                    MainTabDef helpTab = DefDatabase<MainTabDef>.GetNamed("CCL_ModHelp", false);

                                    if (helpTab != null)
                                    {
                                        HelpDef helpTabHelpDef = DefDatabase<HelpDef>.AllDefsListForReading.First(
                                                hd => hd.keyDef == defStringTriplet.Def );
                                        MainTabWindow_ModHelp helpWindow = (MainTabWindow_ModHelp) helpTab.Window;
                                        helpWindow.SelectedHelpDef = helpTabHelpDef;
                                        Find.MainTabsRoot.SetCurrentTab(helpTab, false);
                                        helpWindow.JumpToDef(helpTabHelpDef);
                                    }
                                }
                            }
                        }
                    }
                    cur.y += paragraphMargin;
                }
            }

            _contentHeight = cur.y;

            Widgets.EndScrollView();
            GUI.EndGroup();
            #endregion

            #region controls

            GUI.BeginGroup( controlRect );
            Rect buttonRect = new Rect(controlRect.width / 2f - _buttonSize.x / 2, 0f, _buttonSize.x, _buttonSize.y);
            if( SelectedProject.IsFinished )
            {
                Widgets.DrawMenuSection( buttonRect );
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label( buttonRect, "Finished".Translate() );
                Text.Anchor = TextAnchor.UpperLeft;
            }
            else if( SelectedProject == Find.ResearchManager.currentProj )
            {
                Widgets.DrawMenuSection( buttonRect );
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label( buttonRect, "InProgress".Translate() );
                Text.Anchor = TextAnchor.UpperLeft;
            }
            else if( !SelectedProject.PrereqsFulfilled )
            {
                Widgets.DrawMenuSection( buttonRect );
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label( buttonRect, "RI.PreReqLocked".Translate() );
                Text.Anchor = TextAnchor.UpperLeft;
            }
            else
            {
                if( Widgets.TextButton( buttonRect, "Research".Translate() ) )
                {
                    SoundDef.Named( "ResearchStart" ).PlayOneShotOnCamera();
                    Find.ResearchManager.currentProj = SelectedProject;
                }
                if( Prefs.DevMode )
                {
                    Rect devButtonRect = buttonRect;
                    devButtonRect.x += devButtonRect.width + _margin.x;
                    if( Widgets.TextButton( devButtonRect, "Debug Insta-finish" ) )
                    {
                        Find.ResearchManager.currentProj = SelectedProject;
                        Find.ResearchManager.InstantFinish( SelectedProject );
                    }
                }
            }
            Rect progressRect = new Rect(_margin.x, _buttonSize.y + _margin.y, controlRect.width - 2 * _margin.x, _buttonSize.y);
            Widgets.FillableBar( progressRect, SelectedProject.PercentComplete, BarFillTex, BarBgTex, true );
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label( progressRect, SelectedProject.ProgressNumbersString );
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            #endregion
        }
Example #8
0
 public static void parrotSetCurrentResearch(ResearchProjectDef project)
 {
     Find.ResearchManager.currentProj = project;
 }
Example #9
0
 public TechMapping(ResearchProjectDef tech)
 {
     Tech = tech;
 }
        static HelpDef HelpForResearch( ResearchProjectDef researchProjectDef, HelpCategoryDef category )
        {
            var helpDef = new HelpDef();
            helpDef.defName = researchProjectDef.defName + "_ResearchProjectDef_Help";
            helpDef.keyDef = researchProjectDef.defName;
            helpDef.label = researchProjectDef.label;
            helpDef.category = category;

            var s = new StringBuilder();

            s.AppendLine( researchProjectDef.description );
            s.AppendLine();

            #region Base Stats

            s.AppendLine( "AutoHelpTotalCost".Translate( researchProjectDef.totalCost.ToString() ) );
            s.AppendLine();

            #endregion

            #region Research, Buildings, Recipes and SowTags

            // Add research required
            var researchDefs = researchProjectDef.GetResearchRequirements();
            BuildDefDescription( s, "AutoHelpListResearchRequired".Translate(), researchDefs.ConvertAll<Def>( def =>(Def)def ) );

            // Add buildings it unlocks
            var thingDefs = researchProjectDef.GetThingsUnlocked();
            BuildDefDescription( s, "AutoHelpListThingsUnlocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) );

            // Add recipes it unlocks
            var recipeDefs = researchProjectDef.GetRecipesUnlocked( ref thingDefs );
            BuildDefWithDefDescription( s, "AutoHelpListRecipesUnlocked".Translate(), "AutoHelpListRecipesOnThingsUnlocked".Translate(), recipeDefs.ConvertAll<Def>( def =>(Def)def ), thingDefs.ConvertAll<Def>( def =>(Def)def ) );

            // Look in advanced research to add plants and sow tags it unlocks
            var sowTags = researchProjectDef.GetSowTagsUnlocked( ref thingDefs );
            BuildDefWithStringDescription( s, "AutoHelpListPlantsUnlocked".Translate(), "AutoHelpListPlantsIn".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ), sowTags );

            #endregion

            #region Lockouts

            // Get advanced research which locks
            researchDefs = researchProjectDef.GetResearchedLockedBy();
            BuildDefDescription( s, "AutoHelpListResearchLockout".Translate(), researchDefs.ConvertAll<Def>( def =>(Def)def ) );

            #endregion

            helpDef.description = s.ToString();
            return helpDef;
        }
        public override void DoWindowContents(Rect inRect)
        {
            base.DoWindowContents(inRect);
            if (!_noBenchWarned)
            {
                if (!Find.ListerBuildings.ColonistsHaveBuilding(ThingDefOf.ResearchBench))
                {
                    Find.WindowStack.Add(new Dialog_Message("ResearchMenuWithoutBench".Translate()));
                }
                _noBenchWarned = true;
            }
            Text.Font = GameFont.Medium;
            Text.Anchor = TextAnchor.UpperCenter;
            Widgets.Label(new Rect(0f, 0f, inRect.width, 300f), "Research".Translate());
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font = GameFont.Small;
            Rect sidebar = new Rect(0f, 75f, 330f, inRect.height - 75f);
            Rect content = new Rect(sidebar.xMax + 10f, 45f, inRect.width - sidebar.width - 10f, inRect.height - 45f);
            Widgets.DrawMenuSection(sidebar, false);
            Widgets.DrawMenuSection(content);

            // plop in extra row for input + sort buttons
            Rect sortFilterRow = sidebar.ContractedBy(10f);
            sortFilterRow.height = 30f;

            Rect filterRect = new Rect(sortFilterRow);
            filterRect.width = sortFilterRow.width - 110f;
            Rect deleteFilter = new Rect(filterRect.xMax + 6f, filterRect.yMin + 3f, 24f, 24f);
            Rect sortByName = new Rect(deleteFilter.xMax + 6f, filterRect.yMin + 3f, 24f, 24f);
            Rect sortByCost = new Rect(sortByName.xMax + 6f, filterRect.yMin + 3f, 24f, 24f);
            TooltipHandler.TipRegion(filterRect, "RI.filterTooltip".Translate());
            if (_filter != "") TooltipHandler.TipRegion(deleteFilter, "RI.deleteFilterTooltip".Translate());
            TooltipHandler.TipRegion(sortByName, "RI.sortByNameTooltip".Translate());
            TooltipHandler.TipRegion(sortByCost, "RI.sortByCostTooltip".Translate());

            // filter options
            _filter = Widgets.TextField(filterRect, _filter);
            if (_oldFilter != _filter)
            {
                _oldFilter = _filter;
                RefreshSource();
            }
            if (_filter != "")
            {
                if (Widgets.ImageButton(deleteFilter, Widgets.CheckboxOffTex))
                {
                    _filter = "";
                    RefreshSource();
                }
            }

            // sort options
            if (Widgets.ImageButton(sortByName, _sortByNameTex))
            {
                if (_sortBy != SortOptions.Name)
                {
                    _sortBy = SortOptions.Name;
                    _asc = false;
                    RefreshSource();
                }
                else
                {
                    _asc = !_asc;
                    RefreshSource();
                }
            }
            if (Widgets.ImageButton(sortByCost, _sortByCostTex))
            {
                if (_sortBy != SortOptions.Cost)
                {
                    _sortBy = SortOptions.Cost;
                    _asc = true;
                    RefreshSource();
                }
                else
                {
                    _asc = !_asc;
                    RefreshSource();
                }
            }

            // contract sidebar area
            Rect sidebarInner = sidebar.ContractedBy(10f);
            sidebarInner.yMin += 30f;
            sidebarInner.height -= 30f;
            float height = 25 * _source.Count() + 100;
            Rect sidebarContent = new Rect(0f, 0f, sidebarInner.width - 16f, height);
            Widgets.BeginScrollView(sidebarInner, ref _projectListScrollPosition, sidebarContent);
            Rect position = sidebarContent.ContractedBy(10f);
            GUI.BeginGroup(position);
            int num = 0;

            foreach (ResearchProjectDef current in from rp in _source
                                                   select rp)
            {
                Rect sidebarRow = new Rect(0f, num, position.width, 25f);
                if (SelectedProject == current)
                {
                    GUI.DrawTexture(sidebarRow, TexUI.HighlightTex);
                }

                string text = current.LabelCap + " (" + current.totalCost.ToString("F0") + ")";
                Rect sidebarRowInner = new Rect(sidebarRow);
                sidebarRowInner.x += 6f;
                sidebarRowInner.width -= 6f;
                float num2 = Text.CalcHeight(text, sidebarRowInner.width);
                if (sidebarRowInner.height < num2)
                {
                    sidebarRowInner.height = num2 + 3f;
                }
                // give the label a colour if we're in the all tab.
                Color textColor;
                if (_showResearchedProjects == ShowResearch.All)
                {
                    if (current.IsFinished)
                    {
                        textColor = new Color(1f, 1f, 1f);
                    }
                    else if (!current.PrereqsFulfilled)
                    {
                        textColor = new Color(.6f, .6f, .6f);
                    }
                    else
                    {
                        textColor = new Color(.8f, .85f, 1f);
                    }
                }
                else
                {
                    textColor = new Color(.8f, .85f, 1f);
                }
                if (Widgets.TextButton(sidebarRowInner, text, false, true, textColor))
                {
                    SoundDefOf.Click.PlayOneShotOnCamera();
                    SelectedProject = current;
                }
                num += 25;
            }
            GUI.EndGroup();
            Widgets.EndScrollView();
            List<TabRecord> list = new List<TabRecord>();
            TabRecord item = new TabRecord("RI.All".Translate(), delegate
            {
                this._showResearchedProjects = ShowResearch.All;
                RefreshSource();
            }, _showResearchedProjects == ShowResearch.All);
            list.Add(item);
            TabRecord item2 = new TabRecord("Researched".Translate(), delegate
            {
                this._showResearchedProjects = ShowResearch.Completed;
                RefreshSource();
            }, _showResearchedProjects == ShowResearch.Completed);
            list.Add(item2);
            TabRecord item3 = new TabRecord("RI.Available".Translate(), delegate
            {
                this._showResearchedProjects = ShowResearch.Available;
                RefreshSource();
            }, _showResearchedProjects == ShowResearch.Available);
            list.Add(item3);
            TabDrawer.DrawTabs(sidebar, list);
            Rect position2 = content.ContractedBy(20f);
            GUI.BeginGroup(position2);
            if (SelectedProject != null)
            {
                Text.Font = GameFont.Medium;
                GenUI.SetLabelAlign(TextAnchor.MiddleLeft);
                Rect rect6 = new Rect(20f, 0f, position2.width - 20f, 50f);
                Widgets.Label(rect6, SelectedProject.LabelCap);
                GenUI.ResetLabelAlign();
                Text.Font = GameFont.Small;
                Rect rect7 = new Rect(0f, 50f, position2.width, position2.height - 50f);
                string desc = SelectedProject.description;

                // select prerequisites
                desc += ".\n\n";
                string[] prereqs = SelectedProject.prerequisites.Select(def => def.LabelCap).ToArray();
                desc += "RI.Prerequisites".Translate() + ": ";
                if (prereqs.Length == 0)
                {
                    desc += "RI.none".Translate();
                }
                else
                {
                    desc += String.Join(", ", prereqs);
                }
                desc += ".\n\n";

                // select follow-ups
                string[] follow = DefDatabase<ResearchProjectDef>.AllDefsListForReading.Where(rpd => rpd.prerequisites.Contains(SelectedProject)).Select(rpd => rpd.LabelCap).ToArray();
                desc += "RI.LeadsTo".Translate() + ": ";
                if (!follow.Any())
                {
                    desc += "RI.none".Translate();
                }
                else
                {
                    desc += String.Join(", ", follow);
                }
                desc += ".\n\n";

                //// find all unlocks
                //desc += "Unlocks: ";
                //string[] unlocks = getUnlocks(selectedProject);
                //if (unlocks == null || unlocks.Count() == 0)
                //{
                //    desc += "none";
                //}
                //else
                //{
                //    desc += String.Join(", ", unlocks);
                //}
                //desc += ".\n\n";

                Widgets.Label(rect7, desc);
                Rect rect8 = new Rect(position2.width / 2f - 50f, 300f, 100f, 50f);
                if (SelectedProject.IsFinished)
                {
                    Widgets.DrawMenuSection(rect8);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(rect8, "Finished".Translate());
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                else if (SelectedProject == Find.ResearchManager.currentProj)
                {
                    Widgets.DrawMenuSection(rect8);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(rect8, "InProgress".Translate());
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                else if (!SelectedProject.PrereqsFulfilled)
                {
                    Widgets.DrawMenuSection(rect8);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(rect8, "RI.PreReqLocked".Translate());
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                else
                {
                    if (Widgets.TextButton(rect8, "Research".Translate()))
                    {
                        SoundDef.Named("ResearchStart").PlayOneShotOnCamera();
                        Find.ResearchManager.currentProj = SelectedProject;
                    }
                    if (Prefs.DevMode)
                    {
                        Rect rect9 = rect8;
                        rect9.x += rect9.width + 4f;
                        if (Widgets.TextButton(rect9, "Debug Insta-finish"))
                        {
                            Find.ResearchManager.currentProj = SelectedProject;
                            Find.ResearchManager.InstantFinish(SelectedProject);
                        }
                    }
                }
                Rect rect10 = new Rect(15f, 450f, position2.width - 30f, 35f);
                Widgets.FillableBar(rect10, SelectedProject.PercentComplete, BarFillTex, BarBgTex, true);
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(rect10, SelectedProject.ProgressNumbersString);
                Text.Anchor = TextAnchor.UpperLeft;
            }
            GUI.EndGroup();
        }
 public override void PreOpen()
 {
     base.PreOpen();
     SelectedProject = Find.ResearchManager.currentProj;
     _filter = "";
     _oldFilter = "";
     RefreshSource();
 }
 public ThingResearchPair( ThingDef t, ResearchProjectDef r )
 {
     thingDef = t;
     researchProject = r;
 }
 public ResearchCompletePair( ResearchProjectDef r )
 {
     researchProject = r;
     wasComplete = false;
 }
        private void DrawResearchRow( ResearchProjectDef current, Rect sidebarRow )
        {
            if( SelectedProject == current )
            {
                GUI.DrawTexture( sidebarRow, TexUI.HighlightTex );
            }

            string text = current.LabelCap + " (" + current.totalCost.ToString("F0") + ")";
            Rect sidebarRowInner = new Rect(sidebarRow);
            sidebarRowInner.x += 6f;
            sidebarRowInner.width -= 6f;
            float num2 = Text.CalcHeight(text, sidebarRowInner.width);
            if( sidebarRowInner.height < num2 )
            {
                sidebarRowInner.height = num2 + 3f;
            }
            // give the label a colour if we're in the all tab.
            Color textColor;
            if( _showResearchedProjects == ShowResearch.All )
            {
                if( current.IsFinished )
                {
                    textColor = new Color( 1f, 1f, 1f );
                }
                else if( !current.PrereqsFulfilled )
                {
                    textColor = new Color( .6f, .6f, .6f );
                }
                else
                {
                    textColor = new Color( .8f, .85f, 1f );
                }
            }
            else
            {
                textColor = new Color( .8f, .85f, 1f );
            }
            if( Widgets.TextButton( sidebarRowInner, text, false, true, textColor ) )
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                SelectedProject = current;
            }
        }
Example #16
0
 public static bool TechprintAvailable(ResearchProjectDef research)
 {
     return(research.TechprintRequirementMet);
 }
Example #17
0
 public static bool BuildingPresent(ResearchProjectDef research)
 {
     throw stubMsg;
 }
 // Token: 0x0600002B RID: 43 RVA: 0x000028C0 File Offset: 0x00000AC0
 private static bool CanQueueResearches(bool original, ResearchProjectDef research)
 {
     return(original && CustomStorytellerUtility.TechLevelAllowed(research.techLevel));
 }
Example #19
0
 public static List <ResearchProjectDef> Ancestors(this ResearchProjectDef research)
 {
     throw stubMsg;
 }
Example #20
0
        // Token: 0x06000087 RID: 135 RVA: 0x00005260 File Offset: 0x00003460
        public bool ValidateRecipe(ThingDef t, out bool CanUseMax, out List <RCPItemCanUse> FinalList, out int MinProd,
                                   out int MaxProd, out int Ticks)
        {
            CanUseMax = true;
            FinalList = null;
            MinProd   = 0;
            MaxProd   = 0;
            Ticks     = 0;
            if (debug && Find.TickManager.TicksGame % 100 == 0)
            {
                Log.Message("ValRep: " + t.defName);
            }

            if (!RPThingMakerUtility.RCPProdValues(t, out var ticks, out var minProd, out var maxProd, out var Res))
            {
                return(false);
            }

            Ticks   = ticks;
            MinProd = minProd;
            MaxProd = maxProd;
            if (debug)
            {
                Log.Message(
                    string.Concat("RCPVals: Ticks: ", ticks.ToString(), " minProd: ", minProd.ToString(), " maxProd: ",
                                  maxProd.ToString(), " Res: ", Res));
            }

            if (!ResearchProjectDef.Named(Res).IsFinished || minProd <= 0 || maxProd <= 0 || ticks <= 0)
            {
                if (!ResearchProjectDef.Named(Res).IsFinished)
                {
                    Log.Message("RPThingMaker.ErrorRes".Translate(MakerThingDef.label));
                    isProducing        = false;
                    NumProd            = 0;
                    ProdWorkTicks      = 0;
                    TotalProdWorkTicks = 0;
                }
                else
                {
                    Log.Message(
                        "RPThingMaker.ErrorRCP".Translate(MakerThingDef.label, ticks.ToString(), minProd.ToString(),
                                                          maxProd.ToString()));
                    isProducing        = false;
                    NumProd            = 0;
                    ProdWorkTicks      = 0;
                    TotalProdWorkTicks = 0;
                }

                return(false);
            }

            var listRCP = RPThingMakerUtility.GetRCPList(t);

            if (listRCP.Count <= 0)
            {
                if (debug)
                {
                    Log.Message("RCP is False.");
                }

                return(false);
            }

            if (debug)
            {
                Log.Message("RCP Listings: " + listRCP.Count);
            }

            var RCPListPotentials = new List <RCPItemCanUse>();
            var RCPGroups         = new List <int>();

            foreach (var rprcpListItem in listRCP)
            {
                var MaterialsMin    = 0;
                var MaterialsMax    = 0;
                var RCPItem         = rprcpListItem;
                var RCPMinNumNeeded = (int)Math.Round(RCPItem.num * minProd * RCPItem.ratio);
                var RCPMaxNumNeeded = (int)Math.Round(RCPItem.num * maxProd * RCPItem.ratio);
                if (HasEnoughMaterialInHoppers(RCPItem.def, RCPMinNumNeeded, true))
                {
                    MaterialsMin = RCPMinNumNeeded;
                }

                if (HasEnoughMaterialInHoppers(RCPItem.def, RCPMaxNumNeeded, false))
                {
                    MaterialsMax = RCPMaxNumNeeded;
                }

                if (MaterialsMin > 0 || MaterialsMax > 0)
                {
                    RCPListPotentials.Add(new RCPItemCanUse
                    {
                        def = RCPItem.def,
                        Min = MaterialsMin,
                        Max = MaterialsMax,
                        Grp = RCPItem.mixgrp
                    });
                }

                if (!RCPGroups.Contains(RCPItem.mixgrp))
                {
                    RCPGroups.Add(RCPItem.mixgrp);
                }
            }

            if (debug)
            {
                Log.Message(
                    "InnerRecipe List: Groups: " + RCPGroups.Count + " , Potentials: " + RCPListPotentials.Count);
            }

            FinalList = new List <RCPItemCanUse>();
            var NotAllGroups = false;

            if (RCPGroups.Count > 0)
            {
                foreach (var grp in RCPGroups)
                {
                    var foundGroup = false;
                    if (RCPListPotentials.Count > 0)
                    {
                        var bestthingsofar = default(RCPItemCanUse);
                        var best           = false;
                        var bestmax        = false;
                        foreach (var itemchk in RCPListPotentials)
                        {
                            if (itemchk.Grp != grp)
                            {
                                continue;
                            }

                            foundGroup = true;
                            if (itemchk.Min <= 0)
                            {
                                continue;
                            }

                            if (itemchk.Max > 0)
                            {
                                if (bestmax)
                                {
                                    continue;
                                }

                                bestthingsofar.def = itemchk.def;
                                bestthingsofar.Min = itemchk.Min;
                                bestthingsofar.Max = itemchk.Max;
                                bestthingsofar.Grp = itemchk.Grp;
                                best    = true;
                                bestmax = true;
                            }
                            else if (!best)
                            {
                                bestthingsofar.def = itemchk.def;
                                bestthingsofar.Min = itemchk.Min;
                                bestthingsofar.Max = itemchk.Max;
                                bestthingsofar.Grp = itemchk.Grp;
                                best = true;
                            }
                        }

                        if (!bestmax)
                        {
                            bestthingsofar.Max = 0;
                        }

                        FinalList.Add(bestthingsofar);
                    }

                    if (foundGroup)
                    {
                        continue;
                    }

                    NotAllGroups = true;
                    DoNotFoundGroupsOverlay(this, t, grp);
                }
            }

            if (FinalList.Count > 0)
            {
                for (var l = 0; l < FinalList.Count; l++)
                {
                    if (FinalList[l].Max == 0)
                    {
                        CanUseMax = false;
                    }
                }
            }

            if (NotAllGroups)
            {
                if (debug)
                {
                    Log.Message("RCP is False. Not all inputs found");
                }

                return(false);
            }

            if (debug)
            {
                Log.Message("RCP is True. with (" + FinalList.Count + ") final list items");
            }

            return(true);
        }
Example #21
0
 public static bool ContainedInDefProjects(ResearchProjectDef project) => srtsDefProjects.Any(x => x.Value == project);
 // Token: 0x06000003 RID: 3 RVA: 0x000021E6 File Offset: 0x000003E6
 private void FinishInstantly(ResearchProjectDef proj)
 {
     Find.ResearchManager.FinishProject(proj);
     Messages.Message("MessageResearchProjectFinishedByItem".Translate(proj.label),
                      MessageTypeDefOf.PositiveEvent);
 }
 private void FinishInstantly(ResearchProjectDef proj, Pawn usedBy)
 {
     Find.ResearchManager.FinishProject(proj, false, null);
     Messages.Message("MessageResearchProjectFinishedByItem".Translate(proj.LabelCap), usedBy, MessageTypeDefOf.PositiveEvent, true);
 }
Example #24
0
 private float PosX(ResearchProjectDef d)
 {
     return(CoordToPixelsX(d.ResearchViewX));
 }
Example #25
0
        internal static ThingDef CreateNanoBedDefFromSupportedBed(this ThingDef bed, Action <ThingDef> fnAdditionalProcessing, List <ThingDef> linkableBuildings, List <CompProperties_Facility> facilities)
        {
            Type typeRimworldBed = typeof(Building_Bed);
            Type bedToClone      = bed.GetType();

            if (typeRimworldBed.IsAssignableFrom(bedToClone))
            {
                throw new Exception("Type [" + bedToClone.Name + "] is not supported.");
            }

            //FieldInfo[] fieldsThingDef = typeof(ThingDef).GetFields(BindingFlags.Public | BindingFlags.Instance);

            //ThingDef nBed = new ThingDef();
            //foreach (FieldInfo field in fieldsThingDef)
            //	field.SetValue(nBed, field.GetValue(bed));

            //nBed.comps = new List<CompProperties>();
            //for (int i = 0; i < bed.comps.Count; i++)
            //{
            //	ConstructorInfo constructor = bed.comps[i].GetType().GetConstructor(Type.EmptyTypes);
            //	CompProperties comp = (CompProperties)constructor.Invoke(null);

            //	FieldInfo[] fields = comp.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            //	foreach (FieldInfo field in fields)
            //		field.SetValue(comp, field.GetValue(bed.comps[i]));

            //	nBed.comps.Add(comp);
            //}

            ThingDef nBed = InitialCloneWithComps(bed);

            nBed.statBases.Add(new StatModifier()
            {
                stat = StatDef.Named("Ogre_NanoApparelRate"), value = 0
            });
            nBed.statBases.Add(new StatModifier()
            {
                stat = StatDef.Named("Ogre_NanoWeaponsRate"), value = 0
            });

            CompProperties_Power power = new CompProperties_Power();

            power.compClass            = typeof(CompPowerTrader);
            power.basePowerConsumption = 60f;
            power.shortCircuitInRain   = false;
            nBed.comps.Add(power);

            CompProperties_Flickable flick = new CompProperties_Flickable();

            flick.compClass = typeof(CompFlickable);
            nBed.comps.Add(flick);

            CompProperties_Refuelable fuel = new CompProperties_Refuelable();

            fuel.fuelConsumptionRate     = 0;
            fuel.fuelCapacity            = 25.0f * bed.size.x;  // same way it calculates in BedUtility
            fuel.consumeFuelOnlyWhenUsed = true;
            fuel.fuelFilter = new ThingFilter();
            fuel.fuelFilter.SetAllow(ThingDef.Named("Ogre_NanoTechFuel"), true);
            nBed.comps.Add(fuel);

            Dictionary <string, int> cost = new Dictionary <string, int>()
            {
                { "ComponentIndustrial", 1 },
                { "Steel", 5 }
            };

            if (nBed.costList == null)
            {
                nBed.costList = new List <ThingDefCountClass>();
            }

            Dictionary <string, ThingDefCountClass> current = nBed.costList.ToDictionary(x => x.thingDef.defName, y => y);


            foreach (string item in cost.Keys)
            {
                ThingDefCountClass count = null;
                if (!current.TryGetValue(item, out count))
                {
                    count = new ThingDefCountClass(ThingDef.Named(item), (cost[item] * nBed.size.x));
                    nBed.costList.Add(count);
                }
                else
                {
                    count.count += (cost[item] * nBed.size.x);
                }
            }

            bool found = false;

            nBed.researchPrerequisites = new List <ResearchProjectDef>();
            if (bed.researchPrerequisites != null && bed.researchPrerequisites.Count > 0)
            {
                foreach (ResearchProjectDef d in bed.researchPrerequisites)
                {
                    if (d.defName == "Ogre_NanoTech")
                    {
                        found = true;
                    }
                    nBed.researchPrerequisites.Add(d);
                }
            }

            if (!found)
            {
                nBed.researchPrerequisites.Add(ResearchProjectDef.Named("Ogre_NanoTech"));
            }


            nBed.defName                      += "_NanoBed";
            nBed.description                  += "\n\n" + TranslatorFormattedStringExtensions.Translate("NanoTech.Description.Short");
            nBed.label                         = TranslatorFormattedStringExtensions.Translate("NanoTech.ModName.Short") + " " + nBed.label;
            nBed.thingClass                    = typeof(NanoBed);
            nBed.tradeability                  = Tradeability.None;
            nBed.scatterableOnMapGen           = false;
            nBed.tickerType                    = TickerType.Rare;
            nBed.constructionSkillPrerequisite = bed.constructionSkillPrerequisite < 2 ? 2 : bed.constructionSkillPrerequisite;
            nBed.uiIconScale                   = 0.9f;
            nBed.techLevel                     = TechLevel.Industrial;
            nBed.shortHash                     = 0;

            nBed.statBases = new List <StatModifier>();
            foreach (StatModifier s in bed.statBases)
            {
                if (s.stat == StatDefOf.WorkToBuild)
                {
                    nBed.statBases.Add(new StatModifier()
                    {
                        stat  = StatDefOf.WorkToBuild,
                        value = s.value + 2500
                    });
                }
                else
                {
                    nBed.statBases.Add(s);
                }
            }

            ModContentPack nTechModPack = DefDatabase <ThingDef> .GetNamed("Ogre_NanoTech_Bed").modContentPack;;

            nBed.modContentPack = nTechModPack;

            // as of 1.3 without this, it wont
            // show the out of fuel icon
            nBed.drawerType = DrawerType.RealtimeOnly;

            nBed.designationCategory = DefDatabase <DesignationCategoryDef> .AllDefsListForReading.Find(x => x.defName == "Ogre_NanoRepairTech_DesignationCategory");

            //typeof(ShortHashGiver).GetMethod("GiveShortHash", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, new object[] { nBed, typeof(ThingDef) });

            MethodInfo hashGiver = typeof(ShortHashGiver).GetMethod("GiveShortHash", BindingFlags.NonPublic | BindingFlags.Static);

            hashGiver.Invoke(null, new object[] { nBed, typeof(ThingDef) });

            // These things do not appear to work as good as
            // they did in 1.2, comment them out and do the
            // frame/blueprint defs by clone

            //MethodInfo newBluePrintDef = typeof(RimWorld.ThingDefGenerator_Buildings).GetMethod("NewBlueprintDef_Thing", BindingFlags.Static | BindingFlags.NonPublic);
            //nBed.blueprintDef = (ThingDef)newBluePrintDef.Invoke(null, new object[] { nBed, false, null });
            //nBed.installBlueprintDef = (ThingDef)newBluePrintDef.Invoke(null, new object[] { nBed, true, null });

            //MethodInfo newFrameDef = typeof(RimWorld.ThingDefGenerator_Buildings).GetMethod("NewFrameDef_Thing", BindingFlags.Static | BindingFlags.NonPublic);
            //nBed.frameDef = (ThingDef)newFrameDef.Invoke(null, new object[] { nBed });

            //ThingDef bluePrint = new ThingDef();
            //foreach (FieldInfo field in fieldsThingDef)
            //	field.SetValue(bluePrint, field.GetValue(bed.blueprintDef));

            //bluePrint.comps = new List<CompProperties>();
            //for (int i = 0; i < bed.blueprintDef.comps.Count; i++)
            //{
            //	ConstructorInfo constructor = bed.blueprintDef.comps[i].GetType().GetConstructor(Type.EmptyTypes);
            //	CompProperties comp = (CompProperties)constructor.Invoke(null);

            //	FieldInfo[] fields = comp.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            //	foreach (FieldInfo field in fields)
            //		field.SetValue(comp, field.GetValue(bed.blueprintDef.comps[i]));

            //	bluePrint.comps.Add(comp);
            //}

            ThingDef bluePrint = InitialCloneWithComps(bed.blueprintDef);

            bluePrint.modContentPack   = nTechModPack;
            bluePrint.entityDefToBuild = nBed;
            bluePrint.defName          = nBed.defName + "_BluePrint";

            bluePrint.shortHash = 0;
            hashGiver.Invoke(null, new object[] { bluePrint, typeof(ThingDef) });

            nBed.blueprintDef = bluePrint;

            //ThingDef installBluePrint = new ThingDef();
            //foreach (FieldInfo field in fieldsThingDef)
            //	field.SetValue(installBluePrint, field.GetValue(bed.installBlueprintDef));

            //installBluePrint.comps = new List<CompProperties>();
            //for (int i = 0; i < bed.installBlueprintDef.comps.Count; i++)
            //{
            //	ConstructorInfo constructor = bed.installBlueprintDef.comps[i].GetType().GetConstructor(Type.EmptyTypes);
            //	CompProperties comp = (CompProperties)constructor.Invoke(null);

            //	FieldInfo[] fields = comp.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            //	foreach (FieldInfo field in fields)
            //		field.SetValue(comp, field.GetValue(bed.installBlueprintDef.comps[i]));

            //	installBluePrint.comps.Add(comp);
            //}

            ThingDef installBluePrint = InitialCloneWithComps(bed.installBlueprintDef);

            installBluePrint.modContentPack   = nTechModPack;
            installBluePrint.entityDefToBuild = nBed;
            installBluePrint.defName          = nBed.defName + "_InstallBluePrint";

            installBluePrint.shortHash = 0;
            hashGiver.Invoke(null, new object[] { installBluePrint, typeof(ThingDef) });

            nBed.installBlueprintDef = installBluePrint;

            //ThingDef frameDef = new ThingDef();
            //foreach (FieldInfo field in fieldsThingDef)
            //	field.SetValue(frameDef, field.GetValue(bed.frameDef));

            //frameDef.comps = new List<CompProperties>();

            //for (int i = 0; i < bed.frameDef.comps.Count; i++)
            //{
            //	ConstructorInfo constructor = bed.frameDef.comps[i].GetType().GetConstructor(Type.EmptyTypes);
            //	CompProperties comp = (CompProperties)constructor.Invoke(null);

            //	FieldInfo[] fields = comp.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            //	foreach (FieldInfo field in fields)
            //		field.SetValue(comp, field.GetValue(bed.frameDef.comps[i]));

            //	frameDef.comps.Add(comp);
            //}

            ThingDef frameDef = InitialCloneWithComps(bed.frameDef);

            frameDef.modContentPack   = nTechModPack;
            frameDef.entityDefToBuild = nBed;
            frameDef.defName          = nBed.defName + "_Frame";

            frameDef.shortHash = 0;
            hashGiver.Invoke(null, new object[] { frameDef, typeof(ThingDef) });

            nBed.frameDef = frameDef;

            // Breaks on save if these defs
            // are not loaded into the DefDatabase
            DefDatabase <ThingDef> .Add(bluePrint);

            DefDatabase <ThingDef> .Add(installBluePrint);

            DefDatabase <ThingDef> .Add(frameDef);

            if (bed.building.bed_humanlike)
            {
                CompProperties_AffectedByFacilities abf = nBed.GetCompProperties <CompProperties_AffectedByFacilities>();
                if (abf == null)
                {
                    abf = new CompProperties_AffectedByFacilities();
                    nBed.comps.Add(abf);
                }

                if (abf.linkableFacilities == null)
                {
                    abf.linkableFacilities = new List <ThingDef>();
                }

                abf.linkableFacilities.AddRange(linkableBuildings);

                foreach (CompProperties_Facility f in facilities)
                {
                    f.linkableBuildings.Add(nBed);
                }
            }

            if (fnAdditionalProcessing != null)
            {
                fnAdditionalProcessing.Invoke(nBed);
            }



            return(nBed);
        }
Example #26
0
 private float PosY(ResearchProjectDef d)
 {
     return(CoordToPixelsY(d.ResearchViewY));
 }
Example #27
0
        private void DrawRightRect(Rect rightOutRect)
        {
            rightOutRect.yMin += 32f;
            Widgets.DrawMenuSection(rightOutRect);
            List <TabRecord> list = new List <TabRecord>();

            foreach (ResearchTabDef allDef in DefDatabase <ResearchTabDef> .AllDefs)
            {
                ResearchTabDef localTabDef = allDef;
                list.Add(new TabRecord(localTabDef.LabelCap, delegate
                {
                    CurTab = localTabDef;
                }, CurTab == localTabDef));
            }
            TabDrawer.DrawTabs(rightOutRect, list);
            if (Prefs.DevMode)
            {
                Rect rect = rightOutRect;
                rect.yMax = rect.yMin + 20f;
                rect.xMin = rect.xMax - 80f;
                Rect butRect = rect.RightPartPixels(30f);
                rect = rect.LeftPartPixels(rect.width - 30f);
                Widgets.CheckboxLabeled(rect, "Edit", ref editMode);
                if (Widgets.ButtonImageFitted(butRect, TexButton.Copy))
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (ResearchProjectDef item in from def in DefDatabase <ResearchProjectDef> .AllDefsListForReading
                             where def.Debug_IsPositionModified()
                             select def)
                    {
                        stringBuilder.AppendLine(item.defName);
                        stringBuilder.AppendLine(string.Format("  <researchViewX>{0}</researchViewX>", item.ResearchViewX.ToString("F2")));
                        stringBuilder.AppendLine(string.Format("  <researchViewY>{0}</researchViewY>", item.ResearchViewY.ToString("F2")));
                        stringBuilder.AppendLine();
                    }
                    GUIUtility.systemCopyBuffer = stringBuilder.ToString();
                    Messages.Message("Modified data copied to clipboard.", MessageTypeDefOf.SituationResolved, historical: false);
                }
            }
            else
            {
                editMode = false;
            }
            Rect outRect = rightOutRect.ContractedBy(10f);
            Rect rect2   = new Rect(0f, 0f, rightViewWidth, rightViewHeight);
            Rect rect3   = rect2.ContractedBy(10f);

            rect2.width = rightViewWidth;
            rect3       = rect2.ContractedBy(10f);
            Vector2 start = default(Vector2);
            Vector2 end   = default(Vector2);

            Widgets.ScrollHorizontal(outRect, ref rightScrollPosition, rect2);
            Widgets.BeginScrollView(outRect, ref rightScrollPosition, rect2);
            GUI.BeginGroup(rect3);
            List <ResearchProjectDef> allDefsListForReading = DefDatabase <ResearchProjectDef> .AllDefsListForReading;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < allDefsListForReading.Count; j++)
                {
                    ResearchProjectDef researchProjectDef = allDefsListForReading[j];
                    if (researchProjectDef.tab == CurTab)
                    {
                        start.x = PosX(researchProjectDef);
                        start.y = PosY(researchProjectDef) + 25f;
                        for (int k = 0; k < researchProjectDef.prerequisites.CountAllowNull(); k++)
                        {
                            ResearchProjectDef researchProjectDef2 = researchProjectDef.prerequisites[k];
                            if (researchProjectDef2 != null && researchProjectDef2.tab == CurTab)
                            {
                                end.x = PosX(researchProjectDef2) + 140f;
                                end.y = PosY(researchProjectDef2) + 25f;
                                if (selectedProject == researchProjectDef || selectedProject == researchProjectDef2)
                                {
                                    if (i == 1)
                                    {
                                        Widgets.DrawLine(start, end, TexUI.HighlightLineResearchColor, 4f);
                                    }
                                }
                                else if (i == 0)
                                {
                                    Widgets.DrawLine(start, end, TexUI.DefaultLineResearchColor, 2f);
                                }
                            }
                        }
                    }
                }
            }
            for (int l = 0; l < allDefsListForReading.Count; l++)
            {
                ResearchProjectDef researchProjectDef3 = allDefsListForReading[l];
                if (researchProjectDef3.tab == CurTab)
                {
                    Rect   source    = new Rect(PosX(researchProjectDef3), PosY(researchProjectDef3), 140f, 50f);
                    string label     = GetLabel(researchProjectDef3);
                    Rect   rect4     = new Rect(source);
                    Color  textColor = Widgets.NormalOptionColor;
                    Color  color     = default(Color);
                    Color  color2    = default(Color);
                    bool   flag      = !researchProjectDef3.IsFinished && !researchProjectDef3.CanStartNow;
                    if (researchProjectDef3 == Find.ResearchManager.currentProj)
                    {
                        color = TexUI.ActiveResearchColor;
                    }
                    else if (researchProjectDef3.IsFinished)
                    {
                        color = TexUI.FinishedResearchColor;
                    }
                    else if (flag)
                    {
                        color = TexUI.LockedResearchColor;
                    }
                    else if (researchProjectDef3.CanStartNow)
                    {
                        color = TexUI.AvailResearchColor;
                    }
                    if (selectedProject == researchProjectDef3)
                    {
                        color += TexUI.HighlightBgResearchColor;
                        color2 = TexUI.HighlightBorderResearchColor;
                    }
                    else
                    {
                        color2 = TexUI.DefaultBorderResearchColor;
                    }
                    if (flag)
                    {
                        textColor = ProjectWithMissingPrerequisiteLabelColor;
                    }
                    for (int m = 0; m < researchProjectDef3.prerequisites.CountAllowNull(); m++)
                    {
                        ResearchProjectDef researchProjectDef4 = researchProjectDef3.prerequisites[m];
                        if (researchProjectDef4 != null && selectedProject == researchProjectDef4)
                        {
                            color2 = TexUI.HighlightLineResearchColor;
                        }
                    }
                    if (requiredByThisFound)
                    {
                        for (int n = 0; n < researchProjectDef3.requiredByThis.CountAllowNull(); n++)
                        {
                            ResearchProjectDef researchProjectDef5 = researchProjectDef3.requiredByThis[n];
                            if (selectedProject == researchProjectDef5)
                            {
                                color2 = TexUI.HighlightLineResearchColor;
                            }
                        }
                    }
                    if (Widgets.CustomButtonText(ref rect4, label, color, textColor, color2, cacheHeight: true))
                    {
                        SoundDefOf.Click.PlayOneShotOnCamera();
                        selectedProject = researchProjectDef3;
                    }
                    if (editMode && Mouse.IsOver(rect4) && Input.GetMouseButtonDown(0))
                    {
                        draggingTab = researchProjectDef3;
                    }
                }
            }
            GUI.EndGroup();
            Widgets.EndScrollView();
            if (!Input.GetMouseButton(0))
            {
                draggingTab = null;
            }
            if (draggingTab != null && !Input.GetMouseButtonDown(0) && Event.current.type == EventType.Layout)
            {
                ResearchProjectDef researchProjectDef6 = draggingTab;
                Vector2            delta = Event.current.delta;
                float   x      = PixelsToCoordX(delta.x);
                Vector2 delta2 = Event.current.delta;
                researchProjectDef6.Debug_ApplyPositionDelta(new Vector2(x, PixelsToCoordY(delta2.y)));
            }
        }
Example #28
0
 private string GetLabel(ResearchProjectDef r)
 {
     return(r.LabelCap + "\n(" + r.CostApparent.ToString("F0") + ")");
 }
Example #29
0
 public void LearnCrops(ResearchProjectDef tech)
 {
     proficientPlants.AddRange(tech.UnlockedPlants());
 }
Example #30
0
        private void DrawResearchBenchFacilityRequirement(ThingDef requiredFacility, CompAffectedByFacilities bestMatchingBench, ResearchProjectDef project, ref Rect rect)
        {
            Thing thing  = null;
            Thing thing2 = null;

            if (bestMatchingBench != null)
            {
                thing  = bestMatchingBench.LinkedFacilitiesListForReading.Find((Thing x) => x.def == requiredFacility);
                thing2 = bestMatchingBench.LinkedFacilitiesListForReading.Find((Thing x) => x.def == requiredFacility && bestMatchingBench.IsFacilityActive(x));
            }
            SetPrerequisiteStatusColor(thing2 != null, project);
            string text = requiredFacility.LabelCap;

            if (thing != null && thing2 == null)
            {
                text = text + " (" + "InactiveFacility".Translate() + ")";
            }
            Widgets.LabelCacheHeight(ref rect, "  " + text);
        }
Example #31
0
 public static IEnumerable <ThingDef> GetPlantsUnlocked(this ResearchProjectDef research)
 {
     return(DefDatabase <ThingDef> .AllDefsListForReading
            .Where(td => td.plant?.sowResearchPrerequisites?.Contains( research ) ?? false));
 }
Example #32
0
 public static bool Allows(this Bill bill, ResearchProjectDef tech)
 {
     return(bill.ingredientFilter.Allows(TechTracker.FindTech(tech).Stuff));
 }
Example #33
0
        public void Hatch()
        {
            int randomNumber = rand.Next(1, 13);

            //Log.Warning(randomNumber.ToString());


            if (randomNumber == 12)
            {
                if (ResearchProjectDef.Named("GR_AdvancedGeneticEngineering").IsFinished)
                {
                    GenSpawn.Spawn(ThingDef.Named("GR_ThrumboGenetic"), this.parent.Position, this.parent.Map);
                }
                else
                {
                    RecombinateAgain();
                }
            }
            else if (randomNumber == 11)
            {
                if (ResearchProjectDef.Named("GR_HumanoidGeneticEngineering").IsFinished)
                {
                    GenSpawn.Spawn(ThingDef.Named("GR_HumanoidGenetic"), this.parent.Position, this.parent.Map);
                }
                else
                {
                    RecombinateAgain();
                }
            }
            else if (randomNumber == 10)
            {
                if (ResearchProjectDef.Named("GR_ReptilianGenome").IsFinished)
                {
                    GenSpawn.Spawn(ThingDef.Named("GR_ReptilianGenetic"), this.parent.Position, this.parent.Map);
                }
                else
                {
                    RecombinateAgain();
                }
            }
            else if (randomNumber == 9)
            {
                if (ResearchProjectDef.Named("GR_InsectoidGenome").IsFinished)
                {
                    GenSpawn.Spawn(ThingDef.Named("GR_InsectoidGenetic"), this.parent.Position, this.parent.Map);
                }
                else
                {
                    RecombinateAgain();
                }
            }
            else if (randomNumber == 8)
            {
                GenSpawn.Spawn(ThingDef.Named("GR_FelineGenetic"), this.parent.Position, this.parent.Map);
            }
            else if (randomNumber == 7)
            {
                GenSpawn.Spawn(ThingDef.Named("GR_RodentGenetic"), this.parent.Position, this.parent.Map);
            }
            else if (randomNumber == 6)
            {
                GenSpawn.Spawn(ThingDef.Named("GR_BearGenetic"), this.parent.Position, this.parent.Map);
            }
            else if (randomNumber == 5)
            {
                GenSpawn.Spawn(ThingDef.Named("GR_ChickenGenetic"), this.parent.Position, this.parent.Map);
            }
            else if (randomNumber == 4)
            {
                GenSpawn.Spawn(ThingDef.Named("GR_BoomalopeGenetic"), this.parent.Position, this.parent.Map);
            }
            else if (randomNumber == 3)
            {
                GenSpawn.Spawn(ThingDef.Named("GR_MuffaloGenetic"), this.parent.Position, this.parent.Map);
            }
            else if (randomNumber == 2)
            {
                GenSpawn.Spawn(ThingDef.Named("GR_WolfGenetic"), this.parent.Position, this.parent.Map);
            }
            else
            {
                GenSpawn.Spawn(ThingDef.Named("GR_RuinedGenetic"), this.parent.Position, this.parent.Map);
            }

            this.parent.Destroy(DestroyMode.Vanish);
        }
 public static Node Node(this ResearchProjectDef research)
 {
     return(ResearchTree.Forest.FirstOrDefault(node => node.Research == research));
 }
Example #35
0
        public static void MakeThingDictionaries()
        {
            thingDic    = new Dictionary <ThingDef, ResearchProjectDef>();
            researchDic = new Dictionary <ResearchProjectDef, List <ThingDef> >();

            foreach (RecipeDef recipe in DefDatabase <RecipeDef> .AllDefsListForReading)
            {
                ResearchProjectDef rpd = ThingDefHelper.GetBestRPDForRecipe(recipe);
                if (rpd != null && recipe.ProducedThingDef != null)
                {
                    if (ShardMaker.ShardForProject(rpd) != null && (rpd.techprintCount > 0 || TechprintingSettings.printAllItems))
                    {
                        ThingDef producedThing = recipe.ProducedThingDef;
                        if (producedThing.GetCompProperties <CompProperties_Shardable>() == null)
                        {
                            producedThing.comps.Add(new CompProperties_Shardable());
                        }

                        thingDic.SetOrAdd(producedThing, rpd);

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

            if (TechprintingSettings.shardBuildings)
            {
                foreach (ThingDef building in DefDatabase <ThingDef> .AllDefs.Where(x => x.category == ThingCategory.Building || x.building != null))
                {
                    if (thingDic.ContainsKey(building))
                    {
                        continue;
                    }
                    ResearchProjectDef rpd = ThingDefHelper.GetBestRPDForBuilding(building);
                    if (rpd != null)
                    {
                        if (ShardMaker.ShardForProject(rpd) != null && (rpd.techprintCount > 0 || TechprintingSettings.printAllItems))
                        {
                            if (building.GetCompProperties <CompProperties_Shardable>() == null)
                            {
                                building.comps.Add(new CompProperties_Shardable());
                            }

                            thingDic.SetOrAdd(building, rpd);

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

            GearAssigner.HardAssign(ref thingDic, ref researchDic);
            GearAssigner.OverrideAssign(ref thingDic, ref researchDic);
        }
Example #36
0
 public static float GetResearchStat(ResearchProjectDef project) => SRTSMod.GetStatFor <float>(srtsDefProjects.FirstOrDefault(x => x.Value == project).Key.defName, StatName.researchPoints);
Example #37
0
 public static void prefix(ref ResearchProjectDef __state)
 {
     __state = Find.ResearchManager.currentProj;
 }
Example #38
0
 public static NamedArgument GetResearchStatString(ResearchProjectDef project) => SRTSMod.GetStatFor <float>(srtsDefProjects.FirstOrDefault(x => x.Value == project).Key.defName, StatName.researchPoints).ToString("F0");
Example #39
0
 internal static bool _NotFinishedNotLockedOut( ResearchProjectDef project )
 {
     return ( !project.IsFinished )&&( !project.IsLockedOut() );
 }
        static HelpDef HelpForResearch( ResearchProjectDef researchProjectDef, HelpCategoryDef category )
        {
            var helpDef = new HelpDef();
            helpDef.defName = researchProjectDef.defName + "_ResearchProjectDef_Help";
            helpDef.keyDef = researchProjectDef;
            helpDef.label = researchProjectDef.label;
            helpDef.category = category;
            helpDef.description = researchProjectDef.description;

            #region Base Stats

            HelpDetailSection totalCost = new HelpDetailSection(null, new [] { "AutoHelpTotalCost".Translate(researchProjectDef.totalCost.ToString()) });
            helpDef.HelpDetailSections.Add( totalCost );

            #endregion

            #region Research, Buildings, Recipes and SowTags

            // Add research required
            var researchDefs = researchProjectDef.GetResearchRequirements();
            if( !researchDefs.NullOrEmpty() )
            {
                HelpDetailSection researchRequirements = new HelpDetailSection(
                    "AutoHelpListResearchRequired".Translate(),
                    researchDefs.ConvertAll<Def>(def => (Def)def));

                helpDef.HelpDetailSections.Add( researchRequirements );
            }

            // Add research unlocked
            //CCL_Log.Message(researchProjectDef.label, "getting unlocked research");
            researchDefs = researchProjectDef.GetResearchUnlocked();
            if( !researchDefs.NullOrEmpty() )
            {
                HelpDetailSection reseachUnlocked = new HelpDetailSection(
                    "AutoHelpListResearchLeadsTo".Translate(),
                    researchDefs.ConvertAll<Def>(def => (Def)def));

                helpDef.HelpDetailSections.Add( reseachUnlocked );
            }

            // Add buildings it unlocks
            var thingDefs = researchProjectDef.GetThingsUnlocked();
            if( !thingDefs.NullOrEmpty() )
            {
                HelpDetailSection thingsUnlocked = new HelpDetailSection(
                    "AutoHelpListThingsUnlocked".Translate(),
                    thingDefs.ConvertAll<Def>(def => (Def)def));

                helpDef.HelpDetailSections.Add( thingsUnlocked );
            }

            // Add recipes it unlocks
            var recipeDefs = researchProjectDef.GetRecipesUnlocked( ref thingDefs );
            if(
                (!recipeDefs.NullOrEmpty()) &&
                (!thingDefs.NullOrEmpty())
            )
            {
                HelpDetailSection recipesUnlocked = new HelpDetailSection(
                    "AutoHelpListRecipesUnlocked".Translate(),
                    recipeDefs.ConvertAll<Def>(def => (Def)def));

                helpDef.HelpDetailSections.Add( recipesUnlocked );

                HelpDetailSection recipesOnThingsUnlocked = new HelpDetailSection(
                    "AutoHelpListRecipesOnThingsUnlocked".Translate(),
                    thingDefs.ConvertAll<Def>(def => (Def)def));

                helpDef.HelpDetailSections.Add( recipesOnThingsUnlocked );
            }

            // Look in advanced research to add plants and sow tags it unlocks
            var sowTags = researchProjectDef.GetSowTagsUnlocked( ref thingDefs );
            if(
                (!sowTags.NullOrEmpty()) &&
                (!thingDefs.NullOrEmpty())
            )
            {
                HelpDetailSection plantsUnlocked = new HelpDetailSection(
                    "AutoHelpListPlantsUnlocked".Translate(),
                    thingDefs.ConvertAll<Def>( def =>(Def)def ));

                helpDef.HelpDetailSections.Add( plantsUnlocked );

                HelpDetailSection plantsIn = new HelpDetailSection(
                    "AutoHelpListPlantsIn".Translate(),
                    sowTags.ToArray());

                helpDef.HelpDetailSections.Add( plantsIn );
            }

            #endregion

            #region Lockouts

            // Get advanced research which locks
            researchDefs = researchProjectDef.GetResearchedLockedBy();
            if( !researchDefs.NullOrEmpty() )
            {
                HelpDetailSection researchLockout = new HelpDetailSection(
                    "AutoHelpListResearchLockout".Translate(),
                    researchDefs.ConvertAll<Def>( def =>(Def)def ) );

                helpDef.HelpDetailSections.Add( researchLockout );
            }

            #endregion

            return helpDef;
        }