Пример #1
0
        private void DrawHelpCategoryRow(Rect catRect, HelpCategoryDef cat)
        {
            try
            {
                GUI.BeginGroup(catRect);

                if (catRect.Contains(Event.current.mousePosition))
                {
                    Widgets.DrawHighlight(catRect);
                }

                Rect      imageRect = new Rect(Margin * 2, catRect.height / 2f - ArrowImageSize.y / 2f, ArrowImageSize.x, ArrowImageSize.y);
                Texture2D texture   = cat.Expanded ? ArrowUpTex : ArrowDownTex;
                GUI.DrawTexture(imageRect, texture);

                Rect labelRect = new Rect(imageRect.xMax + Margin, 0f, catRect.width - imageRect.width - Margin * 3, catRect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(labelRect, cat.LabelCap);
                Text.Anchor = TextAnchor.UpperLeft;

                GUI.color = Color.gray;
                Widgets.DrawLineHorizontal(0f, 0f, catRect.width);
                GUI.color = Color.white;

                if (Widgets.InvisibleButton(catRect))
                {
                    cat.Expanded = !cat.Expanded;
                }
            }
            finally
            {
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.EndGroup();
            }
        }
Пример #2
0
        void DrawHelpCategory(Rect catRect, HelpCategoryDef cat)
        {
            GUI.BeginGroup(catRect);

            var catRowRect = new Rect(0f, 0f, catRect.width, EntryHeight);

            DrawHelpCategoryRow(catRowRect, cat);

            if (cat.Expanded)
            {
                float curY = EntryHeight;
                foreach (var helpDef in cat.HelpDefs)
                {
                    var helpRect = new Rect(
                        EntryIndent, curY,
                        catRect.width, EntryHeight);

                    DrawHelpRow(helpRect, helpDef);
                    GUI.color = Color.gray;
                    Widgets.DrawLineHorizontal(0f, curY, catRect.width);
                    GUI.color = Color.white;

                    curY += EntryHeight;
                }
            }

            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
        }
Пример #3
0
 public void AddCategory(HelpCategoryDef def)
 {
     if (!helpCategories.Contains(def))
     {
         helpCategories.Add(def);
     }
 }
Пример #4
0
        public void DrawCatEntry(ref Vector2 cur, int nestLevel, Rect view, HelpCategoryDef catDef)
        {
            State curState = catDef.Expanded ? State.Expanded : State.Closed;

            if (DrawEntry(ref cur, nestLevel, view, catDef.LabelCap, curState))
            {
                catDef.Expanded = !catDef.Expanded;
            }
        }
Пример #5
0
        public void JumpTo(HelpDef helpDef)
        {
            Find.MainTabsRoot.SetCurrentTab(this.def);
            ResetFilter();
            _jump           = true;
            SelectedHelpDef = helpDef;
            HelpCategoryDef cat = DefDatabase <HelpCategoryDef> .AllDefsListForReading.First(hc => hc.HelpDefs.Contains(helpDef));

            cat.Expanded = true;
            ModCategory mod = CachedHelpCategories.First(mc => mc.HelpCategories.Contains(cat));

            mod.Expanded = true;
        }
        static HelpCategoryDef HelpCategoryForKey( string key, string label, string modname )
        {
            // Get help category
            var helpCategoryDef = DefDatabase< HelpCategoryDef >.GetNamed( key, false );

            if( helpCategoryDef == null )
            {
                // Create new designation help category
                helpCategoryDef = new HelpCategoryDef();
                helpCategoryDef.defName = key;
                helpCategoryDef.keyDef = key;
                helpCategoryDef.label = label;
                helpCategoryDef.ModName = modname;

                DefDatabase<HelpCategoryDef>.Add( helpCategoryDef );
            }

            return helpCategoryDef;
        }
        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 void AddCategory( HelpCategoryDef def )
 {
     if( !_helpCategories.Contains( def ) )
     {
         _helpCategories.Add( def );
     }
 }
Пример #9
0
 public void AddCategory(HelpCategoryDef def)
 {
     _helpCategories.AddUnique(def);
 }
Пример #10
0
        private void DrawHelpCategoryRow(Rect catRect, HelpCategoryDef cat)
        {
            try
            {
                GUI.BeginGroup(catRect);

                if (catRect.Contains(Event.current.mousePosition))
                    Widgets.DrawHighlight(catRect);

                Rect imageRect = new Rect(Margin * 2, catRect.height / 2f - ArrowImageSize.y / 2f, ArrowImageSize.x, ArrowImageSize.y);
                Texture2D texture = cat.Expanded ? ArrowUpTex : ArrowDownTex;
                GUI.DrawTexture(imageRect, texture);

                Rect labelRect = new Rect(imageRect.xMax + Margin, 0f, catRect.width - imageRect.width - Margin * 3, catRect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(labelRect, cat.LabelCap);
                Text.Anchor = TextAnchor.UpperLeft;

                GUI.color = Color.gray;
                Widgets.DrawLineHorizontal(0f, 0f, catRect.width);
                GUI.color = Color.white;

                if (Widgets.InvisibleButton(catRect))
                {
                    cat.Expanded = !cat.Expanded;
                }
            }
            finally
            {
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.EndGroup();
            }
        }
        static HelpDef HelpForRecipe( ThingDef thingDef, RecipeDef recipeDef, HelpCategoryDef category )
        {
            var helpDef = new HelpDef();
            helpDef.keyDef = recipeDef;
            helpDef.defName = helpDef.keyDef + "_RecipeDef_Help";
            helpDef.label = recipeDef.label;
            helpDef.category = category;
            helpDef.description = recipeDef.description;

            #region Base Stats

            helpDef.HelpDetailSections.Add( new HelpDetailSection( null, new[] { "WorkAmount".Translate() + " : " + recipeDef.WorkAmountTotal( (ThingDef)null ).ToStringWorkAmount() } ) );

            #endregion

            #region Skill Requirements

            if( !recipeDef.skillRequirements.NullOrEmpty() )
            {
                helpDef.HelpDetailSections.Add( new HelpDetailSection(
                    "MinimumSkills".Translate(),
                    recipeDef.skillRequirements.Select( sr => sr.skill ).ToList().ConvertAll( sd => (Def)sd ),
                    null,
                    recipeDef.skillRequirements.Select( sr => sr.minLevel.ToString( "####0" ) ).ToArray() ) );
            }

            #endregion

            #region Ingredients

            // List of ingredients
            if( !recipeDef.ingredients.NullOrEmpty() )
            {
                // TODO: find the actual thingDefs of ingredients so we can use defs instead of strings.
                HelpDetailSection ingredients = new HelpDetailSection(
                    "Ingredients".Translate(),
                    recipeDef.ingredients.Select(ic => recipeDef.IngredientValueGetter.BillRequirementsDescription( ic )).ToArray());

                helpDef.HelpDetailSections.Add( ingredients );
            }

            #endregion

            #region Products

            // List of products
            if( !recipeDef.products.NullOrEmpty() )
            {
                HelpDetailSection products = new HelpDetailSection(
                    "AutoHelpListRecipeProducts".Translate(),
                    recipeDef.products.Select(tc => tc.thingDef).ToList().ConvertAll(def => (Def)def),
                    recipeDef.products.Select(tc => tc.count.ToString()).ToArray());

                helpDef.HelpDetailSections.Add( products );
            }

            #endregion

            #region Things & Research

            // Add things it's on
            var thingDefs = recipeDef.GetThingsCurrent();
            if( !thingDefs.NullOrEmpty() )
            {
                HelpDetailSection billgivers = new HelpDetailSection(
                    "AutoHelpListRecipesOnThings".Translate(),
                    thingDefs.ConvertAll<Def>(def => (Def)def));

                helpDef.HelpDetailSections.Add( billgivers );
            }

            // Add research required
            var researchDefs = recipeDef.GetResearchRequirements();
            if( !researchDefs.NullOrEmpty() )
            {
                HelpDetailSection requiredResearch = new HelpDetailSection(
                    "AutoHelpListResearchRequired".Translate(),
                    researchDefs);

                helpDef.HelpDetailSections.Add( requiredResearch );
            }

            // What things is it on after research
            thingDefs = recipeDef.GetThingsUnlocked( ref researchDefs );
            if( !thingDefs.NullOrEmpty() )
            {
                HelpDetailSection recipesOnThingsUnlocked = new HelpDetailSection(
                    "AutoHelpListRecipesOnThingsUnlocked".Translate(),
                    thingDefs.ConvertAll<Def>(def => (Def)def));

                helpDef.HelpDetailSections.Add( recipesOnThingsUnlocked );

                if( !researchDefs.NullOrEmpty() )
                {
                    HelpDetailSection researchBy = new HelpDetailSection(
                        "AutoHelpListResearchBy".Translate(),
                        researchDefs.ConvertAll<Def>(def => (Def)def));

                    helpDef.HelpDetailSections.Add( researchBy );
                }
            }

            // Get research which locks recipe
            thingDefs = recipeDef.GetThingsLocked( ref researchDefs );
            if( !thingDefs.NullOrEmpty() )
            {
                HelpDetailSection recipesOnThingsLocked = new HelpDetailSection(
                    "AutoHelpListRecipesOnThingsLocked".Translate(),
                    thingDefs.ConvertAll<Def>(def => (Def)def));

                helpDef.HelpDetailSections.Add( recipesOnThingsLocked );

                if( !researchDefs.NullOrEmpty() )
                {
                    HelpDetailSection researchBy = new HelpDetailSection(
                        "AutoHelpListResearchBy".Translate(),
                        researchDefs.ConvertAll<Def>(def => (Def)def));

                    helpDef.HelpDetailSections.Add( researchBy );
                }
            }

            #endregion

            return helpDef;
        }
 public void DrawCatEntry( ref Vector2 cur, int nestLevel, Rect view, HelpCategoryDef catDef )
 {
     State curState = catDef.Expanded ? State.Expanded : State.Closed;
     if( DrawEntry( ref cur, nestLevel, view, catDef.LabelCap, curState ) )
     {
         catDef.Expanded = !catDef.Expanded;
     }
 }
        static HelpDef HelpForRecipe( ThingDef thingDef, RecipeDef recipeDef, HelpCategoryDef category )
        {
            var helpDef = new HelpDef();
            helpDef.keyDef = thingDef.defName +"_" + recipeDef.defName;
            helpDef.defName = helpDef.keyDef + "_RecipeDef_Help";
            helpDef.label = recipeDef.label;
            helpDef.category = category;

            var s = new StringBuilder();

            s.AppendLine( recipeDef.description );
            s.AppendLine();

            #region Base Stats

            s.AppendLine( "WorkAmount".Translate() + " : " + GenText.ToStringWorkAmount( recipeDef.WorkAmountTotal( (ThingDef) null ) ) );
            s.AppendLine();

            #endregion

            #region Skill Requirements

            if( ( recipeDef.skillRequirements != null )&&
                ( recipeDef.skillRequirements.Count > 0 ) )
            {
                s.AppendLine( "MinimumSkills".Translate() );
                foreach( var sr in recipeDef.skillRequirements )
                {
                    s.Append( "\t" );
                    s.AppendLine( "BillRequires".Translate( new object[] {
                        sr.minLevel.ToString( "####0" ),
                        sr.skill.label.ToLower()
                    } ) );
                }
                s.AppendLine();
            }

            #endregion

            #region Ingredients

            // List of ingredients
            if( ( recipeDef.ingredients != null )&&
                ( recipeDef.ingredients.Count > 0 ) )
            {
                s.Append( "Ingredients".Translate() );
                s.AppendLine( ":" );
                foreach( var ing in recipeDef.ingredients )
                {
                    if( !GenText.NullOrEmpty( ing.filter.Summary ) )
                    {
                        s.Append( "\t" );
                        s.AppendLine( recipeDef.IngredientValueGetter.BillRequirementsDescription( ing ) );
                    }
                }
                s.AppendLine();
            }

            #endregion

            #region Products

            // List of products
            if( ( recipeDef.products != null )&&
                ( recipeDef.products.Count > 0 ) )
            {
                s.AppendLine( "AutoHelpListRecipeProducts".Translate() );
                foreach( var ing in recipeDef.products )
                {
                    s.Append( "\t" );
                    s.Append( ing.thingDef.LabelCap );
                    s.Append( " : " );
                    s.AppendLine( ing.count.ToString() );
                }
                s.AppendLine();
            }

            #endregion

            #region Things & Research

            // Add things it's on
            var thingDefs = recipeDef.GetThingsCurrent();
            BuildDefDescription( s, "AutoHelpListRecipesOnThings".Translate(), thingDefs.ConvertAll<Def>( def => (Def)def ) );

            // Add research required
            var researchDefs = recipeDef.GetResearchRequirements();
            BuildDefDescription( s, "AutoHelpListResearchRequired".Translate(), researchDefs );

            // What things is it on after research
            thingDefs = recipeDef.GetThingsUnlocked( ref researchDefs );
            BuildDefWithDefDescription( s, "AutoHelpListRecipesOnThingsUnlocked".Translate(), "AutoHelpListResearchBy".Translate(), thingDefs.ConvertAll<Def>( def => (Def)def ), researchDefs.ConvertAll<Def>( def => (Def)def ) );

            // Get research which locks recipe
            thingDefs = recipeDef.GetThingsLocked( ref researchDefs );
            BuildDefWithDefDescription( s, "AutoHelpListRecipesOnThingsLocked".Translate(), "AutoHelpListResearchBy".Translate(), thingDefs.ConvertAll<Def>( def => (Def)def ), researchDefs.ConvertAll<Def>( def => (Def)def ) );

            #endregion

            helpDef.description = s.ToString();
            return helpDef;
        }
        static HelpDef HelpForBuildable( BuildableDef buildableDef, HelpCategoryDef category )
        {
            var helpDef = new HelpDef();
            helpDef.defName = buildableDef.defName + "_BuildableDef_Help";
            helpDef.keyDef = buildableDef.defName;
            helpDef.label = buildableDef.label;
            helpDef.category = category;

            var s = new StringBuilder();

            s.AppendLine( buildableDef.description );
            s.AppendLine();

            #region Base Stats

            // Look at base stats
            foreach( var stat in buildableDef.statBases )
            {
                s.Append( stat.stat.LabelCap );
                s.Append( " : " );
                s.AppendLine( stat.stat.ValueToString( stat.value, stat.stat.toStringNumberSense ) );
            }
            s.AppendLine();

            #endregion

            #region ThingDef Specific

            var thingDef = buildableDef as ThingDef;
            if( thingDef != null )
            {

                #region Ingestible Stats

                // Look at base stats
                if( thingDef.IsNutritionSource )
                {
                    if( thingDef.ingestible.nutrition > 0.0001f )
                    {
                        s.Append( "Nutrition".Translate() );
                        s.Append( " : " );
                        s.AppendLine( thingDef.ingestible.nutrition.ToString( "0.###" ) );
                    }
                    if( thingDef.ingestible.joy > 0.0001f )
                    {
                        s.Append( "Joy".Translate() );
                        s.Append( " : " );
                        s.AppendLine( thingDef.ingestible.joy.ToString( "0.###" ) );
                    }
                    s.AppendLine();
                }

                #endregion

                #region Body Part Stats

                if( ( !thingDef.thingCategories.NullOrEmpty() )&&
                    ( thingDef.thingCategories.Contains( ThingCategoryDefOf.BodyPartsAndImplants ) )&&
                    ( thingDef.IsImplant() ) )
                {
                    var hediffDef = thingDef.GetImplantHediffDef();

                    #region Efficiency

                    if( hediffDef.addedPartProps != null )
                    {
                        s.Append( "BodyPartEfficiency".Translate() );
                        s.Append( " : " );
                        s.AppendLine( hediffDef.addedPartProps.partEfficiency.ToString( "P0" ) );
                        s.AppendLine();
                    }

                    #endregion

                    #region Capacities

                    if( ( !hediffDef.stages.NullOrEmpty() )&&
                        ( hediffDef.stages.Exists( stage => (
                            ( !stage.capMods.NullOrEmpty() )
                        ) ) )
                    )
                    {
                        foreach( var hediffStage in hediffDef.stages )
                        {
                            if( !hediffStage.capMods.NullOrEmpty() )
                            {
                                foreach( var c in hediffStage.capMods )
                                {
                                    s.Append( c.capacity.LabelCap );
                                    if( c.offset > 0 )
                                    {
                                        s.Append( " : +" );
                                    }
                                    else
                                    {
                                        s.Append( " : " );
                                    }
                                    s.AppendLine( c.offset.ToString( "P0" ) );
                                }
                            }
                        }
                        s.AppendLine();
                    }

                    #endregion

                    #region Components (Melee attack)

                    if( ( !hediffDef.comps.NullOrEmpty() )&&
                        ( hediffDef.comps.Exists( p => (
                            ( p.compClass == typeof( HediffComp_VerbGiver ) )
                        ) ) )
                    )
                    {
                        foreach( var comp in hediffDef.comps )
                        {
                            if( comp.compClass == typeof( HediffComp_VerbGiver ) )
                            {
                                if( !comp.verbs.NullOrEmpty() )
                                {
                                    foreach( var verb in comp.verbs )
                                    {
                                        if( verb.verbClass == typeof( Verb_MeleeAttack ) )
                                        {
                                            s.AppendLine( "MeleeAttack".Translate( verb.meleeDamageDef.label ) );
                                            s.Append( "\t" );
                                            s.Append( "MeleeWarmupTime".Translate() );
                                            s.Append( " : " );
                                            s.AppendLine( verb.defaultCooldownTicks.ToString() );
                                            s.Append( "\t" );
                                            s.Append( "StatsReport_MeleeDamage".Translate() );
                                            s.Append( " : " );
                                            s.AppendLine( verb.meleeDamageBaseAmount.ToString() );
                                            s.AppendLine();
                                        }
                                    }
                                }
                            }
                        }
                    }

                    #endregion

                    #region Body part fixed or replaced

                    var recipeDef = thingDef.GetImplantRecipeDef();
                    if( !recipeDef.appliedOnFixedBodyParts.NullOrEmpty() )
                    {
                        s.Append( "AutoHelpSurgeryFixOrReplace".Translate() );
                        s.AppendLine( ":" );
                        foreach( var b in recipeDef.appliedOnFixedBodyParts )
                        {
                            s.Append( "\t" );
                            s.AppendLine( b.LabelCap );
                        }
                        s.AppendLine();
                    }

                    #endregion

                }

                #endregion

                #region Stuff Cost

                // What stuff can it be made from?
                if( thingDef.costStuffCount > 0 )
                {
                    s.AppendLine( "AutoHelpStuffCost".Translate( thingDef.costStuffCount.ToString() ) );
                    BuildDefDescription( s, "AutoHelpListStuffCategories".Translate(), thingDef.stuffCategories.ConvertAll<Def>( def => (Def)def ) );
                }

                #endregion

                #region Cost List

                // What other things are required?
                if( ( thingDef.costList != null )&&
                    ( thingDef.costList.Count > 0 ) )
                {
                    s.Append( "AutoHelpThingCost".Translate() );
                    s.AppendLine( ":" );
                    foreach( var tc in thingDef.costList )
                    {
                        s.Append( "\t" );
                        s.Append( tc.thingDef.LabelCap );
                        s.Append( " : " );
                        s.AppendLine( tc.count.ToString() );
                    }
                    s.AppendLine();
                }

                #endregion

                #region Recipes & Research

                // Get list of recipes
                var recipeDefs = thingDef.AllRecipes;
                BuildDefDescription( s, "AutoHelpListRecipes".Translate(), recipeDefs.ConvertAll<Def>( def => (Def)def ) );

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

                // Build help for unlocked recipes associated with building
                recipeDefs = thingDef.GetRecipesUnlocked( ref researchDefs );
                BuildDefWithDefDescription( s, "AutoHelpListRecipesUnlocked".Translate(), "AutoHelpListResearchBy".Translate(), recipeDefs.ConvertAll<Def>( def => (Def)def ), researchDefs.ConvertAll<Def>( def => (Def)def ) );

                // Build help for locked recipes associated with building
                recipeDefs = thingDef.GetRecipesLocked( ref researchDefs );
                BuildDefWithDefDescription( s, "AutoHelpListRecipesLocked".Translate(), "AutoHelpListResearchBy".Translate(), recipeDefs.ConvertAll<Def>( def => (Def)def ), researchDefs.ConvertAll<Def>( def => (Def)def ) );

                #endregion

                #region Facilities

                // Get list of facilities that effect it
                var affectedBy = thingDef.GetCompProperties( typeof( CompAffectedByFacilities ) );
                if( ( affectedBy != null )&&
                    ( affectedBy.linkableFacilities != null )&&
                    ( affectedBy.linkableFacilities.Count > 0 ) )
                {
                    BuildDefDescription( s, "AutoHelpListFacilitiesAffecting".Translate(), affectedBy.linkableFacilities.ConvertAll<Def>( def => (Def)def ) );
                }

                // Get list of buildings effected by it
                if( thingDef.HasComp( typeof( CompFacility ) ) )
                {
                    var effectsBuildings = DefDatabase< ThingDef >.AllDefsListForReading
                        .Where( f => (
                            ( f.HasComp( typeof( CompAffectedByFacilities ) ) )&&
                            ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ) != null )&&
                            ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ).linkableFacilities != null )&&
                            ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ).linkableFacilities.Contains( thingDef ) )
                        ) ).ToList();
                    if( ( effectsBuildings != null )&&
                        ( effectsBuildings.Count > 0 ) )
                    {
                        var facilityProperties = thingDef.GetCompProperties( typeof( CompFacility ) );
                        s.AppendLine( "AutoHelpMaximumAffected".Translate( facilityProperties.maxSimultaneous.ToString() ) );
                        // Look at stats modifiers
                        foreach( var stat in facilityProperties.statOffsets )
                        {
                            s.Append( stat.stat.LabelCap );
                            s.Append( " : " );
                            s.AppendLine( stat.stat.ValueToString( stat.value, stat.stat.toStringNumberSense ) );
                        }
                        s.AppendLine();
                        BuildDefDescription( s, "AutoHelpListFacilitiesAffected".Translate(), effectsBuildings.ConvertAll<Def>( def => (Def)def ) );
                    }
                }

                #endregion

                #region Joy

                // Get valid joy givers
                var joyGiverDefs = DefDatabase< JoyGiverDef >.AllDefsListForReading
                    .Where( j => (
                        ( j.thingDef == thingDef )&&
                        ( j.jobDef != null )
                    ) ).ToList();

                if( !joyGiverDefs.NullOrEmpty() )
                {
                    s.AppendLine( "AutoHelpListJoyActivities".Translate() );
                    foreach( var joyGiverDef in joyGiverDefs )
                    {
                        // Get job driver stats
                        s.Append( "\t" );
                        s.AppendLine( joyGiverDef.jobDef.reportString );
                        s.Append( "\t" );
                        s.AppendLine( "AutoHelpMaximumParticipants".Translate( joyGiverDef.jobDef.joyMaxParticipants.ToString() ) );
                        s.Append( "\t" );
                        s.AppendLine( "AutoHelpJoyKind".Translate( joyGiverDef.jobDef.joyKind.LabelCap ) );
                        if( joyGiverDef.jobDef.joySkill != null )
                        {
                            s.Append( "\t" );
                            s.AppendLine( "AutoHelpJoySkill".Translate( joyGiverDef.jobDef.joySkill.LabelCap ) );
                        }
                    }
                    s.AppendLine();
                }

                #endregion

            }

            #endregion

            helpDef.description = s.ToString();
            return helpDef;
        }
        static HelpDef HelpForAdvancedResearch( AdvancedResearchDef advancedResearchDef, HelpCategoryDef category )
        {
            var helpDef = new HelpDef();
            helpDef.defName = advancedResearchDef.defName + "_AdvancedResearchDef_Help";
            helpDef.keyDef = advancedResearchDef.defName;
            helpDef.label = advancedResearchDef.label;
            if( advancedResearchDef.helpCategoryDef == null )
            {
                advancedResearchDef.helpCategoryDef = category;
            }
            if( advancedResearchDef.IsHelpEnabled )
            {
                helpDef.category = advancedResearchDef.helpCategoryDef;
            }

            var s = new StringBuilder();

            s.AppendLine( advancedResearchDef.description );
            s.AppendLine();

            #region Base Stats

            s.AppendLine( "AutoHelpTotalCost".Translate( advancedResearchDef.TotalCost.ToString() ) );
            s.AppendLine();

            #endregion

            #region Research, Buildings, Recipes and SowTags

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

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

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

            // Add plants and sow tags it unlocks
            var sowTags = advancedResearchDef.GetSowTagsUnlocked( ref thingDefs );
            BuildDefWithStringDescription( s, "AutoHelpListPlantsUnlocked".Translate(), "AutoHelpListPlantsIn".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ), sowTags );

            #endregion

            #region Lockouts

            // Add buildings it locks
            thingDefs = advancedResearchDef.GetThingsLocked();
            BuildDefDescription( s, "AutoHelpListThingsLocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) );

            // Add recipes it locks
            recipeDefs = advancedResearchDef.GetRecipesLocked( ref thingDefs );
            BuildDefWithDefDescription( s, "Prevents recipes:", "AutoHelpListRecipesOnThings".Translate(), recipeDefs.ConvertAll<Def>( def =>(Def)def ), thingDefs.ConvertAll<Def>( def =>(Def)def ) );

            // Add plants and sow tags it locks
            sowTags = advancedResearchDef.GetSowTagsLocked( ref thingDefs );
            BuildDefWithStringDescription( s, "AutoHelpListPlantsLocked".Translate(), "AutoHelpListPlantsIn".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ), sowTags );

            #endregion

            helpDef.description = s.ToString();
            advancedResearchDef.HelpDef = helpDef;
            return helpDef;
        }
        static HelpDef HelpForAdvancedResearch( AdvancedResearchDef advancedResearchDef, HelpCategoryDef category )
        {
            var helpDef = new HelpDef();
            helpDef.defName = advancedResearchDef.defName + "_AdvancedResearchDef_Help";
            helpDef.keyDef = advancedResearchDef;
            helpDef.label = advancedResearchDef.label;
            helpDef.description = advancedResearchDef.description;

            if( advancedResearchDef.helpCategoryDef == null )
            {
                advancedResearchDef.helpCategoryDef = category;
            }
            if( advancedResearchDef.IsHelpEnabled )
            {
                helpDef.category = advancedResearchDef.helpCategoryDef;
            }

            #region Base Stats

            HelpDetailSection totalCost = new HelpDetailSection(
                null,
                new [] {"AutoHelpTotalCost".Translate( advancedResearchDef.TotalCost.ToString() )});

            helpDef.HelpDetailSections.Add( totalCost );

            #endregion

            #region Research, Buildings, Recipes and SowTags

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

                helpDef.HelpDetailSections.Add( researchRequired );
            }

            // Add buildings it unlocks
            var thingDefs = advancedResearchDef.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 = advancedResearchDef.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(
                    "AutoHelpListRecipesOnThings".Translate(),
                    thingDefs.ConvertAll<Def>(def => (Def)def));

                helpDef.HelpDetailSections.Add( recipesOnThingsUnlocked );
            }

            // Add plants and sow tags it unlocks
            var sowTags = advancedResearchDef.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 recipesOnThingsUnlocked = new HelpDetailSection(
                    "AutoHelpListPlantsIn".Translate(),
                    sowTags.ToArray() );

                helpDef.HelpDetailSections.Add( recipesOnThingsUnlocked );
            }

            #endregion

            #region Lockouts

            // Add buildings it locks
            thingDefs = advancedResearchDef.GetThingsLocked();
            if( !thingDefs.NullOrEmpty() )
            {
                HelpDetailSection thingsLocked = new HelpDetailSection(
                    "AutoHelpListThingsLocked".Translate(),
                    thingDefs.ConvertAll<Def>( def =>(Def)def ) );

                helpDef.HelpDetailSections.Add( thingsLocked );
            }

            // Add recipes it locks
            recipeDefs = advancedResearchDef.GetRecipesLocked( ref thingDefs );
            if(
                (!recipeDefs.NullOrEmpty()) &&
                (!thingDefs.NullOrEmpty())
            )
            {
                HelpDetailSection recipesLocked = new HelpDetailSection(
                    "AutoHelpListRecipesLocked".Translate(), recipeDefs.ConvertAll<Def>( def =>(Def)def ) );

                helpDef.HelpDetailSections.Add( recipesLocked );

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

                helpDef.HelpDetailSections.Add( recipesOnThings );
            }

            // Add plants and sow tags it locks
            sowTags = advancedResearchDef.GetSowTagsLocked( ref thingDefs );
            if(
                (!sowTags.NullOrEmpty()) &&
                (!thingDefs.NullOrEmpty())
            )
            {
                HelpDetailSection plantsLocked = new HelpDetailSection(
                    "AutoHelpListPlantsLocked".Translate(),
                    thingDefs.ConvertAll<Def>( def =>(Def)def ) );

                helpDef.HelpDetailSections.Add( plantsLocked );

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

                helpDef.HelpDetailSections.Add( plantsIn );
            }

            #endregion

            advancedResearchDef.HelpDef = helpDef;
            return helpDef;
        }
        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;
        }
        static void ResolveThingDefList( List< ThingDef > thingDefs, HelpCategoryDef category )
        {
            // Get help database
            var helpDefs = DefDatabase< HelpDef >.AllDefsListForReading;

            // Scan through defs and auto-generate help
            foreach( var thingDef in thingDefs )
            {
                // Find an existing entry
                var helpDef = helpDefs.Find( h => (
                    ( h.keyDef == thingDef.defName )
                ) );

                if( helpDef == null )
                {
                    // Make a new one
                    helpDef = HelpForBuildable( thingDef, category );

                    // Inject the def
                    if( helpDef != null )
                    {
                        DefDatabase< HelpDef >.Add( helpDef );
                    }
                }

            }
        }
Пример #19
0
        private void DrawHelpCategory(Rect catRect, HelpCategoryDef cat)
        {
            try
            {
                GUI.BeginGroup(catRect);

                Rect catRowRect = new Rect(0f, 0f, catRect.width, EntryHeight);
                DrawHelpCategoryRow(catRowRect, cat);

                if (cat.Expanded)
                {
                    float curY = EntryHeight;
                    foreach (var helpDef in cat.HelpDefs)
                    {
                        Rect helpRect = new Rect(EntryIndent, curY, catRect.width, EntryHeight);
                        DrawHelpRow(helpRect, helpDef);
                        GUI.color = Color.gray;
                        Widgets.DrawLineHorizontal(0f, curY, catRect.width);
                        GUI.color = Color.white;
                        curY += EntryHeight;
                    }
                }
            }
            finally
            {
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.EndGroup();
            }
        }
 public void AddCategory( HelpCategoryDef def )
 {
     _helpCategories.AddUnique( def );
 }
        static HelpDef HelpForBuildable( BuildableDef buildableDef, HelpCategoryDef category )
        {
            var helpDef = new HelpDef();
            helpDef.defName = buildableDef.defName + "_BuildableDef_Help";
            helpDef.keyDef = buildableDef;
            helpDef.label = buildableDef.label;
            helpDef.category = category;
            helpDef.description = buildableDef.description;

            #region Base Stats

            // Look at base stats
            HelpDetailSection baseStats = new HelpDetailSection(
                null,
                buildableDef.statBases.Select(sb => sb.stat).ToList().ConvertAll(def => (Def)def),
                null,
                buildableDef.statBases.Select(sb => sb.stat.ValueToString(sb.value, sb.stat.toStringNumberSense)).ToArray());

            helpDef.HelpDetailSections.Add( baseStats );

            #endregion

            #region ThingDef Specific

            var thingDef = buildableDef as ThingDef;
            if( thingDef != null )
            {

                #region Ingestible Stats
                // Look at base stats
                if( thingDef.IsNutritionSource )
                {
                    string[] ingestibleStats =
                    {
                        "Nutrition".Translate() + ": " + thingDef.ingestible.nutrition.ToString( "0.###" ),
                        "Joy".Translate() + ": " + thingDef.ingestible.joy.ToString( "0.###" )
                    };

                    helpDef.HelpDetailSections.Add( new HelpDetailSection( null, ingestibleStats ) );
                }

                #endregion

                #region Body Part Stats

                if( (!thingDef.thingCategories.NullOrEmpty()) &&
                    (thingDef.thingCategories.Contains( ThingCategoryDefOf.BodyPartsAndImplants )) &&
                    (thingDef.IsImplant()) )
                {
                    var hediffDef = thingDef.GetImplantHediffDef();

                    #region Efficiency

                    if( hediffDef.addedPartProps != null )
                    {
                        helpDef.HelpDetailSections.Add( new HelpDetailSection( "BodyPartEfficiency".Translate(), new[] { hediffDef.addedPartProps.partEfficiency.ToString( "P0" ) } ) );
                    }

                    #endregion

                    #region Capacities
                    if( (!hediffDef.stages.NullOrEmpty()) &&
                        (hediffDef.stages.Exists( stage => (
                           (!stage.capMods.NullOrEmpty())
                       ) ))
                    )
                    {
                        HelpDetailSection capacityMods = new HelpDetailSection(
                            "CapacityModifiers".Translate(),
                            hediffDef.stages.Where(s => !s.capMods.NullOrEmpty())
                                            .SelectMany(s => s.capMods)
                                            .Select(cm => cm.capacity)
                                            .ToList()
                                            .ConvertAll(def => (Def)def),
                            null,
                            hediffDef.stages
                                     .Where(s => !s.capMods.NullOrEmpty())
                                     .SelectMany(s => s.capMods)
                                     .Select(
                                        cm => (cm.offset > 0 ? ": +" : ": ") + cm.offset.ToString("P0"))
                                     .ToArray());

                        helpDef.HelpDetailSections.Add( capacityMods );
                    }

                    #endregion

                    #region Components (Melee attack)

                    if( (!hediffDef.comps.NullOrEmpty()) &&
                        (hediffDef.comps.Exists( p => (
                           (p.compClass == typeof( HediffComp_VerbGiver ))
                       ) ))
                    )
                    {
                        foreach( var comp in hediffDef.comps )
                        {
                            if( comp.compClass == typeof( HediffComp_VerbGiver ) )
                            {
                                if( !comp.verbs.NullOrEmpty() )
                                {
                                    foreach( var verb in comp.verbs )
                                    {
                                        if( verb.verbClass == typeof( Verb_MeleeAttack ) )
                                        {
                                            helpDef.HelpDetailSections.Add( new HelpDetailSection(
                                                    "MeleeAttack".Translate( verb.meleeDamageDef.label ),
                                                    new[]
                                                    {
                                                        "MeleeWarmupTime".Translate() + verb.defaultCooldownTicks,
                                                        "StatsReport_MeleeDamage".Translate() + verb.meleeDamageBaseAmount
                                                    }
                                                ) );
                                        }
                                    }
                                }
                            }
                        }
                    }

                    #endregion

                    #region Body part fixed or replaced
                    var recipeDef = thingDef.GetImplantRecipeDef();
                    if( !recipeDef.appliedOnFixedBodyParts.NullOrEmpty() )
                    {
                        helpDef.HelpDetailSections.Add( new HelpDetailSection(
                            "AutoHelpSurgeryFixOrReplace".Translate(),
                            recipeDef.appliedOnFixedBodyParts.ToList().ConvertAll( def => (Def)def ) ) );
                    }

                    #endregion

                }

                #endregion

                #region Cost List

                // What other things are required?
                if( !thingDef.costList.NullOrEmpty() )
                {
                    HelpDetailSection costs = new HelpDetailSection(
                        "AutoHelpCost".Translate(),
                        thingDef.costList.Select(tc => tc.thingDef).ToList().ConvertAll(def => (Def)def),
                        null,
                        thingDef.costList.Select(tc => ": " + tc.count.ToString()).ToArray());

                    helpDef.HelpDetailSections.Add( costs );
                }

                #endregion

                #region Stuff Cost

                // What stuff can it be made from?
                if(
                    (thingDef.costStuffCount > 0) &&
                    (!thingDef.stuffCategories.NullOrEmpty())
                )
                {
                    helpDef.HelpDetailSections.Add( new HelpDetailSection(
                        "AutoHelpStuffCost".Translate( thingDef.costStuffCount.ToString() ),
                        thingDef.stuffCategories.ToList().ConvertAll( def => (Def)def ) ) );
                }

                #endregion

                #region Recipes & Research

                // Get list of recipes
                var recipeDefs = thingDef.AllRecipes;
                if( !recipeDefs.NullOrEmpty() )
                {
                    HelpDetailSection recipes = new HelpDetailSection(
                        "AutoHelpListRecipes".Translate(),
                        recipeDefs.ConvertAll(def => (Def)def));
                    helpDef.HelpDetailSections.Add( recipes );
                }

                // Add list of required research
                var researchDefs = buildableDef.GetResearchRequirements();
                if( !researchDefs.NullOrEmpty() )
                {
                    HelpDetailSection reqResearch = new HelpDetailSection(
                        "AutoHelpListResearchRequired".Translate(),
                        researchDefs.ConvertAll(def => (Def)def));
                    helpDef.HelpDetailSections.Add( reqResearch );
                }

                // Build help for unlocked recipes associated with building
                recipeDefs = thingDef.GetRecipesUnlocked( ref researchDefs );
                if(
                    (!recipeDefs.NullOrEmpty()) &&
                    (!researchDefs.NullOrEmpty())
                )
                {
                    HelpDetailSection unlockRecipes = new HelpDetailSection(
                        "AutoHelpListRecipesUnlocked".Translate(),
                        recipeDefs.ConvertAll<Def>(def => (Def)def));
                    HelpDetailSection researchBy = new HelpDetailSection(
                        "AutoHelpListResearchBy".Translate(),
                        researchDefs.ConvertAll<Def>(def => (Def)def));
                    helpDef.HelpDetailSections.Add( unlockRecipes );
                    helpDef.HelpDetailSections.Add( researchBy );
                }

                // Build help for locked recipes associated with building
                recipeDefs = thingDef.GetRecipesLocked( ref researchDefs );
                if(
                    (!recipeDefs.NullOrEmpty()) &&
                    (!researchDefs.NullOrEmpty())
                )
                {
                    HelpDetailSection unlockRecipes = new HelpDetailSection(
                        "AutoHelpListRecipesLocked".Translate(),
                        recipeDefs.ConvertAll<Def>(def => (Def)def));
                    HelpDetailSection researchBy = new HelpDetailSection(
                        "AutoHelpListResearchBy".Translate(),
                        researchDefs.ConvertAll<Def>(def => (Def)def));
                    helpDef.HelpDetailSections.Add( unlockRecipes );
                    helpDef.HelpDetailSections.Add( researchBy );
                }

                #endregion

                #region Facilities

                // Get list of facilities that effect it
                var affectedBy = thingDef.GetCompProperties( typeof( CompAffectedByFacilities ) );
                if( (affectedBy != null) &&
                    (!affectedBy.linkableFacilities.NullOrEmpty()) )
                {
                    HelpDetailSection facilitiesAffecting = new HelpDetailSection(
                        "AutoHelpListFacilitiesAffecting".Translate(),
                        affectedBy.linkableFacilities.ConvertAll<Def>(def => (Def)def));
                }

                // Get list of buildings effected by it
                if( thingDef.HasComp( typeof( CompFacility ) ) )
                {
                    var effectsBuildings = DefDatabase< ThingDef >.AllDefsListForReading
                        .Where( f => (
                            ( f.HasComp( typeof( CompAffectedByFacilities ) ) )&&
                            ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ) != null )&&
                            ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ).linkableFacilities != null )&&
                            ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ).linkableFacilities.Contains( thingDef ) )
                        ) ).ToList();
                    if( !effectsBuildings.NullOrEmpty() )
                    {
                        var facilityProperties = thingDef.GetCompProperties( typeof( CompFacility ) );

                        List<string> facilityStats = new List<string>();
                        facilityStats.Add(
                            "AutoHelpMaximumAffected".Translate( facilityProperties.maxSimultaneous.ToString() ) );

                        // Look at stats modifiers
                        foreach( var stat in facilityProperties.statOffsets )
                        {
                            facilityStats.Add( stat.stat.LabelCap + ": " + stat.stat.ValueToString( stat.value, stat.stat.toStringNumberSense ) );
                        }

                        HelpDetailSection facilityDetailSection = new HelpDetailSection(
                            "AutoHelpFacilityStats".Translate(),
                            facilityStats.ToArray());

                        HelpDetailSection facilitiesAffected = new HelpDetailSection(
                            "AutoHelpListFacilitiesAffected".Translate(),
                            effectsBuildings.ConvertAll<Def>(def => (Def)def));

                        helpDef.HelpDetailSections.Add( facilityDetailSection );
                        helpDef.HelpDetailSections.Add( facilitiesAffected );
                    }
                }

                #endregion

                #region Joy

                // Get valid joy givers
                var joyGiverDefs = DefDatabase< JoyGiverDef >.AllDefsListForReading
                    .Where( j => (
                        ( j.thingDef == thingDef )&&
                        ( j.jobDef != null )
                    ) ).ToList();

                if( !joyGiverDefs.NullOrEmpty() )
                {
                    List<string> joyStats = new List<string>();
                    foreach( var joyGiverDef in joyGiverDefs )
                    {
                        // Get job driver stats
                        joyStats.Add( joyGiverDef.jobDef.reportString );
                        joyStats.Add( "AutoHelpMaximumParticipants".Translate( joyGiverDef.jobDef.joyMaxParticipants.ToString() ) );
                        joyStats.Add( "AutoHelpJoyKind".Translate( joyGiverDef.jobDef.joyKind.LabelCap ) );
                        if( joyGiverDef.jobDef.joySkill != null )
                        {
                            joyStats.Add( "AutoHelpJoySkill".Translate( joyGiverDef.jobDef.joySkill.LabelCap ) );
                        }
                    }

                    HelpDetailSection joyDetailSection = new HelpDetailSection(
                        "AutoHelpListJoyActivities".Translate(),
                        joyStats.ToArray());

                    helpDef.HelpDetailSections.Add( joyDetailSection );
                }

                #endregion

            }

            #endregion

            return helpDef;
        }