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, required double rotation,
}) : _rotation = rotation, }) : _rotation = rotation,
super( super(
pathwayLayer: Layer.jetpack, insideLayer: Layer.jetpack,
outsideLayer: outsideLayer, outsideLayer: outsideLayer,
orientation: RampOrientation.down, orientation: RampOrientation.down,
); );

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

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

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

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

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

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

Loading…
Cancel
Save