Skip to content

Commit 58cbfde

Browse files
committed
Code fixes
1 parent e2900e3 commit 58cbfde

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
public class RubbleCreationSystem implements EventReceiver {
5454

5555
public static final float SIZE_TO_RUBBLE_COUNT = 8f;
56+
public static final float MIN_DIVISIBLE_SIZE = .1f;
5657
public static final float MIN_SCALE = .1f;
5758
public static final float MAX_SCALE = .3f;
5859
private static final float MAX_SPD = 40f;
@@ -116,7 +117,8 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
116117
element.graphicsOffset = new Vector2();
117118

118119
float scale = SolRandom.randomFloat(MIN_SCALE, MAX_SCALE);
119-
element.setSize(scale * size.size);
120+
float scaledSize = scale * size.size;
121+
element.setSize(scaledSize);
120122

121123
element.relativePosition = new Vector2();
122124
element.tint = Color.WHITE;
@@ -126,7 +128,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
126128
//Create position component
127129
float velocityAngle = SolRandom.randomFloat(180);
128130
Vector2 position = new Vector2();
129-
SolMath.fromAl(position, velocityAngle, SolRandom.randomFloat(size.size));
131+
SolMath.fromAl(position, velocityAngle, SolRandom.randomFloat(scaledSize));
130132
position.add(basePos);
131133
Position positionComponent = new Position();
132134
positionComponent.position = position;
@@ -137,7 +139,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
137139

138140
//Create size component
139141
Size sizeComponent = new Size();
140-
sizeComponent.size = scale * size.size;
142+
sizeComponent.size = scaledSize;
141143

142144
//Create velocity component
143145
Velocity velocityComponent = new Velocity();
@@ -148,7 +150,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
148150
EntityRef entityRef = entitySystemManager.getEntityManager().createEntity(graphicsComponent, positionComponent,
149151
sizeComponent, angle, velocityComponent, new RubbleMesh(), health);
150152

151-
if (sizeComponent.size > 0.1) {
153+
if (scaledSize > MIN_DIVISIBLE_SIZE) {
152154
entityRef.setComponent(new CreatesRubbleOnDestruction());
153155
entityRef.setComponent(new DropsMoneyOnDestruction());
154156
}

0 commit comments

Comments
 (0)