Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix MovingBlocks#617(iii, iv): Asteroids break into smaller pieces an…
Browse files Browse the repository at this point in the history
…d then into tiny rocks. The smaller pieces also drop loot when destroyed.
Mystic-Slice committed Mar 2, 2022
1 parent 62b07db commit 0a2949c
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
import org.destinationsol.location.components.Angle;
import org.destinationsol.location.components.Position;
import org.destinationsol.location.components.Velocity;
import org.destinationsol.moneyDropping.components.DropsMoneyOnDestruction;
import org.destinationsol.removal.events.DeletionEvent;
import org.destinationsol.removal.systems.DestructionSystem;
import org.destinationsol.rendering.RenderableElement;
@@ -51,9 +52,9 @@
*/
public class RubbleCreationSystem implements EventReceiver {

public static final float SIZE_TO_RUBBLE_COUNT = 13f;
public static final float MIN_SCALE = .07f;
public static final float MAX_SCALE = .12f;
public static final float SIZE_TO_RUBBLE_COUNT = 8f;
public static final float MIN_SCALE = .1f;
public static final float MAX_SCALE = .3f;
private static final float MAX_SPD = 40f;

@In
@@ -115,7 +116,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
element.graphicsOffset = new Vector2();

float scale = SolRandom.randomFloat(MIN_SCALE, MAX_SCALE);
element.setSize(scale);
element.setSize(scale * size.size);

element.relativePosition = new Vector2();
element.tint = Color.WHITE;
@@ -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;

//Create velocity component
Velocity velocityComponent = new Velocity();
@@ -145,7 +146,13 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
velocityComponent.velocity = velocity;

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

if(sizeComponent.size > 0.1) {
entityRef.setComponent(new CreatesRubbleOnDestruction());
entityRef.setComponent(new DropsMoneyOnDestruction());
}

SolMath.free(velocity);
entityRef.setComponent(new BodyLinked());
}

0 comments on commit 0a2949c

Please sign in to comment.