MonkeyModdingTroop / MonkeyLoader

A convenience and extendability focused mod loader using NuGet packages.
https://monkeymoddingtroop.github.io/MonkeyLoader/index.html
GNU Lesser General Public License v3.0
11 stars 3 forks source link

Add a trait/component system for (defining) config keys #9

Closed Banane9 closed 5 months ago

Banane9 commented 5 months ago

One might want to combine a variety of features or extra data for config keys, such as (but not limited to):

Trying to achieve these by nesting key definitions and such is inflexible and becoming a pain. As such, it would seem to make more sense to be able to optionally add those as traits to keys. Especially common ones such as description would have integrated support from properties on the key, while others would have to be accessed via (Generic) methods to get traits of a specific (interface) type. By letting keys implement IEnumerable for the trait type and defining a suitable Add method, the traits will be addable in the convenient object/collection initializer syntax.

These traits should probably have an initialize method that accept the defining key they're being added to (and a property linking to it), which must be called when the key is added to a config section and thus "finalized". It may be best if this is done in two steps so that all traits can do basic setup before (optionally) integrating with eachother, should that be a thing. This could be done via another interface.