chore: renamed pathwayLayer and pathwayPriority to inside

pull/83/head
RuiAlonso 4 years ago
parent 4f321ee6f7
commit dd666d6890

@ -107,7 +107,7 @@ class _JetpackRampOpening extends RampOpening {
required double rotation,
}) : _rotation = rotation,
super(
pathwayLayer: Layer.jetpack,
insideLayer: Layer.jetpack,
outsideLayer: outsideLayer,
orientation: RampOrientation.down,
);

@ -122,7 +122,7 @@ class _LauncherRampOpening extends RampOpening {
required double rotation,
}) : _rotation = rotation,
super(
pathwayLayer: Layer.launcher,
insideLayer: Layer.launcher,
orientation: RampOrientation.down,
);

@ -169,7 +169,7 @@ class SpaceshipExitRailEnd extends RampOpening {
/// {@macro spaceship_exit_rail_end}
SpaceshipExitRailEnd()
: super(
pathwayLayer: Layer.spaceshipExitRail,
insideLayer: Layer.spaceshipExitRail,
orientation: RampOrientation.down,
) {
layer = Layer.spaceshipExitRail;

@ -27,32 +27,32 @@ enum RampOrientation {
abstract class RampOpening extends BodyComponent with InitialPosition, Layered {
/// {@macro ramp_opening}
RampOpening({
required Layer pathwayLayer,
required Layer insideLayer,
Layer? outsideLayer,
int? pathwayPriority,
int? insidePriority,
int? outsidePriority,
required this.orientation,
}) : _pathwayLayer = pathwayLayer,
}) : _insideLayer = insideLayer,
_outsideLayer = outsideLayer ?? Layer.board,
_pathwayPriority = pathwayPriority ?? 0,
_insidePriority = insidePriority ?? 0,
_outsidePriority = outsidePriority ?? 0 {
layer = Layer.opening;
}
final Layer _pathwayLayer;
final Layer _insideLayer;
final Layer _outsideLayer;
final int _pathwayPriority;
final int _insidePriority;
final int _outsidePriority;
/// Mask of category bits for collision inside pathway.
Layer get pathwayLayer => _pathwayLayer;
/// Mask of category bits for collision inside ramp.
Layer get insideLayer => _insideLayer;
/// Mask of category bits for collision outside pathway.
/// Mask of category bits for collision outside ramp.
Layer get outsideLayer => _outsideLayer;
/// Priority for the [Ball] inside pathway.
int get pathwayPriority => _pathwayPriority;
/// Priority for the [Ball] inside ramp.
int get insidePriority => _insidePriority;
/// Priority for the [Ball] outside pathway.
/// Priority for the [Ball] outside ramp.
int get outsidePriority => _outsidePriority;
/// The [Shape] of the [RampOpening].
@ -77,8 +77,7 @@ abstract class RampOpening extends BodyComponent with InitialPosition, Layered {
}
/// {@template ramp_opening_ball_contact_callback}
/// Detects when a [Ball] enters or exits a pathway ramp through a
/// [RampOpening].
/// Detects when a [Ball] enters or exits a ramp through a [RampOpening].
///
/// Modifies [Ball]'s [Layer] accordingly depending on whether the [Ball] is
/// outside or inside a ramp.
@ -93,10 +92,10 @@ class RampOpeningBallContactCallback<Opening extends RampOpening>
Layer layer;
if (!_ballsInside.contains(ball)) {
layer = opening.pathwayLayer;
layer = opening.insideLayer;
_ballsInside.add(ball);
ball
..sendTo(opening.pathwayPriority)
..sendTo(opening.insidePriority)
..layer = layer;
} else {
_ballsInside.remove(ball);

@ -150,9 +150,9 @@ class SpaceshipEntrance extends RampOpening {
/// {@macro spaceship_entrance}
SpaceshipEntrance()
: super(
pathwayLayer: Layer.spaceship,
insideLayer: Layer.spaceship,
orientation: RampOrientation.up,
pathwayPriority: Spaceship.ballPriorityWhenOnSpaceship,
insidePriority: Spaceship.ballPriorityWhenOnSpaceship,
) {
layer = Layer.spaceship;
}
@ -183,7 +183,7 @@ class SpaceshipHole extends RampOpening {
/// {@macro spaceship_hole}
SpaceshipHole({Layer? outsideLayer, int? outsidePriority = 1})
: super(
pathwayLayer: Layer.spaceship,
insideLayer: Layer.spaceship,
outsideLayer: outsideLayer,
outsidePriority: outsidePriority,
orientation: RampOrientation.up,
@ -266,7 +266,7 @@ class SpaceshipEntranceBallContactCallback
@override
void begin(SpaceshipEntrance entrance, Ball ball, _) {
ball
..sendTo(entrance.pathwayPriority)
..sendTo(entrance.insidePriority)
..layer = Layer.spaceship;
}
}

@ -12,7 +12,7 @@ class TestRampOpening extends RampOpening {
required RampOrientation orientation,
required Layer pathwayLayer,
}) : super(
pathwayLayer: pathwayLayer,
insideLayer: pathwayLayer,
orientation: orientation,
);
@ -134,7 +134,7 @@ void main() {
when(() => ball.layer).thenReturn(Layer.board);
callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1);
verify(() => ball.layer = area.insideLayer).called(1);
});
flameTester.test(
@ -155,7 +155,7 @@ void main() {
when(() => ball.layer).thenReturn(Layer.board);
callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1);
verify(() => ball.layer = area.insideLayer).called(1);
});
flameTester.test(
@ -176,7 +176,7 @@ void main() {
when(() => ball.layer).thenReturn(Layer.board);
callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1);
verify(() => ball.layer = area.insideLayer).called(1);
callback.end(ball, area, MockContact());
verify(() => ball.layer = Layer.board);
@ -200,7 +200,7 @@ void main() {
when(() => ball.layer).thenReturn(Layer.board);
callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1);
verify(() => ball.layer = area.insideLayer).called(1);
callback.end(ball, area, MockContact());
verify(() => ball.layer = Layer.board);
@ -224,13 +224,13 @@ void main() {
when(() => ball.layer).thenReturn(Layer.board);
callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1);
verify(() => ball.layer = area.insideLayer).called(1);
callback.end(ball, area, MockContact());
verifyNever(() => ball.layer = Layer.board);
callback.begin(ball, area, MockContact());
verifyNever(() => ball.layer = area.pathwayLayer);
verifyNever(() => ball.layer = area.insideLayer);
callback.end(ball, area, MockContact());
verify(() => ball.layer = Layer.board);

@ -60,7 +60,7 @@ void main() {
group('SpaceshipEntranceBallContactCallback', () {
test('changes the ball priority on contact', () {
when(() => ball.priority).thenReturn(2);
when(() => entrance.pathwayPriority).thenReturn(3);
when(() => entrance.insidePriority).thenReturn(3);
SpaceshipEntranceBallContactCallback().begin(
entrance,
@ -68,7 +68,7 @@ void main() {
MockContact(),
);
verify(() => ball.sendTo(entrance.pathwayPriority)).called(1);
verify(() => ball.sendTo(entrance.insidePriority)).called(1);
});
});

Loading…
Cancel
Save