feat: Implemented basic item drag-and-drop

- Added bundle names
- Added system to update bundle names with entity name
This commit is contained in:
Alexey 2026-03-11 22:40:17 +03:00
commit a462c64786
4 changed files with 56 additions and 18 deletions

View file

@ -20,6 +20,7 @@ fn player_bundle(asset_server: &Res<AssetServer>) -> impl Bundle {
Action::default_input_map(),
Inventory::new(UVec2::new(4, 4)),
ActiveInventory,
Name::new("Player"),
)
}
@ -33,6 +34,7 @@ pub fn try_insert_item(
inventory_query: Query<(Entity, &Inventory, Option<&Children>)>,
) {
let mut item = Item::new(UVec2::new(1, 1));
let name = Name::new(format!("Item {}x{}", item.size.x, item.size.y));
for (entity, inventory, children) in inventory_query {
let children = match children {
Some(children) => &children[..],
@ -45,7 +47,7 @@ pub fn try_insert_item(
}
item.position = Some(position);
info!("Spawning item {item:?}");
commands.entity(entity).with_child(item);
commands.entity(entity).with_child((item, name));
},
None => {
warn!("Inventory does not have space for {}", item.size);