Trouv / bevy_ecs_ldtk

ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap
Other
630 stars 74 forks source link

feat: add level locale types and begin splitting internal_levels and external_levels features #237

Closed Trouv closed 9 months ago

Trouv commented 9 months ago

As part of the rework of the asset types, it is useful to be able to define types that are generic over the "level locale" of the project they represent. The terminology level locale refers to whether or not the project uses internal levels (level data embedded in the main project asset) or external levels (level data stored in separate individual-level files). Such a generic type is able to define different implementations of the same trait for the two locales, or the same implementation of the same trait, or even completely different methods between the two locales.

To facilitate this, this PR adds a LevelLocale trait, which is mostly a marker trait implemented by the new InternalLevels and ExternalLevels unit structs. It does provide an associated type to the sort of level metadata that is created for the two locales, but other than that it will mostly be used as a trait bound for generic types. The fact that the trait is private means that users will not be able to create new locales that don't fit into the canonical asset type design defined here.

This also introduces the internal_levels and external_levels features. These two features are not mutually exclusive, but at least one of them does need to be enabled. The eventual asset type design will hide most things behind these features so users can slightly optimize their compilation if they want to.

(Ignore broken doc-links here, they will no longer be broken in future PRs)