KittenAqua / TrainworksModdingTools

Modding framework for the 2020 PC game Monster Train
15 stars 9 forks source link

Custom Unit Synthesis Patcher #142

Closed lilleypad13 closed 3 years ago

lilleypad13 commented 3 years ago

This is a starting foundation for a process that helps modders create unit syntheses for their custom units in Monster Train's The Last Divinity DLC.

ResetUnitSynthesisMapping: The ResetUnitSynthesisMapping contains the entirety of this main feature. It accesses Monster Train's existing instance of a new post-DLC class named UnitSynthesisMapping and calls its CollectMappingData from within. This resets the editorMapping list (responsible for knowing the connections between CharacterData and CardUpgradeData that make up a synthesis pair) searches through AllGameData finding all the CharacterData (including newly added custom ones), and then tries to pair them up with CardUpgradeData (including newly added custom ones), again found in AllGameData. Ideally this is called once after ALL mods have added their custom content, but even calling it multiple times (such as after each mod is initialized) should theoretically be ok, just not efficient.

Other Edits: The suggested changes I made to CardEffectDataBuilder and CardUpgradeDataBuilder are just there to make it more apparent what this process needs to occur properly, and what default values will cause issues if the modder does not set them properly.

CardEffectDataBuilder edit: CollectMappingData uses a specific string check looking for a CardEffect named "CardEffectSpawnMonster" to identify that a card is indeed a monster character, so the Trainworks default value from AssemblyQualifiedName will NOT satisfy this. Modders can get around this by just making sure to set that specific EffectStateName AFTER setting the EffectStateType, but wanted to point that out and make a suggestion just to see if there is a clean solution to that (I am unclear how necessary AssemblyQualifiedName is there).

CardUpgradeDataBuilder edit: The CardUpgradeDataBuilder edit was suggested because it appears Trainworks removes CardUpgradeData objects in the overall AllGameData list if it finds multiple have the same UpgradeTitleKey (as a solid duplication check), however, if that was not set for several upgrades (unit synthesis upgrades in this case), they would all receive the same exact UpgardeTitleKey (because they all have NULL, and the original setup would just add NULL before a fixed string, naming them the same). My suggestion is to just use the upgradeTitle there instead to make sure they are unique even if the modder doesn't set them to something else.