Skip to content

feat(flame_behaviors): Add ScreenCollisionBehavior#3910

Open
Barba2k2 wants to merge 2 commits intoflame-engine:mainfrom
Barba2k2:feat/screen-collision-behavior
Open

feat(flame_behaviors): Add ScreenCollisionBehavior#3910
Barba2k2 wants to merge 2 commits intoflame-engine:mainfrom
Barba2k2:feat/screen-collision-behavior

Conversation

@Barba2k2
Copy link
Copy Markdown

@Barba2k2 Barba2k2 commented May 2, 2026

Description

Adds an abstract ScreenCollisionBehavior to flame_behaviors as proposed in #3750.

It is a thin type-narrowing of CollisionBehavior that pins the Collider type parameter to ScreenHitbox, so subclasses only need to specify their Parent entity.

Before

class BounceOffScreen extends CollisionBehavior<ScreenHitbox, MyEntity> {
  @override
  void onCollisionStart(Set<Vector2> intersectionPoints, ScreenHitbox other) {
    parent.velocity.negate();
  }
}

After

class BounceOffScreen extends ScreenCollisionBehavior<MyEntity> {
  @override
  void onCollisionStart(Set<Vector2> intersectionPoints, ScreenHitbox other) {
    parent.velocity.negate();
  }
}

The behavior still cooperates with the existing PropagatingCollisionBehavior on the entity and a ScreenHitbox registered on the game — no wiring changes needed.

The flame_steering_behaviors example previously declared a private class also named ScreenCollisionBehavior. It has been renamed to ScreenWrappingBehavior (which better describes what it actually does — wrapping entities around screen edges) to avoid the import collision.

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.

Related Issues

Closes #3750

Barba2k2 added 2 commits May 2, 2026 12:01
Adds an abstract ScreenCollisionBehavior that pins the Collider
generic of CollisionBehavior to ScreenHitbox and exposes screen-
specific callbacks (onScreenCollision[Start|End]) that drop the
redundant 'other' argument. This removes the boilerplate of writing
CollisionBehavior<ScreenHitbox, MyEntity> and clarifies intent at
call sites that only care about screen-edge interactions.

Closes flame-engine#3750
…ing example class

Address review of flame-engine#3910:

- Drop the duplicate onScreenCollision*() callback layer. The new abstract
  class is now a pure type-fix that pins CollisionBehavior's Collider to
  ScreenHitbox; subclasses override onCollision/onCollisionStart/
  onCollisionEnd directly and keep access to the ScreenHitbox (which
  carries the screen extent — needed e.g. for screen-wrapping logic).
- Rename the local class in flame_steering_behaviors_example from
  ScreenCollisionBehavior to ScreenWrappingBehavior (its actual
  behaviour) so the example app no longer collides on import with the
  new public ScreenCollisionBehavior. Migrate it to extend the new
  abstract base to demonstrate the simplification.
- Drop the British 'specialisation' word from the doc to satisfy
  the cspell dictionary on the spell_checker workflow.
Copy link
Copy Markdown
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.

The PR description needs to follow the PR template.

@Barba2k2
Copy link
Copy Markdown
Author

Barba2k2 commented May 3, 2026

@spydon updated the description to follow the PR template — thanks for the heads up.

@Barba2k2 Barba2k2 requested a review from spydon May 3, 2026 14:01
@spydon
Copy link
Copy Markdown
Member

spydon commented May 3, 2026

@spydon updated the description to follow the PR template — thanks for the heads up.

It still doesn't unfortunately, it needs to keep all the tags in the original template.

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.

feat(flame_behaviours): add an abstract ScreenCollisionBehavior to interact with a ScreenHitbox

2 participants