Rework some PawnColumnWorker syncing #502
Merged
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.
This change is primarily to fix
PawnColumnWorker_DesignatorandPawnColumnWorker_Sterilizedisplaying confirmation dialogs, which caused issues as pressing the checkbox would open the dialog for all players and the dialogs themselves weren't synced. I've mentioned this issue in #429.The first change is to stop syncing
PawnColumnWorker_Designator.SetValueandPawnColumnWorker_Sterilize.SetValue, as those could display confirmation dialogs. Instead of those 2 methods, we instead sync:DesignationManager.AddDesignationDesignationManager.RemoveDesignation(and may come in handy for mod compat, it can be safely removed if desired)DesignationManager.RemoveDesignationPawnColumnWorker_Designator.SetValuewhen value is falsePawnColumnWorker_Designator.DesignationConfirmedDesignationManager.AddDesignation(along with another method), which is why that specific method is not needed for syncingPawnColumnWorker_Sterilize.AddSterilizeOperationPawnColumnWorker_Sterilize.CancelSterilizeOperationsThis required adding extra sync worker delegates for
DesignationandDesignationManager. Those were taken from MP Compat (rwmt/Multiplayer-Compatibility#394).By not syncing the
SetValuemethod, it allows for a potential multiple calls to the other synced methods which generally don't have checks if the state already matches. This requires additional patches that cancel execution if it would cause issues (PreventPawnTableDesignationErrors,PreventPawnTableMultipleSterilizeOperations).Finally, by not syncing the
SetValuemethods we don't callSetDirtyon the pawn tables. To fix this I've added a method (TryDirtyCurrentPawnTable) which is called in post invoke for the synced methods, as well as after syncing designators, to cause the tables to re-sort their values. This will cause the tables to be re-sorted in a few extra situations (like when a different player modifies designators outside of pawn tables). It may be expanded to include more methods to cause the tables to be re-sorted when they normally wouldn't be in vanilla (if we so desire). Alternatively, this could be reduced or removed if we don't want it.