This makes SokobanPlugin "agnostic", meaning that it's no longer dependent on willos-graveyard, and could be extracted into its own crate. I think agnosticized plugins are partially good as they give us the opportunity to contribute the plugin to the wider bevy community, and partially good because they encourage good coding practices. The fact that the most central, core logic of the game can be completely decoupled from the rest of the game is a good sign that our organization and ECS practices aren't "tangled up" in any way.
Implementation
Agnosticization
Assumes that the user is spawning levels with bevy_ecs_ldtk.
Replace WilloMovementEvent with SokobanCommands. This allows users to command the plugin to move blocks, handling collisions, pushes, etc.
Add PushTracker marker component and PushEvent. Users can addPushTrackerto an entity so that, whenever that entity pushes another block, aPushEventis fired. Being pushed into pushing another entity will also causePushEvent`s.
Move Willo's push animation logic to willo module.
Remove scheduling restrictions that were only necessary for animation.
Move WallBundle LDtk registrations to new wall module.
Rewrite filters depending on willo-specific code to be sokoban-specific instead.
Move push translation logic to willo module.
Make plugin generic over its iyes_loopless state.
Add SokobanLayerIdentifier resource for defining which LDtk layer should be used for determining level bounds, tile size, etc.
Other improvements
Rename RigidBody to SokobanBlock, give it a nice API for bevy_ecs_ldtk users.
Improve error handling with appropriate warnings/expects.
Flesh out documentation.
Add iyes_loopless run criteria to system scheduling, which should improve performance
Add unit tests for push_collision_map_entry function.
Add unit tests for the entire plugin.
Probably some other stuff, but I can't remember it all...
Adding those tests is important, not just because these are the first tests in the entire game, but the chances that a PR introduced some game-breaking bugs are at an all-time high with this one.
Summary
This makes SokobanPlugin "agnostic", meaning that it's no longer dependent on willos-graveyard, and could be extracted into its own crate. I think agnosticized plugins are partially good as they give us the opportunity to contribute the plugin to the wider bevy community, and partially good because they encourage good coding practices. The fact that the most central, core logic of the game can be completely decoupled from the rest of the game is a good sign that our organization and ECS practices aren't "tangled up" in any way.
Implementation
Agnosticization
Assumes that the user is spawning levels with
bevy_ecs_ldtk
.WilloMovementEvent
withSokobanCommands
. This allows users to command the plugin to move blocks, handling collisions, pushes, etc.PushTracker
marker component andPushEvent. Users can add
PushTrackerto an entity so that, whenever that entity pushes another block, a
PushEventis fired. Being pushed into pushing another entity will also cause
PushEvent`s.willo
module.WallBundle
LDtk registrations to newwall
module.willo
module.iyes_loopless
state.SokobanLayerIdentifier
resource for defining whichLDtk
layer should be used for determining level bounds, tile size, etc.Other improvements
RigidBody
toSokobanBlock
, give it a nice API forbevy_ecs_ldtk
users.CollisionMap
type alias.push_collision_map_entry
function.CollisionMap
immutably inpush_collision_map_entry
function.flush_sokoban_commands
system.iyes_loopless
run criteria to system scheduling, which should improve performancepush_collision_map_entry
function.Adding those tests is important, not just because these are the first tests in the entire game, but the chances that a PR introduced some game-breaking bugs are at an all-time high with this one.