From 870abd53650326601cad1c64805258b04e5efef7 Mon Sep 17 00:00:00 2001
From: Metious <71298690+Metious@users.noreply.github.com>
Date: Wed, 25 Oct 2023 14:09:57 +0330
Subject: [PATCH] Added an overload for WithAnalysisTech
Added an overload for `WithAnalysisTech` that doesn't take a story goal. This way it's easier to write the same code for both SN and BZ.
---
Nautilus/Assets/Gadgets/ScanningGadget.cs | 46 +++++++++++++++++++----
1 file changed, 39 insertions(+), 7 deletions(-)
diff --git a/Nautilus/Assets/Gadgets/ScanningGadget.cs b/Nautilus/Assets/Gadgets/ScanningGadget.cs
index 7f29e080..93060fb9 100644
--- a/Nautilus/Assets/Gadgets/ScanningGadget.cs
+++ b/Nautilus/Assets/Gadgets/ScanningGadget.cs
@@ -285,7 +285,29 @@ public ScanningGadget WithScannerEntry(float scanTime, bool isFragment = false,
return this;
}
+
+ ///
+ /// Adds additional info on what should happen when this item is unlocked.
+ ///
+ /// The sprite that should popup on unlock.
+ /// The sound that will be played on unlock.
+ /// Message which should be shown on unlock.
+ /// A reference to this instance after the operation has completed.
+ public ScanningGadget WithAnalysisTech(
+ Sprite popupSprite,
+ FMODAsset unlockSound = null,
+ string unlockMessage = null
+ )
+ {
+ return WithAnalysisTech(new KnownTech.AnalysisTech
+ {
+ unlockPopup = popupSprite,
+ unlockSound = unlockSound,
+ unlockMessage = unlockMessage
+ });
+ }
+#if SUBNAUTICA
///
/// Adds additional info on what should happen when this item is unlocked.
///
@@ -296,24 +318,34 @@ public ScanningGadget WithScannerEntry(float scanTime, bool isFragment = false,
/// A reference to this instance after the operation has completed.
public ScanningGadget WithAnalysisTech(
Sprite popupSprite,
-#if SUBNAUTICA
List storyGoalsToTrigger = null,
-#endif
FMODAsset unlockSound = null,
string unlockMessage = null
)
{
- AnalysisTech ??= new KnownTech.AnalysisTech();
+ return WithAnalysisTech(new KnownTech.AnalysisTech
+ {
+ unlockPopup = popupSprite,
+ storyGoals = storyGoalsToTrigger,
+ unlockSound = unlockSound,
+ unlockMessage = unlockMessage
+ });
+ }
+#endif
+
+ private ScanningGadget WithAnalysisTech(KnownTech.AnalysisTech analysisTech)
+ {
+ AnalysisTech = analysisTech;
AnalysisTech.techType = prefab.Info.TechType;
AnalysisTech.unlockTechTypes = RequiredForUnlock != TechType.None
? new() { prefab.Info.TechType }
: new();
- AnalysisTech.unlockPopup = popupSprite;
+ AnalysisTech.unlockPopup = analysisTech.unlockPopup;
#if SUBNAUTICA
- AnalysisTech.storyGoals = storyGoalsToTrigger ?? new();
+ AnalysisTech.storyGoals = analysisTech.storyGoals ?? new();
#endif
- AnalysisTech.unlockSound = unlockSound;
- AnalysisTech.unlockMessage = unlockMessage ?? KnownTechHandler.DefaultUnlockData.BlueprintUnlockMessage;
+ AnalysisTech.unlockSound = analysisTech.unlockSound;
+ AnalysisTech.unlockMessage = analysisTech.unlockMessage ?? KnownTechHandler.DefaultUnlockData.BlueprintUnlockMessage;
return this;
}