Skip to content

Commit

Permalink
refactor: Fix unrelated types reported by DCM (#3023)
Browse files Browse the repository at this point in the history
DCM recently started reporting
`avoid-collection-methods-with-unrelated-types` for the quadtree class,
this PR fixes the reported issues.
  • Loading branch information
spydon committed Feb 8, 2024
1 parent abca337 commit 1d020a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Expand Up @@ -190,11 +190,11 @@ class QuadTree<T extends Hitbox<T>> {
}

void remove(T hitbox, {bool keepOldPosition = false}) {
final node = _hitboxAtNode.remove(hitbox);
final node = _hitboxAtNode.remove(hitbox as ShapeHitbox);
if (node != null) {
node.hitboxes.remove(hitbox);
if (!keepOldPosition) {
_oldPositionByItem.remove(hitbox);
_oldPositionByItem.remove(hitbox as ShapeHitbox);
}
}
}
Expand Down Expand Up @@ -273,7 +273,7 @@ class QuadTree<T extends Hitbox<T>> {
}

bool hasMoved(T hitbox) {
final lastPos = _oldPositionByItem[hitbox];
final lastPos = _oldPositionByItem[hitbox as ShapeHitbox];
if (lastPos == null) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flame/test/collisions/collision_test_helpers.dart
Expand Up @@ -126,7 +126,7 @@ class TestBlock extends PositionComponent with CollisionCallbacks {
return activeCollisions.contains(other);
}

bool collidedWithExactly(List<CollisionCallbacks> collidables) {
bool collidedWithExactly(List<PositionComponent> collidables) {
final otherCollidables = collidables.toSet()..remove(this);
return activeCollisions.containsAll(otherCollidables) &&
otherCollidables.containsAll(activeCollisions);
Expand Down

0 comments on commit 1d020a5

Please sign in to comment.