Skip to content

Make CustomizeBuildings config easier to read for other mods, example included#88

Open
Sgt-Imalas wants to merge 4 commits intoTruinto:masterfrom
Sgt-Imalas:master
Open

Make CustomizeBuildings config easier to read for other mods, example included#88
Sgt-Imalas wants to merge 4 commits intoTruinto:masterfrom
Sgt-Imalas:master

Conversation

@Sgt-Imalas
Copy link
Copy Markdown

Adds a static method to the mod config of CustomizeBuildings.

this helps other mods to more easily read config values of the mod for better intra-mod compatibility.

the class Customize_Buildings_ModIntegration is an example of such an integration, it can be directly copied by other mods.

Those mods then can call Customize_Buildings_ModIntegration.TryGetConfigValue to read config state values without any further requirements

@Truinto
Copy link
Copy Markdown
Owner

Truinto commented Apr 4, 2026

The original json logic was way back when I started coding. I have made better implementations, but never took the time to rewrite the old mods.
Until now. I don't think it was worth the time, but here it is. See https://github.com/Truinto/Shared/blob/master/General/BaseSettings.cs for the actual code.

If you do use Reflection this would be the code to do it:
Type.GetType("CustomizeBuildings.CustomizeBuildingsState, CustomizeBuildings")?.BaseType?.GetMethod("TryGetValue")?.Invoke(null, ["Version"]);
Replace "Version" with the field you want to read.

I would really appreciate, if someone else would also test the new assembly. I did change a lot, so a lot could break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants