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

chore(flame_steering_behaviors): bring flame_steering_behaviors into the repository #51

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ updates:
directory: "/packages/flame_behaviors/example"
schedule:
interval: "daily"
- package-ecosystem: "pub"
directory: "/packages/flame_steering_behaviors"
schedule:
interval: "daily"
- package-ecosystem: "pub"
directory: "/packages/flame_steering_behaviors/example"
schedule:
interval: "daily"
30 changes: 30 additions & 0 deletions .github/workflows/flame_steering_behaviors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: flame_steering_behaviors

on:
pull_request:
paths:
- ".github/workflows/flame_steering_behaviors.yaml"
- "packages/flame_steering_behaviors/lib/**"
- "packages/flame_steering_behaviors/test/**"
- "packages/flame_steering_behaviors/pubspec.yaml"
push:
branches:
- main
paths:
- ".github/workflows/flame_steering_behaviors.yaml"
- "packages/flame_steering_behaviors/lib/**"
- "packages/flame_steering_behaviors/test/**"
- "packages/flame_steering_behaviors/pubspec.yaml"

jobs:
build:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1
with:
working_directory: packages/flame_steering_behaviors
flutter_channel: stable
flutter_version: 3.13.5
wolfenrain marked this conversation as resolved.
Show resolved Hide resolved

pana:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/pana.yml@v1
with:
working_directory: packages/flame_steering_behaviors
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ View the full documentation [here](https://github.com/VeryGoodOpenSource/flame_b
| Package | Pub |
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| [flame_behaviors](https://github.com/verygoodopensource/flame_behaviors/tree/main/packages/flame_behaviors) | [![pub package](https://img.shields.io/pub/v/flame_behaviors.svg)](https://pub.dev/packages/flame_behaviors) |
| [flame_steering_behaviors](https://github.com/verygoodopensource/flame_behaviors/tree/main/packages/flame_steering_behaviors) | [![pub package](https://img.shields.io/pub/v/flame_steering_behaviors.svg)](https://pub.dev/packages/flame_steering_behaviors) |


## Quick Start 🚀
Expand Down
2 changes: 1 addition & 1 deletion docs/collision-detection.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Collision Detection 💥

Flame comes with a powerful built-in [collision detection system](https://docs.flame-engine.org/1.6.0/flame/collision_detection.html),
Flame comes with a powerful built-in [collision detection system](https://docs.flame-engine.org/1.10.0/flame/collision_detection.html),
but this API is not strongly typed. Components always get the colliding component as a
`PositionComponent` and developers need to manually check what type of class it is.

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
In order to use Flame Behaviors you must have the [Flame package][flame_package_link] added to
your project.

> **Note**: Flame Behaviors requires Flame `">=1.6.0 <2.0.0"`
> **Note**: Flame Behaviors requires Flame `">=1.10.0 <2.0.0"`

## Installing 🧑‍💻

Expand Down
2 changes: 1 addition & 1 deletion packages/flame_behaviors/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ dev_dependencies:
flame_test: ^1.13.2
flutter_test:
sdk: flutter
mocktail: ^0.3.0
mocktail: ^1.0.2
very_good_analysis: ^5.1.0
20 changes: 20 additions & 0 deletions packages/flame_steering_behaviors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Files and directories created by pub
.dart_tool/
.packages
pubspec.lock

# Android Studio and IntelliJ
.idea

# Conventional directory for build outputs
build/

# Directory created by dartdoc
doc/api/

# Temporary Files
.tmp/

# Files generated during tests
.test_coverage.dart
coverage/
3 changes: 3 additions & 0 deletions packages/flame_steering_behaviors/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 0.0.1-dev.0

- chore: project creation
21 changes: 21 additions & 0 deletions packages/flame_steering_behaviors/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Very Good Ventures

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
105 changes: 105 additions & 0 deletions packages/flame_steering_behaviors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Steering Behaviors

[![Very Good Ventures][logo_white]][very_good_ventures_link_dark]
[![Very Good Ventures][logo_black]][very_good_ventures_link_light]

Developed with 💙 by [Very Good Ventures][very_good_ventures_link] 🦄

[![ci][ci_badge]][ci_link]
[![coverage][coverage_badge]][ci_link]
[![pub package][pub_badge]][pub_link]
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
[![License: MIT][license_badge]][license_link]
[![Powered by Flame][flame_badge_link]]([flame_link])

---

An implementation of steering behaviors for Flame Behaviors.
See [Steering Behaviors For Autonomous Characters](https://www.red3d.com/cwr/steer/) by
[Craig Reynolds](https://www.red3d.com/cwr/) for an in-depth explanation

---

## Installation 💻

```
flutter pub add flame_steering_behaviors
```

## Usage ✨

This package is built on top of the [`flame_behaviors`](https://pub.dev/packages/flame_behaviors), if you are not yet familiar with it, we recommend reading up on the documentation of that package first.

### Steerable

If you want to apply steering behaviors to your entities you have to add the `Steerable` mixin to your entity class:

```dart
class MyEntity extends Entity with Steerable {
/// Provide the max velocity this entity can hold.
double get maxVelocity => 100;

...
}
```

The `Steerable` mixin provides a `velocity` value to your entity, this velocity will then be applied on each update cycle to your entity until the velocity becomes zero.

### Steering Behaviors

Each algorithm defined by this project is available as a `Behavior` and you can add them to your [steerable](#steerable) entities as you would with any behavior:

```dart
class MyEntity extends Entity with Steerable {
MyEntity() : super(
behaviors: [
WanderBehavior(
circleDistance: 200,
maximumAngle: 45 * degrees2Radians,
startingAngle: 0,
)
]
);

...
}
```

Some steering behaviors require information that is not always available on entity creation, when that happens we recommend using the entity's `onLoad` method:

```dart
class MyEntity extends Entity with Steerable {
...

@override
Future<void> onLoad() async {
world.children.register<MyOtherEntity>();
await add(
SeparationBehavior(
world.children.query<MyOtherEntity>(),
maxDistance: 25,
maxAcceleration: 1000,
),
);
}

...
}
```

[ci_badge]: https://github.com/VeryGoodOpenSource/flame_behaviors/workflows/flame_steering_behaviors/badge.svg
[ci_link]: https://github.com/VeryGoodOpenSource/flame_behaviors/actions
[coverage_badge]: https://raw.githubusercontent.com/VeryGoodOpenSource/flame_behaviors/main/coverage_badge.svg
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
[license_link]: https://opensource.org/licenses/MIT
[logo_black]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_black.png#gh-light-mode-only
[logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only
[pub_badge]: https://img.shields.io/pub/v/flame_steering_behaviors.svg
[pub_link]: https://pub.dartlang.org/packages/flame_steering_behaviors
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
[very_good_ventures_link]: https://verygood.ventures/?utm_source=github&utm_medium=banner&utm_campaign=CLI
[very_good_ventures_link_dark]: https://verygood.ventures/?utm_source=github&utm_medium=banner&utm_campaign=CLI#gh-dark-mode-only
[very_good_ventures_link_light]: https://verygood.ventures/?utm_source=github&utm_medium=banner&utm_campaign=CLI#gh-light-mode-only
[flame_badge_link]: https://img.shields.io/badge/Powered%20by-%F0%9F%94%A5-orange.svg
[flame_link]: https://flame-engine.org
1 change: 1 addition & 0 deletions packages/flame_steering_behaviors/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:very_good_analysis/analysis_options.5.1.0.yaml
135 changes: 135 additions & 0 deletions packages/flame_steering_behaviors/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/*

# Visual Studio Code related
.classpath
.project
.settings/
.vscode/*

# Flutter repo-specific
/bin/cache/
/bin/mingit/
/dev/benchmarks/mega_gallery/
/dev/bots/.recipe_deps
/dev/bots/android_tools/
/dev/docs/doc/
/dev/docs/flutter.docs.zip
/dev/docs/lib/
/dev/docs/pubspec.yaml
/dev/integration_tests/**/xcuserdata
/dev/integration_tests/**/Pods
/packages/flutter/coverage/
version

# packages file containing multi-root paths
.packages.generated

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
build/
flutter_*.png
linked_*.ds
unlinked.ds
unlinked_spec.ds
.fvm/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
**/android/key.properties
**/android/.idea/
*.jks

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/.last_build_id
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Coverage
coverage/

# Submodules
!pubspec.lock
packages/**/pubspec.lock

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Exceptions to the above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/dev/ci/**/Gemfile.lock
!.vscode/extensions.json
!.vscode/launch.json
!.idea/codeStyles/
!.idea/dictionaries/
!.idea/runConfigurations/

android/
ios/
macos/
windows/
linux/
web/
pubspec.lock
10 changes: 10 additions & 0 deletions packages/flame_steering_behaviors/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 9b2d32b605630f28625709ebd9d78ab3016b2bf6
channel: stable

project_type: app
Loading