From 9d59c0ebbd25be054f556a47178f7890c5594117 Mon Sep 17 00:00:00 2001 From: alestiago Date: Thu, 21 Apr 2022 16:34:52 +0100 Subject: [PATCH] refactor: removed unecessary InitialPosition --- .../lib/src/components/launch_ramp.dart | 18 ++++-------------- .../lib/src/components/spaceship_rail.dart | 13 ++----------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/packages/pinball_components/lib/src/components/launch_ramp.dart b/packages/pinball_components/lib/src/components/launch_ramp.dart index 7f51e3cf..baa54744 100644 --- a/packages/pinball_components/lib/src/components/launch_ramp.dart +++ b/packages/pinball_components/lib/src/components/launch_ramp.dart @@ -16,7 +16,6 @@ class LaunchRamp extends Blueprint { LaunchRamp() : super( components: [ - // TODO(alestiago): Is it using initialPosition? _LaunchRampBase(), _LaunchRampForegroundRailing(), _LaunchRampExit()..initialPosition = Vector2(0.6, -34), @@ -28,7 +27,7 @@ class LaunchRamp extends Blueprint { /// {@template launch_ramp_base} /// Ramp the [Ball] is launched from at the beginning of each ball life. /// {@endtemplate} -class _LaunchRampBase extends BodyComponent with InitialPosition, Layered { +class _LaunchRampBase extends BodyComponent with Layered { /// {@macro launch_ramp_base} _LaunchRampBase() : super( @@ -103,12 +102,7 @@ class _LaunchRampBase extends BodyComponent with InitialPosition, Layered { @override Body createBody() { - final bodyDef = BodyDef( - position: initialPosition, - userData: this, - ); - - final body = world.createBody(bodyDef); + final body = world.createBody(BodyDef()); _createFixtureDefs().forEach(body.createFixture); return body; @@ -157,7 +151,7 @@ class _LaunchRampBackgroundRailingSpriteComponent extends SpriteComponent /// Foreground railing for the [_LaunchRampBase] to render in front of the /// [Ball]. /// {@endtemplate} -class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition { +class _LaunchRampForegroundRailing extends BodyComponent { /// {@macro launch_ramp_foreground_railing} _LaunchRampForegroundRailing() : super( @@ -200,11 +194,7 @@ class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition { @override Body createBody() { - final bodyDef = BodyDef() - ..userData = this - ..position = initialPosition; - - final body = world.createBody(bodyDef); + final body = world.createBody(BodyDef()); _createFixtureDefs().forEach(body.createFixture); return body; diff --git a/packages/pinball_components/lib/src/components/spaceship_rail.dart b/packages/pinball_components/lib/src/components/spaceship_rail.dart index 6b66c59b..1175384b 100644 --- a/packages/pinball_components/lib/src/components/spaceship_rail.dart +++ b/packages/pinball_components/lib/src/components/spaceship_rail.dart @@ -14,7 +14,6 @@ class SpaceshipRail extends Blueprint { SpaceshipRail() : super( components: [ - // TODO(alestiago): Investigate if it's using initial position. _SpaceshipRailRamp(), _SpaceshipRailExit(), _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 InitialPosition, Layered { +class _SpaceshipRailRamp extends BodyComponent with Layered { _SpaceshipRailRamp() : super( priority: RenderPriority.spaceshipRail, @@ -112,14 +110,8 @@ class _SpaceshipRailRamp extends BodyComponent with InitialPosition, Layered { @override Body createBody() { - final bodyDef = BodyDef( - position: initialPosition, - userData: this, - ); - - final body = world.createBody(bodyDef); + final body = world.createBody(BodyDef()); _createFixtureDefs().forEach(body.createFixture); - return body; } @@ -180,7 +172,6 @@ class _SpaceshipRailBase extends BodyComponent with InitialPosition { final fixtureDef = FixtureDef(shape); final bodyDef = BodyDef( position: initialPosition, - userData: this, ); return world.createBody(bodyDef)..createFixture(fixtureDef);