Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScanningGadget & KnownTech handling #473

Merged
merged 17 commits into from
Oct 26, 2023

Conversation

Metious
Copy link
Member

@Metious Metious commented Sep 27, 2023

Changes made in this pull request

resolves #402
fixes #466

  • Improved the KnownTechPatcher implementation; special thanks to @vlyon for the suggestion in AnalysisTech & Unlocking #402
  • Fixed AddAnalysisTech assignment being flipped, results in overwriting values never being implemented for existing entries
  • Added AddRequirementForUnlock method that just adds blueprints to a requirement tech type
  • Added a better WithScannerEntry overload for the ScanningGadget that doesn't override a techtype's scanner entry that it has no business in
  • ScanningGadget now always adds analysis tech to the current tech type, when the WithAnalysisTech method is called
  • Fixed log spams for buildables
  • Added hard-locking to make items not unlockable by default or by the unlockall command
  • Added a cross-game-friendly overload for AnalysisTech.

Breaking changes

  • You can no longer set requirements for tech types that don't have an Analysis tech

Deprecated methods

TODO:

  • Decide on how to implement the KnownTechPatcher.RemovalTechs efficiently

@Metious
Copy link
Member Author

Metious commented Sep 27, 2023

The KnownTechPatcher.RemovalTechs list is only used once and only for compound techs. I'd like to know why are we removing compound techs from other unlocks and if it is necessary anymore

Fixed a bug where calling the `RemoveAllCurrentAnalysisTechEntry` would also remove the unlock for the target's analysis tech entry, resulting in unexpected behavior.
@Metious Metious marked this pull request as ready for review September 28, 2023 21:00
We now call the original `KnownTech.Initialize` method to ensure mods that patch the method don't get unnoticed upon repatching.
Copy link
Member

@MrPurple6411 MrPurple6411 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks right and doesn't seem to break any of my mods from the small testing I did.

And while my gut still feels like somethings wrong here it seems to work, and I can't figure out what my gut is trying to tell me so.......

Since buildables are never registered to a crafting tree, Nautilus always logs a warning for that interpreting it as a mistake, when in reality it isn't.
Copy link
Member

@MrPurple6411 MrPurple6411 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way I think this is good enough.

Just wondering about setting that 1 log to Debug. if not then good, if yes then good, either way get this merged already lol

}
else if (!prefab.TryGetGadget(out ScanningGadget scanningGadget) || !scanningGadget.IsBuildable)
{
InternalLogger.Log($"Prefab '{prefab.Info.ClassID}' was not automatically registered into a crafting tree.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we could make this Debug log instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think marking that as a debug log will make it easy to miss because a craftable item without a crafting tree that isn't a buildable is alarming and it's safer to assume that the developer missed something. In fact, I'd even argue it should be a warning instead.

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.
Copy link
Member

@MrPurple6411 MrPurple6411 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Metious Metious merged commit 2d58afd into SubnauticaModding:master Oct 26, 2023
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScanningGadget is written incorrectly (AnalysisTech & ScannerEntry) AnalysisTech & Unlocking
2 participants