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

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

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

MaxCWhitehead
Copy link
Collaborator

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.

gameplay code without interfering with map hydration
@MaxCWhitehead MaxCWhitehead added this pull request to the merge queue Apr 14, 2024
Merged via the queue into fishfolk:main with commit 51958d2 Apr 15, 2024
8 checks passed
@MaxCWhitehead MaxCWhitehead deleted the kick_bomb_spawning branch April 15, 2024 00:04
github-merge-queue bot pushed a commit that referenced this pull request Apr 15, 2024
…972)

I broke hydration with in #968, accidentally marked things as hydrated
even when element was not kick bomb / spawning was skipped.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant