docs: included doc comments where possible

pull/234/head
alestiago 3 years ago
parent eae56fe19f
commit 77907a922b

@ -49,6 +49,8 @@ class BallController extends ComponentController<Ball>
/// {@macro ball_controller} /// {@macro ball_controller}
BallController(Ball ball) : super(ball); BallController(Ball ball) : super(ball);
/// Event triggered when the ball is lost.
// TODO(alestiago): Refactor using behaviors.
void lost() { void lost() {
component.shouldRemove = true; component.shouldRemove = true;
} }

@ -3,6 +3,7 @@ import 'package:pinball/game/game.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
/// Adds a [GameBonus.googleWord] when all [GoogleLetter]s are activated.
class GoogleWordBonusBehavior extends Component class GoogleWordBonusBehavior extends Component
with HasGameRef<PinballGame>, ParentIsA<GoogleWord> { with HasGameRef<PinballGame>, ParentIsA<GoogleWord> {
@override @override
@ -11,6 +12,9 @@ class GoogleWordBonusBehavior extends Component
final googleLetters = parent.children.whereType<GoogleLetter>(); final googleLetters = parent.children.whereType<GoogleLetter>();
for (final letter in googleLetters) { for (final letter in googleLetters) {
// TODO(alestiago): Refactor subscription management once the following is
// merged:
// https://github.com/flame-engine/flame/pull/1538
letter.bloc.stream.listen((_) { letter.bloc.stream.listen((_) {
final achievedBonus = googleLetters final achievedBonus = googleLetters
.every((letter) => letter.bloc.state == GoogleLetterState.active); .every((letter) => letter.bloc.state == GoogleLetterState.active);

@ -75,6 +75,7 @@ class AlienBumper extends BodyComponent with InitialPosition {
// TODO(alestiago): Consider refactoring once the following is merged: // TODO(alestiago): Consider refactoring once the following is merged:
// https://github.com/flame-engine/flame/pull/1538 // https://github.com/flame-engine/flame/pull/1538
// ignore: public_member_api_docs
final AlienBumperCubit bloc; final AlienBumperCubit bloc;
@override @override

@ -2,6 +2,9 @@ import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
// TODO(alestiago): Evaluate if there is any useful documentation that could
// be added to this class.
// ignore: public_member_api_docs
class AlienBumperBallContactBehavior extends ContactBehavior<AlienBumper> { class AlienBumperBallContactBehavior extends ContactBehavior<AlienBumper> {
@override @override
void beginContact(Object other, Contact contact) { void beginContact(Object other, Contact contact) {

@ -2,13 +2,19 @@ import 'package:bloc/bloc.dart';
part 'alien_bumper_state.dart'; part 'alien_bumper_state.dart';
// TODO(alestiago): Evaluate if there is any useful documentation that could
// be added to this class.
// ignore: public_member_api_docs
class AlienBumperCubit extends Cubit<AlienBumperState> { class AlienBumperCubit extends Cubit<AlienBumperState> {
// ignore: public_member_api_docs
AlienBumperCubit() : super(AlienBumperState.active); AlienBumperCubit() : super(AlienBumperState.active);
/// Event added when a bumper contacts with a ball.
void onBallContacted() { void onBallContacted() {
emit(AlienBumperState.inactive); emit(AlienBumperState.inactive);
} }
/// Event added when a bumper finishes blinking.
void onBlinked() { void onBlinked() {
emit(AlienBumperState.active); emit(AlienBumperState.active);
} }

@ -2,6 +2,9 @@ import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
// TODO(alestiago): Evaluate if there is any useful documentation that could
// be added to this class.
// ignore: public_member_api_docs
class GoogleLetterBallContactBehavior extends ContactBehavior<GoogleLetter> { class GoogleLetterBallContactBehavior extends ContactBehavior<GoogleLetter> {
@override @override
void beginContact(Object other, Contact contact) { void beginContact(Object other, Contact contact) {

@ -2,13 +2,19 @@ import 'package:bloc/bloc.dart';
part 'google_letter_state.dart'; part 'google_letter_state.dart';
// TODO(alestiago): Evaluate if there is any useful documentation that could
// be added to this class.
// ignore: public_member_api_docs
class GoogleLetterCubit extends Cubit<GoogleLetterState> { class GoogleLetterCubit extends Cubit<GoogleLetterState> {
// ignore: public_member_api_docs
GoogleLetterCubit() : super(GoogleLetterState.inactive); GoogleLetterCubit() : super(GoogleLetterState.inactive);
/// Event added when a letter contacts with a ball.
void onBallContacted() { void onBallContacted() {
emit(GoogleLetterState.active); emit(GoogleLetterState.active);
} }
/// Event added when a letter should return to its initial configuration.
void onReset() { void onReset() {
emit(GoogleLetterState.inactive); emit(GoogleLetterState.inactive);
} }

@ -1,7 +1,10 @@
part of 'google_letter_cubit.dart'; part of 'google_letter_cubit.dart';
/// Indicates the [GoogleLetterCubit]'s current state.
enum GoogleLetterState { enum GoogleLetterState {
/// A lit up letter.
active, active,
/// A dimmed letter.
inactive, inactive,
} }

@ -1,7 +1,5 @@
import 'package:flame/components.dart'; import 'package:flame/components.dart';
import 'package:flame/effects.dart';
import 'package:flame_forge2d/flame_forge2d.dart'; import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flutter/material.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_components/src/components/google_letter/behaviors/behaviors.dart'; import 'package:pinball_components/src/components/google_letter/behaviors/behaviors.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
@ -26,6 +24,7 @@ class GoogleLetter extends BodyComponent with InitialPosition {
// TODO(alestiago): Consider refactoring once the following is merged: // TODO(alestiago): Consider refactoring once the following is merged:
// https://github.com/flame-engine/flame/pull/1538 // https://github.com/flame-engine/flame/pull/1538
// ignore: public_member_api_docs
final GoogleLetterCubit bloc; final GoogleLetterCubit bloc;
@override @override

@ -2,6 +2,9 @@ import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
// TODO(alestiago): Evaluate if there is any useful documentation that could
// be added to this class.
// ignore: public_member_api_docs
class SparkyBumperBallContactBehavior extends ContactBehavior<SparkyBumper> { class SparkyBumperBallContactBehavior extends ContactBehavior<SparkyBumper> {
@override @override
void beginContact(Object other, Contact contact) { void beginContact(Object other, Contact contact) {

@ -2,13 +2,19 @@ import 'package:bloc/bloc.dart';
part 'sparky_bumper_state.dart'; part 'sparky_bumper_state.dart';
// TODO(alestiago): Evaluate if there is any useful documentation that could
// be added to this class.
// ignore: public_member_api_docs
class SparkyBumperCubit extends Cubit<SparkyBumperState> { class SparkyBumperCubit extends Cubit<SparkyBumperState> {
// ignore: public_member_api_docs
SparkyBumperCubit() : super(SparkyBumperState.active); SparkyBumperCubit() : super(SparkyBumperState.active);
/// Event added when a bumper contacts with a ball.
void onBallContacted() { void onBallContacted() {
emit(SparkyBumperState.inactive); emit(SparkyBumperState.inactive);
} }
/// Event added when a bumper finishes blinking.
void onBlinked() { void onBlinked() {
emit(SparkyBumperState.active); emit(SparkyBumperState.active);
} }

@ -91,6 +91,7 @@ class SparkyBumper extends BodyComponent with InitialPosition {
// TODO(alestiago): Consider refactoring once the following is merged: // TODO(alestiago): Consider refactoring once the following is merged:
// https://github.com/flame-engine/flame/pull/1538 // https://github.com/flame-engine/flame/pull/1538
// ignore: public_member_api_docs
final SparkyBumperCubit bloc; final SparkyBumperCubit bloc;
@override @override

@ -3,6 +3,15 @@ import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
/// Adds a new [ContactCallbacks] to the parent.
///
/// This is a convenience class for adding a [ContactCallbacks] to the parent.
/// In constract with just adding a [ContactCallbacks] to the parent's userData,
/// this class respects the previous [ContactCallbacks], if any, in the parent.
/// Hence, it avoids overriding any previous [ContactCallbacks] in the parent.
///
/// It does so by grouping the [ContactCallbacks] in a [_ContactCallbacksGroup],
/// and resetting the parent's userData accordingly.
// TODO(alestiago): Make use of generics to infer the type of the contact. // TODO(alestiago): Make use of generics to infer the type of the contact.
// https://github.com/VGVentures/pinball/pull/234#discussion_r859182267 // https://github.com/VGVentures/pinball/pull/234#discussion_r859182267
abstract class ContactBehavior<T extends BodyComponent> extends Component abstract class ContactBehavior<T extends BodyComponent> extends Component

Loading…
Cancel
Save