fix(kick_bomb): Add spawn kickbomb command to allow spawning from gameplay code without interfering with map hydration#968
Merged
MaxCWhitehead merged 1 commit intofishfolk:mainfrom Apr 15, 2024
Conversation
gameplay code without interfering with map hydration
DRuppFv
pushed a commit
to DRuppFv/jumpy
that referenced
this pull request
Apr 20, 2024
…eplay code without interfering with map hydration (fishfolk#968) `commands.add(KickBombCommand::spawn_kick_bomb(Some(entity), transform, kick_bomb_meta_handle)` may be used to spawn a kick bomb. - If entity is passed in it will initialize kick bomb components on this entity (mostly to support hydration from map elements), otherwise None will make it create an entity for you. - The handle is untyped handle (can use `handle.untyped()` to convert to this), it supports `Handle<ElementMeta>` or `Handle<KickBombMeta>` automatically. 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.
DRuppFv
pushed a commit
to DRuppFv/jumpy
that referenced
this pull request
Apr 20, 2024
…ishfolk#972) I broke hydration with in fishfolk#968, accidentally marked things as hydrated even when element was not kick bomb / spawning was skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
commands.add(KickBombCommand::spawn_kick_bomb(Some(entity), transform, kick_bomb_meta_handle)may be used to spawn a kick bomb.handle.untyped()to convert to this), it supportsHandle<ElementMeta>orHandle<KickBombMeta>automatically.This command adds a
KickBombHandlecontainingHandle<KickBombMeta>, this should be used to get meta for entities. The kick bomb systems now use this instead ofHandle<ElementMeta>.Gameplay systems were also updated such that usages of components
MapElementHydratedandDehydratedOutOfBounds(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_handlehelper function was added to help convert an untypedHandle<KickBombMeta>orHandle<ElementMeta>toHandle<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.