diff --git a/Nautilus/Handlers/KnownTechHandler.cs b/Nautilus/Handlers/KnownTechHandler.cs
index 7ffab1dc1..43ec9f745 100644
--- a/Nautilus/Handlers/KnownTechHandler.cs
+++ b/Nautilus/Handlers/KnownTechHandler.cs
@@ -21,6 +21,16 @@ public static void UnlockOnStart(TechType techType)
KnownTechPatcher.UnlockedAtStart.Add(techType);
}
+ ///
+ /// Unlocks the when the tech type is unlocked.
+ ///
+ /// The blueprint to unlock.
+ /// The tech type that will unlock the specified blueprint once unlocked.
+ public static void AddRequirementForUnlock(TechType blueprint, TechType requirement)
+ {
+ KnownTechPatcher.BlueprintRequirements.GetOrAddNew(requirement).Add(blueprint);
+ }
+
internal static void AddAnalysisTech(KnownTech.AnalysisTech analysisTech)
{
if (analysisTech.techType != TechType.None)
diff --git a/Nautilus/Patchers/KnownTechPatcher.cs b/Nautilus/Patchers/KnownTechPatcher.cs
index 8e7e34e44..5ed35700c 100644
--- a/Nautilus/Patchers/KnownTechPatcher.cs
+++ b/Nautilus/Patchers/KnownTechPatcher.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
+using Nautilus.Handlers;
using Nautilus.Utility;
namespace Nautilus.Patchers;
@@ -13,12 +14,11 @@ internal class KnownTechPatcher
internal static HashSet UnlockedAtStart = new();
internal static HashSet LockedWithNoUnlocks = new();
internal static IDictionary AnalysisTech = new SelfCheckingDictionary("AnalysisTech", AsStringFunction);
+ internal static IDictionary> BlueprintRequirements = new SelfCheckingDictionary>("BlueprintRequirements", AsStringFunction);
internal static IDictionary CompoundTech = new SelfCheckingDictionary("CompoundTech", AsStringFunction);
internal static IDictionary> RemoveFromSpecificTechs = new SelfCheckingDictionary>("RemoveFromSpecificTechs", AsStringFunction);
internal static List RemovalTechs = new();
- private static FMODAsset UnlockSound;
-
public static void Patch(Harmony harmony)
{
harmony.Patch(AccessTools.Method(typeof(KnownTech), nameof(KnownTech.Initialize)),
@@ -35,12 +35,10 @@ internal static void InitializePrefix(PDAData data)
return;
}
- data.defaultTech.AddRange(KnownTechPatcher.UnlockedAtStart);
+ data.defaultTech.AddRange(UnlockedAtStart);
- foreach (var tech in KnownTechPatcher.AnalysisTech.Values)
+ foreach (var tech in AnalysisTech.Values)
{
- data.defaultTech.Remove(tech.techType);
-
var index = data.analysisTech.FindIndex(analysisTech => analysisTech.techType == tech.techType);
if (index == -1)
{
@@ -52,12 +50,27 @@ internal static void InitializePrefix(PDAData data)
InternalLogger.Debug($"Replacing analysisTech for {tech.techType}");
data.analysisTech[index] = tech;
}
+
+ if (tech.unlockSound == null)
+ {
+ tech.unlockSound = KnownTechHandler.DefaultUnlockData.BlueprintUnlockSound;
+ }
}
- foreach (var tech in KnownTechPatcher.CompoundTech.Values)
+ foreach (var blueprintRequirements in BlueprintRequirements)
{
- data.defaultTech.Remove(tech.techType);
+ var index = data.analysisTech.FindIndex(tech => tech.techType == blueprintRequirements.Key);
+ if (index == -1)
+ {
+ InternalLogger.Error($"TechType '{blueprintRequirements.Key.AsString()}' does not have an analysis tech. Cancelling requirement addition.");
+ continue;
+ }
+
+ data.analysisTech[index].unlockTechTypes.AddRange(blueprintRequirements.Value);
+ }
+ foreach (var tech in CompoundTech.Values)
+ {
var index = data.compoundTech.FindIndex(compoundTech => compoundTech.techType == tech.techType);
if (index == -1)
{