Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixing the issue of multiple actions calling the same method was (partially) fixed by syncing both the hashed method's description and the hashed original target's type description.
This only fixes the issue partially, as it will only work if the type we're syncing is a generic type and each possible action uses a different generic arguments. However, it should be enough to handle everything in the game, as well as most (if not all) mods.
As for fixing the issue where an action we sync is opening a confirmation dialog - the fix is a bit more complex.
I've added a new delegate that will work as a wrapper around the original action. It may return either null or the synced method as-is, in which case nothing will happen. However, the wrapper may return a different action that will be called instead of immediately syncing the method.
The wrapper is passed the current instance of the object, its arguments, the original
Actionthat was going to be called, as well as theActionthat, when invoked, will sync the data. The arguments are (currently) unused, but I've decided to include them for the case of future-proofing this code.As for the wrappers I've included:
The wrapper for Caravan actions will return null (no wrapper) unless the method's declaring type is
CaravanArrivalActionUtility.<>c__DisplayClass0_1<T>.If the type matches then we will replace the original action with our own which will access the
actionfield from the target type, and:As for the wrapper for Transport Pods, it will return null (no wrapper) unless the method's declaring type is
TransportPodsArrivalActionUtility.<>c__DisplayClass0_0<T>.If the type matches then we will replace the original action with our own which will access the
uiConfirmationCallbackfield.As an additional note, we access the inner compiler-generated types directly. This is due to
MpMethodUtilnot supporting generic types and methods. If we decide to make it support those, we'll need to change how we access those types.