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 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;
        }