chore: rename priority class

pull/198/head
Allison Ryan 3 years ago
parent b16b5afcb1
commit 8ce61013cf

@ -42,7 +42,7 @@ class Board extends Component {
// TODO(alestiago): Consider renaming once entire Board is defined.
class _BottomGroup extends Component {
/// {@macro bottom_group}
_BottomGroup() : super(priority: PinballPriority.bottomGroup);
_BottomGroup() : super(priority: RenderPriority.bottomGroup);
@override
Future<void> onLoad() async {

@ -18,7 +18,7 @@ class ControlledBall extends Ball with Controls<BallController> {
required PinballTheme theme,
}) : super(baseColor: theme.characterTheme.ballColor) {
controller = BallController(this);
priority = PinballPriority.ballOnLaunchRamp;
priority = RenderPriority.ballOnLaunchRamp;
layer = Layer.launcher;
}
@ -31,13 +31,13 @@ class ControlledBall extends Ball with Controls<BallController> {
required PinballTheme theme,
}) : super(baseColor: theme.characterTheme.ballColor) {
controller = BallController(this);
priority = PinballPriority.ballOnBoard;
priority = RenderPriority.ballOnBoard;
}
/// [Ball] used in [DebugPinballGame].
ControlledBall.debug() : super(baseColor: const Color(0xFFFF0000)) {
controller = DebugBallController(this);
priority = PinballPriority.ballOnBoard;
priority = RenderPriority.ballOnBoard;
}
}

@ -165,7 +165,7 @@ class DebugPinballGame extends PinballGame with TapDetector {
anchor: Anchor.center,
)
..position = Vector2(0, -7.8)
..priority = PinballPriority.background;
..priority = RenderPriority.background;
await add(spriteComponent);
}

@ -19,7 +19,7 @@ class AlienBumper extends BodyComponent with InitialPosition {
_activeAssetPath = activeAssetPath,
_inactiveAssetPath = inactiveAssetPath,
_spriteComponent = spriteComponent,
super(priority: PinballPriority.alienBumper);
super(priority: RenderPriority.alienBumper);
/// {@macro alien_bumper}
AlienBumper.a()

@ -23,7 +23,7 @@ class Boundaries extends Forge2DBlueprint {
/// {@endtemplate bottom_boundary}
class _BottomBoundary extends BodyComponent with InitialPosition {
/// {@macro bottom_boundary}
_BottomBoundary() : super(priority: PinballPriority.bottomBoundary);
_BottomBoundary() : super(priority: RenderPriority.bottomBoundary);
List<FixtureDef> _createFixtureDefs() {
final fixturesDefs = <FixtureDef>[];
@ -88,7 +88,7 @@ class _BottomBoundarySpriteComponent extends SpriteComponent with HasGameRef {
/// {@endtemplate outer_boundary}
class _OuterBoundary extends BodyComponent with InitialPosition {
/// {@macro outer_boundary}
_OuterBoundary() : super(priority: PinballPriority.outerBoudary);
_OuterBoundary() : super(priority: RenderPriority.outerBoudary);
List<FixtureDef> _createFixtureDefs() {
final fixturesDefs = <FixtureDef>[];

@ -16,7 +16,7 @@ class ChromeDino extends BodyComponent with InitialPosition {
: super(
// TODO(alestiago): Remove once sprites are defined.
paint: Paint()..color = Colors.blue,
priority: PinballPriority.dino,
priority: RenderPriority.dino,
);
/// The size of the dinosaur mouth.

@ -10,7 +10,7 @@ class DashAnimatronic extends SpriteAnimationComponent with HasGameRef {
: super(
anchor: Anchor.center,
playing: false,
priority: PinballPriority.dashAnimatronic,
priority: RenderPriority.dashAnimatronic,
);
@override

@ -16,7 +16,7 @@ abstract class DashNestBumper extends BodyComponent with InitialPosition {
}) : _activeAssetPath = activeAssetPath,
_inactiveAssetPath = inactiveAssetPath,
_spriteComponent = spriteComponent,
super(priority: PinballPriority.dashBumper);
super(priority: RenderPriority.dashBumper);
final String _activeAssetPath;
late final Sprite _activeSprite;

@ -28,7 +28,7 @@ class DinoWalls extends Forge2DBlueprint {
/// {@endtemplate}
class _DinoTopWall extends BodyComponent with InitialPosition {
///{@macro dino_top_wall}
_DinoTopWall() : super(priority: PinballPriority.dinoTopWall);
_DinoTopWall() : super(priority: RenderPriority.dinoTopWall);
List<FixtureDef> _createFixtureDefs() {
final fixturesDef = <FixtureDef>[];
@ -124,7 +124,7 @@ class _DinoTopWallSpriteComponent extends SpriteComponent with HasGameRef {
/// {@endtemplate}
class _DinoBottomWall extends BodyComponent with InitialPosition {
///{@macro dino_top_wall}
_DinoBottomWall() : super(priority: PinballPriority.dinoBottomWall);
_DinoBottomWall() : super(priority: RenderPriority.dinoBottomWall);
List<FixtureDef> _createFixtureDefs() {
final fixturesDef = <FixtureDef>[];

@ -7,7 +7,7 @@ import 'package:pinball_components/pinball_components.dart';
/// {@endtemplate}
class FlutterSignPost extends BodyComponent with InitialPosition {
/// {@macro flutter_sign_post}
FlutterSignPost() : super(priority: PinballPriority.flutterSignPost);
FlutterSignPost() : super(priority: RenderPriority.flutterSignPost);
@override
Future<void> onLoad() async {

@ -41,7 +41,7 @@ class LaunchRamp extends Forge2DBlueprint {
/// {@endtemplate}
class _LaunchRampBase extends BodyComponent with InitialPosition, Layered {
/// {@macro launch_ramp_base}
_LaunchRampBase() : super(priority: PinballPriority.launchRamp) {
_LaunchRampBase() : super(priority: RenderPriority.launchRamp) {
layer = Layer.launcher;
}
@ -144,7 +144,7 @@ class _LaunchRampBaseSpriteComponent extends SpriteComponent with HasGameRef {
class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition {
/// {@macro launch_ramp_foreground_railing}
_LaunchRampForegroundRailing()
: super(priority: PinballPriority.launchRampForegroundRailing);
: super(priority: RenderPriority.launchRampForegroundRailing);
List<FixtureDef> _createFixtureDefs() {
final fixturesDef = <FixtureDef>[];
@ -247,8 +247,8 @@ class _LaunchRampExit extends RampOpening {
insideLayer: Layer.launcher,
outsideLayer: Layer.board,
orientation: RampOrientation.down,
insidePriority: PinballPriority.ballOnLaunchRamp,
outsidePriority: PinballPriority.ballOnBoard,
insidePriority: RenderPriority.ballOnLaunchRamp,
outsidePriority: RenderPriority.ballOnBoard,
) {
layer = Layer.launcher;
renderBody = false;

@ -14,7 +14,7 @@ class Plunger extends BodyComponent with InitialPosition, Layered {
required this.compressionDistance,
// TODO(ruimiguel): set to priority +1 over LaunchRamp once all priorities
// are fixed.
}) : super(priority: PinballPriority.plunger) {
}) : super(priority: RenderPriority.plunger) {
layer = Layer.launcher;
}

@ -35,7 +35,7 @@ abstract class RampOpening extends BodyComponent with InitialPosition, Layered {
}) : _insideLayer = insideLayer,
_outsideLayer = outsideLayer ?? Layer.board,
_insidePriority = insidePriority,
_outsidePriority = outsidePriority ?? PinballPriority.ballOnBoard {
_outsidePriority = outsidePriority ?? RenderPriority.ballOnBoard {
layer = Layer.opening;
}
final Layer _insideLayer;

@ -9,7 +9,7 @@ class RocketSpriteComponent extends SpriteComponent with HasGameRef {
// TODO(ruimiguel): change this priority to be over launcher ramp and bottom
// wall.
/// {@macro rocket_sprite_component}
RocketSpriteComponent() : super(priority: PinballPriority.rocket);
RocketSpriteComponent() : super(priority: RenderPriority.rocket);
@override
Future<void> onLoad() async {

@ -18,7 +18,7 @@ class ScoreText extends TextComponent {
text: text,
position: position,
anchor: Anchor.center,
priority: PinballPriority.scoreText,
priority: RenderPriority.scoreText,
);
late final Effect _effect;

@ -42,7 +42,7 @@ class Slingshot extends BodyComponent with InitialPosition {
}) : _length = length,
_angle = angle,
_spritePath = spritePath,
super(priority: PinballPriority.slingshot);
super(priority: RenderPriority.slingshot);
final double _length;

@ -34,7 +34,7 @@ class Spaceship extends Forge2DBlueprint {
AndroidHead()..initialPosition = position,
SpaceshipHole(
outsideLayer: Layer.spaceshipExitRail,
outsidePriority: PinballPriority.ballOnSpaceshipRail,
outsidePriority: RenderPriority.ballOnSpaceshipRail,
)..initialPosition = position - Vector2(5.2, -4.8),
SpaceshipHole()..initialPosition = position - Vector2(-7.2, -0.8),
SpaceshipWall()..initialPosition = position,
@ -47,7 +47,7 @@ class Spaceship extends Forge2DBlueprint {
/// {@endtemplate}
class SpaceshipSaucer extends BodyComponent with InitialPosition, Layered {
/// {@macro spaceship_saucer}
SpaceshipSaucer() : super(priority: PinballPriority.spaceshipSaucer) {
SpaceshipSaucer() : super(priority: RenderPriority.spaceshipSaucer) {
layer = Layer.spaceship;
}
@ -91,7 +91,7 @@ class SpaceshipSaucer extends BodyComponent with InitialPosition, Layered {
/// {@endtemplate}
class AndroidHead extends BodyComponent with InitialPosition, Layered {
/// {@macro spaceship_bridge}
AndroidHead() : super(priority: PinballPriority.androidHead) {
AndroidHead() : super(priority: RenderPriority.androidHead) {
layer = Layer.spaceship;
}
@ -153,7 +153,7 @@ class SpaceshipEntrance extends RampOpening {
: super(
insideLayer: Layer.spaceship,
orientation: RampOrientation.up,
insidePriority: PinballPriority.ballOnSpaceship,
insidePriority: RenderPriority.ballOnSpaceship,
) {
layer = Layer.spaceship;
}
@ -187,7 +187,7 @@ class SpaceshipHole extends RampOpening {
insideLayer: Layer.spaceship,
outsideLayer: outsideLayer,
orientation: RampOrientation.up,
insidePriority: PinballPriority.ballOnSpaceship,
insidePriority: RenderPriority.ballOnSpaceship,
outsidePriority: outsidePriority,
) {
renderBody = false;
@ -238,7 +238,7 @@ class _SpaceshipWallShape extends ChainShape {
/// {@endtemplate}
class SpaceshipWall extends BodyComponent with InitialPosition, Layered {
/// {@macro spaceship_wall}
SpaceshipWall() : super(priority: PinballPriority.spaceshipSaucerWall) {
SpaceshipWall() : super(priority: RenderPriority.spaceshipSaucerWall) {
layer = Layer.spaceship;
}

@ -40,7 +40,7 @@ class SpaceshipRail extends Forge2DBlueprint {
/// Represents the spaceship drop rail from the [Spaceship].
class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
_SpaceshipRailRamp() : super(priority: PinballPriority.spaceshipRail) {
_SpaceshipRailRamp() : super(priority: RenderPriority.spaceshipRail) {
layer = Layer.spaceshipExitRail;
}
@ -156,7 +156,7 @@ class _SpaceshipRailRampSpriteComponent extends SpriteComponent
class _SpaceshipRailForeground extends SpriteComponent with HasGameRef {
_SpaceshipRailForeground()
: super(priority: PinballPriority.spaceshipRailForeground);
: super(priority: RenderPriority.spaceshipRailForeground);
@override
Future<void> onLoad() async {
@ -204,7 +204,7 @@ class SpaceshipRailExit extends RampOpening {
: super(
orientation: RampOrientation.down,
insideLayer: Layer.spaceshipExitRail,
insidePriority: PinballPriority.ballOnSpaceshipRail,
insidePriority: RenderPriority.ballOnSpaceshipRail,
) {
renderBody = false;
layer = Layer.spaceshipExitRail;

@ -21,14 +21,14 @@ class SpaceshipRamp extends Forge2DBlueprint {
]);
final rightOpening = _SpaceshipRampOpening(
outsidePriority: PinballPriority.ballOnBoard,
outsidePriority: RenderPriority.ballOnBoard,
rotation: math.pi,
)
..initialPosition = Vector2(1.7, -19.8)
..layer = Layer.opening;
final leftOpening = _SpaceshipRampOpening(
outsideLayer: Layer.spaceship,
outsidePriority: PinballPriority.ballOnSpaceship,
outsidePriority: RenderPriority.ballOnSpaceship,
rotation: math.pi,
)
..initialPosition = Vector2(-13.7, -18.6)
@ -58,7 +58,7 @@ class SpaceshipRamp extends Forge2DBlueprint {
class _SpaceshipRampBackground extends BodyComponent
with InitialPosition, Layered {
_SpaceshipRampBackground() : super(priority: PinballPriority.spaceshipRamp) {
_SpaceshipRampBackground() : super(priority: RenderPriority.spaceshipRamp) {
layer = Layer.spaceshipEntranceRamp;
}
@ -125,7 +125,7 @@ class _SpaceshipRampBackground extends BodyComponent
class _SpaceshipRampBackgroundRailingSpriteComponent extends SpriteComponent
with HasGameRef {
_SpaceshipRampBackgroundRailingSpriteComponent()
: super(priority: PinballPriority.spaceshipRampBackgroundRailing);
: super(priority: RenderPriority.spaceshipRampBackgroundRailing);
@override
Future<void> onLoad() async {
await super.onLoad();
@ -171,7 +171,7 @@ class _SpaceshipRampBoardOpeningSpriteComponent extends SpriteComponent
class _SpaceshipRampForegroundRailing extends BodyComponent
with InitialPosition, Layered {
_SpaceshipRampForegroundRailing()
: super(priority: PinballPriority.spaceshipRampForegroundRailing) {
: super(priority: RenderPriority.spaceshipRampForegroundRailing) {
layer = Layer.spaceshipEntranceRamp;
}
@ -291,7 +291,7 @@ class _SpaceshipRampOpening extends RampOpening {
insideLayer: Layer.spaceshipEntranceRamp,
outsideLayer: outsideLayer,
orientation: RampOrientation.down,
insidePriority: PinballPriority.ballOnSpaceshipRamp,
insidePriority: RenderPriority.ballOnSpaceshipRamp,
outsidePriority: outsidePriority,
) {
renderBody = false;

@ -21,7 +21,7 @@ class SparkyBumper extends BodyComponent with InitialPosition {
_activeAssetPath = activeAssetPath,
_inactiveAssetPath = inactiveAssetPath,
_spriteComponent = spriteComponent,
super(priority: PinballPriority.sparkyBumper);
super(priority: RenderPriority.sparkyBumper);
/// {@macro sparky_bumper}
SparkyBumper.a()

@ -22,7 +22,7 @@ class SparkyComputer extends Forge2DBlueprint {
}
class _ComputerBase extends BodyComponent with InitialPosition {
_ComputerBase() : super(priority: PinballPriority.computerBase);
_ComputerBase() : super(priority: RenderPriority.computerBase);
List<FixtureDef> _createFixtureDefs() {
final fixturesDef = <FixtureDef>[];
@ -99,7 +99,7 @@ class _ComputerTopSpriteComponent extends SpriteComponent with HasGameRef {
: super(
anchor: Anchor.center,
position: Vector2(-12.45, -49.75),
priority: PinballPriority.computerTop,
priority: RenderPriority.computerTop,
);
@override

@ -1,110 +1,114 @@
// 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 pinball_priority}
/// {@template render_priority}
/// Priorities for the component rendering order in the pinball game.
/// {@endtemplate}
abstract class PinballPriority {
static const base = 0;
static const above = 1;
static const below = -1;
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;
static const int ballOnBoard = _base;
/// Render priority for the [Ball] while it's on the [SpaceshipRamp].
static const int ballOnSpaceshipRamp = above + spaceshipRampBackgroundRailing;
static const int ballOnSpaceshipRamp =
_above + spaceshipRampBackgroundRailing;
/// Render priority for the [Ball] while it's on the [Spaceship].
static const int ballOnSpaceship = above + spaceshipSaucer;
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;
static const int ballOnLaunchRamp = _above + launchRamp;
// BACKGROUND
static const int background = 3 * below + base;
static const int background = 3 * _below + _base;
// BOUNDARIES
static const int bottomBoundary = above + dinoBottomWall;
static const int bottomBoundary = _above + dinoBottomWall;
static const int outerBoudary = above + background;
static const int outerBoudary = _above + background;
// BOTTOM GROUP
static const int bottomGroup = above + ballOnBoard;
static const int bottomGroup = _above + ballOnBoard;
// LAUNCHER
static const int launchRamp = above + outerBoudary;
static const int launchRamp = _above + outerBoudary;
static const int launchRampForegroundRailing = above + ballOnLaunchRamp;
static const int launchRampForegroundRailing = _above + ballOnLaunchRamp;
static const int plunger = above + launchRamp;
static const int plunger = _above + launchRamp;
static const int rocket = above + bottomBoundary;
static const int rocket = _above + bottomBoundary;
// DINO LAND
static const int dinoTopWall = above + ballOnBoard;
static const int dinoTopWall = _above + ballOnBoard;
static const int dino = above + dinoTopWall;
static const int dino = _above + dinoTopWall;
static const int dinoBottomWall = above + dino;
static const int dinoBottomWall = _above + dino;
static const int slingshot = above + ballOnBoard;
static const int slingshot = _above + ballOnBoard;
// FLUTTER FOREST
static const int flutterSignPost = above + launchRampForegroundRailing;
static const int flutterSignPost = _above + launchRampForegroundRailing;
static const int dashBumper = above + ballOnBoard;
static const int dashBumper = _above + ballOnBoard;
static const int dashAnimatronic = above + launchRampForegroundRailing;
static const int dashAnimatronic = _above + launchRampForegroundRailing;
// SPARKY FIRE ZONE
static const int computerBase = below + ballOnBoard;
static const int computerBase = _below + ballOnBoard;
static const int computerTop = above + ballOnBoard;
static const int computerTop = _above + ballOnBoard;
static const int sparkyAnimatronic = above + spaceshipRampForegroundRailing;
static const int sparkyAnimatronic = _above + spaceshipRampForegroundRailing;
static const int sparkyBumper = above + ballOnBoard;
static const int sparkyBumper = _above + ballOnBoard;
// ANDROID SPACESHIP
static const int spaceshipRail = above + bottomGroup;
static const int spaceshipRail = _above + bottomGroup;
static const int spaceshipRailForeground = above + spaceshipRail;
static const int spaceshipRailForeground = _above + spaceshipRail;
static const int spaceshipSaucer = above + spaceshipRail;
static const int spaceshipSaucer = _above + spaceshipRail;
static const int spaceshipSaucerWall = above + spaceshipSaucer;
static const int spaceshipSaucerWall = _above + spaceshipSaucer;
static const int androidHead = above + spaceshipSaucer;
static const int androidHead = _above + spaceshipSaucer;
static const int spaceshipRamp = above + ballOnBoard;
static const int spaceshipRamp = _above + ballOnBoard;
static const int spaceshipRampBackgroundRailing = above + spaceshipRamp;
static const int spaceshipRampBackgroundRailing = _above + spaceshipRamp;
static const int spaceshipRampForegroundRailing = above + ballOnSpaceshipRamp;
static const int spaceshipRampForegroundRailing =
_above + ballOnSpaceshipRamp;
static const int spaceshipRampBoardOpening = below + ballOnBoard;
static const int spaceshipRampBoardOpening = _below + ballOnBoard;
static const int alienBumper = above + ballOnBoard;
static const int alienBumper = _above + ballOnBoard;
// SCORE TEXT
static const int scoreText = above + spaceshipRampForegroundRailing;
static const int scoreText = _above + spaceshipRampForegroundRailing;
}
/// Helper methods to change the [priority] of a [Component].

@ -9,7 +9,7 @@ class LaunchRampGame extends BasicBallGame {
LaunchRampGame()
: super(
color: Colors.blue,
ballPriority: PinballPriority.ballOnLaunchRamp,
ballPriority: RenderPriority.ballOnLaunchRamp,
ballLayer: Layer.launcher,
);

@ -9,7 +9,7 @@ class SpaceshipRailGame extends BasicBallGame {
SpaceshipRailGame()
: super(
color: Colors.blue,
ballPriority: PinballPriority.ballOnSpaceshipRail,
ballPriority: RenderPriority.ballOnSpaceshipRail,
ballLayer: Layer.spaceshipExitRail,
);

@ -9,7 +9,7 @@ class SpaceshipRampGame extends BasicBallGame {
SpaceshipRampGame()
: super(
color: Colors.blue,
ballPriority: PinballPriority.ballOnSpaceshipRamp,
ballPriority: RenderPriority.ballOnSpaceshipRamp,
ballLayer: Layer.spaceshipEntranceRamp,
);

Loading…
Cancel
Save