Asteroids break into smaller pieces and then into tiny rocks. Small pieces drop loot. - #654
Conversation
8f0cbdf to
52d2b8c
Compare
BenjaminAmos
left a comment
There was a problem hiding this comment.
I haven't tested this yet but a few things caught my eye whilst looking through the changes.
| EntityRef entityRef = entitySystemManager.getEntityManager().createEntity(graphicsComponent, positionComponent, | ||
| velocityComponent, angle, sizeComponent, new RubbleMesh()); | ||
|
|
||
| if(sizeComponent.size > 0.1) { |
There was a problem hiding this comment.
You might want to move the 0.1 value into a MIN_DIVISIBLE_SIZE constant. I wasn't clear on why that value was chosen until I realised what it was.
| //Create size component | ||
| Size sizeComponent = new Size(); | ||
| sizeComponent.size = scale; | ||
| sizeComponent.size = scale * size.size; |
There was a problem hiding this comment.
GitHub doesn't let me comment on unchanged lines but you forgot to multiply by the parent size on line 129.
Why not create a local variable to store the scaled size?
float scaledSize = scale * size.size;You can then use that variable everywhere where you are currently using scale * size.size.
|
@BenjaminAmos Thnkx for the review. I have made the corrections. |
…d then into tiny rocks. The smaller pieces also drop loot when destroyed.
a27f01d to
58cbfde
Compare
|
Rebased to develop |
BenjaminAmos
left a comment
There was a problem hiding this comment.
The fix works and the changes seem reasonable to me. I've never seen rubble as large as this before! I'll approve this but will wait for another review if possible, since I'm not too familiar with this area of the code,
NicholasBatesNZ
left a comment
There was a problem hiding this comment.
Second review as requested — this looks good to me. The thing I most wanted to check was whether the splitting could run away, and it can't: each piece is scale × parent.size with scale capped at 0.3, and the MIN_DIVISIBLE_SIZE gate means the cascade bottoms out after three generations (~150 entities from the largest asteroid, spread across separate destruction events rather than one frame). It also merges cleanly and compiles fine on the new Gradle 9.6.1 / Java 17 setup.
Two non-blocking notes: MIN_DIVISIBLE_SIZE (0.1) is slightly below the size at which (int)(size * SIZE_TO_RUBBLE_COUNT) first reaches 1 (0.125), so pieces in that band get the component but never spawn anything — 1f / SIZE_TO_RUBBLE_COUNT would tidy that up. And the children now collectively pay out noticeably more than the parent did, so money-per-asteroid goes up roughly 3–4×; worth a balance pass whenever the ECS asteroid path comes off DebugOptions.SPAWN_ECS_ASTEROID. Neither is a reason to hold this up.
Description
Testing
P.S: The newly created pieces of asteroid do not break(fixed in #653). To test, add the health component to the rubble entities.
Pre Pull Request Checklist: