diff --git a/packages/pinball_components/lib/src/components/components.dart b/packages/pinball_components/lib/src/components/components.dart index 7b4e1ddd..36fe6954 100644 --- a/packages/pinball_components/lib/src/components/components.dart +++ b/packages/pinball_components/lib/src/components/components.dart @@ -21,6 +21,7 @@ export 'launch_ramp.dart'; export 'layer.dart'; export 'plunger.dart'; export 'ramp_opening.dart'; +export 'render_priority.dart'; export 'rocket.dart'; export 'score_text.dart'; export 'shapes/shapes.dart'; diff --git a/packages/pinball_components/lib/src/components/render_priority.dart b/packages/pinball_components/lib/src/components/render_priority.dart new file mode 100644 index 00000000..9de5be9d --- /dev/null +++ b/packages/pinball_components/lib/src/components/render_priority.dart @@ -0,0 +1,109 @@ +// ignore_for_file: public_member_api_docs + +import 'package:pinball_components/pinball_components.dart'; + +/// {@template render_priority} +/// Priorities for the component rendering order in the pinball game. +/// {@endtemplate} +abstract class RenderPriority { + static const _base = 0; + static const _above = 1; + static const _below = -1; + + // BALL + + /// Render priority for the [Ball] while it's on the board. + static const int ballOnBoard = _base; + + /// Render priority for the [Ball] while it's on the [SpaceshipRamp]. + static const int ballOnSpaceshipRamp = + _above + spaceshipRampBackgroundRailing; + + /// Render priority for the [Ball] while it's on the [Spaceship]. + static const int ballOnSpaceship = _above + spaceshipSaucer; + + /// Render priority for the [Ball] while it's on the [SpaceshipRail]. + static const int ballOnSpaceshipRail = spaceshipRail; + + /// Render priority for the [Ball] while it's on the [LaunchRamp]. + static const int ballOnLaunchRamp = _above + launchRamp; + + // BACKGROUND + + static const int background = 3 * _below + _base; + + // BOUNDARIES + + static const int bottomBoundary = _above + dinoBottomWall; + + static const int outerBoudary = _above + background; + + // BOTTOM GROUP + + static const int bottomGroup = _above + ballOnBoard; + + // LAUNCHER + + static const int launchRamp = _above + outerBoudary; + + static const int launchRampForegroundRailing = _above + ballOnLaunchRamp; + + static const int plunger = _above + launchRamp; + + static const int rocket = _above + bottomBoundary; + + // DINO LAND + + static const int dinoTopWall = _above + ballOnBoard; + + static const int dino = _above + dinoTopWall; + + static const int dinoBottomWall = _above + dino; + + static const int slingshot = _above + ballOnBoard; + + // FLUTTER FOREST + + static const int flutterSignPost = _above + launchRampForegroundRailing; + + static const int dashBumper = _above + ballOnBoard; + + static const int dashAnimatronic = _above + launchRampForegroundRailing; + + // SPARKY FIRE ZONE + + static const int computerBase = _below + ballOnBoard; + + static const int computerTop = _above + ballOnBoard; + + static const int sparkyAnimatronic = _above + spaceshipRampForegroundRailing; + + static const int sparkyBumper = _above + ballOnBoard; + + // ANDROID SPACESHIP + + static const int spaceshipRail = _above + bottomGroup; + + static const int spaceshipRailForeground = _above + spaceshipRail; + + static const int spaceshipSaucer = _above + spaceshipRail; + + static const int spaceshipSaucerWall = _above + spaceshipSaucer; + + static const int androidHead = _above + spaceshipSaucer; + + static const int spaceshipRamp = _above + ballOnBoard; + + static const int spaceshipRampBackgroundRailing = _above + spaceshipRamp; + + static const int spaceshipRampForegroundRailing = + _above + ballOnSpaceshipRamp; + + static const int spaceshipRampBoardOpening = _below + ballOnBoard; + + static const int alienBumper = _above + ballOnBoard; + + // SCORE TEXT + + static const int scoreText = _above + spaceshipRampForegroundRailing; +} diff --git a/packages/pinball_components/lib/src/flame/priority.dart b/packages/pinball_components/lib/src/flame/priority.dart index 25d2855a..e68b72f0 100644 --- a/packages/pinball_components/lib/src/flame/priority.dart +++ b/packages/pinball_components/lib/src/flame/priority.dart @@ -1,115 +1,6 @@ -// ignore_for_file: public_member_api_docs - import 'dart:math' as math; import 'package:flame/components.dart'; -import 'package:pinball_components/pinball_components.dart'; - -/// {@template render_priority} -/// Priorities for the component rendering order in the pinball game. -/// {@endtemplate} -abstract class RenderPriority { - static const _base = 0; - static const _above = 1; - static const _below = -1; - - // BALL - - /// Render priority for the [Ball] while it's on the board. - static const int ballOnBoard = _base; - - /// Render priority for the [Ball] while it's on the [SpaceshipRamp]. - static const int ballOnSpaceshipRamp = - _above + spaceshipRampBackgroundRailing; - - /// Render priority for the [Ball] while it's on the [Spaceship]. - static const int ballOnSpaceship = _above + spaceshipSaucer; - - /// Render priority for the [Ball] while it's on the [SpaceshipRail]. - static const int ballOnSpaceshipRail = spaceshipRail; - - /// Render priority for the [Ball] while it's on the [LaunchRamp]. - static const int ballOnLaunchRamp = _above + launchRamp; - - // BACKGROUND - - static const int background = 3 * _below + _base; - - // BOUNDARIES - - static const int bottomBoundary = _above + dinoBottomWall; - - static const int outerBoudary = _above + background; - - // BOTTOM GROUP - - static const int bottomGroup = _above + ballOnBoard; - - // LAUNCHER - - static const int launchRamp = _above + outerBoudary; - - static const int launchRampForegroundRailing = _above + ballOnLaunchRamp; - - static const int plunger = _above + launchRamp; - - static const int rocket = _above + bottomBoundary; - - // DINO LAND - - static const int dinoTopWall = _above + ballOnBoard; - - static const int dino = _above + dinoTopWall; - - static const int dinoBottomWall = _above + dino; - - static const int slingshot = _above + ballOnBoard; - - // FLUTTER FOREST - - static const int flutterSignPost = _above + launchRampForegroundRailing; - - static const int dashBumper = _above + ballOnBoard; - - static const int dashAnimatronic = _above + launchRampForegroundRailing; - - // SPARKY FIRE ZONE - - static const int computerBase = _below + ballOnBoard; - - static const int computerTop = _above + ballOnBoard; - - static const int sparkyAnimatronic = _above + spaceshipRampForegroundRailing; - - static const int sparkyBumper = _above + ballOnBoard; - - // ANDROID SPACESHIP - - static const int spaceshipRail = _above + bottomGroup; - - static const int spaceshipRailForeground = _above + spaceshipRail; - - static const int spaceshipSaucer = _above + spaceshipRail; - - static const int spaceshipSaucerWall = _above + spaceshipSaucer; - - static const int androidHead = _above + spaceshipSaucer; - - static const int spaceshipRamp = _above + ballOnBoard; - - static const int spaceshipRampBackgroundRailing = _above + spaceshipRamp; - - static const int spaceshipRampForegroundRailing = - _above + ballOnSpaceshipRamp; - - static const int spaceshipRampBoardOpening = _below + ballOnBoard; - - static const int alienBumper = _above + ballOnBoard; - - // SCORE TEXT - - static const int scoreText = _above + spaceshipRampForegroundRailing; -} /// Helper methods to change the [priority] of a [Component]. extension ComponentPriorityX on Component {