Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove mustCallSuper from onComponentTypeCheck #2561

Merged

Conversation

ASGAlex
Copy link
Contributor

@ASGAlex ASGAlex commented May 31, 2023

Description

@mustCallSuper is very strict requirement. This is true only for hitboxes and internal engine's logic, but unnecessary for other, "client-side" game components.
When overriding onComponentTypeCheck for component you can simple return true or false and this would not break anything.

Checklist

  • I have followed the [Contributor Guide] when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

@mustCallSuper is very strict requirement. This is true only for hitboxes, but unnecessary for other game components.
Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be some dartdocs added for when one should call super at least then

@spydon spydon changed the title fix: onComponentTypeCheck really MUST call super only for hitboxes fix: Remove mustCallSuper from onComponentTypeCheck May 31, 2023
@ASGAlex
Copy link
Contributor Author

ASGAlex commented May 31, 2023

In fact, the decision is always up to game developer. If he want to leave a chance to owerride the type check in parent component - super should be calles. Otherways it only waste system recources.
In the engine we call super everywhere just because we dont know, where exactly it will be overriden by user.

@spydon
Copy link
Member

spydon commented Jun 1, 2023

Yes, the decision is up to the game developer, but we should inform them of what is happening when super is called and with an example for when they'd want to do it so that the developer can make an informed decision on whether they should call super or not.

@spydon
Copy link
Member

spydon commented Jun 1, 2023

Because there are cases when the developer would want to call super right?

Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

doc/flame/collision_detection.md Outdated Show resolved Hide resolved
packages/flame/lib/src/collisions/collision_callbacks.dart Outdated Show resolved Hide resolved
packages/flame/lib/src/collisions/collision_callbacks.dart Outdated Show resolved Hide resolved
@spydon spydon enabled auto-merge (squash) June 2, 2023 09:48
@spydon spydon merged commit bcae760 into flame-engine:main Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants