Skip to content

Conversation

janis-bhm
Copy link
Contributor

relevant issue: #20976

Solution

In order to spawn bundles inside MovingPtrs alongside other bundles, we need to be able to name MovingPtr as a bundle, which the new associated type Name on Bundle allows. This type is basically a canonicalized bundle name-type that allows types like SpawnRelatedBundle to appear to the Bundles as if they were the bundle they are wrapping: R::RelationshipTarget. (I need to write tests for this).

Other parts of the engine, like observers, rely on Bundle being 'static in order to pass around the type without being constrained by lifetimes, which is why I've renamed Bundle to BundleImpl and made trait Bundle: BundleImpl + 'static.
Not sure how much I like this personally.
Observers only use the associated trait functions of Bundle which shouldn't be affected by the lifetime of the type implementing Bundle (I think).
An alternative would be to enforce Bundle::Name to impl Bundle itself (which it does, since it's just a tuple of bundles) and have the same components/component order as Self so that Bundles methods are available 'static (though using DynamicBundle this way would certainly be unsafe). That could allow types carrying Bundles in phantom datas to use the associated functions for component order and ids.

@janis-bhm janis-bhm added A-ECS Entities, components, systems, and events D-Unsafe Touches with unsafe code in some way S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Needs-Testing Testing must be done before this is safe to merge C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times labels Sep 12, 2025
@janis-bhm janis-bhm closed this Oct 7, 2025
@janis-bhm janis-bhm deleted the movingptr-bundle-impl-bundle branch October 7, 2025 13:01
@janis-bhm janis-bhm restored the movingptr-bundle-impl-bundle branch October 7, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times D-Unsafe Touches with unsafe code in some way S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Needs-Testing Testing must be done before this is safe to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant