Sync fishing zone settings and allow fishing gizmo #607
Conversation
Add sync for FishingZone settings, including repeat mode via FloatMenu The biggest challenge was synchronizing the repeat mode toggle triggered through the FloatMenu. To achieve this, I implemented a transpiler that locates the FloatMenu construction and injects a sync call just before the WindowStack.Add invocation. I based the approach on the existing sync implementation for Bill repeat mode (BillConfigFloatMenuTranspiler), adapting it to correctly identify and inject at the relevant IL pattern. Additional safeguards ensure the patch fails gracefully if the underlying code structure changes.
|
This looks nightmareish, let me check further. |
|
I can strip it down more if you want. Most of the nightmarish stuff you probably mean are pattern-matching safeguards against IL changes. But I must say, it's my first "large" transpiler - so maybe those aren't even necessary. Maybe it's enough to just check whether the patch was inserted twice, like in the bill example I mentioned. I did learn everything on the fly and I'm always open to better solutions :) |
|
Is this transpiler here necessary? Can't this be done with a SyncDelegate? SyncDelegate.Lambda(typeof(ITab_Fishing), nameof(ITab_Fishing.FillTab), 0);If this was inspired by the patch for |
|
:D :D Yeah… you could say this is a cleaner solution. Thanks :)) I’ve started splitting the fishing zone into a partial class. If you’d rather not go that route, I can merge it back into one class tomorrow. |
|
... and good to know why the bill repeat mode is synced this way. I directly thought the bill had a repeat mode as well and didn’t even consider another solution. |
notfood
left a comment
There was a problem hiding this comment.
I'm fine with partial. Syncfields is an already huge file.
Label: 1.6, desync
PR:
Syncs fishing zone settings and allow fishing gizmo
Implementation:
The biggest challenge was synchronizing the repeat mode toggle triggered through the FloatMenu. To achieve this, I implemented a transpiler that locates the FloatMenu construction and injects a sync call just before the WindowStack.Add invocation.
I based the approach on the existing sync implementation for Bill repeat mode (BillConfigFloatMenuTranspiler), adapting it to correctly identify and inject at the relevant IL pattern.
Additional safeguards ensure the patch fails gracefully if the underlying code structure changes.
I thought it would be an easy task to do while on vacation... It wasn't :D