Skip to content

Commit

Permalink
Updated forum post for new version, rebuilt DLLs after merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenShell committed Apr 27, 2016
2 parents 79e137c + 58ade25 commit af5d0cc
Show file tree
Hide file tree
Showing 20 changed files with 274 additions and 2,984 deletions.
521 changes: 256 additions & 265 deletions DLL_Project/CommunityCoreLibrary.csproj

Large diffs are not rendered by default.

43 changes: 17 additions & 26 deletions DLL_Project/Extensions/ResearchProjectDef_Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
using CommunityCoreLibrary.ResearchTree;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Verse;

namespace CommunityCoreLibrary
{

[StaticConstructorOnStartup]
public static class ResearchProjectDef_Extensions
{

#region Static Data

private static Dictionary<ushort, bool> isLockedOut;
Expand All @@ -21,10 +18,9 @@ static ResearchProjectDef_Extensions()
{
isLockedOut = new Dictionary<ushort, bool>();
_unlocksCache = new Dictionary<ushort, List<Pair<Def, string>>>();

}

#endregion
#endregion Static Data

#region Availability

Expand All @@ -42,7 +38,7 @@ public static bool IsLockedOut( this ResearchProjectDef researchProjectDef )
internal static bool _IsLockedOut( this ResearchProjectDef researchProjectDef, ResearchProjectDef initialDef )
{
bool rVal = false;
if( !isLockedOut.TryGetValue( researchProjectDef.shortHash, out rVal ) )
if ( !isLockedOut.TryGetValue( researchProjectDef.shortHash, out rVal ) )
{
#if DEBUG
CCL_Log.TraceMod(
Expand Down Expand Up @@ -107,7 +103,7 @@ public static bool HasResearchRequirement( this ResearchProjectDef researchProje
) );
}

#endregion
#endregion Availability

#region Lists of affected data

Expand Down Expand Up @@ -199,11 +195,6 @@ public static List<Pair<Def, string>> GetUnlockDefsAndDescs( this ResearchProjec
return unlocks;
}

public static Node Node( this ResearchProjectDef research )
{
return ResearchTree.ResearchTree.Forest.FirstOrDefault( node => node.Research == research );
}

public static List<Def> GetResearchRequirements( this ResearchProjectDef researchProjectDef )
{
#if DEBUG
Expand Down Expand Up @@ -314,8 +305,8 @@ public static List<ThingDef> GetThingsUnlocked( this ResearchProjectDef research
var thingsOn = new List<ThingDef>();
var researchThings = DefDatabase<ThingDef>.AllDefsListForReading.Where( t => (
( !t.IsLockedOut() )&&
(t.GetResearchRequirements() != null) &&
(t.GetResearchRequirements().Contains(researchProjectDef))
( t.GetResearchRequirements() != null ) &&
( t.GetResearchRequirements().Contains( researchProjectDef ) )
) ).ToList();

if ( !researchThings.NullOrEmpty() )
Expand Down Expand Up @@ -357,7 +348,7 @@ public static List<TerrainDef> GetTerrainUnlocked( this ResearchProjectDef resea
var researchThings = DefDatabase<TerrainDef>.AllDefsListForReading.Where( t => (
( !t.IsLockedOut() )&&
( t.GetResearchRequirements() != null )&&
( t.GetResearchRequirements().Contains(researchProjectDef))
( t.GetResearchRequirements().Contains( researchProjectDef ) )
) ).ToList();

if ( !researchThings.NullOrEmpty() )
Expand Down Expand Up @@ -389,25 +380,25 @@ public static List<RecipeDef> GetRecipesUnlocked( this ResearchProjectDef resear
( d.researchPrerequisite == researchProjectDef )
) ).ToList();

if( !researchRecipes.NullOrEmpty() )
if ( !researchRecipes.NullOrEmpty() )
{
recipes.AddRangeUnique( researchRecipes );
}

if ( thingDefs != null )
{
// Add buildings for those recipes
foreach( var r in recipes )
foreach ( var r in recipes )
{
if( !r.recipeUsers.NullOrEmpty() )
if ( !r.recipeUsers.NullOrEmpty() )
{
thingDefs.AddRangeUnique( r.recipeUsers );
}
var recipeThings = DefDatabase<ThingDef>.AllDefsListForReading.Where( d => (
( !d.recipes.NullOrEmpty() )&&
( d.recipes.Contains( r ) )
) ).ToList();
if( !recipeThings.NullOrEmpty() )
if ( !recipeThings.NullOrEmpty() )
{
thingDefs.AddRangeUnique( recipeThings );
}
Expand All @@ -423,12 +414,12 @@ public static List<RecipeDef> GetRecipesUnlocked( this ResearchProjectDef resear
) ).ToList();

// Aggregate research
if( !advancedResearch.NullOrEmpty() )
if ( !advancedResearch.NullOrEmpty() )
{
foreach( var a in advancedResearch )
foreach ( var a in advancedResearch )
{
recipes.AddRangeUnique( a.recipeDefs );
if( thingDefs != null )
if ( thingDefs != null )
{
thingDefs.AddRangeUnique( a.thingDefs );
}
Expand Down Expand Up @@ -500,13 +491,13 @@ public static List<string> GetSowTagsUnlocked( this ResearchProjectDef researchP
( d.plant.sowResearchPrerequisites.Contains( researchProjectDef ) )
) ).ToList();

if( !researchPlants.NullOrEmpty() )
if ( !researchPlants.NullOrEmpty() )
{
foreach( var plant in researchPlants )
foreach ( var plant in researchPlants )
{
sowTags.AddRangeUnique( plant.plant.sowTags );
}
if( thingDefs != null )
if ( thingDefs != null )
{
thingDefs.AddRangeUnique( researchPlants );
}
Expand Down
Loading

0 comments on commit af5d0cc

Please sign in to comment.