fix(VGE): replace oxygen gizmo sync fields with sync methods#577
Merged
notfood merged 1 commit intorwmt:masterfrom Apr 13, 2026
Merged
fix(VGE): replace oxygen gizmo sync fields with sync methods#577notfood merged 1 commit intorwmt:masterfrom
notfood merged 1 commit intorwmt:masterfrom
Conversation
notfood
requested changes
Apr 12, 2026
sviyh
added a commit
to sviyh/Multiplayer-Compatibility
that referenced
this pull request
Apr 12, 2026
FieldRef<object, ThingComp> and FieldRef<object, Gizmo_Slider> let callsites drop the (ThingComp) and (Gizmo_Slider) casts. Only the field generic needs to be compile-time known; the runtime Type arg passed to FieldRefAccess stays dynamic. Review feedback from rwmt#577.
Replaces the oxygen gizmo sync fields with a SyncMethod + SyncWorker so the Gizmo_Slider.targetValuePct cache round-trips cleanly instead of being overwritten every frame by the base-class slider logic. Uses AccessTools.FieldRef<object, ThingComp> / FieldRef<object, Gizmo_Slider> so callsites don't need casts. targetType is set via reflection on the ISyncField because RegisterSyncField resolves it via FieldInfo.ReflectedType, which returns the base Gizmo_Slider rather than the concrete subclass. See rwmt/Multiplayer#880.
ee05e36 to
d4cd07b
Compare
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
rechargeAtCharges,automaticRechargeEnabled) with sync method for the toggle andtargetValuePctsync on the gizmo for the sliderRoot cause
The old approach synced
rechargeAtChargeson the comp, butGizmo_Slider.targetValuePct(a private cache in the base class) overwrites the comp field every frame viaTarget = targetValuePct, defeating the sync. This is the same pattern the MP mod itself uses forGeneGizmo_ResourceandActivityGizmo— sync the gizmo'stargetValuePctdirectly.Approach
AutomaticRechargeEnabled):RegisterSyncMethodon the property setter — discrete event, no need for field watchingtargetValuePct):RegisterSyncFieldwithSetBufferChanges()on the gizmo, plus aSyncWorkerandtargetTypeoverride (the compat API resolves to the declaring base type)Matches review item S9: "All of this should be easy to do with just sync methods, sync fields are just an extra overhead."
Test plan
🤖 Generated with Claude Code