From 0b6c62afcd5596c68710e24e6a830302ee1b1ce9 Mon Sep 17 00:00:00 2001 From: tkshnwesper Date: Sun, 2 Jun 2024 20:09:45 +0530 Subject: [PATCH 1/4] Fix for #520 --- lib/collision/block_movement_collision.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/collision/block_movement_collision.dart b/lib/collision/block_movement_collision.dart index 74d28461f..549071f75 100644 --- a/lib/collision/block_movement_collision.dart +++ b/lib/collision/block_movement_collision.dart @@ -101,15 +101,20 @@ mixin BlockMovementCollision on Movement { return; } - ShapeHitbox shape1 = _getCollisionShapeHitbox( + ShapeHitbox? shape1 = _getCollisionShapeHitbox( shapeHitboxes, intersectionPoints, ); - ShapeHitbox shape2 = _getCollisionShapeHitbox( + ShapeHitbox? shape2 = _getCollisionShapeHitbox( other.children.query(), intersectionPoints, ); + if (shape1 == null || shape2 == null) { + super.onCollision(intersectionPoints, other); + return; + } + ({Vector2 normal, double depth})? colisionResult; if (_isPolygon(shape1)) { @@ -273,10 +278,11 @@ mixin BlockMovementCollision on Movement { return (normal: normal, depth: depth); } - ShapeHitbox _getCollisionShapeHitbox( + ShapeHitbox? _getCollisionShapeHitbox( List shapeHitboxes, Set intersectionPoints, ) { + if (shapeHitboxes.isEmpty || intersectionPoints.isEmpty) return null; if (shapeHitboxes.length == 1) { return shapeHitboxes.first; } From b30dd3d4d4539df7f2f5fae352c2793e58483c8a Mon Sep 17 00:00:00 2001 From: tkshnwesper Date: Sun, 2 Jun 2024 20:11:57 +0530 Subject: [PATCH 2/4] refactor: move `super.onCollision` call to the end --- lib/collision/block_movement_collision.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/collision/block_movement_collision.dart b/lib/collision/block_movement_collision.dart index 549071f75..05359ed34 100644 --- a/lib/collision/block_movement_collision.dart +++ b/lib/collision/block_movement_collision.dart @@ -75,8 +75,10 @@ mixin BlockMovementCollision on Movement { @override void onCollision(Set intersectionPoints, PositionComponent other) { - super.onCollision(intersectionPoints, other); - if (other is Sensor || !_blockMovementCollisionEnabled) return; + if (other is Sensor || !_blockMovementCollisionEnabled) { + super.onCollision(intersectionPoints, other); + return; + } bool stopOtherMovement = true; bool stopMovement = other is GameComponent ? onBlockMovement(intersectionPoints, other) @@ -89,6 +91,7 @@ mixin BlockMovementCollision on Movement { } if (!stopMovement || !stopOtherMovement) { + super.onCollision(intersectionPoints, other); return; } @@ -98,6 +101,7 @@ mixin BlockMovementCollision on Movement { _collisionsResolution[other]!, ); _collisionsResolution.remove(other); + super.onCollision(intersectionPoints, other); return; } @@ -148,6 +152,7 @@ mixin BlockMovementCollision on Movement { other.setCollisionResolution(this, data.inverted()); } } + super.onCollision(intersectionPoints, other); } bool _isPolygon(ShapeHitbox shape) { From 66816310d5ce329d15b4e5180775cdfb8b015e59 Mon Sep 17 00:00:00 2001 From: tkshnwesper Date: Sun, 2 Jun 2024 20:19:27 +0530 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d6d581b7..34c08a428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - push improvements. - `Movement` mixin improvements. - Other otimizations +- Fix intermittent crash after `simpleAttackRanged` is called # 3.9.2 - MiniMap improviments. Fix issue [#517](https://github.com/RafaelBarbosatec/bonfire/issues/517) From 7b6aee8d80a57d52be0854dae5dd5401ac1dd11e Mon Sep 17 00:00:00 2001 From: tkshnwesper Date: Sun, 2 Jun 2024 20:28:48 +0530 Subject: [PATCH 4/4] fix whitespace issue --- lib/mixins/direction_animation.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mixins/direction_animation.dart b/lib/mixins/direction_animation.dart index 046b5cac2..e9cf54916 100644 --- a/lib/mixins/direction_animation.dart +++ b/lib/mixins/direction_animation.dart @@ -91,9 +91,9 @@ mixin DirectionAnimation on Movement { await animation?.onLoad(gameRef); return super.onLoad(); } - + @override - void onMount(){ + void onMount() { super.onMount(); idle(); }