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

holds gets entity based on first tick #195

Open
tillschallau opened this issue Nov 8, 2024 · 0 comments
Open

holds gets entity based on first tick #195

tillschallau opened this issue Nov 8, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@tillschallau
Copy link
Member

Describe the bug
The holds function gets the references for entities entity1 and entity2 based on the first tick. This is problematic when an entity is not present in the first tick but appears in a later tick. In this case, the entity that appeared at a later point is not evaluated at all.

fun <E1 : E, E2 : E> holds(
predicate: BinaryPredicate<E1, E2, E, T, S, U, D>,
tick: U,
entityId1: Int,
entityId2: Int
): Boolean =
binaryPredicateCache.getOrPut(predicate to (Triple(tick, entityId1, entityId2))) {
val currentTick = segment.ticks[tick]
val entity1 = currentTick?.getEntityById(entityId1)
val entity2 = currentTick?.getEntityById(entityId2)
entityId1 != entityId2 &&
currentTick != null &&
predicate.kClasses.first.isInstance(entity1) &&
predicate.kClasses.second.isInstance(entity2) &&
predicate.eval(
this,
predicate.kClasses.first.cast(entity1),
predicate.kClasses.second.cast(entity2))
}

Expected behavior
The entity should be acquired for the first timestamp in which the entity exists.

Additional context
Kai discovered this in his bachelor thesis.

@tillschallau tillschallau added the bug Something isn't working label Nov 8, 2024
@tillschallau tillschallau added this to the v0.6 milestone Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant