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

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Mystic-Slice
Copy link
Contributor

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

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
Copy link
Contributor

@BenjaminAmos BenjaminAmos left a comment

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.

@@ -146,6 +147,12 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz

EntityRef entityRef = entitySystemManager.getEntityManager().createEntity(graphicsComponent, positionComponent,
velocityComponent, angle, sizeComponent, new RubbleMesh());

if(sizeComponent.size > 0.1) {
Copy link
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.

@@ -136,7 +137,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz

//Create size component
Size sizeComponent = new Size();
sizeComponent.size = scale;
sizeComponent.size = scale * size.size;
Copy link
Contributor

@BenjaminAmos BenjaminAmos Mar 2, 2022

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
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
Contributor Author

Rebased to develop

Copy link
Contributor

@BenjaminAmos BenjaminAmos left a comment

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,

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.

2 participants