Commit Graph

1121 Commits

Author SHA1 Message Date
Yukiteru Attano
cc035fb4a3 refactor: Change the ClipComponent factory Constructor to redirect Constructor (#3089)
The ClipComponent factory Constructor "circle", "rectangle" and
"polygon" are now redirect Constructor while they persist their previous
behaviour and syntax.
This allows subclasses of ClipComponent to directly address them.
```dart
/// Examples: 

SubClass.fancyShape() : super.polygon();
Smiley() : super.circle();
```

---------

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2024-03-21 11:52:12 +01:00
Natalie Masse Hooper
8f50c92795 fix: Updated oxygen dep to v0.3.1 and added removing components (#3087)
Updated oxygen dep to v0.3.1 and added call to new method to remove
components.
2024-03-20 09:27:01 +01:00
Erick
e3e755c6de feat: Update http dependency on flame_network_assets (#3084)
Updates the http dependency on flame_network_assets
2024-03-18 15:06:28 -03:00
Erick
bf3c282dd6 feat: Add SpriteBatch.replace to allow the replacement of the batch information (#3079)
This PR adds a new method to the `SpriteBatch` class which allow users
to replace the information, based on an index of the batch.

This is useful when you want to change some of the rendering calls
without having to rebuild the whole batch.

---------

Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
2024-03-18 10:41:46 -03:00
Lukas Klingsbo
76498eb95a chore: Add riverpod as a direct dependency to flame_riverpod 2024-03-15 12:05:36 +01:00
Lukas Klingsbo
af6ee64917 chore: Publish flame_riverpod v5.4.0 (#3081)
```
Package Name     Current Version   Updated Version   Update Reason
flame_riverpod   5.3.0             5.4.0             updated with minor changes
```
2024-03-15 12:02:39 +01:00
markvideon
b44011fd71 fix: Resolve logic error with assignment of ComponentRef's game property in flame_riverpod (#3082)
Assignment of the game property on Components using
RiverpodComponentMixin was being performed inside the onLoad method,
meaning if components were unmounted and mounted once again, attempts to
invoke callbacks to the GameWidget's build method would throw an
exception.

This functionality has been moved to the onMount method, where it always
should have been.
2024-03-15 10:38:51 +00:00
Tizian Seehaus
44b10fd60c feat: Allow ComponentRef access in RiverpodGameMixin (#3010)
This PR allows `ComponentRef` access through the `RiverpodGameMixin`.


Closes #2971

---------

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-03-15 07:03:55 +00:00
markvideon
e3aaa7c21d fix: Resolve breaking changes from Riverpod affecting flame_riverpod (#3080)
Changes to how support for manual listeners is implemented in
flutter_riverpod 2.5.1 (released 4 days ago) have affected
flame_riverpod - specifically, the implementation of
ProviderSubscription.

This PR updates the implementation of manual listeners in flame_riverpod
in the same manner that flutter_riverpod has.
2024-03-15 07:57:24 +01:00
Lukas Klingsbo
17da92b2d1 fix: Implement necessary ProviderSubscription getters (#3075)
This adds implementations of the necessary `ProviderSubscription`
getters.
2024-03-11 22:34:48 +01:00
DevKage
faf2df4b8c feat: Add initial version of behavior_tree and flame_behavior_tree package (#3045)
First pass on adding behavior tree for flame. This PR adds 2 packages:

- behavior_tree: A pure dart implementation of behavior tree.
- flame_behavior_tree: A bridge package that integrates behavior_tree
with flame.

Demo: 


https://github.com/flame-engine/flame/assets/33748002/1d2b00ab-1b6e-406e-9052-a24370c8f1ab
2024-03-10 17:29:15 +01:00
Yukiteru Attano
f49d24c02d fix!: Removed unused parameters from SpriteWidget (#3074)
The unused fields of "SpriteWidget", "srcPosition" and "srcSize" and
their matching parameter in the default constructor has been removed.


If SpriteWidget is used, remove the parameter srcPosition and srcSize as
they have not been used in the default constructor.
(This does not belong to SpriteWidget.asset())
2024-03-08 15:59:35 +01:00
William Shakour
9282cc38f0 fix: Clamp opacity set by the ColorEffect to 1.0 (#3069)
Clamp opacity set by the ColorEffect to 1.0; this was causing an issue
when the tween returned values greater than 1.

The test shows that when dt is greater than 0.5 and less than 0.75 for a
period of 1 the tween returns approx 1.2 which causes Color to throw an
exception.

This has now been fixed.

Since https://github.com/flutter/flutter/issues/89433 has also now been
fixed, I have changed the min opacity to 0.
2024-03-06 13:47:00 +00:00
DevKage
1c51334e86 feat: Add initial version of flame_sprite_fusion package (#3062)
This PR adds a new package which makes it easier to parse and render
tilemaps exported from [Sprite Fusion](https://www.spritefusion.com/).
2024-03-05 09:49:46 +01:00
Lukas Klingsbo
c92910c688 feat: Initial functionality of flame_devtools (#3061)
![image](https://github.com/flame-engine/flame/assets/744771/4ca93f5f-369e-4644-b7fb-1d7790b962e2)

This adds a structure and some basic functionality for the Flame
devtools extension.

Later I will add a pre/post-hook for publishing to Melos so that it can
build the devtools extension before publishing (and remove the directory
afterwards), since it isn't committed to this repository. For now one
has to run `melos devtools-build` before publishing.

---------

Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com>
Co-authored-by: Erick <erickzanardoo@gmail.com>
2024-03-05 01:04:43 +01:00
DevKage
30fde805b4 refactor!: Use HasTimeScale for Route (#3064)
This PR replaces the `Route.timeSpeed` with `HasTimeScale.timeScale`.
2024-03-03 13:17:54 +01:00
Lukas Klingsbo
72678c6760 fix: FutureOr return type of ComponentViewportMargin.onLoad (#3059)
Closes #3058
2024-03-02 00:42:54 +01:00
Ahmad Fakhri
2ed71a3c89 fix: Size for SpriteComponent.fromImage should be nullable (#3054)
I received an assertion error after I set `autoResize` to true when I am
using `SpriteComponent.fromImage` component. It's kinda weird for me
that the message tells me **"If size is set, autoResize should be false
or size should be null when autoResize is true.''**, but the thing is I
never set the size for that image yet. Then, I check the code and I
found out that the size will never be null anyway, so the `autoresize`
should always be false.

In this PR, I just remove all the fallback value for `size`, so it would
not give an assertion error when `size` is not being set yet while the
`autoresize` is true.

---------

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-03-01 21:01:53 +00:00
Lukas Klingsbo
741d9384db fix: Revert "feat(flame_3d): initial implementation of 3D support" (#3060)
This reverts commit e434bafb15 (flame_3d)
for the time being so that we can get the pipeline back up running.
2024-03-01 20:48:40 +00:00
Jochum van der Ploeg
e434bafb15 feat(flame_3d): initial implementation of 3D support (#3012)
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-02-26 15:52:33 +01:00
DevKage
41e9e4e38c feat: Export TileAtlas from flame_tiled package (#3049)
`TileAtlas` has a `clearCache` method which the users might need to call
from their code. This is recommended in our docs here:
https://docs.flame-engine.org/latest/bridge_packages/flame_tiled/flame_tiled.html#clearing-images-cache

---------

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-02-25 11:08:14 +00:00
DevKage
3a24a51d10 fix: Check for removing state while adding a child (#3050)
Adding a child component to a parent which is in `removing` state,
caused the lifecycle processing to go into a cyclic dependency when the
parent is re-added. It happens because, while processing the lifecycle
events, child's add event causes itself and the parent to get added to
the blocked list. As a result of this, when the parent's add event is
processed next, it gets skipped due to being in the blocked list.

This PR makes sure that the child does not get enqueued when parent is
about to be removed.
2024-02-25 12:02:20 +01:00
Matthias Nehlsen
892052b99a feat(flame_texturepacker): Expose TexturePackerAtlas (#3047)
Closes #3046

---------

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2024-02-20 09:35:06 +01:00
DevKage
6270353af9 feat: Add HasPerformanceTracker mixin on Game (#3043)
This PR adds a `HasPerformanceTracker` mixin on `Game`. This mixin will
allow for tracking the update and render time of the game.
2024-02-18 18:53:29 +01:00
Lukas Klingsbo
d409193300 chore(release): Publish Flame v1.16.0 et. al (#3044)
```
Package Name           Current Version   Updated Version   Update Reason
flame                  1.15.0            1.16.0            manual versioning
flame_audio            2.1.8             2.10.0            manual versioning
flame_bloc             1.10.10           1.11.0            manual versioning
flame_fire_atlas       1.4.8             1.5.0             manual versioning
flame_rive             1.9.11            1.10.0            manual versioning
flame_riverpod         5.2.0             5.3.0             manual versioning
flame_svg              1.9.0             1.10.0            manual versioning
flame_test             1.15.4            1.16.0            manual versioning
flame_texturepacker    3.0.0             3.1.0             manual versioning
flame_tiled            1.18.4            1.19.0            manual versioning
flame_forge2d          0.16.0+5          0.17.0            updated with major changes
flame_isolate          0.5.1             0.6.0             updated with major changes
flame_lottie           0.3.0+8           0.4.0             updated with major changes
flame_markdown         0.1.1+8           0.2.0             updated with major changes
flame_network_assets   0.2.0+13          0.3.0             updated with major changes
flame_noise            0.2.0             0.3.0             updated with major changes
flame_oxygen           0.1.9+8           0.2.0             updated with major changes
flame_spine            0.1.1+10          0.2.0             updated with major changes
flame_splash_screen    0.2.0             0.3.0             updated with major changes
jenny                  1.2.1             1.3.0             updated with minor changes
```
2024-02-17 11:23:14 +01:00
Lukas Klingsbo
7c3038becb fix: BodyComponent fixtures should test with global point (#3042)
The previous solution didn't take the whole transform into
consideration, this one does.



Closes: #3039
2024-02-17 10:34:44 +05:30
Lukas Klingsbo
4f053ed74c fix: Vertices in PolygonComponent should subtract vertices positioning (#3040)
If the vertices in the `PolygonComponent` weren't starting at 0,0 they
got the wrong hitbox, but rendered correctly.
This PR fixes that.

Closes: #3031
2024-02-16 15:09:45 +01:00
Brett Morgan
330862c98e fix!: Migrate from RawKeyEvent to KeyEvent (#3002)
First pass at migrating from `RawKeyEvent` and `RawKeyboard`
to `KeyEvent` and `HardwareKeyboard`.

Context:
https://docs.flutter.dev/release/breaking-changes/key-event-migration
2024-02-15 23:10:51 +01:00
Renan
20d368c326 chore: Fix dangling_library_doc_comments (#3038)
This is decreasing flame's points on pub.
2024-02-15 15:43:34 +01:00
Fran Tovar
219226201a feat: Add new methods to CommandStorage to support more arguments (#3035)
Added new **addCommand4** and **addCommand5** methods to the
_CommandStorage_ class from the Jenny package.
2024-02-14 09:53:39 +00:00
DevKage
78380b9d3b feat: Add TiledObjectHealpers extension on TiledObject (#3032)
This PR adds an extension on `TiledObject` to allow getting the object's
`position` and `size` as `Vector2` objects.

---------

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-02-11 17:06:51 +00:00
Lukas Klingsbo
d78f7f83b9 chore(release): Publish flame_svg v1.9.0 (#3033)
```
Package Name   Current Version   Updated Version   Update Reason
flame_svg      1.8.10            1.9.0             updated with minor changes
```
2024-02-11 11:34:45 +01:00
Lukas Klingsbo
b0cafb2a55 feat: Add loadFromString to Svg class (#3030)
Lets you create an `Svg` directly from a string instead of from a file.
2024-02-09 17:18:19 +01:00
Lukas Klingsbo
1d020a525b refactor: Fix unrelated types reported by DCM (#3023)
DCM recently started reporting
`avoid-collection-methods-with-unrelated-types` for the quadtree class,
this PR fixes the reported issues.
2024-02-08 10:09:00 +01:00
Lukas Klingsbo
abca337734 chore(release): Publish Flame v1.15.0 (#3022)
```
The following 18 packages will be updated:

Package Name           Current Version   Updated Version   Update Reason
flame                  1.14.0            1.15.0            updated with minor changes
flame_isolate          0.5.0+7           0.5.1             updated with minor changes
flame_noise            0.1.1+12          0.2.0             updated with major changes
flame_riverpod         5.1.5             5.2.0             updated with minor changes
flame_test             1.15.3            1.15.4            updated with patch changes
flame_texturepacker    2.1.0             3.0.0             updated with major changes
flame_oxygen           0.1.9+7           0.1.9+8           dependency was updated
flame_tiled            1.18.3            1.18.4            dependency was updated
flame_fire_atlas       1.4.7             1.4.8             dependency was updated
flame_audio            2.1.7             2.1.8             dependency was updated
flame_spine            0.1.1+9           0.1.1+10          dependency was updated
flame_bloc             1.10.9            1.10.10           dependency was updated
flame_rive             1.9.10            1.9.11            dependency was updated
flame_lottie           0.3.0+7           0.3.0+8           dependency was updated
flame_markdown         0.1.1+7           0.1.1+8           dependency was updated
flame_forge2d          0.16.0+4          0.16.0+5          dependency was updated
flame_svg              1.8.9             1.8.10            dependency was updated
flame_network_assets   0.2.0+12          0.2.0+13          dependency was updated
```
2024-02-07 21:23:29 +01:00
Lukas Klingsbo
5d3be3137a refactor: Minimize Vector2 creation in IsometricTileMapComponent (#3018)
The `IsometricTileMapComponent` was creating a lot of new `Vector2`
objects, this PR minimizes the creation of them.
2024-02-05 12:54:39 +01:00
Lukas Klingsbo
e27818d872 fix: Set margins of JoystickComponent properly (#3019)
The margins of the `JoystickComponent` weren't set properly, this PR
fixes that.
2024-02-05 11:02:02 +00:00
Luan Nico
2fd84c846f feat!: Update flame_noise to use latest version of fast_noise (#3015)
Update flame_noise to use the latest version of fast_noise, basically
replacing the Perlin-specific effect controller with a generic
`NoiseEffectController` that can take in any noise class (leveraging the
new Noise2 interface).

Just update from `PerlinNoiseEffectController` to
`NoiseEffectController` and provide the noise/parameters you want
directly into the `noise` field.

---------

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-02-04 16:37:54 +01:00
Luan Nico
343bdca79b chore: Fix warnings and lint issues across the codebase (#3017)
Fix warnings and lint issues across the codebase.

This includes:
* equals should now be Object instead of dynamic (and thus we don't need
_help.dart anymore)
* the `always_require_non_null_named_parameters` lint rule is removed
* the `avoid-banned-imports` rule from DCM actually doesn't do anything
unless configured
2024-02-04 16:21:14 +01:00
Lukas Klingsbo
982f2263da refactor: Update flame_texturepacker's file structure (#3014)
This update `flame_texturepacker` to follow the same directory structure
as we have in the rest of the packages.
2024-02-04 14:34:51 +00:00
Lukas Klingsbo
23cf8b9de8 fix: Properly update sprites in SpriteButtonComponent (#3013)
Previously if you replaced a sprite in a `SpriteButtonComponent` with
`component.button = ...` it didn't update the button visually since the
`sprites` map wasn't updated, this PR solves that.
2024-02-01 11:22:33 +01:00
Gnarhard
4e6968a05c feat: TexturePacker atlas can be generated from device's file (#3006)
TexturePacker atlas can be generated from device's file.

---------

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-01-29 10:09:24 +01:00
Lukas Klingsbo
3804f52434 fix: Lifecycle completers to be called for FlameGame (#3007)
Previously the `mounted`, `loaded` and `removed` completers for
`FlameGame` weren't called since `FlameGame` doesn't go through the
normal component lifecycle flow, this PR adds so that the completers are
completed properly.

Closes #3003
2024-01-28 19:54:35 +01:00
Erick
1e56293c1f feat: Add support for base64 encoded images to be manually added to Images cache. (#3008)
Adds a method so base64 encoded images can be manually added to the
Images cache.
2024-01-28 11:16:50 -03:00
Lukas Klingsbo
45c87ddfb6 feat!: Transfer flame_texturepacker to monorepo (#2987)
This PR transfers the
[flame_texturepacker](https://github.com/Brixto/flame_texturepacker) to
the monorepo and updates it to be compatible with the rest of the
structure (linting etc).
2024-01-25 14:40:16 +00:00
Johannes Löhnn
6a1059b0a6 fix: CameraComponent no longer throws Concurrent modification on stop (#2997)
When camera is following a component and trying to follow another target
I got an exception:
```
dart:core                                              Iterable.forEach
package:flame/src/camera/camera_component.dart 326:25  CameraComponent.stop
package:flame/src/camera/camera_component.dart 309:5   CameraComponent.follow
test/camera/camera_component_test.dart 69:14           main.<fn>.<fn>
package:flame_test/src/test_flame_game.dart 80:21      testWithGame.<fn>

Concurrent modification during iteration: _Set len:0.
```

Copying viewfinder children before iterating through it and removing
child from parent does the trick, as we are not iterating through the
same list as we are removing items from, but rather a copy of it.

I tried to use camera from `game` provided in the test but it is AFAIK
not mounted and will hence not queue modifications (adds and removes).
Hence I create a new camera and mount it.
2024-01-23 08:55:05 +00:00
Johannes Löhnn
3c38ee6058 feat: Bumped integral_isolates package for flame_isolate (#2994)
Updated package dependencies for flame_isolate.
Added support for TailoredIsolate and computeStream (called
isolateComputeStream in flame_isolate).

Updated the example package with new sprites created by yours truly, and
updated the license for the package, now that there is no assets with
copy-left CC license remaining.

### Migration instructions

Computation function is renamed from `isolate` to `isolateCompute`.
There are future breaking changes that are, as of now, mitigated with a
`@Deprecated` annotation with information regarding what function to use
instead.
2024-01-22 21:08:33 +00:00
Lukas Klingsbo
7fbd5af935 feat: Make Component.key public (#2988)
Since the user might want to use the `ComponentKey` after it has been
assigned it should be made public.

It also updates `Consumer.key` to `Consumer.widgetKey` in flame_riverpod
to avoid a name clash. (Slightly breaking)


### Migration instructions

If you are using `consumer.key` from flame_riverpod you have to now use
`consumer.widgetKey` instead.

## Related Issues

Closes #2985
2024-01-22 10:38:40 +01:00
David Jandrey
a6fe62a2c3 fix: Updated PolygonComponent.containsPoint to account for concave polygons (#2979)
Previously, the `PolygonComponent.containsPoint()` and
`.containsLocalPoint()` functions consisted of duplicate code that
checked whether a given point lies within a convex polygon. They didn't
function properly with concave polygons.

I created a new `_containsPoint()` function that is called from both
functions to reduce redundancies. This new function uses a different
approach to figure out whether a point lies within a polygon, which
should also work for concave polygons, or even polygons with holes. The
algorithm is vaguely explained within code comments, and is visualized
in this post: https://stackoverflow.com/a/218081/5008997

---------

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-01-21 10:52:52 +00:00
John McDole
1d9fe61392 fix: Add missing generic to ComponentViewportMargin (#2983)
Improve `ComponentViewportMargin` (see #2982)


Closes #2982
2024-01-16 19:40:06 +01:00