Skip to content

Commit

Permalink
Merge pull request #280 from EldritchCarMaker/Fix-CompoundTech-patching
Browse files Browse the repository at this point in the history
  • Loading branch information
Metious committed Nov 19, 2022
2 parents f02f116 + 3ee9e04 commit baf3d4c
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions SMLHelper/Patchers/KnownTechPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,20 @@ internal static void InitializePostfix()
analysisTech.Add(tech);
}


List<KnownTech.CompoundTech> compoundTech = KnownTech.compoundTech;
IEnumerable<KnownTech.CompoundTech> compoundTechToAdd = CompoundTech.Values.Where(a => !compoundTech.Any(a2 => a.techType == a2.techType));

foreach (KnownTech.CompoundTech tech in compoundTech)
{
foreach (KnownTech.CompoundTech customTech in CompoundTech.Values)
{
tech.dependencies = customTech.dependencies;
}
}

foreach (KnownTech.CompoundTech tech in compoundTechToAdd)
foreach (KnownTech.CompoundTech customTech in CompoundTech.Values)
{
if (tech == null)
if (customTech == null) // Safety check
continue;

if (!KnownTech.Contains(tech.techType))
compoundTech.Add(tech);
// Only add the new compound tech if it isn't unlocked yet
if (!KnownTech.Contains(customTech.techType))
compoundTech.Add(customTech);

// If a compound tech already exists, set the dependencies correctly.
var foundTech = compoundTech.Find(tech => tech.techType == customTech.techType);
if (foundTech != null)
foundTech.dependencies = customTech.dependencies;
}
}
}
Expand Down

0 comments on commit baf3d4c

Please sign in to comment.