Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -51,9 +52,10 @@
*/
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_DIVISIBLE_SIZE = .1f;
public static final float MIN_SCALE = .1f;
public static final float MAX_SCALE = .3f;
private static final float MAX_SPD = 40f;

@In
Expand Down Expand Up @@ -115,7 +117,8 @@ 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);
float scaledSize = scale * size.size;
element.setSize(scaledSize);

element.relativePosition = new Vector2();
element.tint = Color.WHITE;
Expand All @@ -125,7 +128,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
//Create position component
float velocityAngle = SolRandom.randomFloat(180);
Vector2 position = new Vector2();
SolMath.fromAl(position, velocityAngle, SolRandom.randomFloat(size.size));
SolMath.fromAl(position, velocityAngle, SolRandom.randomFloat(scaledSize));
position.add(basePos);
Position positionComponent = new Position();
positionComponent.position = position;
Expand All @@ -136,7 +139,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz

//Create size component
Size sizeComponent = new Size();
sizeComponent.size = scale;
sizeComponent.size = scaledSize;

//Create velocity component
Velocity velocityComponent = new Velocity();
Expand All @@ -147,6 +150,11 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
EntityRef entityRef = entitySystemManager.getEntityManager().createEntity(graphicsComponent, positionComponent,
sizeComponent, angle, velocityComponent, new RubbleMesh(), health);

if (scaledSize > MIN_DIVISIBLE_SIZE) {
entityRef.setComponent(new CreatesRubbleOnDestruction());
entityRef.setComponent(new DropsMoneyOnDestruction());
}

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