refactor: removed unecessary InitialPosition

pull/212/head
alestiago 3 years ago
parent 8bcc19ca94
commit 9d59c0ebbd

@ -16,7 +16,6 @@ class LaunchRamp extends Blueprint {
LaunchRamp() LaunchRamp()
: super( : super(
components: [ components: [
// TODO(alestiago): Is it using initialPosition?
_LaunchRampBase(), _LaunchRampBase(),
_LaunchRampForegroundRailing(), _LaunchRampForegroundRailing(),
_LaunchRampExit()..initialPosition = Vector2(0.6, -34), _LaunchRampExit()..initialPosition = Vector2(0.6, -34),
@ -28,7 +27,7 @@ class LaunchRamp extends Blueprint {
/// {@template launch_ramp_base} /// {@template launch_ramp_base}
/// Ramp the [Ball] is launched from at the beginning of each ball life. /// Ramp the [Ball] is launched from at the beginning of each ball life.
/// {@endtemplate} /// {@endtemplate}
class _LaunchRampBase extends BodyComponent with InitialPosition, Layered { class _LaunchRampBase extends BodyComponent with Layered {
/// {@macro launch_ramp_base} /// {@macro launch_ramp_base}
_LaunchRampBase() _LaunchRampBase()
: super( : super(
@ -103,12 +102,7 @@ class _LaunchRampBase extends BodyComponent with InitialPosition, Layered {
@override @override
Body createBody() { Body createBody() {
final bodyDef = BodyDef( final body = world.createBody(BodyDef());
position: initialPosition,
userData: this,
);
final body = world.createBody(bodyDef);
_createFixtureDefs().forEach(body.createFixture); _createFixtureDefs().forEach(body.createFixture);
return body; return body;
@ -157,7 +151,7 @@ class _LaunchRampBackgroundRailingSpriteComponent extends SpriteComponent
/// Foreground railing for the [_LaunchRampBase] to render in front of the /// Foreground railing for the [_LaunchRampBase] to render in front of the
/// [Ball]. /// [Ball].
/// {@endtemplate} /// {@endtemplate}
class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition { class _LaunchRampForegroundRailing extends BodyComponent {
/// {@macro launch_ramp_foreground_railing} /// {@macro launch_ramp_foreground_railing}
_LaunchRampForegroundRailing() _LaunchRampForegroundRailing()
: super( : super(
@ -200,11 +194,7 @@ class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition {
@override @override
Body createBody() { Body createBody() {
final bodyDef = BodyDef() final body = world.createBody(BodyDef());
..userData = this
..position = initialPosition;
final body = world.createBody(bodyDef);
_createFixtureDefs().forEach(body.createFixture); _createFixtureDefs().forEach(body.createFixture);
return body; return body;

@ -14,7 +14,6 @@ class SpaceshipRail extends Blueprint {
SpaceshipRail() SpaceshipRail()
: super( : super(
components: [ components: [
// TODO(alestiago): Investigate if it's using initial position.
_SpaceshipRailRamp(), _SpaceshipRailRamp(),
_SpaceshipRailExit(), _SpaceshipRailExit(),
_SpaceshipRailBase(radius: 0.55) _SpaceshipRailBase(radius: 0.55)
@ -26,8 +25,7 @@ class SpaceshipRail extends Blueprint {
); );
} }
/// Represents the spaceship drop rail from the [Spaceship]. class _SpaceshipRailRamp extends BodyComponent with Layered {
class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
_SpaceshipRailRamp() _SpaceshipRailRamp()
: super( : super(
priority: RenderPriority.spaceshipRail, priority: RenderPriority.spaceshipRail,
@ -112,14 +110,8 @@ class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered {
@override @override
Body createBody() { Body createBody() {
final bodyDef = BodyDef( final body = world.createBody(BodyDef());
position: initialPosition,
userData: this,
);
final body = world.createBody(bodyDef);
_createFixtureDefs().forEach(body.createFixture); _createFixtureDefs().forEach(body.createFixture);
return body; return body;
} }
@ -180,7 +172,6 @@ class _SpaceshipRailBase extends BodyComponent with InitialPosition {
final fixtureDef = FixtureDef(shape); final fixtureDef = FixtureDef(shape);
final bodyDef = BodyDef( final bodyDef = BodyDef(
position: initialPosition, position: initialPosition,
userData: this,
); );
return world.createBody(bodyDef)..createFixture(fixtureDef); return world.createBody(bodyDef)..createFixture(fixtureDef);

Loading…
Cancel
Save