#How do I get the bundle

1 messages · Page 1 of 1 (latest)

hollow yoke
#

How do I get the inner bundle from this ```rs
// Creates a tilemap
commands.entity(tilemap_entity).insert(TilemapBundle {
grid_size,
map_type,
size: map_size,
storage: tile_storage.clone(),
texture: TilemapTexture::Vector(texture_handle.clone()),
tile_size,
transform: get_tilemap_center_transform(&map_size, &grid_size, &map_type, z),
..Default::default()
});

#

How do I get the bundle

vapid estuary
# hollow yoke How do I get the inner bundle from this ```rs // Creates a tilemap comma...

What do you mean, get the inner bundle? This bundle seem to contain only components.
When you're inserting the bundle to an entity, you can define the inner components/bundles one by one, or rely on the default.
What it does is it inserts all of the components inside the bundle to the entity, the bundle itself is not inserted directly, it's not a component.
You can then query your entity by those components in a system: Query<&Transform, With<TilemapType>>

hollow yoke
#

In that system without querying it

vapid estuary
#

@hollow yoke In the same system it's being inserted? What do you want to do with it?
You could just assign it to a variable and modify it before inserting it, or cloning it, are you looking for something like that?

hollow yoke
vapid estuary
#

@hollow yoke You can store the Entity that the bundle is inserted to:

let tilemap_entity = commands.entity(tilemap_entity).insert(TilemapBundle {
    //[...]
}).id();
``` (note the `id()` at the end)

You can store that in a Resource or something else and then say you need the Transform (for example) of this entity in another system: `transform_query.get(entity).unwrap()` where `transform_query` is of type `Query<&Transform>`
#

But if you have only one typemap entity in your App, this should be your only entity with a TilemapType component, then something like Query<&Transform, With<TilemapType>> might be easier

hollow yoke
#

I have at least n amount of tile maps

#

0 < n < ∞