lvgamedev / simairport-modding

4 stars 4 forks source link

New Modding API for custom Needs and Zones. #109

Closed BR146 closed 4 years ago

BR146 commented 4 years ago

Proposal for a new modding API addition with internal implementation detail as reference.

This pull request depends of a few changes in the game classes to provide mod-abilities for custom needs and zones. Mostly, these are UI relevant changes such as internationalization and sprite selection. Those values are somewhat hard coded.

This PR includes the method patches I used for the proof-of-concept: proof-of-concept As dynamic patching does not allow for addition or modification of fields, I was stuck on creating patch methods. For many i18n issues, adding fields is the better option. Therefore, I proposed changed to some in-game classes more suited for those tasks - with the drawback that the project can not be compiled because of missing fields and invalid assignments. Please keep in mind, that the implementation details are only one possible I would intend to implement.

On this note I should also address the zone_type field in ZoneToolConfig: I used heavy weaponry on this Enum to extend it to modded zones. As Enums only allow integers, I used a lookup table for translating between unique string ids and type enum ids, which is mainly used for saving and loading airports (which was fully supported in my proof-of-concept).

In addition to the front end API and the internal implementation proposal, an example was added. The later demonstrates how the proposed API is intended to be used by modders.

If this PR find's its way into the game, I'm willed to create a standalone example mod for the wiki.

BR146 commented 4 years ago

A basic example for modded zones and needs. It basically boils down to have access to two register methods: Example Mod Project.zip

The folder ressources contains all stuff for the actual mod. src contains all code.

Note: The register methods in src/Mod.cs needs adjustment to the implemented interface.