Skip to content

Commit 8f0cbdf

Browse files
committed
fix #617(iii, iv): Asteroids break into smaller pieces and then into tiny rocks. The smaller pieces also drop loot when destroyed.
1 parent 62b07db commit 8f0cbdf

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

engine/src/main/java/org/destinationsol/rubble/systems/RubbleCreationSystem.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.destinationsol.location.components.Angle;
3333
import org.destinationsol.location.components.Position;
3434
import org.destinationsol.location.components.Velocity;
35+
import org.destinationsol.moneyDropping.components.DropsMoneyOnDestruction;
3536
import org.destinationsol.removal.events.DeletionEvent;
3637
import org.destinationsol.removal.systems.DestructionSystem;
3738
import org.destinationsol.rendering.RenderableElement;
@@ -51,9 +52,9 @@
5152
*/
5253
public class RubbleCreationSystem implements EventReceiver {
5354

54-
public static final float SIZE_TO_RUBBLE_COUNT = 13f;
55-
public static final float MIN_SCALE = .07f;
56-
public static final float MAX_SCALE = .12f;
55+
public static final float SIZE_TO_RUBBLE_COUNT = 8f;
56+
public static final float MIN_SCALE = .1f;
57+
public static final float MAX_SCALE = .3f;
5758
private static final float MAX_SPD = 40f;
5859

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

117118
float scale = SolRandom.randomFloat(MIN_SCALE, MAX_SCALE);
118-
element.setSize(scale);
119+
element.setSize(scale * size.size);
119120

120121
element.relativePosition = new Vector2();
121122
element.tint = Color.WHITE;
@@ -136,7 +137,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
136137

137138
//Create size component
138139
Size sizeComponent = new Size();
139-
sizeComponent.size = scale;
140+
sizeComponent.size = scale * size.size;
140141

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

147148
EntityRef entityRef = entitySystemManager.getEntityManager().createEntity(graphicsComponent, positionComponent,
148-
velocityComponent, angle, sizeComponent, new RubbleMesh());
149+
velocityComponent, angle, sizeComponent, new RubbleMesh(), health);
150+
151+
if(sizeComponent.size > 0.1) {
152+
entityRef.setComponent(new CreatesRubbleOnDestruction());
153+
entityRef.setComponent(new DropsMoneyOnDestruction());
154+
}
155+
149156
SolMath.free(velocity);
150157
entityRef.setComponent(new BodyLinked());
151158
}

0 commit comments

Comments
 (0)