Skip to content

Commit

Permalink
allow enum tags for family creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Quillraven committed Sep 27, 2023
1 parent 09450a9 commit 1e2fde5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/commonMain/kotlin/com/github/quillraven/fleks/family.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data class FamilyDefinition(
/**
* Any [entity][Entity] must have all given [types] to be part of the [family][Family].
*/
fun all(vararg types: ComponentType<*>): FamilyDefinition {
fun all(vararg types: UniqueId<*>): FamilyDefinition {
allOf = BitArray(types.size).also { bits ->
types.forEach { bits.set(it.id) }
}
Expand All @@ -36,7 +36,7 @@ data class FamilyDefinition(
/**
* Any [entity][Entity] must not have any of the given [types] to be part of the [family][Family].
*/
fun none(vararg types: ComponentType<*>): FamilyDefinition {
fun none(vararg types: UniqueId<*>): FamilyDefinition {
noneOf = BitArray(types.size).also { bits ->
types.forEach { bits.set(it.id) }
}
Expand All @@ -46,7 +46,7 @@ data class FamilyDefinition(
/**
* Any [entity][Entity] must have at least one of the given [types] to be part of the [family][Family].
*/
fun any(vararg types: ComponentType<*>): FamilyDefinition {
fun any(vararg types: UniqueId<*>): FamilyDefinition {
anyOf = BitArray(types.size).also { bits ->
types.forEach { bits.set(it.id) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlin.test.*

data object Visible : EntityTag()

class TestTagSystem(var ticks: Int = 0) : IteratingSystem(family { all(Visible) }) {
class TestTagSystem(var ticks: Int = 0) : IteratingSystem(family { all(Visible, TestTags.PLAYER) }) {
override fun onTickEntity(entity: Entity) {
++ticks
}
Expand Down Expand Up @@ -45,7 +45,10 @@ class EntityTagTest {
add(TestTagSystem().also { testSystem = it })
}
}
val entity = world.entity { it += Visible }
val entity = world.entity {
it += Visible
it += TestTags.PLAYER
}

world.update(1f)
assertEquals(1, testSystem.ticks)
Expand Down

0 comments on commit 1e2fde5

Please sign in to comment.