rwmt / Multiplayer

Zetrith's Multiplayer mod for RimWorld
MIT License
481 stars 98 forks source link

Use more `nameof` and use Harmony to access properties rather than methods #503

Open SokyranTheDragon opened 2 months ago

SokyranTheDragon commented 2 months ago

String constant, wherever possible (assuming I haven't missed some), were replaced by the use of nameof.

Replaced places where properties are accessed with AccessTools.PropertyGetter or AccessTools.IndexerGetter, rather than AccessTools.Method by using get_ in the method name.

Also, I've changed array initialization to use collection expressions in SyncThingFilters class, since I was already modifying it.

SokyranTheDragon commented 2 months ago

I've reverted change for m_RevealCursor, as it seems to sometimes cause errors

Not sure why (I've tried to clear my publicizer cache, etc.). It seems that, for me, Rider is refusing to acknowledge that this field is public. It still compiles fine and without any errors, however this causes annoying errors while working on the project.

So for the sake of safety (in case anyone else is going to encounter this issue) - I've decided to just revert this specific change.

On top of that, one thing I did not consider at the time - rather than using reflection, we could have just replaced this with te.m_RevealCursor = true (if there was no issue after publicizing).