Skip to content

Update to bevy 0.16-dev#428

Merged
Shatur merged 52 commits into
masterfrom
bevy-0.16-dev
Apr 26, 2025
Merged

Update to bevy 0.16-dev#428
Shatur merged 52 commits into
masterfrom
bevy-0.16-dev

Conversation

@Shatur
Copy link
Copy Markdown
Contributor

@Shatur Shatur commented Mar 7, 2025

Summary of changes:

  • Changes due to 0.16 update:
    • Replace all Trigger::entity with Trigger::target.
    • The Component trait now requires a Mutability type.
    • Minor import changes.
    • Replace never_param_warn on systems with an explicit check. The panicking behavior now depends on system params.
    • Replace postcard::Result with the new Result type from Bevy. It's much more flexible; I can define proper error messages in both the library and user code.
    • Update hooks that now accept HookContext instead of separate arguments.
    • The EntityMapper trait is now a bit different: map_entity is now called get_mapped and contains the new set_mapped method. I can't implement it for structs that hold references, so I put an unimplemented! stub. Bevy does the same. It's not really elegant - maybe we'll figure something out later on the Bevy side.
    • Deprecate replicate_mapped and related functions. Now all components have a method to map entities. Events still require mapping.
    • Replace manual MappedEvent implementations with the derive macro.
    • Remove parent_sync. It's no longer needed; users can now just replicate ChildOf.
    • single, which we use in tests, now returns Result, so I added unwraps.
  • no_std support:
    • Replace all std usage with core and enable corresponding lints.
    • Auto-enable usage of portable-atomic for bytes, similar to what Bevy does for portable-atomic itself.
    • Use log directly since bevy_log doesn't support no_std yet. The issue is caused by the tracing dependency. Bevy also uses log directly in all no_std crates; it's compatible with tracing, so there's no effect for users.
    • Add a compilation check for GBA to CI.
    • We can't mention Transform in docs since we are no_std now. There was only a single place or two. I just rewrote them a bit. Doc-examples are fine since they use dev-dependencies.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 20, 2025

Codecov Report

Attention: Patch coverage is 78.37838% with 32 lines in your changes missing coverage. Please review.

Project coverage is 79.84%. Comparing base (ef6d9f5) to head (bb7ee53).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/server.rs 61.29% 12 Missing ⚠️
src/shared/event/server_event.rs 50.00% 4 Missing ⚠️
src/shared/event/client_event.rs 62.50% 3 Missing ⚠️
src/shared/event/ctx.rs 50.00% 3 Missing ⚠️
src/server/replication_messages/mutations.rs 92.59% 2 Missing ⚠️
...ed/replication/replication_registry/command_fns.rs 81.81% 2 Missing ⚠️
...hared/replication/replication_registry/rule_fns.rs 71.42% 2 Missing ⚠️
src/scene.rs 50.00% 1 Missing ⚠️
src/shared/event/server_trigger.rs 0.00% 1 Missing ⚠️
src/shared/replication/replication_registry/ctx.rs 75.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #428      +/-   ##
==========================================
- Coverage   80.30%   79.84%   -0.46%     
==========================================
  Files          53       52       -1     
  Lines        2797     2774      -23     
==========================================
- Hits         2246     2215      -31     
- Misses        551      559       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Shatur Shatur marked this pull request as ready for review April 15, 2025 16:46
@Shatur Shatur requested a review from UkoeHB April 15, 2025 16:46
Comment thread CHANGELOG.md Outdated
Shatur and others added 13 commits April 17, 2025 00:41
* Use more explicit variable name

* Remove `removals_id` into `removal_ids`

* Preserve removals even when the component is immediately inserted

To avoid inconsistent triggers behavior between the server and client.
Just define directly in main. Doesn't make much sense to create a plugin for an example.
During the migration to 0.16, I added a few workarounds related to `hashbrown` to make the code compile.
These issues have been fixed in the latest Bevy RC: bevyengine/bevy#18694
So we can now remove those workarounds.
Just an internal rename. I think it makes the intent clearer.
This will better fit the upcoming relationships support.
* Allow markers to be immutable

* Add support for immutable components

Immutable components were introduced in Bevy via: bevyengine/bevy#16372
These components can only be changed via re-insertion. This allows users to enforce invariants through triggers and hooks.

When porting to 0.16, I initially added a `Mutability = Mutable` constraint.
To support immutable components, I replaced this constraint with the `MutWrite` trait.
It is implemented for both `Mutable` and `Immutable` markers to select the appropriate write function.
For `Immutable` components, this function always performs insertion.

* Update src/shared/replication/replication_registry/command_fns.rs

Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com>

* Add reinsertion test

* Apply clippy suggestions

---------

Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com>
- Rename into `Updates` and `Mutations`. Shorter and these components
  aren't messages. We actually create messages from them.
- Use shorter methods in `Mutations`. Things like
  `mutations.add_mutated_entity` looks too redundant.
- In `Updates` I made few names more explicit since it accumulates not
  only changes.
- Use the variable name `changes` when referring to `ChangeRanges`.
@Shatur Shatur merged commit c21198f into master Apr 26, 2025
@Shatur Shatur deleted the bevy-0.16-dev branch April 26, 2025 11:56
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.

2 participants