Restore Nautilus GameInput compatibility#2740
Conversation
Applies the focused Nautilus GameInput/keybind compatibility work from JackNytely's PR SubnauticaNitrox#2663. This restores compatibility with newer Nautilus builds that extend Subnautica's GameInput system, while excluding unrelated launcher/server changes from the original PR. Credit: based on JackNytely's work in SubnauticaNitrox#2663.
Removes readonly from UwePrefab so spawning code can mutate Probability without throwing a MissingMethodException for UwePrefab.set_Probability. This fixes repeated server-side sync exceptions during multiplayer world/entity spawning.
| try | ||
| { | ||
| return Assembly.LoadFile(dllPath); | ||
| return Assembly.LoadFrom(dllPath); |
There was a problem hiding this comment.
Think we want to keep this LoadFile so that we get a chance to resolve dependencies ourselves. Otherwise it might load dependencies that cause (hidden) incompatibilities by loading slightly different assembly versions.
Use the LoadFile method to load and examine assemblies that have the same identity, but are located in different paths. LoadFile does not load files into the load-from context, and does not resolve dependencies using the load path, as the LoadFrom method does. LoadFile is useful in this limited scenario because LoadFrom cannot be used to load assemblies that have the same identities but different paths; it will load only the first such assembly.
There was a problem hiding this comment.
That concern makes sense, and I agree we do not want the launcher accidentally resolving incompatible dependency versions.
The reason I changed this is that the LoadFile behavior appears to be the source of the runtime mismatch we were seeing in Release builds. In practice, it can load an assembly outside the normal load context, which means another assembly with the same identity can still be loaded elsewhere. That was causing type/API-surface mismatches, including the UwePrefab/Nitrox.Model.Subnautica MissingMethodException during world sync.
So the issue was not that we needed less control over dependency loading; it was that LoadFile gave us too much isolation and allowed duplicate/mismatched assemblies with the same identity to exist at runtime.
LoadFrom still loads from the explicit path selected by this resolver, so we are still preferring the intended lib/launcher-local assembly path. The important difference is that it participates in the load-from context, so subsequent binds to the same assembly identity resolve consistently instead of creating a hidden duplicate assembly situation.
That said, I understand the concern about broadening dependency resolution. If preferred, I can adjust this to be more targeted, but the purpose of the change is specifically to prevent the Release build from loading mismatched Nitrox assemblies and producing runtime MissingMethodExceptions.
|
I split the Release launcher dependency-loading fix into its own PR: #2749. This PR currently builds on top of that work, so some shared Release/lib-loading changes may appear here until #2749 is merged. Once #2749 lands, I can rebase/update this branch so this PR only shows the Nautilus/GameInput compatibility changes. The dependency is intentional because the Release/lib-loading fix is needed for clean Release-build testing: without it, existing servers may not show and new server creation can fail/crash due to mismatched dependency loading from |
|
I also created a temporary draft integration/testing PR that combines the current related fixes for anyone who wants to test them together before they land individually:
This is not intended to replace the focused PRs. It is only a convenience branch for combined Release/modded testing. |
Summary
Restores compatibility between Nitrox and newer Nautilus builds that use Nautilus's Subnautica GameInput integration.
Nautilus 1.0.0-pre.45+ introduced a new GameInput/custom button system. With Nitrox, this caused the game to reach the title/menu scene but fail to populate the expected menu/UI state, making Nitrox effectively incompatible with newer Nautilus builds.
This PR applies the focused GameInput/keybind compatibility work from JackNytely's PR #2663, excluding the unrelated launcher/server changes from that PR.
Full credit for the Nautilus GameInput compatibility work goes to JackNytely and PR #2663. This PR separates the input compatibility pieces into a smaller, focused change set.
What changed
UwePrefab fix
During multiplayer world sync, the server repeatedly threw:
System.MissingMethodException: Method not found:
'Void Nitrox.Model.Subnautica.DataStructures.GameLogic.Entities.UwePrefab.set_Probability(Single)'.