Skip to content

Asteroids break into smaller pieces and then into tiny rocks. Small pieces drop loot. - #654

Merged
NicholasBatesNZ merged 2 commits into
MovingBlocks:developfrom
Mystic-Slice:RubbleSizeCount
Aug 14, 2026
Merged

NicholasBatesNZ merged 2 commits into
MovingBlocks:developfrom
Mystic-Slice:RubbleSizeCount

Conversation

@Mystic-Slice

@Mystic-Slice Mystic-Slice commented Mar 2, 2022

Copy link
Copy Markdown
Contributor

Description

Rubble created from destroying asteroid also now create smaller pieces when destroyed.
CreatesRubbleOnDestruction component is not added for tiny rocks.
DropsMoneyOnDestruction component added to rubble also except the tiny rocks.

Testing

  • Break the golden asteroid.
  • Observe that it does not collapse into tiny pieces of rocks straight away. Instead, it acts like normal asteroids in the game.
  • The smaller pieces when broken also drop loot.

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:

  • Code has been scanned with SonarLint
  • There are no errors present in the project
  • Code has been formatted and indented
  • Methods have appropriate Javadoc (How to write Javadoc)

@Mystic-Slice
Mystic-Slice force-pushed the RubbleSizeCount branch 4 times, most recently from 8f0cbdf to 52d2b8c Compare March 2, 2022 17:25
@Mystic-Slice Mystic-Slice changed the title fix #617(iii): Asteroids break into smaller pieces and then into tiny rocks fix #617(iii, iv): Asteroids break into smaller pieces and then into tiny rocks. Small pieces drop loot. Mar 2, 2022

@BenjaminAmos BenjaminAmos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

@BenjaminAmos BenjaminAmos Mar 2, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub doesn't let me comment on unchanged lines but you forgot to multiply by the parent size on line 129.

Vector2 position = new Vector2();
SolMath.fromAl(position, velocityAngle, SolRandom.randomFloat(size.size));
position.add(basePos);

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.

@Mystic-Slice

Copy link
Copy Markdown
Contributor Author

@BenjaminAmos Thnkx for the review. I have made the corrections.

@Mystic-Slice Mystic-Slice changed the title fix #617(iii, iv): Asteroids break into smaller pieces and then into tiny rocks. Small pieces drop loot. Asteroids break into smaller pieces and then into tiny rocks. Small pieces drop loot. Mar 3, 2022
…d then into tiny rocks. The smaller pieces also drop loot when destroyed.
@Mystic-Slice

Copy link
Copy Markdown
Contributor Author

Rebased to develop

@BenjaminAmos BenjaminAmos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NicholasBatesNZ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@NicholasBatesNZ
NicholasBatesNZ merged commit aab5e1f into MovingBlocks:develop Aug 14, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants