From dd666d68900084c8f12f8fe55bee3eafa6957144 Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Thu, 31 Mar 2022 21:26:57 +0200 Subject: [PATCH] chore: renamed pathwayLayer and pathwayPriority to inside --- lib/game/components/jetpack_ramp.dart | 2 +- lib/game/components/launcher_ramp.dart | 2 +- lib/game/components/spaceship_exit_rail.dart | 2 +- .../lib/src/components/ramp_opening.dart | 31 +++++++++---------- .../lib/src/components/spaceship.dart | 8 ++--- .../src/components/ramp_opening_test.dart | 14 ++++----- .../test/src/components/spaceship_test.dart | 4 +-- 7 files changed, 31 insertions(+), 32 deletions(-) diff --git a/lib/game/components/jetpack_ramp.dart b/lib/game/components/jetpack_ramp.dart index 4c4c8be9..aa5a9dbd 100644 --- a/lib/game/components/jetpack_ramp.dart +++ b/lib/game/components/jetpack_ramp.dart @@ -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, ); diff --git a/lib/game/components/launcher_ramp.dart b/lib/game/components/launcher_ramp.dart index 79b7c831..c05f8aa2 100644 --- a/lib/game/components/launcher_ramp.dart +++ b/lib/game/components/launcher_ramp.dart @@ -122,7 +122,7 @@ class _LauncherRampOpening extends RampOpening { required double rotation, }) : _rotation = rotation, super( - pathwayLayer: Layer.launcher, + insideLayer: Layer.launcher, orientation: RampOrientation.down, ); diff --git a/lib/game/components/spaceship_exit_rail.dart b/lib/game/components/spaceship_exit_rail.dart index 0dc38322..4a6c44cd 100644 --- a/lib/game/components/spaceship_exit_rail.dart +++ b/lib/game/components/spaceship_exit_rail.dart @@ -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; diff --git a/packages/pinball_components/lib/src/components/ramp_opening.dart b/packages/pinball_components/lib/src/components/ramp_opening.dart index 1ad07489..3ae5fb3a 100644 --- a/packages/pinball_components/lib/src/components/ramp_opening.dart +++ b/packages/pinball_components/lib/src/components/ramp_opening.dart @@ -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 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); diff --git a/packages/pinball_components/lib/src/components/spaceship.dart b/packages/pinball_components/lib/src/components/spaceship.dart index d753f639..4d84eb68 100644 --- a/packages/pinball_components/lib/src/components/spaceship.dart +++ b/packages/pinball_components/lib/src/components/spaceship.dart @@ -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; } } diff --git a/packages/pinball_components/test/src/components/ramp_opening_test.dart b/packages/pinball_components/test/src/components/ramp_opening_test.dart index e0ea71e5..cb42203a 100644 --- a/packages/pinball_components/test/src/components/ramp_opening_test.dart +++ b/packages/pinball_components/test/src/components/ramp_opening_test.dart @@ -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); diff --git a/packages/pinball_components/test/src/components/spaceship_test.dart b/packages/pinball_components/test/src/components/spaceship_test.dart index fa995b63..4d980c69 100644 --- a/packages/pinball_components/test/src/components/spaceship_test.dart +++ b/packages/pinball_components/test/src/components/spaceship_test.dart @@ -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); }); });