Skip to content

Generic Components #75

Answered by Quillraven
ernespn asked this question in Q&A
Nov 17, 2022 · 2 comments · 8 replies
Discussion options

You must be logged in to vote

@ernespn: I experimented a little bit now, and I see two solutions but still I'd like to know why you do it like that instead of modifying the components directly where you currently add your Transfer component.

Option 1

This is similar to what you tried and as I expected, it does not work currently in Fleks. I had to add another plusAssign operator that accepts a "wildcard" ComponentType to work. The result would be this:

class Damage : Component<Damage> {
    override fun type(): ComponentType<Damage> = Damage

    companion object : ComponentType<Damage>()
}

class Life : Component<Life> {
    override fun type(): ComponentType<Life> = Life

    companion object : ComponentType<Life>()…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@Quillraven
Comment options

@ernespn
Comment options

@ernespn
Comment options

@ernespn
Comment options

@Quillraven
Comment options

Answer selected by ernespn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants