Skip to content

Commit

Permalink
Added an overload for WithAnalysisTech
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Metious committed Oct 25, 2023
1 parent f0d935b commit 870abd5
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions Nautilus/Assets/Gadgets/ScanningGadget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,29 @@ public ScanningGadget WithScannerEntry(float scanTime, bool isFragment = false,

return this;
}

/// <summary>
/// Adds additional info on what should happen when this item is unlocked.
/// </summary>
/// <param name="popupSprite">The sprite that should popup on unlock.</param>
/// <param name="unlockSound">The sound that will be played on unlock.</param>
/// <param name="unlockMessage">Message which should be shown on unlock.</param>
/// <returns>A reference to this instance after the operation has completed.</returns>
public ScanningGadget WithAnalysisTech(
Sprite popupSprite,
FMODAsset unlockSound = null,
string unlockMessage = null
)
{
return WithAnalysisTech(new KnownTech.AnalysisTech
{
unlockPopup = popupSprite,
unlockSound = unlockSound,
unlockMessage = unlockMessage
});
}

#if SUBNAUTICA
/// <summary>
/// Adds additional info on what should happen when this item is unlocked.
/// </summary>
Expand All @@ -296,24 +318,34 @@ public ScanningGadget WithScannerEntry(float scanTime, bool isFragment = false,
/// <returns>A reference to this instance after the operation has completed.</returns>
public ScanningGadget WithAnalysisTech(
Sprite popupSprite,
#if SUBNAUTICA
List<StoryGoal> 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;
}
Expand Down

0 comments on commit 870abd5

Please sign in to comment.