tbeswick96 / BannerlordYetAnotherPartyOrganiser

Mount & Blade II: Bannerlord - Troop Manager Mod
GNU Lesser General Public License v3.0
6 stars 0 forks source link

Fix vanilla formation selection saving #15

Closed MLNW closed 4 years ago

MLNW commented 4 years ago

When merged this pull request will:

MLNW commented 4 years ago

Still have to test it on the 1.2.0 beta branch

MLNW commented 4 years ago

As it stands we need to implement this differently for 1.1.1 and 1.2.0 since there was a change relating to the Campaign class that is used to figure out when everything has been loaded and the game actually starts.

Question now is do we support both versions or only one? Since this feature isn't really core to our mission it may be best to simply implement it for the newer version and have it go live as soon as 1.2.0 isn't beta anymore.

tbeswick96 commented 4 years ago

How tricky is it to have it for both? Can it be resolved through reflection based on version to avoid having to explicitly specify the thing needed from Campaign?

MLNW commented 4 years ago

How tricky is it to have it for both? Can it be resolved through reflection based on version to avoid having to explicitly specify the thing needed from Campaign?

We would need to patch different methods on TaleWorlds.CampaignSystem.Campaing:

From a quick look they do the same thing but for what ever reason they decided to rename the method.

For 1.2.0 there was also another patch added for TaleWorlds.Core.BasicCharacterObject.DefaultFormationGroup. Sounds like it was added for 1.2.0.

I haven't worked with reflection in C# so I'm not sure if it's possible. But it does sound feasible. YAPO.Fixes.Formations.Patches.CampaignPatches would need to take into account the current version and patch different methods depending on it. That should be possible with Harmonys TargetMethod syntax.

For the DefaultFormationGroup I'm not sure. It may be problematic if it was only added for 1.2.0 but there is probably a way similar to the one above.

EDIT: I found this which I will try to check for the version: https://stackoverflow.com/a/12528418