Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Iid component #249

Open
Trouv opened this issue Oct 18, 2023 · 0 comments
Open

Generic Iid component #249

Trouv opened this issue Oct 18, 2023 · 0 comments

Comments

@Trouv
Copy link
Owner

Trouv commented Oct 18, 2023

Many types in LDtk have an Iid, and I think it's becoming increasingly useful to create components storing these values on the corresponding entities. This is being done for LevelIid and EntityIid currently. However, these two implementations are pretty different, when they could be pretty much exactly the same type with a slightly different context.

Instead we could have a generic LdtkIid<> component and contextualize it with a generic parameter. Something like...

trait LdtkInstance {}
impl LdtkInstance for EntityInstance {}
impl LdtkInstance for Level {}

#[derive(Component)]
struct LdtkIid<I>
    where I: LdtkInstance
{
    iid: String,
    phantom: PhantomData<I>,
}

type LevelIid = LdtkIid<Level>;
type EntityIid = LdtkIid<EntityInstance>;

This would reduce repeated code and make it easier to add other Iid components in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant