fishfolk / jumpy

Tactical 2D shooter in fishy pixels style. Made with Rust-lang 🦀 and Bevy 🪶
https://fishfolk.org/games/jumpy/
Other
1.59k stars 116 forks source link

fix(kick_bomb): Add spawn kickbomb command to allow spawning from gameplay code without interfering with map hydration #968

Closed MaxCWhitehead closed 2 months ago

MaxCWhitehead commented 2 months ago

commands.add(KickBombCommand::spawn_kick_bomb(Some(entity), transform, kick_bomb_meta_handle) may be used to spawn a kick bomb.

This command adds a KickBombHandle containing Handle<KickBombMeta>, this should be used to get meta for entities. The kick bomb systems now use this instead of Handle<ElementMeta>.

Gameplay systems were also updated such that usages of components MapElementHydrated and DehydratedOutOfBounds (things specific to map spawned kickbombs) are optionally used, meaning these systems still run for gameplay spawned kickbombs missing these components.

Under the hood, try_cast_meta_handle helper function was added to help convert an untyped Handle<KickBombMeta> or Handle<ElementMeta> to Handle<KickBombMeta>. This function is generic and may be used for other gameplay items that we refactor to add spawn commands to separate item spawn logic from map spawning.

I tested this and the map spawned kickbombs will still respawn after use, but the gameplay spawned ones do not.