fix: modified rampopening for priority changes

pull/126/head
RuiAlonso 4 years ago
parent 022adb5f8e
commit 2095e90f8a

@ -124,6 +124,7 @@ class _LauncherRampOpening extends RampOpening {
super(
pathwayLayer: Layer.launcher,
orientation: RampOrientation.down,
pathwayPriority: 4,
);
final double _rotation;

@ -171,6 +171,7 @@ class SpaceshipExitRailEnd extends RampOpening {
: super(
pathwayLayer: Layer.spaceshipExitRail,
orientation: RampOrientation.down,
pathwayPriority: 3,
) {
layer = Layer.spaceshipExitRail;
}

@ -27,12 +27,18 @@ abstract class RampOpening extends BodyComponent with InitialPosition, Layered {
/// {@macro ramp_opening}
RampOpening({
required Layer pathwayLayer,
required int pathwayPriority,
Layer? outsideLayer,
int? outsidePriority,
required this.orientation,
}) : _pathwayLayer = pathwayLayer,
_outsideLayer = outsideLayer ?? Layer.board {
_outsideLayer = outsideLayer ?? Layer.board,
_pathwayPriority = pathwayPriority,
_outsidePriority = outsidePriority ?? 1 {
layer = Layer.board;
}
final int _pathwayPriority;
final int _outsidePriority;
final Layer _pathwayLayer;
final Layer _outsideLayer;
@ -42,6 +48,12 @@ abstract class RampOpening extends BodyComponent with InitialPosition, Layered {
/// Mask of category bits for collision outside pathway.
Layer get outsideLayer => _outsideLayer;
/// Mask of category bits for collision outside pathway.
int get pathwayPriority => _pathwayPriority;
/// Mask of category bits for collision outside pathway.
int get outsidePriority => _outsidePriority;
/// The [Shape] of the [RampOpening].
Shape get shape;
@ -82,7 +94,9 @@ class RampOpeningBallContactCallback<Opening extends RampOpening>
if (!_ballsInside.contains(ball)) {
layer = opening.pathwayLayer;
_ballsInside.add(ball);
ball.layer = layer;
ball
..layer = layer
..priority = opening.pathwayPriority;
} else {
_ballsInside.remove(ball);
}
@ -103,7 +117,9 @@ class RampOpeningBallContactCallback<Opening extends RampOpening>
ball.body.linearVelocity.y > 0);
if (isBallOutsideOpening) {
ball.layer = opening.outsideLayer;
ball
..layer = opening.outsideLayer
..priority = opening.outsidePriority;
_ballsInside.remove(ball);
}
}

@ -149,14 +149,11 @@ class SpaceshipEntrance extends RampOpening {
: super(
pathwayLayer: Layer.spaceship,
orientation: RampOrientation.up,
pathwayPriority: 4,
) {
layer = Layer.spaceship;
}
/// Priority order for [SpaceshipHole] on enter.
// TODO(ruimiguel): apply Elevated when PR merged.
final int onEnterElevation = 4;
@override
Shape get shape {
renderBody = false;
@ -186,6 +183,8 @@ class SpaceshipHole extends RampOpening {
pathwayLayer: Layer.spaceship,
outsideLayer: onExitLayer,
orientation: RampOrientation.up,
pathwayPriority: 4,
outsidePriority: onExitElevation,
) {
layer = Layer.spaceship;
}
@ -269,8 +268,7 @@ class SpaceshipEntranceBallContactCallback
@override
void begin(SpaceshipEntrance entrance, Ball ball, _) {
ball
// TODO(ruimiguel): apply Elevated when PR merged.
..priority = entrance.onEnterElevation
..priority = entrance.pathwayPriority
..gameRef.reorderChildren()
..layer = Layer.spaceship;
}
@ -287,7 +285,7 @@ class SpaceshipHoleBallContactCallback
void begin(SpaceshipHole hole, Ball ball, _) {
ball
// TODO(ruimiguel): apply Elevated when PR merged.
..priority = hole.onExitElevation
..priority = hole.outsidePriority
..gameRef.reorderChildren()
..layer = hole.outsideLayer;
}

Loading…
Cancel
Save