Trouv / bevy_ecs_ldtk

ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap
Other
641 stars 73 forks source link

Provide API abstracting over external/internal levels better #205

Closed Trouv closed 9 months ago

Trouv commented 1 year ago

Currently, LdtkLevel is the de-facto abstraction for retrieving level data in both external and internal cases. A Handle<LdtkLevel> is loaded as a labeled asset in the internal case, and it is loaded as a dependent asset in the external case. However, Since LdtkAsset already has this level data in the internal case, it ends up being cloned in order to create an LdtkLevel. Surely there's a way to leverage a smart pointer and/or enums to avoid this expensive clone.

Something to the effect of...

enum LevelPointer {
    Internal {
        data: Arc<Level>,
        bg_image: Handle<Image>,
    },
    External {
        handle: Handle<LdtkExternalLevel>
    },
}