refactor: suffixed Component

pull/158/head
alestiago 4 years ago
parent 46016e8136
commit c04ed87701

@ -31,7 +31,7 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
double _boostTimer = 0; double _boostTimer = 0;
static const _boostDuration = 2.0; static const _boostDuration = 2.0;
final SpriteComponent _spriteComponent = _BallSprite(); final _BallSpriteComponent _spriteComponent = _BallSpriteComponent();
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
@ -108,7 +108,7 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
} }
} }
class _BallSprite extends SpriteComponent with HasGameRef { class _BallSpriteComponent extends SpriteComponent with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();

@ -83,7 +83,7 @@ class Baseboard extends BodyComponent with InitialPosition {
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_BaseboardSprite(side: _side)); await add(_BaseboardSpriteComponent(side: _side));
} }
@override @override
@ -101,8 +101,8 @@ class Baseboard extends BodyComponent with InitialPosition {
} }
} }
class _BaseboardSprite extends SpriteComponent with HasGameRef { class _BaseboardSpriteComponent extends SpriteComponent with HasGameRef {
_BaseboardSprite({required BoardSide side}) : _side = side; _BaseboardSpriteComponent({required BoardSide side}) : _side = side;
final BoardSide _side; final BoardSide _side;

@ -64,11 +64,11 @@ class _BottomBoundary extends BodyComponent with InitialPosition {
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_BottomBoundarySprite()); await add(_BottomBoundarySpriteComponent());
} }
} }
class _BottomBoundarySprite extends SpriteComponent with HasGameRef { class _BottomBoundarySpriteComponent extends SpriteComponent with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
@ -135,11 +135,11 @@ class _OuterBoundary extends BodyComponent with InitialPosition {
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_OuterBoundarySprite()); await add(_OuterBoundarySpriteComponent());
} }
} }
class _OuterBoundarySprite extends SpriteComponent with HasGameRef { class _OuterBoundarySpriteComponent extends SpriteComponent with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();

@ -102,11 +102,11 @@ class _DinoTopWall extends BodyComponent with InitialPosition {
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_DinoTopWallSprite()); await add(_DinoTopWallSpriteComponent());
} }
} }
class _DinoTopWallSprite extends SpriteComponent with HasGameRef { class _DinoTopWallSpriteComponent extends SpriteComponent with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
@ -202,11 +202,11 @@ class _DinoBottomWall extends BodyComponent with InitialPosition {
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_DinoBottomWallSprite()); await add(_DinoBottomWallSpriteComponent());
} }
} }
class _DinoBottomWallSprite extends SpriteComponent with HasGameRef { class _DinoBottomWallSpriteComponent extends SpriteComponent with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();

@ -42,9 +42,6 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
body.linearVelocity = Vector2(0, _speed); body.linearVelocity = Vector2(0, _speed);
} }
/// Loads the sprite that renders with the [Flipper].
Future<void> _loadSprite() async {}
/// Anchors the [Flipper] to the [RevoluteJoint] that controls its arc motion. /// Anchors the [Flipper] to the [RevoluteJoint] that controls its arc motion.
Future<void> _anchorToJoint() async { Future<void> _anchorToJoint() async {
final anchor = _FlipperAnchor(flipper: this); final anchor = _FlipperAnchor(flipper: this);
@ -117,7 +114,7 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
renderBody = false; renderBody = false;
await _anchorToJoint(); await _anchorToJoint();
await add(_FlipperSprite(side: side)); await add(_FlipperSpriteComponent(side: side));
} }
@override @override
@ -133,8 +130,8 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
} }
} }
class _FlipperSprite extends SpriteComponent with HasGameRef { class _FlipperSpriteComponent extends SpriteComponent with HasGameRef {
_FlipperSprite({required BoardSide side}) : _side = side; _FlipperSpriteComponent({required BoardSide side}) : _side = side;
final BoardSide _side; final BoardSide _side;

@ -11,7 +11,7 @@ class FlutterSignPost extends BodyComponent with InitialPosition {
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_FlutterSignPostSprite()); await add(_FlutterSignPostSpriteComponent());
} }
@override @override
@ -24,7 +24,7 @@ class FlutterSignPost extends BodyComponent with InitialPosition {
} }
} }
class _FlutterSignPostSprite extends SpriteComponent with HasGameRef { class _FlutterSignPostSpriteComponent extends SpriteComponent with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();

@ -122,12 +122,12 @@ class Kicker extends BodyComponent with InitialPosition {
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_KickerSprite(side: _side)); await add(_KickerSpriteComponent(side: _side));
} }
} }
class _KickerSprite extends SpriteComponent with HasGameRef { class _KickerSpriteComponent extends SpriteComponent with HasGameRef {
_KickerSprite({required BoardSide side}) : _side = side; _KickerSpriteComponent({required BoardSide side}) : _side = side;
final BoardSide _side; final BoardSide _side;

@ -117,11 +117,11 @@ class _LaunchRampBase extends BodyComponent with InitialPosition, Layered {
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_LaunchRampBaseSprite()); await add(_LaunchRampBaseSpriteComponent());
} }
} }
class _LaunchRampBaseSprite extends SpriteComponent with HasGameRef { class _LaunchRampBaseSpriteComponent extends SpriteComponent with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
@ -195,11 +195,11 @@ class _LaunchRampForegroundRailing extends BodyComponent
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_LaunchRampForegroundRailingSprite()); await add(_LaunchRampForegroundRailingSpriteComponent());
} }
} }
class _LaunchRampForegroundRailingSprite extends SpriteComponent class _LaunchRampForegroundRailingSpriteComponent extends SpriteComponent
with HasGameRef { with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {

@ -139,11 +139,12 @@ class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
await add(_SpaceshipRailRampSprite()); await add(_SpaceshipRailRampSpriteComponent());
} }
} }
class _SpaceshipRailRampSprite extends SpriteComponent with HasGameRef { class _SpaceshipRailRampSpriteComponent extends SpriteComponent
with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();

@ -111,12 +111,12 @@ class _SpaceshipRampBackground extends BodyComponent
await super.onLoad(); await super.onLoad();
renderBody = false; renderBody = false;
await add(_SpaceshipRampBackgroundRailingSprite()); await add(_SpaceshipRampBackgroundRailingSpriteComponent());
await add(_SpaceshipRampBackgroundRampSprite()); await add(_SpaceshipRampBackgroundRampSpriteComponent());
} }
} }
class _SpaceshipRampBackgroundRailingSprite extends SpriteComponent class _SpaceshipRampBackgroundRailingSpriteComponent extends SpriteComponent
with HasGameRef { with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
@ -131,7 +131,7 @@ class _SpaceshipRampBackgroundRailingSprite extends SpriteComponent
} }
} }
class _SpaceshipRampBackgroundRampSprite extends SpriteComponent class _SpaceshipRampBackgroundRampSpriteComponent extends SpriteComponent
with HasGameRef { with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
@ -199,11 +199,11 @@ class _SpaceshipRampForegroundRailing extends BodyComponent
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
await add(_SpaceshipRampForegroundRalingSprite()); await add(_SpaceshipRampForegroundRalingSpriteComponent());
} }
} }
class _SpaceshipRampForegroundRalingSprite extends SpriteComponent class _SpaceshipRampForegroundRalingSpriteComponent extends SpriteComponent
with HasGameRef { with HasGameRef {
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {

Loading…
Cancel
Save