mirror of
https://github.com/bevyengine/bevy
synced 2024-11-23 13:13:49 +00:00
Re-order systems
This commit is contained in:
parent
bb4e13e663
commit
b606aa88e1
1 changed files with 28 additions and 28 deletions
|
@ -99,6 +99,34 @@ fn spawn_inventory_slot(mut commands: Commands, inventory: Single<Entity, With<I
|
|||
});
|
||||
}
|
||||
|
||||
/// Spawn two arbitrary inventory items. Here we'll just pick the first two slots.
|
||||
fn add_items_to_inventory(
|
||||
asset_server: Res<AssetServer>,
|
||||
mut commands: Commands,
|
||||
slots: Query<Entity, With<InventorySlot>>,
|
||||
) {
|
||||
let paths = [
|
||||
"textures/rpg/props/generic-rpg-loot01.png",
|
||||
"textures/rpg/props/generic-rpg-loot02.png",
|
||||
];
|
||||
for (i, slot) in slots.iter().enumerate().take(2) {
|
||||
commands.entity(slot).with_children(|parent| {
|
||||
parent
|
||||
.spawn((
|
||||
Draggable,
|
||||
// This node serves solely to be dragged! It provides the transform, using required
|
||||
// components.
|
||||
Node::default(),
|
||||
ImageNode::new(asset_server.load(paths[i])),
|
||||
// TODO: seems clumsy, better solution?
|
||||
ZIndex(99),
|
||||
))
|
||||
.observe(drag_start())
|
||||
.observe(drag_end());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// This observer detects the beginning of a drag-and-drop motion and takes care of tasks such as
|
||||
/// detaching the target from its parent and allowing the node to be moved.
|
||||
fn drag_start() -> impl Fn(
|
||||
|
@ -206,34 +234,6 @@ fn drag_inventory_items(
|
|||
item_node.top = Val::Px(cursor_pos.y);
|
||||
}
|
||||
|
||||
/// Spawn two arbitrary inventory items. Here we'll just pick the first two slots.
|
||||
fn add_items_to_inventory(
|
||||
asset_server: Res<AssetServer>,
|
||||
mut commands: Commands,
|
||||
slots: Query<Entity, With<InventorySlot>>,
|
||||
) {
|
||||
let paths = [
|
||||
"textures/rpg/props/generic-rpg-loot01.png",
|
||||
"textures/rpg/props/generic-rpg-loot02.png",
|
||||
];
|
||||
for (i, slot) in slots.iter().enumerate().take(2) {
|
||||
commands.entity(slot).with_children(|parent| {
|
||||
parent
|
||||
.spawn((
|
||||
Draggable,
|
||||
// This node serves solely to be dragged! It provides the transform, using required
|
||||
// components.
|
||||
Node::default(),
|
||||
ImageNode::new(asset_server.load(paths[i])),
|
||||
// TODO: seems clumsy, better solution?
|
||||
ZIndex(99),
|
||||
))
|
||||
.observe(drag_start())
|
||||
.observe(drag_end());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Display instructions.
|
||||
fn spawn_text(mut commands: Commands) {
|
||||
commands.spawn((
|
||||
|
|
Loading…
Reference in a new issue