3047 Commits

Author SHA1 Message Date
10fb65f66c feat: Add TextElementComponent (#2694)
Add TextElementComponent
2023-09-02 19:36:58 +00:00
6dbcd0bd40 chore: Fix typo on cicd.yaml (#2702)
I think that #2698 has introduced a confusing typo to the cicd pipeline.
2023-09-02 21:25:16 +02:00
4b420b7952 refactor!: Rename (Text) Elements, Nodes and Styles for clarity, add docs (#2700)
This occurred to me after a discussion on the [new FCS component
PR](https://github.com/flame-engine/flame/pull/2694#discussion_r1312450113).
As per usual, @spydon has opened my eyes to the ultimate truth:

We should rename loads of files, and it shall affect almost no one.

The idea is to (1) add a "Text" prefix to all text-rendering-related
classes and (2) rename the existing `Text*` to `InlineText*` (which is
what they are).

This PR is a bit big, but the changes should hopefully be simple to
review, and can be broken down into:

* Add a proper base class for the node inheritance chain, call it
TextNode (while working on Flame Markdown I realized the value this will
have to me)
* Rename the old TextNode to InlineTextNode
* Rename DocumentNode to DocumentRoot because it is not a node
* Rename Element to TextElement
* Rename the old TextElement to InlineTextElement
* Rename Style to FlameTextStyle (note: we could consider dropping the
Flame here)
* Rename the old FlameTextStyle to InlineTextStyle
* Update the docs accordingly
* Add some more diagrams and explanations to the docs, following the new
nomenclature
* I also updated our "internal" imports to use the text module to make
life so much easier (this could arguably be done in a separate PR, but I
honestly think it's easier to review together, please lmk if you prefer
me to split).

These are all breaking changes but likely won't actually affect most
users (see below).

While this is breaking, it should hopefully not affect most users,
because these are all infrastructure classes that most people aren't
using directly. If you are using the FCS components, or the renderers
`TextPaint` or `SpriteFontRenderer` directly, this should have zero
effect to you.

If you are using the Nodes, Stlyes or Elements directly, or have a
custom TextRenderer, see below.

Migrating should be a simple matter of renaming your type references:

* from TextNode to InlineTextNode
* from TextElement to InlineTextElement
* from Element to TextElement
* from FlameTextStyle to InlineTextStyle
* from Style to FlameTextStyle

Make sure to do it in the appropriate order not to cause any
double-replace issues.

If you are importing via the module `package:flame/text.dart`, which we
highly encourage, you should not have to change any import statements
whatsoever.
2023-09-02 12:59:59 -04:00
99a1016f72 feat: Expose atlas limits for TiledComponent (#2701)
This PR add the ability for users to override the max size of
`TiledAtlas` used by `TiledComponent` for packing all the images of all
the tilesets used by a tilemap. The overrides can be used if one is sure
that their target platform can handle huge textures.

It also adds an assert for cases when the `RectangleBinPacker` runs out
of space. This is done to help users find the problem quickly.
2023-09-01 19:51:03 +02:00
0d7c6a09d2 ci: Try running the test pipeline without spec (#2698)
Try if `flutter test` works better in the pipeline. 😥
Maybe spec is using too much resources and gets killed.
2023-08-31 16:50:25 -03:00
ad1a126b09 ci: Try to use ubuntu-20.04 for tests (#2697)
The issue with GitHub killing out test pipeline might be due to the running on the latest ubuntu image, this commit tries to use the older one (which I read could be a solution somewhere...)
2023-08-31 12:34:02 +00:00
df23ab5171 docs: Add Flutter favorite logo to readme (#2696)
Just adds the Flutter favorite logo to the readme.
2023-08-31 11:46:10 +00:00
1485f8426e feat(flame_jenny): Public access to variables to allow load/save (#2689)
Allows direct access to the variables in the VariableStorage class in jenny (via YarnProject.variables.variables).

This enables a user to implement a save game feature to save the variables and later restore them.
2023-08-28 12:28:22 +02:00
a1cb9a06ad refactor!: Kill TextRenderer, Long Live TextRenderer (#2683)
This will:

    kill the TextRenderer inheritance chain
    incorporate the functionality of the base TextRenderer in the base TextFormatter
    rename TextFormatter to TextRenderer and appropriate references

That is because both essentially do the same job; encompass the style (or "how") information about how to render text, but using two slightly different interfaces. While that could allow for more flexibility, it is a faux choice that needlessly complicates the pipeline. By having a single interface to comply with, we still allow for custom renders while at the same time making all the code downstream simpler to use and understand.
2023-08-27 21:47:01 +02:00
88d3270e2f docs: Extend the contributing guidelines with more usable markdown suggestions (#2684)
Extend the contributing guidelines with more usable markdown
suggestions.
In particular suggest the `Rewrap` VS-code extension since the existing
tooling cannot fix laborious markdown line length issues.
2023-08-26 17:42:25 -04:00
eeb6749fd2 refactor!: Extract TextRendererFactory (#2680)
This is part of my ongoing effort to simplify the text rendering
pipeline.
My ultimate goal is to:
* get rid of renders
* rename formatters to renderers
* make the interface complies to both
All details are specified here:
https://github.com/flame-engine/flame/pull/2663

As a first step to break down that huge PR, this extracts
TextRendererFactory in preparation of getting rid of TextRenderer
entirely.

This is technically a breaking change but should have no effect for
users, unless you they have a custom Renderer *and* are using the
registry (which I honestly doubt). But if you are:
* just import TextRendererFactory and use the createDefault method from
there instead
2023-08-26 12:34:28 -04:00
1a64443cca refactor!: Make TextElement more usable on its own (#2679)
This is part of my ongoing effort to simplify the text rendering
pipeline.
My ultimate goal is to:
* get rid of renders
* rename formatters to renderers
* make the interface complies to both
All details are specified here:
https://github.com/flame-engine/flame/pull/2663

As a first step to break down that huge PR, this makes a small change to
TextElements to make them more useful

This PR will:
### rename render -> draw

draw becomes the "internal", underlying impl, raw method, that just
draws the element w/ any custom options

### add a new render method that takes in more options

this does not need to be extended by every impl.
this is for end users and accepts parameters like position and anchor to
be more in line with the renderer interface

This is technically a breaking change but should have no effect for
users, unless you are creating your own custom `TextElement`s. In that
case, to migrate:

* rename your `render` method to `draw`
2023-08-26 12:10:03 -04:00
76405daf48 feat: Component visibility (HasVisibility mixin) (#2681)
This PR introduces a new HasVisibility mixin on Component. It prevents the renderTree method from progressing if the isVisible property is false. It therefore prevents the component and all it's children from rendering.

The purpose of this mixin is to allow showing and hiding a component without removing it from the tree.

An important note is that the component (and all it's children) will still be on the tree. They will continue to receive update events, and all other lifecycle events. If the user has implemented input such as tap events, or collision detection, or any other interactivity, this will continue to operate without affect (unless it relies on the render step - such as per-pixel collision detection).

This is expected behaviour. If it is not desired, the user needs to account for it (by checking isVisible in their code) or someone needs to create another mixin for HasEnabled or HasActive which would prevent these other actions 😁

I am very happy to make changes, take suggestions, etc!
2023-08-26 14:26:22 +02:00
158fc34cae refactor: Enable new DCM rule: avoid-cascade-after-if-null (#2676)
Enable new DCM rule: avoid-cascade-after-if-null
Reference: https://dcm.dev/docs/rules/common/avoid-cascade-after-if-null/
2023-08-26 10:35:03 +00:00
10e4109c81 refactor: Fix lint issues across the codebase - Part 2 (#2677)
Fix a handful of lint issues across the codebase, identified using DCM.
Nothing controversial, I expect; slowly getting these out of the way so
we can focus on discussing bigger things.
2023-08-25 18:15:17 +00:00
75aee76781 fix: Absolute angle takes into account BodyComponent ancestors too (#2678)
Currently, the implementation of the `absoluteAngle` getter in
`PositionComponent` only takes into account `PositionComponent`
ancestors. The implementation simply runs through the whole hierarchy
summing up the relative angles.

This gives a wrong result with Forge2D because `BodyComponent`s have
angles too: in the common situation where a `PositionComponent` (e.g. a
`SpriteComponent`) is the child of a `BodyComponent`, the
`BodyComponent`'s rotation is ignored when computing the
`absoluteAngle`.

The fix simply introduces a new minimal interface `HasAngle` that both
`PositionComponent` and `BodyComponent` implement (`PositionComponent`
implements it automatically via `AngleProvider`), and reimplements
`absoluteAngle` so that it considers all ancestors with an angle and not
just the `PositionComponent` ones.
2023-08-25 17:59:22 +02:00
b77802a5e3 refactor: Remove unused variable on dialogue_view_test.dart (#2673)
Fix existing issue detect by GitHub's ever-evolving automated analysis:
2023-08-25 09:35:10 +02:00
9afe6395fd docs: Fix component diagram (#2675)
Fix component diagram
Broken by f582f49
2023-08-24 22:44:52 +00:00
27a8fd61cb refactor: Enable DCM linting (#2667)
This is a first step towards enabling DCM for Flame. Though I have tested with all rules, and am working on selecting, assessing, and fixing violations, as a first step, we can merge the infrastructural changes to flame_lint to and GitHub actions.
As a proof of concept, I am enabling two rules for which we have no violations.
I will followup with enabling more rules, adding discussions for controversial changes, and fixing non-controversial violations.
2023-08-24 13:09:26 +02:00
6fe9a24778 refactor: Fix lint issues across the codebase (#2672)
Fix a couple lint issues across the codebase, identified by
https://github.com/flame-engine/flame/pull/2667
Nothing controversial, I expect; getting these out of the way so we can
focus on discussing bigger things.
2023-08-24 05:17:07 -04:00
34f69b953c refactor!: Simplify text rendering pipeline (#2663)
While studying the existing text rendering pipeline and infrastructure, in order to better document it and add some easier user-facing ways to render rich text, I found it to be on a slightly overcomplicated state that seems to me to be an artifact of a migration.

Let me first briefly describe how it works with some diagrams (I am writing docs for everything and will re-use this content but wanted to propose this PR first as it will change how things look like).

We have 3 hierarchies related to rendering:

    renderers: children of TextRenderer, these define how to render text (style). do not include text
    formatters: children of TextFormatter, this also define how to render text (style), but a bit more higher level than TextRenderer.
    elements: these are laid-out, styled and ready-render pieces of text (style + string), created by formatters

Note that the renderers and formatters kinda serve the same purpose, but the renderers are a more low-level API. Here is how it it looks like today:

Not only that but all of our TextRenderer are actually FormatterTextRenderer, which just use a formatter to "comply" with the "renderer" interface. There are no "raw" TextRenderers anymore.

This current structure seems to clearly derive from an unfinished transition into the new, higher level and more flexible "formatter" structure while still supporting the "renderers" while we transition. That transition, though, seems to have completed.

The current state makes things more complicated as our current versions of components (TextComponent and TextBoxComponent), specifically the former, have branching code to support both the raw TextRenderer and the specific FormatterTextRenderer implementation, which breaks the inheritance encapsulation and voids its purpose in the first place.

The purpose of this PR is to simplify this class structure by:

    remove the base TextRenderer
    rename FormatterTextRenderer to TextRenderer: all renderers are formatter-based now
    update all references
    simplify the code of the components by only dealing with (former FormatterTextRenderer) TextRenderers

This is what it looks like now:

Note that while this is a breaking change, it should not affect most users as they should be using much more user-facing classes, like the aforementioned components, instead of the backing implementations. In fact even if they use the renderers, they probably use one of the concrete implementations anyway, TextPaint or SpriteFontRenderer. Notwithstanding, I added migration instructions below.

This is a small step towards a world where we completely combine the converts of renderers and formatters, as, in my eyes, they do the same thing (carry the style information w/o the text).

Possible future (but definitely breaking) changes:

    remove renderers entirely and use formatters directly
    consider renaming formatters to renderers (or not)
    rename TextPaint as the name does not make sense in any hierarchical model we use
    (what I am really interested in): allow the creation of text_ and text_box_ components directly from renderers + elements
2023-08-24 09:58:52 +02:00
d172146405 fix: Prevent onRemove/onDetach being called for initial Gesture Detector addition (#2653)
This fixes: https://github.com/flame-engine/flame/issues/2647
Reverts: https://github.com/flame-engine/flame/pull/2602
OBE: https://github.com/flame-engine/flame/pull/2650

To be clear, the memory leak issue is not addressed because it is not a
Flame issue. Flame properly calls the `onRemove` event and if it is
needed to pass that on to children, users should do as documented:
https://docs.flame-engine.org/latest/flame/game.html#lifecycle.

So if you are using `GameWidget.controlled`, add a tappable component
and then remove the game, the lifecycle looks like:

```
flutter: onLoad
flutter: mount
flutter: onMount
flutter: attach
flutter: add has_tappable_components
flutter: refreshWidget 
// Remove Game
flutter: detach
flutter: removeGameStateListener
flutter: onRemove
flutter: remove
```

If you do not use `GameWidget.controlled`, add a tappable component and
then remove the game, the lifecycle looks like:

```
flutter: onLoad
flutter: mount
flutter: onMount
flutter: attach
flutter: add has_tappable_components
flutter: refreshWidget
// Remove Game
flutter: detach
flutter: removeGameStateListener
flutter: onRemove
flutter: remove
```

If you do not use `GameWidget.controlled`, do not add a tappable
component and then remove the game, the lifecycle looks like:

```
flutter: onLoadFuture
flutter: mount
flutter: onMount
flutter: attach
// Remove Game
flutter: detach
flutter: removeGameStateListener
flutter: onRemove
flutter: remove
```

Previously, the lifecycle would look like:

```
flutter: onLoad
flutter: mount
flutter: onMount
flutter: attach
flutter: add has_tappable_components
flutter: refreshWidget 
flutter: detach // These unnecessary calls have been eliminated
flutter: removeGameStateListener // These unnecessary calls have been eliminated
flutter: onRemove // These unnecessary calls have been eliminated
flutter: attach
// Remove Game
flutter: detach
flutter: removeGameStateListener
flutter: onRemove
flutter: remove
```

I have updated the below diagram for those who may need it in the
future:

![Flame and Flutter Events
Fixed](https://github.com/flame-engine/flame/assets/17042581/1d98bdaf-db13-4e2c-b0a6-74da2ada89f3)
2023-08-20 19:30:32 +02:00
2f44e4832f feat: Add onDispose to game.dart called from game_widget.dart (#2659)
This adds, imo, the missing piece in the event lifecycle based on all the other lifecycle work I have been doing.

Currently, when dispose is called in game_widget.dart, it calls disposeCurrentGame which has the call for onRemove, at issue though is, disposeCurrentGame is also called by didUpdateWidget if the oldWidget.game != widget.game. It may not be needed, but I feel like because FlameGame is inherently a stateless set of widgets (children of the LeafRenderObjectWidget), the hook for onRemove is muddled with what is NOT actually a dispose event. So my thought is, introduce the onDispose method to game which gets called by making disposeCurrentGame({isDispose = false}) then in the actual overridden dispose method, pass that as true, so we can then call currentGame.onDispose() after the call to currentGame.onRemove().
2023-08-20 16:28:20 +00:00
f582f4924f docs: Update components diagram on the docs to be simpler [Proposal] (#2666)
Update components diagram on the docs to be simpler.
It seems we no longer have any abstract classes to note (other than the
abstract concept of "Effects").
I feel right now the colouring (while pretty) is just "highlighting" the
effects node on the graph for no particular reason.
I think it would be simpler and more immediate to understand if we
remove this distinction on this diagram.
Just a thought, though. Hard to assess what will be clearer to someone
not so familiar with the concepts.

Current version:

![image](https://github.com/flame-engine/flame/assets/882703/31ec2b94-8fce-4927-91b0-8e30e2a12fe9)

New version:

``` mermaid
graph TD
    %% Config %%
    classDef default fill:#282828,stroke:#F6BE00;
    
    %% Nodes %%
    Component(Component)
    Misc("
        TimerComponent
        ParticleComponent
        SpriteBatchComponent
    ")
    Effects("Effects<br/>(See the effects section)")
    Game(Game)
    FlameGame(FlameGame)
    PositionComponent(PositionComponent)
   
    Sprites("
        SpriteComponent
        SpriteGroupComponent 
        SpriteAnimationComponent
        SpriteAnimationGroupComponent
        ParallaxComponent 
        IsoMetricTileMapComponent
    ")
    
    HudMarginComponent(HudMarginComponent)
    HudComponents("
        HudButtonComponent
        JoystickComponent
    ")
    
    OtherPositionComponents("
        ButtonComponent
        CustomPainterComponent
        ShapeComponent
        SpriteButtonComponent
        TextComponent
        TextBoxComponent
        NineTileBoxComponent
    ")
        
    %% Flow %%
    Component --> Misc
    Component --> Effects
    Component --> PositionComponent
    Component --> FlameGame
   
    Game --> FlameGame
    PositionComponent --> Sprites
    PositionComponent --> HudMarginComponent
    PositionComponent --> OtherPositionComponents
    HudMarginComponent --> HudComponents    
```
2023-08-20 15:28:01 +02:00
7409ec5004 docs: Update PR template so "Migration instructions" is after the breaking change checkbox (#2665)
Update PR template so "Migration instructions" is after the breaking
change checkbox.
I believe that was where it was intended to be, but please assess if
this makes sense.
2023-08-20 15:26:57 +02:00
8401c569bf docs: Improve documentation around SpriteFontTextFormatter (#2661)
Add a class-level doc comment to `SpriteFontTextFormatter`, analogous to
`TextPainterTextFormatter`.
Also, super-specify the return type of the `format` method to facilitate
understanding (again, this makes it more aligned with its twin
`TextPainterTextFormatter`).
2023-08-20 15:26:21 +02:00
37271f5c52 feat: Add pause and isPaused to SpriteAnimationTicker (#2660)
Based on the Discord discussion and consultation with @ufrshubham, this PR adds the ability to pause a SpriteAnimationTicker.
2023-08-20 13:23:04 +00:00
f3d4158b83 fix: Change DialogueView to a mixin class (#2652)
The DialogueView is responsible for handling and (almost always) displaying the dialog to the user. A very common use case requires the DialogueView to be a PositionComponent or other visual component in the game. This would require extending from both PositionComponent and DialogueView.

Problem: The current DialogueView implementation is an abstract class. Dart does not support multiple inheritance. This means that the case above is difficult to implement.

Solution: Changing the DialogueView from an abstract class to a mixin class allows the developer to extend PositionComponent and mix in DialogueView. The class can now be used as a base class OR as a mixin. All existing tests still pass. An additional test has been added that validates the use as a mixin (extending one class and mixing in DialogueView).
2023-08-20 10:34:17 +00:00
94963c3532 docs: Remove outdated references to the flame_flare package from our docs (#2664)
Remove outdated references to the flame_flare package from our docs
2023-08-20 10:22:58 +00:00
96978e2496 docs: Improve comments and documentation for text-rendering Nodes (#2662)
Improve comments and documentation for text-rendering Nodes
Super-specify return types whenever possible
Minor refactorings to improve legibility
2023-08-20 12:13:51 +02:00
9887892493 chore: Update to Flutter 3.13 (#2656)
Updates the pipeline to use Flutter 3.13 and does all the analyze fixes.
2023-08-18 20:13:17 +02:00
d08284ddca feat: Added prefix parameter to TiledComponent.load to specify assets folder for tiled maps (#2651)
Added prefix parameter to TiledComponent.load for allowing tiled maps files in different assets folder structures. It still defaults to assets/tiles. I created this PR because I discovered it when I wanted to add a tiled map in a different folder structure. I also saw this issue #2641. And though lets add it.
2023-08-17 14:14:23 +02:00
09f09c6f4c docs: Update README.md of rogue_shooter (#2646)
This updates the rogue shooter readme since there was some confusion in
#2640.
2023-08-09 20:02:47 +02:00
9bbecb88d8 fix: Proper Flame dependency in flame_forge2d (#2644)
Proper Flame dependency in flame_forge2d
1.8.2 v1.8.2
2023-08-08 20:30:56 +00:00
b26700df7e chore(release): Publish Flame 1.8.2 (#2643)
- flame@1.8.2
 - flame_lint@1.1.0
 - flame_rive@1.9.1
 - flame_tiled@1.13.0
 - flame_isolate@0.4.0+2
 - flame_audio@2.0.5
 - flame_spine@0.1.1+1
 - flame_svg@1.8.1
 - flame_test@1.12.1
 - flame_oxygen@0.1.8+5
 - flame_bloc@1.10.1
 - flame_fire_atlas@1.3.8
 - flame_forge2d@0.14.1+1
 - flame_noise@0.1.1+4
 - flame_network_assets@0.2.0+4
 - flame_lottie@0.2.1+1
2023-08-08 22:17:03 +02:00
4e66424584 fix: Respect artboard clip value (#2639)
Adds a check for the artboard's clip value before actually clipping
2023-08-07 23:16:42 +02:00
1c4d6cd065 fix: Compute scale in TileLayers based on native map tile size rather than image sizes to support oversized/undersized tiles. (#2634)
Compute isometric tile scale based on the map's tile size rather than the tile image's default size. This fixes an issue where scale was incorrect when those two sizes differed.
2023-08-07 17:28:16 +00:00
a35d3a10ab fix: Reset _completeCompleter in ticker (#2636)
I was running this code:
```dart
void attack() async {
  print('Attack started');
  current = PlayerState.attack;

  final attackTicker = animationTicker!;
  await attackTicker.completed;
  print('Attack ticker completed');

  attackTicker.reset();
  current = PlayerState.idle;
}
```
and `attackTicker.completed` would get stuck as permanently completed
after the first completion.
2023-08-07 17:17:04 +00:00
f3de66507e feat: Possiblity to pass in FilterQuality to tiled layers (#2627)
This makes it possible to pass in `FilterQuality` to the
`TiledComponent` and to the layers, since `PaintImage` defaults to
`FilterQuality.none`.
2023-08-07 12:11:50 +00:00
e852064e49 fix: Viewport should recieve events before the world (#2630)
The viewport should receive events before the world, otherwise all huds will get the events after the world components, if there are any world components underneath them.
2023-08-07 11:57:21 +00:00
ff59aa152c fix: Use ComponentKeys to keep track of dispatchers (#2629)
This uses the `ComponentKey` API to register and unregister dispatchers,
so that we don't have to create unnecessary dispatcher components that
are removed directly in `onMount` if there already is a dispatcher or
the same type added.

This also opens up for registering components to the dispatchers so that
we don't have to go through the whole tree to deliver events which it
does currently.
2023-08-07 11:45:00 +00:00
c542d3c34b feat: Adding key argument to shape components (#2632)
Components based on `ShapeComponent` were missing the `key` constructor
argument. This PR addresses that.
2023-08-02 09:30:43 -03:00
dac2ebbf50 fix: FlameGame onRemove fix to prevent memory leak (#2602)
In addressing https://github.com/flame-engine/flame/issues/2403, this PR
removes the game widget `onRemove` call which was technically locked
into an internal method and places the call in `FlameGame` that can then
be triggered by `Game` which can be triggered by `GameRenderBox.detach`.

So why not use `dispose` as was discussed in the issue? I would refer to
the Flutter API docs:
https://api.flutter.dev/flutter/widgets/State/dispose.html

_Called when this object is removed from the tree permanently._

_The framework calls this method when this
[State](https://api.flutter.dev/flutter/widgets/State-class.html) object
will never build again. After the framework calls
[dispose](https://api.flutter.dev/flutter/widgets/State/dispose.html),
the [State](https://api.flutter.dev/flutter/widgets/State-class.html)
object is considered un[mounted]
(https://api.flutter.dev/flutter/widgets/State/mounted.html) and the
mounted property is false. It is an error to call
[setState](https://api.flutter.dev/flutter/widgets/State/setState.html)
at this point. This stage of the lifecycle is terminal: there is no way
to remount a
[State](https://api.flutter.dev/flutter/widgets/State-class.html) object
that has been disposed._

So, the issue comes down to you may be removing a `FlameGame` but not
want it permanently destroyed. Since you need the state maintained, then
by naming the method `dispose()`, users would think it permanently
destroys the game. So, this keeps it with `onRemove` and thus inline
with user expectations imo.

A user simply needs to override `onRemove` and set `FlameGame.disposeAll
= true` then call `super.onRemove()` which did not exist previously for
`FlameGame`; thus, I do not think this is a breaking change.

```dart
  @override
  void onRemove() {
    disposeAll = true;
    super.onRemove();
  }
  ```
Currently, due to my lack of knowledge of bloc, the test is not working as the game is never mounted, so I am posting the PR in order to get some assistance with that.  I tried to use the exact code that was originally posted in the issue, so we can validate the fix resolves that specific leak.  This code currently passes all tests and the behavior when stepping through the code, is as would be expected for the life cycle.

I am hoping @imaNNeo can take a look at the test and provide some pointers.
2023-07-29 19:38:02 +00:00
970babe97e docs: Minor updates to steps 3 & 4 in Klondike tutorial (#2626)
I have just finished steps 1-4 of the Klondike tutorial and noticed a
couple of minor things that look to be outdated with the current dart /
flame versions.

### Step 3 - `late` keyword isn't required
When following this step the analyser hightlight this rule
[unnecessary_late](https://dart.dev/tools/linter-rules/unnecessary_late)
(introduced in Dart 2.16.0) which states:

> Top-level and static variables with initializers are already evaluated
lazily as if they are marked late.

I updated the notes around why the laziness is important so the reader
can still understand the reasoning.
2023-07-29 13:15:11 +00:00
e430b6cdf2 perf!: Pool CollisionProspects and remove some list creations from the collision detection (#2625)
This change introduces a very simple pool for `CollisionProspect`s so
that those objects don't have to be re-created each tick.
It means that the `CollisionProspect` needs to be mutable though, so the
code becomes a little bit harder to read since sets can't be used
anymore.
2023-07-28 22:59:24 +02:00
781e898315 docs: Add more guidance to collision detection algorithm choices (#2624)
This is adding a bit more precise language and more context to API docs
of `HasCollisionDetection`, `Broadphase` and
`HasQuadTreeCollisionDetection`.
2023-07-26 14:42:57 +02:00
b4f6e271df chore: Bump audioplayers to 5.0.0 (#2621)
Bumps AP to 5.0.0
2023-07-24 13:05:27 +00:00
36e2b509b3 chore(deps): Bump pygments from 2.14.0 to 2.15.0 in /doc/_sphinx (#2620)
Bumps [pygments](https://github.com/pygments/pygments) from 2.14.0 to
2.15.0.
2023-07-24 12:40:00 +00:00
1cad0b23e1 feat: Add optional world input to CameraComponent.canSee (#2616)
CameraComponent.canSee wasn't performing any kind of sanity checks on the given components world or mounted-ness. This PR adds these checks to correctly return false if the component is not mounted or if the optional world is not the same as camera's current target world.
2023-07-21 23:12:26 +02:00
8e0a7879d7 perf: Improve performance of raycasts (#2617)
Creates an axis-aligned bounding box (AABB) around the ray to short-circuit checking.

In the general case, we skip ~75% of the checks because the ray originates at some point in the 2D cartesian space and goes towards infinity. The AABB in that case is a quadrant of space, and so only entities intersecting with this quadrant of space need to be checked.

In the case where the raycast is called with a maxDistance, the savings are much higher. A relatively short ray will generate a small AABB around its origin and end point. In a typical game world, there will be many entities that do not intersect with this AABB, and can be skipped.
2023-07-21 15:55:09 +02:00